text
stringlengths 0
3.34M
|
---|
##PROJET: Manipulation de polynomes
#1) Quelle serait la représentation creuse sous forme de liste du polynome 2+x^4−3x^5 ? list(c(2, 0), c(1, 4), c(-3, 5))
#2) Et sa représentation dense ? c(2, 0, 0, 0, 1, -3)
#3) Quand choisit-on de travailler plutot en représentation creuse ? Quand on souhaite travailler avec les degrés
#4) Quelle est la représentation la plus économique en terme d’espace mémoire ? Representation dense
# SOURCES :
# http://www.i3s.unice.fr/~malapert/R/pdf/A4-Polynomes.pdf
# https://www.youtube.com/watch?v=Z393AcN_Gz0 (Horner methode comprehension)
# Pour executer le programme faire Rscript ./polynomes.r
# Ou l'executer dans Rstudio.
# Va executer toutes les demonstrations de l'activite.
# Vous devez avoir installer le package 'polynom' sinon il y aura une erreur.
# Pour utiliser les fonctions une a une
# (cf. Activite_manipulation_des_polynomes.pdf)
# qui est une documentation du code.
p <- list(c(2,5), c(-1,4),c(-2,1))
q <- list(c(1,4), c(7,2),c(-1,0))
# indique si le polynome est nul
is_poly0 <- function(p) length(p) == 0
# renvoyant le degre d’un monome ou d’un polynome.
degre <- function(mp) {
if(is_poly0(mp)) return(-Inf)
if (is.list(mp)) mp <- mp[[1]]
if (is.vector(mp) && length(mp) == 2) return(mp[2])
else return(NULL)
}
# renvoyant le coefficient d’un monome ou d’un polynome.
coeff <- function(mp) {
if(is_poly0(mp)) return(-Inf)
if (is.list(mp)) mp <- mp[[1]]
if (is.vector(mp) && length(mp) == 2) return(mp[1])
else return(NULL)
}
# renvoyant une chaîne de caractères représentant le polynome creux sous la forme ∑aiX^i
poly2str <- function(p){
if(length(p) == 0){
return ("")
}
acc = ""
for(e in p){
acc = paste(acc, e[1], "*X^", e[2], " + ", sep="")
}
return(substr(acc, 0, nchar(acc) - 3))
}
# multiplication par un scalaire k d’un polynome
mult_ext <- function(p, k) {
return(lapply(p, function(x) c(k*x[1], x[2])))
}
# transforme un polynome plein en un polynome creux
make_poly <- function(x) {
poly_creux <- list()
power <- length(x) - 1
j <- 1
for (i in length(x):1) {
if (x[i] != 0) {
poly_creux[[j]] <- c(x[i], power)
j <- j + 1
}
power <- power - 1
}
return(poly_creux)
}
# générant un polynome aléatoire de degré inférieur à n
# et dont les coefficients sont tirés dans le vecteur coeffs
rand_poly <- function(n, coeffs) {
poly <- list()
len_poly <- sample(1:n-1, 1)
j <- 1
for (i in len_poly:1) {
rand_coeff <- sample(coeffs, 1)
if (rand_coeff != 0) {
poly[[j]] <- c(rand_coeff, i)
j <- j + 1
}
}
if (length(poly) == 0) return(rand_poly(n, coeffs))
return(poly)
}
# trie une liste de monomes par degré décroissant
sort_monoms <- function(p) {
for (i in 1:length(p)) {
for (j in i:length(p)) {
if (p[[i]][2] < p[[j]][2]) {
x <- p[[i]]
p[[i]] <- p[[j]]
p[[j]] <- x
}
}
}
return(p)
}
# somme les termes de même degré, et supprime les termes dont le coefficient est nulle
merge_monoms <- function(p) {
monoms <- list(p[[1]])
l_p <- length(p)
i <- 2
j <- 1
# Additionne les monoms entre eux
while (i <= l_p) {
if (monoms[[j]][2] == p[[i]][2] && i != j) {
monoms[[j]] <- c(monoms[[j]][1] + p[[i]][1], p[[i]][2])
} else {
j <- j + 1
monoms[[j]] <- p[[i]]
}
i <- i + 1
}
k <- 1
# Enlève les monoms de coeff nulle
while (k <= length(monoms)) {
if (monoms[[k]][1] == 0) {
monoms[[k]] <- NULL
next
}
k <- k + 1
}
return(monoms)
}
# Addition de deux polynomes
add <- function(p, q) {
combine <- c(p, q) # combine 2 listes
return(merge_monoms(sort_monoms(combine)))
}
# Soustraction de 2 polynomes
sub <- function(p,q) add(p,mult_ext(q,-1))
# polynome dérivé du polynome p
deriv <- function(p) {
drv <- list()
for (i in p) {
if (i[[2]] == 1) {
drv <- c(drv, list(c(i[[1]], 0)))
}
else if (i[[2]] == 0) {
i <- NULL
}
else {
drv <- c(drv, list(c(i[[2]] * i[[1]], i[[2]] - 1)))
}
}
return(drv)
}
# primitive du polynome p
integ <- function(p) {
integ <- list()
for (c in p) {
integ <- c(integ, list(c(c[[1]] / (c[[2]] + 1), c[[2]] + 1)))
}
return(integ)
}
# Multiplication de 2 monomes
mult_monoms <- function(m1, m2) {
return(list(c(m1[1] * m2[1], m1[2] + m2[2])))
}
# Multiplication d'un polynome par un monome
mult_poly_mono <- function(p, m) {
return(lapply(p, function(x) c(m[1]*x[1], m[2] + x[2])))
}
# Multiplication interne de deux polynomes
mult <- function(p, q) {
res <- list()
# S'appuyant sur la methode vu dans le cours de l'activite
for (monom in q) {
res <- add(res, mult_poly_mono(p, monom))
}
return(res)
}
# Valeur d'un polynome en un point x version naive
polyval <- function(p, x) {
res <- c()
for (monom in p) {
res <- c(res, c(monom[1] * x ** monom[2]))
}
return(sum(res))
}
# Fonction personnel pour faire polyhorn
# qui convertir un polynome creux a dense
creux_to_dense <- function(p) {
degre <- degre(p)
res <- c()
old <- p[[1]][2]
i <- 1
j <- 1
while (i <= length(p)) {
if (old - p[[j]][2] >= 2) {
res <- c(res, 0)
old <- old - 1
next
}
else {
res <- c(res, p[[j]][1])
j <- j + 1
}
old <- p[[i]][2]
i <- i + 1
}
adjust <- degre - length(res) + 1
if (adjust > 0) res <- c(res, numeric(adjust))
return(rev(res))
}
# Valeur d'un polynome en un point x version Horner
polyhorn <- function(p, x) {
# Verification que le polynome p est un polynome creux, si oui conversion en dense
if (is.list(p)) p <- creux_to_dense(p)
len_p <- length(p)
res <- p[[len_p]][1]
for (i in (len_p-1):1) {
res <- (res * x) + p[[i]][1]
}
return(res)
}
# construit la fonction polynome associee a p
fpoly <- function(p) {
return( function(x) {polyval(p, x)}) # on peut faire pareil avec polyhorn
}
# dessine les courbes de la primitive, derivee et du polynome
dessiner <- function(p, x) {
cols <- c("green", "red", "blue")
finteg <- fpoly(integ(p))
fderiv <- fpoly(deriv(p))
fpoly_p <- fpoly(p)
integ <- sapply(x, finteg)
derivate <- sapply(x, fderiv)
poly_p <- sapply(x, fpoly_p)
matplot(x, cbind(integ, derivate, poly_p), t="l", lwd=1.5, lty=1, xlab="x", ylab="y", col=cols)
legend("topleft", inset=.05, legend=c("Primitive", "Derivee", "Polynome"), horiz=FALSE, lwd=2, lty=1, col=cols)
}
# tout les cas de test de l'activite polynome
# sont effectue dans cette fonction
demonstration <- function() {
stopifnot("2*X^5 + -1*X^4 + -2*X^1" == poly2str(p))
stopifnot(poly2str(mult_ext(p,-2)) == "-4*X^5 + 2*X^4 + 4*X^1")
stopifnot(poly2str(make_poly(c(0, -2, 0, 0, -1, 2))) == "2*X^5 + -1*X^4 + -2*X^1")
stopifnot(poly2str(make_poly(c(-1, 0, -7, 0, 1))) == "1*X^4 + -7*X^2 + -1*X^0")
stopifnot(poly2str(add(p, list())) == "2*X^5 + -1*X^4 + -2*X^1")
stopifnot(poly2str(add(list(), q)) == "1*X^4 + 7*X^2 + -1*X^0")
stopifnot(poly2str(add(p,q)) == "2*X^5 + 7*X^2 + -2*X^1 + -1*X^0")
stopifnot(poly2str(sub(p,p)) == "")
stopifnot(poly2str(sub(p,q)) == "2*X^5 + -2*X^4 + -7*X^2 + -2*X^1 + 1*X^0")
stopifnot(poly2str(sub(q,p)) == "-2*X^5 + 2*X^4 + 7*X^2 + 2*X^1 + -1*X^0")
stopifnot(poly2str(integ(p)) == "0.333333333333333*X^6 + -0.2*X^5 + -1*X^2")
stopifnot(poly2str(integ(q)) == "0.2*X^5 + 2.33333333333333*X^3 + -1*X^1")
stopifnot(poly2str(deriv(p)) == "10*X^4 + -4*X^3 + -2*X^0")
stopifnot(poly2str(deriv(q)) == "4*X^3 + 14*X^1")
p1 <- make_poly(c(1,1))
p2 <- make_poly(c(-1,1))
p3 <- make_poly(c(1,-1,1))
stopifnot(poly2str(mult(p1,p2)) == "1*X^2 + -1*X^0")
stopifnot(poly2str(mult(p3,p3)) == "1*X^4 + -2*X^3 + 3*X^2 + -2*X^1 + 1*X^0")
cat('---TEST CASES DE L\'ACTIVITE POLYNOME---\n')
cat('TEST CASE : poly2str(p) == "2*X^5 + -1*X^4 + -2*X^1" TRUE\n')
cat('TEST CASE : poly2str(mult_ext(p,-2)) == "-4*X^5 + 2*X^4 + 4*X^1" TRUE\n')
cat('TEST CASE : poly2str(make_poly(c(0, -2, 0, 0, -1, 2))) == "2*X^5 + -1*X^4 + -2*X^1" TRUE\n')
cat('TEST CASE : poly2str(make_poly(c(-1, 0, -7, 0, 1))) == "1*X^4 + -7*X^2 + -1*X^0" TRUE\n')
cat('TEST CASE : poly2str(rand_poly(5,0:3)) = ', poly2str(rand_poly(5,0:3)), '\n')
cat('TEST CASE : poly2str(rand_poly(10,0:1)) = ', poly2str(rand_poly(10,0:1)), '\n')
cat('TEST CASE : poly2str(add(p, list())) == "2*X^5 + -1*X^4 + -2*X^1" TRUE\n')
cat('TEST CASE : poly2str(add(list(), q)) == "1*X^4 + 7*X^2 + -1*X^0" TRUE\n')
cat('TEST CASE : poly2str(add(p,q)) == "2*X^5 + 7*X^2 + -2*X^1 + -1*X^0" TRUE\n')
cat('TEST CASE : poly2str(sub(p,p)) == "" TRUE\n')
cat('TEST CASE : poly2str(sub(p,q)) == "2*X^5 + -2*X^4 + -7*X^2 + -2*X^1 + 1*X^0" TRUE\n')
cat('TEST CASE : poly2str(sub(q,p)) == "-2*X^5 + 2*X^4 + 7*X^2 + 2*X^1 + -1*X^0" TRUE\n')
cat('TEST CASE : poly2str(integ(p)) == "0.333333333333333*X^6 + -0.2*X^5 + -1*X^2" TRUE\n')
cat('TEST CASE : poly2str(integ(q)) == "0.2*X^5 + 2.33333333333333*X^3 + -1*X^1" TRUE\n')
cat('TEST CASE : poly2str(deriv(p)) == "10*X^4 + -4*X^3 + -2*X^0" TRUE\n')
cat('TEST CASE : poly2str(deriv(q)) == "4*X^3 + 14*X^1" TRUE\n')
cat('TEST CASE : poly2str(mult(p1,p2)) == "1*X^2 + -1*X^0" TRUE\n')
cat('TEST CASE : poly2str(mult(p3,p3)) == "1*X^4 + -2*X^3 + 3*X^2 + -2*X^1 + 1*X^0" TRUE\n')
cat('---TEST POLYNOMES P EN UN POINT X---\n')
cat('UTILISATION DE POLYVAL\n')
print(poly2str(p))
for(i in -1:1) {
print(paste("p(",i,") = ",polyval(p,i), sep=""))
}
print(poly2str(q))
for(i in -1:1) {
print(paste("q(",i,") = ",polyval(q,i), sep=""))
}
cat('UTALISATION DE POLYHORN\n')
print(poly2str(p))
for(i in -1:1) {
print(paste("p(",i,") = ",polyhorn(p,i), sep=""))
}
print(poly2str(q))
for(i in -1:1) {
print(paste("q(",i,") = ",polyhorn(q,i), sep=""))
}
cat('dessiner(p, x) -> (voir plot)\n')
x <- seq(-2,4,length.out=1000)
p1 <- make_poly(c(-1,-1,1))
dessiner(p1,x)
}
demonstration()
### N'AFFICHE PAS COMME DANS L'EXEMPLE DE L'ACTIVITE MAIS A LES MEMES RESULTAT
### EN COMPARANT vh, vn et vr ci-dessous (sachant que polyhorn et polyval fonctionnent bien avec de multiple tests)
x <- seq(2-0.02,2.02,length.out=1001)
vec <- c(-2,0,1)
## p(x) = (x^2-2)^16
p1 <- make_poly(vec)
for(i in 1:4) {
p1 <- mult(p1,p1)
}
## Evaluate p using our methods (observed)
vn <- sapply(x, polyval, p=p1)
vh <- sapply(x, polyhorn, p=p1)
library("polynom")
## Evaluate p using R package (expected)
pr <-as.polynomial(c(-2,0,1))
## p is an R object ! I directly used the power operator.
pr <- pr ** 16
## I also use a generic function
vr <- predict(pr,x)
## Last, visualize the results
cols <- c("red", "gold")
matplot(x, cbind(vn-vr,vh-vr),t="l", lwd=2, lty=1,col=cols, xlab="x",ylab="P(x)-P^R(x)")
legend("topleft", inset=.05, legend=c("Naive", "Horner"), horiz=TRUE, lwd=2, lty=1, col=cols)
|
module Algebra
import public Algebra.ZeroOneOmega
import public Algebra.Semiring
import public Algebra.Preorder
%default total
public export
RigCount : Type
RigCount = ZeroOneOmega
export
showCount : RigCount -> String
showCount = elimSemi "0 " "1 " (const "")
|
#' match arg to choices
#'
#' Wrapper around \link[base]{match.arg} that defaults to ignoring case and
#' trimming white space
#'
#' @param arg a character vector (of length one unless several.ok is TRUE) or
#' NULL
#' @param choices a character vector of candidate values
#' @param multiple logical specifying if arg should be allowed to have more than
#' one element. Defaults to FALSE
#' @param ignore_case logical indicating whether to ignore capitalization.
#' Defaults to TRUE
#' @param trim_ws logical indicating whether to trim surrounding white space.
#' Defaults to TRUE
#' @return Value(s) matched via partial matching.
#' @author Michael Wayne Kearney
#' @export
match_arg <- function(arg, choices,
multiple = FALSE,
ignore_case = TRUE,
trim_ws = TRUE) {
if (missing(choices)) {
formal.args <- formals(sys.function(sysP <- sys.parent()))
choices <- eval(formal.args[[as.character(substitute(arg))]],
envir = sys.frame(sysP))
}
if (is.null(arg))
return(choices[1L])
else if (!is.character(arg))
stop("'arg' must be NULL or a character vector")
if (!multiple) {
if (identical(arg, choices))
return(arg[1L])
if (length(arg) > 1L)
stop("'arg' must be of length 1")
}
else if (length(arg) == 0L)
stop("'arg' must be of length >= 1")
if (trim_ws) {
arg <- trim_ws(arg)
}
if (ignore_case) {
arg <- tolower(arg)
choices_ <- choices
choices <- tolower(choices)
}
i <- pmatch(arg, choices, nomatch = 0L, duplicates.ok = TRUE)
if (all(i == 0L))
stop(gettextf("'arg' should be one of %s",
paste(dQuote(choices), collapse = ", ")),
domain = NA)
i <- i[i > 0L]
if (!multiple && length(i) > 1)
stop("there is more than one match in 'match.arg'")
if (ignore_case) {
choices <- choices_
}
choices[i]
}
#' Add defaults to argument list
#'
#' Adds parameters to argument list if list does not already include those
#' parameters
#'
#' @param args Argument list
#' @param ... Other named arguments are added (depending on override) and
#' returned with args
#' @param override Logical indicating whether to override existing values in
#' args with the values provided as a named argument here.
#' @return Argument list with updated values.
#' @author Michael Wayne Kearney
#' @examples
#' ## arg list
#' args <- list(x = 5, y = TRUE, z = FALSE)
#'
#' ## add arg defaults
#' add_arg_if(args, w = TRUE, z = TRUE)
#'
#' ## add arg defaults, overriding any previous values
#' add_arg_if(args, x = 10, z = TRUE, override = TRUE)
#'
#' @export
add_arg_if <- function(args, ..., override = FALSE) {
dots <- list(...)
if (length(dots) == 0) return(args)
if (length(args) == 0) return(dots)
## if already specified, don't update that arg
if (!override) {
dots <- dots[!names(dots) %in% names(args)]
}
if (length(dots) == 0) return(args)
for (i in names(dots)) {
args[[i]] <- dots[[i]]
}
args
}
|
theory TrivialPursuit
imports "Z_Machines.Z_Machine"
begin
lit_vars
enumtype Player = one | two | three | four | five | six
enumtype Colour = blue | pink | yellow | brown | green | orange
definition Colour :: "Colour set" where
"Colour = UNIV"
alphabet LocalScore =
s :: "Colour set"
record_default LocalScore
alphabet GlobalScore =
score :: "Player \<Zpfun> LocalScore"
record_default GlobalScore
zoperation AnswerLocal =
params c \<in> Colour
pre "c \<in> s"
update "[s \<leadsto> s \<union> {c}]"
chantype chan1 =
answer1 :: "Colour"
chantype chan =
answer :: "Player \<times> Colour"
definition "Answer = operation answer1 AnswerLocal"
definition AnswerGlobal :: "(chan, GlobalScore) htree" where
[code_unfold]: "AnswerGlobal = operation answer (promote_op (\<lambda> p. (score[p])\<^sub>v) AnswerLocal)"
definition "TrivialPursuit = process [\<leadsto>] (loop (Answer \<box> Stop))"
lemma "AnswerGlobal = undefined"
apply (simp add: AnswerGlobal_def operation_def)
oops
declare operation_def [code_unfold]
declare wp [code_unfold]
declare unrest [code_unfold]
export_code TrivialPursuit in Haskell module_name TrivialPursuit (string_classes)
term "AnswerLocal c \<Up>\<Up> score[p]"
end
|
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: work_gga_c *)
(* prefix:
gga_x_n12_params *params;
assert(p->params != NULL);
params = (gga_x_n12_params * )(p->params);
*)
omega_x := 2.5:
gamma_x := 0.004:
rss := (rs, z) -> rs * (2/(1 + z))^(1/3):
vx := rs -> 1/(1 + (1/(RS_FACTOR*omega_x))*rs):
ux := x -> gamma_x*x^2/(1 + gamma_x*x^2):
FN12 := (rs, x) ->
+ add(1*params_a_CC_0_[i+1]*ux(x)^i, i=0..3)
+ add(1*params_a_CC_1_[i+1]*ux(x)^i, i=0..3) * vx(rs)
+ add(1*params_a_CC_2_[i+1]*ux(x)^i, i=0..3) * vx(rs)^2
+ add(1*params_a_CC_3_[i+1]*ux(x)^i, i=0..3) * vx(rs)^3:
f_n12 := (rs, z, xt, xs0, xs1) -> -X_FACTOR_C*RS_FACTOR*(
+ (1 + z)*FN12(rss(rs, z), xs0)/(2*rss(rs, z))
+ (1 - z)*FN12(rss(rs, -z), xs1)/(2*rss(rs, -z))
):
f := (rs, z, xt, xs0, xs1) -> f_n12(rs, z, xt, xs0, xs1):
|
module GPLikelihoods
using Distributions
using Functors
using LinearAlgebra
using Random
using StatsFuns
export BernoulliLikelihood,
CategoricalLikelihood,
GaussianLikelihood,
HeteroscedasticGaussianLikelihood,
PoissonLikelihood,
ExponentialLikelihood,
GammaLikelihood
export Link,
ChainLink,
ExpLink,
LogLink,
InvLink,
SqrtLink,
SquareLink,
LogitLink,
LogisticLink,
ProbitLink,
NormalCDFLink,
SoftMaxLink
# Inverses
include("inverse.jl")
# Links
include("links.jl")
# Likelihoods
abstract type AbstractLikelihood end
include("likelihoods/bernoulli.jl")
include("likelihoods/categorical.jl")
include("likelihoods/gaussian.jl")
include("likelihoods/poisson.jl")
include("likelihoods/gamma.jl")
include("likelihoods/exponential.jl")
end # module
|
{-# OPTIONS --without-K #-}
open import Base
open import Algebra.Groups
open import Integers
module Algebra.GroupIntegers where
_+_ : ℤ → ℤ → ℤ
O + m = m
pos O + m = succ m
pos (S n) + m = succ (pos n + m)
neg O + m = pred m
neg (S n) + m = pred (neg n + m)
-_ : ℤ → ℤ
- O = O
- (pos m) = neg m
- (neg m) = pos m
+-succ : (m n : ℤ) → succ m + n ≡ succ (m + n)
+-succ O n = refl _
+-succ (pos m) n = refl _
+-succ (neg O) n = ! (succ-pred n)
+-succ (neg (S m)) n = ! (succ-pred _)
+-pred : (m n : ℤ) → pred m + n ≡ pred (m + n)
+-pred O n = refl _
+-pred (pos O) n = ! (pred-succ n)
+-pred (pos (S m)) n = ! (pred-succ _)
+-pred (neg m) n = refl _
+-assoc : (m n p : ℤ) → (m + n) + p ≡ m + (n + p)
+-assoc O n p = refl _
+-assoc (pos O) n p = +-succ n p
+-assoc (pos (S m)) n p = +-succ (pos m + n) p ∘ map succ (+-assoc (pos m) n p)
+-assoc (neg O) n p = +-pred n p
+-assoc (neg (S m)) n p = +-pred (neg m + n) p ∘ map pred (+-assoc (neg m) n p)
O-right-unit : (m : ℤ) → m + O ≡ m
O-right-unit O = refl _
O-right-unit (pos O) = refl _
O-right-unit (pos (S m)) = map succ (O-right-unit (pos m))
O-right-unit (neg O) = refl _
O-right-unit (neg (S m)) = map pred (O-right-unit (neg m))
succ-+-right : (m n : ℤ) → succ (m + n) ≡ m + succ n
succ-+-right O n = refl _
succ-+-right (pos O) n = refl _
succ-+-right (pos (S m)) n = map succ (succ-+-right (pos m) n)
succ-+-right (neg O) n = succ-pred n ∘ ! (pred-succ n)
succ-+-right (neg (S m)) n = (succ-pred (neg m + n) ∘ ! (pred-succ (neg m + n)))
∘ map pred (succ-+-right (neg m) n)
pred-+-right : (m n : ℤ) → pred (m + n) ≡ m + pred n
pred-+-right O n = refl _
pred-+-right (pos O) n = pred-succ n ∘ ! (succ-pred n)
pred-+-right (pos (S m)) n = (pred-succ (pos m + n) ∘ ! (succ-pred (pos m + n)))
∘ map succ (pred-+-right (pos m) n)
pred-+-right (neg O) n = refl _
pred-+-right (neg (S m)) n = map pred (pred-+-right (neg m) n)
opp-right-inverse : (m : ℤ) → m + (- m) ≡ O
opp-right-inverse O = refl O
opp-right-inverse (pos O) = refl O
opp-right-inverse (pos (S m)) = succ-+-right (pos m) (neg (S m))
∘ opp-right-inverse (pos m)
opp-right-inverse (neg O) = refl O
opp-right-inverse (neg (S m)) = pred-+-right (neg m) (pos (S m))
∘ opp-right-inverse (neg m)
opp-left-inverse : (m : ℤ) → (- m) + m ≡ O
opp-left-inverse O = refl O
opp-left-inverse (pos O) = refl O
opp-left-inverse (pos (S m)) = pred-+-right (neg m) (pos (S m))
∘ opp-left-inverse (pos m)
opp-left-inverse (neg O) = refl O
opp-left-inverse (neg (S m)) = succ-+-right (pos m) (neg (S m))
∘ opp-left-inverse (neg m)
-- pred-+-right (neg m) (pos (S m)) ∘ opp-left-inverse (pos m)
ℤ-group : Group _
ℤ-group = group (pregroup
ℤ
_+_ O -_
+-assoc O-right-unit (λ m → refl _) opp-right-inverse opp-left-inverse)
ℤ-is-set
|
\hypertarget{classglite_1_1wmsui_1_1api_1_1ThreadException}{
\section{glite::wmsui::api::Thread\-Exception Class Reference}
\label{classglite_1_1wmsui_1_1api_1_1ThreadException}\index{glite::wmsui::api::ThreadException@{glite::wmsui::api::ThreadException}}
}
{\tt \#include $<$Job\-Exceptions.h$>$}
Inheritance diagram for glite::wmsui::api::Thread\-Exception::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2cm]{classglite_1_1wmsui_1_1api_1_1ThreadException}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item
\hyperlink{classglite_1_1wmsui_1_1api_1_1ThreadException_a0}{Thread\-Exception} (const std::string \&file, int line, const std::string \&method, int code, int job\-Number)
\end{CompactItemize}
\subsection{Detailed Description}
Thrown when a thread is unable to be launched or to run
\subsection{Constructor \& Destructor Documentation}
\hypertarget{classglite_1_1wmsui_1_1api_1_1ThreadException_a0}{
\index{glite::wmsui::api::ThreadException@{glite::wmsui::api::Thread\-Exception}!ThreadException@{ThreadException}}
\index{ThreadException@{ThreadException}!glite::wmsui::api::ThreadException@{glite::wmsui::api::Thread\-Exception}}
\subsubsection[ThreadException]{\setlength{\rightskip}{0pt plus 5cm}glite::wmsui::api::Thread\-Exception::Thread\-Exception (const std::string \& {\em file}, int {\em line}, const std::string \& {\em method}, int {\em code}, int {\em job\-Number})}}
\label{classglite_1_1wmsui_1_1api_1_1ThreadException_a0}
The documentation for this class was generated from the following file:\begin{CompactItemize}
\item
\hyperlink{JobExceptions_8h}{Job\-Exceptions.h}\end{CompactItemize}
|
## 3章
\begin{eqnarray}
y
=
\begin{cases}
0 & ( b + w_1x_1 + w_2x_2 \leqq \theta ) \\
1 & ( b + w_1x_1 + w_2x_2 \gt \theta )
\end{cases}
\end{eqnarray}
上記式は以下に変換
\begin{equation}
y = h( b + w_1x_1 + w_2x_2)
\end{equation}
\begin{eqnarray}
h(x)
=
\begin{cases}
0 & ( x \leqq \theta ) \\
1 & ( x \gt \theta )
\end{cases}
\end{eqnarray}
h は活性化関数と呼ばれる
この関数は閾値を境に出力が切り替わるためステップ関数や階段関数と呼ばれる
\begin{eqnarray}
h(x)
=
\begin{cases}
0 & ( x \leqq \theta ) \\
1 & ( x \gt \theta )
\end{cases}
\end{eqnarray}
### シグモイド関数
\begin{eqnarray}
h(x)
=
\frac {1}{1 + exp(-x)}
\end{eqnarray}
```python
import numpy as np
import matplotlib.pylab as plt
def step(x):
y = x > 0
return np.array(x > 0, dtype=np.int)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def relu(x):
return np.maximum(0, x)
x = np.arange(-5,5,0.1)
y1= step(x)
y2 = sigmoid(x)
y3 = relu(x)
plt.ylim(-0.1,5)
plt.plot(x, y1, label="step")
plt.plot(x, y2, linestyle="--", label="sigmoid")
plt.plot(x, y3, linestyle="-", label="relu")
plt.show()
```
### 行列の積
ようわからん。あとでまた学習
### MINST データセット
```python
import sys, os
sys.path.append(os.pardir) # 親ディレクトリのファイルをインポートするための設定
import numpy as np
from dataset.mnist import load_mnist
from PIL import Image
def img_show(img):
pil_img = Image.fromarray(np.uint8(img))
pil_img.show()
# (訓練画像、訓練ラベル)、(テスト画像、テストラベル)
(x_train, t_train), (x_test, t_test) = load_mnist(flatten=True, normalize=False, one_hot_label=False)
print(x_train.shape)
print(t_train.shape)
print(x_test.shape)
print(t_test.shape)
img = x_train[0]
label = t_train[0]
print(label) # 5
print(img.shape) # (784,)
img = img.reshape(28, 28) # 形状を元の画像サイズに変形
print(img.shape) # (28, 28)
img_show(img)
```
(60000, 784)
(60000,)
(10000, 784)
(10000,)
5
(784,)
(28, 28)
```python
# 推論処理
# MINST データとサンプルの学習済みの重みパラメータを使用してニューラルネットワークによる推論処理を行う
# 結果として、学習済みのニューラネットワークの認識精度を表示
from ch03.neuralnet_mnist import get_data, init_network,predict
import numpy as np
x, t = get_data()
network = init_network()
batch_size = 100
accuracy_cnt = 0
print(len(x))
for i in range(0, len(x), batch_size):
x_batch = x[i:i+batch_size]
y_batch = predict(network, x_batch)
p = np.argmax(y_batch, axis=1)
accuracy_cnt += np.sum(p==t[i:i+batch_size])
line = "Accuracy:{0}".format(str(float(accuracy_cnt/ len(x))))
print(line)
```
10000
Accuracy:0.9352
```python
```
|
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
# Expression that generates a histogram. The expression is
# wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should re-execute automatically
# when inputs change
# 2) Its output type is a plot
output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})
|
[STATEMENT]
lemma passive_start: "TAG_sctn False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. TAG_sctn False
[PROOF STEP]
by simp
|
[STATEMENT]
lemma MtransC_StepC:
assumes *: "cf \<rightarrow>*c cf'" and **: "cf' \<rightarrow>c cf''"
shows "cf \<rightarrow>*c cf''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. cf \<rightarrow>*c cf''
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. cf \<rightarrow>*c cf''
[PROOF STEP]
have "cf' \<rightarrow>*c cf''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. cf' \<rightarrow>*c cf''
[PROOF STEP]
using **
[PROOF STATE]
proof (prove)
using this:
cf' \<rightarrow>c cf''
goal (1 subgoal):
1. cf' \<rightarrow>*c cf''
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cf' \<rightarrow>*c cf''
goal (1 subgoal):
1. cf \<rightarrow>*c cf''
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
cf' \<rightarrow>*c cf''
goal (1 subgoal):
1. cf \<rightarrow>*c cf''
[PROOF STEP]
using * MtransC_Trans
[PROOF STATE]
proof (prove)
using this:
cf' \<rightarrow>*c cf''
cf \<rightarrow>*c cf'
\<lbrakk>?cf \<rightarrow>*c ?cf'; ?cf' \<rightarrow>*c ?cf''\<rbrakk> \<Longrightarrow> ?cf \<rightarrow>*c ?cf''
goal (1 subgoal):
1. cf \<rightarrow>*c cf''
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
cf \<rightarrow>*c cf''
goal:
No subgoals!
[PROOF STEP]
qed
|
#############################################################################
##
#W utilsfrgrp.gi automgrp package Yevgen Muntyan
## Dmytro Savchuk
##
#Y Copyright (C) 2003 - 2018 Yevgen Muntyan, Dmytro Savchuk
##
#############################################################################
##
## AG_InverseLessThanForLetters(<w1>, <w2>)
##
## Compares w1 and w2 according to lexicografic ordering given by
## x1 < x1^-1 < x2 < x2^-1 < ...
##
BindGlobal("AG_InverseLessThanForLetters",
function(w1, w2)
local i, er1, er2;
if Length(w1) <> Length(w2) then
return Length(w1) < Length(w2);
fi;
er1 := LetterRepAssocWord(w1);
er2 := LetterRepAssocWord(w2);
for i in [1..Length(er1)] do
if AbsInt(er1[i]) <> AbsInt(er2[i]) then
return AbsInt(er1[i]) < AbsInt(er2[i]);
fi;
if er1[i] <> er2[i] then
return er1[i] > er2[i];
fi;
od;
return false;
end);
#############################################################################
##
## AG_ReducedListOfWordsByNielsen(<words_list>)
## AG_ReducedListOfWordsByNielsenBack(<words_list>)
## AG_ReducedListOfWordsByNielsen(<words_list>, <string>)
## AG_ReducedListOfWordsByNielsenBack(<words_list>, <string>)
##
InstallMethod(AG_ReducedListOfWordsByNielsen, [IsAssocWordCollection],
function(words)
return AG_ReducedListOfWordsByNielsen(words, \<);
end);
InstallMethod(AG_ReducedListOfWordsByNielsenBack, [IsAssocWordCollection],
function(words)
return AG_ReducedListOfWordsByNielsen(words, \<);
end);
InstallMethod(AG_ReducedListOfWordsByNielsen, [IsAssocWordCollection, IsString],
function(words, string)
return AG_ReducedListOfWordsByNielsen(words, AG_InverseLessThanForLetters);
end);
InstallMethod(AG_ReducedListOfWordsByNielsenBack, [IsAssocWordCollection, IsString],
function(words, string)
return AG_ReducedListOfWordsByNielsen(words, AG_InverseLessThanForLetters);
end);
#############################################################################
##
#M AG_ReducedListOfWordsByNielsen(<words_list>, <lt>)
##
InstallMethod( AG_ReducedListOfWordsByNielsen,
[IsAssocWordCollection, IsFunction],
function(words_list, lt)
local result, transform, did_something, n, i, j, try_again, tmp;
n := Length(words_list);
result := ShallowCopy(words_list);
transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(n)));
did_something := false;
try_again := true;
for i in [1..n] do
if not IsAssocWord(result[i]) then
Print("error in AG_ReducedListOfWordsByNielsen(IsAssocWordCollection, IsFunction):\n");
Print(" ", i, "-th element of list is not an associative word\n");
return fail;
fi;
od;
while try_again do
try_again := false;
for i in [1..n] do
for j in [1..n] do
if i = j then
if lt(result[i]^-1, result[i]) then
result[i] := result[i]^-1;
transform[i] := transform[i]^-1;
did_something := true;
try_again := true;
fi;
continue;
fi;
if i > j and lt(result[i], result[j]) then
tmp := result[i];
result[i] := result[j];
result[j] := tmp;
tmp := transform[i];
transform[i] := transform[j];
transform[j] := tmp;
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j], result[i]) then
result[i] := result[i]*result[j];
transform[i] := transform[i]*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j], result[j]) then
result[j] := result[i]*result[j];
transform[j] := transform[i]*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j], result[i]) then
result[i] := result[i]^-1*result[j];
transform[i] := transform[i]^-1*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j], result[j]) then
result[j] := result[i]^-1*result[j];
transform[j] := transform[i]^-1*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j]^-1, result[i]) then
result[i] := result[i]*result[j]^-1;
transform[i] := transform[i]*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j]^-1, result[j]) then
result[j] := result[i]*result[j]^-1;
transform[j] := transform[i]*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j]^-1, result[i]) then
result[i] := result[i]^-1*result[j]^-1;
transform[i] := transform[i]^-1*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j]^-1, result[j]) then
result[j] := result[i]^-1*result[j]^-1;
transform[j] := transform[i]^-1*transform[j]^-1;
did_something := true;
try_again := true;
fi;
od;
od;
od;
return [result, transform, did_something];
end);
#############################################################################
##
#M AG_ReducedListOfWordsByNielsenBack(<words_list>, <lt>)
##
InstallMethod(AG_ReducedListOfWordsByNielsenBack,
[IsAssocWordCollection, IsFunction],
function(words_list, lt)
local result, transform, did_something, n, i, j, try_again, tmp;
n := Length(words_list);
result := ShallowCopy(words_list);
transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(n)));
did_something := false;
try_again := true;
for i in [1..n] do
if not IsAssocWord(result[i]) then
Print("error in AG_ReducedListOfWordsByNielsenBack(IsAssocWordCollection, IsFunction):\n");
Print(" ", i, "-th element of list is not an associative word\n");
return fail;
fi;
od;
while try_again do
try_again := false;
for i in [1..n] do
for j in [1..n] do
if i = j then
if lt(result[i]^-1, result[i]) then
result[i] := result[i]^-1;
transform[i] := transform[i]^-1;
did_something := true;
try_again := true;
fi;
continue;
fi;
if i > j and lt(result[i], result[j]) then
tmp := result[i];
result[i] := result[j];
result[j] := tmp;
tmp := transform[i];
transform[i] := transform[j];
transform[j] := tmp;
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j]^-1, result[j]) then
result[j] := result[i]^-1*result[j]^-1;
transform[j] := transform[i]^-1*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j]^-1, result[i]) then
result[i] := result[i]^-1*result[j]^-1;
transform[i] := transform[i]^-1*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j]^-1, result[j]) then
result[j] := result[i]*result[j]^-1;
transform[j] := transform[i]*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j]^-1, result[i]) then
result[i] := result[i]*result[j]^-1;
transform[i] := transform[i]*transform[j]^-1;
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j], result[i]) then
result[i] := result[i]^-1*result[j];
transform[i] := transform[i]^-1*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]^-1*result[j], result[j]) then
result[j] := result[i]^-1*result[j];
transform[j] := transform[i]^-1*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j], result[j]) then
result[j] := result[i]*result[j];
transform[j] := transform[i]*transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]*result[j], result[i]) then
result[i] := result[i]*result[j];
transform[i] := transform[i]*transform[j];
did_something := true;
try_again := true;
fi;
od;
od;
od;
return [result, transform, did_something];
end);
#############################################################################
##
## AG_ComputeMihailovaSystemPairs(<pairs_list>)
##
InstallGlobalFunction(AG_ComputeMihailovaSystemPairs,
function(pairs)
local result, i, nie, m, n, w, tmp,
did_smth, npairs, transform,
generate_full_group, nielsen_mihaylov, nielsen_low, rank,
number_of_letters;
if not IsDenseList(pairs) then
Print("error in AG_ComputeMihailovaSystemPairs: \n");
Print(" argument is not an IsDenseList\n");
return fail;
fi;
if not IsList(pairs[1]) then
Print("error in AG_ComputeMihailovaSystemPairs: \n");
Print(" first element of list is not an IsList\n");
return fail;
fi;
if Length(pairs[1]) <> 2 then
Print("error in AG_ComputeMihailovaSystemPairs: \n");
Print(" can work only with pairs\n");
return fail;
fi;
if not IsAssocWord(pairs[1][1]) then
Print("error in AG_ComputeMihailovaSystemPairs: \n");
Print(" <arg>[1][1] is not IsAssocWord\n");
return fail;
fi;
#############################################################################
##
## generate_full_group
##
generate_full_group := function(list, rank)
local nie, i;
nie := AG_ReducedListOfWordsByNielsen(list)[1];
if Length(Difference(nie, [One(nie[1])])) <> rank then
return false;
fi;
for i in [1..Length(nie)] do
if Length(nie[i]) > 1 then return false; fi;
od;
return true;
end;
#############################################################################
##
## rank
##
rank := function(words)
return Length(Difference(AG_ReducedListOfWordsByNielsen(words)[1],
[One(words[1])]));
end;
#############################################################################
##
## number_of_letters
##
number_of_letters := function(list)
local letters, i, j;
letters := [];
for i in [1..Length(list)] do
for j in [1..NumberSyllables(list[i])] do
AddSet(letters, GeneratorSyllable(list[i], j));
od;
od;
return Length(letters);
end;
#############################################################################
##
## nielsen_mihaylov
##
nielsen_mihaylov := function(words_list, m, n)
local result, transform, did_something, try_again, nie, i, j, tf, pair,
good_tf, good_pair, tmp;
result := StructuralCopy(words_list);
transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(m+n)));
did_something := false;
try_again := true;
while try_again do
try_again := false;
nie := nielsen_low(result, m, n, \<);
if nie[3] then
did_something := true;
try_again := true;
result := nie[1];
transform := AG_CalculateWords(nie[2], transform);
fi;
nie := AG_ReducedListOfWordsByNielsen(result{[m+1..m+n]});
if nie[3] then
did_something := true;
try_again := true;
result := Concatenation(result{[1..m]}, nie[1]);
transform := Concatenation( transform{[1..m]},
AG_CalculateWords(nie[2],
transform{[m+1..m+n]}));
fi;
if rank(result{[m+1..m+n]}) = n then
if List(result{[m+1..m+n]}, w -> Length(w)) = List([1..n], i -> 1) then
## ok
try_again := false;
else
## try to minimize sum of lengths
good_pair := false;
for pair in ListX([m+1..m+n], [1..m], function(i,j) return [i,j]; end) do
good_tf := false;
for tf in [ [1,1,2,1],[2,1,1,1],[1,-1,2,1],[2,-1,1,1],
[1,1,2,-1],[2,1,1,-1],[1,-1,2,-1],[2,-1,1,-1] ] do
tmp := StructuralCopy(result);
tmp[pair[1]] := tmp[pair[tf[1]]]^tf[2] * tmp[pair[tf[3]]]^tf[4];
if rank(tmp{[m+1..m+n]}) = n and
number_of_letters(tmp{[m+1..m+n]}) =
number_of_letters(result{[m+1..m+n]}) and
Sum(List(tmp{[m+1..m+n]}, w -> Length(w))) <
Sum(List(result{[m+1..m+n]}, w -> Length(w)))
then
good_tf := true;
break;
fi;
od;
if good_tf then
good_pair := true;
break;
fi;
od;
if not good_pair then
## give up
return [result, transform, did_something];
else
result[pair[1]] := result[pair[tf[1]]]^tf[2] *
result[pair[tf[3]]]^tf[4];
transform[pair[1]] := transform[pair[tf[1]]]^tf[2] *
transform[pair[tf[3]]]^tf[4];
try_again := true;
did_something := true;
fi;
fi;
else
## try to make rank bigger
for i in [1..m] do
good_tf := false;
pair := [m+1, i];
for tf in [ [1,1,2,1],[2,1,1,1],[1,-1,2,1],[2,-1,1,1],
[1,1,2,-1],[2,1,1,-1],[1,-1,2,-1],[2,-1,1,-1] ] do
tmp := StructuralCopy(result);
tmp[pair[1]] := tmp[pair[tf[1]]]^tf[2] * tmp[pair[tf[3]]]^tf[4];
if rank(tmp{[m+1..m+n]}) > rank(result{[m+1..m+n]}) and
number_of_letters(tmp{[m+1..m+n]}) >=
number_of_letters(result{[m+1..m+n]})
then
good_tf := true;
break;
fi;
od;
if good_tf then
good_pair := true;
break;
fi;
od;
if not good_pair then
## give up
return [result, transform, did_something];
else
result[pair[1]] := result[pair[tf[1]]]^tf[2] *
result[pair[tf[3]]]^tf[4];
transform[pair[1]] := transform[pair[tf[1]]]^tf[2] *
transform[pair[tf[3]]]^tf[4];
try_again := true;
did_something := true;
fi;
fi;
od;
return [result, transform, did_something];
end;
#############################################################################
##
## nielsen_low
##
nielsen_low := function(words_list, m, n, lt)
local result, transform, did_something, i, j, try_again, tmp, nie;
result := ShallowCopy(words_list);
transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(m+n)));
did_something := false;
try_again := true;
while try_again do
try_again := false;
nie := AG_ReducedListOfWordsByNielsen(result{[1..m]});
if nie[3] then
result := Concatenation(AG_CalculateWords(nie[2], result{[1..m]}),
result{[m+1..m+n]});
transform := Concatenation( AG_CalculateWords(nie[2], transform{[1..m]}),
transform{[m+1..m+n]} );
did_something := true;
try_again := true;
fi;
for i in [1..m] do
for j in [m+1..m+n] do
if lt(result[i]^result[j], result[i]) then
result[i] := result[i]^result[j];
transform[i] := transform[i]^transform[j];
did_something := true;
try_again := true;
fi;
if lt(result[i]^(result[j]^-1), result[i]) then
result[i] := result[i]^(result[j]^-1);
transform[i] := transform[i]^(transform[j]^-1);
did_something := true;
try_again := true;
fi;
if lt((result[i]^-1)^result[j], result[i]) then
result[i] := (result[i]^-1)^result[j];
transform[i] := (transform[i]^-1)^transform[j];
did_something := true;
try_again := true;
fi;
if lt((result[i]^-1)^(result[j]^-1), result[i]) then
result[i] := (result[i]^-1)^(result[j]^-1);
transform[i] := (transform[i]^-1)^(transform[j]^-1);
did_something := true;
try_again := true;
fi;
od;
od;
od;
return [result, transform, did_something];
end;
#############################################################################
##
## MihailovaSystem body
##
n := Length(FreeGeneratorsOfWholeGroup(Group(pairs[1][1])));
m := Length(pairs) - n;
npairs := StructuralCopy(pairs);
transform := StructuralCopy(FreeGeneratorsOfFpGroup(FreeGroup(n+m)));
did_smth := false;
if not generate_full_group(List(pairs, p -> p[1]), n)
or not generate_full_group(List(pairs, p -> p[2]), n)
then
Print("error in AG_ComputeMihailovaSystemPairs: \n");
Print(" projections do not generate full free group\n");
return fail;
fi;
## if rank equals number of pairs then just make one coordinate nicer
if m = 0 then
nie := AG_ReducedListOfWordsByNielsen(List(npairs, p -> p[1]), "r");
if nie[3] then
tmp := List(npairs, p -> []);
for i in [1..m+n] do
tmp[i][1] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[1]));
tmp[i][2] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[2]));
od;
npairs := StructuralCopy(tmp);
transform := StructuralCopy(nie[2]);
did_smth := true;
fi;
return [npairs, transform, did_smth];
fi;
## else try to do as much as possible
## 1. Apply Nielsen to first coordinate
nie := AG_ReducedListOfWordsByNielsen(List(npairs, p -> p[1]), "r");
if nie[3] then
tmp := StructuralCopy(npairs);
for i in [1..m+n] do
tmp[i][1] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[1]));
tmp[i][2] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[2]));
od;
npairs := StructuralCopy(tmp);
transform := StructuralCopy(nie[2]);
did_smth := true;
fi;
## 2. Now apply nielsen_mihaylov to the second coordinate
nie := nielsen_mihaylov(List(npairs, p -> p[2]), m, n);
if nie[3] then
tmp := StructuralCopy(npairs);
for i in [1..m+n] do
tmp[i][1] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[1]));
tmp[i][2] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[2]));
od;
npairs := StructuralCopy(tmp);
tmp := StructuralCopy(transform);
for i in [1..m+n] do
tmp[i] := AG_CalculateWord(nie[2][i], transform);
od;
transform := StructuralCopy(tmp);
did_smth := true;
fi;
## 3. Try to get nice generators on first coordinate
nie := AG_ReducedListOfWordsByNielsenBack(List(npairs{[m+1..m+n]}, p -> p[1]), "r");
if nie[3] then
tmp := StructuralCopy(npairs);
for i in [1..n] do
tmp[m+i][1] := AG_CalculateWord(nie[2][i], List(npairs{[m+1..m+n]}, p -> p[1]));
tmp[m+i][2] := AG_CalculateWord(nie[2][i], List(npairs{[m+1..m+n]}, p -> p[2]));
od;
npairs := StructuralCopy(tmp);
tmp := StructuralCopy(transform);
for i in [1..n] do
tmp[m+i] := AG_CalculateWord(nie[2][i], transform{[m+1..m+n]});
od;
transform := StructuralCopy(tmp);
did_smth := true;
fi;
return [npairs, transform, did_smth];
end);
#############################################################################
##
#M AG_ReducedByNielsen(<words_list>)
##
InstallMethod(AG_ReducedByNielsen,
"for [IsList and IsAssocWordCollection]",
[IsList and IsAssocWordCollection],
function(words)
if AG_Globals.use_inv_order_in_apply_nielsen then
return AG_ReducedListOfWordsByNielsen(words, "back")[1];
else
return AG_ReducedListOfWordsByNielsen(words)[1];
fi;
end);
#############################################################################
##
#M AG_ReducedByNielsen(<autom_list>)
##
InstallMethod(AG_ReducedByNielsen,
"for [IsList and IsAutomCollection]",
[IsList and IsAutomCollection],
function(automs)
local words;
if IsEmpty(automs) then
return [];
fi;
words := AG_ReducedByNielsen(List(automs, a -> a!.word));
return List(words, w -> Autom(w, automs[1]));
end);
#E
|
SUBROUTINE SUB (X,Y)
INTERFACE
SUBROUTINE SUB2 (A,B)
OPTIONAL :: B
END SUBROUTINE
END INTERFACE
OPTIONAL :: Y
IF (PRESENT(Y)) THEN ! Reference to Y conditional
X = X + Y ! on its presence
ENDIF
CALL SUB2(X,Y)
END SUBROUTINE
SUBROUTINE SUB2 (A,B)
OPTIONAL :: B ! B and Y are argument associated,
IF (PRESENT(B)) THEN ! even if Y is not present, in
B = B * A ! which case, B is also not present
PRINT*, B
ELSE
A = A**2
PRINT*, A
ENDIF
END SUBROUTINE
|
using Polynomials
import Base: show, *, +
"""
PolyExp(p::Vector{T}, a::T, b::T)
PolyExp(pol::Polynomial{T},a::T,b::T)
On the model of `Polynomial` from package `Polynomials`, construct a function that is a polynome multiply by an exponential
function. The exponential is an exponential of an affine function ``a x + b``.
The polynome is construct from its coefficients `p`, lowest order first.
If ``f = (p_n x^n + \\ldots + p_2 x^2 + p_1 x + p_0)e^{a x + b}``, we construct this through
`PolyExp([p_0, p_1, ..., p_n], a, b)`.
It is also possible to construct it directly from the polynome.
In the sequels some methods with the same name than for Polynomial are implemented
(`derivative`, `integrate`, `strings`, ...) but not all, only the methods needed are developped.
# Arguments :
- `p::Vector{T}` or pol::Polynomial{T} : vector of coefficients of the polynome, or directly the polynome.
- `a::T`, `b::T` : coefficients of affine exponentiated function.
# Examples
```julia
julia> pe=PolyExp([1,2,3],2,1)
PolyExp(Polynomial(1 + 2*x + 3*x^2)*exp(2*x + 1))
julia> pe(0)
2.718281828459045
julia> pe(1)
120.51322153912601
```
"""
struct PolyExp{T}
p::Polynomial{T}
a::T
b::T
PolyExp(p::Vector{T}, a::T, b::T) where {T<:Number} = new{T}(Polynomial{T}(p), a, b)
PolyExp(pol::Polynomial{T}, a::T, b::T) where {T<:Number} = new{T}(pol, a, b)
end
function _printNumberPar(x::Number)
return isreal(x) ? "$(real(x))" : (iszero(real(x)) ? "$(imag(x))im" : "($x)")
end
function _printNumber(x::Number)
return isreal(x) ? "$(real(x))" : (iszero(real(x)) ? "$(imag(x))im" : "$x")
end
function Base.show(io::IO, pe::PolyExp)
return print(
io,
"PolyExp($(pe.p)*exp($(_printNumberPar(pe.a))*x + $(_printNumber(pe.b))))",
)
end
"""
derivative(pe::PolyExp)
Construct the derivative of the `pe` function.
# Examples
```julia
julia> derivative(PolyExp([1, 3, -1],3,1))
PolyExp(Polynomial(6 + 7*x - 3*x^2)*exp(3*x + 1))
julia> derivative(PolyExp([1.0+im, 3im, -1, 4.0], 2.0+1.5im,1.0im))
PolyExp(Polynomial((0.5 + 6.5im) - (6.5 - 6.0im)*x + (10.0 - 1.5im)*x^2 + (8.0 + 6.0im)*x^3)*exp((2.0 + 1.5im)*x + 1.0im))
```
"""
function Polynomials.derivative(pe::PolyExp)
return PolyExp(pe.p * pe.a + Polynomials.derivative(pe.p), pe.a, pe.b)
end
"""
integrate(pe::PolyExp)
Construct the integrate function of `pe` which is of `PolyExp` type.
The algorithm used is a recursive integration by parts.
# Examples
```julia
julia> integrate(PolyExp([1.0,2,3],2.0,5.0))
PolyExp(Polynomial(0.75 - 0.5*x + 1.5*x^2)*exp(2.0*x + 5.0))
julia> integrate(PolyExp([1.0+0im,2],2.0im,3.0+0im))
PolyExp(Polynomial((0.5 - 0.5im) - 1.0im*x)*exp(2.0im*x + 3.0))
```
"""
function Polynomials.integrate(pe::PolyExp)
if (pe.a != 0)
pol = pe.p / pe.a
if Polynomials.degree(pe.p) > 0
pol -=
Polynomials.integrate(PolyExp(Polynomials.derivative(pe.p), pe.a, pe.b)).p /
pe.a
end
else
pol = Polynomials.integrate(pol)
end
return PolyExp(pol, pe.a, pe.b)
end
(pe::PolyExp)(x) = pe.p(x) * exp(pe.a * x + pe.b)
coeffs(pe::PolyExp) = vcat(Polynomials.coeffs(pe.p), pe.a, pe.b)
function Polynomials.integrate(p::PolyExp, v_begin::Number, v_end::Number)
pol = Polynomials.integrate(p)
return pol(v_end) - pol(v_begin)
end
*(p1::PolyExp, p2::PolyExp) = PolyExp(p1.p * p2.p, p1.a + p2.a, p1.b + p2.b)
function +(p1::PolyExp, p2::PolyExp)
@assert (p1.a == p2.a && p1.b == p2.b) "for adding exponents must be equal"
return PolyExp(p1.p + p2.p, p1.a, p1.b)
end
|
\section*{Acknowledgements}
\label{s:ack}
The authors of this paper include organisers and participants in the
summer school. We are very grateful to all of the people who helped
make the school a success and want to acknowledge everybody who is not an
author.
First we thank the organisers: John McDermott, Angela Miguel, and Lakshitha de Silva for organisational and technical help.
We thank the various sponsors of the summer school for financial and
other forms of assistance:
SICSA (the Scottish Informatics and Computer Science Alliance);
Microsoft Research; the Software Sustainability Institute;
the St Andrews School of Computer Science;
and the EPSRC Impact Acceleration Award ``Recomputation.org: Making
Computational Experiments Recomputable''
at the University of St Andrews.
We are also grateful to speakers at the summer school who were not also authors of this paper:
Neil Chue Hong,
Stephen Crouch,
Darren Kidney, and
Burkhard Schafer.
|
import data.nat.parity
import data.real.basic
#check mul_left_comm
/- Tactic proofs -/
example : ∀ m n : nat, even n → even (m * n) :=
begin
intros m n hn,
cases hn with k hk,
use m * k,
sorry,
end
example : ∀ m n : nat, even n → even (m * n) :=
begin
rintro m n ⟨k, hk⟩,
use m * k,
sorry,
end
|
!**********************************************************************************************************************************
! Copyright (C) 2013-2016 National Renewable Energy Laboratory
!
!> This code provides a wrapper for the SLATEC routines currently used at the NWTC (mainly codes in the FAST framework). This
!! enables us to call generic routines (not single- or double-precision specific ones) so that we don't have to change source
!! code to compile in double vs. single precision.
!
!**********************************************************************************************************************************
MODULE NWTC_SLATEC
USE NWTC_Base ! we only need the precision and error level constants
! Notes:
! Your project must include the following files:
! From the NWTC Subroutine Library:
! SingPrec.f90 [from NWTC Library]
! Sys*.f90 [from NWTC Library]
! NWTC_Base.f90 [from NWTC Library]
! lapack library (preferably a binary, but available in source form from http://www.netlib.org/, too)
! This wrapper file:
! NWTC_SLATEC.f90
! NOTES:
! The routines in the slatec library use REAL and DOUBLE PRECISION. When compiling in double precision
! the -fdefault-real-8 option is used, which promotes all DOUBLE to QUAD. Therefore the interaces here
! are done using ReKi and DBKi to interface to the appropriate library. This allows the user to specify
! the typing of variables passed to these routines as ReKi, DBKi, or R8Ki.
! Note that SiKi can'bt be specified in the calling variable type as it will still be kind=4, which
! won't have any promoted routines to match to in DOUBLE precision compiles.
! http://www.netlib.org/slatec/explore-html/
IMPLICIT NONE
!> integrate an external function using the 61-point kronrod rule
interface slatec_qk61
module procedure wrap_qk61
module procedure wrap_dqk61
end interface
CONTAINS
!> Single precision wrapper for the qk61 integration routine from the slatec library
!! Note that the qk61 routine follows -fdefault-real-8 setting, so it is of type ReKi
subroutine wrap_qk61(func,low,hi,answer,abserr,resabs,resasc)
real(ReKi), intent(in ) :: low,hi ! integration limits
real(ReKi), intent( out) :: answer
real(ReKi), intent(in ) :: abserr,resabs,resasc
real(ReKi), external :: func ! function
call qk61(func,low,hi,answer,abserr,resabs,resasc)
end subroutine wrap_qk61
!> Double precision wrapper for the dqk61 integration routine from the slatec library
!! Note that the qk61 routine follows -fdefault-real-8 setting, so it is of type DbKi
subroutine wrap_dqk61(func,low,hi,answer,abserr,resabs,resasc)
real(DbKi), intent(in ) :: low,hi ! integration limits
real(DbKi), intent( out) :: answer
real(DbKi), intent(in ) :: abserr,resabs,resasc
real(DbKi), external :: func ! function
call dqk61(func,low,hi,answer,abserr,resabs,resasc)
end subroutine wrap_dqk61
END MODULE NWTC_SLATEC
|
[STATEMENT]
lemma components_full_pmdl_subset:
"component_of_term ` Keys ((full_pmdl K)::('t \<Rightarrow>\<^sub>0 'b::zero) set) \<subseteq> K" (is "?l \<subseteq> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. component_of_term ` Keys (full_pmdl K) \<subseteq> K
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> component_of_term ` Keys (full_pmdl K) \<Longrightarrow> x \<in> K
[PROOF STEP]
let ?M = "(full_pmdl K)::('t \<Rightarrow>\<^sub>0 'b) set"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> component_of_term ` Keys (full_pmdl K) \<Longrightarrow> x \<in> K
[PROOF STEP]
fix k
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> component_of_term ` Keys (full_pmdl K) \<Longrightarrow> x \<in> K
[PROOF STEP]
assume "k \<in> ?l"
[PROOF STATE]
proof (state)
this:
k \<in> component_of_term ` Keys (full_pmdl K)
goal (1 subgoal):
1. \<And>x. x \<in> component_of_term ` Keys (full_pmdl K) \<Longrightarrow> x \<in> K
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<in> component_of_term ` Keys (full_pmdl K)
[PROOF STEP]
obtain v where "v \<in> Keys ?M" and k: "k = component_of_term v"
[PROOF STATE]
proof (prove)
using this:
k \<in> component_of_term ` Keys (full_pmdl K)
goal (1 subgoal):
1. (\<And>v. \<lbrakk>v \<in> Keys (full_pmdl K); k = component_of_term v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
v \<in> Keys (full_pmdl K)
k = component_of_term v
goal (1 subgoal):
1. \<And>x. x \<in> component_of_term ` Keys (full_pmdl K) \<Longrightarrow> x \<in> K
[PROOF STEP]
from this(1)
[PROOF STATE]
proof (chain)
picking this:
v \<in> Keys (full_pmdl K)
[PROOF STEP]
obtain p where "p \<in> ?M" and "v \<in> keys p"
[PROOF STATE]
proof (prove)
using this:
v \<in> Keys (full_pmdl K)
goal (1 subgoal):
1. (\<And>p. \<lbrakk>p \<in> full_pmdl K; v \<in> keys p\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (rule in_KeysE)
[PROOF STATE]
proof (state)
this:
p \<in> full_pmdl K
v \<in> keys p
goal (1 subgoal):
1. \<And>x. x \<in> component_of_term ` Keys (full_pmdl K) \<Longrightarrow> x \<in> K
[PROOF STEP]
thus "k \<in> K"
[PROOF STATE]
proof (prove)
using this:
p \<in> full_pmdl K
v \<in> keys p
goal (1 subgoal):
1. k \<in> K
[PROOF STEP]
unfolding k
[PROOF STATE]
proof (prove)
using this:
p \<in> full_pmdl K
v \<in> keys p
goal (1 subgoal):
1. component_of_term v \<in> K
[PROOF STEP]
by (rule full_pmdlD)
[PROOF STATE]
proof (state)
this:
k \<in> K
goal:
No subgoals!
[PROOF STEP]
qed
|
import data.real.basic
open_locale classical
/-
Theoretical negations.
This file is for people interested in logic who want to fully understand
negations.
Here we don't use `contrapose` or `push_neg`. The goal is to prove lemmas
that are used by those tactics. Of course we can use
`exfalso`, `by_contradiction` and `by_cases`.
If this doesn't sound like fun then skip ahead to the next file.
-/
section negation_prop
variables P Q : Prop
-- 0055
example : (P → Q) ↔ (¬ Q → ¬ P) :=
begin
-- sorry
split,
{ intros h hnQ hP,
exact hnQ (h hP) },
{ intros h hP,
by_contradiction hnQ,
exact h hnQ hP },
-- sorry
end
-- 0056
lemma non_imp (P Q : Prop) : ¬ (P → Q) ↔ P ∧ ¬ Q :=
begin
-- sorry
split,
{ intro h,
by_contradiction H,
apply h,
intro hP,
by_contradiction H',
apply H,
exact ⟨hP, H'⟩ },
{ intros h h',
cases h with hP hnQ,
exact hnQ (h' hP) },
-- sorry
end
-- In the next one, let's use the axiom
-- propext {P Q : Prop} : (P ↔ Q) → P = Q
-- 0057
example (P : Prop) : ¬ P ↔ P = false :=
begin
-- sorry
split,
{ intro h,
apply propext,
split,
{ intro h',
exact h h' },
{ intro h,
exfalso,
exact h } },
{ intro h,
rw h,
exact id },
-- sorry
end
end negation_prop
section negation_quantifiers
variables (X : Type) (P : X → Prop)
-- 0058
example : ¬ (∀ x, P x) ↔ ∃ x, ¬ P x :=
begin
-- sorry
split,
{ intro h,
by_contradiction H,
apply h,
intros x,
by_contradiction H',
apply H,
use [x, H'] },
{ rintros ⟨x, hx⟩ h',
exact hx (h' x) },
-- sorry
end
-- 0059
example : ¬ (∃ x, P x) ↔ ∀ x, ¬ P x :=
begin
-- sorry
split,
{ intros h x h',
apply h,
use [x, h'] },
{ rintros h ⟨x, hx⟩,
exact h x hx },
-- sorry
end
-- 0060
example (P : ℝ → Prop) : ¬ (∃ ε > 0, P ε) ↔ ∀ ε > 0, ¬ P ε :=
begin
-- sorry
split,
{ intros h ε ε_pos hP,
apply h,
use [ε, ε_pos, hP] },
{ rintros h ⟨ε, ε_pos, hP⟩,
exact h ε ε_pos hP },
-- sorry
end
-- 0061
example (P : ℝ → Prop) : ¬ (∀ x > 0, P x) ↔ ∃ x > 0, ¬ P x :=
begin
-- sorry
split,
{ intros h,
by_contradiction H,
apply h,
intros x x_pos,
by_contradiction HP,
apply H,
use [x, x_pos, HP] },
{ rintros ⟨x, xpos, hx⟩ h',
exact hx (h' x xpos) },
-- sorry
end
end negation_quantifiers
|
% !TeX root = ../../thesis.tex
\chapter{Trapping of a single protein inside a nanopore}
%
\label{ch:trapping}
%
%
\epigraphhead[\epipos]{%
\epigraph{%
%
``Magic is organizing chaos. And while oceans of mystery remain, we have deduced that this requires two
things. Balance and control.''
%
}{%
\textit{`Tissaia De Vries'}
%
}
}
%
%
%
%
\definecolor{shadecolor}{gray}{0.85}
\begin{shaded}
This chapter was published as:
%
\begin{itemize}
\item K. Willems*, D. Rui\'{c}*, A. Biesemans*, N. S. Galenkamp, P. Van Dorpe and G. Maglia.
\textit{ACS Nano} \textbf{13 (9)}, 9980--9992 (2019) %\cite{Willems-Ruic-Biesemans-2019}
\\
*equal contributions
\end{itemize}
%
\newpage
\end{shaded}
%
%
% Glossary reset
%
In this chapter we used experimental, computational, and theoretical methods to investigate the trapping
behavior of a small protein, \glsfirst{dhfr}, within the \glsfirst{clya} nanopore. It builds upon the
electrostatic energy methodology developed in \cref{ch:electrostatics} to parameterize and verify a
mathematical model that captures the essential physics of the experimentally observed voltage- and
charge-dependent dwell times of a tagged \gls{dhfr} molecule in \gls{clya}. \\
%
%
To the extent possible, the main and supplementary texts and figures of the original manuscript were
integrated into this chapter, and the remainder of the supplementary information can be found in
\cref{ch:trapping_appendix}. The text and figures of this chapter represent entirely my own work. All
experimental work was performed by Dr.~Annemie Biesemans, and the trapping model was derived by
Dr.~rer.~nat.~Dino Rui\'{c} (see~\cref{sec:trapping_appendix:escape_rates}).
%
%
\adapACS{Willems-Ruic-Biesemans-2019}
%
%
Note that further permissions related to the material excerpted should be directed to the ACS.
%
% \cleardoublepage
%
%
%
\section{Abstract}
%
\label{sec:trapping:abstract}
%
The ability to confine and to study single molecules has enabled important advances in natural and applied
sciences. Recently, we have shown that unlabeled proteins can be confined inside the biological nanopore
\glsfirst{clya} and conformational changes monitored by ionic current recordings. However, trapping small
proteins remains a challenge. Here we describe a system where steric, electrostatic, electrophoretic, and
electro-osmotic forces are exploited to immobilize a small protein, \glsfirst{dhfr}, inside \gls{clya}.
Assisted by electrostatic simulations, we show that the dwell time of \gls{dhfr} inside \gls{clya} can be
increased by orders of magnitude (from milliseconds to seconds) by manipulation of the \gls{dhfr} charge
distribution. Further, we describe a physical model that includes a double energy barrier and the main
electrophoretic components for trapping \gls{dhfr} inside the nanopore. Simultaneous fits to the voltage
dependence of the dwell times allowed direct estimates of the \cisi{} and \transi{} translocation
probabilities, the mean dwell time, and the force exerted by the electro-osmotic flow on the protein
(\SI{\approx9}{\pN} at \SI{-50}{\mV}) to be retrieved. The observed binding of \gls{nadph} to the trapped
\gls{dhfr} molecules suggested that the engineered proteins remained folded and functional inside \gls{clya}.
Contact-free confinement of single proteins inside nanopores can be employed for the manipulation and
localized delivery of individual proteins and will have further applications in single-molecule analyte
sensing and enzymology studies.
%
\section{Introduction}
%
\label{sec:trapping:intro}
%
Sensors capable of the label-free interrogation of proteins at the single-molecule level have applications in
biosensing, biophysics, and enzymology~\cite{Gooding-2016,Xie-2001,Willems-VanMeervelt-2017}. In particular,
the ability to observe the behavior of individual proteins allows one to directly retrieve the rates of
kinetic processes and provides a wealth of mechanistic, energetic and structural information,which are not
readily obtained from statistically averaged ensemble (bulk) measurements~\cite{Gooding-2016}. To achieve
single-molecular sensitivity at high signal-to-noise ratios, the observational volume of the sensor should be
similar in size to the object of interest (\ie~zeptoliter-range for a protein with a radius of \SI{2.5}{\nm}).
Moreover, many kinetic processes have relatively long time scales (\eg~\SIrange{e-3}{e0}{\second}) which in
turn necessitate long observational times to obtain a statistically relevant number of events. Hence, the
protein must also remain inside the observational volume for seconds or minutes, a feat that is only possible
if the protein is either physically immobilized or trapped in a local energetic minimum that is significantly
deeper than the thermal energy~\cite{Krishnan-2010,Myers-2015}.
To counteract the random thermal motion of nanoscale objects in solution several optical, microfluidic, and
nanofluidic methodologies have been developed over the years. The optical trapping of nanoscale objects
(\SI{<50}{\nm} radius) requires the sub-diffraction limited confinement of light~\cite{Neuman-2004,Baker-2017,
Bradac-2018} which can be achieved with photonic~\cite{Yang-2009,Mandal-2010} or
plasmonic~\cite{Juan-2009,Chen-2011,
Pang-2011,Bergeron-2013,Kotnala-2014,Kerman-2015,Chen-2018,Verschueren-2019}, nanostructures. Although optical
techniques have been shown be capable of trapping proteins with a radius of
\SI{\approx2.3}{\nm}~\cite{Kotnala-2014}, the high optical intensities required and the solid-state nature of
the devices tend to not only trap the proteins but also unfold them, limiting the scope of their
applicability~\cite{Pang-2011, Verschueren-2019}.
Microfluidic techniques might offer softer alternatives for the immobilization of single molecules. The
\gls{abel} trap makes use of optical tracking to electrophoretically counteract the Brownian motion of
individual dielectric particles~\cite{Cohen-2005,Cohen-2006,Goldsmith-2010, Goldsmith-2011}, enabling the
trapping of proteins down to \SI{\approx2.9}{\nm} radius~\cite{Goldsmith-2011} and even single
fluorophores~\cite{Fields-2011}. Because this technique uses fluorescence microscopy to track the movement of
their targets, the observational time window is ultimately limited by the photobleaching of the
dye~\cite{Cohen-2005,Goldsmith-2010}.
Nanopores, which are nanometer-sized apertures in a membrane separating two electrolyte reservoirs, have been
used extensively to study single
molecules~\cite{Ma-2009,Laszlo-2016,Willems-VanMeervelt-2017,Varongchayakul-2018}. In nanopore analyses, an
electric field is applied across the membrane and information about a molecule passing through the pore is
collected by monitoring the modulations of the ionic charge current. As proteins typically transit the pore at
high velocities (\SIrange{\approx e-3}{e-2}{\meter\per\second})~\cite{Fologea-2007,Plesa-2013,Li-2013B,
Larkin-2014}, the dwell time (\ie~the duration a molecule of interest spends inside the observable volume) is
on the order of \SIrange{e-6}{e-3}{\second}. These timescales have proven sufficient for obtaining structural
information such as protein size, shape, charge, dipole moment, and
rigidity~\cite{Fologea-2007,Larkin-2014,Waduge-2017,Hu-2018,Houghtaling-2019}, but they are too brief to
efficiently study the enzymatic cycle of the majority of human enzymes (turnover numbers between
\SIrange{e-3}{e3}{\per\second}).
%
\begin{figure*}[t]
%
\begin{minipage}{6cm}
%
\begin{subfigure}[t]{5.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_concept_clya}
\includegraphics[scale=1]{trapping_concept_clya}
\end{subfigure}
%
\end{minipage}
%
\begin{minipage}{6cm}
%
\begin{subfigure}[t]{5.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_concept_dhfr}
\includegraphics[scale=1]{trapping_concept_dhfr}
\end{subfigure}
%
\\
%
\begin{subfigure}[t]{5.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_concept_sequence}
\includegraphics[scale=1]{trapping_concept_sequence}
\end{subfigure}
%
\end{minipage}
\caption[Trapping of proteins inside the {ClyA-AS} nanopore]{%
\textbf{Trapping of proteins inside the {ClyA-AS} nanopore.}
%
(\subref{fig:trapping_concept_clya})
%
Surface representation of a type I \gls{clya-as} nanopore embedded in a planar lipid bilayer (derived
through homology modeling from \pdbid{2WCD}~\cite{Mueller-2009}, see~\cref{sec:elec:methods:molec}), and
colored according to its electrostatic potential in \SI{150}{\mM} \ce{NaCl} (calculated by
\gls{apbs}~\cite{Baker-2001,Dolinsky-2004,Dolinsky-2007}, see~\cref{sec:elec:methods:elec}).
%
%
(\subref{fig:trapping_concept_dhfr})
%
Depiction of a single \glsfirst{dhfr} molecule extended with a positively charged C-terminal polypeptide tag
(\DHFR{4}{S}) inside a \gls{clya-as} nanopore. The secondary structure of the tag (primarily
\textalpha-helical) was predicted by the {PEP-FOLD} server~\cite{Thevenet-2012,Shen-2014}. At negative
applied bias voltages relative to \transi{}, the electric field ($\protect\overrightarrow{E}$) is expected
to pull the negatively charged body of \gls{dhfr} upward ($\forceep^{\rm{body}}$) and the positively charged
fusion tag downward ($\forceep^{\rm{tag}}$), while the electro-osmotic flow pushes the entire protein
downward ($\forceeo$). Lastly, as the body of \gls{dhfr} is larger than the diameter of the \transi{}
constriction, the force required to overcome the steric hindrance ($\forcest$) during full
\cisi{}-to-\transi{} translocation is expected to be significant.
%
(\subref{fig:trapping_concept_sequence})
%
Sequence of \DHFR{4}{S} fusion tag with its positive and negative residues colored blue and red,
respectively. The sequence of the Strep-tag starts at residue 183, and the GSS and GSA linkers are shown in
italicized font. Note that, at \pH{7.5}, the C- and N-termini contribute one negative charge to the body and
one positive charge to the tag, respectively.
%
%
Images were rendered using \gls{vmd}~\cite{Humphrey-1996,Stone-1998}.
%
}\label{fig:clya_dhfr_trapping_concept}
\end{figure*}
%
To increase the observation window of proteins by nanopores, researchers have made extensive use of
noncovalent interactions. By coating solid-state nanopores with \gls{nta} receptors, the dwell time of
His-tagged proteins could be prolonged up to six orders of magnitude~\cite{Wei-2012}. In another account, the
diffusion coefficient of several proteins was reduced 10-fold \textit{via} tethering to a lipid bilayer coated
nanopore~\cite{Yusko-2011,Yusko-2017}. The decoration of biological nanopores with thrombin-specific aptamers
enabled the investigation of the binding kinetics of thrombin to its aptamer~\cite{Rotem-2012} and the
selective detection in the presence of a 100-fold excess of non-cognate proteins~\cite{Soskine-2012}.
Electrophoretic translocation of protein-DNA complexes through small nanopores (\SI{<3}{\nm} diameter)
typically results in the temporary trapping of the entire complex, which has allowed for the study of
polymerase enzymes~\cite{Lieberman-2010,Derrington-2015} and DNA-binding
proteins~\cite{Squires-2015,Yang-2018}. Although promising, none of these approaches could efficiently control
the trapping of the protein inside the nanopore or allow observation of enzyme kinetics or ligand-induced
conformational changes.
The energetic landscape of a protein translocating through a nanopore stems directly from the electrostatic,
electrophoretic, electro-osmotic, and steric forces exerted on it~\cite{Muthukumar-2014}. Given the relatively
high motility of proteins, the creation of a long lasting (\SIrange{10}{100}{\second}), contact-free trap
within a spatial region of a few nanometers mandates the presence of a deep potential energy well within the
nanopore~\cite{Movileanu-2005}. Such a potential profile was achieved by Luchian and co-workers, who showed
that the dwell time of a polypeptide inside the \gls{ahl} pore could be significantly increased by
manipulating the strength of the electro-osmotic flow~\cite{Mereuta-2014,Asandei-2016} or by placement of
oppositely charged amino acids at the polypeptide's termini~\cite{Asandei-2015}. In a similar approach, a
single barnase enzyme was trapped inside \gls{ahl} \textit{via} the addition of a positively charged
N-terminal tag~\cite{Mohammad-2008}.
Previous work in the Maglia group on protein analysis with nanopores was centered around the biological
nanopore \glsfirst{clya}---a protein with a highly negatively charged interior whose shape can best be
described by a large (\SI{\approx 5.5}{\nm} diameter, \SI{\approx 10}{\nm} height, \cisi{} \lumen{}) and a
small (\SI{\approx 3.3}{\nm} diameter, \SI{\approx 4}{\nm} height, \transi{} constriction) cylinder stacked on
top of each other (\cref{fig:trapping_concept_clya})~\cite{Soskine-2012,Soskine-2013}. Upon capture from the
\cisi{} side of the pore, certain proteins exhibited exceptionally long dwell times inside \gls{clya} from
seconds up to tens of
minutes~\cite{Soskine-2012,Soskine-2013,Soskine-Biesemans-2015,Wloka-2017,VanMeervelt-2017,Galenkamp-2018},
enabling the monitoring of conformational changes~\cite{VanMeervelt-2014, Galenkamp-2018,Biesemans-2015} and
even of the orientation~\cite{VanMeervelt-2014} of the proteins inside the nanopore. A subset of the
investigated proteins, such as lysozyme, Dendra2\_M159A and \glsfirst{dhfr}, resided inside the nanopore
\lumen{} only for hundreds of microseconds and hence could not be
studied~\cite{Soskine-2012,Soskine-Biesemans-2015}. It was observed that the size of the nanopore plays a
crucial role in the effectiveness of protein trapping, as a mere \SI{<10}{\percent} increase of \gls{clya}'s
diameter (\ie~by using \gls{clya} nanopores with a higher oligomeric state) is enough to reduce the dwell time
of proteins by almost three orders of magnitude~\cite{Soskine-2013}. Next to pore size, the charge
distribution of proteins can significantly affect their dwell time inside a nanopore. For example, the binding
of the negatively charged (\SI{-2}{\ec}) inhibitor \gls{mtx} to a modified \gls{dhfr} molecule with positively
charged fusion tag at the C-terminus (\DHFRt{}) increased the dwell time of the protein inside the \gls{clya}
nanopore from \SI{\approx3}{\ms} to \SI{\approx3}{\second} at \SI{-90}{\mV}~\cite{Soskine-Biesemans-2015}.
In this work the immobilization of individual \textit{Escherichia coli} \gls{dhfr} molecules
(\cref{fig:trapping_concept_dhfr}) inside the \gls{clya} biological nanopore (specifically type I
\gls{clya}-AS~\cite{Soskine-2013}, \cref{fig:trapping_concept_clya}) is investigated in detail. Using
nanoscale protein electrostatic simulations as a guideline, our results show that the dwell time of
\DHFR{4}{S}---a molecule identical to the above-mentioned \DHFRt{} aside from the insertion of a single
alanine residue its fusion tag (A174\_A175insA, \cref{fig:trapping_concept_sequence})---inside \gls{clya} can
be increased several orders of magnitude by manipulating the distribution of positive and negative charges on
its surface. To elucidate the physical origin of the trapping mechanism, a double energy barrier model was
developed which---by fitting the voltage dependency of the dwell times for various \gls{dhfr} mutants---yields
direct estimates of the \cisi{} and \transi{} translocation rates and the magnitude of force exerted by the
electro-osmotic flow on \gls{dhfr}\@. Our method provides an efficient means to increase the dwell time of the
\gls{dhfr} protein inside the \gls{clya} nanopore and suggests a general mechanism to tune the dwell time of
other proteins, which we believe has significant value for single-molecule sensing and analysis applications.
%
\section{Results and discussion}
%
\label{sec:trapping:results_discussion}
%
\subsection{Phenomenology of {DHFR} trapped inside {ClyA}}
%
\label{sec:trapping:phenomenology}
%
To effectively study the enzymes at the single-molecular level, one must be able to collect a statistically
significant (\ie~typically hundreds) of catalytic cycles from the same enzyme. In the case of the
\textit{E.~coli} \gls{dhfr}, which has a turnover number of \SI{\approx0.08}{\second}~\cite{Kohen-2015}, this
means that the protein must remain trapped inside the pore for tens of seconds. However, as detailed above,
such long dwell times were only achieved for \gls{dhfr} by adding a positively charged polypeptide tag to the
C-terminus of \gls{dhfr}, together with the binding of the negatively charged inhibitor
\gls{mtx}~\cite{Soskine-Biesemans-2015}. Although these long dwell times are encouraging, the requirement for
\gls{mtx} excludes the study of the full enzymatic cycle. Hence, using these previous findings as a starting
point we aim to find out how to prolong the dwell time of a tagged \gls{dhfr} molecule inside the
\gls{clya-as} nanopore without the use of \gls{mtx} and to understand the fundamental physical mechanisms that
determine the escape of \gls{dhfr} from the pore.
The structure of \DHFR{4}{S}, the tagged \gls{dhfr} molecule used as a starting point in this work, can be
roughly divided into a `body', which encompasses the enzyme itself and has a net negative charge,
$\Nbody=\mSI{-10}{\ec}$, and a `tag', which comprises the C-terminal polypeptide extension and bears a net
positive charge, $\Ntag=\mSI{+4}{\ec}$ (\cref{fig:trapping_concept_dhfr,fig:trapping_concept_sequence}). To
capture a tagged \gls{dhfr} molecule, an electric field oriented from \cisi{} to \transi{} (\ie~negative bias
voltage) must be applied across the nanopore which gives rise to an electro-osmotic flow pushing the protein
into the pore ($\forceeo$). The electrophoretic force on the body ($\forceep^{\rm{body}}$) strongly opposes
this electro-osmotic force, but is significantly weakened by the electrophoretic force on the tag
($\forceep^{\rm{tag}}$), allowing the protein to be
captured~\cite{Soskine-2012,Soskine-Biesemans-2015,Biesemans-2015}. As the body and tag of the \gls{dhfr}
molecules bear a significant amount of opposing charges, it is likely that the molecule will align itself with
the electric field, where the tag is oriented toward the \transi{} side. In this configuration the body sits
in the \gls{clya} \lumen{} and the tag is located in or near the narrow constriction. Because the body
(\SI{\approx4}{\nm}) is larger than the diameter of the constriction (\SI{3.3}{\nm}), the steric hindrance
between the body and the pore is expected to strongly disfavor full translocation to the \transi{} reservoir,
giving rise to an apparent `steric hindrance' force ($\forcest$). Finally, Poisson-Boltzmann electrostatic
calculations showed that the negatively charged interior of \gls{clya-as} creates a negative electrostatic
potential within both the \lumen{} (\SI{\approx-0.3}{\kTe}) and the constriction (\SI{\approx-1}{\kTe}) of the
pore~\cite{Franceschini-2016}, which will result in unfavorable and favorable interactions with the body and
the tag, respectively.
%
\begin{figure*}[p]
\centering
\begin{minipage}{6cm}
%
\begin{subfigure}[t]{5.5cm}
\caption{}\vspace{-3mm}\label{fig:trapping_apbs_model}
\includegraphics[scale=1]{trapping_apbs_model}
\end{subfigure}
%
\\
%
\begin{subfigure}[t]{5.5cm}
\caption{}\vspace{-3mm}\label{fig:trapping_apbs_energy}
\includegraphics[scale=1]{trapping_apbs_pqrs}
\includegraphics[scale=1]{trapping_apbs_energy_landscape}
\end{subfigure}
%
\end{minipage}
%
\hspace{-5mm}
%
\begin{minipage}{6cm}
%
\begin{subfigure}[t]{5.5cm}
\caption{}\vspace{-3mm}\label{fig:trapping_apbs_barrier_body}
\includegraphics[scale=1]{trapping_apbs_barrier_body}
\end{subfigure}
%
\\
%
\begin{subfigure}[t]{5.5cm}
\caption{}\vspace{-3mm}\label{fig:trapping_apbs_barrier_tag}
\includegraphics[scale=1]{trapping_apbs_barrier_tag}
\end{subfigure}
%
\end{minipage}
\caption[Energy landscape of \DHFR{4}{S} inside {ClyA-AS}]{%
\textbf{Energy landscape of \DHFR{4}{S} inside {ClyA-AS}.}
%
(\subref{fig:trapping_apbs_model})
%
Coarse-grained model of \DHFR{4}{S} used in the electrostatic energy calculations in \gls{apbs}\@. The
body of \gls{dhfr} consists of seven negatively charged (\SI{-1.43}{\ec}) beads (\SI{1.6}{\nm} diameter)
in a spherical configuration (\SI{0.8}{\nm} spacing), whereas the tail is represented by a linear string
of beads (\SI{1}{\nm} diameter, \SI{0.6}{\nm} spacing), each holding the net charge of three amino acids.
%
%
(\subref{fig:trapping_apbs_energy})
%
Electrostatic energy ($\energyelec$) resulting from a series of \gls{apbs} energy calculations where the
coarse-grained \DHFR{4}{S} bead model is moved along the central axis of the pore. The distances $\dxcis$
and $\dxtrans$ refer to the distances between the energy minimum near the bottom of the \lumen{}
($z_{\rm{body}} = \mSI{3}{\nm}$) and the maximum at, respectively, \cisi{} ($z_{\rm{body}} =
\mSI{5.7}{\nm}$) and \transi{} ($z_{\rm{body}} = \mSI{-0.6}{\nm}$)
%
%
(\subref{fig:trapping_apbs_barrier_body})
%
Although every additional negative charge to the body of \gls{dhfr} increases the \transi{} electrostatic
barrier by \SI{1.46}{\kT}, it has virtually no effect on the \cisi{} barrier, which increases only by
\SI{0.04}{\kT} per charge.
%
%
(\subref{fig:trapping_apbs_barrier_tag})
%
Addition of a single positive charge to \gls{dhfr}'s tag affects the height of the \transi{} and \cisi{}
much more similarly, with increases of \SI{0.875}{\kT} and \SI{0.621}{\kT} per charge, respectively.
%
}\label{fig:apbs_simulation_results}
\end{figure*}
%
\subsection{Energy landscape of {DHFR} in {ClyA}}
%
To increase the dwell time of \gls{dhfr}---and to generalize our findings for other proteins---it is necessary
to understand how the forces exerted on \gls{dhfr} inside the pore behave as a function of the experimental
conditions (\ie~charge distribution and applied bias). In the absence of specific high affinity interactions,
\gls{dhfr}'s trapping behavior should be chiefly determined by its electrostatic interactions with the pore,
whereas the external electrophoretic and electro-osmotic forces can be viewed as modifications thereof. Hence,
we will start by investigating the molecule's electrostatic energy landscape within \gls{clya} in equilibrium
where the externally applied electric field vanishes.
To this end, we used \gls{apbs}~\cite{Baker-2001,Dolinsky-2004,Dolinsky-2007,Li-2005} to compute the
electrostatic energy ($\energyelec$) of a simplified bead-like tagged \gls{dhfr} molecule model as it moves
through the pore (\cref{fig:trapping_apbs_model,fig:trapping_apbs_energy}), similar to the approach used in
\cref{ch:electrostatics} (\cref{sec:elec:methods:elec:energy}) to investigate \gls{ssdna}
(\cref{sec:elec:frac:dna}) and \gls{dsdna} (\cref{sec:elec:clya:dna}) translocation through \gls{frac} and
\gls{clya}, respectively. The tagged \gls{dhfr} molecule was reduced to a coarse-grained `bead' model
(\cref{fig:trapping_apbs_model}), where the bulk of the protein (body) was defined by seven negatively charged
beads ($r = \SI{0.8}{\nm}$, $Q_i = \SI{-1.7143}{\ec}$) in a spherical configuration (\SI{0.8}{\nm} spacing);
and the C-terminal fusion tag (tail) was represented by nine smaller beads ($r = \SI{0.5}{\nm}$,
$\partialcharge{}_i = \num{-3}$ to \SI{+3}{\ec} depending on the amount of charges in their corresponding
amino acids) each representing three amino acids in an alpha-helix (\SI{0.6}{\nm} spacing). Our reasons for
this simplification were two-fold: (1) the high degree of axial symmetry in the bead model resulted in a free
energy that was independent of the precise orientation of \gls{dhfr}, significantly reducing the number of
required computations; and (2) the reduced body size of the coarse-grained model compared to the full atom
model allowed for the placement of \gls{dhfr} along the entire length of the pore without nonphysical overlaps
between the atoms of \gls{clya} and \gls{dhfr} inside the \transi{} constriction, resulting in more realistic
free energies. This allows the body to pass the constriction without necessitating conformational changes,
which cannot be modeled using \gls{apbs}. Hence, this also means that the magnitude of maxima of the
electrostatic energy landscape, which occur when the charges of the bead model come close to those of the
pore, should be viewed as indicative and not absolute.
Nevertheless, the energy profile of \DHFRt{} (\cref{fig:trapping_apbs_energy}) clearly shows that there is a
significant electrostatic barrier, $\barrier^{\trans}_{\rm{es}}$, to overcome when the body of the \gls{dhfr}
moves through the constriction of the pore. Moreover, we observed a second smaller electrostatic barrier,
$\barrier^{\cis}_{\rm{es}}$, toward the \cisi{} side so that an energetic minimum exists inside \gls{clya} in
which the molecule can reside. The size difference between these two barriers clearly suggests that in the
absence of an external force (\ie~at \SI{0}{\mV} bias) the molecule will exit toward \cisi{} with overwhelming
probability. Nevertheless, the multiple distinct blockade current levels observed experimentally
(see~\cref{fig:trapping_traces}) suggest the presence of multiple energy minima within the pore, of which the
equilibrium energy landscape might provide a potential physical location.
To estimate how the charges on \gls{dhfr} impact its dwell time, we modified the number of charges in the body
from \SIrange{-10}{-13}{\ec} and recomputed the energy landscape using \gls{apbs}
(\cref{fig:trapping_apbs_barrier_body}). We found that the electrostatic energy barrier toward \cisi{} was
largely unaffected (\SI{0.04}{\kT} increase per negative charge) while the barrier for \transi{} exit
increased significantly (\SI{1.46}{\kT} increase per negative charge). The latter is a reflection of the
highly negatively charged and narrow \transi{} constriction of \gls{clya}.
Contrary to the body of \gls{dhfr}, the modification of the charge in the tag from \num{+4} to \SI{+9}{\ec}
influenced the heights of both the \cisi{} and the \transi{} barrier similarly, with increases of
\SI{0.621}{\kT} and \SI{0.875}{\kT} per positive elementary charge, respectively
(\cref{fig:trapping_apbs_barrier_tag}). This behavior can be explained by the fact that, at \gls{dhfr}'s
equilibrium position within the pore, the positively charged tag resides in the highly negatively
electrostatic well present in the \transi{} constriction of the nanopore (\cref{fig:trapping_apbs_energy}).
Moving the molecule from this position into either direction requires this Coulombic attraction to be overcome
which is directly proportional to the number of charges on the tag, irrespective of whether the molecule moves
toward \cisi{} or toward \transi{}.
Note that when an external electric field is applied, the electrophoretic and electro-osmotic forces must be
taken into account. If their net balance is positive (\ie~a net force toward \cisi{}) or negative (\ie~a net
force toward \transi{}), the electrostatic landscape will be tilted upward and downward, respectively
(see~\cref{fig:trapping_apbs_external_biased}). The capture of highly negative charged (\SI{-11}{\ec}) wild
type \gls{dhfr} molecules against the electric field~\cite{Soskine-Biesemans-2015} strongly indicates that the
electro-osmosis outweighs electrophoresis and the energy landscape will be shifted downward at \transi{}
(see~\cref{sec:trapping:biased_landscape}), resulting in higher and lower barrier heights at \cisi{} and
\transi{}, respectively. This effectively deepens the energy minimum, which should manifest as an increase of
\gls{dhfr}'s dwell time.
\subsection{Dwell time measurements}
%
The entry of a single protein into \gls{clya} results in a temporary reduction of the ionic current from the
`open pore' ($\iopen$) to a characteristic `blocked pore' ($\iblock$) level. Previously, we revealed that the
\gls{dhfr} protein shows a main current blockade with $\iresp = \iblock / \iopen \approx \SI{70}{\percent}$
(see~\cref{fig:trapping_traces}). However, occasionally deeper blocks are observed which most likely represent
the transient visit of \gls{dhfr} to multiple locations inside the nanopore. Here we assume that the dwell
time ($\dwelltime$) is simply given by the time from the initial capture to the final release where the
current level returns to the open pore current.
After gathering sufficient statistics for the dwell time events, we computed the expectation value of
$\dwelltime$ by taking the arithmetic mean of all dwell time events. This is because the chance for an escape
can be modeled as the probability of overcoming a potential barrier whose distribution function is exponential
(see~\cref{sec:trapping_appendix:escape_rates}). Note that even if the molecule transitions through multiple
meta-states with individual rates connecting each of them before it exits, the expectation value is still
given by the arithmetic mean (see~\cref{eq:tau_arithmetic_mean}).
%
\begin{table}[t]
\begin{threeparttable}
\centering
\footnotesize
%
\captionsetup{width=12cm}
\caption[Mutations and charges of all {DHFR} variants]%
{Mutations and charges of all {DHFR} variants.}
\label{tab:dhfr_variants}
%
\renewcommand{\arraystretch}{1.15}
\scriptsize
\begin{tabularx}{12cm}{Xllccc}
\toprule
& \multicolumn{2}{c}{Mutations\tnote{a}} &
\multicolumn{3}{c}{$\chargeq_{\rm{DHFR}}$\tnote{b} [\si{\ec}]} \\
\cmidrule(r){2-3} \cmidrule(l){4-6}
Name & Body & Tag & Body & Tag & Total \\
\midrule
\DHFR{4}{S} & --- & ---
& \num{-10} & \num{+4} & \num{-6} \\
\DHFR{4}{I} & V88E P89E & ---
& \num{-12} & \num{+4} & \num{-8} \\
\DHFR{4}{C} & A82E A83E & ---
& \num{-12} & \num{+4} & \num{-8} \\
\DHFR{4}{O1} & E71Q & ---
& \num{-12} & \num{+4} & \num{-8} \\
\DHFR{4}{O2} & T68E R71E & ---
& \num{-13} & \num{+4} & \num{-9} \\
\midrule
\DHFR{5}{O1} & E71Q & A175K
& \num{-12} & \num{+5} & \num{-7} \\
\DHFR{7}{O1} & E71Q & A175K A174K A176K
& \num{-12} & \num{+7} & \num{-5} \\
\DHFR{5}{O2} & T68E R71E & A175K
& \num{-13} & \num{+5} & \num{-8} \\
\DHFR{6}{O2} & T68E R71E & A175K A174K
& \num{-13} & \num{+6} & \num{-7} \\
\DHFR{7}{O2} & T68E R71E & A175K A174K A176K
& \num{-13} & \num{+7} & \num{-6} \\
\DHFR{8}{O2} & T68E R71E & A175K A174K A176K A169K
& \num{-13} & \num{+8} & \num{-5} \\
\DHFR{9}{O2} & T68E R71E & A175K A174K A176K A169K L177K
& \num{-13} & \num{+9} & \num{-4} \\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\item[a] W.r.t. \DHFR{4}{S}: body residues \numrange{1}{163} and tag residues \numrange{164}{190};
\item[b] Net charge of \gls{dhfr} at \pH{7.5}.
\end{tablenotes}
\end{threeparttable}
\end{table}
%
We observed before that the dwell time of tagged \gls{dhfr} molecules depends strongly on the applied
bias~\cite{Biesemans-2015}. That is, exponentially rising with voltage until a certain bias---which we will
refer to as the \emph{threshold voltage}---followed by an exponential fall. This behavior has also been
observed for charged peptides in \gls{ahl}~\cite{Movileanu-2005}, and is typical for a decay of a bound state
into multiple final states, such as an escape to either \cisi{} or \transi{}
(see~\cref{sec:trapping_appendix:escape_rates}). Therefore, the dwell time of the molecule, as a function of
bias voltage, $\vbias$, can be expressed as the inverse of the sum of two escape rates~\cite{Movileanu-2005}
%
\begin{align}\label{eq:double_barrier_simple}
\dfrac{1}{\dwelltime} = \rate ={}& \rate^\cis + \rate^\trans \\
={}&
\rate^\cis_0 \exp \left( -\dfrac{\alpha^\cis \ec \vbias}{\kbt} \right) +
\rate^\trans_0 \exp \left( \dfrac{\alpha^\trans \ec \vbias}{\kbt} \right)
\text{ ,}
\end{align}
%
where $\rate^{\cis/\trans}$ are the molecule's escape rates toward \cisi{} and \transi{}, respectively. These
can be further decomposed into attempt frequencies $\rate^{\cis/\trans}_0$ and bias dependent barriers in the
exponentials. Although this equation can help to qualitatively describe the experimental data, the reduction
of the entire protein-nanopore system to four parameters does not allow for their physical interpretation.
%
\begin{figure*}[p]
\centering
%
\begin{subfigure}[t]{4cm}
\centering
\caption{}\vspace{-5mm}\label{fig:trapping_dwell_times_body_model}
\includegraphics[scale=1]{trapping_dwell_times_body_model}
\end{subfigure}
%
\begin{subfigure}[t]{6.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_dwell_times_body_data}
\includegraphics[scale=1]{trapping_dwell_times_body_data}
\end{subfigure}
%
\caption[Effect of the body charge on the dwell time of tagged {DHFR}]{%
\textbf{Effect of the body charge on the dwell time of tagged {DHFR}\@.}
%
(\subref{fig:trapping_dwell_times_body_model})
%
Surface representation of the five tested \DHFR{4}{X} body charge mutants, and the \DHFR{4}{S}+MTX
complex. The mutated residues are indicated for each variant. The positive charges in the fusion tag are
colored blue. From top to bottom: \DHFR{4}{S}, \DHFR{4}{I}, \DHFR{4}{C}, \DHFR{4}{O1}, \DHFR{4}{O2}, and
\DHFR{4}{S}$_{\text{MTX}}$.
%
%
(\subref{fig:trapping_dwell_times_body_data})
%
Voltage dependence of the average dwell time ($\dwelltime$) inside \gls{clya-as} for \gls{dhfr} mutants in
(\subref{fig:trapping_dwell_times_body_model}). The solid lines represent the voltage dependency predicted
by fitting the double barrier model given by \cref{eq:double_barrier_simple} to the data
(see~\cref{tab:fitting_parameters_simple}). The dotted lines represent the dwell times due the \cisi{}
(low to high) and \transi{} (high to low) barriers. The threshold voltages at the maximum dwell time were
estimated by inserting the fitting parameters into \cref{eq:threshold_voltage_simple}. The error envelope
represents the minimum and maximum values obtained from repeats at the same condition. All measurements
were performed at \SI{\approx28}{\celsius} in aqueous buffer at \pH{7.5} containing \SI{150}{\mM}
\ce{NaCl}, \SI{15}{\mM} \ce{Tris-HCl}. Current traces were sampled at \SI{10}{\kilo\hertz} and filtered
using a low-pass Bessel filter with a \SI{2}{\kilo\hertz} cutoff.
%
}\label{fig:trapping_dwell_times_body}
\end{figure*}
%
\subsection[Engineering {DHFR}'s dwell time by manip. of its charge]%
{Engineering {DHFR}'s dwell time by manipulation of its charge}
%
The results from the \gls{apbs} simulations, together with the previous work with \DHFRt{} and
\gls{mtx}~\cite{Soskine-Biesemans-2015}, suggest that the dwell time of \gls{dhfr} in \gls{clya} can be
increased by the manipulation of its charge distribution. To achieve the increase in dwell time without the
need for \gls{mtx}, several non-conserved amino acids on the surface of \DHFR{4}{S} were identified and
mutated to negatively charged glutamate residues, resulting in the molecules \DHFR{4}{I}, \DHFR{4}{C},
\DHFR{4}{O1}, and \DHFR{4}{O2} (\cref{tab:dhfr_variants} and \cref{fig:trapping_dwell_times_body_model}).
These mutations modify the number of charges in the body compared to \DHFR{4}{S} and their charges are also in
different locations. For convenience, this series of mutations will be referred to as the \emph{body charge
variations} from here on out.
We performed ionic current measurements for all body charge variations for a wide range of bias voltages
(\SIrange{-40}{-120}{\mV}, see~\cref{fig:trapping_traces,fig:trapping_blockades}) and extracted the dwell
times as shown in \cref{fig:trapping_dwell_times_body_data}. All body charge variations showed the same
increase of the dwell time at low electric fields and decreased at high fields. However, we observed
differences in the threshold voltage and the magnitude of the maximum dwell time. These differences cannot
simply be explained by the total number of charges as \DHFR{4}{I} and \DHFR{4}{C} have the same charge as
\DHFR{4}{O1} but their dwell times are 10-fold lower (\cref{fig:trapping_dwell_times_body_data}). This result
implies that the location of the body charge on \gls{dhfr} plays an important role.
Additional body mutations could potentially compromise the catalytic cycle of \gls{dhfr}\@. Hence, we
proceeded by systematically increasing the number of positive charges to the fusion tag ($\Ntag$) of
\DHFR{4}{O2}, the variant that exhibited the longest dwell time, \textit{via} lysine substitution from
\SIrange{+4}{+9}{\ec} (\cref{tab:dhfr_variants,fig:trapping_dwell_times_tag}). The resulting
\DHFR{$\Ntag$}{O2} mutants will be referred to as the \emph{tag charge variations}.
Subsequent characterization of their the dwell times revealed that the addition of positive charges to the tag
significantly increased \gls{dhfr}'s dwell time (\cref{fig:trapping_dwell_times_tag_data}). We observed a
similar increase for \DHFR{4}{O1} variants with \num{+5} and \num{+7} tag charge numbers
(see~\cref{fig:trapping_model_comparison_o1_simple}). This behavior is consistent with the tag being trapped
electrostatically inside the negatively charged \transi{}
constriction~\cite{Franceschini-2016,Movileanu-2005,Asandei-2015,Asandei-2016} and it suggests that the tag
plays a crucial role in the trapping of \gls{dhfr}, which was already observed in previous
work~\cite{Soskine-Biesemans-2015}.
%
\begin{figure*}[p]
\centering
%
\begin{subfigure}[t]{4.5cm}
\centering
\caption{}\vspace{-5mm}\label{fig:trapping_dwell_times_tag_model}
\includegraphics[scale=1]{trapping_dwell_times_tag_model}
\end{subfigure}
%
\begin{subfigure}[t]{6.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_dwell_times_tag_data}
\includegraphics[scale=1]{trapping_dwell_times_tag_data}
\end{subfigure}
%
\caption[Effect of the tag charge on the dwell time of \DHFR{$\Ntag$}{O2}]{%
\textbf{Effect of the tag charge on the dwell time of \DHFR{$\Ntag$}{O2}.}
%
(\subref{fig:trapping_dwell_times_tag_model})
%
Surface representations of all \DHFR{$\Ntag$}{O2} mutants going from $\Ntag=4$ (top) to $\Ntag=9$
(bottom). The positively charged residues in the tag have been annotated and highlighted in blue.
%
%
(\subref{fig:trapping_dwell_times_tag_data})
%
Voltage dependencies of the mean dwell time ($\dwelltime$) for the mutant on the left hand side, fitted
with the double barrier model of \cref{eq:double_barrier_complex}. The annotated threshold voltages were
computed by ESI \cref{eq:threshold_voltage_complex}. Solid lines represent the double barrier dwell time,
and the dotted lines show the dwell times due the \cisi{} (low to high) and \transi{} (high to low)
barriers. Fitting parameters can be found in \cref{tab:fitting_params_complex}. The error envelope
represents the minimum and maximum values obtained from repeats at the same condition. Experimental
conditions are the same as those in \cref{fig:trapping_dwell_times_body}.
%
}\label{fig:trapping_dwell_times_tag}
\end{figure*}
%
\subsection{Binding of {NADPH} reveals that {DHFR} remains folded inside the pore}
%
To verify that our \gls{dhfr} variants remained folded inside the nanopore, we measured and analyzed the
binding of \gls{nadph} to the enzyme. The addition of the \gls{nadph} co-factor to the \transi{} solution of
nanopore-entrapped \gls{dhfr} molecules induced reversible ionic current enhancements that reflect the binding
and unbinding of the co-factor to the protein (\cref{fig:trapping_nadph_trace} and
\cref{fig:trapping_nadph_o2_traces,tab:nadph_rates}).
Not all \gls{dhfr} variants were found to be suitable for \gls{nadph}-binding analysis: \DHFR{5}{O2} did not
dwell long enough inside \gls{clya-as} at \SI{-60}{\mV} ($\dwelltime = \SI{0.32\pm0.17}{\second}$) to allow a
detailed characterization of \gls{nadph} binding, whereas \gls{nadph}-binding events to \DHFR{8}{O2} were too
noisy for a proper determination of $\rate_{\rm{on}}$ and $\rate_{\rm{off}}$. No \gls{nadph} binding events to
\DHFR{9}{O2} could be observed. \gls{nadph}-binding events to the other \gls{dhfr} variants (\DHFR{5}{O2},
\DHFR{6}{O2}, and \DHFR{7}{O2}) showed similar values for $\rate_{\rm{on}}$, $\rate_{\rm{off}}$, and event
amplitude (\cref{tab:nadph_rates}), suggesting that the binding of \gls{nadph} to \gls{dhfr} inside the
\gls{clya-as} nanopore is not affected by the number of positive charges in the C-terminal fusion tag.
Possibly, the inability of \DHFR{8}{O2} and \DHFR{9}{O2} to bind the substrate is due the lodging of
\gls{dhfr} closer to the \transi{} constriction.
%
\begin{figure*}[!t]
\centering
%
\begin{subfigure}[t]{6.25cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_nadph_trace}
\includegraphics[scale=1]{trapping_nadph_trace}
\end{subfigure}
%
\begin{subfigure}[t]{5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_nadph_ires}
\includegraphics[scale=1]{trapping_nadph_ires}
\end{subfigure}
%
\caption[Binding of NADPH to \DHFR{7}{O2}.]{%
\textbf{Binding of NADPH to \DHFR{7}{O2}.}
%
(\subref{fig:trapping_nadph_trace})
%
Top: Typical current trace after the addition of \SI{50}{\nM} \DHFR{7}{O2} to a single \gls{clya-as}
nanopore added to the \cisi{} reservoir at \SI{-60}{\mV} applied potential. The open-pore current
(`$\iopen$') and the blocked pore levels (`L1') are highlighted. Bottom: Current trace showing the blocked
pore current of a single \DHFR{7}{O2} molecule (\SI{50}{\nM}, \cisi) at \SI{-60}{\mV} applied potential
before (left) and after (right) the addition of \SI{27}{\uM} \gls{nadph} to the \transi{} compartment.
\Gls{nadph} binding to confined \gls{dhfr} molecule is reflected by current enhancements from the unbound
`L1' to the \gls{nadph}-bound `L1\textsubscript{NADPH}' current levels, and showed association
($\rate_{\rm{on}}$) and dissociation ($\rate_{\rm{off}}$) rate constants of
\SI{2.03\pm0.58e6}{\per\Molar\per\second} and \SI{71.2\pm20.4}{\per\second}, respectively
(see~\cref{tab:nadph_rates}).
%
(\subref{fig:trapping_nadph_ires})
%
Dependence of the $\iresp$ on the applied potential for \DHFR{7}{O2} and \DHFR{7}{O2} bound to
\gls{nadph}\@. All current traces were collected in \SI{250}{\mM} \ce{NaCl} and \ce{15}{\mM}
\ce{Tris-HCl}, \pH{7.5}, at \SI{23}{\celsius}, by applying a Bessel low-pass filter with a
\SI{2}{\kilo\hertz} cutoff and sampled at \SI{10}{\kilo\hertz}.
%
}\label{fig:trapping_nadph}
\end{figure*}
Work with solid-state nanopores also previously reported that electric fields inside a nanopore may unfold
proteins during translocation~\cite{Talaga-2009}, suggesting that the high degree of charge separation between
the body and tag of \gls{dhfr} might destabilize its structure. To further investigate the effect of the
applied potential on the protein structure, we analyzed the dependency of the residual current on the applied
potential (\cref{fig:trapping_nadph}). We found that the residual current of both the apo-\gls{dhfr} and the
ligand-bound enzyme increased by \SI{\approx2.5}{\percent} from \SIrange{-60}{-100}{\mV}. A voltage-dependent
change in residual current is compatible with a force-induced stretching of the enzyme. However,
single-molecule force spectroscopy experiments showed that \gls{nadph} binding increases the force required to
unfold the protein by more than 3-fold from \num{27} to \SI{98}{\pN}~\cite{Ainavarapu-2005}. As the change of
residual current over the potential was identical for both apo- and ligand-bound \gls{dhfr}
(\cref{fig:trapping_nadph}), a likely explanation is that, rather than stretching \gls{dhfr}, the applied bias
changes the position of \gls{dhfr} within the nanopore. Hence, our data suggest that, as previously reported
for several other proteins~\cite{VanMeervelt-2017,Galenkamp-2018}, the protein remains folded at different
applied bias.
\subsection{Double barrier model for the trapping of {DHFR}}
Puzzled by the strong dependence of the dwell time on the tag charge, we set out to understand the underlying
trapping mechanism by building a quantitative model. To this end, we will focus on the data set of the dwell
time of \DHFR{$\Ntag$}{O2} shown in \cref{fig:trapping_dwell_times_tag_data}.
We propose a double barrier model that describes the trapping of the molecule as a combination of escape rates
toward \cisi{} and toward \transi{} (see~\cref{sec:trapping_appendix:double_barrier}). Similar to
\cref{eq:double_barrier_simple}, the dwell time is defined in terms of the rate $\rate$ which in turn is given
by the sum of the rate for \cisi{} exit and the rate for \transi{} exit. However, now we define the rates in
terms of energy barriers:
%
\begin{align}\label{eq:double_barrier}
\frac{1}{\dwelltime} = \rate =
\rate_0 \exp \left( - \dfrac{\barrier^{\cis}}{\kbt} \right)
+ \rate_0 \exp \left( - \dfrac{\barrier^{\trans}}{\kbt} \right)
\text{ ,}
\end{align}
%
where $\rate_0$ is the attempt rate and $\barrier^{\cis/\trans}$ are the energy barriers the molecule has to
overcome in order to escape toward \cisi{} and \transi{}, respectively. These can be readily decomposed into
\emph{steric}, \emph{electrostatic}, and \emph{external} contributions:
%
\begin{subequations}\label{eq:decomposition}
\begin{align}
\barrier^{\cis} ={}&
\barrier^{\cis}_{\steric,0}
+ \barrier^{\cis}_\static
+ \barrier^{\cis}_\ext \text{ , and,} \\
\barrier^{\trans} ={}&
\barrier^{\trans}_{\steric,0}
+ \barrier^{\trans}_\static
+ \barrier^{\trans}_\ext
\text{ .}
\end{align}
\end{subequations}
%
The steric components $\barrier^{\cis/\trans}_{\steric,0}$ are defined as those interactions of the molecule
with the nanopore that are not electrostatic in nature, such as size- or conformation-related effects as
\gls{dhfr} translocates through the narrow constriction toward \transi{}.
Supported by the \gls{apbs} simulations (\cref{fig:trapping_apbs_energy}) and the corresponding barrier
height to tag charge dependency analyses (\cref{fig:trapping_apbs_barrier_tag}), we infer that the
electrostatic components $\barrier^{\cis/\trans}_{\static}$ can be further decomposed as
%
\begin{subequations}\label{eq:static-barrier}
\begin{align}
\barrier^{\cis}_\static ={}&
\barrier^{\cis}_{\static,0}
+ \Ntag \ec \potbar_{\rm{tag}}^{\cis},\\
\barrier^{\trans}_\static ={}&
\barrier^{\trans}_{\static,0}
+ \Ntag \ec \potbar_{\rm{tag}}^{\trans}
\text{ ,}
\end{align}
\end{subequations}
%
where $\potbar_{\rm{tag}}^{\cis/\trans}$ are the electrostatic potentials associated with the tag charge
$\Ntag$ for the \cisi{} and \transi{} barriers (\ie~the change in barrier height per additional charge in
$\Ntag$) and $\barrier^{\cis/\trans}_{\static,0}$ are two constant terms that combine all electrostatic
interactions between the protein and the pore that do not depend on $\Ntag$ (\eg~body charge related
interactions with the electric fields in the nanopore).
%
\begin{table}[t]
\centering
\begin{threeparttable}
\footnotesize
\centering
%
\captionsetup{width=12cm}
\caption[Fitting parameters for \DHFR{$\Ntag$}{O2}]%
{Fitting parameters for \DHFR{$\Ntag$}{O2}.}
\label{tab:fitting_params_complex}
%
\renewcommand{\arraystretch}{1.5}
\scriptsize
\begin{tabularx}{12cm}{XXll}
\toprule
Parameter & Description & Type & Value\tnote{a} \\
\midrule
$\vbias$
& Applied bias voltage
& independent & \SIrange{40}{120}{\mV} \\
$\Ntag$
& Tag charge number
& independent & \SIrange{4}{9}{} \\
$\Nbody$
& Body charge number
& fixed & \SI{-13}{} \\
$\Neo$
& Equivalent osmotic charge number
& dependent & \SI{15.5\pm0.9}{} \\
$L$
& Nanopore length
& fixed & \SI{14}{\nm} \\
$\dxtrans$
& Distance to \transi{} barrier\tnote{b}
& fixed & \SI{3.5}{\nm} \\
$\dxcis$
& Distance to \cisi{} barrier\tnote{b}
& dependent & \SI{5.21\pm1.32}{\nm} \\
$\potbar_{\rm{tag}}^{\trans}$
& Change of $\barrier^{\trans}_\static$ with tag charge
& dependent & \SI{0.860\pm0.078}{\kbt\per\ec} \\
$\potbar_{\rm{tag}}^{\cis}$
& Change of $\barrier^{\cis}_\static$ with tag charge
& dependent & \SI{0.218\pm0.167}{\kbt\per\ec} \\
$\ln (\rateft/\si{\hertz})$
& Effective attempt rate for the \transi{} barrier
& dependent & \num{-3.44\pm1.24} (\SI{3.21e-2}{\hertz}) \\
$\ln (\ratefc/\si{\hertz})$
& Effective attempt rate for the \cisi{} barrier
& dependent & \num{7.39\pm1.02} (\SI{1.62e3}{\hertz}) \\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\item[a] Errors are confidence intervals for one standard deviation.
\item[b] Relative to the energetic minimum inside the pore.
\end{tablenotes}
\sisetup{table-format=2.4}
\end{threeparttable}
\end{table}
%
The external forces acting on a protein trapped inside \gls{clya} under applied bias voltages manifest in the
barrier contribution $\barrier^{\cis/\trans}_\ext$. They comprise an \emph{electrophoretic} component
$\barrier^{\cis/\trans}_\ep$ and an \emph{electro-osmotic} component $\barrier^{\cis/\trans}_\eo$. The former
results from the strong electric field (\SI{\approx3.5e6}{\volt\per\meter} at \SI{-50}{\mV}) and the nonzero
net charge on the molecule, whereas the latter springs from the force exerted by \gls{clya}'s electro-osmotic
flow, which is strong enough to allow the capture of negatively charged proteins even in opposition to the
electrophoretic force~\cite{Soskine-2012,Soskine-2013,Soskine-Biesemans-2015,Biesemans-2015}. It is assumed
that the bias potential changes linearly over the length of the pore, the external energy barriers are given
by (see~\cref{sec:trapping_appendix:escape_rates})
%
\begin{subequations}\label{eq:external-barrier}
\begin{align}
\barrier^{\cis}_\ext ={}&
\barrier^{\cis}_\ep + \barrier^{\cis}_\eo =
-(\Nnet + \Neo) \ec \dfrac{\dxcis}{L} \vbias \text{ , and,}\\
\barrier^{\trans}_\ext ={}&
\barrier^{\trans}_\ep + \barrier^{\trans}_\eo =
+(\Nnet + \Neo) \ec \dfrac{\dxtrans}{L} \vbias
\text{ ,}
\end{align}
\end{subequations}
%
where $\Nnet = \Nbody + \Ntag$ is the total number of charges on \gls{dhfr}\@, $L$ is the length of the
nanopore (\SI{14}{\nm}), and $\vbias$ is the negative applied bias. The strength of the electro-osmotic force
is defined by the \emph{equivalent osmotic charge number} $\Neo$---the number of charges that must be added to
\gls{dhfr} to create an equal electrophoretic force on the molecule. Defining the electro-osmotic force in
terms of an equivalent osmotic charge number reveals its complete analogy to an electrophoretic force, which
has the benefit that the magnitudes of both forces can be readily compared. Moreover, the equivalent osmotic
charge number is an invariant related solely to the size and shape of the molecule.
The quantities $\Delta x^{\cis/\trans}$ are defined as the distances from the electrostatic energy minimum to
the \cisi{} and \transi{} barriers, which depend on the energetic landscape of \gls{clya} and on the precise
location of residence of \gls{dhfr} within the pore. To estimate these values, we can use the APBS simulations
(\cref{fig:trapping_apbs_energy}) from which we can read off that $\dxtrans \approx \SI{3.5}{\nm}$. The
\cisi{} distance is more difficult to define as the \cisi{} electrostatic barrier is much shallower. Without
external fields, it has a distance of about $\SI{\approx2.7}{\nm}$, but as we shall see in
\cref{fig:trapping_apbs_external_biased}, when the energy landscape is tilted by an external force, the
barrier that needs to be overcome is actually located at the \cisi{} entrance of the pore. In practice,
$\dxcis$ will need to be adjusted to a value between these two possibilities to give an adequate estimate and
hence will be left as a fitting parameter.
Inserting \cref{eq:decomposition,eq:static-barrier,eq:external-barrier} into \cref{eq:double_barrier} yields
the final dwell time model:
%
\begin{equation}\label{eq:double_barrier_complex}
\begin{split}
\frac{1}{\dwelltime} = \rate ={}&
\ratefc \exp{%
\left(
-\dfrac{%
\Ntag \ec \potbar_{\rm{tag}}^{\cis}
- (\Nnet + \Neo) \ec \dfrac{\dxcis}{L} \vbias}{\kbt}
\right)
} \\
&\enspace +
\rateft \exp{%
\left(
-\dfrac{%
\Ntag \ec \potbar_{\rm{tag}}^{\trans}
+ (\Nnet + \Neo) \ec \dfrac{\dxtrans}{L} \vbias}{\kbt}
\right)
}
\text{ ,}
\end{split}
\end{equation}
%
where the static terms are absorbed into the prefactor to form the effective \cisi{} and \transi{} barrier
attempt rates $\rate_{\rm{eff}}^{\cis/\trans}$. The formulation of \cref{eq:double_barrier_complex} offers a
compact description of the most salient features of the molecule-nanopore system, and it enables us to
describe the dwell time of \gls{dhfr} inside \gls{clya} quantitatively as a function of the physical
properties of the system. Fitting this model to all \DHFR{$\Ntag$}{O2} data simultaneously---with both
$\vbias$ and $\Ntag$ as independent variables---leads to the fitting values in
\cref{tab:fitting_params_complex} and the plots in \cref{fig:trapping_dwell_times_tag_data}, which show
excellent accuracy considering the simplicity of our model. This is a strong indication that we captured the
essence of the trapping mechanism within our model.
%
\begin{figure*}[p]
\centering
%
\begin{subfigure}[t]{27.5mm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_apbs_external_model}
\includegraphics[scale=1]{trapping_apbs_external_model}
\end{subfigure}
%
\begin{subfigure}[t]{42.5mm}
\centering
\caption{}\vspace{-3mm}%
\label{fig:trapping_apbs_external_equilibrium}
\includegraphics[scale=1]{trapping_apbs_external_equilibrium}
\end{subfigure}
%
\begin{subfigure}[t]{42.5mm}
\centering
\caption{}\vspace{-3mm}%
\label{fig:trapping_apbs_external_biased}
\includegraphics[scale=1]{trapping_apbs_external_biased}
\end{subfigure}
%
\caption[Electrostatic landscape of a \DHFRt{} bead model in {ClyA-AS}]%
{%
\textbf{Electrostatic landscape of a \DHFRt{} bead model in {ClyA-AS}.}
%
(\subref{fig:trapping_apbs_external_model})
%
Simplified bead model of all \DHFR{$\Ntag$}{O2} in comparison with their corresponding full-atom
homology model.
%
(\subref{fig:trapping_apbs_external_equilibrium})
%
The simulated electrostatic energy landscapes of all \DHFR{$\Ntag$}{O2} variants. Increasing the number
of positive charges in the tag deepens the energetic minimum at $z \approx \mSI{3}{\nm}$.
%
%
(\subref{fig:trapping_apbs_external_biased})
%
Approximation of the `tilting' of the energy landscapes from
(\subref{fig:trapping_apbs_external_equilibrium}) by an applied bias voltage, which acts on the total
effective charge of \gls{dhfr} through a constant electric field (\ie~linear potential drop) inside the
pore (\cref{eq:external_energy}). Because the body is negative, increasing the number of positive
charges in the tag decreases the electrophoretic force countering the electro-osmotic force, resulting
in a higher degree of tilting. Down- and upward faces triangles indicate the presence of a local minimum
and maximum, respectively.
%
}\label{fig:trapping_apbs_external}
\end{figure*}
%
\subsection{Effect of tag charge and bias voltage on the energy landscape}
%
\label{sec:trapping:biased_landscape}
%
Our equilibrium electrostatics simulations showed the existence of an electrostatic energy minimum
(\cref{fig:trapping_apbs_external_equilibrium}) at the bottom of \gls{clya}'s \lumen{} ($z = \SI{3}{\nm}$),
flanked by two maxima, located at the \transi{} constriction ($z = \SI{-0.6}{\nm}$), and at the middle of the
\cisi{} \lumen{} ($z = \SI{5.7}{\nm}$). Hence, when \gls{dhfr} resides at the electrostatic potential minimum
inside the nanopore, the largest electrostatic barrier is given by the narrower and negatively charged
\transi{} constriction while the barrier at the \cisi{} side is much shallower. Under the influence of an
external force (\ie~the bias voltage), however, the entire energy landscape will become `tilted', reducing
some barriers and enhancing others. The biased energy $\energyelec_{\vbias}$ is thus
%
\begin{align}\label{eq:external_energy}
\energyelec_{\vbias} = \energyelec + \Eext
\text{ ,}
\end{align}
%
where $\Eext$ is the energy of the \gls{dhfr} molecule due to the external bias voltage. Assuming the bias
voltage changes linearly from \cisi{} to \transi{}, $\Eext$ can be approximated as
%
\begin{align}\label{eq:external_energy_model}
\Eext =
\begin{cases}
\Ntot \dfrac{\vbias}{\SI{14}{\nm}} (z - \SI{11}{\nm})
& \text{for}\; -3 < z < \SI{11}{\nm} \text{ ,} \\
0, & \text{for}\; z >= \SI{11}{\nm} \text{ ,}\\
\Ntot \vbias, & \text{for}\; z < \SI{-3}{\nm} \text{ ,}
\end{cases}
\end{align}
%
with $\Ntot = \Nbody + \Ntag + \Neo$ the effective charge of charge of \gls{dhfr}. In the case of
\DHFR{$\Ntag$}{O2} (\cref{fig:trapping_apbs_external_model}), the net charge of the protein is negative
($\Nbody = -13$) and the electro-osmotic flow exerts an opposing force ($\Neo = 15.5$). This means that
increasing the number of positive charges in the tag decreases the net electrophoretic force and thus leads to
a more pronounced tilting of the entire energy landscape, deepening the electrostatic minimum
(cf.~\cref{fig:trapping_apbs_external_equilibrium,fig:trapping_apbs_external_biased}). This increases the
barrier heights at both the \cisi{} and \transi{} sides similarly, which results in the lowering of both the
\cisi{} and \transi{} escape rates and hence longer dwell times. Because the \cisi{} energy barrier in the
\lumen{} is relatively shallow, it disappears at moderate applied voltages (\SI{>-50}{\mV}). This indicates
that, under a negative applied bias voltage, the location of the \cisi{} barrier is voltage dependent and
hence the distance $\dxcis$ is not well defined. The \cisi{} barrier at low and high biases it is located at
respectively the middle of the \lumen{} ($z \approx \mSI{5.7}{\nm}$) and the \cisi{} entry ($z \approx
\mSIrange{10}{13}{\nm}$).
%
\begin{figure*}[b]
\centering
%
\begin{subfigure}[t]{5.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_translocation_voltage}
\includegraphics[scale=1]{trapping_translocation_voltage}
\end{subfigure}
%
\begin{subfigure}[t]{5.5cm}
\centering
\caption{}\vspace{-3mm}\label{fig:trapping_translocation_probability}
\includegraphics[scale=1]{trapping_translocation_probability}
\end{subfigure}
%
\caption[Tag charge depend. of the threshold voltage and transl. probability]{%
\textbf{Tag charge dependence of the threshold voltage and translocation probability.}
%
(\subref{fig:trapping_translocation_voltage})
%
Every additional positive charge in the fusion tag of the \DHFR{$\Ntag$}{O2} variants increases the
threshold voltage (\cref{eq:threshold_voltage_complex}) by \SI{\approx5.21}{\mV}. The solid line is a
linear fit to the data.
%
%
(\subref{fig:trapping_translocation_probability})
%
Translocation probability voltage $\vbias^{\probability_{\rm{transl}}}$ plotted against tag charge for
$\probability_{\rm{transl}} = \mSIlist{0.1;5;50;95;99.9}{\percent}$, shows that variants with high tag
charge require less bias voltage to fully translocate the pore. Values were obtained through interpolation
from \cref{eq:ptrans}, using the parameters in \cref{tab:fitting_params_complex}.
%
}\label{fig:trapping_translocation}
\end{figure*}
%
%
\begin{table}
\centering
%
\begin{threeparttable}[t]
\centering
%
\captionsetup{width=12cm}
\caption[Summary of all threshold voltages and their dwell times]%
{Summary of all threshold voltages and their dwell times.}
\label{tab:threshold_voltages_and_dwelltimes}
%
\renewcommand{\arraystretch}{1.2}
\footnotesize
%
\begin{tabularx}{12cm}{Xllll}
\toprule
& \multicolumn{2}{c}{Simple model\tnote{a}}
& \multicolumn{2}{c}{Complex model\tnote{b}} \\
\cmidrule(r){2-3}\cmidrule(l){4-5}
{DHFR} variant & $\vthresh$ [mV] & $\tthresh$ [s]
& $\vthresh$ [mV] & $\tthresh$ [s] \\
\midrule
\DHFR{4}{S} & \num{56.1} & \num{0.31} & --- & --- \\
\DHFR{4}{I} & \num{65.5} & \num{0.25} & --- & --- \\
\DHFR{4}{C} & \num{63.7} & \num{0.44} & --- & --- \\
\DHFR{4}{O1} & \num{71.5} & \num{2.11} & \num{75.6} & \num{2.28} \\
\DHFR{5}{O1} & \num{70.7} & \num{3.14} & \num{69.8} & \num{4.16} \\
\DHFR{7}{O1} & \num{65.4} & \num{15.6} & \num{61.6} & \num{13.9} \\
\DHFR{4}{O2} & \num{83.0} & \num{2.69} & \num{87.3} & \num{2.28} \\
\DHFR{5}{O2} & \num{78.5} & \num{5.68} & \num{79.2} & \num{4.16} \\
\DHFR{6}{O2} & \num{70.8} & \num{11.8} & \num{73.0} & \num{7.59} \\
\DHFR{7}{O2} & \num{65.4} & \num{10.8} & \num{68.1} & \num{13.9} \\
\DHFR{8}{O2} & \num{63.6} & \num{35.1} & \num{64.1} & \num{25.3} \\
\DHFR{9}{O2} & \num{59.8} & \num{80.2} & \num{60.4} & \num{46.2} \\
\bottomrule
\end{tabularx}
%
\begin{tablenotes}
\item[a] Estimated using \cref{eq:threshold_voltage_simple} after fitting of
\cref{eq:double_barrier_simple} the individual mean dwell times of each mutant.
\item[b] Estimated using \cref{eq:threshold_voltage_complex} after fitting of \cref{eq:double_barrier}
to all \DHFR{$\Ntag$}{O2} mean dwell time data.
\end{tablenotes}
%
\end{threeparttable}
\end{table}
%
\subsection{Characteristics of the trapping}
%
As the double barrier model of \cref{eq:double_barrier_complex} is derived from the underlying physical
interactions of the molecule with the nanopore and with the externally applied field, the fitted parameters of
\cref{tab:fitting_params_complex} are physically relevant quantities that describe the characteristics of the
system.
The sizes of the electrostatic barriers $\potbar_{\rm{tag}}^{\cis/\trans}$ that the tag charges experience are
in direct relation to the gradients of the barrier sizes computed using the \gls{apbs} model
(\cref{fig:trapping_apbs_barrier_tag}). We find that the change of the \transi{} barrier with respect to tag
charge, $\potbar_{\rm{tag}}^{\trans} = \text{\SI{0.860}{\kbt\per\ec}}$, is in excellent agreement with the
simulated gradient of \SI{0.875}{\Vt}. The change observed for the \cisi{} barrier, $\potbar_{\rm tag}^{\cis}
= \text{\SI{0.218}{\kbt\per\ec}}$, is approximately 3-fold smaller compared to its \gls{apbs} value of
\SI{0.621}{\kbt\per\ec}. This deviation likely results from the shallowness of the \cisi{} barrier, causing it
to disappear when the energy landscape is tilted under an applied bias voltage
(see~\cref{fig:trapping_apbs_external_biased}). This gives rise to a \cisi{} barrier that lies at a location
further away from the electrostatic minimum located inside the \transi{} constriction, effectively limiting
the influence of the tag charge number on the barrier height. This claim is further corroborated by the
finding that the fitted value of $\dxcis \approx \SI{5.2}{\nm}$, which is almost twice the distance predicted
by the \gls{apbs} simulations and moves that \cisi{} barrier much closer to the \cisi{} entry.
One of the key insights we obtain from our model is the ability to directly extract information on the
strength of the osmotic flow. However, let us first observe that the equivalent electro-osmotic charge number
$\Neo\approx15.5$ is much bigger than the net charge of all tag charge variations, $\Ntag + \Nbody = -
9,\ldots, -4$, and also has the opposite sign. This is in agreement with the earlier assumption that the
electro-osmotic force is strong enough to overcome the opposing electrophoretic force and is hence responsible
for the capture of the molecule~\cite{Soskine-2012,Soskine-Biesemans-2015}. At a bias of $\vbias =
\SI{-50}{\mV}$ the electro-osmotic force exerted onto the \gls{dhfr} molecule (\cref{eq:osmoticforce}) is
%
\begin{equation}
\forceeo = \ec \Neo \frac{\vbias}{L} \approx \SI{9}{\pN}
\text{ .}
\end{equation}
%
The magnitude of this force is in line with those found experimentally for
DNA~\cite{Keyser-2006,vanDorp-2009,Lu-2012} and proteins~\cite{Oukhaled-2011} in solid-state nanopores.
We found the threshold voltages (obtained from the fitted model, see~\cref{eq:threshold_voltage_complex}) to
be roughly linearly dependent on the number of tag charges, with a decrease of \SI{\approx5}{\mV} per
additional positive charge (\cref{fig:trapping_translocation_voltage}). This effect is caused by the increase
of the net external force on the molecule with increasing tag charge, resulting in a simultaneous lowering of
the \transi{} barrier and raising the \cisi{} barrier. The threshold voltages and their corresponding
dwell times for both the simple and complex double barrier models are listed in
\cref{tab:threshold_voltages_and_dwelltimes}.
Another important finding of our model is that the \gls{dhfr} variations are essentially trapped by the
electrostatic forces of the pore on the tag. This can be seen from the direct exponential dependence of the
electrostatics on the tag charge as shown in \cref{eq:static-barrier}. If the molecule was trapped as a whole
between two barriers, we would rather see a dependence on the net charge on the molecule. Indeed, we verified
that such a net charge dependence cannot be fitted to the data. This suggest that the tag acts as an anchor
which is located in the electrostatic minimum created by the \transi{} constriction
(\cref{fig:trapping_apbs_energy}).
We can also determine the probability of a full translocation of \gls{dhfr} using
%
\begin{align}\label{eq:ptrans}
\probtrans = \dfrac{\rate^{\trans}}{\rate^{\cis} + \rate^{\trans}}
\text{ ,}
\end{align}
%
where $k^\cis$ and $k^\trans$ can be computed using the individual components given by
\cref{eq:double_barrier_complex} and the parameters in \cref{tab:fitting_params_complex}. At zero bias and
zero tag charge, we find that only \SI{0.002}{\percent} of \gls{dhfr} molecules would exit to the \transi{}
side, indicating that in the absence of an electrophoretic driving force a \cisi{} exit is much more likely
than a \transi{} exit. This is in agreement with our expectations because \gls{dhfr}'s size leads to a
significant steric hindrance when it tries to translocate through the nanopore constriction.
Finally, from \cref{eq:ptrans} we can compute the voltage $\vbias^{\probtrans}$ required to obtain a given
translocation probability (\cref{fig:trapping_translocation_probability}). The number of tag charges
significantly lowers the voltage required to achieve full translocation, for example, $\vbias^{\probtrans}$
for $\probtrans = \SI{99.9}{\percent}$ decreases from \SI{\approx-130}{\mV} to \SI{\approx-85}{\mV} going from
$\Ntag = +4$ to \num{+9}. This effect is mainly due to the lowering of the \transi{} barrier height, as the
\cisi{} escape probability voltage (\SI{0.01}{\percent} line in \cref{fig:trapping_translocation_probability})
only changes from \SI{\approx-40}{\mV} to \SI{\approx-35}{\mV} going from \num{+4} to \num{+9} tag charges.
Hence, the higher the tag charge number, the stronger the net external force which pushes the molecule through
the \transi{} constriction of the pore.
%
\section{Conclusion}
%
\label{sec:trapping:conclusion}
%
We showed previously that neutral or weakly charged proteins larger than the \transi{} constriction
(\SI{>3.3}{\nm}) of \gls{clya} can be trapped inside the nanopore for a relatively long duration (seconds to
minutes) and that their behavior can be sampled by ionic current recordings~\cite{Soskine-2013,
Soskine-2012,Soskine-Biesemans-2015,Biesemans-2015,VanMeervelt-2014,VanMeervelt-2017,Wloka-2017}. In contrast,
small proteins rapidly translocate through the nanopore due to the strong electro-osmotic flow and highly
negatively charged proteins remain inside \gls{clya} only briefly or they do not enter at
all~\cite{Soskine-2012}.
In this work, we use \gls{dhfr} as a model molecule to enhance and investigate the trapping of small and
negatively charged proteins inside the \gls{clya} nanopore~\cite{Biesemans-2015}. \gls{dhfr}
(\SIrange{3.5}{4}{\nm}) is slightly too large to pass through the \transi{} constriction, and its negatively
charged body ($\Nbody = -13$) only allowed trapping the protein inside the nanopore for a few milliseconds.
The introduction of a positively charged C-terminal fusion tag partially counterbalanced the electrophoretic
force and introduced an electrostatic trap in the \transi{} constriction of \gls{clya} that increased the
\gls{dhfr} dwell time up to minutes.
The \gls{dhfr} mutants showed a biphasic voltage dependency which was explained by using a physical model
containing a double energy barrier to account for the exit on either side of the nanopore. The model contained
steric, electrostatic, electrophoretic, and electro-osmotic components and it allowed us to describe the
complex voltage-dependent data for the different \gls{dhfr} constructs. Furthermore, fitting to experimental
data of a series of \DHFR{$\Ntag$}{O2} constructs, in which the positive charge of the tag was systematically
increased, enabled us to deduce meaningful values for \gls{dhfr}'s intrinsic \cisi{} and \transi{}
translocation probabilities, as well as an estimate of the force exerted by the electro-osmotic flow on the
protein of \SI{0.178}{\pico\newton\per\milli\volt} (\eg~\SI{9}{\pN} at \SI{-50}{\mV},
\cref{tab:fitting_params_complex}). We also showed that the \gls{apbs} simulation results of a simple bead
model for the molecule are directly related to the independently fitted parameters of the double barrier
model. In conclusion, this means that it should be possible to predict the dwell times of similar experiments
by obtaining parameters directly from these types of \gls{apbs} simulations. Interestingly, some \DHFRt{}
variants showed several well-defined current blockade levels, indicating the presence of several stable energy
minima within the pore. Even though we did not investigate this phenomenon in detail, we did observe the
presence multiple minima in the electrostatic energy landscape of \DHFRt{}. These findings suggest that the
distinct current blockades observed experimentally might correspond to different physical locations of the
protein along the length of \gls{clya}.
The double barrier model of \cref{eq:double_barrier_complex} in its current form does not adequately describe
mutations that modify the body charge distribution of \gls{dhfr}\@. This is most likely because body charge
variations close to the electrostatically trapped tag will impact the height of the barriers more strongly
than modifications on the far end of the tag. Although a model accounting for this effect could be made, it
would also make the double barrier model significantly more complex without providing any significant
advantages over a more comprehensive atomistic simulation. A more detailed discussion can be found in
\cref{sec:trapping_appendix:body_charge_variations}.
Inside the \lumen{} of \gls{clya}, proteins are able to bind to their specific substrates at all applied
potentials tested (up to \SI{-100}{\mV}), indicating that the electrostatic potential inside the nanopore and
the electrostatic potential originating from the inner surface of the nanopore did not unfold the protein.
Therefore, our results indicate that \gls{clya} nanopores can be used as nanoscale test tubes to investigate
enzyme function at the single-molecule level. Compared to the wide variety of single-molecule techniques based
on fluorescence, nanopore recordings are label-free, which have the advantage of allowing long observation
times.
The electrophoretic trapping of proteins inside nanopores is likely to have practical applications. For
example, arrays of biological or solid-state nanopores will allow the precise alignment of proteins on a
surface. In addition, proteins immobilized inside glass nanopipettes atop a scanning ion conductance
microscope~\cite{Bruckbauer-2007,Babakinejad-2013} can be manipulated with nanometer-scale precision, which
might be used, for instance, for the localized delivery of proteins. Furthermore, ionic current measurements
through the nanopore can be used for the detection of analyte binding to an immobilized protein, which has
applications in single-molecule protein studies and small analyte sensing.
%
\section{Materials and methods}
%
\label{sec:trapping:methods}
%
\subsection{Electrostatic energy landscape computation}
%
The electrostatic energy landscape of a coarse-grained \gls{dhfr} molecule translocating through a full-atom
\gls{clya-as} model was computed using the \gls{apbs}~\cite{Baker-2001}, using the approach described in
\cref{sec:elec:methods:elec:energy}. In summary, a full atom model of \gls{clya-as}~\cite{Franceschini-2016}
was prepared \textit{via} homology modeling with MODELLER software package~\cite{Sali-1993} from the wild-type
\gls{clya} crystal structure (\pdbid{2WCD}~\cite{Mueller-2009}) and its energy was further minimized using the
\gls{vmd}~\cite{Humphrey-1996} and \gls{namd} programs~\cite{Phillips-2005}. A coarse-grained bead model of
\gls{dhfr} was placed at various locations along the central axis of the pore using custom \code{Python} code
and the \code{Biopython} package~\cite{Cock-2009}. The bead model of \DHFRt{} consisted of a `body' of seven
negatively charged beads (\SI{-1.43}{\ec}) beads (\SI{1.6}{\nm} diameter) in a spherical configuration and a
`tail' of nine smaller beads (\SI{1}{\nm} diameter, \SI{0.6}{\nm} spacing) in a linear configuration with
varying charge (depending on the net charge of the three amino acids they represent). Each atom in the
resulting \gls{clya}-\gls{dhfr} complexes was subsequently assigned a radius and partial charge (according to
the CHARMM36 force-field~\cite{Huang-2013}) with the PDB2PQR program~\cite{Dolinsky-2004,Dolinsky-2007}, and
the electrostatic was energy computed with \gls{apbs}. The net electrostatic energy cost or gain of placing a
\gls{dhfr} molecule (\ie~$\energyelec$) along the central z-axis of \gls{clya} (from
$z_{\rm{body}}=\SI{-12.5}{\nm}$ to $\SI{27.5}{\nm}$ relative to the center of the bilayer, with steps of
\SI{0.5}{\nm} inside the pore) was computed by \cref{eq:electrostatic_energy}. To this end, all systems were
solved using the non-linear \gls{pbe} (\code{npbe}) in two steps with the automatic solver (\code{mg-auto}):
(1) a coarse calculation in a box of \SI{40x40x110}{\nm} with grid lengths of \SI{0.138x0.138x0.122}{\nm} and
multiple Debye-H\"{u}ckel boundary conditions (\code{bcfl mdh}), followed by (2) a finer focusing calculation
in a box of \SI{15x15x70}{\nm} with grid lengths of \SI{0.052x0.052x0.052}{\nm} that used the values of the
coarse calculation at its boundaries. The monovalent salt concentration was set to \SI{0.150}{\Molar} with a
radius of \SI{0.2}{\nm} for both ions. The solvent and solute relative permittivities were set to \num{78.15}
and \num{10}, respectively~\cite{Li-2013}. Both the charge density and the ion accessibility maps were
constructed using cubic B-spline discretization (\code{chgm spl2} and \code{srfm spl2}).
\subsection{Protein mutagenesis, overexpression, and purification}
%
All \gls{dhfr} variants were constructed, overexpressed and purified using standard molecular biology
techniques~\cite{Soskine-Biesemans-2015,Biesemans-2015}, as described in full detail in the supplementary
information (see~\cref{sec:trapping_appendix:dhfr_cloning}). Briefly, the \DHFR{4}{S} DNA construct was built
from the {pT7-SC1} plasmid containing the \DHFRt{} construct (see ref.~\cite{Soskine-Biesemans-2015}) by
inserting an additional alanine residue at position 175 (located in the fusion tag) with site-directed
mutagenesis. All other variants were derived---again using site-directed mutagenesis---either directly from
\DHFR{4}{S} or from a variant thereof. The plasmids of each \gls{dhfr} variant were used to transform E.
cloni\textsuperscript{\textregistered} EXPRESS BL21(DE3) cells (Lucigen, Middleton, USA), and the \gls{dhfr}
proteins they encode were overexpressed overnight at \SI{25}{\celsius} in a liquid culture. After the
bacterial cells were harvested by centrifugation, the overexpressed proteins were released into solution
through lysis---using a combination of at least a single freeze-thaw cycle, incubation with lysozyme, and
probe tip sonification. Finally, the \gls{dhfr} proteins were purified from the lysate with affinity
chromatography with Strep-Tactin\textsuperscript{\textregistered} Sepharose\textsuperscript{\textregistered}
(IBA Lifesciences, Goettingen, Germany), aliquoted, and stored at \SI{-20}{\celsius} until further use.
\subsection{ClyA-AS overexpression, purification and oligomerization}
%
\gls{clya-as} oligomers were prepared as described previously~\cite{Soskine-2013}, and full details can be
found in \cref{sec:trapping_appendix:dhfr_cloning}. Briefly, the \gls{clya-as} monomers were overexpressed and
purified in a manner similar to that for \gls{dhfr}, with the largest difference being the use of
\ce{Ni-NTA}-based affinity chromatography. After purification, \gls{clya-as} monomers were oligomerized in
\SI{0.5}{\percent} \textbeta-dodecylmaltoside (GLYCON Biochemicals GmbH, Luckenwalde, Germany) at
\SI{37}{\celsius} for \SI{30}{\minute}. The type I oligomer (12-mer) was isolated by gel extraction from a
blue native \gls{page}.
\subsection{Electrical recordings in planar lipid bilayers}
%
Electrical recordings of individual \gls{clya-as} nanopores were carried out using a typical planar lipid
bilayer setup with an AxoPatch 200B (Axon Instruments, San Jose, USA) patch-clamp
amplifier~\cite{Maglia-2010,Soskine-2012}. Briefly, a black lipid membrane consisting of
1,2-diphytanoyl-sn-glycero-3-phosphocholine (Avanti Polar Lipids, Alabaster, USA), was formed inside a
\SI{\approx 100}{\micro\meter} diameter aperture in a thin polytetrafluoroethylene film (Goodfellow Cambridge
Limited, Huntingdon, England) separating two electrolyte compartments. Single nanopores were then made to
insert into the \cisi{}-side chamber (grounded) by addition of \SIrange{0.01}{0.1}{\nano\gram} of
preoligomerized \gls{clya-as} to the buffered electrolyte (\SI{150}{\mM} \ce{NaCl}, \SI{15}{\mM} \ce{Tris-HCl}
\pH{7.5}). All ionic currents were sampled at \SI{10}{\kilo\hertz} and filtered with a \SI{2}{\kilo\hertz}
low-pass Bessel filter. A more detailed description can be found in
\cref{sec:trapping_appendix:nanopore_experiments}.
\subsection{Dwell time analysis and model fitting}
%
The dwell times of the \gls{dhfr} protein blocks were extracted from single-nanopore channel recordings using
the `single-channel search' algorithm of the pCLAMP 10.5 (Molecular Devices, San Jose, USA) software suite.
The process was monitored manually, and any events shorter than \SI{1}{\ms} were discarded. We processed the
dwell time data, and fitted the double barrier model to it, using a custom Python code employing the
\code{NumPy}~\cite{vanderWalt-2011}, \code{pandas}~\cite{McKinney-2010}, and \code{lmfit}~\cite{Newville-2014}
packages. Fitting of the exponential models to the data was performed using non-linear least-squares
minimization with the Levenberg-Marquardt algorithm as implemented by \code{lmfit}. Note that to improve the
robustness and quality of the fitted parameters, we moved the exponential prefactors into the exponential and
we fitted the natural logarithm of the equations to the natural logarithm of the dwell time data.
\subsection{Analytical expression for the threshold voltages}
%
An analytic expression for the threshold voltage $\vthresh$---the bias voltage at maximum dwell time---can
found as the bias voltage for which $\dfrac{d\rate}{d\vbias} = 0$. For the simple double barrier model given
by \cref{eq:double_barrier_simple} this becomes
%
\begin{align}\label{eq:threshold_voltage_simple}
\vthresh = \dfrac{ \left[
\frac{%
\log \left( \rateft / \ratefc \right)+
\log \left( -N_{\rm{eq}}^\trans / N_{\rm{eq}}^\cis \right)
}{%
N_{\rm{eq}}^\trans - N_{\rm{eq}}^\cis
}\right]}%
{ \ec / \kbt }
\text{ ,}
\end{align}
%
whereas for the more complex model given by \cref{eq:double_barrier_complex} it becomes
%
\begin{equation}\label{eq:threshold_voltage_complex}
\vthresh = - \dfrac{\left[
\frac{%
\log \left( \rateft / \ratefc \right)
+ \log \left( \dxtrans / \dxtrans \right)
+ \left( \potbar_{\rm{tag}}^{\cis} - \potbar_{\rm{tag}}^{\trans} \right)\Ntag
}{%
\left( \Nnet + \Neo \right) \left(\dxcis + \dxtrans \right) / L
}\right]}%
{ \ec / \kbt }
\text{ .}
\end{equation}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Keep the following \cleardoublepage at the end of this file,
% otherwise \includeonly includes empty pages.
\cleardoublepage
% vim: tw=70 nocindent expandtab foldmethod=marker foldmarker={{{}{,}{}}}
|
<center>
<h1> ILI286 - Computación Científica II </h1>
<h2> EDP Parabólicas: Diferencias Finitas </h2>
<h2> <a href="#acknowledgements"> [S]cientific [C]omputing [T]eam </a> </h2>
<h2> Version: 1.2 </h2>
</center>
# Tabla de Contenidos
* [Introducción](#intro)
* [EDP Parabólica: Ecuación de Onda](#para)
* [Diferencias Finitas (Forward Difference)](#fd)
* [Diferencias Finitas (Backward Difference)](#bd)
* [Ecuación de calor 1D: Condición de borde de Dirichlet](#heat1d:dirichlet)
* [Ecuación de calor 1D: Condición de borde Periódicas](#heat1d:periodic)
* [Ecuación de calor 2D](#heat2d)
* [Acknowledgements](#acknowledgements)
### Librerias necesarias
```python
%matplotlib notebook
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
from mpl_toolkits.mplot3d import Axes3D
from IPython.display import HTML
```
```python
def show(x, t, u):
Nt = len(t)
fig, ax = plt.subplots()
l, = plt.plot(x, u[:,0],'ko:')
dx = 0.05*(x[-1]-x[0])
ymin = u.min().min()
ymax = u.max().max()
dy = 0.05*(ymax-ymin)
ax.set_xlim([x[0]-dx, x[-1]+dx])
ax.set_ylim([ymin-dy, ymax+dy])
plt.xlabel("$x$", fontsize=20)
plt.ylabel("$u(x,t)$", fontsize=20)
def animate(i):
l.set_ydata(u[:,i])
return l,
#Init only required for blitting to give a clean slate.
def init():
l.set_ydata(np.ma.array(u[:,0], mask=True))
return l,
dt = t[1]-t[0]
#interval = 4 * 100. * 200/Nt # So simulations run in the same time regardless of Nt
interval = 100
anim = animation.FuncAnimation(
fig, animate, np.arange(1, Nt),
init_func=init, interval=interval, blit=True
)
return anim
def animate(all_sims, interval=100):
NumSims = all_sims.shape[0]
fig, ax = plt.subplots()
img = plt.imshow(all_sims[0,:,:], cmap=cm.coolwarm, interpolation='nearest', origin='lower')
plt.xticks(range(0,101,10), np.linspace(0.,1.0,11))
plt.yticks(range(10,101,10), np.linspace(0.1,1.0,10))
plt.colorbar(img)
def animate(i):
img.set_data(all_sims[i,:,:])
return img,
#Init only required for blitting to give a clean slate.
def init():
img.set_data(all_sims[0,:,:])
return img,
anim = animation.FuncAnimation(
fig, animate, np.arange(1, NumSims),
init_func=init, interval=interval, blit=True
)
return anim
```
<div id='para' />
## EDP Parabólica: Ecuación de Onda
En esta sección estudiaremos una clase distinta (y muy común) de EDPs: Parabólicas, en partícular, la **ecuación de calor**:
$$
u_t(x,t) = D\, u_{xx}(x,t).
$$
Este corresponde a un modelo de difusión, que explica como una variable $u(x,t)$ a lo largo de una dimensión espacial $x$, se propaga desde regiones de mayores concentraciones hacia menores concentraciones, a lo largo del tiempo $t$, hasta alcanzar un estado estable. En este sentido el coeficiente $D$ representa la capacidad de dufisividad, esto es, la fácilidad con la que puede propagarse a lo largo del medio.
<div id='fd' />
## Diferencias Finitas (Forward Difference)
Similar a como se hizo para solucionar numéricamente ODEs, se puede discretizar cada derivada parcial de la PDE con *finite differences*. Sea la siguiente PDE (ecuación de calor) con sus condiciones de borde:
\begin{align*}
u_t(x,t) &= D\, u_{xx}(x,t) \\
u(x,0) &= f(x) \\
u(a,t) &= l(t) \\
u(b,t) &= r(t) \\
\end{align*}
Un primer enfoque es utilizar *forward difference* para aproximar la derivada temporal, y *centered difference formula* para la segunda derivada espacial, del siguiente modo:
\begin{align}
u_t(x,t) &\approx \frac{1}{k} \left( u(x, t+k) - u(x,t) \right) \\
u_{xx}(x,t) &\approx \frac{1}{h^2} \left( u(x+h,t) - 2 u(x,t) + u(x-h, t) \right),
\end{align}
siendo $k,h$ el *time step* y *spatial step* respectivamente. Si por simplicidad se denota $w_{i,j} = u(x_i, t_j)$, entonces la discretización de la ecuación queda del siguiente modo:
$$
\frac{1}{k} (w_{i,j+1} - w_{i,j}) \approx \frac{D}{h^2} ( w_{i+1,j}-2 w_{i,j} + w_{i-1,j} ),
$$
con error de aproximación del orden $O(k) + O(h^2)$.
(**Idea**) La idea del método es la siguiente; Dado que por la condiciones de borde y las condiciones iniciales, sabemos los valores de $w_{0,j}, w_{M,j}, w_{i,0} \ \ \forall i,j$, determinar sucesivamente los valores $w_{i,j}$ en los tiempos siguientes,
\begin{align}
t_1: \ (w_{1,1}, w_{2,1}, &\ldots, w_{M-1,1}) \\
t_2: \ (w_{1,2}, w_{2,2}, &\ldots, w_{M-1,2}) \\
& \cdots \\
t_N: \ (w_{1,N}, w_{2,N}, &\ldots, w_{M-1,N}).
\end{align}
Por medio de la ecuación discretizada anteriormente, es posible obtener un método iterativo que permite conocer los valores aproximados $w_{i,j}$, secuencialmente sobre cada instante siguiente:
$$
\begin{pmatrix}
w_{1,j+1} \\
\\
\vdots \\
\\
w_{m,j+1}
\end{pmatrix} =
\begin{pmatrix}
1-2\sigma & \sigma & 0 & \cdots & 0 \\
\sigma & 1-2\sigma & \sigma & \ddots & \vdots \\
0 & \sigma & 1-2\sigma & \ddots & 0 \\
\vdots & \ddots & \ddots & \ddots & \sigma \\
0 & \cdots & 0 & \sigma & 1-2\sigma
\end{pmatrix}
\begin{pmatrix}
w{1,j} \\
\\
\vdots \\
\\
w_{m,j}
\end{pmatrix}
+
\sigma \begin{pmatrix}
w_{0,j} \\
0 \\
\vdots \\
0 \\
w_{m+1,j}
\end{pmatrix} \ \ \ \text{con} \ \sigma = \frac{Dk}{h^2}
$$
Para ver más detalles, consultar texto guía (*Numerical Analysis, Timothy Sauer, 2nd edition*). Tal método se encuentra implementado en `heat_equation_forward_differences()`.
<div id='bd' />
## Diferencias Finitas (Backward Difference)
Una de las desventajas del método anterior, es que es **condicionalmente estable**, esto es, que converge únicamente bajo ciertas condiciones sobre el tamaño de discretización de la malla: $\sigma = \frac{Dk}{h^2} < \frac{1}{2}$.
Un enfoque distinto y que intenta sobrellevar este problema, es utilizar **backward differences** para la aproximación de derivadas (tal como se hizo en ODEs). Consideremos ahora, que la derivada temporal en la ecuación de calor, es aproximada con el tiempo anterior en vez del tiempo siguiente:
$$
u_t(x,t) \approx \frac{1}{k} \left( u(x,t) - u(x,t-k) \right),
$$
dejando la segunda derivada espacial intacta. Luego se obtiene una ecuación discretizada como se muestra a continuación:
$$
\frac{1}{k}\left( w_{i,j} - w_{i,j-1} \right) = \frac{D}{h^2} \left( w_{i+1,j} - 2 w_{i,j} + w_{i-1,j} \right).
$$
Evaluando esta ecuación y organizando correctamente, se obtiene el método iterativo siguiente:
$$
\begin{pmatrix}
1+2\sigma & -\sigma & 0 & \cdots & 0 \\
-\sigma & 1+2\sigma & -\sigma & \ddots & \vdots \\
0 & -\sigma & 1+2\sigma & \ddots & 0 \\
\vdots & \ddots & \ddots & \ddots & \sigma \\
0 & \cdots & 0 & -\sigma & 1+2\sigma
\end{pmatrix}
\begin{pmatrix}
w_{1,j} \\
\\
\vdots \\
\\
w_{m,j}
\end{pmatrix}
=
\begin{pmatrix}
w_{1,j-1} \\
\\
\vdots \\
\\
w_{m,j-1}
\end{pmatrix}
+
\sigma
\begin{pmatrix}
w_{0,j} \\
0 \\
\vdots \\
0 \\
w_{m+1,j}
\end{pmatrix}
$$
Para más detalles consultar texto guía (*Numerical Analysis, Timothy Sauer, 2nd edition*). Puede ver la implementación de este método en `heat_equation_backward_differences()`.
A diferencia del anterior, este no impone ninguna restricción para su convergencia!, esto es, es ** incondicionalmente estable **.
<div id='heat1d:dirichlet' />
## Ecuación de calor 1D: Condición de borde de Dirichlet
Consideremos la siguiente EDP parabólica, para $ x \in [a,b]$ y $t \in [0,T_{max}]$:
\begin{align*}
u_t(x,t) = D\, u_{xx}(x,t)
\end{align*}
\begin{align*}
u(x,0) = f(x)
\end{align*}
\begin{align*}
u(a,t) = l(t)
\end{align*}
\begin{align*}
u(b,t) = r(t)
\end{align*}
```python
def heat_equation_forward_differences(P, Nx, Nt, bc='boundary'):
"""
Solves the heat equation using forward differences
"""
if bc=='dirichlet':
x = np.linspace(P["xmin"], P["xmax"], Nx)
t = np.linspace(P["tmin"], P["tmax"], Nt)
dx = x[1]-x[0]
dt = t[1]-t[0]
S = P["D"]*dt/dx**2
print("CFL condition: D*dt/dx^2 = %.1f <= 0.5 ?",S)
# Storage
u = np.zeros((Nx, Nt))
# Time Loop
for i, ti in enumerate(t):
if i==0:
u[:,0] = P["f"](x)
else:
u[ 0,i] = P["l"](ti)
u[-1,i] = P["r"](ti)
u[1:-1, i] = S*u[:-2, i-1] + (1-2*S)*u[1:-1,i-1]+S*u[2:,i-1]
return x, t, u
elif bc=='periodic':
x = np.linspace(P["xmin"], P["xmax"], Nx)
t = np.linspace(P["tmin"], P["tmax"], Nt)
dx = x[1]-x[0]
dt = t[1]-t[0]
S = P["D"]*dt/dx**2
print("CFL condition: D*dt/dx^2 = ",S, " <= 0.5 ?")
# Storage
u = np.zeros((Nx, Nt))
# Time Loop
for i, ti in enumerate(t):
if i==0:
u[:,0] = P["f"](x)
else:
u[0, i] = S*u[-2, i-1] + (1-2*S)*u[0,i-1]+S*u[1,i-1]
u[1:-1, i] = S*u[:-2, i-1] + (1-2*S)*u[1:-1,i-1]+S*u[2:,i-1]
u[-1, i] = S*u[-2, i-1] + (1-2*S)*u[-1,i-1]+S*u[1,i-1]
return x, t, u
```
```python
def heat_equation_backward_differences(P, Nx, Nt, bc='dirichlet'):
"""
Solves the heat equation using forward differences
"""
if bc=='dirichlet':
x = np.linspace(P["xmin"], P["xmax"], Nx)
t = np.linspace(P["tmin"], P["tmax"], Nt)
dx = x[1]-x[0]
dt = t[1]-t[0]
S = P["D"]*dt/dx**2
print("CFL condition not required: D*dt/dx^2 = ",S)
# Constructing the matrix
A = np.diag(-S*np.ones(Nx-3),-1) + np.diag((1+2*S)*np.ones(Nx-2),0) + np.diag(-S*np.ones(Nx-3),+1)
# Storage
u = np.zeros((Nx, Nt))
# Time Loop
for i, ti in enumerate(t):
if i==0:
u[:,0] = P["f"](x)
else:
u[ 0,i] = P["l"](ti)
u[-1,i] = P["r"](ti)
b = u[1:-1,i-1].copy()
b[ 0] += S*u[ 0,i]
b[-1] += S*u[-1,i]
u[1:-1, i] = np.linalg.solve(A, b)
return x, t, u
```
### Experimentación
```python
f1 = lambda x: np.sin(2*np.pi*x)**2
l1 = lambda t: t
r1 = lambda t: t
P1 = {"xmin":0, "xmax":1, "tmin":0, "tmax":1.0, "D":1, "f":f1, "l":l1, "r":r1}
f2 = lambda x: 10*np.exp(-(x-.5)**2/0.01)
l2 = lambda t: 0
r2 = lambda t: 0
P2 = {"xmin":0, "xmax":1, "tmin":0, "tmax":1.0, "D":1, "f":f2, "l":l2, "r":r2}
f3 = lambda x: x
l3 = lambda t: 0
r3 = lambda t: 0
P3 = {"xmin":0, "xmax":1, "tmin":0, "tmax":1.0, "D":1, "f":f3, "l":l3, "r":r3}
```
```python
P = P1
#x, t, u = heat_equation_forward_differences(P, 10, 10, bc='dirichlet') # Unstable
#x, t, u = heat_equation_forward_differences(P, 10, 200, bc='dirichlet') # Stable
#x, t, u = heat_equation_forward_differences(P, 100, 20000,bc='dirichlet') # Stable
#x, t, u = heat_equation_backward_differences(P, 10, 10, bc='dirichlet') # Stable
#x, t, u = heat_equation_backward_differences(P, 10, 100, bc='dirichlet') # Stable
x, t, u = heat_equation_backward_differences(P, 100, 100, bc='dirichlet') # Stable
show(x,t,u)
```
```python
fig = plt.figure()
ax = fig.gca(projection='3d')
X,T = np.meshgrid(x,t)
surf = ax.plot_surface(X, T, u, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)
#ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
```
```python
fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
```
<div id='heat1d:periodic' />
## Ecuación de calor 1D: Condición de borde Periódica
Consideremos la siguiente EDP parabólica, para $ x \in [a,b]\ \ $ y $t \in [0,T_{max}] \ \ $:
\begin{align*}
u_t(x,t) = D\, u_{xx}(x,t)
\end{align*}
\begin{align*}
u(x,0) = f(x)
\end{align*}
\begin{align*}
u(-x,t) = u(1-x,t)
\end{align*}
La condición de frontera es periódica, esto es, estudiamos la evolución de la temperatura en un anillo,
por lo que consideramos que para $u(-x,t) = u(1-x,t)$
```python
f1 = lambda x: np.sin(2*np.pi*x)**2
P1 = {"xmin":0, "xmax":1, "tmin":0, "tmax":1.0, "D":1, "f":f1}
f2 = lambda x: 10*np.exp(-(x-.5)**2/0.01)
P2 = {"xmin":0, "xmax":1, "tmin":0, "tmax":1.0, "D":1, "f":f2}
f3 = lambda x: x
P3 = {"xmin":0, "xmax":1, "tmin":0, "tmax":1.0, "D":1, "f":f3}
```
```python
P = P3
#x, t, u = heat_equation_forward_differences(P, 10, 10, bc='periodic') # Unstable
#x, t, u = heat_equation_forward_differences(P, 10, 200, bc='periodic') # Stable
x, t, u = heat_equation_forward_differences(P, 100, 20000, bc='periodic') # Stable
show(x,t,u)
```
<div id='heat2d' />
## Ecuación de calor 2D
De forma equivalente, la ecuación de calor puede ser planteada para situaciones n-dimensionales. En partícular para en caso 2D puede ser escrita como se muestra a continuación
$$
\frac{\partial u}{\partial t} = D \ \Delta u = D \ \left(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} \right)
$$
con sus respectivas condiciones de borde e iniciales. Las funciones que se muestran a continuación (`evolve()` y `solver()`) se encargan de la resolución *explícita* e *iterativa* del la ecuación 2D.
```python
# This is the 2D version of Explicit Finite Differences
def evolve(u_new, u_old, dt, D, dx2, dy2):
u_new[1:-1, 1:-1] = u_old[1:-1, 1:-1]
u_new[1:-1, 1:-1] += D * dt * (u_old[2:, 1:-1] - 2*u_old[1:-1, 1:-1] + u_old[:-2, 1:-1]) / dx2
u_new[1:-1, 1:-1] += D * dt * (u_old[1:-1, 2:] - 2*u_old[1:-1, 1:-1] + u_old[1:-1, :-2]) / dy2
return u_new
####################################################
# MAIN 2D-PARABOLIC FUNCTION SOLVER
####################################################
def solver(u0, D=1., Nx=100, Ny=100, num_steps=10000):
dx = 1./Nx
dy = 1./Ny
dx2 = dx**2
dy2 = dy**2
# For stability, this is the largest interval possible
# for the size of the time-step:
dt = 1.0*dx2*dy2 / ( 2*D*(dx2+dy2) )
u_aux = u0
u = np.zeros([Nx,Ny])
all_sims = np.zeros([num_steps, Nx, Ny])
# Iterative step
for n in range(num_steps):
evolve(u, u_aux, D, dt, dx2, dy2)
u_aux = u
all_sims[n,:,:] = u
return all_sims
```
A continuación se genera como condición inicial, un distribución de *temperatura* con una distribución en forma de anillo en un dominio $[0,1]\times [0,1]$. **Pruebe variando los parámetros!**.
```python
####################################################
# Initial conditions generation: Ring distribution
####################################################
Ri = 0.05 # Internal Radii
Re = 0.10 # External Radii
Nx = 100
Ny = 100
dx = 1./Nx # Interval size in x-direction.
dy = 1./Ny # Interval size in y-direction.
D = 1. # Diffusion constant.
u0 = np.zeros([Nx,Ny])
# Now, set the initial conditions (ui).
for i in range(Nx):
for j in range(Ny):
v=np.array([i*dx-0.5,j*dy-0.5])
C1 = np.linalg.norm(v,1) <= np.sqrt(Re)
C2 = np.linalg.norm(v,1) >= np.sqrt(Ri)
if C1 and C2 : u0[i,j] = 1
```
```python
####################################################
# ANIMATION
####################################################
all_sims = solver(u0)
animate(all_sims, interval=50)
```
```python
########################################################
# Initial conditions generation: Write your own IC here
########################################################
x,y = np.meshgrid(np.linspace(0.,1.,Nx), np.linspace(0.,1.,Ny), sparse=True)
# initial condition
f0 = lambda x,y : 10*np.sin(8*np.pi*x)*np.sin(8*np.pi*y)
u0 = f0(x,y)
```
```python
####################################################
# ANIMATION
####################################################
all_sims = solver(u0)
animate(all_sims, interval=50)
```
<div id='acknowledgements' />
# Acknowledgements
* _Material creado por profesor Claudio Torres_ (`[email protected]`) _y ayudantes: Alvaro Salinas y Martín Villanueva. DI UTFSM. Noviembre 2016._
***
### DISCLAIMER ###
El presente notebook ha sido creado para el curso **ILI286 - Computación Científica 2**, del [Departamento de Informática](http://www.inf.utfsm.cl/), [Universidad Técnica Federico Santa María](http://www.utfsm.cl/).
El material ha sido creado por Claudio Torres <[email protected]> y Sebastian Flores <[email protected]>, y es distribuido sin restricciones. En caso de encontrar un error, por favor no dude en contactarnos.
[Update 2016] (Martín) Notebook creado como una fusión de las tres partes anteriores. Agregado contexto / Marco teórico. Agregadas/Arregladas animaciones de los experimentos 1D. Se agregó la simulación y animación en 2D de distribución de temperatura en forma de anillo.
***
|
with(StringTools):
DiagLatex := proc(spart, size:=0)
local phis, thetas, phithetas, zeds, Lambda, string, cercle, triangle, triangle_cercle, boite, part, endline, k;
phis:= spart[2];
phis:= map( x-> [x,"c"], phis);
thetas:= spart[3];
thetas:= map(x-> [x,"b"], thetas);
phithetas:= spart[1];
phithetas:= map(x-> [x,"d"], phithetas);
zeds:= spart[4];
zeds:= map(x-> [x,"a"], zeds);
Lambda:= sort([op(phithetas),op(phis), op(thetas), op(zeds)]);
string:="";
cercle:= "\\yC";
triangle:= "\\yT";
triangle_cercle:= "\\yTC";
boite:= "\\,";
for k from 1 to nops(Lambda) do
part:= Lambda[k];
print(Lambda);
print(part);
if k = 1 then endline:=""; else endline:="\\\\ \n"; end if:
if part[2] = "c" then
string:= cat(cat(Repeat(cat(boite, "& "), part[1]), triangle, endline), string);
elif part[2] = "b" then
string:= cat(cat(Repeat(cat(boite, "& "), part[1]), cercle, endline), string);
elif part[2] = "a" then
string:= cat(cat(Repeat(cat(boite, "& "), part[1]-1), boite, endline), string);
elif part[2] = "d" then
string:= cat(cat(Repeat(cat(boite, "& "), part[1]), triangle_cercle, endline), string);
end if;
end do:
if size = 0 then
string:= cat("{\\, \\superYsmall{", string, "}}");
elif size = 1 then
string:= cat("{\\, \\superY{", string, "}}");
elif size = 2 then
string:= cat("\\superRusse{{\\superY{", string, "}}}");
end if;
return string;
end proc:
superLatex := proc(expr,initial_term:=0, wipe:=0)
local sparts, astring, spart, spart_string, fd, basetype, terms, thecoeff, latexsparts, latex_terms, k, ou;
if wipe <> 0 then
fd:= fopen("out.txt", WRITE);
fprintf(fd, "");
fclose(fd);
else
fd:=fopen("out.txt", APPEND);
fprintf(fd,"new \n \\begin{gather*} \n");
fclose(fd);
end if;
basetype:= "m";
terms:= [op(indets(expr, 'superindexed'))];
terms:= sort(terms, list_sort);
#print(terms);
sparts:= map(x-> [op(x)], terms);
#print(sparts);
thecoeff:= map(x-> coeff(expr, x), terms);
#print(thecoeff);
#latexcoeff:= map(x-> latex(x), thecoeff);
#Activate following line for diagrams
#latexsparts:= map(x-> DiagLatex(x,0), sparts);
#Activate following line for sparts
latexsparts:= map(x-> SpartLatex(x),sparts);
latex_terms:= [];
if initial_term <> 0 then
fd:=fopen("out.txt", APPEND);
fprintf(fd,cat(initial_term[1],"\\,",basetype,"_",DiagLatex(initial_term[2], 0),"=","\n+"));
fclose(fd);
end if;
for k from 1 to nops(sparts) do
fd:= fopen("out.txt", APPEND);
fprintf(fd, "\t");
fclose(fd);
if whattype(thecoeff[k]) = `+` then
fd:= fopen("out.txt", APPEND);
fprintf(fd, "(");
fclose(fd);
end if;
latex(thecoeff[k],"out.txt",'append');
if whattype(thecoeff[k]) = `+` then
fd:= fopen("out.txt", APPEND);
fprintf(fd, ")");
fclose(fd);
end if;
fd:= fopen("out.txt", APPEND);
fprintf(fd, cat(basetype,"_",latexsparts[k],"\n+"));
fclose(fd);
end do:
fd:=fopen("out.txt", APPEND);
fprintf(fd,"\\end{gather*} \n");
fclose(fd);
end proc:
SpartLatex:= proc(spart)
local pts, phis, thetas, zeds, pt_string, phi_string, theta_string, zed_string, SpartString;
pts:= spart[1];
phis:= spart[2];
thetas:= spart[3];
zeds:= spart[4];
pt_string:= convert(pts, string);
phi_string:= convert(phis, string);
theta_string:= convert(thetas, string);
zed_string:= convert(zeds, string);
pt_string:= Substitute(pt_string, "[", "(");
pt_string:= Substitute(pt_string, "]", ";\\,");
phi_string:= Substitute(phi_string, "[", "");
phi_string:= Substitute(phi_string, "]", ";\\,");
theta_string:= Substitute(theta_string, "[", "");
theta_string:= Substitute(theta_string, "]", ";\\,");
zed_string:= Substitute(zed_string, "[", "");
zed_string:= Substitute(zed_string, "]", ")");
SpartString:= cat(pt_string, phi_string, theta_string, zed_string);
SpartString:= cat("{",SpartString, "}");
return SpartString;
end proc:
|
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: gga_exc *)
(* prefix:
gga_x_optx_params *params;
assert(p->params != NULL);
params = (gga_x_optx_params * )(p->params);
*)
optx_f := x-> params_a_a + params_a_b*(params_a_gamma*x^2/(1 + params_a_gamma*x^2))^2:
f := (rs, z, xt, xs0, xs1) -> gga_exchange(optx_f, rs, z, xs0, xs1):
|
If $f$ and $g$ have isolated singularities at $z$, then $f - g$ has an isolated singularity at $z$.
|
{-# OPTIONS --safe #-}
module Generics.Reflection where
open import Function.Base
import Data.Unit as ⊤
import Data.Product as Product
import Relation.Binary.PropositionalEquality as Eq
open import Data.Nat.Base hiding (_⊔_)
open import Data.List.Base as List hiding (_++_)
import Data.Vec.Base as Vec
open import Data.String as S using (String; _++_)
open import Data.Bool.Base
open import Data.Maybe.Base using (Maybe; just; nothing; maybe)
open import Agda.Builtin.Reflection renaming ( primQNameEquality to _Name≈_
)
open import Reflection.Abstraction using (unAbs)
open import Reflection.Argument using (_⟨∷⟩_; _⟅∷⟆_)
open import Reflection.Term hiding (Telescope; var)
open import Relation.Nullary using (yes; no)
open import Category.Monad as Monad
import Data.List.Categorical as List
import Data.Nat.Induction as Nat
import Data.Char as C
open import Reflection.TypeChecking.Monad.Instances using (tcMonad)
open import Reflection.Traversal hiding (_,_)
open import Generics.Prelude
open import Generics.Telescope
open import Generics.Desc renaming (_,_ to _,ω_)
import Generics.Accessibility as Accessibility
open import Generics.HasDesc
import Function.Identity.Categorical as Identity
open List.TraversableM ⦃...⦄
open Monad.RawMonad ⦃...⦄
tErr : Term → TC ⊤
tErr = typeError ∘ [_] ∘ termErr
sErr : String → TC ⊤
sErr = typeError ∘ [_] ∘ strErr
open Actions
-- `liftN n f` maps numbers 0..(n-1) to themselves, and numbers
-- `n + k` to `n + (f k)`
liftN : ℕ → (ℕ → ℕ) → (ℕ → ℕ)
liftN zero f k = f k
liftN (suc n) f zero = zero
liftN (suc n) f (suc k) = suc (liftN n f k)
mapVars : (ℕ → ℕ) → Term → Term
mapVars f = traverseTerm Identity.applicative actions (0 Reflection.Traversal., [])
where
actions : Actions Identity.applicative
actions .onVar ctx = liftN (ctx .Cxt.len) f
actions .onMeta _ = id
actions .onCon _ = id
actions .onDef _ = id
prettyName : Name → String
prettyName f = maybe id "" (List.last (S.wordsBy ('.' C.≟_) (showName f)))
{-
When converting types to telescopes
variables are converted to context lookups:
Given K := [(oₒ : Oₒ) ⋯ (o₁ : O₁)] "forced" arguments (reversed)
P := [A₁ ⋯ Aₙ] parameters
I := [B₁ ⋯ Bₘ] indices,
we want to replace a term in context (Γ , O₁ , ⋯ , Oₒ , A₁ , ⋯ , Aₙ , B₁ , ⋯ , Bₘ , C₁ , ⋯ , Cₚ)
into a term in context (Γ , Σ P I , C₁ , ⋯ , Cₚ)
A term (var k) should be replaced by:
- (var k) if k < p
- (proj₂ (proj₂ (var p))) if p <= k < p + m (inside I)
(proj₂ (proj₁ (proj₂ (var p)))) ...
(proj₂ (proj₁ (proj₁ (proj₂ (var p))))) ...
- (proj₂ (proj₁ (var p)) if p + m <= k < p + m + n (inside P)
- (proj₂ (proj₁ (proj₁ (var p))) ...
- (proj₂ (proj₁ (proj₁ (proj₁ (var p)))) ...
- K[k - (n + m + p)] if p + m + n <= k < p + m + n + o
- var (k + 1 - n - m - o) if p + m + n + o <= k
-}
-- o: position of (PI : Σ P I) in the context
-- (i.e number of locally bound variables)
mkVar : (o k : ℕ) → Name → List (Arg Term) → Term
mkVar o k t args = def (quote proj₂) (aux o k ⟨∷⟩ args)
where
aux : (o k : ℕ) → Term
aux o zero = def t (var o [] ⟨∷⟩ [])
aux o (suc k) = def (quote proj₁) (aux o k ⟨∷⟩ [])
mkPVar : (o k : ℕ) → List (Arg Term) → Term
mkPVar o k = mkVar o k (quote proj₁)
mkIVar : (o k : ℕ) → List (Arg Term) → Term
mkIVar o k = mkVar o k (quote proj₂)
-- TODO: telescopize should account for forced arguments
module _ (fargs : List Term) (nP nI : ℕ) where
telescopize : ℕ → Term → Term
telescopizeSort : ℕ → Sort → Sort
telescopizeArgs : ℕ → List (Arg Term) → List (Arg Term)
telescopizeTel : ℕ → List (String × Arg Type) → List (String × Arg Type)
telescopizeClause : ℕ → List Clause → List Clause
lookupForced : List Term → ℕ → ℕ → List (Arg Term) → Term
lookupForced [] n o = var (suc (n + o))
-- WARN: we ignore args, this should go alright
-- ALSO, we might/should lift everything up, probably
lookupForced (x ∷ xs) zero o = const (mapVars (λ n → n + suc o) x)
lookupForced (x ∷ xs) (suc n) o = lookupForced xs n o
telescopize o (var k args) =
let args′ = telescopizeArgs o args in
if k <ᵇ o then var k args′
else if k ∸ o <ᵇ nI then mkIVar o (k ∸ o ) args′
else if k ∸ o <ᵇ nI + nP then mkPVar o (k ∸ o ∸ nI) args′
else lookupForced fargs (k ∸ (nI + nP + o)) o args
-- else var (k ∸ pred (nP + nI)) args′
telescopize o (con c args) = con c (telescopizeArgs o args)
telescopize o (def f args) = def f (telescopizeArgs o args)
telescopize o (lam v (abs s t)) = lam v (abs s (telescopize (suc o) t))
telescopize o (pat-lam cs args) = pat-lam (telescopizeClause o cs) (telescopizeArgs o args)
telescopize o (Π[ s ∶ arg i a ] b) = Π[ s ∶ arg i (telescopize o a) ] telescopize (suc o) b
telescopize o (sort s) = sort (telescopizeSort o s)
telescopize o (lit l) = lit l
telescopize o (meta x args) = meta x (telescopizeArgs o args)
telescopize o unknown = unknown
telescopizeSort o (set t) = set (telescopize o t)
telescopizeSort o (prop t) = prop (telescopize o t)
telescopizeSort o x = x
telescopizeArgs o [] = []
telescopizeArgs o (arg i x ∷ xs) = arg i (telescopize o x) ∷ telescopizeArgs o xs
telescopizeTel o [] = []
telescopizeTel o ((s , arg i t) ∷ xs) = (s , arg i (telescopize o t))
∷ telescopizeTel (suc o) xs
telescopizeClause o [] = []
telescopizeClause o (clause tel ps t ∷ xs)
-- careful: telescopes bring (length tel) variables in scope
= clause (telescopizeTel o tel) ps (telescopize (o + length tel) t)
∷ telescopizeClause o xs
telescopizeClause o (absurd-clause tel ps ∷ xs) =
absurd-clause (telescopizeTel o tel) ps ∷ telescopizeClause o xs
-- sanity check
private
module TelescopizeTests where
t : Term
t = var 4 []
-- locally bound variable
t₁ : Term
t₁ = telescopize [] 0 0 5 t
t₁-ok : t₁ ≡ var 4 []
t₁-ok = refl
-- retrieving var in index telescope, 4 variable locally-bound
t₂ : Term
t₂ = telescopize [] 2 1 4 t
t₂-ok : t₂ ≡ def (quote proj₂) (def (quote proj₂) (var 4 [] ⟨∷⟩ []) ⟨∷⟩ [])
t₂-ok = refl
-- retrieving var in parameter telescope, 2 variable locally-bound
t₃ : Term
t₃ = telescopize [] 1 2 2 t
t₃-ok : t₃ ≡ def (quote proj₂) (def (quote proj₁) (var 2 [] ⟨∷⟩ []) ⟨∷⟩ [])
t₃-ok = refl
-- retrieving var outside parameter & index telescope
t₄ : Term
t₄ = telescopize [] 1 1 2 t
t₄-ok : t₄ ≡ var 3 []
t₄-ok = refl
-- retrieving 4th var in index telescope
t₅ : Term
t₅ = telescopize [] 0 5 1 t
t₅-ok : t₅ ≡ def (quote proj₂)
(def (quote proj₁)
(def (quote proj₁)
(def (quote proj₁) (def (quote proj₂) (var 1 [] ⟨∷⟩ []) ⟨∷⟩ []) ⟨∷⟩
[])
⟨∷⟩ [])
⟨∷⟩ [])
t₅-ok = refl
-----------------------------
-- Deriving telescopes
getIndexTel : List Term → ℕ → Type → TC Term
getIndexTel fargs nP ty = aux ty 0 (con (quote ε) [])
where aux : Type → ℕ → Term → TC Term
aux (agda-sort s) n I = return I
aux (Π[ s ∶ arg i a ] b) n I = do
i′ ← quoteTC i >>= normalise
aux b (suc n) (con (quote _⊢<_>_)
(I ⟨∷⟩ con (quote Product._,_) (lit (string s) ⟨∷⟩ i′ ⟨∷⟩ [])
⟨∷⟩ vLam "PI" (telescopize fargs nP n 0 a)
⟨∷⟩ []))
aux _ _ _ = typeError [ strErr "ill-formed type signature when deriving index telescope" ]
getTels : List Term → ℕ → Type → TC (Term × Term)
getTels fargs nP ty = aux nP ty 0 (quoteTerm (ε {A = ⊤}))
where aux : ℕ → Type → ℕ → Term → TC (Term × Term)
aux zero ty _ P = (P ,_) <$> getIndexTel fargs nP ty
aux (suc nP) (Π[ s ∶ arg i a ] b) n P = do
i′ ← quoteTC i >>= normalise
aux nP b (suc n) (con (quote _⊢<_>_)
(P ⟨∷⟩ con (quote Product._,_) (lit (string s) ⟨∷⟩ i′ ⟨∷⟩ [])
⟨∷⟩ vLam "PI" (telescopize fargs 0 n 0 a)
⟨∷⟩ []))
aux _ _ _ _ = typeError [ strErr "ill-formed type signature when deriving parameter telescope" ]
-----------------------------
-- Deriving descriptions
-- we cannot unquote things in Setω directly
-- so we can't unquote Terms of type Telescope directly
-- instead we produce skeletons to ease code generation
data Skel : Set where
Cκ : Skel
Cπ : ArgInfo → Skel → Skel
_C⊗_ : Skel → Skel → Skel
dropPis : ℕ → Type → Type
dropPis (suc n) (pi a (abs _ b)) = dropPis n b
dropPis _ t = t
module _ (fargs : List Term) (dt : Name) (nP : ℕ) where
toIndex : ℕ → List (Arg Term) → Term
toIndex nV xs = vLam "PV" $ foldl cons (quoteTerm ⊤.tt) (drop (nP + List.length fargs) xs)
where cons : Term → Arg Term → Term
cons x (arg _ y) =
con (quote Product._,_) ( x
⟨∷⟩ telescopize fargs nP nV 0 y
⟨∷⟩ [])
getRecDesc : ℕ → Type → TC (Maybe (Term × Skel))
getRecDesc n (def nm args) = do
if nm Name≈ dt
then return (just (con (quote ConDesc.var) (toIndex n args ⟨∷⟩ []) , Cκ))
else return nothing
getRecDesc n (Π[ s ∶ arg i a ] b) = do
getRecDesc (suc n) b >>= λ where
(just (right , skright)) → do
i′ ← quoteTC i >>= normalise
return $ just ( con (quote ConDesc.π) (con (quote Product._,_) (lit (string s) ⟨∷⟩ i′ ⟨∷⟩ [])
⟨∷⟩ vLam "PV" (telescopize fargs nP n 0 a) ⟨∷⟩ right ⟨∷⟩ [])
, Cπ i skright
)
nothing → return nothing
getRecDesc n ty = return nothing
getDesc : (ℕ → ℕ) → ℕ → Type → TC (Term × Skel)
getDesc f n (def nm args) =
-- we're gonna assume nm == dt
-- TODO: why does this work???
-- surely args contain parameters
return (con (quote ConDesc.var) (toIndex n (List.map (Arg.map (mapVars f)) args) ⟨∷⟩ []) , Cκ)
getDesc f n (Π[ s ∶ arg i a ] b) =
getRecDesc n (mapVars f a) >>= λ where
-- (possibly higher order) inductive argument
(just (left , skleft)) → do
-- we cannot depend on inductive argument (for now)
-- note: inductive arguments are relevant (for now)
-- /!\ inductive arguments to not bind a variable, so we strengthen the term
(right , skright) ← getDesc ((_- 1) ∘ f) n b
return (con (quote ConDesc._⊗_) (left ⟨∷⟩ right ⟨∷⟩ []) , (skleft C⊗ skright))
-- plain old argument
nothing → do
(right , skright) ← getDesc (liftN 1 f) (suc n) b
i′ ← quoteTC i >>= normalise
return ( con (quote ConDesc.π) (con (quote Product._,_) (lit (string s) ⟨∷⟩ i′ ⟨∷⟩ [])
⟨∷⟩ vLam "PV" (telescopize fargs nP n 0 a)
⟨∷⟩ right
⟨∷⟩ [])
, Cπ i skright
)
getDesc _ _ _ = typeError [ strErr "ill-formed constructor type" ]
-- TODO: the reason we do this is that I've failed to make the PI arguments
-- implicit in the reflection code
record HD {P} {I : ExTele P} {ℓ} (A : Indexed P I ℓ) : Setω where
constructor mkHD
A′ : ⟦ P , I ⟧xtel → Set ℓ
A′ = uncurry P I A
field
{n} : ℕ
D : DataDesc P I n
names : Vec String n
constr : ∀ pi → ⟦ D ⟧Data A′ pi → A′ pi
split : ∀ pi → A′ pi → ⟦ D ⟧Data A′ pi
split∘constr : ∀ pi → (x : ⟦ D ⟧Data A′ pi) → split pi (constr pi x) ≡ω x
constr∘split : ∀ pi → (x : A′ pi ) → constr pi (split pi x) ≡ x
open Accessibility A D (λ {pi} → split pi)
field wf : ∀ pi (x : A′ pi) → Acc x
badconvert : ∀ {P} {I : ExTele P} {ℓ} {A : Indexed P I ℓ}
→ HD {P} {I} {ℓ} A → HasDesc {P} {I} {ℓ} A
badconvert d = record
{ D = HD.D d
; names = HD.names d
; constr = λ {PI} → HD.constr d PI
; split = λ {PI} → HD.split d PI
; split∘constr = λ {PI} → HD.split∘constr d PI
; constr∘split = λ {PI} → HD.constr∘split d PI
; wf = λ {PI} → HD.wf d PI
}
withAI : ArgInfo → Term → Term
withAI i t with relevance i
... | relevant = t
... | irrelevant = con (quote irrv) [ vArg t ]
patAI : ArgInfo → Pattern → Pattern
patAI i t with relevance i
... | relevant = t
... | irrelevant = con (quote irrv) [ vArg t ]
deriveThings : (gargs : List (Arg Term)) (nP : ℕ)
(qconstr qsplit qsplitconstr qconstrsplit qwf : Name)
(cons : List (Name × Skel))
→ TC ⊤
deriveThings gargs nP qconstr qsplit qsplitconstr qconstrsplit qwf cons = do
let clauses = deriveDef cons
-- TODO: use some n-ary magic
let (constr_cls , rest ) = unzip clauses
let (split_cls , rest ) = unzip rest
let (splitconstr_cls , rest ) = unzip rest
let (constrsplit_cls , wf_cls) = unzip rest
defineFun qconstr constr_cls
defineFun qsplit split_cls
defineFun qsplitconstr splitconstr_cls
defineFun qconstrsplit constrsplit_cls
defineFun qwf wf_cls
where
deriveIndArg : Skel → ℕ × List (String × Arg Type) × List (Arg Pattern) × List (Arg Term)
deriveIndArg Cκ = 0 , [] , [] , []
deriveIndArg (Cπ ia C) =
let (o , tel , pat , args) = deriveIndArg C
in suc o
, ("x" , vArg unknown) ∷ tel
, arg ia (var o) ∷ pat
, arg ia (var o []) ∷ args
-- WARNING: intentionally wrong, never used when deriving descriptions
deriveIndArg (A C⊗ B) = 0 , [] , [] , []
deriveCon : Skel → ℕ × List (String × Arg Type) -- variable types
× Pattern -- pattern for ⟦_⟧Data
× List (Arg Pattern) -- pattern for arguments of A′ cons
× List (Arg Term) -- arguments for constructor
× Term -- return value for split
× Term -- body of wf
deriveCon Cκ
= 0 , [] -- we bind zero vars
, con (quote Eq.refl) []
, []
, []
, con (quote Eq.refl) []
, def (quote ttω) []
deriveCon (Cπ ia C) =
let (o , vars , datapat , apat , cargs , sval , wfval) = deriveCon C
in suc o
, ("s" , arg ia unknown) ∷ vars -- TODO: unsure about ia here
, con (quote Product._,_) (patAI ia (var o) ⟨∷⟩ datapat ⟨∷⟩ [])
, arg ia (var o) ∷ apat
, arg ia (var o []) ∷ cargs
, con (quote Product._,_) (withAI ia (var o []) ⟨∷⟩ sval ⟨∷⟩ [])
, wfval
deriveCon (A C⊗ B) =
let (ro , rtel , rpat , rargs) = deriveIndArg A in
let (o , vars , datapat , apat , cargs , sval , wfval) = deriveCon B
in suc o
, ("x" , vArg unknown) ∷ vars -- we only support visible relevant inductive args
, con (quote Product._,_) (var o ⟨∷⟩ datapat ⟨∷⟩ [])
, var o ⟨∷⟩ apat
, var o [] ⟨∷⟩ cargs
, con (quote Product._,_) (var o [] ⟨∷⟩ sval ⟨∷⟩ [])
, def (quote _ω,ω_)
(pat-lam [ clause rtel rpat
(def qwf (unknown -- PI of inductive argument
⟨∷⟩ var (o + ro) rargs
⟨∷⟩ []))
] []
⟨∷⟩ wfval ⟨∷⟩ []) -- TODOOOO
deriveClause : Pattern → Term → Name × Skel
→ Clause × Clause × Clause × Clause × Clause
deriveClause kp kt (consname , shape) =
let (o , vars , datapat , apat , cargs , sval , wfval) = deriveCon shape
in clause (("pi" , vArg unknown) ∷ vars)
(var o ⟨∷⟩ con (quote _,ω_) (kp ⟨∷⟩ datapat ⟨∷⟩ []) ⟨∷⟩ [])
(con consname (nP ⋯⟅∷⟆ cargs)) -- TODO: maybe forced args go here
, clause (("pi" , vArg unknown) ∷ vars)
(var o ⟨∷⟩ con consname apat ⟨∷⟩ [])
(con (quote _,ω_) (kt ⟨∷⟩ sval ⟨∷⟩ []))
, clause (("pi" , vArg unknown) ∷ vars)
(var o ⟨∷⟩ con (quote _,ω_) (kp ⟨∷⟩ datapat ⟨∷⟩ []) ⟨∷⟩ [])
(def (quote reflω) [])
, clause (("pi" , vArg unknown) ∷ vars)
(var o ⟨∷⟩ con consname apat ⟨∷⟩ [])
(con (quote Eq.refl) [])
, clause (("pi" , vArg unknown) ∷ vars)
(var o ⟨∷⟩ con consname apat ⟨∷⟩ [])
(con (quote Accessibility.Acc.acc) (wfval ⟨∷⟩ []))
deriveClauses : Pattern -- pattern for index of constructor
→ Term -- term for index constructor
→ List (Name × Skel)
→ List (Clause × Clause × Clause × Clause × Clause)
deriveClauses _ _ [] = []
deriveClauses kp kt (x ∷ xs)
= deriveClause kp kt x
∷ deriveClauses (con (quote Fin.suc) (kp ⟨∷⟩ []))
(con (quote Fin.suc) (kt ⟨∷⟩ []))
xs
deriveDef : List (Name × Skel) → List (Clause × Clause × Clause × Clause × Clause)
deriveDef [] = [ cls , cls , cls , cls , cls ]
where cls = absurd-clause (("PI" , hArg unknown) ∷ ("x" , vArg unknown) ∷ [])
(var 1 ⟨∷⟩ absurd 0 ⟨∷⟩ [] )
deriveDef xs = deriveClauses (con (quote Fin.zero) [])
(con (quote Fin.zero) [])
xs
macro
deriveDesc : Term → Term → TC ⊤
deriveDesc t hole = do
-- Arguments are used for enabling universe-polymorphic defintions
-- these arguments should be prepended to every use of nm as a type
def nm gargs ← return t
where _ → typeError [ strErr "Expected name with arguments." ]
let fargs = reverse (List.map Arg.unArg gargs)
data-type nP cs ← getDefinition nm
where _ → typeError [ strErr "Name given is not a datatype." ]
let nCons = List.length cs
let nArgs = List.length gargs
names ← quoteTC (Vec.fromList (List.map prettyName cs))
-- we get the type of the family, with the provided arguments removed
ty ← getType nm >>= normalise <&> dropPis nArgs >>= normalise
-- (nP - nArgs) is the amount of actual parameters we consider in our encoding
-- the remaining Pi types are indices
(P , I) ← getTels fargs (nP - nArgs) ty
descs&skels ← forM cs λ cn → do
-- get the type of current constructor, with explicit arguments and parameters stripped
conTyp ← getType cn >>= normalise <&> dropPis nP
(desc , skel) ← getDesc fargs nm (nP - nArgs) id 0 conTyp
return $ (cn , skel) , desc
let descs = List.map proj₂ descs&skels
let skels = List.map proj₁ descs&skels
let D = foldr (λ C D → con (quote DataDesc._∷_) (C ⟨∷⟩ D ⟨∷⟩ []))
(con (quote DataDesc.[]) [])
descs
qconstr ← freshName "constr"
qsplit ← freshName "split"
qsplitconstr ← freshName "split∘constr"
qconstrsplit ← freshName "constr∘split"
qwf ← freshName "wf"
declareDef (vArg qconstr)
(pi (vArg (def (quote ⟦_,_⟧xtel) (P ⟨∷⟩ I ⟨∷⟩ [])))
(abs "PI" (pi (vArg unknown) (abs "x" unknown))))
declareDef (vArg qsplit)
(pi (vArg (def (quote ⟦_,_⟧xtel) (P ⟨∷⟩ I ⟨∷⟩ [])))
(abs "PI" (pi (vArg unknown) (abs "x" unknown))))
declareDef (vArg qconstrsplit)
(pi (vArg (def (quote ⟦_,_⟧xtel) (P ⟨∷⟩ I ⟨∷⟩ [])))
(abs "PI" (pi (vArg unknown) (abs "x" unknown))))
declareDef (vArg qsplitconstr)
(pi (vArg (def (quote ⟦_,_⟧xtel) (P ⟨∷⟩ I ⟨∷⟩ [])))
(abs "PI" (pi (vArg unknown) (abs "x" unknown))))
declareDef (vArg qwf)
(pi (vArg (def (quote ⟦_,_⟧xtel) (P ⟨∷⟩ I ⟨∷⟩ [])))
(abs "PI" (pi (vArg unknown) (abs "x" unknown))))
deriveThings gargs (nP - nArgs) qconstr qsplit qsplitconstr qconstrsplit qwf skels
unify hole (def (quote badconvert) ((con (quote mkHD)
( P -- P
⟅∷⟆ I -- I
⟅∷⟆ unknown -- ℓ
⟅∷⟆ def nm gargs -- A
⟅∷⟆ lit (nat nCons) -- n
⟅∷⟆ D -- D
⟨∷⟩ names -- names
⟨∷⟩ def qconstr []
⟨∷⟩ def qsplit []
⟨∷⟩ def qsplitconstr []
⟨∷⟩ def qconstrsplit []
⟨∷⟩ def qwf []
⟨∷⟩ [])) ⟨∷⟩ []))
|
import .path
import .graph_induction
-- from math 688 notes, lec-19
universe u
variables (V : Type u)
-- TO DO:
-- define components (they are used twice here), give them some lemmas
-- prove that removing a vertex from a tree results in a graph whose components are trees with smaller size
-- concrete development of the category of graphs so we can prove useful properties (see Hedetniemi branch)
-- might be useful:
-- `finset.eq_singleton_iff_unique_mem` says `s = {a} ↔ a ∈ s ∧ ∀ x ∈ s, x = a`
open_locale classical
namespace simple_graph
-- create some sort of type coercion for edges in subgraph and supergraph
variables {V} (T : simple_graph V) (a b : V) --(S : simple_graph (λ v, v ≠ a))
#check T.adj a b
def connected : Prop := ∀ (a b : V), ∃ (p : T.path), a = p.head ∧ b = p.last
def acyclic : Prop := ∀ (p : T.path), ¬ p.simple_cycle
class tree : Prop :=
(connected : connected T)
(acyclic : acyclic T)
#check T.connected
--def tree : Prop := connected T ∧ acyclic T
def leaf (v : V) [fintype (T.neighbor_set v)] : Prop := T.degree v = 1
variables [∀ v, fintype (T.neighbor_set v)] [tree T] (p : path T)
#check fintype.card
-- move this to simple_graph later (need to prove that `p.is_tour` and therefore `p.is_maximal` exists in any finite simple graph)
lemma fin_max_path [fintype V] (h : 2 ≤ fintype.card V) : ∃ (p : path T), p.is_maximal :=
begin
-- show that if the number of vertices is finite then the path lengths are all finite
-- use the fact that you have an upper bound for sets of integers
/-have h2 := fintype.exists_pair_of_one_lt_card h,
cases h2 with a hb,
cases hb with b h3,-/ -- don't think we want to pick arbitrary a and b
--have h4 := T.connected,
-- we're gonna need the bijection (λ (p : path), p.length) in order to find a maximum because then we can find a finite set on ℕ
sorry,
end
/- Theorem 1: every tree on n ≥ 2 vertices contains at least two vertices of degree 1 -/
lemma two_deg_one [fintype V] (h : 2 ≤ fintype.card V) : ∃ (v₁ v₂ : V), v₁ ≠ v₂ ∧ T.leaf v₁ ∧ T.leaf v₂ :=
begin
-- Proof outline:
have h2 := fintype.exists_pair_of_one_lt_card h,
cases h2 with a hb,
cases hb with b h3,
use a,
use b,
split,
exact h3,
split,
-- let p = x0 x1 ... xk in T be a maximal path in tree T
-- Sub-lemma : prove that maximal paths exist
-- use `p.tail.length` (number of edges in `p`)
-- assume for contradiction that we have some neighbor y of x0, where y ≠ x1. this gives us two cases:
-- either y is contained in a path that links back up with the original path, so acyclicity is violated
-- or y is contained in a path that does not link back up, which then makes that new path an extension of the original, so maximality of p is violated
-- `p.cons e hp hs` is the path extending `p` by edge `e`.
-- (these two things should probably be their own lemmas so we can just apply them to x0 and xk)
-- so then x0 does not have any neighbors besides x1, and therefore has degree 1
-- similar argument goes for xk, which gives us at least two vertices in T that are leaves
sorry,
sorry,
end
/- Theorem 2: if T is a tree on n ≥ 2 vertices and x is a leaf, then the graph obtained by removing x from T is a tree on n - 1 vertices -/
-- this should probably be made with more general lemmas
section other
lemma acyclic_subgraph_acyclic (t : acyclic T) (s : set V) : acyclic (induced_subgraph V T s) :=
begin
-- Proof outline:
-- T has no cycles so T \ {x} has no cycles
sorry,
end -- generalize to any subgraph once that's defined
variable (x : V)
--vertex_mem (v : V) (p : G.path) : Prop := v ∈ p.vertices
-- is this actually useful? who knows
/-lemma leaf_path_endpoint (p : T.path) (h1 : T.leaf x) (h2 : x ∈ p.vertices) : p.head = x ∨ p.last = x :=
begin
-- `rw mem_neighbor_finset` says `w ∈ G.neighbor_finset v ↔ G.adj v w`
unfold leaf at h1,
unfold degree at h1,
rw finset.card_eq_one at h1,
cases h1 with w hw,
rw finset.eq_singleton_iff_unique_mem at hw,
cases hw with hm hu,
-- reverse (head :: tail) to, well, reverse it
-- list.head (list.reverse (head :: tail) is the new list head
sorry,
end-/
lemma connected_rmleaf_connected (t : connected T) {x : V} (h : T.leaf x) : connected (induced_subgraph V T (λ v, v ≠ x)) :=
begin
-- Proof outline:
-- there are uv paths for all u v in T
-- if T.leaf x and x ∈ p, x must either be p.head or p.last ?
-- should this be its own sub-lemma?
-- T.connected means there are paths from every vertex to every vertex
unfold connected,
unfold connected at t,
intros h1 h2,
sorry,
end
end other
instance tree_rmleaf_is_tree {x : V} (h : T.leaf x) : tree (induced_subgraph V T (λ v, v ≠ x)) :=
{ connected := T.connected_rmleaf_connected tree.connected h,
acyclic := T.acyclic_subgraph_acyclic tree.acyclic _
}
/- Theorem 3: TFAE
(a) T is a tree
(b) There exists a unique path between any two distinct vertices of T
(c) T is a connected graph on n vertices with n-1 edges
(d) T is an acyclic graph on n vertices with n-1 edges -/
-- Proof outline:
/- Lemma 1: (a) → (b) : T is a tree → there exists a unique path between any two distinct vertices -/
lemma tree_unique_path [inhabited V] (t : tree T) (u v : V) (p : T.path) (q : T.path) : (p.head = q.head) ∧ (p.last = q.last) → p = q :=
begin
-- Subproof outline:
-- let u,v be distinct vertices in T
-- T is a tree, so a uv path p exists
-- we already have uv path guaranteed by definition of tree
intro h,
cases h with hh hl,
rw path.eq_of_vertices_eq,
-- suppose for contradiction that another path uv path q exists, p ≠ q (negation of eq_of_vertices_eq?)
by_contra,
-- there exists w s.t. w ∈ p and w ∈ q, where w is the last vertex before p and q diverge (maybe make a lemma for this)
-- shit this is gonna be tricky
-- (this doesn't cover the edge case that u is adjacent to v, which is false by the condition that we have a simple graph. this is a problem. fix the definition somehow)
-- p.last = q.last, so we must have a vertex w' in p,q (could be v) such that (figure out how to say this correctly) w'.tail ∈ p ∧ w'.tail ∈ q (also this should probably be a path lemma)
-- now, this means that we can build a path from w back to itself using the segments w to w' in p and q (do we have reversible paths in path.lean?)
sorry,
end
/- Lemma 2: (b) → (c) : there exists a unique path between any two distinct vertices → T is connected on n vertices with n - 1 edges -/
-- note: no mention of T being a tree here, so that's not one of our assumptions (and can be used on any simple graph i think)
-- Subproof outline: (strong induction on V.card)
-- Base Case: trivially true for V.card = 1, but that's because we have no edges
-- this might be a problem - if we don't have loops, how can we say the individual vertex has a path to itself?
-- maybe need to show it's true for V.card = 2?
-- IH: assume the statement holds for V.card < n vertices
-- let V.card = n
-- let u,v be distinct vertices in T
-- by assumption, a uv path p exists
-- since p is unique, removing an edge x from p (and in fact the edge set of T. maybe new induced subgraph definition?) disconnects u from v
-- the resultant graph contains two components H and K on vertex sets U and W, where U.card < n and W.card < n, so by IH we have U.card - 1 edges in H and W.card - 1 edges in K, and U.card + W.card = n - 1, which gives us n - 2 edges in H ∪ K. then adding back x, we have n - 1 edges in T.
/- Lemma 3: (c) → (d) : T is connected on n vertices with n - 1 edges → T is acyclic on n vertices with n - 1 edges -/
-- note: no mention of T being a tree here, so that's not one of our assumptions (and can be used on any simple graph)
-- Subproof outline:
-- suppose for contradiction that T has a cycle C of length k ≥ 3.
-- C contains k vertices and k edges (i think there are lemmas for this in path.lean)
-- since k ≤ n (by (c)), there are n - k vertices in T that are not in C
-- ∀ v : V, v ∉ C
-- consider a path connecting v to a vertex in C
-- each path will have at least 1 edge
-- the number of edges connecting the rest of the vertices in V to those in C is at least n - k
-- this means we have n - k + k = n ≤ edges in T, which is a contradiction
/- Lemma 4: (d) → (a) : T is acyclic on n vertices with n - 1 edges → T is a tree -/
-- note: this time we want to prove that T is a tree, so that's not one of our assumptions (and can be used on any simple graph)
-- Subproof outline:
-- T is acyclic, V.card = n
-- suppose T has k ≥ 1 components T1, T2, ... , Tk (oh boy finset time)
-- since T is acyclic and components are connected, each Ti is a tree (say they're on Vi, and Vi.card = ni)
-- since each Ti is a tree, we can use (a) → (b) → (c) to get that each Ti has ni - 1 edges
-- therefore, T has ∑ (ni - 1) = (∑ ni) - k = n - k edges
-- since n - k = n - 1, we have k = 1, so we have 1 component (which is connected by definition of component)
-- the one component is all of T (make this a lemma about components)
-- therefore T is acyclic and connected, and must be a tree
-- i guess make a bunch of iff lemmas out of that so i can rw stuff
-- make Prüfer codes
end simple_graph
|
/*
Copyright (c) 2022 Xavier Leclercq
Released under the MIT License
See https://github.com/ishiko-cpp/time/blob/main/LICENSE.txt
*/
#ifndef _ISHIKO_CPP_TIME_MONTH_HPP_
#define _ISHIKO_CPP_TIME_MONTH_HPP_
#include <boost/date_time.hpp>
#include <string>
namespace Ishiko
{
class Month
{
public:
enum Name
{
january = 1,
february = 2,
march = 3,
april = 4,
may = 5,
june = 6,
july = 7,
august = 8,
september = 9,
october = 10,
november = 11,
december = 12
};
Month(boost::gregorian::greg_month month);
unsigned char number() const;
bool operator==(int other) const;
bool operator!=(int other) const;
std::string toShortString() const;
private:
boost::gregorian::greg_month m_month;
};
}
#endif
|
module Data.Buffer
import Data.List
import System.FFI
%default total
-- Reading and writing binary buffers. Note that this primitives are unsafe,
-- in that they don't check that buffer locations are within bounds.
-- We really need a safe wrapper!
-- They are used in the Idris compiler itself for reading/writing checked
-- files.
-- This is known to the compiler, so maybe ought to be moved to Builtin
export
data Buffer : Type where [external]
bufferClass : String
bufferClass = "io/github/mmhelloworld/idrisjvm/runtime/IdrisBuffer"
stringsClass : String
stringsClass = "io/github/mmhelloworld/idrisjvm/runtime/Strings"
%foreign "scheme:blodwen-buffer-size"
"RefC:getBufferSize"
"node:lambda:b => b.length"
jvm bufferClass "size"
prim__bufferSize : Buffer -> Int
export %inline
rawSize : HasIO io => Buffer -> io Int
rawSize buf = pure (prim__bufferSize buf)
%foreign "scheme:blodwen-new-buffer"
"RefC:newBuffer"
"node:lambda:s=>Buffer.alloc(s)"
jvm bufferClass "create"
prim__newBuffer : Int -> PrimIO Buffer
export
newBuffer : HasIO io => Int -> io (Maybe Buffer)
newBuffer size
= if size >= 0
then do buf <- primIO (prim__newBuffer size)
pure $ Just buf
else pure Nothing
-- if prim__nullAnyPtr buf /= 0
-- then pure Nothing
-- else pure $ Just $ MkBuffer buf size 0
%foreign "scheme:blodwen-buffer-setbyte"
"RefC:setBufferByte"
"node:lambda:(buf,offset,value)=>buf.writeUInt8(value, offset)"
jvm bufferClass "setByte"
prim__setByte : Buffer -> (offset : Int) -> (val : Int) -> PrimIO ()
%foreign "scheme:blodwen-buffer-setbyte"
"RefC:setBufferByte"
"node:lambda:(buf,offset,value)=>buf.writeUInt8(value, offset)"
jvm bufferClass "setByte"
prim__setBits8 : Buffer -> (offset : Int) -> (val: Bits8) -> PrimIO ()
-- Assumes val is in the range 0-255
export %inline
setByte : HasIO io => Buffer -> (offset : Int) -> (val : Int) -> io ()
setByte buf offset val
= primIO (prim__setByte buf offset val)
export %inline
setBits8 : HasIO io => Buffer -> (offset : Int) -> (val : Bits8) -> io ()
setBits8 buf offset val
= primIO (prim__setBits8 buf offset val)
%foreign "scheme:blodwen-buffer-getbyte"
"RefC:getBufferByte"
"node:lambda:(buf,offset)=>buf.readUInt8(offset)"
jvm bufferClass "getByte"
prim__getByte : Buffer -> (offset : Int) -> PrimIO Int
%foreign "scheme:blodwen-buffer-getbyte"
"RefC:getBufferByte"
"node:lambda:(buf,offset)=>buf.readUInt8(offset)"
jvm bufferClass "getByte"
prim__getBits8 : Buffer -> (offset : Int) -> PrimIO Bits8
export %inline
getByte : HasIO io => Buffer -> (offset : Int) -> io Int
getByte buf offset
= primIO (prim__getByte buf offset)
export %inline
getBits8 : HasIO io => Buffer -> (offset : Int) -> io Bits8
getBits8 buf offset
= primIO (prim__getBits8 buf offset)
%foreign "scheme:blodwen-buffer-setbits16"
"node:lambda:(buf,offset,value)=>buf.writeUInt16LE(value, offset)"
jvm bufferClass "setShort"
prim__setBits16 : Buffer -> (offset : Int) -> (value : Bits16) -> PrimIO ()
export %inline
setBits16 : HasIO io => Buffer -> (offset : Int) -> (val : Bits16) -> io ()
setBits16 buf offset val
= primIO (prim__setBits16 buf offset val)
%foreign "scheme:blodwen-buffer-getbits16"
"node:lambda:(buf,offset)=>buf.readUInt16LE(offset)"
jvm bufferClass "getShort"
prim__getBits16 : Buffer -> (offset : Int) -> PrimIO Bits16
export %inline
getBits16 : HasIO io => Buffer -> (offset : Int) -> io Bits16
getBits16 buf offset
= primIO (prim__getBits16 buf offset)
%foreign "scheme:blodwen-buffer-setbits32"
"node:lambda:(buf,offset,value)=>buf.writeUInt32LE(value, offset)"
jvm bufferClass "setInt"
prim__setBits32 : Buffer -> (offset : Int) -> (value : Bits32) -> PrimIO ()
export %inline
setBits32 : HasIO io => Buffer -> (offset : Int) -> (val : Bits32) -> io ()
setBits32 buf offset val
= primIO (prim__setBits32 buf offset val)
%foreign "scheme:blodwen-buffer-getbits32"
"node:lambda:(buf,offset)=>buf.readUInt32LE(offset)"
jvm bufferClass "getInt"
prim__getBits32 : Buffer -> Int -> PrimIO Bits32
export %inline
getBits32 : HasIO io => Buffer -> (offset : Int) -> io Bits32
getBits32 buf offset
= primIO (prim__getBits32 buf offset)
%foreign "scheme:blodwen-buffer-setbits64"
jvm bufferClass "setLong"
prim__setBits64 : Buffer -> Int -> Bits64 -> PrimIO ()
export %inline
setBits64 : HasIO io => Buffer -> (offset : Int) -> (val : Bits64) -> io ()
setBits64 buf offset val
= primIO (prim__setBits64 buf offset val)
%foreign "scheme:blodwen-buffer-getbits64"
jvm bufferClass "getLong"
prim__getBits64 : Buffer -> (offset : Int) -> PrimIO Bits64
export %inline
getBits64 : HasIO io => Buffer -> (offset : Int) -> io Bits64
getBits64 buf offset
= primIO (prim__getBits64 buf offset)
%foreign "scheme:blodwen-buffer-setint32"
"node:lambda:(buf,offset,value)=>buf.writeInt32LE(value, offset)"
jvm bufferClass "setInt"
prim__setInt32 : Buffer -> (offset : Int) -> (val : Int) -> PrimIO ()
export %inline
setInt32 : HasIO io => Buffer -> (offset : Int) -> (val : Int) -> io ()
setInt32 buf offset val
= primIO (prim__setInt32 buf offset val)
%foreign "scheme:blodwen-buffer-getint32"
"node:lambda:(buf,offset)=>buf.readInt32LE(offset)"
jvm bufferClass "getInt"
prim__getInt32 : Buffer -> (offset : Int) -> PrimIO Int
export %inline
getInt32 : HasIO io => Buffer -> (offset : Int) -> io Int
getInt32 buf offset
= primIO (prim__getInt32 buf offset)
%foreign "scheme:blodwen-buffer-setint"
"RefC:setBufferInt"
"node:lambda:(buf,offset,value)=>buf.writeInt32LE(value, offset)"
jvm bufferClass "setInt"
prim__setInt : Buffer -> (offset : Int) -> (val : Int) -> PrimIO ()
export %inline
setInt : HasIO io => Buffer -> (offset : Int) -> (val : Int) -> io ()
setInt buf offset val
= primIO (prim__setInt buf offset val)
%foreign "scheme:blodwen-buffer-getint"
"RefC:getBufferInt"
"node:lambda:(buf,offset)=>buf.readInt32LE(offset)"
jvm bufferClass "getInt"
prim__getInt : Buffer -> (offset : Int) -> PrimIO Int
export %inline
getInt : HasIO io => Buffer -> (offset : Int) -> io Int
getInt buf offset
= primIO (prim__getInt buf offset)
%foreign "scheme:blodwen-buffer-setdouble"
"RefC:setBufferDouble"
"node:lambda:(buf,offset,value)=>buf.writeDoubleLE(value, offset)"
jvm bufferClass "setDouble"
prim__setDouble : Buffer -> (offset : Int) -> (val : Double) -> PrimIO ()
export %inline
setDouble : HasIO io => Buffer -> (offset : Int) -> (val : Double) -> io ()
setDouble buf offset val
= primIO (prim__setDouble buf offset val)
%foreign "scheme:blodwen-buffer-getdouble"
"RefC:getBufferDouble"
"node:lambda:(buf,offset)=>buf.readDoubleLE(offset)"
jvm bufferClass "getDouble"
prim__getDouble : Buffer -> (offset : Int) -> PrimIO Double
export %inline
getDouble : HasIO io => Buffer -> (offset : Int) -> io Double
getDouble buf offset
= primIO (prim__getDouble buf offset)
-- Get the length of a string in bytes, rather than characters
export
%foreign "scheme:blodwen-stringbytelen"
"C:strlen, libc 6"
jvm stringsClass "bytesLengthUtf8"
stringByteLength : String -> Int
%foreign "scheme:blodwen-buffer-setstring"
"RefC:setBufferString"
"node:lambda:(buf,offset,value)=>buf.write(value, offset,buf.length - offset, 'utf-8')"
jvm bufferClass "setString"
prim__setString : Buffer -> (offset : Int) -> (val : String) -> PrimIO ()
export %inline
setString : HasIO io => Buffer -> (offset : Int) -> (val : String) -> io ()
setString buf offset val
= primIO (prim__setString buf offset val)
%foreign "scheme:blodwen-buffer-getstring"
"RefC:getBufferString"
"node:lambda:(buf,offset,len)=>buf.slice(offset, offset+len).toString('utf-8')"
jvm bufferClass "getString"
prim__getString : Buffer -> (offset : Int) -> (len : Int) -> PrimIO String
export %inline
getString : HasIO io => Buffer -> (offset : Int) -> (len : Int) -> io String
getString buf offset len
= primIO (prim__getString buf offset len)
export
covering
bufferData : HasIO io => Buffer -> io (List Int)
bufferData buf
= do len <- rawSize buf
unpackTo [] len
where
covering
unpackTo : List Int -> Int -> io (List Int)
unpackTo acc 0 = pure acc
unpackTo acc offset
= do val <- getByte buf (offset - 1)
unpackTo (val :: acc) (offset - 1)
%foreign "scheme:blodwen-buffer-copydata"
"RefC:copyBuffer"
"node:lambda:(b1,o1,length,b2,o2)=>b1.copy(b2,o2,o1,o1+length)"
jvm bufferClass "copy"
prim__copyData : (src : Buffer) -> (srcOffset, len : Int) ->
(dst : Buffer) -> (dstOffset : Int) -> PrimIO ()
export
copyData : HasIO io => Buffer -> (srcOffset, len : Int) ->
(dst : Buffer) -> (dstOffset : Int) -> io ()
copyData src start len dest offset
= primIO (prim__copyData src start len dest offset)
export
resizeBuffer : HasIO io => Buffer -> Int -> io (Maybe Buffer)
resizeBuffer old newsize
= do Just buf <- newBuffer newsize
| Nothing => pure Nothing
-- If the new buffer is smaller than the old one, just copy what
-- fits
oldsize <- rawSize old
let len = if newsize < oldsize then newsize else oldsize
copyData old 0 len buf 0
pure (Just buf)
||| Create a buffer containing the concatenated content from a
||| list of buffers.
export
concatBuffers : HasIO io => List Buffer -> io (Maybe Buffer)
concatBuffers xs
= do let sizes = map prim__bufferSize xs
let (totalSize, revCumulative) = foldl scanSize (0,[]) sizes
let cumulative = reverse revCumulative
Just buf <- newBuffer totalSize
| Nothing => pure Nothing
traverse_ (\(b, size, watermark) => copyData b 0 size buf watermark) (zip3 xs sizes cumulative)
pure (Just buf)
where
scanSize : (Int, List Int) -> Int -> (Int, List Int)
scanSize (s, cs) x = (s+x, s::cs)
||| Split a buffer into two at a position.
export
splitBuffer : HasIO io => Buffer -> Int -> io (Maybe (Buffer, Buffer))
splitBuffer buf pos = do size <- rawSize buf
if pos > 0 && pos < size
then do Just first <- newBuffer pos
| Nothing => pure Nothing
Just second <- newBuffer (size - pos)
| Nothing => pure Nothing
copyData buf 0 pos first 0
copyData buf pos (size-pos) second 0
pure $ Just (first, second)
else pure Nothing
|
%% CorpusAvesticum.tex
%% Copyright 2018-2021 Martin Sievers
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Martin Sievers
%
% This work consists of the files
% brill.cls
% brill.lua
% CorpusAvesticum.tex
% muya.bbx
% muya.cbx
% muya.dbx
% muya.lua
% xindex-brill.lua
% xindex-muya.lua
% xindex-muyaPassages.lua
%%
\ProvidesFile{CorpusAvesticum.tex}%
[2021/08/30 v0.93.0 Configuration file for brill]
\RequirePackage{xspace}
\RequirePackage{collcell}
\RequirePackage{newunicodechar}
%\RequirePackage[pages=absolute]{flowfram}
%\if@printversion
% \RequirePackage[status=final,layout={margin},author={!!!}]{fixme}
%\else
% \RequirePackage[status=draft,layout={margin},author={!!!}]{fixme}
%\fi%
%\directlua {
% fonts.handlers.otf.addfeature {
% name = "supsnumonly",
% type = "substitution",
% data = {
% ["0"] = "⁰",
% ["1"] = "¹",
% ["2"] = "²",
% ["3"] = "³",
% ["4"] = "⁴",
% ["5"] = "⁵",
% ["6"] = "⁶",
% ["7"] = "⁷",
% ["8"] = "⁸",
% ["9"] = "⁹",
% },
% }
% fonts.handlers.otf.addfeature {
% name = "supsaddkern",
% type = "kern",
% data = {
% ["ī"] = {
% ["¹"] = 500,%
% ["1"] = 500,%
% ["2"] = 500,%
% ["three.sups"] = 500,%
% ["four.sups"] = 500,%
% ["five.sups"] = 500,%
% ["six.sups"] = 500,%
% ["seven.sups"] = 500,%
% ["eight.sups"] = 500,%
% ["nine.sups"] = 500,%
% },
% ["š"] = {%
% ["¹"] = 500,%
% ["two.sups"] = 500,%
% ["three.sups"] = 500,%
% ["four.sups"] = 500,%
% ["five.sups"] = 500,%
% ["six.sups"] = 500,%
% ["seven.sups"] = 500,%
% ["eight.sups"] = 500,%
% ["nine.sups"] = 500,%
% },
% },
% }
%}
%\newfontfamily{\editedtextfont}{Brill}
%[%
% Ligatures = {Common,NoRare},%
% SmallCapsFeatures = {RawFeature=+c2sc},%
% Renderer = Node,%
% RawFeature = {+supsnumonly,+supsaddkern},%
%]%
\newfontfamily{\freeserif}{FreeSerif}%
[%
Extension = .otf,%
UprightFont = *,%
BoldFont = *Bold,%
ItalicFont = *Italic,%
BoldItalicFont = *BoldItalic,%
Scale = MatchLowercase,%
Ligatures = {Common},%
Renderer = Node,%
]%
\newfontfamily{\freesans}{FreeSans}%
[%
Extension = .otf,%
UprightFont = *,%
BoldFont = *Bold,%
ItalicFont = *Oblique,%
BoldItalicFont = *BoldOblique,%
Scale = MatchLowercase,%
Ligatures = {Common},%
Renderer = Node,%
]%
\newfontfamily{\avestanfont}{NotoSansAvestan}%
[%
Extension = .ttf,%
UprightFont = *-Regular,%
Scale = MatchLowercase,%
Ligatures = {Common},%
Renderer = Harfbuzz,%
Script = Avestan,%
]%
\newfontfamily{\gujaratifont}{NotoSerifGujarati}%
[%
Extension = .ttf,%
UprightFont = *-Regular,%
BoldFont = *-Bold,%
Scale = MatchLowercase,%
Renderer = Harfbuzz,%
Script = Gujarati,%
]%
\newfontfamily{\arabicfont}{NotoNaskhArabic}%
[%
Extension = .ttf,%
UprightFont = *-Regular,%
BoldFont = *-Bold,%
Scale = MatchLowercase,%
Ligatures = {Common},%
Renderer = Harfbuzz,%
Script = Arabic,%
]%
\newfontfamily{\sanskritfont}{NotoSerifDevanagari}%
[%
Extension = .ttf,%
UprightFont = *-Regular,%
BoldFont = *-Bold,%
Scale = MatchLowercase,%
Renderer = Harfbuzz,%
Script = Devanagari,%
]%
\newfontfamily{\pahlavifont}{KHUSRO__}%
[%
Extension = .TTF,%
UprightFont = *,%
Scale = MatchLowercase,%
]%
\newfontfamily{\syriacfont}{NotoSansSyriac}%
[%
Extension = .ttf,%
UprightFont = *-Regular,%
BoldFont = *-Black,%
Scale = MatchLowercase,%
Renderer = Harfbuzz,%
Script = Syriac,%
]%
\newcommand{\textarabic}[1]{%
\bgroup\microtypesetup{activate=false}\textdir TRT\arabicfont #1\egroup}
\newcommand{\textavestan}[1]{%
\bgroup\microtypesetup{activate=false}\textdir TRT\avestanfont #1\egroup}
\newcommand{\textgujarati}[1]{%
\bgroup\microtypesetup{activate=false}\gujaratifont #1\egroup}
\newcommand{\textpahlavi}[1]{%
\bgroup\microtypesetup{activate=false}\textdir TRT\pahlavifont #1\egroup}
\newcommand{\textsanskrit}[1]{%
\bgroup\microtypesetup{activate=false}\sanskritfont #1\egroup}
\newcommand{\textsyriac}[1]{%
\bgroup\microtypesetup{activate=false}\syriacfont #1\egroup}
\newcommand*{\aee}{ǝ̄}
\newcommand*{\XVE}{x\realsuperscript{v}}%\ifdefstring{\f@shape}{it}{\kern-1pt}{}}
\newcommand*{\NGVE}{ŋ\realsuperscript{v}}%\ifdefstring{\f@shape}{it}{\kern-1pt}{}}
\newcommand*{\shinthreedots}{%
\ifdefstring{\f@shape}{it}
{\ensuremath{\stackrel%
{\text{\raisebox{-1.5ex}[0pt][0pt]{\hspace{0.3em}\syriacfont\symbol{"0745}}}}%
{\text{š}}}%
}%
{\ensuremath{\stackrel%
{\text{\raisebox{-1.5ex}[0pt][0pt]{\syriacfont\symbol{"0745}}}}%
{\text{š}}}%
}%
}
\newcommand*{\AvA}{\symbol{"10B00}}
\newcommand*{\AvAA}{\symbol{"10B01}}
\newcommand*{\AvAO}{\symbol{"10B02}}
\newcommand*{\AvAAO}{\symbol{"10B03}}
\newcommand*{\AvAN}{\symbol{"10B04}}
\newcommand*{\AvAAN}{\symbol{"10B05}}
\newcommand*{\AvAE}{\symbol{"10B06}}
\newcommand*{\AvAEE}{\symbol{"10B07}}
\newcommand*{\AvE}{\symbol{"10B08}}
\newcommand*{\AvEE}{\symbol{"10B09}}
\newcommand*{\AvO}{\symbol{"10B0A}}
\newcommand*{\AvOO}{\symbol{"10B0B}}
\newcommand*{\AvI}{\symbol{"10B0C}}
\newcommand*{\AvII}{\symbol{"10B0D}}
\newcommand*{\AvU}{\symbol{"10B0E}}
\newcommand*{\AvUU}{\symbol{"10B0F}}
\newcommand*{\AvKE}{\symbol{"10B10}}
\newcommand*{\AvXE}{\symbol{"10B11}}
\newcommand*{\AvXYE}{\symbol{"10B12}}
\newcommand*{\AvXVE}{\symbol{"10B13}}
\newcommand*{\AvGE}{\symbol{"10B14}}
\newcommand*{\AvGGE}{\symbol{"10B15}}
\newcommand*{\AvGHE}{\symbol{"10B16}}
\newcommand*{\AvCE}{\symbol{"10B17}}
\newcommand*{\AvJE}{\symbol{"10B18}}
\newcommand*{\AvTE}{\symbol{"10B19}}
\newcommand*{\AvTHE}{\symbol{"10B1A}}
\newcommand*{\AvDE}{\symbol{"10B1B}}
\newcommand*{\AvDHE}{\symbol{"10B1C}}
\newcommand*{\AvTTE}{\symbol{"10B1D}}
\newcommand*{\AvPE}{\symbol{"10B1E}}
\newcommand*{\AvFE}{\symbol{"10B1F}}
\newcommand*{\AvBE}{\symbol{"10B20}}
\newcommand*{\AvBHE}{\symbol{"10B21}}
\newcommand*{\AvNGE}{\symbol{"10B22}}
\newcommand*{\AvNGYE}{\symbol{"10B23}}
\newcommand*{\AvNGVE}{\symbol{"10B24}}
\newcommand*{\AvNE}{\symbol{"10B25}}
\newcommand*{\AvNYE}{\symbol{"10B26}}
\newcommand*{\AvNNE}{\symbol{"10B27}}
\newcommand*{\AvME}{\symbol{"10B28}}
\newcommand*{\AvHME}{\symbol{"10B29}}
\newcommand*{\AvYYE}{\symbol{"10B2A}}
\newcommand*{\AvYE}{\symbol{"10B2B}}
\newcommand*{\AvVE}{\symbol{"10B2C}}
\newcommand*{\AvRE}{\symbol{"10B2D}}
\newcommand*{\AvLE}{\symbol{"10B2E}}
\newcommand*{\AvSE}{\symbol{"10B2F}}
\newcommand*{\AvZE}{\symbol{"10B30}}
\newcommand*{\AvSHE}{\symbol{"10B31}}
\newcommand*{\AvZHE}{\symbol{"10B32}}
\newcommand*{\AvSHYE}{\symbol{"10B33}}
\newcommand*{\AvSSHE}{\symbol{"10B34}}
\newcommand*{\AvHE}{\symbol{"10B35}}
\newcommand*{\AvAbbrev}{\symbol{"10B39}}
\newcommand*{\AvTTDOOD}{\symbol{"10B3A}}
\newcommand*{\AvSTDOOD}{\symbol{"10B3B}}
\newcommand*{\AvLTDOOD}{\symbol{"10B3C}}
\newcommand*{\AvLODOTD}{\symbol{"10B3D}}
\newcommand*{\AvLTROOR}{\symbol{"10B3E}}
\newcommand*{\AvLOROTR}{\symbol{"10B3F}}
%%% Special characters
%\newunicodechar{←}{{\freeserif\symbol{"2190}}}
%\newunicodechar{→}{{\freeserif\symbol{"2192}}}
\newunicodechar{〈}{\textlangle}% map U+2329 to U+27E8
\newunicodechar{〉}{\textrangle}% map U+232A to U+27E9
\newunicodechar{●}{{\freeserif\symbol{"25CF}}}
\newunicodechar{✓}{{\freeserif\symbol{"2713}}}
\newunicodechar{θ}{ϑ}
\newunicodechar{।}{\textsanskrit{।}}
%\newcommand{\DeclareUnicodeCharacter}[2]{%
% \begingroup\lccode`|=\string"#1\relax
% \lowercase{\endgroup\newunicodechar{|}}{#2}%
%}
%\DeclareUnicodeCharacter{0745}{\raisebox{.75ex}{{\negthinspace\syriacfont\symbol{"0745}}}}
%\newunicodechar{݅ }{\textsyriac{\symbol{"0745}}}
%%%
\newcommand*{\blackcircle}{●}
\renewcommand*{\checkmark}{✓}% from AMSmath
\newcommand*{\leftwardsarrow}{←}
\newcommand*{\rightwardsarrow}{→}
\newcommand*{\sectionsign}{§}
%%% remap from U+2329 to U+27E8 and from U+232A to U+27E9
\renewcommand*{\textlangle}{⟨}% U+27E8
\renewcommand*{\textrangle}{⟩}% U+27E9
\directlua{require("muya")}
\ifbrill@countwords
\directlua{dofile(kpse.find_file"word_count.lua")}
\def\setwordthreshold#1{%
\directlua{packagedata.word_count.set_threshold(\number#1)}%
}
\def\startwordcount{%
\directlua{
luatexbase.add_to_callback(
"pre_linebreak_filter",
packagedata.word_count.callback,
"word_count"
)
}%
}
\def\stopwordcount{%
\endgraf %% force paragraph
\directlua{
luatexbase.remove_from_callback(
"pre_linebreak_filter",
"word_count"
)
}%
}
%%% This outputs the word count to stdout.
\def\dumpwordcount{%
\directlua{packagedata.word_count.dump_total_word_count()}
}
%%% This returns the word count at the current position. Works only at
%%% the end of a paragraph.
\def\currentwordcount{%
\directlua{packagedata.word_count.current_word_count()}%
\logwordcount
}
% \def\printwordcount{%
% \directlua{packagedata.word_count.print_total_word_count()}%
% \logwordcount
% }
\def\logwordcount{%
\directlua{packagedata.word_count.print_total_word_count_to_log()}%
}
\else
\def\setwordthreshold#1{\@gobble}
\let\startwordcount\relax
\let\stopwordcount\relax
\let\dumpwordcount\relax
\let\currentwordcount\relax
% \let\printwordcount\relax
\let\logwordcount\relax
\fi%
\renewrobustcmd*{\textsuperscript}[1]{%
% \edef\@tempsup{#1}%
\Ifisinteger{#1}%
{\realsuperscript{#1}}%
{%
\IfStrEqCase{#1}{%
{+}{\realsuperscript{+}}%
{=}{\realsuperscript{=}}%
{(}{\realsuperscript{(}}%
{)}{\realsuperscript{)}}%
{nd}{\realsuperscript{nd}}%
{rd}{\realsuperscript{rd}}%
{st}{\realsuperscript{st}}%
{th}{\realsuperscript{th}}%
{x}{\realsuperscript{x}}%
}[\fakesuperscript{#1}]%
}%
}
\newsavebox\@titlebox
\newsavebox\@subtitlebox
\newlength{\@titleskip}
\newlength{\@subtitleskipbefore}
\newlength{\@subtitleskipafter}
\ifbrill@PhD
\renewcommand*{\maketitle}[1][1]{%
\begin{titlepage}
\setcounter{page}{%
#1%
}%
\let\titlepage@restore\relax
%\let\footnotesize\small
\let\footnoterule\relax
\let\footnote\thanks
\renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
\let\@oldmakefnmark\@makefnmark
\renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
{\centering
{\usekomafont{title}\LARGE\@title\par}
\ifx\@subtitle\@empty
\vskip 3\baselineskip
\else
\vskip 2\baselineskip
{\usekomafont{subtitle}\Large\@subtitle\par}
\vskip 3\baselineskip
\fi%
{\usekomafont{author}\@author\par}
\vskip 3\baselineskip
\ifdefempty{\@degree}{}{\@degree\\}%
\@date\par
\vfill
\ifdefempty{\@department}{}{\@department\\}%
SOAS, University of London\par
}%
\ifdefempty{\@declarationPhD}{}{%
\next@tdpage
\@declarationPhD
}%
\ifx\@abstract\@empty
\else%
\next@tdpage%
\@abstractheading%
\@abstract%
\fi%
\end{titlepage}
\setcounter{footnote}{0}%
\global\let\and\relax
}
\else
\renewcommand*{\maketitle}[1][1]{%
\InputIfFileExists{titlepages.tex}%
{\ClassInfo{brill}{Information for title pages successfully loaded}}%
{\ClassWarningNoLine{brill}{Found no titlepage information.\MessageBreak
Please check, whether you copied titlepages.tex correctly.}}%
\def\and{\newline}
\begin{titlepage}
\setcounter{page}{%
#1%
}%
\let\titlepage@restore\relax
%\let\footnotesize\small
\let\footnoterule\relax
\let\footnote\thanks
\renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
\let\@oldmakefnmark\@makefnmark
\renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
%%% Calculate title size
\savebox{\@titlebox}{\parbox[b]{\textwidth}{\centering\usekomafont{title}{\fontsize{28bp}{33bp}\selectfont\@title\strut\par\kern-\prevdepth}}}%
\savebox{\@subtitlebox}{\parbox[b]{\textwidth}{\centering\usekomafont{subtitle}{\fontsize{16bp}{20bp}\selectfont\@subtitle\strut\par\kern-\prevdepth}}}%
\ifdimless{\ht\@titlebox}{30bp}{\setlength{\@titleskip}{-1.6bp}}{%
\ifdimless{\ht\@titlebox}{60bp}{\setlength{\@titleskip}{5bp}}{\setlength{\@titleskip}{11.6bp}}%
}
\ifdimless{\ht\@subtitlebox}{20bp}{%
\setlength{\@subtitleskipbefore}{0bp}%
\setlength{\@subtitleskipafter}{2.8bp}%
}{%
\ifdimless{\ht\@subtitlebox}{40bp}{%
\setlength{\@subtitleskipbefore}{3.2bp}%
\setlength{\@subtitleskipafter}{9.6bp}%
}{\setlength{\@subtitleskip}{10bp}}%
}
\ifx\@extratitle\@empty
\ifx\@frontispiece\@empty
\else
\if@twoside\mbox{}\next@tpage\fi
\vspace*{\dimexpr -\topskip\relax}%
\@frontispiece\next@tdpage
\fi
\else
\noindent\@extratitle
\ifx\@frontispiece\@empty
\else
\next@tpage
\vspace*{\dimexpr -\normalbaselineskip-\topskip-\dp\strutbox\relax}%
\noindent\@frontispiece
\fi%
\next@tdpage
\fi%
\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
{\centering
{\vspace*{-33bp}\usekomafont{title}{\fontsize{28bp}{33bp}\selectfont\@title\strut\par\kern-\prevdepth}}%
%\vskip\@titleskip%
\ifx\@subtitle\@empty%
\vskip 4.7bp%
\else%
%\vskip\@subtitleskipbefore%
%\vskip -\dp\strutbox%
\vspace{\dimexpr 2.0\normalbaselineskip+1bp\relax}%
%\vskip 1bp%
{%
\usekomafont{subtitle}{\fontsize{16bp}{20bp}\selectfont\@subtitle\strut\par\kern-\prevdepth}%
}%
\vskip\@subtitleskipafter%
\fi%
\vskip 3\baselineskip%
{%
\normalsize\itshape By\strut\par%
\kern-\prevdepth%
}%
\vskip 1\baselineskip%
{%
\fontsize{14bp}{17bp}\selectfont\@author\strut\par%
\kern-\prevdepth%
}%
\vfill
\IfFileExists{\@titlelogofile}%
{\includegraphics[scale=0.8]{\@titlelogofile}\par\vspace*{\baselineskip}}%
{}
{\normalsize\scshape LEIDEN\ |\ BOSTON\par}%
}%
\next@tpage
\begin{addmargin}[-11mm]{-4mm}
\begin{minipage}[t]{100mm}
\footnotesize%
\raggedright%
\hyphenpenalty=\@M%
\@uppertitleback%
\end{minipage}%
\vfill
\begin{minipage}[b]{130mm}%
\footnotesize%
\raggedright%
\hyphenpenalty=\@M%
\@lowertitleback%
\end{minipage}%
\end{addmargin}\removelastskip%
\vspace*{35mm}%
\ifx\@dedication\@empty
\else
\next@tdpage\null\vfill
{\centering
{\usekomafont{dedication}{\fontsize{12bp}{13.2bp}\selectfont\@dedication\par}}%
\vskip 3\baselineskip
{\fontsize{24bp}{13.2bp}\selectfont\symbol{"2235}\par}}%
\vspace*{22\baselineskip}%
\cleardoubleemptypage
\fi
\ifx\titlepage@restore\relax\else\clearpage\titlepage@restore\fi
\end{titlepage}
\setcounter{footnote}{0}%
\global\let\and\relax
}%
\fi%
\patchcmd{\imki@putindex}%
{\immediate\closeout\csname #1@idxfile\endcsname}%
{\immediate\closeout\csname #1@idxfile\endcsname
\Ifstr{#1}{passages}{%
\ClassInfo{brill}{Start modifying passages for sorting ...}%
\directlua{modifySorting()}%
\ClassInfo{brill}{... done.}%
}{}}%
{\ClassInfo{brill}{\string\imki@putindex\space successfully patched!}}%
{\ClassInfo{brill}{\string\imki@putindex\space could not be patched!}}%
\patchcmd{\imki@putindex}%
{\@input@{#1.ind}}%
{%
\Ifstr{#1}{passages}%
{\@input@{passages-mod.ind}}%
{%
\Ifstr{#1}{words}%
{%
\IfFileExists{words-mod.ind}%
{\@input@{words-mod.ind}}%
{\@input@{#1.ind}}%
}%
{\@input@{#1.ind}}%
}%
}%
{\ClassInfo{brill}{\string\imki@putindex\space successfully patched!}}%
{\ClassInfo{brill}{\string\imki@putindex\space could not be patched!}}%
\patchcmd{\imki@putindex}%
{\imki@exec{\imki@program\imki@options#1.idx}}%
{%
\Ifstr{#1}{passages}%
{\imki@exec{\imki@program\imki@options#1-mod.idx}}%
{\imki@exec{\imki@program\imki@options#1.idx}}%
}%
{\ClassInfo{brill}{\string\imki@putindex\space successfully patched!}}%
{\ClassInfo{brill}{\string\imki@putindex\space could not be patched!}}%
\patchcmd{\theindex}%
{\begin{multicols}}%
{\vspace*{-\normalbaselineskip}\begin{multicols}}%
{\ClassInfo{brill}{\string\theindex\space successfully patched!}}%
{\ClassInfo{brill}{\string\theindex\space could not be patched!}}%
%\def\brill@imki@putindexsplit#1{%
% \ifimki@nonewpage\else
% \imki@clearpage
% \fi
% \let\imki@indexname\indexname % keep \indexname
% \def\imki@maybeaddtotoc{\@nameuse{phantomsection}%
% \addcontentsline{toc}{\imki@toclevel}{\imki@title}}%
% \ifx\imki@title\imki@check@indexname\else
% \def\indexname{\imki@title}%
% \fi
% \@input@{#1.ind}
% \let\indexname\imki@indexname % restore \indexname
%}
\newcommand{\printindexes}{%
\let\indexspace\relax%
\begingroup%
\renewcommand*{\subitem}{\par\hangindent 2\normalparindent\relax}%
\renewcommand*{\@idxitem}{%
\par\nopagebreak\addvspace{\baselineskip}\relax}%
\printindex[words]%
\printindex[passages]%
\endgroup%
\printindex[namesandsubjects]%
}
\ifbrill@PhD
\makeindex[%
name=words,%
title={Index of Words},%
columns=3,%
columnsep=4mm,%
options={-u -l av -n -c muya}%
]%
\makeindex[%
name=passages,%
title={Index of Passages},%
columns=3,%
columnsep=4mm,%
options={-n -c muyaPassages}%
]%
\makeindex[%
name=namesandsubjects,%
title={Index of Names and Subjects},%
columns=3,%
columnsep=4mm,%
options={-n -c brill}%
]%
\else
\makeindex[%
name=words,%
title={Index of Words},%
columns=2,%
columnsep=4mm,%
options={-u -l av -n -c muya}%
]%
\makeindex[%
name=passages,%
title={Index of Passages},%
columns=2,%
columnsep=4mm,%
options={-n -c muyaPassages}%
]%
\makeindex[%
name=namesandsubjects,%
title={Index of Names and Subjects},%
columns=2,%
columnsep=4mm,%
options={-n -c brill}%
]%
\fi%
\newcommand*{\indexheaderfont}[1]{\textbf{#1}}
\protected\def\Word{\@ifstar{\@indexwords}{\@dblarg\@@indexwords}}
\newcommand{\@indexwords}[1]{%
\StrCut*{#1}{!}{\@leftword}{\@rightword}%
\ifstrempty{\@rightword}% no '!' in Argument
{\index[words]{%
\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1@\idxentryfont{#1}}%
}%
{\index[words]{%
\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1@\idxentryfont{\@rightword}}%
}%
}%
\newcommand{\@@indexwords}[2][]{%
% \StrDel{#1}{-}[\@@@rest]
% \StrDel{\@@@rest}{.}[\@@rest]
% \StrDel{\@@rest}{ }[\@rest]
\index[words]{%
\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1@\idxentryfont{#1}}%
#2%
\index[words]{%
\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1@\idxentryfont{#1}}%
}%
\protected\def\Passage{\@ifstar{\@indexpassages}{\@dblarg\@@indexpassages}}
\newcommand{\@indexpassages}[1]{%
\index[passages]{%
\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1@\textup{#1}%
}%
}
\newcommand{\@@indexpassages}[2][]{%
\index[passages]{\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1}%
\textup{#2}%
\index[passages]{\indexlanguage{}@\indexheaderfont{\indexlanguage}!#1}%
}%
\protected\def\Name{\@ifstar%
{\@indexnamesandsubjects}{\@dblarg\@@indexnamesandsubjects}}
\protected\def\Subject{\@ifstar%
{\@indexnamesandsubjects}{\@dblarg\@@indexnamesandsubjects}}
\newcommand{\@indexnamesandsubjects}[1]{\index[namesandsubjects]{#1}}
\newcommand{\@@indexnamesandsubjects}[2][]{\index[namesandsubjects]{#1}#2}
\let\passage\Passage
\let\subject\Subject
\let\name\Name
\let\word\Word
\newcommand*{\indexlanguage}{A@General}
\newcommand*{\idxentryfont}[1]{#1}
\newcommand*{\resetlanguage}{\gdef\indexlanguage{A@General}\renewcommand*{\idxentryfont}[1]{##1}}
\newcommand{\ItalicsOrNot}[1]{%
\IfStrEqCase{#1}{%
{Aram}{\def\indexlanguage{Aramaic}\itshape}%
{Arm}{\def\indexlanguage{Armenian}\itshape}%
{Av}{\def\indexlanguage{Avestan}\itshape}%
{Bactr}{\def\indexlanguage{Bactrian}\upshape}%
{Chor}{\def\indexlanguage{Choresmian}\itshape}%
{El}{\def\indexlanguage{Elamite}\itshape}%
{Goth}{\def\indexlanguage{Gothic}\itshape}%
{Grk}{\def\indexlanguage{Greek}\upshape}%
{Guj}{\def\indexlanguage{Gujarati}\itshape}%
{Hitt}{\def\indexlanguage{Hittite}\itshape}%
{IE}{\def\indexlanguage{Proto-Indo-European}\itshape}%
{IIr}{\def\indexlanguage{Proto-Indo-Iranian}\itshape}%
{IMP}{\def\indexlanguage{Inscriptional Middle Persian}\itshape}%
{Khot}{\def\indexlanguage{Khotanese}\itshape}%
{Lat}{\def\indexlanguage{Latin}\itshape}%
{Lith}{\def\indexlanguage{Lithuanian}\itshape}%
{Luw}{\def\indexlanguage{Luwian}\itshape}%
{MAv}{\def\indexlanguage{Middle Avestan}\itshape}%
{MMP}{\def\indexlanguage{Manichaean Middle Persian}\itshape}%
{MP}{\def\indexlanguage{Middle Persian (unspecified)}\itshape}%
{Munji}{\def\indexlanguage{Munji}\itshape}%
{NP}{\def\indexlanguage{New Persian}\itshape}%
{OAv}{\def\indexlanguage{Old Avestan}\itshape}
{OE}{\def\indexlanguage{Old English}\itshape}%
{OHG}{\def\indexlanguage{Old High German}\itshape}%
{OIrish}{\def\indexlanguage{Old Irish}\itshape}%
{OP}{\def\indexlanguage{Old Persian}\itshape}%
{Oss}{\def\indexlanguage{Ossetic}\itshape}%
{OssD}{\def\indexlanguage{Digoron Ossetic}\itshape}%
{OssI}{\def\indexlanguage{Iron Ossetic}\itshape}%
{Parth}{\def\indexlanguage{Parthian}\itshape}%
{Pashto}{\def\indexlanguage{Pashto}\itshape}%
{PDE}{\def\indexlanguage{Present-Day English}\itshape}%
{PGmc}{\def\indexlanguage{Proto-Germanic}\itshape}%
{Phl}{\def\indexlanguage{Pahlavi}\itshape}%
{Phltlt}{\def\indexlanguage{Pahlavi}\@morewordspace}%
{PIE}{\def\indexlanguage{Proto-Indo-European}\itshape}%
{Pli}{\def\indexlanguage{PāỊi}\itshape}%
{Pra}{\def\indexlanguage{Prakrit}\itshape}%
{PrIIr}{\def\indexlanguage{Proto-Indo-Iranian}\itshape}%
{PrIr}{\def\indexlanguage{Proto-Iranian}\itshape}%
{Pz}{\def\indexlanguage{Pāzand}\itshape}%
{Shugni}{\def\indexlanguage{Shugni}\itshape}%
{Skt}{\def\indexlanguage{Sanskrit}\itshape}%
{Sogd}{\def\indexlanguage{Sogdian}\itshape}%
{TochA}{\def\indexlanguage{Tocharian A}\itshape}%
{TochB}{\def\indexlanguage{Tocharian B}\itshape}%
{Ved}{\def\indexlanguage{Vedic}\itshape}%
{Yidgha}{\def\indexlanguage{Yidgha}\itshape}%
{ZD}{\def\indexlanguage{Zoroastrian Dari}\itshape}%
}[\ClassWarning{brill}{Language `#1` unknown. Using category `General`}%
\def\indexlanguage{A@General}\upshape]%
\hyphenpenalty=\@M%
\exhyphenpenalty=\@M%
}
%%% Define macros for languages
\def\newlanguage{\@ifstar\@newlanguage\@@newlanguage}%
\newcommand{\@newlanguage}[2]{%
\expandafter\newcommand\csname #1\endcsname[2][]{%
\def\indexlanguage{#2}%
\renewcommand*{\idxentryfont}[1]{####1}%
\begin{nohyphens}\nosmallcaps ##2\end{nohyphens}%
\ifstrempty{##1}{}{\ \enquote{##1}}%
\resetlanguage}
\newenvironment{#1Block}{%
\def\indexlanguage{#2}%
\renewcommand*{\idxentryfont}[1]{####1}%
\begin{nohyphens}%
\nosmallcaps%
}%
{%
\end{nohyphens}%
\resetlanguage%
}%
}
\newcommand{\@@newlanguage}[2]{%
\expandafter\newcommand\csname #1\endcsname[2][]{%
\def\indexlanguage{#2}%
\renewcommand*{\idxentryfont}[1]{\textit{####1}}%
\begin{nohyphens}\nosmallcaps\emph{##2}\end{nohyphens}%
\ifstrempty{##1}{}{\ \enquote{##1}}%
\resetlanguage}
\newenvironment{#1Block}{%
\def\indexlanguage{#2}%
\renewcommand*{\idxentryfont}[1]{\textit{####1}}%
\begin{nohyphens}%
\nosmallcaps\itshape}%
{\end{nohyphens}%
\resetlanguage}
}
\newlanguage{Aram}{Aramaic}
\newlanguage{Arm}{Armenian}
\protected\def\Av{\@ifstar\@Av\@@Av}
\newcommand*{\@Av}[2][]{%
\def\indexlanguage{Avestan}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}%
\Word[#2]{\begin{nohyphens}\nosmallcaps\emph{#2}\end{nohyphens}}%
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage}
\newcommand*{\@@Av}[2][]{%
\def\indexlanguage{Avestan}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}%
\begin{nohyphens}\nosmallcaps\emph{#2}\end{nohyphens}%
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage}
\let\Avst\Av
\newcommand*{\Bactr}[3][]{%
\def\indexlanguage{Bactrian}%
\renewcommand*{\idxentryfont}[1]{##1}%
\ifstrempty{#2}
{/#3/}%
{%
\begin{nohyphens}\nosmallcaps #2\end{nohyphens}%
\ifstrempty{#3}{}{\ /#3/}%
}%
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage}
\newlanguage{Chor}{Choresmian}
\newlanguage{El}{Elamite}
\newlanguage{NP}{New Persian}
\let\Fa\NP
\newlanguage{Goth}{Gothic}
\newlanguage*{Grk}{Greek}
\newlanguage{Guj}{Gujarati}
\let\Gujr\Guj
\newlanguage{Hitt}{Hittite}
\newlanguage{IMP}{Inscriptional Middle Persian}
\newlanguage{Khot}{Khotanese}
\newlanguage{Lat}{Latin}
\newlanguage{Lith}{Lithuanian}
\newlanguage{Luw}{Luwian}
\newlanguage{MAv}{Middle Avestan}
\newlanguage{MMP}{Manichaean Middle Persian}
\newlanguage{MP}{Middle Persian (unspecified)}
\newlanguage{Munji}{Munji}
\newlanguage{OAv}{Old Avestan}
\let\origOE\OE
\let\OE\@undefined
\newlanguage{OE}{Old English}
\newlanguage{OHG}{Old High German}
\newlanguage{OIrish}{Old Irish}
\newcommand*{\OP}[2][]{%
\@ifnextchar\bgroup{\@OP[#1]{#2}}{\@OP[#1]{#2}{}}}
\newcommand*{\@OP}[3][]{%
\def\indexlanguage{Old Persian}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}%
\begin{nohyphens}\nosmallcaps\textit{#2}\end{nohyphens}%
\ifstrempty{#3}{}{\ [#3]}%
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage%
\xspace%
}
\newcommand*{\OPtlt}[2][]{%
\def\indexlanguage{Old Persian}%
\renewcommand*{\idxentryfont}[1]{##1}%
\begin{nohyphens}\nosmallcaps #2\end{nohyphens}%
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage}
\newlanguage{Oss}{Ossetic}
\newlanguage{OssD}{Iron Ossetic}
\newlanguage{OssI}{Iron Ossetic}
\newlanguage{Parth}{Parthian}
\newlanguage{Pashto}{Paṣ̌tō}
\newlanguage{PDE}{Present-Day English}
\newlanguage{PGmc}{Proto-Germanic}
\newif\if@PhlNoEmph
\newrobustcmd*{\Phl}{\@ifstar%
{%
%%% \directlua{luatexbase.add_to_callback("post_linebreak_filter",upright_punctuation,"upright_punctuation")}%
\@PhlNoEmphtrue\@@@Phl%
%%% \directlua{luatexbase.remove_from_callback("post_linebreak_filter",upright_punctuation,"upright_punctuation")}%
}%
{%
%%% \directlua{luatexbase.add_to_callback("post_linebreak_filter",upright_punctuation,"upright_punctuation")}%
\@PhlNoEmphfalse\@@@Phl%
%%% \directlua{luatexbase.remove_from_callback("post_linebreak_filter",upright_punctuation,"upright_punctuation")}%
}%
}
\newcommand*{\@@@Phl}{%
% Check for optional argument
\@ifnextchar[%
{% Call another macro to see, whether we have a second optional argument
\@@@@Phl%
}%
{% Call the normal command which works with at most one optional argument
\@Phl%
}%
}
\def\@@@@Phl[#1]{%
% There is at least one optional argument. Check for second one.
\@ifnextchar[%
{% We have two optional arguments. Therefore #1 could be 'r'. Check
\Ifstr{#1}{r}{\@Phlreverse}{\@Phl}%
}%
{% There is only one optional argument
\@Phl[#1]%
}%
}
\newcommand*{\@Phl}[2][]{%
\@ifnextchar\bgroup{\@@Phl[#1]{#2}}{\@@Phl[#1]{#2}{}}}
\newcommand*{\@@Phl}[3][]{%
\def\indexlanguage{Pahlavi}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}%
\if@PhlNoEmph%
\ifstrempty{#2}
{\ifstrempty{#3}{}{\begin{nohyphens}\nosmallcaps\@morewordspace #3\end{nohyphens}}}%
{%
\begin{nohyphens}\nosmallcaps #2\end{nohyphens}%
\ifstrempty{#3}{}{\ \begin{nohyphens}\nosmallcaps\@morewordspace #3\end{nohyphens}}%
}%
\else%
\ifstrempty{#2}
{% We assume, that #2 and #3 are not both empty
\textlangle{}\begin{nohyphens}\nosmallcaps\@morewordspace #3\end{nohyphens}\textrangle{}%
}%
{%
\begin{nohyphens}\nosmallcaps\textit{#2}\end{nohyphens}%
\ifstrempty{#3}
{}%
{\ \textlangle{}\begin{nohyphens}\nosmallcaps\@morewordspace #3\end{nohyphens}\textrangle{}}%
}%
\fi%
% We assume, that #2 and #3 are not both empty
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage%
\xspace%
}
\newcommand*{\@Phlreverse}[3][]{%
\def\indexlanguage{Pahlavi}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}%
\ifstrempty{#3}
{\begin{nohyphens}\nosmallcaps\textit{(#2)}\end{nohyphens}}%
{%
\textlangle{}#3\textrangle{}%
\ifstrempty{#2}{}{\ \begin{nohyphens}\nosmallcaps\textit{(#2)}\end{nohyphens}}%
}%
% We assume, that #2 and #3 are not both empty
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage%
\xspace%
}
\let\Phlv\Phl
\newcommand*{\Phltlt}[2][]{%
\def\indexlanguage{Pahlavi}%
\renewcommand*{\idxentryfont}[1]{##1}%
\ifstrempty{#2}{}{\begin{nohyphens}\nosmallcaps\@morewordspace \textup{#2}\end{nohyphens}}%
\ifstrempty{#1}{}{\unskip\ \enquote{#1}}%
\resetlanguage}
\let\Phlvtlt\Phltlt
\newlanguage{PIE}{Proto-Indo-European}
\let\IE\PIE%
\newlanguage{Pli}{PāỊi}
\newlanguage{Pra}{Prakrit}
\newlanguage{PrIIr}{Proto-Indo-Iranian}
\let\IIr\PrIIr%
\newlanguage{PrIr}{Proto-Iranian}
\newlanguage{Pz}{Pāzand}
\newlanguage{Shughni}{Šuγnī}
\newlanguage{Skt}{Sanskrit}
\let\Sa\Skt
\newcommand*{\Sogd}[3][]{%
\def\indexlanguage{Sogdian}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}%
\ifstrempty{#2}
{\ifstrempty{#3}{}{/#3/}}%
{%
\begin{nohyphens}\nosmallcaps\emph{\@morewordspace #2}\end{nohyphens}%
\ifstrempty{#3}{}{\ /#3/}%
}%
\ifstrempty{#1}{}{\ \enquote{#1}}%
\resetlanguage}
\newlanguage{TochA}{Tocharian A}
\newlanguage{TochB}{Tocharian B}
\newlanguage{Ved}{Vedic}
\let\VedSa\Ved
\newlanguage{Yidgha}{Yidγa}
\newlanguage{ZD}{Zoroastrian Dari}
\newlanguage{Waxi}{Waxī}
\newlanguage{Gilaki}{Gīlakī}
\newlanguage{Ormuri}{Ōrmuṛī}
\newlanguage{Zazaki}{Zāzākī}
\newlanguage{Parachi}{Parāčī}
\newlanguage{Balochi}{Balōčī}
\newlanguage{Yazghulami}{Yazγulāmī}
\newlanguage{Kurmanji}{Kurmanǰī}
%%%
\newenvironment{AvBlock}{%
\def\indexlanguage{Avestan}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}\itshape\hyphenpenalty=\@M\exhyphenpenalty=\@M\relax}%
{\resetlanguage}
\let\AvstBlock\AvBlock
\let\endAvstBlock\endAvBlock
\newenvironment{BactrBlock}{%
\def\indexlanguage{Bactrian}%
\renewcommand*{\idxentryfont}[1]{##1}\hyphenpenalty=\@M\exhyphenpenalty=\@M\relax}%
{\resetlanguage}
\let\FaBlock\NPBlock
\let\endFaBlock\endNPBlock
\let\GujrBlock\GujBlock
\let\endGujrBlock\endGujBlock
\newenvironment{PhlBlock}{\def\indexlanguage{Pahlavi}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}\itshape\hyphenpenalty=\@M\exhyphenpenalty=\@M\relax}%
{\resetlanguage}
\newenvironment{PhltltBlock}{\def\indexlanguage{Pahlavi}%
\renewcommand*{\idxentryfont}[1]{##1}\hyphenpenalty=\@M\exhyphenpenalty=\@M\relax}%
{\resetlanguage}
\let\PhlvBlock\PhlBlock
\let\endPhlvBlock\endPhlBlock
\let\PhlvtltBlock\PhltltBlock
\let\endPhlvtltBlock\endPhltltBlock
\let\IEBlock\PIEBlock
\let\endIEBlock\endPIEBlock
\let\IIrBlock\PrIIrBlock
\let\endIIrBlock\endPrIIrBlock
\let\SaBlock\SkrBlock
\let\endSaBlock\endSkrBlock
\newenvironment{SogdBlock}{%
\def\indexlanguage{Sogdian}%
\renewcommand*{\idxentryfont}[1]{\textit{##1}}\itshape\hyphenpenalty=\@M\exhyphenpenalty=\@M\relax}%
{\resetlanguage}
\let\VedSaBlock\VedBlock
\let\endVedSaBlock\endVedBlock
%%%
\newcommand{\Fr}[1]{\foreignlanguage{french}{#1}}
\newcommand{\Ger}[1]{\foreignlanguage{ngerman}{#1}}
\newcommand{\En}[1]{\foreignlanguage{british}{#1}}
\newenvironment{FrBlock}{\begin{otherlanguage*}{french}}{\end{otherlanguage*}}
\newenvironment{GerBlock}{\begin{otherlanguage*}{ngerman}}{\end{otherlanguage*}}
%%% We define a ``meta macro'' to define all book macros in the same way
\def\newbook{\@dblarg\@newbook}
\def\@newbook[#1]#2{%
\expandafter\newcommand\csname #2\endcsname[1]{\gls{#1}\nobreak\hspace{\fontdimen2\font}##1}%
}
% We need a second abbreviation list for the apparatus criticus
\newglossary{appcrit}{appcritin}{appcritout}{Sigla and Abbreviations Used in the Critical Apparatus}
\newglossarystyle{muyaac}{%
\setglossarystyle{brill}%
\renewenvironment{theglossary}%
{%
% We use \LTpre to correct the spacing; should be done automatically
\setlength{\LTpre}{\dimexpr 0.5\normalbaselineskip\relax}%
\setlength{\LTpost}{0pt}%
\setlength{\widestabbreviationac}{0pt}%
\begin{longtabu} to%
\textwidth{@{}p{\widestabbreviationac}%
@{\hspace*{\normalparindent}}>{\raggedright}X@{}}%
}%
{\end{longtabu}}%
\renewcommand{\glossentry}[2]{%
\@checkforwidestabbreviationac{##1}%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}\strut &
\glossentrydesc{##1}\glspostdescription\space ##2\strut%
\tabularnewline%
}%
}%
\newcommand*{\@listabbreviationsac}{}
\newcommand*{\@listabbreviationsacadd}{}
\newcommand*{\@listabbreviationsacremove}{}
\newcommand*{\@additemtoacaddlist}[1]{\listgadd{\@listabbreviationsacadd}{#1}}
\newcommand*{\@additemtoacremovelist}[1]{\listgadd{\@listabbreviationsacremove}{#1}}
\newcommand*{\@removeitemfromaclist}[1]{\listgremove{\@listabbreviationsac}{#1}}
\define@key{ac}{add}{\forcsvlist{\@additemtoacaddlist}{#1}}
\define@key{ac}{remove}{\forcsvlist{\@additemtoacremovelist}{#1}}
\newcommand*{\actitle}{Sigla and Abbreviations Used in the Critical Apparatus}
\define@key{ac}{title}{\renewcommand*{\actitle}{#1}}
\def\newabbreviationac{\@ifstar\@newabbreviationac\@@newabbreviationac}
\newcommand*{\@newabbreviationac}[4][]{%
\newabbreviation[type=appcrit,#1]{#2}{#3}{#4}%
\listgadd{\@listabbreviationsac}{#2}}
\newcommand*{\@@newabbreviationac}[4][]{%
\newabbreviation[type=appcrit,#1]{#2}{\textup{#3}}{#4}}
\def\printabbreviationsac{\@ifstar\@printabbreviationsac\@@printabbreviationsac}
\newcommand{\@printabbreviationsac}[1][]{%
\setkeys{ac}{#1}%
% If the list of items to be removed is empty, do nothing.
% Otherwise go through the list and remove all list items from the overall
% list.
\ifdefempty{\@listabbreviationsacremove}%
{% Now check, whether add option was given as well
\ifdefempty{\@listabbreviationsacadd}%
{% No additions, no removals. Add all entries to the abbreviation list
\forlistloop{\glsadd}{\@listabbreviationsac}%
}%
{%
% Clear list
%%% \renewcommand*{\@listabbreviationsac}{}%
% Add only specific entries
\forlistloop{\glsadd}{\@listabbreviationsacadd}%
}%
}%
{%
\ifdefempty{\@listabbreviationsacadd}%
{}%
{%
\ClassWarning{brill}{Key-value options `add` and `remove` can not be used together!\MessageBreak
`add` option is ignored!}%
}%
\forlistloop{\@removeitemfromaclist}{\@listabbreviationsacremove}%
\forlistloop{\glsaddNoNumber}{\@listabbreviationsac}%
}%
\begingroup%
\renewcommand*{\glsgroupskip}{}%
\renewcommand{\glossarypreamble}{\small}%
\ifbrill@PhD
\renewcommand*{\arraystretch}{1.4}%
\fi%
\renewcommand{\glossarysection}[2][]{}%
\printabbreviations[type=appcrit,style=muyaac]%
\endgroup%
}
\newcommand{\@@printabbreviationsac}[1][]{%
\setkeys{ac}{#1}%
% Same as above
\ifdefempty{\@listabbreviationsacremove}%
{% Now check, whether add option was given as well
\ifdefempty{\@listabbreviationsacadd}%
{% No additions, no removals. Add all entries to the abbreviation list
\forlistloop{\glsaddNoNumber}{\@listabbreviationsac}%
}%
{%
% Clear list
%%% \renewcommand*{\@listabbreviationsac}{}%
% Add only specific entries
\forlistloop{\glsaddNoNumber}{\@listabbreviationsacadd}%
}%
}%
{%
\ifdefempty{\@listabbreviationsacadd}%
{}%
{%
\ClassWarning{brill}{Key-value options `add` and `remove` can not be used together!\MessageBreak
`add` option is ignored!}%
}%
\forlistloop{\@removeitemfromaclist}{\@listabbreviationsacremove}%
\forlistloop{\glsaddNoNumber}{\@listabbreviationsac}%
}%
\begingroup%
\renewcommand*{\glsgroupskip}{}%
\ifbrill@PhD
\renewcommand*{\arraystretch}{1.4}%
\fi%
\printabbreviations[type=appcrit,title={\actitle},style=muyaac]%
\endgroup%
}
%
% We define macros to be used (only) within the stnazas/apparatus criticus
% We need a special macro for hanging text based on \cs{newline} calls in the export
\newcounter{appcrnewline}
\newcounter{muyalinenumber}
\newcounter{linenumberforstanza}
\newtoggle{@setlinenumberforthisline}
\newcommand{\appcrnewline}{%
\stepcounter{appcrnewline}%
% Check whether we have to end a commentary passage
\if@iscommentarytext
% Last word of current line is a commentary
% Store that information to be able to look back
\global\@iscontinuedcommentarytexttrue%
% Will the next line start with a commentary?
% We check, whether a macro has been defined in the previous run
\ifcsdef{commcont-\theappcrnewline}%
{}%
{% Next line starts with something else -> end passage
\unskip\textrangle{}% closing bracket >
\global\@iscommentarytextfalse%
}%
\else
\global\@iscontinuedcommentarytextfalse%
\fi%
\@setlinenumberstatus%
\par\noindent\hangindent\parindent\hangafter=1\relax%
\@getlinenumberstatus%
}
\newcommand{\lastnewline}{%
\stepcounter{appcrnewline}%
\if@iscommentarytext
\global\@iscontinuedcommentarytexttrue%
\ifcsdef{commcont-\theappcrnewline}%
{}%
{% Next line starts with something else -> end passage
\unskip\textrangle{}% closing bracket >
\global\@iscommentarytextfalse%
}%
\else
\global\@iscontinuedcommentarytextfalse%
\fi%
\@setlinenumberstatus%
\par%
}
% We need to know whether we have the first reading
\newif\if@firstrdg
% The main macro steps the counter for the \enquote{footnotes} and starts a list
\newtoggle{@inapp}
\newrobustcmd{\app}[1]{%
\refstepcounter{appcrfootnote}%
\unskip\kern0.05em\realsuperscript{\theappcrfootnote}%
\@firstrdgtrue
\gappto{\@appcr}{\toggletrue{@inapp}}%
\gappto{\@appcr}{\item }#1%
\gappto{\@appcr}{\togglefalse{@inapp}}%
}
% We define a macro for ritual directions
% The normal macro starts with a newline and some spacing while the starred
% variant starts rightaway.
\newif\if@startwithnewline
\@startwithnewlinetrue
\newif\if@inrd
\newcommand{\rd}{\@ifstar%
{\@startwithnewlinefalse\@rd}{\@startwithnewlinetrue\@rd}}
\newcommand{\@rd}[1]{%TODO: Spacing
\@inrdtrue%
\global\settoggle{@setlinenumberforthisline}{false}%
\if@editedtextonly\else
%TODO: Why do we need this?
%\if@startwithnewline\par\vspace{.5\baselineskip}\fi%
\if@startwithnewline\par\addvspace{1\baselineskip}\fi%
\begingroup%
%\let\newline\appcrnewline%
\tolerance=1%
\emergencystretch=\maxdimen%
\hyphenpenalty=\@M%
%\exhyphenpenalty=\@M%
\hbadness=\@M%
\noindent%
\hangindent\parindent\hangafter=1\relax%
\@getlinenumberstatus%
#1\par\nobreak\addvspace{1\baselineskip}\noindent%
\endgroup%
\fi%
\@inrdfalse%
\hangindent\parindent\hangafter=1\relax%
\ignorespaces%
% \global\settoggle{@setlinenumberforthisline}{true}%
}
% We need to know, whether it's the first witness (sub)class call
\newif\if@firstwitclass
\newif\if@firstwitsubclass
\newif\if@subreading
% We define a macro for the readings. As this macro can have two optional
% arguments, we read the first and remember whether it is empty or not
\newcommand{\rdg}[1][]{%
\ifstrempty{#1}{\@subreadingfalse}{\@subreadingtrue}%
% Call main macro
\@rdg
}
% #1: Abbreviation for subreading
% #2: Witnesses
% #3: Reading
\newcommand{\@rdg}[3][]{%
% If it is not the first reading, add a \cs{par} to the output
\if@firstrdg\@firstrdgfalse\else\gappto{\@appcr}{\par}\fi%
% If it is a subreading (non-empty first opt. argument) then start a
% nested list (either with label or without depending on second
% optional argument)
\if@subreading
\ifstrempty{#1}%
{\gappto{\@appcr}{\begin{appcrenum}\item[]\strut}}%
{\gappto{\@appcr}{\begin{appcrenum}\item[]\makebox[1.25\normalparindent][l]{#1\strut}}}%
\fi%
\@firstwitclasstrue%
\@firstwitsubclasstrue%
% Add reading to apparatus variable
\gappto{\@appcr}{\strut\textit{#3}\ \begingroup\frenchspacing}%
% Evaluate witnesses
#2%
\gappto{\@appcr}{\endgroup}%
% Close nested list if necessary
\if@subreading
\gappto{\@appcr}{\end{appcrenum}}%
\fi%
}
% Write witness to apparatus
\newcommand{\wit}[1]{\gappto{\@appcr}{\strut #1 }}
\newcommand{\witclass}[1]{%
% If this is not the first witness class call, insert punctuation
\if@firstwitclass%
\@firstwitclassfalse%
\else%
\@firstwitsubclasstrue\gappto{\@appcr}{\unskip;\ }%
\fi%
% Evaluate witness class entries
#1%
}
\newcommand{\witsubclass}[1]{%
% If this is not the first witness class call, insert punctuation
\if@firstwitsubclass%
\@firstwitsubclassfalse%
\else%
\gappto{\@appcr}{\unskip,\ }%
\fi%
% Evaluate witness subclass entries
#1%
}
% We manually count the words/footnotes in our editorial texts based
% on \cs{app} calls
\newcounter{stanza}
\newcounter{appcrfootnote}[stanza]
\renewcommand{\theHappcrfootnote}{\thestanza.\arabic{appcrfootnote}}
\newcounter{nextappcrfootnote}
% We define a list of two levels
\newlist{appcrenum}{enumerate}{2}
\newcommand*{\appcrenumlabelfont}{%
\addfontfeatures{Numbers={Tabular,Lining}}\scriptsize}
\setlist[appcrenum]{font=\appcrenumlabelfont,align=left}
\setlist[appcrenum,1]{%
label=\arabic*,%
leftmargin=*,%
widest=88,%
itemsep=.25\baselineskip plus .1\baselineskip minus .1\baselineskip,%
parsep=0pt%
}
\setlist[appcrenum,2]{%
label=\relax,%
left=.5\normalparindent,%
nosep%
}
\let\@MUYAminisec\minisec
\long\def\minisec{\@minisec}
\newcommand{\@minisec}[2][]{\@MUYAminisec{#2}}
% Each stanza starts a new mini section and resets the \enquote{footnote} counter
\newenvironment{stanza}[1]{%
\stepcounter{stanza}%
\Ifstr{\@stanzaheading}{none}%
{}%
{%
\iftoggle{@stanzabooktoindex}%
{\@stanzaheading[#1]{\Av{\passage{#1}}}}%
{\@stanzaheading{#1}}%
}%
% The apparatus is stored in a variable
\gdef\@appcr{}%
\hyphenpenalty=\@M%
\exhyphenpenalty=\@M%
\if@inblocktranslation%
\else%
\let\newline\appcrnewline%
\let\\\appcrnewline%
\par\hangindent\parindent\hangafter=1\noindent\ignorespaces%
% Check, whether to number _first_ line
\@getlinenumberstatus%
\fi%
}{%
\global\settoggle{@setlinenumberforthisline}{false}%
\par%
% If the apparatus is not empty, output it in two columns
\ifdefempty{\@appcr}{}{%
\begin{multicols}{2}%
\begin{appcrenum}\scriptsize\@appcr\end{appcrenum}
\end{multicols}%
}%
}
\newif\if@firstimportstanzas
\@firstimportstanzastrue
\def\Importstanzas{\@ifstar{\@Importstanzas[-transcript]}{\@Importstanzas}}
\newcommand*{\@Importstanzas}[2][]{%
% This macro should only be called in the preamble of a document
%\@onlypreamble
% If this is the first call of the macro, then create the output file.
% An existing file from a previous run is currently overwritten.
% TODO: Compare file dates to decide, whether to reread a file
\if@firstimportstanzas
\directlua{create_stanzafile()}%
\@firstimportstanzasfalse%
\fi%
% Delay call until \begin{document} (if file exists)
\IfFileExists{#2}%
{\AtBeginDocument{\directlua{read_stanzas_from_file("\luaescapestring{\detokenize{#2}}","\luaescapestring{\detokenize{#1}}")}}}%
{\ClassError{brill}{File `#2` could not be found!}{}}%
}
% After all other \AtBeginDocument code we read the stanzas.tex file (if it exists)
\AfterEndPreamble{%
\InputIfFileExists{./stanzas.tex}%
{\ClassInfoNoLine{brill}{Stanza macros successfully loaded from `stanzas.tex`!}}%
{\ClassWarningNoLine{brill}{There is no file `stanzas.tex`. No stanzas read!}}%
}
% We define key-value options for \Getstanza
\newcommand{\@defaultstanzaheading}{\minisec}
\newcommand{\SetDefaultStanzaheading}[1]{%
\renewcommand{\@defaultstanzaheading}{#1}}
\newcommand{\@stanzaheading}{\@defaultstanzaheading}
\newtoggle{@stanzabooktoindex}
\settoggle{@stanzabooktoindex}{true}
\newcommand*{\SetDefaultStanzabooktoindex}[1]{%
\settoggle{@stanzabooktoindex}{#1}}
\newtoggle{@stanzalinenumbers}
\define@key{stanza}{heading}{\renewcommand{\@stanzaheading}{#1}}
\define@key{stanza}{booktoindex}[true]{\settoggle{@stanzabooktoindex}{#1}}
\define@key{stanza}{linenumbers}[true]{\settoggle{@stanzalinenumbers}{#1}}
% Define macro \Getstanza[heading]{reference}
\newcommand{\Getstanza}[2][]{%
\setkeys{stanza}{heading=\@defaultstanzaheading,#1}%
\ifcsdef{stanza-#2}%
{%
\begingroup%
\addfontfeatures{Ligatures=NoCommon}%
\csuse{stanza-#2}%
\endgroup%
}%
{\ClassError{brill}%
{Stanza `#2` could not be read}{There is no macro for stanza `#2`}}%
}
\newif\if@editedtextonly
\newcommand{\GetstanzaTextonly}{\@ifstar%
{\@editedtextonlytrue\@GetstanzaTextonly}%
{\@editedtextonlyfalse\@GetstanzaTextonly}%
}
\newcommand{\@GetstanzaTextonly}[2][]{%
\setkeys{stanza}{heading=\@defaultstanzaheading,#1}%
\iftoggle{@stanzalinenumbers}{\setcounter{linenumberforstanza}{1}}{}%
\ifcsdef{stanza-#2}%
{%
\begingroup%
\let\app\@gobble%
\addfontfeatures{Ligatures=NoCommon}%
\csuse{stanza-#2}%
\endgroup%
}%
{\ClassError{brill}%
{Stanza `#2` could not be read}{There is no macro for stanza `#2`}}%
}
% Define a macro to convert a book string like Y28.1 into a control sequence like \Y{28.1}
\newcommand{\bookstringtocs}[1]{%
\directlua{strtocs("\luaescapestring{\detokenize{#1}}")}}
\newif\if@inblocktranslation
% Define a macro to output the stanza text and its translation as
% blocktranslation
% #1 is the reference of a stanza, e.g. Y28.1
% The starred version uses the -transcript variant of the stanza imported with
% \Importstanzas*{file} and the common translation
\newcommand{\GetstanzaWithtranslation}{\@ifstar%
{\@GetstanzaWithtranslation[-transcript]}{\@GetstanzaWithtranslation}}
\newcommand{\@GetstanzaWithtranslation}[2][]{%
\if@intextandtranslation
\paralleltypesetting%
{\GetstanzaTextonly{#2#1}}%
{\minisec{\bookstringtocs{#2}}\Gettranslation{#2}}%
\else
% Call the blocktranslation macro with appropriate arguments
\blocktranslation[\bookstringtocs{#2}]%
{}%
{\GetstanzaTextonly*[heading=none]{#2#1}}{\Gettranslation*{#2}}%
\fi%
}
\newcommand{\GetstanzasWithtranslations}{\@ifstar%
{\@GetstanzasWithtranslations[-transcript]}{\@GetstanzasWithtranslations}%
}
\newcommand{\@GetstanzasWithtranslations}[3][]{%
\if@intextandtranslation
\paralleltypesetting%
{%
\global\settoggle{@setlinenumberforthisline}{true}%
\GetstanzaTextonly[linenumbers]{#2#1}%
}%
{%
\global\settoggle{@setlinenumberforthisline}{true}%
\reversemarginpar%
\GetstanzaTextonly[linenumbers]{#3}% No opt. argument
}%
\paralleltypesetting%
{%
\global\settoggle{@setlinenumberforthisline}{true}%
\Gettranslation[linenumbers]{#2}%
}%
{%
\global\settoggle{@setlinenumberforthisline}{true}%
\reversemarginpar%
\Gettranslation[linenumbers]{#3}%
}%
\else
\ClassError{brill}%
{Macro `\GetstanzasWithtranslations` outside `textandtranslation`
environment}%
{}%
\fi%
}
\newif\if@substforeign
\newcounter{foreign@in@editedtext}
\newcommand{\GetstanzaWithtranscription}[1]{%
\global\@substforeigntrue
\setcounter{foreign@in@editedtext}{0}%
\Getstanza{#1}%
\global\@substforeignfalse
}
\newcommand{\GetstanzaTextonlyWithtranscription}[1]{%
\global\@substforeigntrue
\setcounter{foreign@in@editedtext}{0}%
\GetstanzaTextonly{#1}%
\global\@substforeignfalse
}
% Translation are stored in a common file translations.tex
% Each translation is defined with \Newtranslation[ritual direction]{label}{translation}
% translations and optional ritual direction are stored in a separate macro
\newcommand{\Newtranslation}[3][]{%
\csgdef{translation-#2}{#3}%
\ifstrempty{#1}{}{\csgdef{rd-#2}{#1}}%
}
% For conveniance
\let\newtranslation\Newtranslation
%\newtoggle{@translationlinenumbers}
\define@key{translation}{linenumbers}[true]{%
\settoggle{@stanzalinenumbers}{#1}}
\newcommand*{\@rdposition}{}
\define@key{translation}{rdposition}{\renewcommand*{\@rdposition}{#1}}
\newcommand{\Gettranslation}{\@ifstar\@Gettranslation\@@Gettranslation}
\newcommand{\@Gettranslation}[1]{\@@Gettranslation[rdposition=none]{#1}}
\newcommand{\@@Gettranslation}[2][]{%
\setkeys{translation}{#1}%
\iftoggle{@stanzalinenumbers}{\setcounter{linenumberforstanza}{1}}{}%
% Outside a blocktranslation we store the information, that we used a
% special \newline for the current line
\if@inblocktranslation
\else
\refstepcounter{specialnewline}%
\xdef\@currvalspecialnewline{\thespecialnewline}%
\fi%
\begingroup%
\let\newline\@specialnewline%
\let\\\@specialnewline%
% No indention outside blocktranslation environment
\if@inblocktranslation
\else
\setlength{\parindent}{0pt}%
\fi%
\IfStrEqCase{\@rdposition}{%
{t}{%
\par\noindent%
\ifcsdef{rd-#2}{\csuse{rd-#2}\par\addvspace{\baselineskip}}{}%
\csuse{translation-#2}%
}%
{m}{}%
{b}{%
\par\noindent%
\csuse{translation-#2}%
\ifcsdef{rd-#2}{\par\addvspace{\baselineskip}\csuse{rd-#2}}{}%
}%
{none}{%
\let\RDTrans\@gobble%
\csuse{translation-#2}%
\par%
}%
}[%
% We have to check, whether the first line is long and needs the
% special layout with hanging lines
\ifcsdef{specialnewline\@currvalspecialnewline}%
{\@@linebreakwithindent\addvspace{\baselineskip}}%
{\par\addvspace{\baselineskip}\noindent}%
\ifcsdef{translation-#2}%
{%
% Number _first_ line (if needed)
\@getlinenumberstatus%
% Output translation
\csuse{translation-#2}%
% Check, whether _last_ line has to be numbered
\@setlinenumberstatus%
% add new line marker (without any line numbering stuff)
\@@linebreakwithindent%
}%
{\ClassWarning{brill}{No translation found for #2}}%
]%
\endgroup%
}
% For convenience
\let\gettranslation\Gettranslation
% We need a special environment for typesetting of text and translation (or any
% other two corresponding texts) on facing pages
% We define a main text frame and two dynamic frames based on the flowfram
% package
% The idea comes from https://tex.stackexchange.com/questions/165019/parallel-paragraphs-across-odd-and-even-pages
%\newflowframe{\textwidth}{\dimexpr\textheight-\baselineskip\relax}%
% {0pt}{0pt}[main]
%\newdynamicframe[odd]{\textwidth}{\dimexpr\textheight-\baselineskip\relax}%
% {0pt}{0pt}[translation]
%\newdynamicframe[even]{\textwidth}{\dimexpr\textheight-\baselineskip\relax}%
% {0pt}{0pt}[text]
%
%% \checkisroom{idl}{text}
%\providecommand{\@gobblethree}[3]{}
%% Define a temporary box and a test macro
%\newsavebox\tmpsbox
%\newif\ifenoughroom
%\newcommand{\checkisroom}[2]{%
% \bgroup
% % get the frame's idn (stored in \ff@id)
% \@dynamicframeid{#1}%
% % temporarily suspend writing to external files
% \let\protected@write\@gobblethree
% % put the frame's contents and the pending text into
% % the temporary sbox
% \begin{lrbox}{\tmpsbox}%
% \begin{minipage}{\textwidth}%
% \csname @dynamicframe@\romannumeral\ff@id\endcsname
% \par
% #2%
% \end{minipage}%
% \end{lrbox}%
% % Does it fit the page?
% \settoheight{\@ff@tmp@y}{\usebox\tmpsbox}%
% \settodepth{\dimen@ii}{\usebox\tmpsbox}%
% \addtolength{\@ff@tmp@y}{\dimen@ii}%
% \ifdim\@ff@tmp@y>\textheight
% \global\enoughroomfalse
% \else
% \global\enoughroomtrue
% \fi%
% \egroup
%}
%
%% \getcontentsheight{length}{text}
%\newcommand{\getcontentsheight}[2]{%
% \bgroup
% \let\protected@write\@gobblethree
% \begin{lrbox}{\tmpsbox}%
% \begin{minipage}{\textwidth}%
% #2%
% \end{minipage}%
% \end{lrbox}%
% \settoheight{\@ff@tmp@y}{\usebox\tmpsbox}%
% \settodepth{\dimen@ii}{\usebox\tmpsbox}%
% \addtolength{\@ff@tmp@y}{\dimen@ii}%
% \global#1=\@ff@tmp@y\relax
% \egroup
%}
%
%%\newcounter{heading}
%\newlength\blockheight
%\newif\if@firstblock
%\newcommand{\blocksep}{%
% \if@firstblock
% \par%
% \global\@firstblockfalse%
% \else
% \par\vspace{\baselineskip}%
% \fi%
%}
%
%% \annote{annotation}{text}
%
\newcommand{\paralleltypesetting}[2]{#1\par#2}%
%\newcommand{\paralleltypesetting}[2]{%
% % get height of the first argument
% \getcontentsheight{\blockheight}{#1}%
% % save it as the larger block (for now)
% \def\largerblock{#1}%
% % get height of the second argument
% \getcontentsheight{\@ff@tmp@y}{#2}%
% % check, whether it is larger than the first block
% \ifdim\blockheight<\@ff@tmp@y
% \blockheight=\@ff@tmp@y\relax
% \def\largerblock{#2}%
% \fi%
% \edef\startblock{%
% %\noexpand\global\noexpand\@firstblocktrue
% \noexpand\blocksep
% \noexpand\begin{minipage}[t][\the\blockheight]{\the\textwidth}%
% \noexpand\setlength{\noexpand\parindent}{\the\parindent}%
% %\noexpand\par\noexpand\noindent\noexpand\ignorespaces
% }%
% \checkisroom{translation}{\largerblock}%
% \ifenoughroom
% \@dynamicframeid{text}%
% \expandafter\appenddynamiccontents\expandafter\ff@id
% %\expandafter\global\expandafter\@firstblocktrue
% \expandafter{%
% \expandafter\blocksep%
% \startblock#1%
% \end{minipage}%
% }%
% \@dynamicframeid{translation}%
% \expandafter\appenddynamiccontents\expandafter\ff@id
% %\expandafter\global\expandafter\@firstblocktrue
% \expandafter{%
% \expandafter\blocksep%
% \startblock#2%
% \end{minipage}%
% }%
% \else
% % output 2 pages
% \cleartoeven
% \@dynamicframeid{text}%
% \expandafter\setdynamiccontents\expandafter\ff@id
% \expandafter{\startblock#1\end{minipage}}%
% \@dynamicframeid{translation}%
% \expandafter\setdynamiccontents\expandafter\ff@id
% \expandafter{\startblock#2\end{minipage}}%
% \fi%
% \par\vspace{\baselineskip}%
%}
\newcommand{\cleartoeven}{%
\Ifthispageodd% KOMA macro
{\newpage}%
{\mbox{}\newpage\mbox{}\newpage}%
}
\def\muyalinenumber{}
%%% This macro is applied at the end of a line (when \\ or \newline is called)
%%% to store, whether or not this line gets a line number.
%%% It is the counterpart of macro \@getlinenumberstatus
\newcommand{\@setlinenumberstatus}{%
\ifboolexpr{ bool {@innumberlines} and togl {@stanzalinenumbers} }%
{%
\xdef\muyalinenumber{\themuyalinenumber}%
% If the line should get a line number, write a corresponding macro
% into th aux file.
\iftoggle{@setlinenumberforthisline}%
{%
\immediate\write\@auxout{\csxdef{linenumber-\muyalinenumber}{}}%
}%
{}%
% set variables for next line
\refstepcounter{muyalinenumber}%
% If we are still within ritual direction or commentary text, do not
% number the next line.
\ifboolexpr{ bool {@inrd}
or bool {@iscommentarytext}
or bool {@inRDTrans}}
{}%{\global\settoggle{@setlinenumberforthisline}{false}}%
{\global\settoggle{@setlinenumberforthisline}{true}}%
}{}%
}
%%% This macro is called at the beginning of a line, i.e. right after a \\ or
%%% \newline has been called.
\newcommand{\@getlinenumberstatus}{%
\ifboolexpr{ bool {@innumberlines} and togl {@stanzalinenumbers} }%
{%
\xdef\muyalinenumber{\themuyalinenumber}%
% If a macro is defined for the current line, i.e. through the aux
% file from the previous run by \@setlinenumberstatus, then make a
% marginal note.
\ifcsdef{linenumber-\muyalinenumber}%
{%
\marginnote{\thelinenumberforstanza}[.17\baselineskip]%
\refstepcounter{linenumberforstanza}%
}%
{}%
}{}%
}
\newif\if@intextandtranslation
\newif\if@innumberlines
\newenvironment{textandtranslation}{\par}{\par}
%\newenvironment{textandtranslation}%
% {%
% \global\@intextandtranslationtrue%
% \global\@innumberlinestrue%
% \cleartoeven
% \setdynamiccontents*{text}{}%
% \setdynamiccontents*{translation}{}%
% %\global\@firstblocktrue%
% }%
% {%
% \cleartoeven
% \setdynamiccontents*{text}{}%
% \setdynamiccontents*{translation}{}%
% \global\@innumberlinesfalse%
% \global\@intextandtranslationfalse%
% %\settoggle{@stanzalinenumbers}{false}%
% }%
%
%\AtEndDocument{\cleartoeven}
%%%
\newif\if@iscommentarytext
\newif\if@iscontinuedcommentarytext
\newrobustcmd*{\editedtext}[1]{%
% We first check, whether we have to end a commentary passage
\if@iscommentarytext
\unskip\textrangle{} %
\global\@iscommentarytextfalse
\fi%
\global\@iscontinuedcommentarytextfalse%
% We test for specific texts and write them as they are.
% All others get additional superscript numbers after each word.
\begingroup%
%\editedtextfont
\ifboolexpr{test { \Ifstrstart{#1}{(date, dedication of} }%
or test { \Ifstr{#1}{(abbreviated text)} }}%
{#1}%
{%
\ifx\app\@gobble
{\itshape #1}%
\else
% we get the current value of appcrfootnote and add 1 -> this would
% be the next footnote number
\setcounter{nextappcrfootnote}{\value{appcrfootnote}}%
\stepcounter{nextappcrfootnote}%
{%
\itshape%
\StrSubstitute{#1}{ }%
{\kern0.05em%
\realsuperscript{\upshape\thenextappcrfootnote} }%
}%
\fi%
}%
\endgroup%
}
\let\editedtranslationtext\editedtext
\newcommand{\editedcommentarytext}[1]{% Adaption of \editedtext
% We test for specific texts and write them as they are.
% All others get additional superscript numbers after each word.
% Check, whether we are at the beginning of a line (following a \newline)
% If so, we deactivate the line numbering.
\ifvmode
\global\settoggle{@setlinenumberforthisline}{false}%
\fi%
\Ifstrstart{#1}{(date, dedication of)}%
{#1}%
{% Check, whether this is the first commentary text
\if@iscontinuedcommentarytext
% This is the first word of a new line continuing a commentary
% from the previous line.
% Store that info to be able to look ahead in the next run
\immediate\write\@auxout%
{\noexpand\csgdef{commcont-\theappcrnewline}{}}%
\global\@iscontinuedcommentarytextfalse
\else
\if@iscommentarytext
% part of a one-line commentary text
\else
% start of a new commentary text passage
\global\@iscommentarytexttrue
\textlangle{}% opening bracket <; closing one after last \editedcommentarytext
\fi%
\fi%
\ifx\app\@gobble
{\itshape #1}%
\else
% we get the current value of appcrfootnote and add 1 -> this would
% be the next footnote number
\setcounter{nextappcrfootnote}{\value{appcrfootnote}}%
\stepcounter{nextappcrfootnote}%
{%
\itshape%
\StrSubstitute{#1}{ }%
{\realsuperscript{\upshape\thenextappcrfootnote} }%
}%
\fi%
}%
}
\newcommand{\trcommentarytext}[1]{%
\global\settoggle{@setlinenumberforthisline}{false}%
\textlangle{}#1\textrangle{}%
}
% We need a macro for text portions within the Avestan (italic) text.
% In the XML these are <foreign> elements
\newrobustcmd*{\foreign}[2][]{%
\if@substforeign
\stepcounter{foreign@in@editedtext}%
%TODO: Check and fix this!%
%\Gettranscription{Y72.10-trans-\theforeign@in@editedtext}%
\else
\IfStrEqCase{#1}{%
{pal-Avst}{\iftoggle{@inapp}{\textit{#2}}{\textit{#2}}}%
{pal-Phlv}{\iftoggle{@inapp}{\textup{#2}}{\textit{#2}}}%
{fa}{\iftoggle{@inapp}{\textup{#2}}{\textit{#2}}}%
{ae-fa}{\iftoggle{@inapp}{\textup{#2}}{\textit{#2}}}%
}[%
\ClassWarning{brill}{Found unknown foreign language `#1`\MessageBreak%
Result may not be as expected!}%
\iftoggle{@inapp}{\textup{#2}}{\textit{#2}}]%
\fi%
}
\newcommand{\Newtranscription}[3][]{%
\csgdef{transcription-#2}{#3}%
\ifstrempty{#1}{}{\csgdef{rd-#2}{#1}}%
}
% For convenience
\let\newtranscription\Newtranscription
\newcommand{\Gettranscription}[2][]{%
%\ifcsdef{rd-#2}{\csuse{rd-#2}\par\vspace{\baselineskip}}{}%
\ifcsdef{#2}%
{\csuse{#2}}%
{\ClassError{brill}{Transcription `#2` not found}{}}%
}
% For convenience
\let\gettranscription\Gettranscription
%%%
\newbook{A}
\newbook{AAM}
%\newcommand*{\A}[1]{\gls{A}\nobreakspace{}#1}% Afrinagan
%\newcommand*{\AAM}[1]{\gls{AAM}\nobreakspace{}#1}%
\newbook{Abu}
\newbook{AD}
\newbook{AG}
\newbook{AJ}
\newbook{AW}
\newbook{AM}
\newbook{Ank}
\newbook{Aog}
\newbook{ApSS}
\newbook{As}
\newbook{AV}
\newbook{AVS}
\newbook{AWN}
%\newbook{AvAlph}
\newbook{Bd}
\newbook{BUK}
\newbook{CAP}
\newbook{DB}
\newbook{DNb}
\newbook{DD}
\newbook{Dhu}
\newbook{Dhy}
\newbook{Dk}
\newbook{DkM}
\newbook{DNa}
\newbook{DPd}
\newbook{DPe}
\newbook{DrYt}
\newbook{DuP}
\newbook{FiO}
\newbook{FiP}
\newbook{FrD}
\newbook{FrW}
%\newbook[G]{Gah}
\let\G\@undefined
\newbook{G}
\let\H\@undefined
\newbook{H}
\let\Herbedestan\H
\newbook{Hb}
\let\HB\Hb
\newbook{HN}
\newbook{KB}
\newbook{KN}
\newbook{KPT}
\newbook{Mbh}
\newbook{MHD}
\newbook{MKS}
\newbook{MS}
\newbook{MX}
\newbook{N}
\newbook{NiAb}
\newbook{NiAs}
\newbook{NiSY}
\newbook{NkB}
\newbook{NS}
\newbook{Ny}
\newbook{PaIr}
\newbook{PaPas}
\newbook{Par}
\newbook{PaXw}
\newbook{PazT}
\newbook{PNy}
\newbook{PRAF}
\newbook{PRDD}
\newbook{PS}
\newbook{PT}
\newbook{Pur}
\newbook{PV}
\newbook{PVr}
\newbook{PY}
\newbook{PYt}
\newbook{PWD}
\newbook{RV}
\let\origS\S
\let\S\@undefined
\newbook{S}
\let\Siroza\S
\newbook{SA}
\newbook{SBM}
\newbook{SCE}
\newbook{SGW}
\newbook{ShahrEr}
\newbook{SnS}
\newbook{SrB}
\newbook{STi}
\newbook{STii}
\newbook{STSnS}
\newbook{SY}
\newbook{SYt}
\newbook{TB}
\newbook{TS}
\newbook{TSP}
\newbook{V}
\let\Vd\V
\newbook{ViDh}
\newbook{Vim}
\newbook{VN}
\newbook{Vr}
\newbook{VrS}
\newbook{VS}
\newbook{Vyt}
\newbook{VytS}
\newbook{WD}
\newbook{WZ}
\newbook{XPl}
\newbook{Y}
\newbook{YAv}
\newbook{YF}
\newbook{Yt}
\newbook{ZWY}
\newcommand{\AvTr}[1]{#1}
\newcommand{\Rd}[1]{#1}
%%%
\newif\if@usechapterref
\newcommand*{\Chapterref}[1]{\if@usechapterref\realsuperscript{\ref{#1}}\fi}
\let\chapterref\Chapterref
\newcommand*{\@abbreviationsfile}{../muya.common/abbreviations.tex}
\newcommand*{\SetAbbreviationsFile}[1]{\renewcommand*{\@abbreviationsfile}{#1}}
\newcommand*{\@abbreviationsacfile}{../muya.common/abbreviations_ac.tex}
\newcommand*{\SetAbbreviationsacFile}[1]{\renewcommand*{\@abbreviationsacfile}{#1}}
\newcommand*{\@transcriptionsfile}{../muya.common/transcriptions.tex}
\newcommand*{\SetTranscriptionsFile}[1]{\renewcommand*{\@transcriptionsfile}{#1}}
\newcommand*{\@translationsfile}{../muya.common/translations.tex}
\newcommand*{\SetTranslationsFile}[1]{\renewcommand*{\@translationsfile}{#1}}
%%\newcommand*{\@bibliographyfile}{../muya.common/zotero.bib}
%%\newcommand*{\SetBibliographyFile}[1]{\renewcommand*{\@bibliographyfile}{#1}}
\newcommand*{\@hyphexceptionsfile}{../muya.common/hyphenation-exceptions.tex}
\newcommand*{\SetHyphexceptionsFile}[1]{\renewcommand*{\@hyphexceptionsfile}{#1}}
\newcommand*{\@titlelogofile}{../muya.common/BRILL.pdf}
\newcommand*{\SetTitleLogoFile}[1]{\renewcommand*{\@titlelogofile}{#1}}
\newcommand{\anklink}[2]{#1\hfill\Ank{#2}}
\newcommand{\setdictlanguage}[1]{\def\@dictlanguage{#1}}
\NewEnviron{Dictionary}[1][Av]%
{%
\stepcounter{numberofglossaries}%
\def\@dictlanguage{#1}%
}%
[{%
\IfStrEqCase{\@dictlanguage}{%
{Av}{\directlua{sortGlossary("Av")}}%
{Guj}{\directlua{sortGlossary("Guj")}}%
{MP}{\directlua{sortGlossary("MP")}}%
{NP}{\directlua{sortGlossary("NP")}}%
{Skt}{\directlua{sortGlossary("Skt")}}%
}[\ClassWarning{brill}{Unknown language `\@dictlanguage`.}]
}%
\input{dictionaryconv}]%
% For the dictionary
\newif\if@firstsublemma
\newif\if@firstsubsublemma
\newif\if@firstsubsubsublemma
\newlist{ModDictionary}{description}{1}
\setlist[ModDictionary]{%
leftmargin=*,%
labelsep=0pt,%
font=\normalfont\bfseries\itshape,%
}
\newlist{Meanings}{enumerate*}{1}
\setlist[Meanings]{label=\arabic*.,mode=unboxed}
%
\newlist{Sublemmata}{description}{1}
\setlist[Sublemmata]{%
leftmargin=*,%
labelindent=2\parindent,%
labelsep=.5em,%
font=\normalfont\bfseries\itshape,%
before={\def~{\textasciitilde}\@firstsublemmatrue}%,
}
\newlist{Subsublemmata}{description}{1}
\setlist[Subsublemmata]{%
leftmargin=*,%
labelindent=2\parindent,%
labelsep=.5em,%
font=\normalfont\bfseries\itshape,%
before={\def~{\textasciitilde}\@firstsubsublemmatrue}%
}
\newlist{Subsubsublemmata}{description}{1}
\setlist[Subsubsublemmata]{labelsep=.5em}
\setlist[Subsubsublemmata]{%
leftmargin=*,%
labelindent=2\parindent,%
labelsep=.5em,%
font=\normalfont\bfseries\itshape,%
before={\def~{\textasciitilde}\@firstsubsubsublemmatrue}%
}
\newcommand{\Meaning}[2][]{\item #2\ifstrempty{#1}{}{\ (#1)}}
\def\Sublemma{\@ifstar\@Sublemma\@@Sublemma}
\newcommand*{\@Sublemma}[1]{%
\if@firstsublemma
\@@Sublemma{#1}%
\@firstsublemmafalse%
\else
\unskip\nobreak\hspace{\fontdimen2\font}|\penalty9999\hspace{\fontdimen2\font}{\bfseries\itshape #1}%
\fi%
}
\newcommand*{\@@Sublemma}[1]{%
\item[#1]%
\@firstattestationtrue%
\@firstsublemmafalse%
}
%
\def\Subsublemma{\@ifstar\@Subsublemma\@@Subsublemma}
\newcommand*{\@Subsublemma}[1]{%
\if@firstsubsublemma
\@@Subsublemma{#1}%
\@firstsubsublemmafalse%
\else
\unskip\nobreak\hspace{\fontdimen2\font}|\penalty9999\hspace{\fontdimen2\font}{\bfseries\itshape #1}%
\fi%
}
\newcommand*{\@@Subsublemma}[1]{%
\item[#1]%
\@firstattestationtrue%
\@firstsubsublemmafalse
}
%
\def\Subsubsublemma{\@ifstar\@Subsubsublemma\@@Subsubsublemma}
\newcommand*{\@Subsubsublemma}[1]{%
\if@firstsubsubsublemma
\@@Subsubsublemma{#1}%
\@firstsubsubsublemmafalse
\else
\unskip\nobreak\hspace{\fontdimen2\font}|\penalty9999\hspace{\fontdimen2\font}{\bfseries\itshape #1}%
\fi%
}
\newcommand*{\@@Subsubsublemma}[1]{%
\item[#1]%
\@firstattestationtrue%
\@firstsubsubsublemmafalse%
}
\newcommand*{\Lemma}[2][]{\item[#2]\@ifnextchar,{}{\hspace{0.5em}}}
\newcommand*{\Lemmaoarg}[1]{\ifstrempty{#1}{}{\textlangle{}#1\textrangle{}}}
\newcommand*{\Link}[1]{\unskip\nobreakspace\symbol{"2192}\,#1}
\newcommand{\AirWb}[1]{\textit{AirWb}\nobreakspace{}#1}
\newcommand{\Etym}[1]{#1}
\newcommand{\EWAia}[1]{\textit{EWAia}\nobreakspace{}#1}
\newcommand{\Reference}[1]{#1}
\newcommand{\Translation}[2][]{%
\IfStrEqCase{#1}{%
{Phlv}{Pahl.\,tr.:\nobreakspace{}}%
{Sa}{Sanskrit tr.:\nobreakspace{}}%
}[]%
\textit{#2}}%
\newcommand{\Stage}[1]{#1}
%%\newcommand{\Ved}[1]{#1}
\newcounter{attestation}
\def\Attestation{\@ifstar%
{\stepcounter{attestation}\@attestation}%
{\setcounter{attestation}{1}\@attestation}}
\newif\if@firstattestation
\def\@attestation{\@ifnextchar[{\@@attestation}{\@@attestation[0]}}
\newcommand{\@@attestation}[3][]{%
\if@firstattestation
\@firstattestationfalse%
\else%
\unskip\nobreak\hspace{\fontdimen2\font}|\nobreak\hspace{\fontdimen2\font}\ignorespaces%
\fi%
\ifstrempty{#1}{}{\Ifstr{#1}{0}{\theattestation.}{#1.}}%
\unskip\nobreak\hspace{\fontdimen2\font}%
\begin{nohyphens}%
\IfStrEqCase{\@dictlanguage}{%
{Av}{\textit{#2}}%
{Guj}{\textit{#2}}%
{MP}{\textlangle{}#2\textrangle{}}%
{NP}{\textlangle{}#2\textrangle{}}%
}[\textit{#2}]%
\end{nohyphens}%
\ #3%
}%
\newcommand{\Pos}[1]{#1}
\ifltxcounter{numberofglossaries}%
{}%
{\newcounter{numberofglossaries}}%
\AtBeginDocument{\setcounter{numberofglossaries}{0}}
\newcounter{@numberofglossaries}
\newcommand{\Sequenceofletters}{%
\par\noindent
Sequence of letters:\\%
\setcounter{@numberofglossaries}{\numexpr\value{numberofglossaries}+1\relax}
\csuse{@sequenceofletters\the@numberofglossaries}%
\par\vspace{\baselineskip}\noindent}
\newlength{\widestabbreviationac}
\newcommand*{\@checkforwidestabbreviationac}[1]{%
\settowidth{\currentwidth}{#1}%
\ifdimgreater{\currentwidth}{\widestabbreviationac}%
{\global\setlength{\widestabbreviationac}{\currentwidth}}%
{}%
}
\AtEndDocument{%
\ifdimless{\widestabbreviationac}{\normalparindent}%
{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 1.0\dimexpr\the\normalparindent\relax \relax}%
}%
}{\ifdimless{\widestabbreviationac}{2\normalparindent}%
{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 2.0\dimexpr\the\normalparindent\relax \relax}%
}%
}{\ifdimless{\widestabbreviationac}{3\normalparindent}%
{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 3.0\dimexpr\the\normalparindent\relax \relax}%
}%
}{\ifdimless{\widestabbreviationac}{4\normalparindent}%
{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 4.0\dimexpr\the\normalparindent\relax \relax}%
}%
}{\ifdimless{\widestabbreviationac}{5\normalparindent}%
{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 5.0\dimexpr\the\normalparindent\relax \relax}%
}%
}{\ifdimless{\widestabbreviationac}{6\normalparindent}%
{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 6.0\dimexpr\the\normalparindent\relax \relax}%
}%
}{\immediate\write\@auxout%
{%
\noexpand\global%
\noexpand\setlength{\widestabbreviationac}%
{\dimexpr 7.0\dimexpr\the\normalparindent\relax \relax}%
}%
}%
}%
}%
}%
}%
}%
}%
%\newcolumntype{W}{>{\collectcell\testme}p{\widestabbreviationac}<{\endcollectcell}}
%\tabucolumn W
\AtEndPreamble{%
\shorthandon{"}
\InputIfFileExists{\@abbreviationsfile}%
{\ClassInfo{brill}{Abbreviations successfully loaded!}}%
{\ClassWarning{brill}{%
No abbreviation file found!\MessageBreak
Please use \string\SetAbbreviationsFile\space}%
}%
\InputIfFileExists{\@abbreviationsacfile}%
{\ClassInfo{brill}{Abbreviations for apparatus criticus successfully
loaded!}}%
{\ClassWarning{brill}{%
No abbreviation file for apparatus criticus found!\MessageBreak
Please use \string\SetAbbreviationsacFile\space}%
}%
\InputIfFileExists{\@translationsfile}%
{\ClassInfo{brill}{Translations successfully loaded!}}%
{\ClassWarning{brill}{%
No translation file found!\MessageBreak
Please use \string\SetTranslationsFile\space}%
}%
\shorthandoff{"}
\IfFileExists{\@transcriptionsfile}%
{%
\directlua{read_transcriptions("\luaescapestring{\@transcriptionsfile}")}%
\InputIfFileExists{transcriptions-mod.tex}%
{%
\ClassInfo{brill}{Transcriptions successfully loaded from `\@transcriptionsfile`!}%
}%
{%
\ClassWarning{brill}{Problem with loading transcriptions from `\@transcriptionsfile`\MessageBreak No transcriptions available}%
}%
}%
{%
\ClassWarning{brill}{No transcription file found!\MessageBreak
Please use \string\SetTranscriptionsFile\space}%
}%
% \IfFileExists{\@bibliographyfile}%
% {\addbibresource{\@bibliographyfile}}%
% {\ClassWarning{brill}{No bibliography file found!\MessageBreak
% Please use \string\SetBibliographyFile\space}}%
\InputIfFileExists{\@hyphexceptionsfile}%
{\ClassInfo{brill}{Successfully loaded hyphenation exceptions file
``\@hyphexceptionsfile''}%
}%
{\ClassInfo{brill}{Could not find hyphenations exceptions file
``\@hyphexceptionsfile''!}%
}%
}%
\DeclareRobustCommand*{\supth}{\textsuperscript{th}\xspace}
\DeclareRobustCommand*{\uncertain}[1]{#1\fakesuperscript{\textup{?}}}
\newcommand{\addblankline}[1][1]{\vspace{#1\baselineskip}}
\newcommand*{\footnotetextsuperscript}[1]{\textsuperscript{\upshape #1}}
\newcommand{\insertion}[1]{{\upshape #1}}
\newif\if@inRDTrans
\newcommand{\RDTrans}[1]{%
\@inRDTranstrue%
\global\settoggle{@setlinenumberforthisline}{false}%
{\itshape #1}%
\global\settoggle{@setlinenumberforthisline}{true}%
\@inRDTransfalse%
}%
%
\let\@abstract\@empty%
\ifbrill@PhD
\newcommand{\@degree}{}%
\newcommand{\degree}[1]{\renewcommand{\@degree}{#1}}
\newcommand{\department}[1]{\renewcommand{\@department}{#1}}
\newcommand{\@department}{}%
\def\abstract{\@ifstar%
{\def\@abstractheading{\chapter*{\abstractname}%
\markboth{\abstractname}{\abstractname}}%
\@@abstract}%
{\def\@abstractheading{\addchap{\abstractname}}%
\@@abstract}%
}
\newcommand{\@@abstract}[1]{\renewcommand{\@abstract}{#1}}%
\newcommand{\declarationPhD}[1]{\renewcommand{\@declarationPhD}{#1}}%
\newcommand{\@declarationPhD}{%
\minisec{Declaration for SOAS PhD thesis}
\noindent I have read and understood Regulation 21 of the General and
Admissions Regulations for students of the SOAS, University of London
concerning plagiarism. I undertake that all the material presented for
examination is my own work and has not been written for me, in whole or in
part, by any other person. I also undertake that any quotation or paraphrase
from the published or unpublished work of another person has been duly
acknowledged in the work which I present for
examination.\par\vspace{\baselineskip}
\noindent Signed: \rule{4cm}{0.4pt} \hfill Date: \rule{4cm}{0.4pt}%
}
\else
\let\declarationPhD\@gobble
\let\abstract\@gobble
\fi%
\pdfstringdefDisableCommands{%
\renewcommand*{\@@Av}[2][]{#2}%
\renewcommand*{\Guj}[2][]{#2}%
\def\gls#1{#1}%
\def\Y#1{Y~#1}%
\def\PY#1{PY~#1}%
\def\Phl#1{Phl~#1}%
}%
\AtBeginDocument{\let\brill@saved@footnotetext\@footnotetext}
\newcommand*{\Deactivatefootnotetext}{\let\@footnotetext=\@gobble}
\newcommand*{\Activatefootnotetext}{\let\@footnotetext\brill@saved@footnotetext}
\providecommand*{\fL}{\hskip0.16667em\relax}
\renewcommand{\slash}{/\penalty\exhyphenpenalty\hspace{0pt}}
\providecommand*{\nbthinslash}{\,\slash\fL{}}
\providecommand*{\appindent}{\hspace*{\normalparindent}}
%\providecommand*{\Comment}{\noindent\textbf{Comment}:}
\providecommand*{\skipaftergraphic}%
{\vspace*{\dimexpr -1.0\normalbaselineskip+1bp\relax}}
%\newcommand*\footnoteruleVAR{%
% \normalsize\ftn@rule@test@values
% \kern-\dimexpr 2.6\p@+\ftn@rule@height\relax
% \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
% {\usekomafont{footnoterule}{%
% \hrule \@height\ftn@rule@height \@width\ftn@rule@width}}%
% \kern 2.6\p@}
%
%\providecommand{\liftfootnotes}[1]{%
% \advance\skip\footins by-#1%
% \def\footnoterule{%
% \normalsize\ftn@rule@test@values
% \kern#1%
% \kern-\dimexpr 2.6\p@+\ftn@rule@height\relax
% \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
% {\usekomafont{footnoterule}{%
% \hrule \@height\ftn@rule@height \@width\ftn@rule@width}}%
% %\kern 2.6\p@%
% \kern-#1}%
%}
\endinput
|
% The OxyGEN proyect by Profoty.xyz
% Together against the Covid-19
% V4.0 rev.17/03/2020
%
% Website/blog: oxygen.protofy.xyz
% Contact: [email protected]
%GEOMETRICAL PARAMETERS
clear;
%Length from the bearing to the hinge
l0 = 27.5;
%Length of the vertical wall that supports the hinge
h0 = 6.5;
%Lenght of the vertical support of the bearing
hb = 4.0;
%Bearing radius
br = 1.1;
%Array of different max and min positions of the bearing
h1a = [6.5, 7.1, 7.7, 8.3];
h2a = [20.5, 20.5, 20.5, 20.5];
%Number of cycles per cam turn (1 to 3).
nc = 1;
%Minimum radius of the camshaft
rmin = 5;
%BREATHING CYCLE PARAMETERS
%Duration of the inhale cycle / duration of the whole cycle
lambda1 = 0.500;
lambda2 = 0.060;
%Soft transition between inhale and exhale cycles
dpsi21 = 0.12;
dpsi12 = 0.15;
%Adjust parameters of the inhale curve
ga1 = pi;
gb1 = 1.2;
ff1 = 20;
sp1 = 1;
%Adjust parametes of the exhale curve
ga2 = 9;
gb2 = .5;
ff2 = 20;
%GENERATION OF THE CURVES AND THE CAMSHAFT
%Generation of the geometry
l = sqrt(l0^2+hb^2);
for i = 1:numel(h1a);
ymin(i) = h1a(i);
ymax(i) = h2a(i);
alphamin(i) = acos((h0 - h1a(i)) / l);
alphamax(i) = acos((h0 - h2a(i)) / l);
xmin(i) = l*sin(alphamin(i));
xmax(i) = l*sin(alphamax(i));
d(i) = sqrt((xmin(i)-xmax(i))^2 + (ymin(i)-ymax(i))^2);
alphatan(i) = (alphamin(i) + alphamax(i)) / 2;
xtan(i) = l*sin(alphatan(i));
ytan(i) = h0 - l*cos(alphatan(i));
xsup(i) = xtan(i) + (d(i)/2)*cos(alphatan(i));
xinf(i) = xtan(i) - (d(i)/2)*cos(alphatan(i));
ysup(i) = ytan(i) + (d(i)/2)*sin(alphatan(i));
yinf(i) = ytan(i) - (d(i)/2)*sin(alphatan(i));
xcam(i) = xtan(i) + (d(i)/2 + rmin + br)*cos(alphatan(i));
ycam(i) = ytan(i) + (d(i)/2 + rmin + br)*sin(alphatan(i));
end;
%Time increment
dt = 0.01;
%time coordinate during the whole cycle
theta = 0:dt:2*pi;
%Generation of the soft transition between inhale and exhale curves
psi1 = [];
psi2 = [];
for i = 1:numel(theta);
if theta(i) < (lambda2-dpsi21/2)*2*pi;
psi1(i) = 0;
elseif theta(i) < (lambda2+dpsi21/2)*2*pi;
psi1(i) = 0.5 + 0.5*cos((theta(i)-(lambda2+dpsi21/2)*2*pi)/(2*dpsi21));
else theta(i) < (lambda1-dpsi12/2)*2*pi;
psi1(i) = 1;
end;
psi2(i) = 1 - psi1(i);
end;
%Generation of the complete breathing cycle rho(theta)
rho = [];
rho1 = [];
rho2 = [];
rho2next = [];
rhomin = 1000;
rhomax = 0;
for i = 1:numel(theta);
%Inhale curve
rho1(i) = ff1*normpdf(sp1*theta(i), ga1, gb1);
rho1next(i) = ff1*normpdf(sp1*theta(i)+sp1*2*pi, ga1, gb1);
%Exhale curve
rho2(i) = ff2*gampdf(theta(i), ga2, gb2);
rho2next(i) = ff2*gampdf(theta(i)+2*pi, ga2, gb2);
rho(i) = max(rho1(i), rho1next(i));
%Capturing min and max in order to generate the normalized curve
if rho(i) > rhomax
rhomax = rho(i);
end;
if rho(i) < rhomin
rhomin = rho(i);
end;
end;
%Generation of a normalised curve and camshaft
rhonorm = [];
rhocam = [];
for i = 1:numel(theta);
rhonorm(i) = (rho(i)-rhomin)/(rhomax-rhomin);
for n = 1:numel(d)
rhocam(n,i) = rmin + rhonorm(i)*d(n);
end;
end;
%Generation of the first derivate of the camshaft geometry to analize and
%validate the design
drho = [];
drhonorm = [];
drhocam = [];
a = rmin;
b = 1/dt;
for i = 1 : numel(rho)-1;
drho(i) = b*(rho(i+1)-rho(i));
drhonorm(i) = b*(rhonorm(i+1)-rhonorm(i));
drhocam(i) = b*(rhocam(i+1)-rhocam(i)) + a;
end;
drho(numel(rho)) = b*(rho(1)-rho(numel(rho)));
drhonorm(numel(rhonorm)) = b*(rhonorm(1)-rhonorm(numel(rhonorm)));
drhocam(numel(rhocam)) = b*(rhocam(1)-rhocam(numel(rhocam))) + a;
%X and Y coordinates during two cycles (for 2-cycle camshaft plot)
theta2 = [theta/2, (2*pi+theta)/2];
rhocam2 = [rhocam, rhocam];
drhocam2 = [drho, drho];
%X and Y coordinates during three cycles (for 3-cycle camshaft plot)
theta3 = [theta/3, (2*pi+theta)/3, (4*pi+theta)/3];
rhocam3 = [rhocam, rhocam, rhocam];
drhocam3 = [drho, drho, drho];
%GENERATION OF THE PLOTS
%Trying to print it out in real size (FAIL)
%set(gcf,'PaperUnits','centimeters');
%set(gcf,'PaperSize',[42 29.7]);
fpos = figure('Name', 'Dimensions', 'Units', 'centimeters', 'NumberTitle', 'off');
set(gcf,'PaperUnits','centimeters', 'PaperSize', [42/2 27.9/2]);
set(gcf, 'units', 'centimeters', 'position', [0, 0, 28, 20]);
fpos = gcf;
hold on
xlim([-5 35]);
ylim([0 30]);
for i = 1:numel(xmin)
plot([0, xmin(i)], [h0, ymin(i)], '-x')
plot([0, xmax(i)], [h0, ymax(i)], '-x')
plot([0, xtan(i)], [h0, ytan(i)], '--xb')
plot([xsup(i), xinf(i)], [ysup(i), yinf(i)], '--xr')
scatter(xcam(i), ycam(i))
end;
hold off
%Plot of the breathing cycle interpolation by curves
fcycle = figure('Name', 'Breath Cycle curves', 'Units', 'centimeters', 'NumberTitle', 'off');
hold on
plot(theta, psi1, '-k')
plot(theta, psi2, '-k')
plot(theta, rho1, '-g')
plot(theta, rho1next, '-g')
plot(theta, rho2, '-g')
plot(theta, rho2next, '-g')
%plot(theta, drho, '-r')
plot(theta, rho, '-b')
hold off
set(gcf,'PaperUnits','centimeters', 'PaperSize', [42 27.9]);
set(gcf, 'units', 'centimeters', 'position', [0, 0, 27.9, 27.9]);
fcam3 = gcf;
%Plot of the normalized breathing cycle and first derivate
fnorm = figure('Name', 'Normalized Breath Cycle', 'Units', 'centimeters', 'NumberTitle', 'off');
hold on
%plot(theta, drhonorm, '-r')
plot(theta, rhonorm, '-b')
hold off
set(gcf,'PaperUnits','centimeters', 'PaperSize', [42/2 27.9/2]);
set(gcf, 'units', 'centimeters', 'position', [0, 0, 27.9, 27.9]);
fcam3 = gcf;
%Plot of a 1-cycle camshaft
for n = 1:numel(d)
fcam1 = figure('Name', '1-Cycle Camshaft', 'Units', 'centimeters', 'NumberTitle', 'off');
%hold on
%polarplot(theta, drhocam, '-r')
polar(theta, rhocam(n,:), '-b')
%rlim([0 25]);
hold off
set(gcf,'PaperUnits','centimeters', 'PaperSize', [42 27.9]);
set(gcf, 'units', 'centimeters', 'position', [0, 0, 27.9, 27.9]);
fcam3 = gcf;
end
% %Plot of a 2-cycle camshaft
%
% fcam2 = figure('Name', '2-Cycle', 'Units', 'centimeters', 'NumberTitle', 'off');
%
% %hold on;
% %polar(theta, drhocam2, '-r')
% polar(theta2, rhocam2, '-b')
% %hold off;
%
% set(gcf,'PaperUnits','centimeters', 'PaperSize', [42 27.9]);
% set(gcf, 'units', 'centimeters', 'position', [0, 0, 27.9, 27.9]);
% fcam3 = gcf;
%
%
% %Plot of a 3-cycle camshaft
%
% fcam3 = figure('Name', '3-Cycle', 'Units', 'centimeters', 'NumberTitle', 'off');
%
% %hold on;
% %polar(theta,drhocam3)
% polar(theta3, rhocam3)
% %hold off;
%
% set(gcf,'PaperUnits','centimeters', 'PaperSize', [42 27.9]);
% set(gcf, 'units', 'centimeters', 'position', [0, 0, 27.9, 27.9]);
% fcam3 = gcf;
% The OxyGEN proyect by Profoty.xyz
% Together against the Covid-19
% V4.0 rev.17/03/2020
%
% Website/blog: oxygen.protofy.xyz
% Contact: [email protected]
|
(** * verif_splitnode.v : Correctness proof of splitnode *)
Require Import VST.floyd.proofauto.
Require Import VST.floyd.library.
Require Import btrees.relation_mem.
Require Import VST.msl.wand_frame.
Require Import VST.msl.iter_sepcon.
Require Import VST.floyd.reassoc_seq.
Require Import VST.floyd.field_at_wand.
Require Import FunInd.
Require Import btrees.btrees.
Require Import btrees.btrees_sep.
Require Import btrees.btrees_spec.
Require Import btrees.verif_splitnode_part0.
Opaque Znth.
Lemma splitnode_main_if_part2_proof:
forall (Espec : OracleKind) (ptr0 : option (node val)) (le : list (entry val))
(First Last : bool) (nval pe : val) (gv : globals) (v_allEntries : val)
(k : key) (ve : V) (xe : val)
(LEAFENTRY : LeafEntry (keyval val k ve xe) =
is_true (node_isLeaf (btnode val ptr0 le true First Last nval))),
let n := btnode val ptr0 le true First Last nval : node val in
forall (H0 : Zlength le = Fanout)
(H : node_integrity (btnode val ptr0 le true First Last nval))
(fri : Z)
(HFRI : findRecordIndex n k = fri)
(vnewnode : val)
(H1 : vnewnode <> nullval),
let nleft := btnode val ptr0 le true First false nval : node val in
forall (PTRXE : isptr xe) (allent_end : list (val * (val + val)))
(H3 : Zlength allent_end = Fanout + 1 - fri)
(FRIRANGE : 0 <= fri <= Fanout)
(* (H4 : 0 <= fri < Zlength (map entry_val_rep (sublist 0 fri le) ++ allent_end)) *),
semax (func_tycontext f_splitnode Vprog Gprog [])
(PROP ()
LOCAL (
temp _newNode vnewnode; temp _tgtIdx (Vint (Int.repr fri));
lvar _allEntries (tarray tentry 16) v_allEntries;
temp _node nval; temp _entry pe)
SEP (mem_mgr gv; btnode_rep nleft;
btnode_rep (empty_node true false Last vnewnode);
data_at Ews tentry (Vptrofs k, inr xe) pe;
data_at Tsh (tarray tentry 16)
(map entry_val_rep (sublist 0 fri le) ++
(Vptrofs k, inr (force_val (sem_cast_pointer xe)))
:: map entry_val_rep (sublist fri Fanout le)) v_allEntries;
entry_rep (keyval val k ve xe))) splitnode_main_if_part2
(frame_ret_assert
(function_body_ret_assert tvoid
(EX newx : val,
PROP ( )
LOCAL ()
SEP (mem_mgr gv;
btnode_rep
(splitnode_left
(btnode val ptr0 le true First Last nval)
(keyval val k ve xe));
entry_rep
(splitnode_right
(btnode val ptr0 le true First Last nval)
(keyval val k ve xe) newx);
data_at Ews tentry
(Vptrofs
(splitnode_key
(btnode val ptr0 le true First Last nval)
(keyval val k ve xe)), inl newx) pe))%assert)
(stackframe_of f_splitnode)).
Proof.
intros. unfold splitnode_main_if_part2. abbreviate_semax.
set (H4 := True).
subst fri; set (fri := findRecordIndex n k) in *.
pose (e:=keyval val k ve xe).
rewrite unfold_btnode_rep with (n:=nleft).
unfold nleft. Intros ent_end0.
forward. (* node->numKeys=8 *)
sep_apply insert_rep. fold e.
replace (insert_le le e) with
(sublist 0 Middle (insert_le le e)
++ sublist Middle (Zlength (insert_le le e)) (insert_le le e)).
2:{ rewrite sublist_rejoin; try rep_lia.
apply sublist_same; list_solve.
clear - H0. simpl in H0.
autorewrite with sublist. rep_lia. }
rewrite iter_sepcon_app.
forward_if (PROP ( )
LOCAL (temp _newNode vnewnode; temp _tgtIdx (Vint (Int.repr fri));
lvar _allEntries (tarray tentry 16) v_allEntries; temp _node nval; temp _entry pe)
SEP (mem_mgr gv; btnode_rep (splitnode_left n e); btnode_rep (empty_node true false Last vnewnode);
data_at Ews tentry (Vptrofs k, inr xe) pe;
data_at Tsh (tarray tentry 16)
(map entry_val_rep (sublist 0 fri le)
++ (Vptrofs k, inr (force_val (sem_cast_pointer xe)))
:: map entry_val_rep (sublist fri Fanout le)) v_allEntries;
iter_sepcon entry_rep (sublist Middle (Zlength (insert_le le e)) (insert_le le e)))).
{ (* fri < 8 *)
Intros.
Intros. rewrite Int.signed_repr in H2.
2:{ subst fri; simpl in *. rewrite Fanout_eq in *. rep_lia. }
unfold Sfor. (* both forward_loop and forward_for_simple_bound fail here *)
forward. (* i=tgtIdx *)
forward_loop (EX i:Z, EX le_end:list(val*(val+val)), PROP(fri <= i <= Middle)
LOCAL (temp _newNode vnewnode; temp _tgtIdx (Vint (Int.repr fri));
lvar _allEntries (tarray tentry 16) v_allEntries; temp _node nval; temp _entry pe;
temp _i (Vint (Int.repr i)))
SEP (mem_mgr gv; iter_sepcon entry_rep (sublist 0 Middle (insert_le le e) );
iter_sepcon entry_rep (sublist Middle (Zlength (insert_le le e)) (insert_le le e)); malloc_token Ews tbtnode nval;
data_at Ews tbtnode
(Val.of_bool true,
(Val.of_bool First,
(Val.of_bool false,
(Vint (Int.repr 8),
(optionally getval nullval ptr0,
map entry_val_rep ( (sublist 0 i (insert_le le e))) ++ le_end))))) nval;
optionally btnode_rep emp ptr0; btnode_rep (empty_node true false Last vnewnode);
data_at Ews tentry (Vptrofs k, inr xe) pe;
data_at Tsh (tarray tentry 16)
(map entry_val_rep ( (sublist 0 fri le)) ++
(Vptrofs k, inr (force_val (sem_cast_pointer xe)))
:: map entry_val_rep ( (sublist fri Fanout le))) v_allEntries))%assert.
- Exists fri.
Exists (map entry_val_rep ((sublist fri (Zlength le) le)) ++ ent_end0).
entailer!.
{ clear - H2. subst fri. simpl. rewrite Middle_eq. lia. }
apply derives_refl'. do 6 f_equal. rewrite <- app_ass. f_equal.
rewrite <- map_app. f_equal.
simpl in H0.
replace (sublist 0 fri (insert_le le e)) with (sublist 0 fri le).
rewrite sublist_rejoin; try list_solve.
autorewrite with sublist. auto.
rewrite insert_fri with (fri:=fri) (key0:=k); try auto with typeclass_instances.
autorewrite with sublist. auto.
- (* loop body *)
Intros i.
Intros le_end.
forward_if.
+ assert(HINSERT: (map entry_val_rep ( (sublist 0 fri le))
++ (Vptrofs k, inr (force_val (sem_cast_pointer xe)))
:: map entry_val_rep ( (sublist fri Fanout le)))
= map entry_val_rep ( (insert_le le e))).
{ rewrite insert_fri with (fri:=fri) (key0:=k); auto with typeclass_instances.
rewrite map_app.
simpl. f_equal.
f_equal. f_equal.
f_equal. f_equal. simpl in H0; lia.
}
rewrite HINSERT.
assert(HENTRY: exists ei, Znth_option i (insert_le le e) = Some ei).
{ apply Znth_option_in_range. simpl in H0. rewrite Zlength_insert_le. rewrite H0. rep_lia. }
destruct HENTRY as [ei HENTRY].
assert (HEI: exists ki vi xi, ei = keyval val ki vi xi).
{ eapply integrity_leaf_insert; auto with typeclass_instances.
simpl in H. destruct H. eauto. unfold e in HENTRY.
eauto. }
destruct HEI as [ki [vi [xi HEI]]]. subst ei.
assert_PROP(isptr xi).
{ apply le_iter_sepcon_split in HENTRY.
gather_SEP (iter_sepcon entry_rep (sublist 0 Middle (insert_le le e)))
(iter_sepcon entry_rep (sublist Middle (Zlength (insert_le le e)) (insert_le le e))).
replace_SEP 0 ( iter_sepcon entry_rep (insert_le le e)).
{ entailer!. rewrite <- iter_sepcon_app. rewrite sublist_rejoin; try list_solve.
rewrite sublist_same by list_solve. auto.
autorewrite with sublist; auto.
simpl in H0; rewrite H0. rep_lia. }
rewrite HENTRY. simpl entry_rep. entailer!. }
rename H7 into XIPTR.
assert(HZNTH: Znth i (map entry_val_rep ( (insert_le le e))) = entry_val_rep (keyval val ki vi xi)).
{ intros. rewrite Znth_map. apply Znth_option_e' in HENTRY. rewrite HENTRY. auto.
apply Znth_option_some in HENTRY; rep_lia. }
assert(0 <= i < 8) by lia.
assert_PROP(Zlength le_end > 0).
{ entailer!.
clear - H10 H7 H0. simplify_value_fits in H10.
destruct H10, H1, H2, H3, H4.
simplify_value_fits in H5. destruct H5.
rewrite Zlength_app, Zlength_map in H5.
pose proof (Zlength_sublist_hack 0 i (insert_le le e)).
lia. }
rename H8 into LEEND.
forward. (* t'20=allEntries[i]->key *)
{ unfold local, lift1. intro; apply prop_right. clear - HZNTH.
fold Inhabitant_entry_val_rep; rewrite HZNTH. hnf; auto. }
fold Inhabitant_entry_val_rep; rewrite HZNTH.
forward. (* node->entries[i]->key=t'20 *)
forward. (* t'19=allEntries[i]->ptr.record *)
{ fold Inhabitant_entry_val_rep; rewrite HZNTH. entailer!. }
fold Inhabitant_entry_val_rep; rewrite HZNTH.
forward. (* node->entries[i]->ptr.record = t'19 *)
forward. (* i=i+1 *)
Exists (i+1).
Exists (sublist 1 (Zlength le_end) le_end).
assert (Hi: i < Zlength (insert_le le e)). {
rewrite Zlength_insert_le. simpl in H0; rewrite H0. rep_lia.
}
entailer!. apply derives_refl'; repeat f_equal.
autorewrite with sublist.
rewrite upd_Znth_twice by list_solve.
rewrite upd_Znth_same by list_solve.
(*WAS:rewrite upd_Znth0. *)
(*NOW:*)simpl; clear H11.
rewrite upd_Znth_app2.
2: rewrite Zlength_map, Zlength_sublist2, Z.min_l, Z.max_l by lia; simpl; lia.
rewrite Zlength_map, Zlength_sublist2, Z.min_l, Z.max_l by lia; simpl.
rewrite Zminus_0_r, Zminus_diag.
rewrite upd_Znth0_old by trivial.
fold (Z.succ i).
rewrite (sublist_split 0 i (Z.succ i)) by lia.
rewrite map_app, app_ass. f_equal.
rewrite (sublist_one i) by lia. simpl. f_equal.
clear - HENTRY.
apply Znth_to_list with (endle:=nil) in HENTRY.
rewrite <- app_nil_end in HENTRY.
rewrite HENTRY. reflexivity.
+
assert(i=8) by rep_lia.
forward. (* break *)
entailer!.
unfold n, splitnode_left.
rewrite unfold_btnode_rep
with (n:=btnode val ptr0 (sublist 0 Middle (insert_le le e)) true First false nval).
Exists le_end.
cancel. simpl.
apply derives_refl'; repeat f_equal.
rewrite Zlength_sublist. rep_lia.
rep_lia. simpl in H0. clear - H0. rewrite Zlength_insert_le. rep_lia.
}
{ (* fri >= 8 *)
rewrite Int.signed_repr in H2.
2:{ subst fri; simpl in *. rewrite Fanout_eq in *. rep_lia. }
forward. (* skip *)
entailer!.
assert((Middle <=? fri) = true).
{ clear -H2. rewrite Middle_eq. apply Z.leb_le. subst fri; simpl; lia. }
unfold splitnode_left, n.
rewrite unfold_btnode_rep with (n:=btnode val ptr0 (sublist 0 Middle (insert_le le e)) true First false nval).
assert(SPLITLE: le = (sublist 0 Middle le) ++ (sublist Middle (Zlength le) le)).
{simpl in H0. rewrite sublist_rejoin; try rep_lia. autorewrite with sublist; auto. }
rewrite SPLITLE.
rewrite map_app, <- app_assoc.
Exists (map entry_val_rep (sublist Middle (Zlength le) le) ++ ent_end0).
simpl. cancel.
apply derives_refl'; do 5 f_equal.
do 2 f_equal.
rewrite <- SPLITLE.
rewrite Zlength_sublist; auto. rep_lia.
rewrite Zlength_insert_le. simpl in H0. rep_lia.
do 3 f_equal.
rewrite nth_first_insert with (k:=k); auto with typeclass_instances.
rewrite <- SPLITLE. auto.
rewrite <- SPLITLE.
(*WAS: change (findRecordIndex' le k 0) with fri. rep_lia.*)
(*NOW*) rewrite Middle_eq. lia.
}
rewrite unfold_btnode_rep with (n:=empty_node true false Last vnewnode).
simpl. Intros ent_empty.
assert(HINSERT: (map entry_val_rep ( (sublist 0 fri le))
++ (Vptrofs k, inr xe)
:: map entry_val_rep ( (sublist fri Fanout le)))
= map entry_val_rep ( (insert_le le e))).
{ rewrite insert_fri with (fri:=fri) (key0:=k); auto with typeclass_instances.
rewrite map_app.
simpl. f_equal.
f_equal.
do 2 f_equal; simpl in H0; rep_lia.
}
rewrite HINSERT.
forward_for_simple_bound (Fanout + 1)
(EX i:Z, EX ent_right:list(val*(val+val)), (PROP (Zlength ent_right + i - 8 = Fanout)
LOCAL (temp _newNode vnewnode; temp _tgtIdx (Vint (Int.repr fri));
lvar _allEntries (tarray tentry 16) v_allEntries; temp _node nval; temp _entry pe)
SEP (mem_mgr gv; btnode_rep (splitnode_left n e);
malloc_token Ews tbtnode vnewnode;
data_at Ews tbtnode
(Vtrue, (Vfalse, (Val.of_bool Last, (Vint (Int.repr 0), (nullval,
map entry_val_rep ((sublist Middle i (insert_le le e))) ++ ent_right)))))
vnewnode;
data_at Ews tentry (Vptrofs k, inr xe) pe;
data_at Tsh (tarray tentry 16) (map entry_val_rep ( (insert_le le e))) v_allEntries;
iter_sepcon entry_rep (sublist Middle (Zlength(insert_le le e)) (insert_le le e)))))%assert.
{ Exists ent_empty. entailer!.
simplify_value_fits in H7. decompose [and] H7. simplify_value_fits in H19.
destruct H19. rewrite Z.add_simpl_r. rewrite Fanout_eq; assumption.
autorewrite with sublist; auto. }
{ (* loop body *)
assert(HENTRY: exists ei, Znth_option i (insert_le le e) = Some ei).
{ apply Znth_option_in_range. simpl in H0. rewrite Zlength_insert_le. rewrite H0.
rep_lia. }
destruct HENTRY as [ei HENTRY].
assert (HEI: exists ki vi xi, ei = keyval val ki vi xi).
{ eapply integrity_leaf_insert; auto with typeclass_instances.
simpl in H. destruct H. eauto. unfold e in HENTRY.
eauto. }
destruct HEI as [ki [vi [xi HEI]]]. subst ei.
assert_PROP(isptr xi).
{ apply le_iter_sepcon_split in HENTRY.
rewrite unfold_btnode_rep with (n:=splitnode_left n e).
unfold splitnode_left. unfold n. Intros ent_left.
gather_SEP (iter_sepcon entry_rep (sublist 0 Middle (insert_le le e)))
(iter_sepcon entry_rep (sublist Middle _ (insert_le le e))).
replace_SEP 0 ( iter_sepcon entry_rep (insert_le le e)).
{ entailer!. rewrite <- iter_sepcon_app. rewrite sublist_rejoin; try rep_lia.
rewrite sublist_same by list_solve; auto.
autorewrite with sublist; auto.
simpl in H0. rep_lia. }
rewrite HENTRY. simpl entry_rep. entailer!. }
rename H5 into XIPTR.
assert(HZNTH: forall ent_end, Znth (d:=(Vundef,inl Vundef)) i (map entry_val_rep ( (insert_le le e)) ++ ent_end) = entry_val_rep (keyval val ki vi xi)).
{ intros. apply Znth_to_list'. auto. }
forward. (* t'18=allEntries[i]->key *)
apply prop_right; rep_lia.
{ specialize (HZNTH nil); rewrite <- app_nil_end in HZNTH; rewrite HZNTH. entailer!. }
specialize (HZNTH nil); rewrite <- app_nil_end in HZNTH; rewrite HZNTH. simpl.
forward. (* newnode->entries[i-8]->key=t'18 *)
apply prop_right; rep_lia.
forward. (* t'17=allEntries[i]->ptr.record *)
apply prop_right; rep_lia.
{ rewrite HZNTH. entailer!. }
rewrite HZNTH. simpl.
forward. (* newnode->entries[i-8]->ptr.record=t'17 *)
entailer!.
rename ent_right into x.
Exists (sublist 1 (Zlength x) x). entailer!.
list_solve.
assert(8 <= i < 16) by rep_lia.
(*NEW:*)clear H9; simpl. rewrite Middle_eq.
rewrite upd_Znth_twice by list_solve.
rewrite upd_Znth_same by list_solve.
rewrite upd_Znth_app2.
rewrite !Zlength_map.
apply derives_refl'. do 6 f_equal.
autorewrite with sublist.
(*WAS: rewrite Zlength_sublist; try rep_lia.
replace (i - 8 - (i - Middle)) with 0 by rep_lia.
rewrite upd_Znth0.*)
(*NOW:*)rewrite upd_Znth0_old.
fold (Z.succ i).
rewrite (sublist_split Middle i (Z.succ i)); try rep_lia.
rewrite map_app, app_ass. f_equal.
rewrite (sublist_one i); try lia. simpl; f_equal.
clear - HENTRY.
apply Znth_to_list with (endle:=nil) in HENTRY.
rewrite <- app_nil_end in HENTRY.
rewrite HENTRY. reflexivity.
rewrite Zlength_insert_le. simpl in H0. rewrite H0. rep_lia.
rewrite Zlength_insert_le. simpl in H0. rewrite H0. rep_lia.
(*WAS: rewrite Zlength_insert_le. simpl in H0. rewrite H0. rep_lia.*)
(*NOW:*) clear - H2 H5; rewrite Fanout_eq in *; lia.
pose proof (Zlength_insert_le _ le e). autorewrite with sublist.
pose proof (Zlength_sublist_hack Middle i (insert_le le e)).
spec (*H17*)H16; [rep_lia|].
rep_lia.
}
Intros ent_right.
forward.
change Vtrue with (Val.of_bool true).
change Vfalse with (Val.of_bool false).
pose (ptr1 := @None (node val)).
change nullval with (optionally getval nullval ptr1).
rewrite <- (sepcon_emp (malloc_token _ _ _)). Intros.
change emp with (optionally btnode_rep emp ptr1).
rewrite add_repr, sub_repr.
fold (Z.succ Fanout).
replace (Z.succ Fanout) with (Zlength (insert_le le e))
by (rewrite Zlength_insert_le; unfold n in H0; simpl in H0; rewrite H0; auto).
rewrite Middle_eq.
sep_apply (fold_btnode_rep ptr1).
simpl.
assert (Zlength le = Fanout) by (unfold n in H0; apply H0).
rewrite Zlength_insert_le. rewrite Zlength_sublist; try rep_lia.
rewrite Zlength_insert_le; rep_lia.
assert(NTHENTRY: exists emid, Znth_option Middle (insert_le le e) = Some emid).
{ apply Znth_option_in_range. unfold n in H0. simpl in H0. rewrite Zlength_insert_le.
rewrite H0. rep_lia. }
destruct NTHENTRY as [emid NTHENTRY].
assert(HZNTH: Znth_option Middle (insert_le le e) = Some emid) by auto.
(* apply Znth_to_list' with (endle:=nil) in HZNTH.*)
rewrite Middle_eq in HZNTH. simpl in HZNTH.
rewrite Znth_option_e in HZNTH. repeat if_tac in HZNTH; try discriminate.
rewrite Znth_map in HZNTH.
2:{ autorewrite with sublist in H6|-*; rep_lia. }
apply Some_inj in HZNTH.
forward. (* t'16=allEntries[8]->key *)
{ entailer!. fold Inhabitant_entry_val_rep. rewrite Znth_map.
destruct (Znth 8 (insert_le le e)); simpl; auto.
autorewrite with sublist in H11|-*. rep_lia. }
fold Inhabitant_entry_val_rep.
rewrite Znth_map by (autorewrite with sublist in H6|-*; rep_lia).
rewrite HZNTH.
forward. (* entry->key=t'16 *)
forward. (* entry->ptr.child=newnode *)
forward. (* return *)
Exists vnewnode. fold e. simpl.
rewrite NTHENTRY. simpl.
cancel.
apply sepcon_derives.
simpl. unfold splitnode_leafnode.
rewrite <- Middle_eq.
subst ptr1. cancel.
destruct (Znth 8 (insert_le le e)); apply derives_refl.
Qed.
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import topology.continuous_function.bounded
import topology.uniform_space.compact_separated
import tactic.equiv_rw
/-!
# Continuous functions on a compact space
Continuous functions `C(α, β)` from a compact space `α` to a metric space `β`
are automatically bounded, and so acquire various structures inherited from `α →ᵇ β`.
This file transfers these structures, and restates some lemmas
characterising these structures.
If you need a lemma which is proved about `α →ᵇ β` but not for `C(α, β)` when `α` is compact,
you should restate it here. You can also use
`bounded_continuous_function.equiv_continuous_map_of_compact` to move functions back and forth.
-/
noncomputable theory
open_locale topological_space classical nnreal bounded_continuous_function
open set filter metric
open bounded_continuous_function
namespace continuous_map
variables {α β E : Type*} [topological_space α] [compact_space α] [metric_space β] [normed_group E]
section
variables (α β)
/--
When `α` is compact, the bounded continuous maps `α →ᵇ β` are
equivalent to `C(α, β)`.
-/
@[simps { fully_applied := ff }]
def equiv_bounded_of_compact : C(α, β) ≃ (α →ᵇ β) :=
⟨mk_of_compact, to_continuous_map, λ f, by { ext, refl, }, λ f, by { ext, refl, }⟩
/--
When `α` is compact, the bounded continuous maps `α →ᵇ 𝕜` are
additively equivalent to `C(α, 𝕜)`.
-/
@[simps apply symm_apply { fully_applied := ff }]
def add_equiv_bounded_of_compact [add_monoid β] [has_lipschitz_add β] :
C(α, β) ≃+ (α →ᵇ β) :=
({ .. to_continuous_map_add_hom α β,
.. (equiv_bounded_of_compact α β).symm, } : (α →ᵇ β) ≃+ C(α, β)).symm
instance : metric_space C(α, β) :=
metric_space.induced
(equiv_bounded_of_compact α β)
(equiv_bounded_of_compact α β).injective
(by apply_instance)
/--
When `α` is compact, and `β` is a metric space, the bounded continuous maps `α →ᵇ β` are
isometric to `C(α, β)`.
-/
@[simps to_equiv apply symm_apply { fully_applied := ff }]
def isometric_bounded_of_compact :
C(α, β) ≃ᵢ (α →ᵇ β) :=
{ isometry_to_fun := λ x y, rfl,
to_equiv := equiv_bounded_of_compact α β }
end
@[simp] lemma _root_.bounded_continuous_function.dist_mk_of_compact (f g : C(α, β)) :
dist (mk_of_compact f) (mk_of_compact g) = dist f g := rfl
@[simp] lemma _root_.bounded_continuous_function.dist_to_continuous_map (f g : α →ᵇ β) :
dist (f.to_continuous_map) (g.to_continuous_map) = dist f g := rfl
open bounded_continuous_function
section
variables {α β} {f g : C(α, β)} {C : ℝ}
/-- The pointwise distance is controlled by the distance between functions, by definition. -/
lemma dist_apply_le_dist (x : α) : dist (f x) (g x) ≤ dist f g :=
by simp only [← dist_mk_of_compact, dist_coe_le_dist, ← mk_of_compact_apply]
/-- The distance between two functions is controlled by the supremum of the pointwise distances -/
lemma dist_le (C0 : (0 : ℝ) ≤ C) : dist f g ≤ C ↔ ∀x:α, dist (f x) (g x) ≤ C :=
by simp only [← dist_mk_of_compact, dist_le C0, mk_of_compact_apply]
lemma dist_le_iff_of_nonempty [nonempty α] :
dist f g ≤ C ↔ ∀ x, dist (f x) (g x) ≤ C :=
by simp only [← dist_mk_of_compact, dist_le_iff_of_nonempty, mk_of_compact_apply]
lemma dist_lt_iff_of_nonempty [nonempty α] :
dist f g < C ↔ ∀x:α, dist (f x) (g x) < C :=
by simp only [← dist_mk_of_compact, dist_lt_iff_of_nonempty_compact, mk_of_compact_apply]
lemma dist_lt_of_nonempty [nonempty α] (w : ∀x:α, dist (f x) (g x) < C) : dist f g < C :=
(dist_lt_iff_of_nonempty).2 w
lemma dist_lt_iff (C0 : (0 : ℝ) < C) :
dist f g < C ↔ ∀x:α, dist (f x) (g x) < C :=
by simp only [← dist_mk_of_compact, dist_lt_iff_of_compact C0, mk_of_compact_apply]
end
instance [complete_space β] : complete_space (C(α, β)) :=
(isometric_bounded_of_compact α β).complete_space
@[continuity] lemma continuous_eval : continuous (λ p : C(α, β) × α, p.1 p.2) :=
continuous_eval.comp ((isometric_bounded_of_compact α β).continuous.prod_map continuous_id)
@[continuity] lemma continuous_evalx (x : α) : continuous (λ f : C(α, β), f x) :=
continuous_eval.comp (continuous_id.prod_mk continuous_const)
lemma continuous_coe : @continuous (C(α, β)) (α → β) _ _ coe_fn :=
continuous_pi continuous_evalx
-- TODO at some point we will need lemmas characterising this norm!
-- At the moment the only way to reason about it is to transfer `f : C(α,E)` back to `α →ᵇ E`.
instance : has_norm C(α, E) :=
{ norm := λ x, dist x 0 }
@[simp] lemma _root_.bounded_continuous_function.norm_mk_of_compact (f : C(α, E)) :
∥mk_of_compact f∥ = ∥f∥ := rfl
@[simp] lemma _root_.bounded_continuous_function.norm_to_continuous_map_eq (f : α →ᵇ E) :
∥f.to_continuous_map∥ = ∥f∥ :=
rfl
open bounded_continuous_function
instance : normed_group C(α, E) :=
{ dist_eq := λ x y,
begin
rw [← norm_mk_of_compact, ← dist_mk_of_compact, dist_eq_norm],
congr' 1,
exact ((add_equiv_bounded_of_compact α E).map_sub _ _).symm
end, }
section
variables (f : C(α, E))
-- The corresponding lemmas for `bounded_continuous_function` are stated with `{f}`,
-- and so can not be used in dot notation.
lemma norm_coe_le_norm (x : α) : ∥f x∥ ≤ ∥f∥ :=
(mk_of_compact f).norm_coe_le_norm x
/-- Distance between the images of any two points is at most twice the norm of the function. -/
lemma dist_le_two_norm (x y : α) : dist (f x) (f y) ≤ 2 * ∥f∥ :=
(mk_of_compact f).dist_le_two_norm x y
/-- The norm of a function is controlled by the supremum of the pointwise norms -/
lemma norm_le {C : ℝ} (C0 : (0 : ℝ) ≤ C) : ∥f∥ ≤ C ↔ ∀x:α, ∥f x∥ ≤ C :=
@bounded_continuous_function.norm_le _ _ _ _
(mk_of_compact f) _ C0
lemma norm_le_of_nonempty [nonempty α] {M : ℝ} : ∥f∥ ≤ M ↔ ∀ x, ∥f x∥ ≤ M :=
@bounded_continuous_function.norm_le_of_nonempty _ _ _ _ _ (mk_of_compact f) _
lemma norm_lt_iff {M : ℝ} (M0 : 0 < M) : ∥f∥ < M ↔ ∀ x, ∥f x∥ < M :=
@bounded_continuous_function.norm_lt_iff_of_compact _ _ _ _ _ (mk_of_compact f) _ M0
lemma norm_lt_iff_of_nonempty [nonempty α] {M : ℝ} :
∥f∥ < M ↔ ∀ x, ∥f x∥ < M :=
@bounded_continuous_function.norm_lt_iff_of_nonempty_compact _ _ _ _ _ _ (mk_of_compact f) _
lemma apply_le_norm (f : C(α, ℝ)) (x : α) : f x ≤ ∥f∥ :=
le_trans (le_abs.mpr (or.inl (le_refl (f x)))) (f.norm_coe_le_norm x)
lemma neg_norm_le_apply (f : C(α, ℝ)) (x : α) : -∥f∥ ≤ f x :=
le_trans (neg_le_neg (f.norm_coe_le_norm x)) (neg_le.mp (neg_le_abs_self (f x)))
lemma norm_eq_supr_norm : ∥f∥ = ⨆ x : α, ∥f x∥ :=
(mk_of_compact f).norm_eq_supr_norm
end
section
variables {R : Type*} [normed_ring R]
instance : normed_ring C(α,R) :=
{ norm_mul := λ f g, norm_mul_le (mk_of_compact f) (mk_of_compact g),
..(infer_instance : normed_group C(α,R)) }
end
section
variables {𝕜 : Type*} [normed_field 𝕜] [normed_space 𝕜 E]
instance : normed_space 𝕜 C(α,E) :=
{ norm_smul_le := λ c f, le_of_eq (norm_smul c (mk_of_compact f)) }
section
variables (α 𝕜 E)
/--
When `α` is compact and `𝕜` is a normed field,
the `𝕜`-algebra of bounded continuous maps `α →ᵇ β` is
`𝕜`-linearly isometric to `C(α, β)`.
-/
def linear_isometry_bounded_of_compact :
C(α, E) ≃ₗᵢ[𝕜] (α →ᵇ E) :=
{ map_smul' := λ c f, by { ext, simp, },
norm_map' := λ f, rfl,
.. add_equiv_bounded_of_compact α E }
end
-- this lemma and the next are the analogues of those autogenerated by `@[simps]` for
-- `equiv_bounded_of_compact`, `add_equiv_bounded_of_compact`
@[simp] lemma linear_isometry_bounded_of_compact_symm_apply (f : α →ᵇ E) :
(linear_isometry_bounded_of_compact α E 𝕜).symm f = f.to_continuous_map :=
rfl
@[simp] lemma linear_isometry_bounded_of_compact_apply_apply (f : C(α, E)) (a : α) :
(linear_isometry_bounded_of_compact α E 𝕜 f) a = f a :=
rfl
@[simp]
lemma linear_isometry_bounded_of_compact_to_isometric :
(linear_isometry_bounded_of_compact α E 𝕜).to_isometric = (isometric_bounded_of_compact α E) :=
rfl
@[simp]
lemma linear_isometry_bounded_of_compact_to_add_equiv :
(linear_isometry_bounded_of_compact α E 𝕜).to_linear_equiv.to_add_equiv =
(add_equiv_bounded_of_compact α E) :=
rfl
@[simp]
lemma linear_isometry_bounded_of_compact_of_compact_to_equiv :
(linear_isometry_bounded_of_compact α E 𝕜).to_linear_equiv.to_equiv =
(equiv_bounded_of_compact α E) :=
rfl
end
section
variables {𝕜 : Type*} {γ : Type*} [normed_field 𝕜] [normed_ring γ] [normed_algebra 𝕜 γ]
instance [nonempty α] : normed_algebra 𝕜 C(α, γ) :=
{ norm_algebra_map_eq := λ c, (norm_algebra_map_eq (α →ᵇ γ) c : _), }
end
end continuous_map
namespace continuous_map
section uniform_continuity
variables {α β : Type*}
variables [metric_space α] [compact_space α] [metric_space β]
/-!
We now set up some declarations making it convenient to use uniform continuity.
-/
lemma uniform_continuity
(f : C(α, β)) (ε : ℝ) (h : 0 < ε) :
∃ δ > 0, ∀ {x y}, dist x y < δ → dist (f x) (f y) < ε :=
metric.uniform_continuous_iff.mp
(compact_space.uniform_continuous_of_continuous f.continuous) ε h
/--
An arbitrarily chosen modulus of uniform continuity for a given function `f` and `ε > 0`.
-/
-- This definition allows us to separate the choice of some `δ`,
-- and the corresponding use of `dist a b < δ → dist (f a) (f b) < ε`,
-- even across different declarations.
def modulus (f : C(α, β)) (ε : ℝ) (h : 0 < ε) : ℝ :=
classical.some (uniform_continuity f ε h)
lemma modulus_pos (f : C(α, β)) {ε : ℝ} {h : 0 < ε} : 0 < f.modulus ε h :=
(classical.some_spec (uniform_continuity f ε h)).fst
lemma dist_lt_of_dist_lt_modulus
(f : C(α, β)) (ε : ℝ) (h : 0 < ε) {a b : α} (w : dist a b < f.modulus ε h) :
dist (f a) (f b) < ε :=
(classical.some_spec (uniform_continuity f ε h)).snd w
end uniform_continuity
end continuous_map
section comp_left
variables (X : Type*) {𝕜 β γ : Type*} [topological_space X] [compact_space X]
[nondiscrete_normed_field 𝕜]
variables [normed_group β] [normed_space 𝕜 β] [normed_group γ] [normed_space 𝕜 γ]
open continuous_map
/--
Postcomposition of continuous functions into a normed module by a continuous linear map is a
continuous linear map.
Transferred version of `continuous_linear_map.comp_left_continuous_bounded`,
upgraded version of `continuous_linear_map.comp_left_continuous`,
similar to `linear_map.comp_left`. -/
protected def continuous_linear_map.comp_left_continuous_compact (g : β →L[𝕜] γ) :
C(X, β) →L[𝕜] C(X, γ) :=
(linear_isometry_bounded_of_compact X γ 𝕜).symm.to_linear_isometry.to_continuous_linear_map.comp $
(g.comp_left_continuous_bounded X).comp $
(linear_isometry_bounded_of_compact X β 𝕜).to_linear_isometry.to_continuous_linear_map
@[simp] lemma continuous_linear_map.to_linear_comp_left_continuous_compact (g : β →L[𝕜] γ) :
(g.comp_left_continuous_compact X : C(X, β) →ₗ[𝕜] C(X, γ)) = g.comp_left_continuous 𝕜 X :=
by { ext f, refl }
@[simp] lemma continuous_linear_map.comp_left_continuous_compact_apply (g : β →L[𝕜] γ)
(f : C(X, β)) (x : X) :
g.comp_left_continuous_compact X f x = g (f x) :=
rfl
end comp_left
namespace continuous_map
/-!
We now setup variations on `comp_right_* f`, where `f : C(X, Y)`
(that is, precomposition by a continuous map),
as a morphism `C(Y, T) → C(X, T)`, respecting various types of structure.
In particular:
* `comp_right_continuous_map`, the bundled continuous map (for this we need `X Y` compact).
* `comp_right_homeomorph`, when we precompose by a homeomorphism.
* `comp_right_alg_hom`, when `T = R` is a topological ring.
-/
section comp_right
/--
Precomposition by a continuous map is itself a continuous map between spaces of continuous maps.
-/
def comp_right_continuous_map {X Y : Type*} (T : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y] [normed_group T]
(f : C(X, Y)) : C(C(Y, T), C(X, T)) :=
{ to_fun := λ g, g.comp f,
continuous_to_fun :=
begin
refine metric.continuous_iff.mpr _,
intros g ε ε_pos,
refine ⟨ε, ε_pos, λ g' h, _⟩,
rw continuous_map.dist_lt_iff ε_pos at h ⊢,
{ exact λ x, h (f x), },
end }
@[simp] lemma comp_right_continuous_map_apply {X Y : Type*} (T : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y] [normed_group T]
(f : C(X, Y)) (g : C(Y, T)) :
(comp_right_continuous_map T f) g = g.comp f :=
rfl
/--
Precomposition by a homeomorphism is itself a homeomorphism between spaces of continuous maps.
-/
def comp_right_homeomorph {X Y : Type*} (T : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y] [normed_group T]
(f : X ≃ₜ Y) : C(Y, T) ≃ₜ C(X, T) :=
{ to_fun := comp_right_continuous_map T f.to_continuous_map,
inv_fun := comp_right_continuous_map T f.symm.to_continuous_map,
left_inv := by tidy,
right_inv := by tidy, }
/--
Precomposition of functions into a normed ring by continuous map is an algebra homomorphism.
-/
def comp_right_alg_hom {X Y : Type*} (R : Type*)
[topological_space X] [topological_space Y] [normed_comm_ring R] (f : C(X, Y)) :
C(Y, R) →ₐ[R] C(X, R) :=
{ to_fun := λ g, g.comp f,
map_zero' := by { ext, simp, },
map_add' := λ g₁ g₂, by { ext, simp, },
map_one' := by { ext, simp, },
map_mul' := λ g₁ g₂, by { ext, simp, },
commutes' := λ r, by { ext, simp, }, }
@[simp] lemma comp_right_alg_hom_apply {X Y : Type*} (R : Type*)
[topological_space X] [topological_space Y] [normed_comm_ring R] (f : C(X, Y)) (g : C(Y, R)) :
(comp_right_alg_hom R f) g = g.comp f :=
rfl
lemma comp_right_alg_hom_continuous {X Y : Type*} (R : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y]
[normed_comm_ring R] (f : C(X, Y)) :
continuous (comp_right_alg_hom R f) :=
begin
change continuous (comp_right_continuous_map R f),
continuity,
end
end comp_right
end continuous_map
|
lemma isUCont_def: "isUCont f \<longleftrightarrow> (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)"
|
C-----------------------------------------------------------------------
SUBROUTINE SPTEZM(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,WAVE,GRID,IDIR)
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTEZ PERFORM SIMPLE SCALAR SPHERICAL TRANSFORMS
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM PERFORMS SPHERICAL TRANSFORMS
C BETWEEN SPECTRAL COEFFICIENTS OF SCALAR QUANTITIES
C AND FIELDS ON A GLOBAL CYLINDRICAL GRID.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C THE GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C WAVE FIELDS ARE IN SEQUENTIAL 'IBM ORDER'.
C GRID FIELDS ARE INDEXED EAST TO WEST, THEN NORTH TO SOUTH.
C FOR MORE FLEXIBILITY AND EFFICIENCY, CALL SPTRAN.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTEZM(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,WAVE,GRID,IDIR)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRT - INTEGER GRID IDENTIFIER
C (IDRT=4 FOR GAUSSIAN GRID,
C IDRT=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRT=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAX - INTEGER EVEN NUMBER OF LONGITUDES
C JMAX - INTEGER NUMBER OF LATITUDES
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM
C WAVE - REAL (2*MX,KMAX) WAVE FIELD IF IDIR>0
C WHERE MX=(MAXWV+1)*((IROMB+1)*MAXWV+2)/2
C GRID - REAL (IMAX,JMAX,KMAX) GRID FIELD (E->W,N->S) IF IDIR<0
C IDIR - INTEGER TRANSFORM FLAG
C (IDIR>0 FOR WAVE TO GRID, IDIR<0 FOR GRID TO WAVE)
C OUTPUT ARGUMENTS:
C WAVE - REAL (2*MX,KMAX) WAVE FIELD IF IDIR<0
C WHERE MX=(MAXWV+1)*((IROMB+1)*MAXWV+2)/2
C GRID - REAL (IMAX,JMAX,KMAX) GRID FIELD (E->W,N->S) IF IDIR>0
C
C SUBPROGRAMS CALLED:
C SPTRANF PERFORM A SCALAR SPHERICAL TRANSFORM
C NCPUS GETS ENVIRONMENT NUMBER OF CPUS
C
C REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
C DIMENSION LINEAR QUADRATIC
C ----------------------- --------- -------------
C IMAX 2*MAXWV+2 3*MAXWV/2*2+2
C JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
C JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
C JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
C JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
C JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
C JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
C ----------------------- --------- -------------
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C
C$$$
REAL WAVE((MAXWV+1)*((IROMB+1)*MAXWV+2),KMAX)
REAL GRID(IMAX,JMAX,KMAX)
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MX=(MAXWV+1)*((IROMB+1)*MAXWV+2)/2
IP=1
IS=1
JN=IMAX
JS=-JN
KW=2*MX
KG=IMAX*JMAX
JB=1
JE=(JMAX+1)/2
JC=NCPUS()
IF(IDIR.LT.0) WAVE=0
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CALL SPTRANF(IROMB,MAXWV,IDRT,IMAX,JMAX,KMAX,
& IP,IS,JN,JS,KW,KG,JB,JE,JC,
& WAVE,GRID,GRID(1,JMAX,1),IDIR)
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
END
|
#include "simple-expose.h"
#include <boost/python.hpp>
#include <clang/ASTMatchers/ASTMatchers.h>
void expose_simple()
{
using namespace boost::python;
using namespace clang;
using namespace clang::ast_matchers;
using namespace clang::ast_matchers::internal;
def("asString", asString);
def("booleanType", booleanType);
def("containsDeclaration", containsDeclaration);
def("declCountIs", declCountIs);
def("designatorCountIs", designatorCountIs);
def("equalsIntegralValue", equalsIntegralValue);
def("forEachConstructorInitializer", forEachConstructorInitializer);
def("forEachOverridden", forEachOverridden);
def("forEachSwitchCase", forEachSwitchCase);
def("forField", forField);
def("forFunction", forFunction);
def("hasAnyConstructorInitializer", hasAnyConstructorInitializer);
def("hasAnyDeclaration", hasAnyDeclaration);
def("hasAnyUsingShadowDecl", hasAnyUsingShadowDecl);
def("hasArgumentOfType", hasArgumentOfType);
def("hasArraySize", hasArraySize);
def("hasAttr", hasAttr);
def("hasAutomaticStorageDuration", hasAutomaticStorageDuration);
def("hasBase", hasBase);
def("hasBitWidth", hasBitWidth);
def("hasCanonicalType", hasCanonicalType);
def("hasCaseConstant", hasCaseConstant);
def("hasCastKind", hasCastKind);
def("hasConditionVariableStatement", hasConditionVariableStatement);
def("hasDecayedType", hasDecayedType);
def("hasDeclContext", hasDeclContext);
def("hasDefaultArgument", hasDefaultArgument);
def("hasDefinition", hasDefinition);
def("hasDestinationType", hasDestinationType);
def("hasElse", hasElse);
def("hasExternalFormalLinkage", hasExternalFormalLinkage);
def("hasFalseExpression", hasFalseExpression);
def("hasGlobalStorage", hasGlobalStorage);
def("hasImplicitDestinationType", hasImplicitDestinationType);
def("hasInClassInitializer", hasInClassInitializer);
def("hasIncrement", hasIncrement);
def("hasIndex", hasIndex);
def("hasInit", hasInit);
def("hasInitializer", hasInitializer);
def("hasKeywordSelector", hasKeywordSelector);
def("hasLocalQualifiers", hasLocalQualifiers);
def("hasLocalStorage", hasLocalStorage);
def("hasLoopInit", hasLoopInit);
def("hasLoopVariable", hasLoopVariable);
def("hasMethod", hasMethod);
def("hasNullSelector", hasNullSelector);
def("hasQualifier", hasQualifier);
def("hasRangeInit", hasRangeInit);
def("hasReceiver", hasReceiver);
def("hasReceiverType", hasReceiverType);
def("hasReturnValue", hasReturnValue);
def("hasSelector", hasSelector);
def("hasSingleDecl", hasSingleDecl);
def("hasSizeExpr", hasSizeExpr);
def("hasSpecializedTemplate", hasSpecializedTemplate);
def("hasStaticStorageDuration", hasStaticStorageDuration);
def("hasSyntacticForm", hasSyntacticForm);
def("hasTargetDecl", hasTargetDecl);
def("hasThen", hasThen);
def("hasThreadStorageDuration", hasThreadStorageDuration);
def("hasTrailingReturn", hasTrailingReturn);
def("hasTrueExpression", hasTrueExpression);
def("hasTypeLoc", hasTypeLoc);
def("hasUnaryOperand", hasUnaryOperand);
def("hasUnarySelector", hasUnarySelector);
def("hasUnderlyingDecl", hasUnderlyingDecl);
def("hasUnqualifiedDesugaredType", hasUnqualifiedDesugaredType);
def("ignoringImpCasts", ignoringImpCasts);
def("ignoringImplicit", ignoringImplicit);
def("ignoringParenCasts", ignoringParenCasts);
def("ignoringParenImpCasts", ignoringParenImpCasts);
def("isAnonymous", isAnonymous);
def("isAnyCharacter", isAnyCharacter);
def("isAnyPointer", isAnyPointer);
def("isArray", isArray);
def("isBaseInitializer", isBaseInitializer);
def("isBitField", isBitField);
def("isCatchAll", isCatchAll);
def("isClass", isClass);
def("isConst", isConst);
def("isConstQualified", isConstQualified);
def("isCopyAssignmentOperator", isCopyAssignmentOperator);
def("isCopyConstructor", isCopyConstructor);
def("isDefaultConstructor", isDefaultConstructor);
def("isDefaulted", isDefaulted);
def("isDelegatingConstructor", isDelegatingConstructor);
def("isDeleted", isDeleted);
def("isExceptionVariable", isExceptionVariable);
def("isExpr", isExpr);
def("isImplicit", isImplicit);
def("isInstanceMessage", isInstanceMessage);
def("isInstantiated", isInstantiated);
def("isInstantiationDependent", isInstantiationDependent);
def("isInteger", isInteger);
def("isIntegral", isIntegral);
def("isInTemplateInstantiation", isInTemplateInstantiation);
def("isLambda", isLambda);
def("isListInitialization", isListInitialization);
def("isMain", isMain);
def("isMemberInitializer", isMemberInitializer);
def("isMoveAssignmentOperator", isMoveAssignmentOperator);
def("isMoveConstructor", isMoveConstructor);
def("isNoReturn", isNoReturn);
def("isOverride", isOverride);
def("isPrivate", isPrivate);
def("isProtected", isProtected);
def("isPublic", isPublic);
def("isPure", isPure);
def("isScoped", isScoped);
def("isSignedInteger", isSignedInteger);
def("isStaticLocal", isStaticLocal);
def("isStruct", isStruct);
def("isTypeDependent", isTypeDependent);
def("isUnion", isUnion);
def("isUnsignedInteger", isUnsignedInteger);
def("isUserProvided", isUserProvided);
def("isValueDependent", isValueDependent);
def("isVariadic", isVariadic);
def("isVirtualAsWritten", isVirtualAsWritten);
def("isVirtual", isVirtual);
def("isVolatileQualified", isVolatileQualified);
def("isWritten", isWritten);
def("matchesName", matchesName);
def("matchesSelector", matchesSelector);
def("member", member);
def("namesType", namesType);
def("nullPointerConstant", nullPointerConstant);
def("numSelectorArgs", numSelectorArgs);
def("ofClass", ofClass);
def("ofKind", ofKind);
def("onImplicitObjectArgument", onImplicitObjectArgument);
def("on", on);
def("realFloatingPointType", realFloatingPointType);
def("refersToDeclaration", refersToDeclaration);
def("refersToIntegralType", refersToIntegralType);
def("refersToTemplate", refersToTemplate);
def("refersToType", refersToType);
def("requiresZeroInitialization", requiresZeroInitialization);
def("returns", returns);
def("specifiesNamespace", specifiesNamespace);
def("specifiesTypeLoc", specifiesTypeLoc);
def("specifiesType", specifiesType);
def("statementCountIs", statementCountIs);
def("throughUsingDecl", throughUsingDecl);
def("to", to);
def("usesADL", usesADL);
def("voidType", voidType);
def("withInitializer", withInitializer);
def("alignOfExpr", alignOfExpr);
def("hasEitherOperand", hasEitherOperand);
def("hasName", hasName);
def("sizeOfExpr", sizeOfExpr);
Matcher<Decl> (*equalsNode_1)(const Decl* const&) = equalsNode;
Matcher<Stmt> (*equalsNode_2)(const Stmt* const&) = equalsNode;
Matcher<Type> (*equalsNode_3)(const Type* const&) = equalsNode;
def("equalsNode", equalsNode_1);
def("equalsNode", equalsNode_2);
def("equalsNode", equalsNode_3);
Matcher<NestedNameSpecifier> (*hasPrefix_1)(const Matcher<NestedNameSpecifier>&) = hasPrefix;
Matcher<NestedNameSpecifierLoc> (*hasPrefix_2)(const Matcher<NestedNameSpecifierLoc>&) = hasPrefix;
def("hasPrefix", hasPrefix_1);
def("hasPrefix", hasPrefix_2);
Matcher<CXXMemberCallExpr> (*thisPointerType_1)(const Matcher<QualType>&) = thisPointerType;
Matcher<CXXMemberCallExpr> (*thisPointerType_2)(const Matcher<Decl>&) = thisPointerType;
def("thisPointerType", thisPointerType_1);
def("thisPointerType", thisPointerType_2);
Matcher<QualType> (*references_1)(const Matcher<QualType>&) = references;
Matcher<QualType> (*references_2)(const Matcher<Decl>&) = references;
def("references", references_1);
def("references", references_2);
Matcher<QualType> (*pointsTo_1)(const Matcher<QualType>&) = pointsTo;
Matcher<QualType> (*pointsTo_2)(const Matcher<Decl>&) = pointsTo;
def("pointsTo", pointsTo_1);
def("pointsTo", pointsTo_2);
Matcher<CallExpr> (*callee_1)(const Matcher<Stmt>&) = callee;
Matcher<CallExpr> (*callee_2)(const Matcher<Decl>&) = callee;
def("callee", callee_1);
def("callee", callee_2);
Matcher<CXXRecordDecl> (*isSameOrDerivedFrom_1)(const Matcher<NamedDecl>&) = isSameOrDerivedFrom;
Matcher<CXXRecordDecl> (*isSameOrDerivedFrom_2)(const std::string&) = isSameOrDerivedFrom;
def("isSameOrDerivedFrom", isSameOrDerivedFrom_1);
def("isSameOrDerivedFrom", isSameOrDerivedFrom_2);
Matcher<QualType> (*ignoringParens_1)(const Matcher<QualType>&) = ignoringParens;
Matcher<Expr> (*ignoringParens_2)(const Matcher<Expr>&) = ignoringParens;
def("ignoringParens", ignoringParens_1);
def("ignoringParens", ignoringParens_2);
BindableMatcher<TypeLoc> (*loc_1)(const Matcher<QualType>&) = loc;
BindableMatcher<NestedNameSpecifierLoc> (*loc_2)(const Matcher<NestedNameSpecifier>&) = loc;
def("loc", loc_1);
def("loc", loc_2);
}
|
import Pkg
Pkg.instantiate() # downloads all dependencies for the current project
using DataFrames, CSV, StatsBase
df = CSV.read("../externals/Core.Math.Data/data/Pejcic_318.csv", copycols = true)
println(corspearman(df.ATV, df.ATT))
|
\setvariables[article][shortauthor={Goffe}, date={December 2020}, issue={5}, DOI={https://doi.org/10.7916/archipelagos-72th-0z19}]
\setupinteraction[title={Unmapping the Caribbean: Toward a Digital Praxis of Archipelagic Sounding},author={Tao Leigh Goffe}, date={December 2020}, subtitle={Unmapping the Caribbean}]
\environment env_journal
\starttext
\startchapter[title={Unmapping the Caribbean: Toward a Digital Praxis of Archipelagic Sounding}
, marking={Unmapping the Caribbean}
, bookmark={Unmapping the Caribbean: Toward a Digital Praxis of Archipelagic Sounding}]
\startlines
{\bf
Tao Leigh Goffe
}
\stoplines
{\startnarrower\it Tackling the conceptual grounds of how maps have been deployed as tools of imperial capitalist extraction, this essay critiques how the two-dimensional visualization of land has traditionally flattened the racial entanglement of the Caribbean archipelago. It explores how born-digital cartography can be used to open up a new sensory possibility for understanding space amplified by sonic and video technologies. The author embarked on the digital project {\em Unmapping the Caribbean} with her students and a team of technologists, employing Esri's ArcGIS Story Maps platform to examine the contours of {\em marronage} and indigeneity in five geographies: New York City, Suriname, Hispaniola, Cuba, and Jamaica. The project anchors the relationality of sedimented racial histories in the archipelago through the concept of \quotation{unmapping}---that is, by creating digital audiovisual story maps of the five Caribbean spaces. Centering the way sound orients the human body in space, the project examines the politics of the opacity of spaces of black and indigenous refuge in Caribbean and Caribbean diasporic communities. The essay considers the pedagogical stakes of collaborative digital assignments that include mapmaking and producing visual soundtracks. The five geographic narratives that {\em Unmapping the Caribbean}~has woven together are part of an ongoing project that aims to articulate archipelagic being. \stopnarrower}
\blank[2*line]
\blackrule[width=\textwidth,height=.01pt]
\blank[2*line]
\startblockquote
You will find a way.
\stopblockquote
\startalignment[flushright]
\tfx{Jamaican police officer on motorbike giving directions in Mandeville, 2014}
\stopalignment
\blank[2*line]
The literary and sonic traditions of the archipelago are equally critical to Caribbean study. The musical soundtrack of island life is inseparable from studying the radical political tradition of the region, and I center this approach in a course I have been teaching since 2015 titled Caribbean Writing, Reggae, and Routes. Vernacular oral traditions trace the roots and routes of the Caribbean and its diaspora to Africa, Asia, and Europe. Each year that I teach the course, music and the sounds of natural and built environments become more essential to the argument of Caribbean critical theory and much more than an accompaniment to novels and poetry featured on the syllabus. In the course, which is both born-digital and born-musical, students annotated literature and songs using online platforms in the first iteration in 2015.\footnote{Students use Genius (formerly RapGenius) and SoundCloud. See \quotation{About Genius,} Genius, \useURL[url2][https://genius.com/Genius-about-genius-annotated]\from[url2]; and \quotation{About SoundCloud,} SoundCloud, \useURL[url3][https://soundcloud.com/pages/contact]\from[url3].} The course has become more digitally and musically engaged as I have encouraged students to produce their own soundtracks, embedding them in maps in a practice I call \quotation{sonic un/mapping.} This multisensorial method of reading the Caribbean archipelago attunes a spatial awareness. Sonic analysis requires attention to the spatial because sound is quite literally how our ears perceive the vibrations that bounce off our environment. As such, my sonic praxis has become amplified by digital geographic technologies.
As a professor and a DJ, a \quotation{PhDJ,} I see the role of an educator as one intimately tied to that of a DJ. The \useURL[url4][https://caribbeanliterature.princeton.edu/][][syllabus]\from[url4] is a mixtape---I narrate the progression of texts on a syllabus, almost toasting, to introduce and string together a line of thought about Caribbean artistic and political expression.\footnote{For the course syllabus, see \useURL[url5][https://caribbeanliterature.princeton.edu/]\from[url5].} Reggae songs are integral, and each week I ask students to choose a song connected to the readings on the syllabus to form a collective weekly playlist, housed on our course blog. Students are required to write a few sentences explaining the reasoning for their choice, be it thematic or affective.
Recognizing the limitations of close reading, in how it assumes a text has an inherent transparency, we instead perform a practice of deep listening. This involves a multisensorial receptivity through the practice of what Audre Lorde calls \quotation{deep participation.}\footnote{Audre Lorde, \quotation{Uses of the Erotic: The Erotic as Power,} in {\em Sister Outsider: Essays and Speeches} (Berkeley, CA: Crossing, 1984), 59.} It also involves the receptivity that Julian Henriques describes as a spatial way of knowing, foundational, for instance, to dancehall culture in Jamaica.\footnote{See Julian Henriques, \quotation{Preamble: Thinking Through Sound,} introduction to {\em Sonic Bodies: Reggae Sound Systems, Performance Techniques, and Ways of Knowing} (New York: Continuum, 2011), xv--xxxvi, \useURL[url6][http://research.gold.ac.uk/id/eprint/4257/1/HenriquesSonicBodiesIntro.pdf]\from[url6].} Attention to sound and where it places the body in space is an intimate part of what I am calling \quotation{unmapping.} For example, Little Roy's sonic exegesis in the song \quotation{Christopher Columbus} poses a challenge to coloniality and Western historiography. Little Roy describes the multiple voyages of Columbus to the Caribbean---\quotation{Him come again and go away}---and says that Natty Rasta, the black man, was metaphysically in the Caribbean long before Columbus.\footnote{Little Roy and Ian Rock, \quotation{Christopher Columbus,} 45rpm single, Tafari, 1975.} Politicizing Afro-Jamaican identity in ways that engage with what Jamaican theorist Sylvia Wynter has conceptualized as {\em indigenization}, Little Roy \quotation{unmaps} the Caribbean, challenging the fixity of Columbus's colonial map through a sonic and lyrical reordering of time and space.\footnote{On {\em indigenization}, see Sylvia Wynter, \quotation{Jonkonnu in Jamaica: Towards the Interpretation of Folk Dance as a Cultural Process,} {\em Jamaica Journal} 4, no. 2 (1970): 34--48.}
In our sonic un/mapping in my course, I ask students to think about how they would map Babylon as a geographic, historic, and imagined place in the context of reggae lyrics. Similarly, I ask them to think about the intertextuality of reggae and Rastafari to the Hebrew Bible and the Christian Testament. Where is the Zion that Kiddus I sings of in \quotation{Graduation in Zion}? We also explore urban spatial politics through the more literal and lyrical mapping of Kingston that Bob Marley performs in \quotation{Natty Dread} by walking through First Street and Second Street, and so on. Then we look to his son Damian Marley's survey of the island in \quotation{Welcome to Jamrock,} and how he sings a refrain that hails each county of Jamaica---Cornwall, Middlesex, and Surrey---delineating a geography that the island postcolony reclaims from the English counties it mirrors.\footnote{Kiddus I, \quotation{Graduation in Zion,} Shepherd, 1977; Bob Marley and the Wailers, \quotation{Natty Dread,} on {\em Natty Dread}, Island Records, 1974; Damian \quotation{Jr.~Gong} Marley, \quotation{Welcome to Jamrock,} on {\em Welcome to Jamrock}, Universal Records, 2005.}
Reggae and dub are as much about unfinished spatial mapping as about cosmic awareness and cosmological mapping. Music is the argument of unmapping. Sound, like light, is energy comprised of waves, a series of perceived reflections and refractions that orient us in time and space. Sound reflects our relation to other bodies and objects. This sonic data is central to a poetic strategy that I call \quotation{decolonial echolocation}---a method of bodily knowing, a somatosensory epistemology of embodied navigation of coloniality for those who were not mean to survive. It is the diasporic physiological process of sensing distant or invisible objects by sound waves emitted back to the emitter, to draw on the dictionary definition of {\em echolocation}.
The map is engraved with the echo of runaway desire, of refusal, in place names like the District of Look Behind, Don't Come Back, and Quick Step. A decolonial register would imply a strategy of detecting the colonizer and finding spaces of refuge. This refuge is encoded in both reggae music and Rastafarian ontology. Rastafari, which Stuart Hall describes as an \quotation{imagined community} formed with an Africa that has moved on but is nevertheless symbolically reconstructed in music, is a form of worlding and navigation beyond coloniality, never quite intended as a literal return to Africa. Echolocation resonates with music as integral to the archipelagic being of Jamaican reggae artist Chronixx when he sings of \quotation{capture land.} It is the replantation of the provision grounds that Wynter describes at the periphery of the colonial plantation.\footnote{See Stuart Hall, \quotation{Negotiating Caribbean Identities,} {\em New Left Review}, no. 209 (January--February 1995): 11; Chronixx, \quotation{Capture Land,} on {\em Dread and Terrible}, Soul and Circle Music, 2014; and Sylvia Wynter, \quotation{Novel and History, Plot and Plantation,} {\em Savacou}, no. 5 (June 1971): 95--102.} The echoes that reverberate through the karstic mountainous terrain of Jamaica's Cockpit Country and Blue Mountains are an intimate part of Caribbean geography that narrates the meaning of refuge for black and native peoples on the island.
To geolocate Caribbean space through literature and music is to chart archipelagic being. It decenters ocularcentric forms of knowledge production and the written word. Archipelagic being attunes one to the power of {\em other} senses to orient oneself in space. Sound---in particular, how we receive certain frequencies---engages the sensorium in a way that is central to a Caribbean vestibular sensibility.
Unmapping as a digital praxis embraces the opacity of sensory disorientation. If mapping is about knowing and surveying, then unmapping is about unknowing and uncharting the territory. To welcome not knowing allows one to be receptive to other forms of knowledge. The West Indies are, after all, a misnaming, so why continue to depend on a Columbian geographic misrecognition for reading the archipelago? The colonial map obscures this dialectic between Wynter's indigenization and Kamau Brathwaite's creolization by enforcing European geography on the archipelago.\footnote{See Edward Kamau Brathwaite, {\em Contradictory Omens: Cultural Diversity and Integration in the Caribbean} (Mona: Savacou, 1974).} Toward unmapping, I challenge my students to consider a spatial politics centering spaces of Caribbean refuge carved out by indigenous peoples and Maroons across the archipelago. Some clues are embedded in place names, but again, music becomes central, especially for examining the hidden African presence indigenized in the landscape. Unmapping therefore challenges the myth of extinction in favor of intentional Caribbean opacity, in the Glissantian register.\footnote{Édouard Glissant argues for \quotation{the right to opacity}; see his {\em Poetics of Relation}, trans. Betsy Wing (Ann Arbor: University of Michigan Press, 1997).}
The Caribbean archipelago was formed through a process of layering that I have elsewhere described as \quotation{racial sedimentation.}\footnote{See Tao Leigh Goffe, \quotation{\quote{Guano in Their Destiny}: Race, Geology, and a Philosophy of Indenture,} {\em Amerasia Journal} 45, no. 1 (2019): 27--49{\em .} See also Tiffany Lethabo King, {\em The Black Shoals: Offshore Formations of Black and Native Studies} (Durham, NC: Duke University Press, 2019); Manu Karuka, {\em Empire's Tracks: Indigenous Nations, Chinese Workers, and the Transcontinental Railroad} (Berkeley: University of California Press, 2019); and Iyko Day, {\em Alien Capital: Asian Racialization and the Logic of Settler Colonial Capitalism} (Durham, NC: Duke University Press, 2016), all of which rigorously tackle the relationality of settler colonialism in forms that decenter whiteness.} I argue that the sedimented presences settle and become transformed in metamorphic rock in accordance with the geological metaphor of the rock cycle.\footnote{Trinidad and Tobagoan-born Canadian author Dionne Brand, for instance, takes up these questions in {\em A Map to the Door of No Return}, and Canadian scholar of black geographies Katherine McKittrick writes of {\em demonic} grounds, invoking Wynter's provision grounds. See Dionne Brand, {\em A Map to the Door of No Return: Notes to Belonging} (Toronto: Vintage Canada, 2001); and Katherine McKittrick, {\em Demonic Grounds: Black Women and the Cartographies of Struggle} (Minneapolis: University of Minnesota Press, 2006).} The materiality of bodies, bones, and decomposing biomatter have become part of the geology of the archipelago over the centuries since Columbus's invasion. Mutilation has made the Caribbean the site of, according to Hortense Spillers, a \quotation{human sequence written in blood.}\footnote{Hortense J. Spillers, \quotation{Mama's Baby, Papa's Maybe: An American Grammar Book,} {\em Diacritics} 17, no. 2 (1987): 67.} Maroon strategies of warfare, especially guerilla warfare, against the British in Jamaica depended on the cover the rainforest provided, and locations in Cockpit Country are accordingly named to reflect these battles. I task my students with examining how the topography of the Caribbean---its crags, its valleys, its mountains, its caves, its ravines---has provided refuge. I wanted to design a digital platform that could represent distinct racialized copresences and coproductions enmeshed through settlement. If, as historian Vincent Brown writes, we ought to consider {\em marronage} as a species of West African warfare, then what are the political stakes of a map that speaks or sings in Maroon vernaculars?\footnote{See Vincent Brown, {\em Tacky's Revolt: The Story of an Atlantic Slave War} (Cambridge, MA: Bellknap, 2020).}
\subsection[title={Committing Treason with the Master's Tools},reference={committing-treason-with-the-masters-tools}]
In 2018, I embarked on the digital project \useURL[url7][https://nyuds.maps.arcgis.com/apps/MapSeries/index.html?appid=489f1aee6b324a75b709d5d37f0cea2a][][{\em Unmapping the Caribbean: Sanctuary and Sound}]\from[url7] with my students and a team of technologists.\footnote{See {\em Unmapping the Caribbean: Sanctuary and Sound}, \useURL[url8][https://nyuds.maps.arcgis.com/apps/MapSeries/index.html?appid=489f1aee6b324a75b709d5d37f0cea2a]\from[url8].} As a method, unmapping challenges the fixity of the map as a technology of colonial organization. As a medium, I used \useURL[url9][https://storymaps.arcgis.com/][][ArcGIS Story Maps]\from[url9],\footnote{See \quotation{ArcGIS Story Maps,} Esri, \useURL[url10][https://storymaps.arcgis.com/]\from[url10].} a cloud-based platform by international geographic information system (GIS) software supplier Esri (Environmental Systems Research Institute), and, in light of our decolonial mission, there were necessarily many limitations and ethical concerns with which to contend. Founded in 1969 as a land-use consulting firm, US-based Esri evolved into a GIS software vendor embedded in the history of US military defense digital technology, holding contracts with the US Department of Defense. As a global tech company, Esri perhaps typifies, to reference Audre Lorde's famous provocation, the \quotation{master's tools}---that is, the structure of the ongoing colonial present.\footnote{See Audre Lorde, \quotation{The Master's Tools Will Never Dismantle the Master's House,} in {\em Sister Outsider}, 110--13.} But I knew that the technologists helping with the project had the most proficiency with this platform because of the contracts Esri had with the university where I worked.
\useURL[url11][https://storymaps-classic.arcgis.com/en/][][Esri Story Maps]\from[url11] describes its educational mission as a strategy of digital storytelling by and through graphic organization.\footnote{See \quotation{Classic Story Maps,} Esri, \useURL[url12][https://storymaps-classic.arcgis.com/en/]\from[url12].} The platform hosts maps that users can design themselves using the Esri database. But a project need not actually be a map---the emphasis is on narrative, which is why I find it so appealing. Esri is essentially a platform for presenting graphic, multimedia information, into which ArcGIS maps can be easily integrated, if you so choose. Another reason I used Esri Story Maps is its accessibility---both in the ease of not needing to download or install a program, since it runs online, and in being able to reach it through mobile devices. Since starting the {\em Unmapping} project, I began a new job at a university, and while it also has a contract with Esri, the platform is not for use by large numbers of students. As such, I am in the process of devising new forms of unmapping that will engage XR (extended reality), which includes mixed reality, open-source AR (augmented reality), and VR (virtual reality) tools such as Unity. The digital amplifies the prospect for a cartographic synesthesia, which is why the potential of embedding digitized sound and video offers so many narrative and epistemological possibilities.
The transparency that military technologies prioritize for the purpose of warfare and seizing dominion is the antithesis of my goal for reading the archipelago. My digital praxis instead employs a cartographic approach to Glissantian opacities---that is, to what remains unknown and unknowable about the Caribbean. My hope is that modes of storytelling can be enhanced experientially through a digital sensorium, a range of audiovisual features that lead to an immersive experience. The body is a geography of inheritances, knowledges, and intuitions that military technologies will never comprehend. With its arteries, veins, and capillaries; its curves; its wrinkles---the body is a terrain, unmapped and unmappable. Thus as someone of Caribbean descent, I began with my body, literally using my hand to anchor the project. I sought to locate the affective mutual coordinates of the \quotation{intimacies} of Africa, Asia, and Europe in the Caribbean.\footnote{See Lisa Lowe, \quotation{The Intimacies of Four Continents,} in Ann Laura Stoler, ed., {\em Haunted by Empire: Geographies of Intimacy in North American History} (Durham, NC: Duke University Press, 2006).}
The first European map of the Caribbean, a 1492--93 drawing by Christopher Columbus, amounts to a few squiggles and splotches of ink (fig.~1). It approximates the curve of the coast of what he would name the Insula hispana, which Bartolomé de las Casas renamed Española. The island is the epicenter, the first place of disembarking, the cradle. I find Columbus's map inscribed with playful desire and possibility---as much a fantasy as a tool of navigation for further colonial conquest. The ways Haiti and the Dominican Republic are peripheral to the map of \quotation{America,} even though Columbus never stepped foot on the mainland, then become a conundrum of hemispheric mapmaking origins. In my process of unmapping, I was led to a later map of Hispaniola, dating to the mid-sixteenth century, that had been drafted by Italian geographer Giovani. Columbus's squiggles had become solidified in a cartographic imaginary practice that sought to \quotation{know} as much as it sought to claim the island for European powers.
\placefigure{West Indies, Christopher Columbus, 1492--93}{\externalfigure[images/goffe/fig1.jpg]}
For the {\em Unmapping} project, I challenged my students to unmap five Caribbean locations---Hispaniola, New York City, Suriname, Cuba, and Jamaica---through sound and attention to the body. I began the semester by juxtaposing analog and digital processes of mapping, asking each student to draw a freehand map of the Caribbean from memory. Most were exasperated by the challenge, realizing that they were far more familiar with the geography of Western Europe than with that of the Caribbean, despite the latter's more relative geographic proximity to the United States. Students who were of Caribbean origin expressed shame at having only \quotation{a sense} of the geography of their homelands.
\placefigure{Maps from Memory}{\externalfigure[images/goffe/fig2.jpg]}
Students began to question whether Guyana, Venezuela, and Bermuda are part of the Caribbean (I did not answer these questions until the activity was over and we had considered the multiplicity of definitions of archipelagic space as well as the imperial positionality implicit in our studying the region from New York). Some of the hand-drawn maps featured only Jamaica or Cuba; others depicted Haiti and the Dominican Republic not on Hispaniola but as separate islands (fig.~2). While many showed south Florida, none included New York City, where, as of 2013, roughly a quarter of the residents were of Caribbean origin.\footnote{Arun Peter Lobo and Joseph J. Salvo, \quotation{Growth and Composition of the Immigrant Population,} in {\em The Newest New Yorkers: Characteristics of the City's Foreign-Born Population} (New York: City of New York, Department of City Planning, and Office of Immigrant Affairs, 2013), 13, \useURL[url13][https://www1.nyc.gov/assets/planning/download/pdf/data-maps/nyc-population/nny2013/nny_2013.pdf]\from[url13].} No maps featured Suriname, the former Dutch colony that is part of the South American landmass; none of my students had even heard of the country, much less the language, Sranan Tongo, or the music, {\em kaseko}. For this reason, I chose to use my hand to visually represent our five disparate but joined geographies---five separate \quotation{fingers,} part of one \quotation{hand.} I projected Battista Ramusio's mid-sixteenth-century map onto my hand to juxtapose the materiality of the body and the epistemic violence the map inscribes on flesh. My palm anchored the inquiry into the archipelagic and served as a starting point for unmapping, a palmistry of wayfinding (fig.~3).
\placefigure{You Will Find a Way}{\externalfigure[images/goffe/fig3.jpg]}
I split the nineteen students into five groups and assigned each a location---I then challenged them to consider how each Caribbean space troubles the concept of the archipelago. The students exploring Suriname, for example, reckoned with the Dutch Empire, which often gets overlooked in the anglophone context. They contrasted the transparency of the paved roadways of the port city Paramaribo with the geographic opacity of the rainforest interior, parts of which are accessible only by small private planes. I taught them about how the Netherlands traded North New Amsterdam, now New York, for the South American New Amsterdam of Suriname because it was a sugar colony. New York, arguably a Caribbean city of the global North, is its own archipelago of forty-odd islands. On Hispaniola, the linguistic, cultural, and racial fracturings between Haiti and the Dominican Republic are as much a barrier as they are spaces of fluid musical exchange. Cuba has existed under a state of economic embargo and technological isolation that forms an opacity of exclusion by the United States, the communist nation's punishment for its refusal to acquiesce to the US geopolitical domination in the hemisphere. The students exploring Jamaica centered the global flows of reggae and how these are entangled with tourism and ecological degradation. Based on the students' research, I used Esri's \quotation{Map Series} template to stitch together five story maps to form one cohesive project with five tabs. Attention to the sensorium is amplified by the digital, insofar as multiple registers can be experienced at once on a story maps. It was important that the students understand how these disparate geographies connected to each other to form one archipelago, a chain of Caribbean/diasporic thought.
By anchoring these disparate geographies on my hand, I wanted students to consider the significance of the body in colonizing and mapping. I turned the image of the map superimposed on my hand into a postcard and wrote a message from the diaspora to an imagined addressee named X---a love letter of longing---which I then submitted to \useURL[url14][https://mina-loy.com/endehorsgarde/][][Post(card)s from the "en dehors garde]\from[url14]," a digital project on the feminist website {\em Mina Loy: Navigating the Avant-Garde} (fig.~4). The project collaborators had invited artists, writers, and scholars to write postcards expressing ideas about the {\em en dehors garde}, a term they had coined to describe the women, people of color, and others marginalized in or excluded from histories and theories of the avant-garde. They arranged seventy postcards on the website, curated together as a \useURL[url15][https://mina-loy.com/chapters/avant-garde-theory-2/digital-flash-mob/][][digital flash mob]\from[url15].\footnote{See \quotation{Post(card)s from the \quote{en dehors garde,}} MinnaLoy.com, https://mina-loy.com/endehorsgarde/. The digital flash mob is here: \useURL[url16][https://mina-loy.com/chapters/avant-garde-theory-2/digital-flash-mob/]\from[url16].} I later adapted my postcard as the landing page for {\em Unmapping the Caribbean}. Thus we began our joint unmapping quest---one professor, nineteen students, and three technologists.\footnote{The students whose assistance has been invaluable to {\em Unmapping the Caribbean} are Moriah Dowd, Zainab Floyd, Sophia Gumbs, Awura Gyimah, Harmony Hemmings-Pallay, Elliot Levy, Efosi Litombe, Naomi Malcolm, Matthew Martinez, Michelle Mawere, Kevwe Okumakube, Massiel Perez, Amodhya Samarakoon, Jesse Sgambati, Tatyana Tandanpolie, Mahalet Tegenu, Eva Toscanos, Hawau Touray, and Xiaolong Woods. Throughout the narrative I link them to specific parts of the project.}
\placefigure{Dear X}{\externalfigure[images/goffe/fig4.png]}
Once the base maps were created, students then meditated on global positioning system (GPS) technologies to consider how a Caribbean GPS might position our five locations. Geographic information systems (GIS) technologies such as Google Maps center individuals: for the first time in human history the center of the map is always the self. I asked students to grapple with what that could mean for a region like the Caribbean, which has been rendered peripheral for so long, despite its being the epicenter of Columbus's destruction. I also asked students to reckon with the power of opacity, of being off the bureaucratic map, of being undetectable, unmappable.
Western maps are often developed and explicitly deployed as tools of capitalist extraction invested in rendering colonial knowledge transparent, and also as ways of marketing, surveying, and making the land knowable and thus safe for tourists to consume. It is not incidental that gas station maps are a genre of petro-capitalist extractivism, considering the petrochemical infrastructure of Esso, Shell, and British Petroleum. These maps occlude the irrevocable ecological damage caused by Big Oil as well as the political violence of extraction and refinement of fossil fuels in Trinidad, Venezuela, and now Guyana and the ways these processes disproportionately threaten Maroon and indigenous communities. But there are other types of maps, even maps containing secret codes. There are Native Australian and Maori maps, for instance, made from tree bark and in the shape of animals, or maps that are guides to navigating waves at certain times of the day. Black and indigenous navigation knowledge production of this sort is precisely what I wanted my students to model in their design.
\subsection[title={Me-no-Sen-You-no-Come: On Opacity and the Impossibility of Mapping},reference={me-no-sen-you-no-come-on-opacity-and-the-impossibility-of-mapping}]
There are Caribbean spaces of refuge that evade the colonial order. I read this refusal---this Glissantian declaration of the right to opacity---in the place name Me-no-Sen-You-no-Come.\footnote{See Kei Miller, {\em The Cartographer Tries to Map a Way to Zion} (Manchester, UK: Carcanet, 2014). Miller's series of poems relay a conversation between a colonial mapmaker and a Rastafarian that includes musings on toponymy and on the narratives inscribed in the maps of the Caribbean. The attempt signaled by the word {\em tries} in the title is key: Miller's cartographer will never be able to map or reach Zion, a place of refuge and salvation as much for the Israelites as for Rastafarians.} This now-extinct village settlement was established and named by runaways fleeing enslavement on plantations in the parish of Trelawny in 1812.\footnote{See B. W. Higman and B. J. Hudson, {\em Jamaican Place Names} (Kingston: University of the West Indies Press, 2009).} Located in the District of Look Behind, the town thrived until emancipation in the mid-1830s. Me-no-Sen-You-no-Come came under siege by the British in 1824 and then by the Maroons of Accompong Town, yet the settlement survived with up to as many as sixty resident runaway peoples into the 1820s. It might at first seem that Maroons would have been natural allies for other runaways, but because of Maroon leader Cudjoe's 1736 land treaty with the British, Jamaican Maroons were supposed to return non-Maroon runaways to British plantations. To find Me-no-Sen-You-no-Come would require an archipelagic wayfaring and wandering, a kind of intellectual Glissantian errantry.
In many ways, just as the Caribbean refuses to be known to the colonial authority, it refuses to be mapped. It is an aqueous and geological geography of mangroves, caves, and coral reefs that cannot be surveyed and conquered entirely. I asked my students to embrace this impossibility.\footnote{During this time, I discovered my colleague Mimi Onuoha's course Impossible Maps at New York University, New York, New York, in which she is asking similar questions. See \useURL[url17][https://github.com/MimiOnuoha/Impossible-Maps]\from[url17].} I assigned excerpts of feminist scholar Macarena Gomez-Barris's {\em The Extractive Zone}, encouraging students to consider what should {\em not} be mapped. Gomez-Barris describes her work as proceeding from a decolonial femme methodology, \quotation{a mode of porous and undisciplined analysis shaped by the perspective and critical genealogies that emerge within these spaces as a mode of doing research{\em .}}\footnote{Macarena Gomez-Barris, {\em The Extractive Zone: Social Ecologies and Decolonial Perspectives} (Durham, NC: Duke University Press, 2017), xvi.} Gomez-Barris's meditation on opacity as a shield, a form of resistance to extractivist geospatial technologies, illuminated for students how mapping was a thorny endeavor, especially for indigenous communities of the Amazon. These technologies can never be truly disentangled from the visuality and transparency of coloniality.
Ethical mapping is a question of how to show the way to those with good intentions. Me-no-Sen-You-no-Come is unequivocal in this regard: If I do not send for you, you will never find your way here. The place name has its own opacity. Black feminist historian Tina Campt poignantly defines {\em opacity} as a type of refusal, different from resistance in that it can involve at-times-subtle tactics of performing illegibility and inaction as a form of defiance.\footnote{See Tina Campt, \quotation{Black Visuality and the Practice of Refusal,} {\em Women and Performance} 29, no. 1 (2019): 79--87, \useURL[url18][https://www.womenandperformance.org/ampersand/29-1/campt]\from[url18].} The place name Me-no-Sen-You-no-Come signifies a fleeting moment of freedom before freedom was formalized in 1834. The runaways who settled there mattered enough to be inscribed on the colonial map. In the patwa inflection of dashes in the village's name, I hear the shorthand rhythm of the lilt of \quotation{nation language,} of creole Caribbean tongues.\footnote{On \quotation{nation language,} see Kamau Brathwaite, \quotation{History of the Voice,} in {\em Roots} (Ann Arbor: University of Michigan Press, 1993), 259--304.} The land refuses in defiance. The toponymy commands. The symmetry and pace of the patwa phrase says something altogether mystical, distinct from what would be the literal English (mis)translation, \quotation{If I do not send for you, you do not come.} The Jamaican phrase is clear and concise. It declares how {\em you} can act toward {\em me}. It declares the right to not be touched, the right to be left alone.\footnote{See Hortense Spillers, \quotation{To the Bone: Some Speculations on Touch} (presented at the Gerrit Rietveld Academie conference \quotation{Hold Me Now---Feel and Touch in an Unreal World,} Stedelijk Museum Amsterdam, 23 March 2018), \useURL[url19][https://www.youtube.com/watch?v=AvL4wUKIfpo]\from[url19].}
My unmapping project was inspired by travels to the Caribbean. It is a place I will always feel disjointed from, having been born in the metropole, London. In 2017 I visited the Windsor Caves in Cockpit Country, not far from Me-No-Sen-You-No-Come, where I experienced the chilling majesty of thousands of bats cascading from the cave at dusk.\footnote{In 2017, I was hosted by Susan Koenig and Sugar Belly of the Windsor Research Centre, where I was able to lodge and from where I was led on a tour of bat caves in search of guano. Several years prior, I had researched guano in relation to Ian Fleming's 1958 James Bond novel {\em Dr.~No}, which centers on a guano island called Crab Key. See Tao Leigh Goffe, \quotation{007 versus the Darker Races: The Black and Yellow Peril in {\em Dr.~No},} {\em Anthurium} 12, no. 1 (2015), article 5, \useURL[url20][http://doi.org/10.33596/anth.280]\from[url20].} They flew past my face, dodging and diving elegantly, screeching, swiftly flying out of a cold cave, their space of refuge, a cathedral of shelter from the rays of sunlight during the day. Bats have an intimate way of knowing, of hearing, of navigating by ultrasound beyond the range of the human ear. Sylvia Wynter considers this fact in \quotation{Towards the Sociogenic Principle,} describing Thomas Nagel's description of the consciousness and being of bat sonar, the way the mammals form three-dimensional forward perception beyond human vocabulary. Bats are fundamentally alien to us, she says, and there is no reason to imagine they perceive the world as we do.\footnote{See Sylvia Wynter, \quotation{Towards the Sociogenic Principle: Fanon, Identity, the Puzzle of Conscious Experience, and What It Is Like to be \quote{Black,}} in Mercedes F. Durán-Cogan and Antonio Gómez-Moriana, eds., {\em National Identities and Socio-political Change in Latin America} (London: Routledge, 2001), 32.} The Maroons and the runaways had inhabited these caves alongside Caribbean wildlife. Through sound, in the dark, they had learned to navigate Cockpit Country in an intimate echolocation and engagement with nature.
The neurophysiology of bats is emblematic of an alternative way of knowing space beyond the ocularcentric. Once the binary between human and nonhuman animals is challenged, other sensorial epistemologies become possible. While I was at the Windsor Caves it occurred to me that during the time the Maroons and the runaways coexisted in interspecies spatial intimacy in these very caves, the bats would have signaled the time of day, the shifting of dawn and dusk; their flight, their movements would have signaled a diurnal fugitivity and anticircadian rhythm, another way of measuring time and navigating space through the nonhuman world. Sensory deprivation or perceptual isolation can heighten other senses. What did the Maroons and the runaways have to tune into for survival? What frequencies had they been attuned to that the British soldiers and planters would never be able to hear?
\subsection[title={{\em Unmapping the Caribbean}: The Website},reference={unmapping-the-caribbean-the-website}]
These questions of freedom, sovereignty, and futurity were what the students in the Jamaica group considered for their story map (fig. 5).\footnote{The students who assisted with the Jamaica story map include Moriah Dowd, Efosi Litombe, Tatyana Tandanpolie, and Mahalet Tegenu.} They titled it \quotation{Xaymaca: Wi Likkle but Wi Tallawah,} highlighting the island's original Arawak name Xaymaca, which means \quotation{the land of wood and water.} This choice of title honors the location's indigenous origin and juxtaposes it with the patwa of a Jamaican folk saying. Jamaican poet laureate Miss Lou riffed on the saying's significance and how it means that we might be a small place, but we are mighty in impact. This small-island sensibility is integral to archipelagic being. No map can accurately represent the size and impact of the Caribbean on the world, flattening, as maps do, the islands into a series of tiny dots.
The Jamaica group centered vernacular and folk knowledge with indigenous knowledge, taking a cue from University of the West Indies professor Carolyn Cooper's essay \quotation{Professing Slackness: Language, Authority, and Power Within the Academy and Without.} When they first read this essay, my students, even those who understood patwa, were disoriented, but they soon realized the metatheatrical stakes of writing a formal academic article in patwa. Cooper defied traditional academic norms to profess in what she describes as \quotation{barefoot language.} Again, the body and sexuality are invoked here in Caribbean orality against colonial power as Cooper explains there is a slackness that \quotation{isn't only about sexual morality} but rather about a \quotation{naked savagery} and a defiance of colonial norms, including wearing \quotation{proper} clothes.\footnote{See Carolyn Cooper, \quotation{Professing Slackness: Language, Authority, and Power Within the Academy and Without,} {\em E-misférica: Caribbean Rasanblaj} 12, no. 1 (2015), \useURL[url21][http://archive.hemisphericinstitute.org/hemi/en/emisferica-121-caribbean-rasanblaj/cooper]\from[url21].} To unmap through the accent of patwa offered the students a way to theorize sonic modes of declaring independence through the theatricality of Jamaicanisms.
\placefigure{Xaymaca: Wi Likkle but Wi Tallawah}{\externalfigure[images/goffe/fig5.png]}
Engaging further with Jamaican sound, the students contrasted sonic recordings (found on YouTube) of tourism in popular locations such as Dunn's River Falls with the sounds of nature---bird, bats, and frogs---in Cockpit Country. The accents of Americans and Western Europeans form a sonic colonialism that disrupts the local soundscape. The students found recordings of the Jamaican Maroon language Coromantee, derived from archaic Ghanaian languages, and embedded these into maps depicting sites of marronage in Accompong. Drawing on what they had learned about all-inclusive resorts and capitalist extraction from the pairing on the syllabus of Jamaica Kincaid's {\em A Small Place} and Stephanie Black's documentary {\em Life and Debt} (with voice-over of Kincaid's text adapted from {\em A Small Place}), the students contended with how the development of tourism irrevocably altered the natural soundscape of the island. The students remixed reggae songs using echoing and reverb DJ effects to consider how Bob Marley forms a global sonic imaginary, putting Jamaica and the broader Caribbean on the world map, so to speak.
The New York group was named Mannahatta, the Lenape word meaning \quotation{place where the wood is gathered.} New York City, where roughly a quarter of the recorded population is Caribbean (as of 2013), allowed an opportunity to meditate on how many more Caribbean people call New York home than were counted, considering those who are not documented, especially from Guyana and the Dominican Republic. The students in this group had the advantage of being able to include interviews and other recorded material from a local context. They chose the title \quotation{New York as Caribbean City: Gentrification as Colonization} to highlight the layers of occupation of Lenape land.\footnote{The students who assisted with the New York story map include Awura Gyimah, Matthew Martinez, Massiel Perez, and Xiaolong Woods.} The only group to directly tackle the issue of opacity directly, the students created a landing page that queries the intentions of those accessing the map: after the title \quotation{Manahatta,} a warning reads, \quotation{The following is only for individuals who have roots in the Caribbean and their allies. Do not proceed if you do not meet the criteria stated above.} They used a flick FBI warning against copyright infringement as the backdrop, which was a curious choice, considering the fraught questions of jurisdiction situating Manhattan as Lenape land. If the user does not fit the criteria of allyship, she has the option to click \quotation{Leave} in the upper right corner, which leads to a broken \useURL[url22][http://leave.leave.leave./][][hyperlink]\from[url22]---a creative strategy for addressing the challenges of retaining opacity and deflecting uninvited/unwanted audiences. The key to the {\em Unmapping the Caribbean} website is a decolonial practice of coalition building; these students did not want the Manahatta map to fall into the \quotation{wrong} hands.
\placefigure{New York as Caribbean City: Gentrification as Colonization}{\externalfigure[images/goffe/fig6.png]}
Listening is the key to opening the map. To welcome the viewers who proceed, the students produced a forty-second soundtrack, layering the rumbling sound of a train on subway tracks with the crashing of waves and Caribbean salsa music and drums. This is followed by four recordings: \quotation{Ven, este mapa es para ti}; \quotation{Cum, this map a fi yuh}; \quotation{Vini non, map sa a se pou ou}; and \quotation{Come, this map is for you.} In each phrase, the word {\em map} or {\em mapa} is hyperlinked and leads to an expandable side accordion story map featuring ten layers of gentrified spaces in New York City (fig.~6). This was the perfect type of story map for their narrative because of its capacity to enact a relational aesthetic of layering. For example, one page features historically Caribbean neighborhoods such as Williamsburg, home to Puerto Rican communities like Los Sures. Similar to how the Xaymaca group aurally focused attention on tourism, the New York group showed gentrification by contrasting the sounds of bodegas and people playing dominos on the street with markers of sonic colonialism---notably, the idle chatter of gentrifying hipsters.
The students in the Suriname group, named Surinen, for the indigenous people of that area, titled their project \quotation{Mapping the Interior: Navigating Black and Brown Queer Intimacy.}\footnote{The students who assisted with the Suriname story map include Zainab Floyd, Kevwe Okumakube, Amodhya Samarakoon, and Hawau Touray.} Rather than focusing on tensions among black and Asian communities, which we had studied in the Eastern Caribbean, they chose to center queer intimacy between black and Asian people in Suriname; one part of the story map is titled \quotation{Navigating the Interior: Black and Brown Queerness.} \quotation{Mati work,} what Dutch-Surinamese feminist theorist Gloria Wekker defines as \quotation{an old practice among Afro-Surinamese working-class women in which marriage is rejected in favor of male and female sexual partners,} and music were central to their story map.\footnote{See the synopsis for Gloria Wekker, {\em The Politics of Passion: Women's Sexual Culture in the Afro-Surinamese Diaspora} (New York: Columbia University Press, 2006) at \useURL[url23][http://cup.columbia.edu/book/the-politics-of-passion/9780231131629]\from[url23].} The students stitched and edited together footage from Surinamese dancehall and {\em kaseko} performances with footage from pride parades and celebrations of LGBTQ life in the country. They also wrote original poems in conversation with the concept of the rainforest that is commonly described as \quotation{the interior} in Suriname.
\placefigure{Surinen: Mapping the Interior}{\externalfigure[images/goffe/fig7.png]}
The Surinen story map also showcases rituals of the African-derived religion Winti and how Amerindian and Maroon communities retain their cultural practices. The students presented time-lapse nature videos of flowers blooming from YouTube alongside the words of Wekker (fig.~7). Though in the beginning of the term my students had not heard of Suriname, by the end they had an intimate relationship with the country. Having conducted research in Paramaribo, I personally found the sonic rendering of the Suriname story map so powerful that it felt as though the students had gone there to carry out this research.\footnote{After the 2016 US presidential election, through my desire to organize against new fascism I found community with the Sanctuary Coalition of New York University. I would like to thank Paula Chakravartty for her generosity and her leadership of the Sanctuary Coalition. I contributed to the Sanctuary syllabus designed by graduate students and published by {\em Public Books}. See \quotation{Sanctuary Syllabus,} {\em Public Books}, 5 December 2017, \useURL[url24][http://www.publicbooks.org/sanctuary-syllabus/]\from[url24].}
The Hispaniola group, named Kiskeya/Quisqueya after the island's original Taíno name, focused on the contours of Afrolatinidad in the Caribbean. These students considered how music has been a space of Afro-Caribbean refuge and expression, and they subtitled their story map both \quotation{A Journey through the Border} and \quotation{A Journey along the Border} (fig.~8).\footnote{The students who assisted with the Hispaniola story map include Sophia Gumbs, Harmony Hemmings-Pallay, Naomi Malcolm, and Jesse Sgambati.} Keeping in mind that several students had rendered Haiti and the Dominican Republic as separate islands in their freehand analog maps at the beginning of the semester (see fig.~3), they wanted to center the connections between the two countries along their linguistic and national border using the \quotation{Cascade} Esri Story Map, which creates an immersive scrolling experience. The students presented how Haiti and the Dominican Republic are joined by music and how the narratives of Taino history inflect both nations, filling the screen with maps, 3D scenes, images, and video.
As one of the most prominent and poetic voices on immigration and the status of black refuge and refugees, Haitian American novelist Edwidge Danticat served as the students' literary guide. In her essay \quotation{Black Bodies in Motion and in Pain,} Danticat evocatively draws connections between black death and flight in the Mediterranean, the Great Migration in the United States, and the deportations at the Haitian-Dominican border. I encouraged the students to also consider the twin-island imaginary of historic Saint-Domingue that Danticat presents in {\em Krik? Krak!}\footnote{See Edwidge Danticat, \quotation{Black Bodies in Motion and in Pain,} {\em New Yorker}, 22 June 2015 (online), \useURL[url25][https://www.newyorker.com/culture/cultural-comment/black-bodies-in-motion-and-in-pain]\from[url25]; and {\em Krik? Krak!} (New York: Soho, 2015).} They historicized their map with information about the border, especially the 1937 \quotation{parsley massacre} and the more recent deportations of Afro-Dominicans.\footnote{In 1937, the Dominican dictator Rafael Trujillo ordered the mass killing of Haitians living in the Dominican Republic.}
\placefigure{Kiskeya/Quisqueya: A Journey along/through the Border}{\externalfigure[images/goffe/fig8.png]}
The students discovered that there are certain instruments that connect Haitian music ({\em kadans}) to Dominican music ({\em bachata}). They featured music videos of two global superstars---Dominican bacahata singer Raulín Rodriguez and Puerto Rican merengue singer Elvis Crespo---to illustrate how genres transcend national and geographic borders. The students also highlighted the Haitian guitar-based Latin genre {\em twoubadou}, which developed through migration across the border with the Dominican Republic. One student, Jesse Sgambati (Jesediah), who was pursuing a degree in recorded music, produced \useURL[url26][http://archipelagosjournal.org/assets/extras/issue05-goffe-recording.mp3][][an original composition]\from[url26], an instrumental track that blends Haitian polyrhythms and features shakers, skin drums, and wood blocks alongside electronic elements, snares, 808 kicks, and synth sounds. The string elements of the song gesture to merengue but are played on a {\em charango}, an Andean folk instrument, which was paired with the {\em banza}, the banjo of Haiti. The song is a beautiful example of sonic copresence and decolonial rhythm, and the classroom presentation of this story map was vibrant---students began to dance and gave the group a standing ovation.
\placefigure{Cubao: Santería from Obscurity to Hypervisiblity}{\externalfigure[images/goffe/fig9.png]}
Continuing on the theme of negotiating and defining Afrolatiniad and Latinx identity in the Caribbean, students in the Cuba group, named Cubao (meaning \quotation{abundant,} derived from the country's original indigenous name, Cubanascnan) titled their story map \quotation{Cuban Santería: Religious Transformation from Obscurity to Hypervisiblity} (fig. 9).\footnote{The students who assisted with the Cuba story map include Elliott Levy, Michelle Mawere, and Eva Toscanos.} The students, one of whom had filmed a documentary in Cuba the year before, mapped the cosmology of Cuba through Santería's global circulation. They were interested in the retention of West African language, rituals, and Yoruba beliefs. Dash Harris, the then Cuba-based founder of the company Afro-Latinx Travel and a guest lecturer to my course, described Catholicism as a cover for practicing original and secret religion, distinct from the ways academics often flatten Santería as a simple expression of syncretism. Though the various religions in the Caribbean certainly retain elements from African, European, and Asian cosmologies, it is significant to consider the mapping of saints and orishas as a strategy as opposed to a multiculturalist celebration. The students were fascinated by religion's role in representing a hidden world of performing West African rituals. I encouraged them to explore Amerindian imagery and Chinese influences present in Cuba as well. They organized their narrative thread around the circulation and hypervisibility of Santería through Afro-diasporic popular musical artists with global audiences, such as Beyoncé, who has invoked Yemaya and Ochun, and Afro-French Cuban singers Ibeyi, the twins Lisa-Kaindé Diaz and Naomi Diaz, who sing in multiple languages, including Yoruba. The students compiled news footage from YouTube of the fraudulent Santería grey economy of false practitioners, a market unsanctioned by the Cuban government, that has arisen alongside tourism in Cuba.
\subsection[title={Future Grounds of Sonic Unmapping},reference={future-grounds-of-sonic-unmapping}]
Questions regarding labor, credit, and archiving are critical for this decolonial cartography. In the interest of interrogating my and my students' US-based perspective, I arranged video conference sessions with experts based in the Caribbean. In addition to our class with Dash Harris in Cuba, we had a session with Trinidad-based Felicia Chang and Zaake De Coninck, cofounders of the media publishing company \useURL[url27][https://www.plantain.me/][][Plantain]\from[url27]. Based on their expertise in oral history, these entrepreneurs provided their digital storytelling experience in consultation with all the groups.\footnote{See Plantain, \useURL[url28][https://www.plantain.me/]\from[url28]. Additional consultants included LGBTQ rights activist Robert Taylor Jr., of Queeribbean (\useURL[url29][https://www.queeribbean.com/]\from[url29]), who consulted with the Jamaica group; and performance artist Alicia Grullon, of Dominican and Haitian heritage and raised in New York, who helped the New York City group. Omar Daujahre, the deputy director of NYU's Center for Latin American and Caribbean Studies, and Melissa Fuster Rivera, an assistant professor of food studies at Brooklyn College, both from Puerto Rico, also helped the New York group.} I also received assistance over the years from technologist Armanda Lewis, who helped me design templates for assessment of collaborative work and the for logistics of the assignment.\footnote{Armanda Lewis brainstormed with me about an approach to grading and provided templates for peer grading.} In addition, Armanda helped me design a rubric clarifying my expectations in terms of creativity, originality, research, citational practice, and collaboration. For the on-boarding process and technological troubleshooting with Esri Story Maps, technologists Michelle Thompson and Himanshu Mistry, of New York University Libraries Data Services, were invaluable.\footnote{See \quotation{Data Services: Home,} New York University Libraries, \useURL[url30][https://guides.nyu.edu/dataservices]\from[url30].}
In the vein of Stefano Harney and Fred Moten's {\em The Undercommons: Fugitive Planning and Black Study}, I encouraged my students to consider treason, in a metaphorical sense. If, as Moten suggests, the university is an engine of settler colonialism---in that weapons are designed there as well as technologies that devastate the natural environment and financial instruments that exploit the most vulnerable with subprime mortgages, for instance (these links were especially clear in the Manahatta group's story map as it paralleled gentrification and imperialism in New York City)---then it is our duty to deploy a university's resources for purposes other than continuing a settler colonial regime.\footnote{See Stefano Harney and Fred Moten, {\em The Undercommons:} {\em Fugitive Planning and Black Study} (Wivenhoe, UK: Minor Compositions, 2013).} Universities vary in access to resources, and I foregrounded awareness of all the technological resources available to students in the university, emphasizing that they are paying tuition, or tuition is being paid on their behalf, for access to these technologies. I made sure to investigate open-source resources as well as any software and hardware available through university subscriptions. And if it is \quotation{treason} to use technology for something other than its intended purpose, then, indeed, we also committed just such an act in our decolonial Caribbean unmapping by using technology from Esri, a company invested in US defense contracts.
It was important for the students to see early in the semester what was possible and that it would not necessarily require advanced computer coding skills. They were able to experience what digital maps---data visualizations centered on geography---could illuminate and trouble. I was fortunate to have been introduced to \useURL[url31][https://newyorkscapes.org/project/unmapping-the-caribbean/][][{\em New York Scapes}]\from[url31] by Nicholas Wolf and Tom Augst, organizers in a research community for people engaged in cultural mapping.\footnote{See New York Scapes, \useURL[url32][https://newyorkscapes.org/]\from[url32]. {\em Unmapping the Caribbean} is included under \quotation{Projects.}} With financial assistance from New York Scapes, I was able to hire Ryn Stafford as project manager for {\em Unmapping the Caribbean}. A former student of mine, Ryn was familiar with the sorts of sonic creative deejaying projects I have assigned in the past, and so they were the perfect guide to translate the project and provide additional help to the five groups of students.\footnote{Familiar with the rhythms of the semester, Ryn encouraged students to seek help at the right moments. Another former student, Lu Biltucci, who has an interest in cartography, provided guidance to my students during the initial stages of the project. In addition, English PhD student and technologist Grace Afsari-Mamagani provided a demo of the various digital decolonial mapping projects that are currently being made. For example, {\em Torn Apart / Separados}, a two-volume digital project designed by Manan Ahmed and Alex Gil that visualizes the territory and infrastructure of US Immigration and Customs Enforcement, was a major inspiration. See {\em Torn Apart /Separados}, vol.~1, \quotation{a rapidly deployed critical data & visualization intervention,} at \useURL[url33][http://xpmethod.columbia.edu/torn-apart/volume/1/]\from[url33]; and vol.~2, \quotation{a deep and radically new look,} at \useURL[url34][http://xpmethod.columbia.edu/torn-apart/volume/2/]\from[url34].}
Beyond what students were able to learn about Caribbean culture through the process of independent research for this project, they also implicitly learned about copyright, the politics of fair use, and proper citation practice. They meditated on the politics and ethics of circulation as well. Who, beyond me, the professor assigning a grade, was the intended audience? The right to copy and the concept of {\em the commons} was deeply embedded in the intellectual exercise of sonic unmapping we engaged in. Citation is politics. Citation is ethics, and yet it is rarely done ethically. Students contended with the differences in copyright between various jurisdictions and territories in the Caribbean and asymmetrical imperial legal legacies. The assignment also gave them a chance to consider the currency of cultural production and how it does and does not travel across an archipelago of many tongues and varying digital accessibility.
{\em Unmapping the Caribbean} is necessarily unfinished, much in the way that musicologist Michael Veal describes dub music as having an unfinished sonic quality.\footnote{See Michael E. Veal, {\em Dub: Songscape, Studio Craft, Science Fiction, and the Shattering of Song Form in Jamaican Reggae} (Middletown, CT: Wesleyan University Press, 2007), 90.} My project of unmapping continues as long as my course does. It is critical that the unmapping is anchored with me and does not belong to any institution. There will at some point be a physical, material installation to complement and extend the digital life of the map as an immersive process using projection mapping. Already, moving between institutional infrastructures has required me to be intentional about disentangling and methodically archiving students' work: I am the guardian of the collected work. Like the image of my hand anchors the map on the landing page, the maps accumulate as part of my pedagogy in ways that continue to inform the layers of my research on archipelagic being.
I must also consider, for future iterations of the project, {\em where} to task my new cohort of students with unmapping. Do I ask them to map five new locations? Perhaps Puerto Rico, St.~Thomas, Miami, St.~Barthes, Toronto, Zion, Port of Spain? Or do I ask them to add layers to the maps made by previous students? In any case, the digital space as a repository of knowledge production becomes a growing archive of unmapping. My students complete the course having gained new technological or research skills that they can highlight on their resumes and in their portfolios.
\subsection[title={Trust Your Inner Map: \#JamaicaIsNotARealPlace},reference={trust-your-inner-map-jamaicaisnotarealplace}]
Part of the reason the unmapping is unfinished is that I did not seek anything definitive from the assignment, and this was vital to it being a process of critique through undoing and unlearning colonial myths. We were not simply remapping, and thus adding new layers of epistemic violence and division to the land. Unmapping is a decolonial digital praxis that embraces sensorial knowledges of black and indigenous cosmologies. In this way it is in conversation with the hashtag \#JamaicaIsNotARealPlace, which has been popular on Jamaican social media. Just as Jamaica \quotation{is not a real place,} the editors of the new Caribbean arts magazine {\em PREE} consider that maybe the Caribbean is not a real place, choosing this as a theme for one of their issues.\footnote{See {\em PREE}, no. 3, 2019, \useURL[url35][https://preelit.com/issue-three-thecaribbeanisnotarealplace/]\from[url35].} They broaden the concept and claim about dysfunction, frustration, and the stalled futurity of the region. In a similar spirit, I posit that the Caribbean defies mapping because it is not a real place. The poetics of Caribbean refusal involve exclusion as much as they can be coded as a set of refusals. The Caribbean seeks legibility but not by everyone. These are pertinent questions for institutions such as the University of the West Indies Mona Geoinformatics Institute, a hub for instruction and contract work for both the private and public sectors. There are generations of Caribbean-trained cartographers whose genealogy is not entirely imperial. For example, GIS specialist Michelle Thompson, of Data Services, who was most instrumental to {\em Unmapping the Caribbean}, is of Guyanese, Trinidadian, and Jamaican background and is the daughter of a rural physical planner with the Ministry of Agriculture in Jamaica who studied at UWI in the 1980s.
It was of special significance to be able to debut the collective {\em Unmapping the Caribbean} project at the Caribbean Digital V conference at UWI, St.~Augustine, in December 2018, with my Trinidad-based collaborators Felicia Chang and Zaake De Coninck (of Plantain), to center Caribbean digital and artistic production. It helped to see the project as part of an ecosystem of Caribbean diasporic digital engagements facing similar ethical concerns, much as we had, about the complicity of using Esri as a tool. Representation puts populations on the map, so to speak, but certain populations may prefer to be unmapped. If you cannot see me, you cannot colonize me. The echo of Me-no-Sen-You-no-Come across the map resists the order of the coloniality of mapping, where trains run on time, where people are where they say they will be at a given time. Predictive analytics work only if people are predictable or their habits can be easily traced, tracked, surveilled, and learned by algorithms.
A moment that typifies \#JamaicaIsNotARealPlace~is the story of my first meeting of a distant cousin in 2014. The epigraph to this essay is drawn from the utterance of a police officer whom my family and I had asked for directions to my cousin's house in Mandeville as we were driving. Just after our query, the traffic light turned green and the policeman zoomed away, leaving us with, \quotation{You will find a way.} His response, which has stayed with me, was flippant, prophetic, mystical, matter of fact, and spoken with a Jamaican affect that cannot quite be described in English---not quite cynical but dismissive, with an air of nonchalance. So we continued on our way, navigating by asking people on the street if they knew where Mr.~Goffe lived. We eventually encountered a few schoolboys who replied that we could find our cousin's house all the way down the road and around the corner.
As frustrating as it was, in the end the policeman was correct. We found a way. We found our cousin. His house, it turns out, did not have an exact address. And we found him in a time capsule of sorts. Our cousin is a collector, a hoarder of things, knickknacks mostly but also the materials of the Afro-indigenous and colonial history of Jamaica. His treasures were strewn across his house---Arawak arrowheads, for example, were scattered next to wedding albums full of colonial-era images of Jamaica's \quotation{mulatto aristocracy.}
The disorientation of being in and journeying through Jamaica made me realize the need to trust our inner maps, to listen to our bodies, to crowdsource people on the roadside in order to tune into our embodied and inherited histories. This is the type of sensorial listening that involves not only the ear but the entire body. It is a detour through the past in order to fashion a future (to recall the way Stuart Hall describes negotiating Caribbean identities as a continuous process). Unmapping is turning attention to an inner vestibular frequency, to an inner balance of finding a way just as so many Caribbean people have had to do to survive.
\subsection[title={Map Key},reference={map-key}]
The key to unmapping was relational. I would very much like to thank Kaiama Glover and Alex Gil for their support and inspiration in creative technology and collaboration. Seeing their early projects at the first Caribbean Digital conferences prompted me to dream and engage in a vulnerable pedagogy of learning with my students assisted by technologists. Thanks also to the anonymous readers and Kelly Martin for attention to the shape of my narrative. None of this would be possible without my students trusting the process of my teaching through digital-born coauthored collaboration. A special thanks to Ryn for their generosity, intellectual curiosity, and work as project manager.
\thinrule
\page
\subsection{Tao Leigh Goffe}
Tao Leigh Goffe is an assistant professor of literary theory and cultural history at Cornell University. She is also a sound artist, specializing in the narratives that emerge from histories of imperialism, migration, and globalization. Her interdisciplinary research and practice examine the unfolding relationship between ecology, infrastructure, and the sensorium. Deejaying, film production, digital cartography, and oral history are also integral to her praxis and pedagogy. She is the cofounder of the \useURL[url1][https://www.darklaboratory.com/][][Dark Laboratory]\from[url1] (see https://www.darklaboratory.com/), a humanities collective of theorist and creative technologists that examines black and indigenous crossroads in ecology and technology.
\stopchapter
\stoptext
|
\chapter{Introduction}
This thesis discusses the problem of real-time sharp wave-ripple (SWR)
detection.
The first three chapters unpack this sentence. What are sharp wave-ripples?
Why do we care about them, and why would we want to detect them in real-time?
And finally, what are the solved and outstanding engineering problems of
real-time SWR detection?
% We first give an overview of why we did the work described in this thesis. The subsequent paragraphs explain this in a bit more detail; including one paragraph on possible applications. Next, we describe prior work done on this topic. Finally, we lay out how this thesis is structured.
% \section{Why this work}
% \subsection{Overview}
% % Actually also focus on general BCI applicability (at least in abstract)
% The brain is a vast, uncharted territory when it comes to mechanistic understanding. % Neuroscience ventured unusually deep when it discovered
% The discovery of \emph{place cells} (see below) has been unusually
% satisfactory in this regard. We now know how mammalian brains represent thir
% location in space, where the neurons that do this are located exactly, and
% how the firing rates of these neurons should be interpreted to calculate
% where the animal is in the environment.
% % Cool 'uncharted territory' picture:
% % http://static1.uk.businessinsider.com/image/5979f5039d09184e5a538b4d/legendary-investor-byron-wien-says-the-stock-market-is-entering-uncharted-territory.jpg
% These are neurons whose firing rate encodes the position of of the anima
% % which neurons
% (see further, \cref{sec:place-cells})
% \subsection{Probing the brain}
% There is a glaring gap in our understanding of the nervous system. We have a
% passable understanding at the circuit level of the first few stages of
% sensory processing, and analogously of the last few stages before muscle and
% gland control. Our understanding of what happens in between those extremes however, is very unsatisfactory.
% The working model of the brain
% - A few, non connected pathways from the senses. Few recurrence.
% - Higher order processing, joint, recurrence
% - [Output]
% \includegraphics[width=\textwidth]{intro/nervous-system-sketch}
% \begin{figure}
% % \includegraphics[width=\textwidth]{example-image-A}
% \includegraphics[width=\textwidth]{intro/nervous-system-sketch}
% \caption{A naive high level view of the nervous system.
% Some notable features: 1) Although there is a high level of recurrence, not every neuron is connected to every other neuron. 2) The different coloured neurons indicate that not all neurons have the same transfer function and dynamics.}
% \end{figure}
% This, at least, is my understanding of the state of neuroscience after my brief
% Why do I say this?
% - Purves \& Kandel chapters
% Organise them according to content (count synapses!! Shortest path!!):
% - Input \& Output
% - Higher level (psychiatry, MRI)
% - Non-specific (synapses, cells, genes)
% - Course 'neural computation' and 'neural systems \& circuits
% - Free reading, and seminars at NERF.
% % Replay is one of the few
% \acrfull{swr}
% \begin{figure}
% \begin{subfigure}{0.6\textwidth}
% \caption{Information flow through a closed-loop neurostimulation system}
% \label{fig:Closed_loop_system}
% % \includegraphics[width=\textwidth]{Closed_loop_system}
% \includegraphics[width=\textwidth]{example-image-A}
% \end{subfigure}
% \begin{subfigure}{0.6\textwidth}
% \caption{Signals at different stages of the closed loop, and the latencies between them.}
% \includegraphics[width=\textwidth]{example-image-B}
% \end{subfigure}
% \caption
% { \subref{fig:Closed_loop_system} Simplified data path through a general closed-loop neurostimulation system. The ``stimulating electrode'' may also be an optical fiber, when optogenetic rather than electrical disruption of neural activity is performed. ALU: Arithmetic Logic Unit.}
% \label{fig:latency}
% \end{figure}
% % ALU: A combinatorial digital electronic circuit that performs operations like addition and comparison on its inputs. Strictly speaking only for integer inputs, but here taken to also operate on floating point numbers.
% \subsection{Hippocampal systems neuroscience}
% \emph{Systems neuroscience} is the study of biological brains at the level of circuits formed by multiple neurons. This is a coarser level than the individual proteins and neurotransmitters studied by molecular biologists, and a more detailed level than fMRI\footnotemark[1] or EEG\footnotemark[2] studies, where each voxel or each electrode represents the entangled activity of many thousands of neurons \cite{Frahm1993,Kreczmanski2007,Collins2016}. Due do its systems approach, it is arguably the most `engineering-like' of all neuroscience-related disciplines. (Though see the papers ``Could a neuroscientist understand a microprocessor?''\cite{Jonas2017} and ``Can a biologist fix a radio?''\cite{Lazebnik2002} for a detailed reflection on the differences in approach between `classical' engineering disciplines, and systems neuroscience or systems biology).
% \footnotetext[1]{Functional magnetic resonance imaging.} %todo
% \footnotetext[2]{Electroencephalography. What is left of the vector sum of many thousands of neurons' electric field potentials, after they have been attenuated by the skull and scalp.}
% Within systems neuroscience (but also in other disciplines of neuroscience), the \emph{hippocampus} is perhaps the most intensively studied brain region. The reasons for this are historically
% its role in learning and memory \cite{HCB_function}, and its critical
% involvement in common diseases such as Alzheimer's and epilepsy \cite{HCB_disease}.
% Most
% Picture a rodent in a lab environment, placed in an open `arena' or in a simple "maze" (like in \cref{fig:lab-env}). This is most often the (sometimes implicitly) assumed setting in the field of systems-neuroscience hippocampus research. In the following sections, we will assume this setting.
% % Also: Kandel (Nobel and _the_ book) mainly worked on memory
% \subsection{Place cells}
% \label{sec:place-cells}
% \emph{Place cells} are neurons that fire at an increased rate when the ani a particular location in the environment.
% \begin{figure}
% \begin{subfigure}{0.5\textwidth}
% \includegraphics[width=\textwidth]{example-image-A}
% \end{subfigure}
% \begin{subfigure}{0.5\textwidth}
% \includegraphics[width=\textwidth]{example-image-B}
% \end{subfigure}
% \caption
% { Rodents in experimental environments [photographs] }
% \label{fig:lab-env}
% \end{figure}
% \subsection{Replay}
% \subsection{Sharp-wave ripples}
% \subsection{Closed-loop SWR disruption}
% \subsection{Relevance of the experimental setup}
% % Generalisability
% % Replay of other encoded data -- we just haven't decoded anything else besides place.
% \subsection{Other applications}
% \section{Prior work}
% \section{Structure of this thesis}
% A feedforward artificial neural network is a useful first order approximation for the sensory processing pipeline in biological brains. Each sensory experience corresponds to a distinct activation pattern of the network. A life episode of say a few seconds long is a concatenation of experiences, and corresponds to a sequence of such neural activation patterns (which we will call a sequence of `states'). Furthermore, as the raw sensory information advances further through the network, its representation becomes more compressed and abstract.
% One of the areas at the end of this abstraction pipeline in human and other mammalian brains is the hippocampus. In-vivo multi-electrode recordings inside the brain allow us to determine the activation time series for sets of individual neurons. This type of neuroscientific research, mostly in freely behaving mice and rats,
% % Neuroscience labs around the world study the brain in health and in disease.
% % An anatomical region of particular interest is the \emph{hippocampus}, for
% % its role in learning and memory \cite{HCB_function}, and its critical
% % involvement in common diseases such as Alzheimer's and epilepsy
% % \cite{HCB_disease}.
% \Cref{fig:experiment} outlines one type of experiment used to study the
% hippocampus \cite{ego2010disruption,jadhav2012awake}.
% \begin{figure}
% \centering
% \includegraphics[width=\textwidth]{example-image-a}
% \caption
% { The type of neuroscientific experiment that is made more rigorous by the
% work described in this paper.
% % Learning is disrupted in a model animal by injecting a
% % current pulse in the hippocampus on detection of a sharp-wave ripple event.
% }
% \label{fig:experiment}
% \end{figure}
|
/*
* BRAINS
* (B)LR (R)everberation-mapping (A)nalysis (I)n AGNs with (N)ested (S)ampling
* Yan-Rong Li, [email protected]
* Thu, Aug 4, 2016
*/
/*! \file dnest_sa.c
* \brief run dnest sampling for sa analysis.
*/
#ifdef SA
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#include <math.h>
#include <float.h>
#include <string.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_interp.h>
#include <mpi.h>
#include "brains.h"
DNestFptrSet *fptrset_sa;
int dnest_sa(int argc, char **argv)
{
int i;
double logz_sa;
set_sa_blr_model();
num_params_blr = 0; /* RM parameter numbers */
num_params_sa_blr = num_params_sa_blr_model + num_params_sa_extpar;
num_params_blr_tot = num_params_sa_blr;
num_params_sa = num_params_sa_blr;
num_params = num_params_sa;
par_fix = (int *) malloc(num_params * sizeof(int));
par_fix_val = (double *) malloc(num_params * sizeof(double));
par_range_model = malloc( num_params * sizeof(double *));
par_prior_gaussian = malloc( num_params * sizeof(double *));
for(i=0; i<num_params; i++)
{
par_range_model[i] = malloc(2*sizeof(double));
par_prior_gaussian[i] = malloc(2*sizeof(double));
}
par_prior_model = malloc( num_params * sizeof(int));
fptrset_sa = dnest_malloc_fptrset();
/* setup functions used for dnest*/
fptrset_sa->from_prior = from_prior_sa;
fptrset_sa->print_particle = print_particle_sa;
fptrset_sa->restart_action = restart_action_sa;
fptrset_sa->accept_action = accept_action_sa;
fptrset_sa->kill_action = kill_action_sa;
fptrset_sa->perturb = perturb_sa;
fptrset_sa->read_particle = read_particle_sa;
fptrset_sa->log_likelihoods_cal_initial = log_likelihoods_cal_initial_sa;
fptrset_sa->log_likelihoods_cal_restart = log_likelihoods_cal_restart_sa;
fptrset_sa->log_likelihoods_cal = log_likelihoods_cal_sa;
set_par_range_sa();
set_par_fix_sa_blrmodel();
for(i=num_params_sa_blr_model; i<num_params; i++)
{
par_fix[i] = 0;
par_fix_val[i] = -DBL_MAX;
}
/* fix DA */
par_fix[num_params_sa_blr_model] = 1;
par_fix_val[num_params_sa_blr_model] = log(550.0);
/* fix FA */
par_fix[num_params_sa_blr_model+2] = 1;
par_fix_val[num_params_sa_blr_model+2] = log(1.0);
print_par_names_sa();
force_update = parset.flag_force_update;
if(parset.flag_para_name != 1)
logz_sa = dnest(argc, argv, fptrset_sa, num_params, dnest_options_file);
dnest_free_fptrset(fptrset_sa);
return 0;
}
void set_par_range_sa()
{
int i;
/* setup parameter range, BLR parameters first */
for(i=0; i<num_params_sa_blr_model; i++)
{
par_range_model[i][0] = sa_blr_range_model[i][0];
par_range_model[i][1] = sa_blr_range_model[i][1];
par_prior_model[i] = UNIFORM;
par_prior_gaussian[i][0] = 0.0;
par_prior_gaussian[i][1] = 0.0;
}
/* sa extra parameters */
for(i=num_params_sa_blr_model; i<num_params_sa; i++)
{
par_range_model[i][0] = sa_extpar_range[i-num_params_sa_blr_model][0];
par_range_model[i][1] = sa_extpar_range[i-num_params_sa_blr_model][1];
par_prior_model[i] = UNIFORM;
par_prior_gaussian[i][0] = 0.0;
par_prior_gaussian[i][1] = 0.0;
}
return;
}
/*!
* print names and prior ranges for parameters
*
*/
void print_par_names_sa()
{
if(thistask != roottask)
return;
int i, j;
FILE *fp;
char fname[BRAINS_MAX_STR_LENGTH], str_fmt[BRAINS_MAX_STR_LENGTH];
sprintf(fname, "%s/%s", parset.file_dir, "data/para_names_sa.txt");
fp = fopen(fname, "w");
if(fp == NULL)
{
fprintf(stderr, "# Error: Cannot open file %s.\n", fname);
exit(0);
}
strcpy(str_fmt, "%4d %-15s %10.6f %10.6f %4d %4d %15.6e\n");
printf("# Print parameter name in %s\n", fname);
fprintf(fp, "#*************************************************\n");
fprint_version(fp);
fprintf(fp, "#*************************************************\n");
fprintf(fp, "%4s %-15s %10s %10s %4s %4s %15s\n", "#", "Par", "Min", "Max", "Prior", "Fix", "Val");
i=-1;
for(j=0; j<num_params_sa_blr_model; j++)
{
i++;
fprintf(fp, str_fmt, i, "SA BLR model", par_range_model[i][0], par_range_model[i][1], par_prior_model[i],
par_fix[i], par_fix_val[i]);
}
for(j=0; j<num_params_sa_extpar; j++)
{
i++;
fprintf(fp, str_fmt, i, "SA ExtPar", par_range_model[i][0], par_range_model[i][1], par_prior_model[i],
par_fix[i], par_fix_val[i]);
}
fclose(fp);
return;
}
/*!
* this function generates a sample from prior.
*/
void from_prior_sa(void *model)
{
int i;
double *pm = (double *)model;
for(i=0; i<num_params; i++)
{
if(par_prior_model[i] == GAUSSIAN)
{
pm[i] = dnest_randn()*par_prior_gaussian[i][1] + par_prior_gaussian[i][0];
dnest_wrap(&pm[i], par_range_model[i][0], par_range_model[i][1]);
}
else
{
pm[i] = par_range_model[i][0] + dnest_rand() * (par_range_model[i][1] - par_range_model[i][0]);
}
}
/* cope with fixed parameters */
for(i=0; i<num_params; i++)
{
if(par_fix[i] == 1)
pm[i] = par_fix_val[i];
}
which_parameter_update = -1;
return;
}
/*!
* this function calculates likelihood at initial step.
*/
double log_likelihoods_cal_initial_sa(const void *model)
{
double logL;
logL = prob_sa(model);
return logL;
}
/*!
* this function calculates likelihood at initial step.
*/
double log_likelihoods_cal_restart_sa(const void *model)
{
double logL;
logL = prob_sa(model);
return logL;
}
/*!
* this function calculates likelihood.
*/
double log_likelihoods_cal_sa(const void *model)
{
double logL;
logL = prob_sa(model);
return logL;
}
/*!
* this function prints out parameters.
*/
void print_particle_sa(FILE *fp, const void *model)
{
int i;
double *pm = (double *)model;
for(i=0; i<num_params; i++)
{
fprintf(fp, "%e ", pm[i] );
}
fprintf(fp, "\n");
return;
}
/*!
* This function read the particle from the file.
*/
void read_particle_sa(FILE *fp, void *model)
{
int j;
double *psample = (double *)model;
for(j=0; j < dnest_num_params; j++)
{
if(fscanf(fp, "%lf", psample+j) < 1)
{
printf("%f\n", *psample);
fprintf(stderr, "#Error: Cannot read file %s.\n", options.sample_file);
exit(0);
}
}
return;
}
/*!
* this function perturbs parameters.
*/
double perturb_sa(void *model)
{
double *pm = (double *)model;
double logH = 0.0, limit1, limit2, width;
int which, which_level, count_saves;
/*
* fixed parameters need not to update
* perturb important parameters more frequently
*/
do
{
which = dnest_rand_int(num_params);
}while(par_fix[which] == 1);
which_parameter_update = which;
/* level-dependent width */
count_saves = dnest_get_count_saves();
which_level_update = dnest_get_which_level_update();
which_level = which_level_update > (size_levels-10)?(size_levels-10):which_level_update;
if( which_level > 0 && count_saves > 1000)
{
limit1 = limits[(which_level-1) * num_params *2 + which *2];
limit2 = limits[(which_level-1) * num_params *2 + which *2 + 1];
width = (limit2 - limit1);
width /= (3*2.35);
}
else
{
limit1 = par_range_model[which][0];
limit2 = par_range_model[which][1];
width = (par_range_model[which][1] - par_range_model[which][0]);
width /= (2.35);
}
if(par_prior_model[which] == GAUSSIAN)
{
logH -= (-0.5*pow((pm[which] - par_prior_gaussian[which][0])/par_prior_gaussian[which][1], 2.0) );
pm[which] += dnest_randh() * width;
dnest_wrap(&pm[which], par_range_model[which][0], par_range_model[which][1]);
//dnest_wrap(&pm[which], limit1, limit2);
logH += (-0.5*pow((pm[which] - par_prior_gaussian[which][0])/par_prior_gaussian[which][1], 2.0) );
}
else
{
pm[which] += dnest_randh() * width;
dnest_wrap(&(pm[which]), par_range_model[which][0], par_range_model[which][1]);
//dnest_wrap(&pm[which], limit1, limit2);
}
return logH;
}
/*!
* this function calculates likelihood.
*/
double log_likelihoods_cal_sa_exam(const void *model)
{
return 0.0;
}
/*
* action when a particle's move is accepted.
* usually store some values with no need to recompute.
*/
void accept_action_sa()
{
return;
}
/*
* action when particle i is killed in cdnest sampling.
* particle i_copy's properties is copyed to particle i.
*/
void kill_action_sa(int i, int i_copy)
{
return;
}
#endif
|
checkEqNat : (num1 : Nat) -> (num2 : Nat) -> Maybe (num1 = num2)
checkEqNat Z Z = Just Refl
checkEqNat Z (S k) = Nothing
checkEqNat (S k) Z = Nothing
checkEqNat (S k) (S j) = case checkEqNat k j of
Nothing => Nothing
Just prf => Just (cong S prf)
|
[STATEMENT]
lemma shows_list_gen_cong [fundef_cong]:
assumes "xs = ys" and "\<And>x. x \<in> set ys \<Longrightarrow> f x = g x"
shows "shows_list_gen f e l sep r xs = shows_list_gen g e l sep r ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. shows_list_gen f e l sep r xs = shows_list_gen g e l sep r ys
[PROOF STEP]
using shows_sep_cong [of xs ys f g] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>xs = ys; \<And>x. x \<in> set ys \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> shows_sep f ?sep xs = shows_sep g ?sep ys
xs = ys
?x \<in> set ys \<Longrightarrow> f ?x = g ?x
goal (1 subgoal):
1. shows_list_gen f e l sep r xs = shows_list_gen g e l sep r ys
[PROOF STEP]
by (cases xs) (auto simp: shows_list_gen_def)
|
Nicole 's best friend during her initial storylines was Aden Jefferies ( Todd Lasance ) . After Brendan Austin ( Kain O 'Keeffe ) caused Roman to go blind , he took his anger out on Nicole and Aden . Subsequently they became " each other 's support network " and Lasance said it was not long afterward that they " slipped between the sheets " . One of the conditions of Aden 's tenancy was to never sleep with Nicole , this made the pair feel guilty that they had deceived Roman . Lasance felt the storyline was controversial as he had a strong fan base for his relationship with Belle Taylor ( Jessica Tovey ) - which meant he knew it would " cause a stir " and divide the audience . In January 2010 , Nicole and Aden " get up close and personal " and they decided to spend Aden 's remaining time in the Bay together . They shared a kiss and James told TV Week that there are " a lot of complications " for them . She said that no one knew what was going to happen with Liam Murphy ( Axle Whitehead ) and that Nicole felt guilty for betraying Belle because she was her friend . James explained that Nicole 's pairing with Aden was " a bit more serious and in @-@ depth than her usual relationships . " James opined that Aden was the " nicer guy " for Nicole , but Liam may have had " the edge she 's after . " Nicole and Aden then embarked on a relationship . James thought that Nicole and Aden 's relationship was great and said " They started out having a kind of brother @-@ sister relationship , and that developed into something more . " Nicole declared her love for Aden , however he did not reciprocate . Lasance described the moment whilst interviewed by TV Week stating : " They 've always had an awesome connection and Nicole gets into a bit of a comfortable state and blurts out that she loves Aden . " Aden appreciated her love for him , however cannot say it back until he felt the same way . It is this that made their relationship " awkward " , Nicole tried to withdraw her declaration and hide her hurt feelings .
|
%% pdf_Sobol: Foo function for simulate a Sobol Set
%
% Usage:
% pdf_Sobol()
%
% Inputs:
% range vector [min max] range of the random variable
%
% Output:
% range vector [min max] range of the random variable
% ------------------------------------------------------------------------
% See also
%
% Author : Flavio Cannavo'
% e-mail: flavio(dot)cannavo(at)gmail(dot)com
% Release: 1.0
% Date : 01-02-2011
%
% History:
% 1.0 01-02-2011 First release.
%%
function range = pdf_Sobol(range)
range = range(:)';
% empty function
|
/-
Copyright (c) 2019 Seul Baek. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Seul Baek
! This file was ported from Lean 3 source module tactic.omega.nat.dnf
! leanprover-community/mathlib commit 402f8982dddc1864bd703da2d6e2ee304a866973
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Data.List.ProdSigma
import Mathbin.Tactic.Omega.Clause
import Mathbin.Tactic.Omega.Nat.Form
/-!
# DNF transformation
-/
namespace Omega
namespace Nat
open Omega.Nat
@[simp]
def dnfCore : Preform → List Clause
| p ∨* q => dnf_core p ++ dnf_core q
| p ∧* q => (List.product (dnf_core p) (dnf_core q)).map fun pq => Clause.append pq.fst pq.snd
| t =* s => [([Term.sub (canonize s) (canonize t)], [])]
| t ≤* s => [([], [Term.sub (canonize s) (canonize t)])]
| ¬* _ => []
#align omega.nat.dnf_core Omega.Nat.dnfCore
/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic omega.nat.preform.induce -/
/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/
theorem exists_clause_holds_core {v : Nat → Nat} :
∀ {p : Preform},
p.NegFree → p.SubFree → p.Holds v → ∃ c ∈ dnfCore p, Clause.Holds (fun x => ↑(v x)) c :=
by
run_tac
preform.induce sorry
· apply List.exists_mem_cons_of
constructor
rw [List.forall_mem_singleton]
cases' h0 with ht hs
simp only [val_canonize ht, val_canonize hs, term.val_sub, preform.holds, sub_eq_add_neg] at *
rw [h2, add_neg_self]
apply List.forall_mem_nil
· apply List.exists_mem_cons_of
constructor
apply List.forall_mem_nil
rw [List.forall_mem_singleton]
simp only [val_canonize h0.left, val_canonize h0.right, term.val_sub, preform.holds,
sub_eq_add_neg] at *
rw [← sub_eq_add_neg, le_sub_comm, sub_zero, Int.ofNat_le]
assumption
· cases h1
·
cases' h2 with h2 h2 <;> [· cases' ihp h1.left h0.left h2 with c h3,
· cases' ihq h1.right h0.right h2 with c h3] <;>
cases' h3 with h3 h4 <;>
refine' ⟨c, list.mem_append.elim_right _, h4⟩ <;>
[left, right] <;>
assumption
· rcases ihp h1.left h0.left h2.left with ⟨cp, hp1, hp2⟩
rcases ihq h1.right h0.right h2.right with ⟨cq, hq1, hq2⟩
refine' ⟨clause.append cp cq, ⟨_, clause.holds_append hp2 hq2⟩⟩
simp only [dnf_core, List.mem_map]
refine' ⟨(cp, cq), ⟨_, rfl⟩⟩
rw [List.mem_product]
constructor <;> assumption
#align omega.nat.exists_clause_holds_core Omega.Nat.exists_clause_holds_core
def Term.varsCore (is : List Int) : List Bool :=
is.map fun i => if i = 0 then false else true
#align omega.nat.term.vars_core Omega.Nat.Term.varsCore
/-- Return a list of bools that encodes which variables have nonzero coefficients -/
def Term.vars (t : Term) : List Bool :=
Term.varsCore t.snd
#align omega.nat.term.vars Omega.Nat.Term.vars
def Bools.or : List Bool → List Bool → List Bool
| [], bs2 => bs2
| bs1, [] => bs1
| b1 :: bs1, b2 :: bs2 => (b1 || b2) :: bools.or bs1 bs2
#align omega.nat.bools.or Omega.Nat.Bools.or
/-- Return a list of bools that encodes which variables have nonzero coefficients in any one of the
input terms. -/
def Terms.vars : List Term → List Bool
| [] => []
| t :: ts => Bools.or (Term.vars t) (terms.vars ts)
#align omega.nat.terms.vars Omega.Nat.Terms.vars
open List.Func
-- get notation for list.func.set
def nonnegConstsCore : Nat → List Bool → List Term
| _, [] => []
| k, ff :: bs => nonneg_consts_core (k + 1) bs
| k, tt :: bs => ⟨0, [] {k ↦ 1}⟩ :: nonneg_consts_core (k + 1) bs
#align omega.nat.nonneg_consts_core Omega.Nat.nonnegConstsCore
def nonnegConsts (bs : List Bool) : List Term :=
nonnegConstsCore 0 bs
#align omega.nat.nonneg_consts Omega.Nat.nonnegConsts
def nonnegate : Clause → Clause
| (eqs, les) =>
let xs := Terms.vars eqs
let ys := Terms.vars les
let bs := Bools.or xs ys
(eqs, nonnegConsts bs ++ les)
#align omega.nat.nonnegate Omega.Nat.nonnegate
/-- DNF transformation -/
def dnf (p : Preform) : List Clause :=
(dnfCore p).map nonnegate
#align omega.nat.dnf Omega.Nat.dnf
theorem holds_nonnegConstsCore {v : Nat → Int} (h1 : ∀ x, 0 ≤ v x) :
∀ m bs, ∀ t ∈ nonnegConstsCore m bs, 0 ≤ Term.val v t
| _, [] => fun _ h2 => by cases h2
| k, ff :: bs => holds_nonneg_consts_core (k + 1) bs
| k, tt :: bs => by
simp only [nonneg_consts_core]
rw [List.forall_mem_cons]
constructor
· simp only [term.val, one_mul, zero_add, coeffs.val_set]
apply h1
· apply holds_nonneg_consts_core (k + 1) bs
#align omega.nat.holds_nonneg_consts_core Omega.Nat.holds_nonnegConstsCore
theorem holds_nonnegConsts {v : Nat → Int} {bs : List Bool} :
(∀ x, 0 ≤ v x) → ∀ t ∈ nonnegConsts bs, 0 ≤ Term.val v t
| h1 => by apply holds_nonneg_consts_core h1
#align omega.nat.holds_nonneg_consts Omega.Nat.holds_nonnegConsts
theorem exists_clause_holds {v : Nat → Nat} {p : Preform} :
p.NegFree → p.SubFree → p.Holds v → ∃ c ∈ dnf p, Clause.Holds (fun x => ↑(v x)) c :=
by
intro h1 h2 h3
rcases exists_clause_holds_core h1 h2 h3 with ⟨c, h4, h5⟩
exists nonnegate c
have h6 : nonnegate c ∈ dnf p := by
simp only [dnf]
rw [List.mem_map]
refine' ⟨c, h4, rfl⟩
refine' ⟨h6, _⟩
cases' c with eqs les
simp only [nonnegate, clause.holds]
constructor
apply h5.left
rw [List.forall_mem_append]
apply And.intro (holds_nonneg_consts _) h5.right
intro x
apply Int.coe_nat_nonneg
#align omega.nat.exists_clause_holds Omega.Nat.exists_clause_holds
theorem exists_clause_sat {p : Preform} :
p.NegFree → p.SubFree → p.Sat → ∃ c ∈ dnf p, Clause.Sat c :=
by
intro h1 h2 h3; cases' h3 with v h3
rcases exists_clause_holds h1 h2 h3 with ⟨c, h4, h5⟩
refine' ⟨c, h4, _, h5⟩
#align omega.nat.exists_clause_sat Omega.Nat.exists_clause_sat
theorem unsat_of_unsat_dnf (p : Preform) :
p.NegFree → p.SubFree → Clauses.Unsat (dnf p) → p.Unsat :=
by
intro hnf hsf h1 h2; apply h1
apply exists_clause_sat hnf hsf h2
#align omega.nat.unsat_of_unsat_dnf Omega.Nat.unsat_of_unsat_dnf
end Nat
end Omega
|
# MadNLP.jl
# Created by Sungho Shin ([email protected])
module MadNLPMa86
import ..MadNLPHSL:
@kwdef, Logger, @debug, @warn, @error, libhsl,
SparseMatrixCSC, SubVector, StrideOneVector,
SymbolicException,FactorizationException,SolveException,InertiaException,
AbstractOptions, AbstractLinearSolver, set_options!,
introduce, factorize!, solve!, improve!, is_inertia, inertia
import ..MadNLPHSL: Mc68
const INPUT_MATRIX_TYPE = :csc
@enum(Ordering::Int,AMD = 1, METIS = 3)
@enum(Scaling::Int,SCALING_NONE = 0, MC64 = 1, MC77 = 2)
@kwdef mutable struct Options <: AbstractOptions
ma86_num_threads::Int = 1
ma86_print_level::Float64 = -1
ma86_nemin::Int = 32
ma86_order::Ordering = METIS
ma86_scaling::Scaling = SCALING_NONE
ma86_small::Float64 = 1e-20
ma86_static::Float64 = 0.
ma86_u::Float64 = 1e-8
ma86_umax::Float64 = 1e-4
end
@kwdef mutable struct Control
f_arrays::Int32 = 0
diagnostics_level::Int32 = 0
unit_diagnostics::Int32 = 0
unit_error::Int32 = 0
unit_warning::Int32 = 0
nemin::Int32 = 0
nb::Int32 = 0
action::Int32 = 0
nbi::Int32 = 0
pool_size::Int32 = 0
small::Float64 = 0.
static::Float64 = 0.
u::Float64 = 0.
umin::Float64 = 0.
scaling::Int32 = 0
end
@kwdef mutable struct Info
detlog::Float64 = 0.
detsign::Int32 = 0
flag::Int32 = 0
matrix_rank::Int32 = 0
maxdepth::Int32 = 0
num_delay::Int32 = 0
num_factor::Clong = 0
num_flops::Clong = 0
num_neg::Int32 = 0
num_nodes::Int32 = 0
num_nothresh::Int32 = 0
num_perturbed::Int32 = 0
num_two::Int32 = 0
pool_size::Int32 = 0
stat::Int32 = 0
usmall::Float64 = 0.
end
mutable struct Solver<:AbstractLinearSolver
csc::SparseMatrixCSC{Float64,Int32}
control::Control
info::Info
mc68_control::Mc68.Control
mc68_info::Mc68.Info
order::Vector{Int32}
keep::Vector{Ptr{Nothing}}
opt::Options
logger::Logger
end
ma86_default_control_d(control::Control) = ccall(
(:ma86_default_control_d,libhsl),
Nothing,
(Ref{Control},),
control)
ma86_analyse_d(n::Cint,colptr::StrideOneVector{Cint},rowval::StrideOneVector{Cint},
order::StrideOneVector{Cint},keep::Vector{Ptr{Nothing}},
control::Control,info::Info) = ccall(
(:ma86_analyse_d,libhsl),
Nothing,
(Cint,Ptr{Cint},Ptr{Cint},Ptr{Cdouble},
Ptr{Ptr{Nothing}},Ref{Control},Ref{Info}),
n,colptr,rowval,order,keep,control,info)
ma86_factor_d(n::Cint,colptr::StrideOneVector{Cint},rowval::StrideOneVector{Cint},
nzval::StrideOneVector{Cdouble},order::StrideOneVector{Cint},
keep::Vector{Ptr{Nothing}},control::Control,info::Info,
scale::Ptr{Nothing}) = ccall(
(:ma86_factor_d,libhsl),
Nothing,
(Cint,Ptr{Cint},Ptr{Cint},Ptr{Cdouble},Ptr{Cint},
Ptr{Ptr{Nothing}},Ref{Control},Ref{Info},Ptr{Nothing}),
n,colptr,rowval,nzval,order,keep,control,info,scale)
ma86_solve_d(job::Cint,nrhs::Cint,n::Cint,rhs::Vector{Cdouble},
order::Vector{Cint},keep::Vector{Ptr{Nothing}},
control::Control,info::Info,scale::Ptr{Nothing}) = ccall(
(:ma86_solve_d,libhsl),
Nothing,
(Cint,Cint,Cint,Ptr{Cdouble},Ptr{Cint},Ptr{Ptr{Nothing}},
Ref{Control},Ref{Info},Ptr{Nothing}),
job,nrhs,n,rhs,order,keep,control,info,scale)
ma86_finalize_d(keep::Vector{Ptr{Nothing}},control::Control)=ccall(
(:ma86_finalise_d,libhsl),
Nothing,
(Ptr{Ptr{Nothing}},Ref{Control}),
keep,control)
ma86_set_num_threads(n) = ccall((:omp_set_num_threads_,libhsl),
Cvoid,
(Ref{Int32},),
Int32(n))
function Solver(csc::SparseMatrixCSC{Float64,Int32};
option_dict::Dict{Symbol,Any}=Dict{Symbol,Any}(),
opt=Options(),logger=Logger(),
kwargs...)
set_options!(opt,option_dict,kwargs)
ma86_set_num_threads(opt.ma86_num_threads)
order = Vector{Int32}(undef,csc.n)
info=Info()
control=Control()
mc68_info = Mc68.Info()
mc68_control = Mc68.get_mc68_default_control()
keep = [C_NULL]
mc68_control.f_array_in=1
mc68_control.f_array_out=1
Mc68.mc68_order_i(Int32(opt.ma86_order),Int32(csc.n),csc.colptr,csc.rowval,order,mc68_control,mc68_info)
ma86_default_control_d(control)
control.diagnostics_level = Int32(opt.ma86_print_level)
control.f_arrays = 1
control.nemin = opt.ma86_nemin
control.small = opt.ma86_small
control.u = opt.ma86_u
control.scaling = Int32(opt.ma86_scaling)
ma86_analyse_d(Int32(csc.n),csc.colptr,csc.rowval,order,keep,control,info)
info.flag<0 && throw(SymbolicException())
M = Solver(csc,control,info,mc68_control,mc68_info,order,keep,opt,logger)
finalizer(finalize,M)
return M
end
function factorize!(M::Solver)
ma86_factor_d(Int32(M.csc.n),M.csc.colptr,M.csc.rowval,M.csc.nzval,
M.order,M.keep,M.control,M.info,C_NULL)
M.info.flag<0 && throw(FactorizationException())
return M
end
function solve!(M::Solver,rhs::StrideOneVector{Float64})
ma86_solve_d(Int32(0),Int32(1),Int32(M.csc.n),rhs,
M.order,M.keep,M.control,M.info,C_NULL)
M.info.flag<0 && throw(SolveException())
return rhs
end
is_inertia(::Solver)=true
function inertia(M::Solver)
return (M.info.matrix_rank-M.info.num_neg,M.csc.n-M.info.matrix_rank,M.info.num_neg)
end
finalize(M::Solver) = ma86_finalize_d(M.keep,M.control)
function improve!(M::Solver)
if M.control.u == M.opt.ma86_umax
@debug(M.logger,"improve quality failed.")
return false
end
M.control.u = min(M.opt.ma86_umax,M.control.u^.75)
@debug(M.logger,"improved quality: pivtol = $(M.control.u)")
return true
end
introduce(::Solver)="ma86"
end # module
|
(** Coq coding by choukh, June 2022 **)
From HF Require Export Meta.
Reserved Notation "x ⨮ y" (at level 65, right associativity).
Reserved Notation "x ∈ y" (at level 70).
(** 遗传有穷结构 **)
Class HF := {
集 : Type;
空 : 集;
并 : 集 → 集 → 集
where "x ⨮ y" := (并 x y) (* {x} ∪ y *)
and "x ∈ y" := (x ⨮ y = y);
栖 x y : x ⨮ y ≠ 空;
入 x y : x ∈ x ⨮ y;
易 x y z : x ⨮ y ⨮ z = y ⨮ x ⨮ z;
属 x y z : x ∈ y ⨮ z → x = y ∨ x ∈ z;
强归纳 (P : 集 → Type) : P 空 → (∀ x y, P x → P y → P (x ⨮ y)) → ∀ x, P x;
}.
Coercion 集 : HF >-> Sortclass.
Arguments 空 {_}.
Notation "∅" := 空 : hf_scope.
Notation "x ⨮ y" := (并 x y) : hf_scope.
Notation "x ∈ y" := (x ⨮ y = y) : hf_scope.
Notation "x ∉ y" := (x ⨮ y ≠ y) (at level 70) : hf_scope.
Notation "x ⊆ y" := (∀ z, z ∈ x → z ∈ y) (at level 70) : hf_scope.
Notation "x ⊈ y" := (¬ x ⊆ y) (at level 70) : hf_scope.
Notation "x ⁺" := (x ⨮ x) (at level 50) : hf_scope.
Notation "{ x , }" := (x ⨮ ∅) (format "{ x , }") : hf_scope.
Notation "{ x , y }" := (x ⨮ {y,}) : hf_scope.
Notation 栖居 x := (∃ y, y ∈ x).
Notation "∀ x .. y ∈ A , P" :=
(∀ x, x ∈ A → (.. (∀ y, y ∈ A → P) ..))
(only parsing, at level 200, x binder, right associativity) : hf_scope.
Notation "∃ x .. y ∈ A , P" :=
(∃ x, x ∈ A ∧ (.. (∃ y, y ∈ A ∧ P) ..))
(only parsing, at level 200, x binder, right associativity) : hf_scope.
Ltac hf_ind x := pattern x; revert x; apply 强归纳.
(* 基本事实 *)
Section Basic.
Context {𝓜 : HF}.
Implicit Types x y z : 𝓜.
Theorem 空集定理 x : x ∉ ∅.
Proof. intros []%栖. Qed.
Example 并运算测试 : {{∅,},} ≠ {∅,}.
Proof.
intros H. assert (H' := H). rewrite <- 入, H in H'.
apply 属 in H' as [H'|H']; now apply 空集定理 in H'.
Qed.
Theorem 并运算规范 x y z : z ∈ x ⨮ y ↔ z = x ∨ z ∈ y.
Proof.
split.
- apply 属.
- intros [-> | H].
+ apply 入.
+ now rewrite 易, H.
Qed.
Fact 并作子集 x y z : x ⨮ y ⊆ z ↔ x ∈ z ∧ y ⊆ z.
Proof.
split.
- intros H. split.
+ apply H, 入.
+ intros a ay. apply H, 并运算规范. now right.
- intros [H1 H2] a [->|]%并运算规范; auto.
Qed.
Fact 空集的子集 x : x ⊆ ∅ → x = ∅.
Proof.
hf_ind x.
- auto.
- intros x y _ _ H.
assert (x0: x ∈ ∅) by apply H, 入.
contradict (空集定理 x0).
Qed.
Fact 空集可判定 x : x = ∅ ∨ 栖居 x.
Proof.
hf_ind x.
- now left.
- intros x y _ _. right. exists x. apply 入.
Qed.
Fact 非空即栖居 x : x ≠ ∅ ↔ 栖居 x.
Proof.
destruct (空集可判定 x) as [->|[y yx]]; split.
- easy.
- intros [x x0]. contradict (空集定理 x0).
- eauto.
- intros _ ->. contradict (空集定理 yx).
Qed.
Definition 传递 x := ∀ y z, y ∈ z → z ∈ x → y ∈ x.
End Basic.
(** 自动化 **)
Lemma 全称等价左 T P Q : (∀ x : T, P x ↔ Q x) → ∀ x, P x → Q x.
Proof. firstorder. Qed.
Lemma 全称等价右 T P Q : (∀ x : T, P x ↔ Q x) → ∀ x, Q x → P x.
Proof. firstorder. Qed.
Ltac 非前提 P := match goal with
|[_ : P |- _] => fail 1
| _ => idtac
end.
Ltac 加前提 H := let T := type of H in 非前提 T; generalize H; intro.
Ltac 引入 := match goal with
|[ |- _ → _ ] => intro
|[ |- _ ∧ _ ] => split
|[ |- _ ↔ _] => split
|[ |- ¬ _ ] => intro
|[ |- ∀ _, _ ] => intro
|[ |- _ ∈ _ ⨮ _] => apply 并运算规范
|[ |- 栖居 _] => apply 非空即栖居
|[ |- 传递 _] => hnf
end.
Ltac 消去 := match goal with
|[H: Σ _, _ |- _ ] => destruct H
|[H: ∃ _, _ |- _ ] => destruct H
|[H: _ ∧ _ |- _ ] => destruct H
|[H: _ * _ |- _] => destruct H
|[H: ∀ _, _ ↔ _ |- _] => 加前提 (全称等价左 H); 加前提 (全称等价右 H); clear H
|[H: ?P ∨ ?Q |- _] => 非前提 P; 非前提 Q; destruct H
|[H: ?P + ?Q |- _] => 非前提 P; 非前提 Q; destruct H
|[H: _ ⨮ _ = ∅ |- _] => destruct (栖 H)
|[H: ∅ = _ ⨮ _ |- _] => destruct (栖 (eq_sym H))
|[H: _ ∈ ∅ |- _] => destruct (空集定理 H)
|[H: ?z ∈ ?x ⨮ _ |- _] => apply 并运算规范 in H as [|]
|[H: _ ⨮ _ ⊆ _ |- _ ] => apply 并作子集 in H as []
|[H: _ ⊆ ∅ |- _] => apply 空集的子集 in H as ->
|[H: 传递 ?x, H': _ ∈ ?x |- _] => 加前提 (H _ H')
end.
Ltac hf n := repeat progress (reflexivity || subst || 引入 || 消去);
try tauto; match n with
| O => idtac
| S ?n => match goal with
|[ |- _ ∨ _] => solve [left; hf n | right; hf n]
|[ |- _ + _] => solve [left; hf n | right; hf n]
|[ |- 可判定 _] => solve [left; hf n | right; hf n]
|[ |- ?x ⨮ ?y ⨮ ?z = ?y ⨮ ?x ⨮ ?z ] => apply 易
|[ |- ?x ∈ ?x ⨮ ?y ] => apply 入
|[ |- ?x ⨮ ?y = ?x ⨮ ?x ⨮ ?y ] => now rewrite 入
|[H: ?X |- ∃ x : ?X, _ ] => exists H; hf n
|[H: ∀ x, x ∈ ?z → _, H': ?X ∈ ?z |- _ ] => 加前提 (H X H'); clear H; hf n
|[H: ∀ x, _ → x ∈ ?z |- _ ∈ ?z] => apply H; hf n
|[H: ?x ⊆ _, H': ?z ∈ ?x |- _ ] => 加前提 (H z H'); clear H; hf n
end
end.
Tactic Notation "hf" := cbn; solve [hf 7].
|
Cullen was born in <unk> @-@ Ontario on August 2 , 1964 . He is one of six children of Barry and Loretta Cullen . His father and uncles Brian and Ray all played in the NHL , and while Cullen and his three brothers all played as well , their father never pressured them , preferring that they enjoy the game .
|
A spate of mass killings in southern Venezuela is stirring international concern as the country’s political and economic crisis continues to drive a migrant exodus.
Read my Q&A with International Crisis Group.
The Dutch island’s geographic proximity – it lies 65 kilometres north of the Venezuelan coast – and cultural and economic ties to its mainland neighbour make Curaçao a logical destination for those fleeing Venezuela’s economic meltdown and autocratic rule.
Yet the island is anything but a safe haven.
Read my article for VICE Canada.
|
# Lecture 13 - Advanced Curve Fitting: Gaussian Processes to Encode Prior Knowledge about Functions
```python
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set_context('talk')
sns.set_style('white')
```
## Objectives
+ Express prior knowledge/beliefs about unknown functions using Gaussian process (GP).
+ Sample functions from the probability measure defined by GP.
## Readings
+ [Chapter 1 from C.E. Rasmussen's textbook on Gaussian processes](http://www.gaussianprocess.org/gpml/chapters/RW1.pdf).
+ (Optional video lecture) [Neil Lawrence's video lecture on Introduction to Gaussian processes](https://www.youtube.com/watch?v=ewJ3AxKclOg).
## Motivation: A fully Bayesian paradigm for curve fitting
Gaussian process regression is Bayesian regression on steroids.
However, understanding how it works requires a change of mind.
After a bit of practice it starts making sense.
Here is how it works:
+ Let's say that you have to learn some function $f(\cdot)$ from some space $\mathcal{X}$ to $\mathbb{R}$ (this could either be a supervised learning problem (regression or classification) or even an unsupervised learning problem.
+ You sit down and you think about $f(\cdot)$. What do you know about it? How large do you expect it be? How small do you expect it be? Is it continuous? Is it differentiable? Is it periodic? How fast does it change as you change its inputs?
+ You create a probability measure on the space of functions in which $f(\cdot)$ lives which is compatible with everything you know about it. Abusing mathematical notation a lot, let's write this probability measure as $p(f(\cdot))$. Now you can sample from it. Any sample you take is compatible with your prior beliefs. You cannot tell which one is better than any other. Any of them could be the true $f(\cdot)$.
+ Then, you get a little bit of data, say $\mathcal{D}$. You model the likelihood of the data, $p(\mathcal{D}|f(\cdot))$, i.e., you model how the data may have been generated if you knew $f(\cdot)$.
+ Finally, you use Bayes' rule to come up with your posterior probability measure over the space of functions:
$$
p(f(\cdot)|\mathcal{D}) \propto p(\mathcal{D}|f(\cdot)) p(f(\cdot)),
$$
which is simultaneously compatible with your prior beliefs and the data.
Again, we are abusing mathematical notation here sinc you cannot really write down the probability density corresponding to a random function.
But you get the point.
This is it.
As Persi Diaconis' said in an 1988 paper:
> Most people, even Bayesians, think that this sounds crazy when they first hear about it.
Where do Gaussian processes come in?
Well, it is just the equivalent of the multivariate Gaussian for function spaces.
It defines a probability measure on the space of functions that is centered about a mean (function) and shaped by a covariance (function).
In this lecture, we will show that the mean function and the covariance function is the place where you can encode your prior knowledge.
We will also show how you can sample functions from this probability measure.
Next time, we will show how you can condition these probability measures on observations.
## Some mathematical terminology
A *stochatic process* is just a collection of random variables that are labeled by some index: $\{X_i\}$ for some $i$ in a set $I$.
If the set $I$ is discrete, then we say that we have a discrete stochastic process.
If the set $I$ is continuous, then we have a continuous stochastic process.
We will mostly work with continuous stochastic processes in this class.
For example, $X_t = X(t)$ is a stochastic process parameterized by time.
You can also think of a stochastic process as a random function.
Here is how, you sample an $\omega$, you keep it fixed, and then $X(t,\omega)$ is just a function of time. (Remember what we learned in earlier lectures: a random variable is just a function from the event space to the real numbers).
Of course, you can have a stochastic process that is parameterized by space, for example $T(x,\omega)$, could be an unknown temperature field.
This is typically called a random field.
You can also have a stochastic process that is parameterized by both space and time, say $T(x,t,\omega)$.
This is a unknown spatiotemporal temperature field.
As a matter of fact, you can have a stochastic process parameterized by any continuous label you like.
It does not have to be space or time.
And also, you can have as many different labels as you like.
Gaussian processes are the simplest continuous stochastic processes you can have.
## Gaussian process
A Gaussian process (GP) is a generalization of a multivariate Gaussian distribution to
*infinite* dimensions.
It essentially defines a probability measure on a function space.
When we say that $f(\cdot)$ is a GP, we mean that it is a random variable that is actually
a function.
Mathematically, we write:
\begin{equation}
f(\cdot) \sim \mbox{GP}\left(m(\cdot), k(\cdot, \cdot) \right),
\end{equation}
where
$m:\mathbb{R}^d \rightarrow \mathbb{R}$ is the *mean function* and
$k:\mathbb{R}^d \times \mathbb{R}^d \rightarrow \mathbb{R}$ is the *covariance function*.
So, compared to a multivariate normal we have:
+ A random function $f(\cdot)$ instead of a random vector $\mathbf{x}$.
+ A mean function $m(\cdot)$ instead of a mean vector $\boldsymbol{\mu}$.
+ A covariance function $k(\cdot,\cdot)$ instead of a covariance matrix $\mathbf{\Sigma}$.
But, what does this definition actually mean? Actually, it gets its meaning from the multivariate Gaussian distribution. Here is how:
+ Let $\mathbf{x}_{1:n}=\{\mathbf{x}_1,\dots,\mathbf{x}_n\}$ be $n$ points in $\mathbb{R}^d$.
+ Let $\mathbf{f}\in\mathbb{R}^n$ be the outputs of $f(\cdot)$ on each one of the elements of $\mathbf{x}_{1:n}$, i.e.,
$$
\mathbf{f} =
\left(
\begin{array}{c}
f(\mathbf{x}_1)\\
\vdots\\
f(\mathbf{x}_n)
\end{array}
\right).
$$
+ The fact that $f(\cdot)$ is a GP with mean and covariance function $m(\cdot)$ and $k(\cdot,\cdot)$, respectively, *means* that the vector of outputs $\mathbf{f}$ at
the arbitrary inputs in $\mathbf{X}$ is the following multivariate-normal:
$$
\mathbf{f} | \mathbf{x}_{1:n}, m(\cdot), k(\cdot, \cdot) \sim \mathcal{N}\left(\mathbf{m}(\mathbf{x}_{1:n}), \mathbf{K}(\mathbf{x}_{1:n}, \mathbf{x}_{1:n}) \right),
$$
with mean vector:
$$
\mathbf{m}(\mathbf{x}_{1:n}) =
\left(
\begin{array}{c}
m(\mathbf{x}_1)\\
\vdots\\
m(\mathbf{x}_n)
\end{array}
\right),
$$
and covariance matrix:
$$
\mathbf{K}(\mathbf{x}_{1:n},\mathbf{x}_{1:n}) = \left(
\begin{array}{ccc}
k(\mathbf{x}_1,\mathbf{x}_1) & \dots & k(\mathbf{x}_1, \mathbf{x}_n)\\
\vdots & \ddots & \vdots\\
k(\mathbf{x}_n, \mathbf{x}_1) & \dots & k(\mathbf{x}_n, \mathbf{x}_n)
\end{array}
\right).
$$
Now that we have defined a Gaussian process (GP), let us talk about we encode our prior beliefs into a GP.
We do so through the mean and covariance functions.
### Interpretation of the mean function
What is the meaning of $m(\cdot)$?
Well, it is quite easy to grasp.
For any point $\mathbf{x}\in\mathbb{R}^d$, $m(\mathbf{x})$ should give us the value we believe is more probable for
$f(\mathbf{x})$.
Mathematically, $m(\mathbf{x})$ is nothing more than the expected value of the random variable $f(\mathbf{x})$.
That is:
\begin{equation}
m(\mathbf{x}) = \mathbb{E}[f(\mathbf{x})].
\end{equation}
The mean function can be any arbitrary function. Essentially, it tracks generic trends in the response as the input is varied. In practice, we try and make a suitable choice for the mean function that is easy to work with. Such choices include:
+ zero, i.e.,
$$
m(\mathbf{x}) = 0.
$$
+ a constant, i.e.,
$$
m(\mathbf{x}) = c,
$$
where $c$ is a parameter.
+ linear, i.e.,
$$
m(\mathbf{x}) = c_0 + \sum_{i=1}^dc_ix_i,
$$
where $c_i, i=0,\dots,d$ are parameters.
+ using a set of $m$ basis functions (generalized linear model), i.e.,
$$
m(\mathbf{x}) = \sum_{i=1}^mc_i\phi_i(\mathbf{x}),
$$
where $c_i$ and $\phi_i(\cdot)$ are parameters and basis functions.
+ generalized polynomial chaos (gPC), i.e.,
using a set of $d$ polynomial basis functions upto a given degree $\rho$
$m(\mathbf{x}) = \sum_{i=1}^{d}c_i\phi_i(\mathbf{x})$
where the basis functions $\phi_i$ are mutually orthonormal with respect to some
measure $\mu$:
$$
\int \phi_{i}(\mathbf{x}) \phi_{j}(\mathbf{x}) d\mu(\mathbf{x}) = \delta_{ij}
$$
+ and many other possibilities.
### Interpretation of the covariance function
What is the meaning of $k(\cdot, \cdot)$?
This concept is considerably more challenging than the mean.
Let's try to break it down:
+ Let $\mathbf{x}\in\mathbb{R}^d$. Then $k(\mathbf{x}, \mathbf{x})$ is the variance of the random variable $f(\mathbf{x})$, i.e.,
$$
\mathbb{V}[f(\mathbf{x})] = \mathbb{E}\left[\left(f(\mathbf{x}) - m(\mathbf{x}) \right)^2 \right].
$$
In other words, we believe that there is about $95\%$ probability that the value of
the random variable $f(\mathbf{x})$ fall within the interval:
$$
\left((m(\mathbf{x}) - 2\sqrt{k(\mathbf{x}, \mathbf{x})}, m(\mathbf{x}) + 2\sqrt{k(\mathbf{x},\mathbf{x})}\right).
$$
+ Let $\mathbf{x},\mathbf{x}'\mathbb{R}^d$. Then $k(\mathbf{x}, \mathbf{x}')$ tells us how the random variable $f(\mathbf{x})$ and
$f(\mathbf{x}')$ are correlated. In particular, $k(\mathbf{x},\mathbf{x}')$ is equal to the covariance
of the random variables $f(\mathbf{x})$ and $f(\mathbf{x}')$, i.e.,
$$
k(\mathbf{x}, \mathbf{x}') = \mathbb{C}[f(\mathbf{x}), f(\mathbf{x}')]
= \mathbb{E}\left[
\left(f(\mathbf{x}) - m(\mathbf{x})\right)
\left(f(\mathbf{x}') - m(\mathbf{x}')\right)
\right].
$$
Essentially, a covariance function (or covariance kernel) defines a nearness or similarity measure on the input space. We cannot choose any arbitrary function of two variables as a covariance kernel. How we go about choosing a covariance function is discussed in great detail [here](http://www.gaussianprocess.org/gpml/chapters/RW4.pdf). We briefly discuss some properties of covariance functions here and then we shall move onto a discussion of what kind of prior beliefs we can encode through the covariance function.
### Properties of the covariance function
+ There is one property of the covariance function that we can note right away.
Namely, that for any $\mathbf{x}\in\mathbb{R}^d$, $k(\mathbf{x}, \mathbf{x}) > 0$.
This is easly understood by the interpretation of $k(\mathbf{x}, \mathbf{x})$ as the variance
of the random variable $f(\mathbf{x})$.
+ $k(\mathbf{x}, \mathbf{x}')$ becomes smaller as the distance between $\mathbf{x}$ and $\mathbf{x}'$ grows.
+ For any choice of points $\mathbf{X}\in\mathbb{R}^{n\times d}$, the covariance matrix: $\mathbf{K}(\mathbf{X}, \mathbf{X})$ has
to be positive-definite (so that the vector of outputs $\mathbf{f}$ is indeed a multivariate
normal distribution).
### Encoding prior beliefs in the covariance function
+ **Modeling regularity**. The choice of the covariance function controls the regularity properties of the functions sampled from the probability induced by the GP. For example, if the covariance kernel chosen is the squared exponential kernel, which is infinitely differentiable, then the functions sampled from the GP will also be infinitely differentiable.
+ **Modeling invariance** If the covariance kernel is invariant w.r.t. a transformation $T$, i.e., $k(\mathbf{x}, T\mathbf{x}')=k(T\mathbf{x}, \mathbf{x}')=k(\mathbf{x}, \mathbf{x}')$ then samples from the GP will be invariant w.r.t. the same transformation.
+ Other possibilities include periodicity, additivity etc.
### Squared exponential covariance function
Squared expnential (SE) is the most commonly used covariance function.
Its formula is as follows:
$$
k(\mathbf{x}, \mathbf{x}') = v\exp\left\{-\frac{1}{2}\sum_{i=1}^d\frac{(x_i - x_i')^2}{\ell_i^2}\right\},
$$
where $v,\ell_i>0, i=1,\dots,d$ are parameters.
The interpretation of the parameters is as follows:
+ $v$ is known as the *signal strength*. The bigger it is, the more the GP $f(\cdot)$ will vary
about the mean.
+ $\ell_i$ is known as the *length scale* of the $i$-th input dimension of the GP.
The bigger it is, the smoother the samples of $f(\cdot)$ appear along the $i$-th input dimension.
Let's experiment with this for a while:
```python
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns # Comment this out if you don't have it
sns.set_style('white')
sns.set_context('talk')
import GPy
# The input dimension
dim = 1
# The variance of the covariance kernel
variance = 1.
# The lengthscale of the covariance kernel
ell = 0.3
# Generate the covariance object
k = GPy.kern.RBF(dim, variance=variance, lengthscale=ell)
# Print it
print (k)
# and plot it
k.plot();
```
### Example 1: Plotting a covariance function
Remember:
> The covariance function $k(x,x')$ measures the similarity of $f(x)$ and $f(x')$.
The interactive tools provided, draw $k(\mathbf{x}, \mathbf{x}'=0)$ in one and two dimensions.
Use them to answer the following questions:
+ What is the intuitive meaning of $\ell$?
+ What is the intuitive meaning of $v$?
+ There are many other covariance functions that we could be using. Try changing ``RBF`` to ``Exponential``. What changes do you nottice.
+ Repeat the previous steps on a 2D covariance function.
+ If you still have time, try a couple of other covariances, e.g., ``Matern32``, ``Matern52``.
+ If you still have time, explore ``help(GPy.kern)``.
```python
from ipywidgets import interactive
def plot_kernel(variance=1., ell=0.3):
k = GPy.kern.RBF(dim, variance=variance, lengthscale=ell)
k.plot()
plt.ylim(0, 10)
interactive(plot_kernel, variance=(1e-3, 10., 0.01), ell=(1e-3, 10., 0.01))
```
interactive(children=(FloatSlider(value=1.0, description='variance', max=10.0, min=0.001, step=0.01), FloatSli…
```python
from ipywidgets import interactive
def plot_kernel(variance=1., ell1=0.3, ell2=0.3):
k = GPy.kern.RBF(2, ARD=True, variance=variance,
lengthscale=[ell1, ell2]) # Notice that I just changed the dimension here
k.plot()
interactive(plot_kernel, variance=(1e-3, 10., 0.01), ell1=(1e-3, 10., 0.01), ell2=(1e-3, 10., 0.01))
```
interactive(children=(FloatSlider(value=1.0, description='variance', max=10.0, min=0.001, step=0.01), FloatSli…
### Example 2: Properties of the covariance matrix
Let $\mathbf{x}_{1:n}$ be an arbitrary set of input points. The covariance matrix $\mathbf{K}\in\mathbb{R}^{n\times n}$ defined by:
$$
\mathbf{K}\equiv\mathbf{K}(\mathbf{x}_{1:n}, \mathbf{x}_{1:n}) = \left(
\begin{array}{ccc}
k(\mathbf{x}_1,\mathbf{x}_1) & \dots & k(\mathbf{x}_1, \mathbf{x}_n)\\
\vdots & \ddots & \vdots\\
k(\mathbf{x}_n, \mathbf{x}_1) & \dots & k(\mathbf{x}_n, \mathbf{x}_n)
\end{array}
\right),
$$
must be [positive definite](https://en.wikipedia.org/wiki/Positive-definite_matrix). Mathematically this can be expressed in two equivalent ways:
+ For all vectors $\mathbf{v}\in\mathbb{R}^T$, we have:
$$
\mathbf{v}^t\mathbf{K}\mathbf{v} > 0,
$$
+ All the eigenvalues of $\mathbf{K}$ are positive.
Using the code provided:
+ Verify that the the sum of two covariance functions is a valid covariance function.
+ Verify that the product of two covariance functions is a valid covariance function.
+ Is the following function a covariance function:
$$
k(x, x') = k_1(x, x')k_2(x, x') + k_3(x, x') + k_4(x, x'),
$$
where all $k_i(x, x')$'s are covariance functions.
+ What about:
$$
k(x, x') = k_1(x, x') / k_2(x, x')?
$$
```python
# Number of dimensions
dim = 1
# Number of input points
n = 20
# The lengthscale
ell = .1
# The variance
variance = 1.
# The covariance function
k1 = GPy.kern.RBF(dim, lengthscale=ell, variance=variance)
# Draw a random set of inputs points in [0, 1]^dim
X = np.random.rand(n, dim)
# Evaluate the covariance matrix on these points
K = k1.K(X)
# Compute the eigenvalues of this matrix
eig_val, eig_vec = np.linalg.eigh(K)
# Plot the eigenvalues (they should all be positive)
print ('> plotting eigenvalues of K')
print ('> they must all be positive')
fig, ax = plt.subplots()
ax.plot(np.arange(1, n+1), eig_val, '.')
ax.set_xlabel('$i$', fontsize=16)
ax.set_ylabel('$\lambda_i$', fontsize=16)
```
```python
# Now create another (arbitrary) covariance function
k2 = GPy.kern.Exponential(dim, lengthscale=0.2, variance=2.1)
# Create a new covariance function that is the sum of these two:
k_new = k1 + k2
# Let's plot the new covariance
fig, ax = plt.subplots()
k1.plot(ax=ax, label='$k_1$')
k2.plot(ax=ax, label='$k_2$')
k_new.plot(ax=ax, label='$k_1 + k_2$')
plt.legend(fontsize=16);
```
```python
# If this is a valid covariance function, then it must
# be positive definite
# Compute the covariance matrix:
K_new = k_new.K(X)
# and its eigenvalues
eig_val_new, eig_vec_new = np.linalg.eigh(K_new)
# Plot the eigenvalues (they should all be positive)
print ('> plotting eigenvalues of K')
print ('> they must all be positive')
fig, ax = plt.subplots()
ax.plot(np.arange(1, n+1), eig_val_new, '.')
ax.set_xlabel('$i$', fontsize=16)
ax.set_ylabel('$\lambda_i$', fontsize=16);
```
### Example 3: Sampling from a Gaussian process
Samples from a Gaussian process are functions. But, functions are infinite dimensional objects?
We cannot sample directly from a GP....
However, if we are interested in the values of $f(\cdot)$ at any given set of test points $\mathbf{x}_{1:n} = \{\mathbf{x}_1,\dots,\mathbf{x}_b\}$, then we have that:
$$
\mathbf{f} | \mathbf{x}_{1:n} \sim \mathcal{N}\left(\mathbf{m}(\mathbf{x}_{1:n}), \mathbf{K}(\mathbf{x}_{1:n}, \mathbf{x}_{1:n}) \right),
$$
where all the quantities have been introduced above.
This is
What we are going to do is pick a dense set of points $\mathbf{x}_{1:n}\in\mathbb{R}^{n\times d}$
sample the value of the GP, $\mathbf{f} = (f(\mathbf{x}_1),\dots,f(\mathbf{x}_n))$ on these points.
We saw above that the probability density of $\mathbf{f}$ is just a multivariate normal
with a mean vector that is specified from the mean function and a covariance matrix
that is specified by the covariance function.
Therefore, all we need to know is how to sample from the multivariate normal.
This is how we do it:
+ Compute the Cholesky of $\mathbf{L}$:
$$
\mathbf{K} = \mathbf{L}\mathbf{L}^T.
$$
+ Draw $n$ random samples $\mathbf{z} = (z_1,\dots,z_n)$ independently from a standard normal.
+ Get one sample by:
$$
\mathbf{f} = \mathbf{m} + \mathbf{L}\mathbf{z}.
$$
```python
# To gaurantee reproducibility
np.random.seed(123456)
# Number of test points
num_test = 10
# Pick a covariance function
k = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=.1)
# Pick a mean function
mean_func = lambda x: np.zeros(x.shape)
# Pick a bunch of points over which you want to sample the GP
X = np.linspace(0, 1, num_test)[:, None]
# Evaluate the mean function at X
m = mean_func(X)
# Compute the covariance function at these points
nugget = 1e-6 # This is a small number required for stability
C = k.K(X) + nugget * np.eye(X.shape[0])
# Compute the Cholesky of the covariance
# Notice that we need to do this only once
L = np.linalg.cholesky(C)
# Number of samples to take
num_samples = 3
# Take 3 samples from the GP and plot them:
fig, ax = plt.subplots()
# Plot the mean function
ax.plot(X, m)
for i in range(num_samples):
z = np.random.randn(X.shape[0], 1) # Draw from standard normal
f = m + np.dot(L, z) # f = m + L * z
ax.plot(X, f, color=sns.color_palette()[1], linewidth=1)
#ax.set_ylim(-6., 6.)
ax.set_xlabel('$x$', fontsize=16)
ax.set_ylabel('$y$', fontsize=16)
ax.set_ylim(-5, 5);
```
The solid line is the mean function and the dashed lines are 3 samples of f . These don’t look like functions yet. This is because we have used only 10 test points to represent the GP.
### Questions
1. Edit the code above changing the number of test points ``num_test`` to 20, 50, 100. Rerun the example. How do your samples of f look like now? Do they look more like functions to you? Imagine that the true nature of the GP appears when these test points become infinitely dense.
2. Edit the code above and change the random seed to an arbitrary integer (just make up one). Rerun the example and notice how the sampled functions change.
3. Edit the code above and change the variance first to 0.1 and then to 5 each time rerunning the example. Notice the values on the vertical axis of the plot. What happens to the sampled functions as you do this? What does the variance parameter of the SE control?
4. Edit the code above and now change the length-scale parameter first to 0.05 and then to 1. What happens to the sampled functions as you do this? What does the length- scale parameter of the SE control?
5. Now set the variance and the length-scale back to their original values (1. and 0.1, respectively). Edit the code and change the mean function to:
```
mean_fun = lambda(x): 5 * x
```
Re-run the example. What do you observe? Try a couple more. For example, try:
```
mean_fun = lambda(x): np.sin(5 * np.pi * x)
```
6. So far, all the samples we have seen are smooth. There is this theorem that says that the samples of the GP will be as smooth as the covariance function we use. Since the SE covariance is infinitely smooth, the samples we draw are infinitely smooth. The [Matern 3-2 covariance function](https://en.wikipedia.org/wiki/Matérn_covariance_function) is twice differentiable. Edit the code and
change ``RBF`` to ``Matern32``. Rerun the example. How smooth are the samples now?
7. The exponential covariance function is continuous but not differentiable. Edit the code and change ``RBF`` to ``Exponential``. Rerun the example. How smooth are the samples now?
8. The covariance function can also be used to model invariances. The periodic exponential covariance function is... a periodic covariance function. Edit line 29 and change ``RBF`` to
```
k = GPy.kern.PeriodicMatern32(input_dim=1, variance=500., lengthscale=0.01, period=0.1)
```
Rerun the example. Do you notice the periodic pattern?
9. How can you encode the information that there are two lengthscales in $f(\cdot)$. There are many ways to do this.
Try summing or multiplying covariance functions.
|
[STATEMENT]
lemma reduced_word_append_reduce_contra1:
assumes "\<not> reduced_word A as"
shows "\<not> reduced_word A (as@bs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
proof (cases "as \<in> lists A" "bs \<in> lists A" rule: two_cases)
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
4. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
case both
[PROOF STATE]
proof (state)
this:
as \<in> lists A
bs \<in> lists A
goal (4 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
4. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
define cs where cs: "cs \<equiv> ARG_MIN length cs. cs \<in> lists A \<and> sum_list cs = sum_list as"
[PROOF STATE]
proof (state)
this:
cs \<equiv> arg_min length (word_for A (sum_list as))
goal (4 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
4. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
with both(1)
[PROOF STATE]
proof (chain)
picking this:
as \<in> lists A
cs \<equiv> arg_min length (word_for A (sum_list as))
[PROOF STEP]
have "reduced_word_for A (sum_list as) cs"
[PROOF STATE]
proof (prove)
using this:
as \<in> lists A
cs \<equiv> arg_min length (word_for A (sum_list as))
goal (1 subgoal):
1. reduced_word_for A (sum_list as) cs
[PROOF STEP]
using reduced_word_for_def is_arg_min_arg_min_nat[of "word_for A (sum_list as)"]
[PROOF STATE]
proof (prove)
using this:
as \<in> lists A
cs \<equiv> arg_min length (word_for A (sum_list as))
reduced_word_for ?A ?a ?as \<equiv> is_arg_min length (word_for ?A ?a) ?as
word_for A (sum_list as) ?x \<Longrightarrow> is_arg_min ?m (word_for A (sum_list as)) (arg_min ?m (word_for A (sum_list as)))
goal (1 subgoal):
1. reduced_word_for A (sum_list as) cs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
reduced_word_for A (sum_list as) cs
goal (4 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
4. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
with assms both
[PROOF STATE]
proof (chain)
picking this:
\<not> reduced_word A as
as \<in> lists A
bs \<in> lists A
reduced_word_for A (sum_list as) cs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> reduced_word A as
as \<in> lists A
bs \<in> lists A
reduced_word_for A (sum_list as) cs
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
using reduced_word_for_lists reduced_word_for_sum_list
reduced_word_for_minimal[of A "sum_list as" cs as]
reduced_word_forI_compare[of A "sum_list as" cs as]
not_reduced_word_for[of "cs@bs" A "sum_list (as@bs)"]
[PROOF STATE]
proof (prove)
using this:
\<not> reduced_word A as
as \<in> lists A
bs \<in> lists A
reduced_word_for A (sum_list as) cs
reduced_word_for ?A ?a ?as \<Longrightarrow> ?as \<in> lists ?A
reduced_word_for ?A ?a ?as \<Longrightarrow> sum_list ?as = ?a
\<lbrakk>reduced_word_for A (sum_list as) cs; as \<in> lists A; sum_list as = sum_list as\<rbrakk> \<Longrightarrow> length cs \<le> length as
\<lbrakk>reduced_word_for A (sum_list as) cs; as \<in> lists A; sum_list as = sum_list as; length as = length cs\<rbrakk> \<Longrightarrow> reduced_word A as
\<lbrakk>cs @ bs \<in> lists A; sum_list (cs @ bs) = sum_list (as @ bs); length (cs @ bs) < length ?as\<rbrakk> \<Longrightarrow> \<not> reduced_word_for A (sum_list (as @ bs)) ?as
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<not> reduced_word A (as @ bs)
goal (3 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
case one
[PROOF STATE]
proof (state)
this:
as \<in> lists A
bs \<notin> lists A
goal (3 subgoals):
1. \<lbrakk>as \<in> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
3. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
as \<in> lists A
bs \<notin> lists A
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
using reduced_word_for_lists
[PROOF STATE]
proof (prove)
using this:
as \<in> lists A
bs \<notin> lists A
reduced_word_for ?A ?a ?as \<Longrightarrow> ?as \<in> lists ?A
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<not> reduced_word A (as @ bs)
goal (2 subgoals):
1. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
case other
[PROOF STATE]
proof (state)
this:
as \<notin> lists A
bs \<in> lists A
goal (2 subgoals):
1. \<lbrakk>as \<notin> lists A; bs \<in> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
2. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
as \<notin> lists A
bs \<in> lists A
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
using reduced_word_for_lists
[PROOF STATE]
proof (prove)
using this:
as \<notin> lists A
bs \<in> lists A
reduced_word_for ?A ?a ?as \<Longrightarrow> ?as \<in> lists ?A
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<not> reduced_word A (as @ bs)
goal (1 subgoal):
1. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
case neither
[PROOF STATE]
proof (state)
this:
as \<notin> lists A
bs \<notin> lists A
goal (1 subgoal):
1. \<lbrakk>as \<notin> lists A; bs \<notin> lists A\<rbrakk> \<Longrightarrow> \<not> reduced_word A (as @ bs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
as \<notin> lists A
bs \<notin> lists A
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
using reduced_word_for_lists
[PROOF STATE]
proof (prove)
using this:
as \<notin> lists A
bs \<notin> lists A
reduced_word_for ?A ?a ?as \<Longrightarrow> ?as \<in> lists ?A
goal (1 subgoal):
1. \<not> reduced_word A (as @ bs)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<not> reduced_word A (as @ bs)
goal:
No subgoals!
[PROOF STEP]
qed
|
#### Nguyễn Tiến Dũng
*CTTN Toán Tin - K62*
*20170062*
***Đại học Bách khoa Hà Nội***
---
## Phân phối dừng
Cho ma trận chuyển trạng thái $P$
Giả sử tại thời điểm $t$, $X$ có thể nhận các trạng thái $1, 2, 3,...,N$ với xác suất tương ứng là $\pi_1, \pi_2,..,\pi_N$.
Khi đó $\pi = \{\pi_1, \pi_2,...,\pi_N\}$ là vector phân phối tại thời điểm $t$. Khi đó nếu $\pi \times (I - P) = 0$ thì ta gọi vector phân phối xác suất $\pi$ là `phân phối dừng`.
----
## Phân phối giới hạn
Vector trạng thái $\pi_0 = \{\pi_1, \pi_2,...,\pi_N\}$ được gọi là có `phân phối giới hạn` nếu thỏa mãn:
\begin{aligned}
\left\{\begin{matrix}
\pi_1 + \pi_2 + ... + \pi_N & = 1\\
\underset{n \to \infty}{lim}P_{ij}^{(n)} & = \pi_j, \forall i
\end{matrix}\right.
\end{aligned}
---
### Ví dụ
Trong một thành phố có $1500000$ dân có 3 siêu thị lớn cạnh tranh nhau là `BigC`, `VinMart` và `Intimex`. Tại thời điểm ban đầu, người ta thấy có $400000$ khách vào `BigC`, $600000$ khách vào `VinMart` và $500000$ khách vào `Intimex`. Qua một thời gian người ta nhận ra rằng:
- Nếu một khách hàng vào `BigC` thì có $80\%$ họ sẽ quay lại siêu thị này, $10\%$ sang `ViMart` và $10\%$ sang `Intimex`
- Mỗi khách hàng vào `VinMart` có $90\%$ sẽ quay trở lại siêu thị này, $7\%$ chuyển sang `BigC` và $3\%$ chuyển sang `Intimex`
- Mỗi một khách hàng vào `Intimex` sẽ có $85\%$ ở lại, chuyển sang `BigC` là $8.3\%$ và chuyển sang `VinMart` là $6.7\%$
Tính số lượng khách hàng ổn định của mỗi siêu thị
---
Ta có vector phân phối trạng thái
\begin{equation}
\pi_0 = \left[\frac{4}{15}, \frac{2}{5}, \frac{1}{3}\right]
\end{equation}
Ma trận chuyển trạng thái:
\begin{bmatrix}
0.8 & 0.1 & 0.1 \\
0.07 & 0.9 & 0.03 \\
0.083 & 0.067 & 0.85
\end{bmatrix}
Ta có $\pi(P - I) = 0 \leftrightarrow \pi = \pi P \rightarrow \pi = [0.273, 0.454, 0.273]$
---
Dưới đây là đồ thị mô tả thị phần của mỗi siêu thị
```python
import processviz as pvz
```
```python
g = pvz.MarkovChain()
g.from_file('./ass1/input.csv')
```
```python
g.generate_state_graph(10)
g.state_vector
```
```python
g.generate_graph(2)
g.data
```
```python
```
|
export restart, step_forward, get_state
function restart(roadway::Roadway, render::Bool)
# Create scene
scene = Scene()
push!(scene,Vehicle(VehicleState(VecSE2(5.0 + rand()*10.0,randn()*0.5,0.0), roadway, 20.0),
VehicleDef(1, AgentClass.CAR, 4.826, 1.81)))
push!(scene,Vehicle(VehicleState(VecSE2(0.,randn()*0.5,0.0), roadway, 10.0 + rand()*20.0),
VehicleDef(2, AgentClass.CAR, 4.826, 1.81)))
# Specify models
context = IntegratedContinuous(1/10,3) #1/framrate
models = Dict{Int, DriverModel}()
if render
model1 = LatLonSeparableDriver(context,
ProportionalLaneTracker(σ=0.0, kp=5.0, kd=0.5),
IntelligentDriverModel(σ=0.0, v_des=21.0))
model2 = LatLonSeparableDriver(context,
ProportionalLaneTracker(σ=0.0, kp=5.0, kd=0.5),
StaticLongitudinalDriver())
else
model1 = LatLonSeparableDriver(context,
ProportionalLaneTracker(σ=0.01, kp=5.0, kd=0.5),
IntelligentDriverModel(σ=0.2, v_des=21.0))
model2 = LatLonSeparableDriver(context,
ProportionalLaneTracker(σ=0.01, kp=5.0, kd=0.5),
StaticLongitudinalDriver())
end
# Placeholder for actions
return scene, model1, model2
end
function step_forward(scene::Scene, roadway::Roadway, model1::DriverModel, model2::DriverModel, action::Float64)
observe!(model1, scene, roadway, 1)
context = action_context(model1)
scene[1].state = propagate(scene[1], rand(model1), context, roadway)
model2.mlon.a = action
observe!(model2, scene, roadway, 2)
context = action_context(model2)
scene[2].state = propagate(scene[2], rand(model2), context, roadway)
return get_state(scene)
end
function get_state(scene::Scene)
# Extract state values
d = scene[1].state.posF.s - scene[2].state.posF.s - scene[1].def.length/2. - scene[2].def.length/2.
r = scene[2].state.v - scene[1].state.v
s = scene[1].state.v
return d, r, s
end
|
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
-- |
-- Module : Statistics.Distribution.Uniform
-- Copyright : (c) 2011 Aleksey Khudyakov
-- License : BSD3
--
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
-- Variate distributed uniformly in the interval.
module Statistics.Distribution.Uniform
(
UniformDistribution
-- * Constructors
, uniformDistr
, uniformDistrE
-- ** Accessors
, uniformA
, uniformB
) where
import Control.Applicative
import Data.Data (Data, Typeable)
import GHC.Generics (Generic)
import qualified System.Random.MWC as MWC
import qualified Statistics.Distribution as D
import Statistics.Internal
-- | Uniform distribution from A to B
data UniformDistribution = UniformDistribution {
uniformA :: {-# UNPACK #-} !Double -- ^ Low boundary of distribution
, uniformB :: {-# UNPACK #-} !Double -- ^ Upper boundary of distribution
} deriving (Eq, Typeable, Data, Generic)
instance Show UniformDistribution where
showsPrec i (UniformDistribution a b) = defaultShow2 "uniformDistr" a b i
instance Read UniformDistribution where
readPrec = defaultReadPrecM2 "uniformDistr" uniformDistrE
-- | Create uniform distribution.
uniformDistr :: Double -> Double -> UniformDistribution
uniformDistr a b = maybe (error errMsg) id $ uniformDistrE a b
-- | Create uniform distribution.
uniformDistrE :: Double -> Double -> Maybe UniformDistribution
uniformDistrE a b
| b < a = Just $ UniformDistribution b a
| a < b = Just $ UniformDistribution a b
| otherwise = Nothing
-- NOTE: failure is in default branch to guard against NaNs.
errMsg :: String
errMsg = "Statistics.Distribution.Uniform.uniform: wrong parameters"
instance D.Distribution UniformDistribution where
cumulative (UniformDistribution a b) x
| x < a = 0
| x > b = 1
| otherwise = (x - a) / (b - a)
instance D.ContDistr UniformDistribution where
density (UniformDistribution a b) x
| x < a = 0
| x > b = 0
| otherwise = 1 / (b - a)
quantile (UniformDistribution a b) p
| p >= 0 && p <= 1 = a + (b - a) * p
| otherwise =
error $ "Statistics.Distribution.Uniform.quantile: p must be in [0,1] range. Got: "++show p
complQuantile (UniformDistribution a b) p
| p >= 0 && p <= 1 = b + (a - b) * p
| otherwise =
error $ "Statistics.Distribution.Uniform.complQuantile: p must be in [0,1] range. Got: "++show p
instance D.Mean UniformDistribution where
mean (UniformDistribution a b) = 0.5 * (a + b)
instance D.Variance UniformDistribution where
-- NOTE: 1/sqrt 12 is not constant folded (#4101) so it's written as
-- numerical constant. (Also FIXME!)
stdDev (UniformDistribution a b) = 0.2886751345948129 * (b - a)
variance (UniformDistribution a b) = d * d / 12 where d = b - a
instance D.MaybeMean UniformDistribution where
maybeMean = Just . D.mean
instance D.MaybeVariance UniformDistribution where
maybeStdDev = Just . D.stdDev
instance D.Entropy UniformDistribution where
entropy (UniformDistribution a b) = log (b - a)
instance D.MaybeEntropy UniformDistribution where
maybeEntropy = Just . D.entropy
instance D.ContGen UniformDistribution where
genContVar (UniformDistribution a b) gen = MWC.uniformR (a,b) gen
|
using Base.Test
using TestSetExtensions
@testset ExtendedTestSet "Rifraf" begin
@includetests ARGS
end
|
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
⊢ UnifIntegrable (f + g) p μ
[PROOFSTEP]
intro ε hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((f + g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hε2 : 0 < ε / 2 := half_pos hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
⊢ ∃ δ x,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((f + g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ₁, hδ₁_pos, hfδ₁⟩ := hf hε2
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
⊢ ∃ δ x,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((f + g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ₂, hδ₂_pos, hgδ₂⟩ := hg hε2
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
⊢ ∃ δ x,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((f + g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨min δ₁ δ₂, lt_min hδ₁_pos hδ₂_pos, fun i s hs hμs => _⟩
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
⊢ snorm (indicator s ((f + g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp_rw [Pi.add_apply, Set.indicator_add']
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
⊢ snorm (indicator s (f i) + indicator s (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' (snorm_add_le ((hf_meas i).indicator hs) ((hg_meas i).indicator hs) hp).trans _
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
⊢ snorm (indicator s (f i)) p μ + snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hε_halves : ENNReal.ofReal ε = ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2) := by
rw [← ENNReal.ofReal_add hε2.le hε2.le, add_halves]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
⊢ ENNReal.ofReal ε = ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2)
[PROOFSTEP]
rw [← ENNReal.ofReal_add hε2.le hε2.le, add_halves]
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hε_halves : ENNReal.ofReal ε = ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2)
⊢ snorm (indicator s (f i)) p μ + snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [hε_halves]
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
ε : ℝ
hε : 0 < ε
hε2 : 0 < ε / 2
δ₁ : ℝ
hδ₁_pos : 0 < δ₁
hfδ₁ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
δ₂ : ℝ
hδ₂_pos : 0 < δ₂
hgδ₂ :
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hε_halves : ENNReal.ofReal ε = ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2)
⊢ snorm (indicator s (f i)) p μ + snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2)
[PROOFSTEP]
exact
add_le_add (hfδ₁ i s hs (hμs.trans (ENNReal.ofReal_le_ofReal (min_le_left _ _))))
(hgδ₂ i s hs (hμs.trans (ENNReal.ofReal_le_ofReal (min_le_right _ _))))
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
⊢ UnifIntegrable (-f) p μ
[PROOFSTEP]
simp_rw [UnifIntegrable, Pi.neg_apply, Set.indicator_neg', snorm_neg]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
⊢ ∀ ⦃ε : ℝ⦄,
0 < ε →
∃ δ h,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact hf
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
⊢ UnifIntegrable (f - g) p μ
[PROOFSTEP]
rw [sub_eq_add_neg]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hg : UnifIntegrable g p μ
hp : 1 ≤ p
hf_meas : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hg_meas : ∀ (i : ι), AEStronglyMeasurable (g i) μ
⊢ UnifIntegrable (f + -g) p μ
[PROOFSTEP]
exact hf.add hg.neg hp hf_meas fun i => (hg_meas i).neg
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
⊢ UnifIntegrable g p μ
[PROOFSTEP]
intro ε hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδ_pos, hfδ⟩ := hf hε
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ_pos : 0 < δ
hfδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδ_pos, fun n s hs hμs => (le_of_eq <| snorm_congr_ae _).trans (hfδ n s hs hμs)⟩
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ_pos : 0 < δ
hfδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ indicator s (g n) =ᵐ[μ] indicator s (f n)
[PROOFSTEP]
filter_upwards [hfg n] with x hx
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f g : ι → α → β
p : ℝ≥0∞
hf : UnifIntegrable f p μ
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ_pos : 0 < δ
hfδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : f n x = g n x
⊢ indicator s (g n) x = indicator s (f n) x
[PROOFSTEP]
simp_rw [Set.indicator_apply, hx]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
inst✝ : MeasurableSpace α
p : ℝ≥0∞
f : ι → α → β
ε : ℝ
x✝² : 0 < ε
i : ι
s : Set α
x✝¹ : MeasurableSet s
x✝ : ↑↑0 s ≤ ENNReal.ofReal 1
⊢ snorm (indicator s (f i)) p 0 ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
x : α
⊢ Tendsto (fun M => indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
[PROOFSTEP]
refine' tendsto_atTop_of_eventually_const (i₀ := Nat.ceil (‖f x‖₊ : ℝ) + 1) fun n hn => _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
x : α
n : ℕ
hn : n ≥ ⌈↑‖f x‖₊⌉₊ + 1
⊢ indicator {x | ↑n ≤ ↑‖f x‖₊} f x = 0
[PROOFSTEP]
rw [Set.indicator_of_not_mem]
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
x : α
n : ℕ
hn : n ≥ ⌈↑‖f x‖₊⌉₊ + 1
⊢ ¬x ∈ {x | ↑n ≤ ↑‖f x‖₊}
[PROOFSTEP]
simp only [not_le, Set.mem_setOf_eq]
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
x : α
n : ℕ
hn : n ≥ ⌈↑‖f x‖₊⌉₊ + 1
⊢ ↑‖f x‖₊ < ↑n
[PROOFSTEP]
refine' lt_of_le_of_lt (Nat.le_ceil _) _
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
x : α
n : ℕ
hn : n ≥ ⌈↑‖f x‖₊⌉₊ + 1
⊢ ↑⌈↑‖f x‖₊⌉₊ < ↑n
[PROOFSTEP]
refine' lt_of_lt_of_le (lt_add_one _) _
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
x : α
n : ℕ
hn : n ≥ ⌈↑‖f x‖₊⌉₊ + 1
⊢ ↑⌈↑‖f x‖₊⌉₊ + 1 ≤ ↑n
[PROOFSTEP]
norm_cast
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have htendsto : ∀ᵐ x ∂μ, Tendsto (fun M : ℕ => {x | (M : ℝ) ≤ ‖f x‖₊}.indicator f x) atTop (𝓝 0) :=
univ_mem' (id fun x => tendsto_indicator_ge f x)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hmeas : ∀ M : ℕ, AEStronglyMeasurable ({x | (M : ℝ) ≤ ‖f x‖₊}.indicator f) μ :=
by
intro M
apply hf.1.indicator
apply
StronglyMeasurable.measurableSet_le stronglyMeasurable_const
hmeas.nnnorm.measurable.coe_nnreal_real.stronglyMeasurable
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
⊢ ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
[PROOFSTEP]
intro M
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
M : ℕ
⊢ AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
[PROOFSTEP]
apply hf.1.indicator
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
M : ℕ
⊢ MeasurableSet {x | ↑M ≤ ↑‖f x‖₊}
[PROOFSTEP]
apply
StronglyMeasurable.measurableSet_le stronglyMeasurable_const
hmeas.nnnorm.measurable.coe_nnreal_real.stronglyMeasurable
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hbound : HasFiniteIntegral (fun x => ‖f x‖) μ :=
by
rw [memℒp_one_iff_integrable] at hf
exact hf.norm.2
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
⊢ HasFiniteIntegral fun x => ‖f x‖
[PROOFSTEP]
rw [memℒp_one_iff_integrable] at hf
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Integrable f
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
⊢ HasFiniteIntegral fun x => ‖f x‖
[PROOFSTEP]
exact hf.norm.2
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have : Tendsto (fun n : ℕ ↦ ∫⁻ a, ENNReal.ofReal ‖{x | n ≤ ‖f x‖₊}.indicator f a - 0‖ ∂μ) atTop (𝓝 0) :=
by
refine' tendsto_lintegral_norm_of_dominated_convergence hmeas hbound _ htendsto
refine' fun n => univ_mem' (id fun x => _)
by_cases hx : (n : ℝ) ≤ ‖f x‖
· dsimp
rwa [Set.indicator_of_mem]
· dsimp
rw [Set.indicator_of_not_mem, norm_zero]
· exact norm_nonneg _
· assumption
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
⊢ Tendsto (fun n => ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ) atTop (𝓝 0)
[PROOFSTEP]
refine' tendsto_lintegral_norm_of_dominated_convergence hmeas hbound _ htendsto
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
⊢ ∀ (n : ℕ), ∀ᵐ (a : α) ∂μ, ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ≤ ‖f a‖
[PROOFSTEP]
refine' fun n => univ_mem' (id fun x => _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
⊢ x ∈ {x | (fun a => ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ≤ ‖f a‖) x}
[PROOFSTEP]
by_cases hx : (n : ℝ) ≤ ‖f x‖
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
hx : ↑n ≤ ‖f x‖
⊢ x ∈ {x | (fun a => ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ≤ ‖f a‖) x}
[PROOFSTEP]
dsimp
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
hx : ↑n ≤ ‖f x‖
⊢ ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f x‖ ≤ ‖f x‖
[PROOFSTEP]
rwa [Set.indicator_of_mem]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
hx : ¬↑n ≤ ‖f x‖
⊢ x ∈ {x | (fun a => ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ≤ ‖f a‖) x}
[PROOFSTEP]
dsimp
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
hx : ¬↑n ≤ ‖f x‖
⊢ ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f x‖ ≤ ‖f x‖
[PROOFSTEP]
rw [Set.indicator_of_not_mem, norm_zero]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
hx : ¬↑n ≤ ‖f x‖
⊢ 0 ≤ ‖f x‖
[PROOFSTEP]
exact norm_nonneg _
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
n : ℕ
x : α
hx : ¬↑n ≤ ‖f x‖
⊢ ¬x ∈ {x | ↑n ≤ ‖f x‖₊}
[PROOFSTEP]
assumption
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this : Tendsto (fun n => ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ) atTop (𝓝 0)
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [ENNReal.tendsto_atTop_zero] at this
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this :
∀ (ε : ℝ≥0∞),
ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ε
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨M, hM⟩ := this (ENNReal.ofReal ε) (ENNReal.ofReal_pos.2 hε)
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this :
∀ (ε : ℝ≥0∞),
ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ε
M : ℕ
hM : ∀ (n : ℕ), n ≥ M → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ENNReal.ofReal ε
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp only [true_and_iff, ge_iff_le, zero_tsub, zero_le, sub_zero, zero_add, coe_nnnorm, Set.mem_Icc] at hM
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this :
∀ (ε : ℝ≥0∞),
ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ε
M : ℕ
hM : ∀ (n : ℕ), M ≤ n → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ∂μ ≤ ENNReal.ofReal ε
⊢ ∃ M, ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨M, _⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this :
∀ (ε : ℝ≥0∞),
ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ε
M : ℕ
hM : ∀ (n : ℕ), M ≤ n → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ∂μ ≤ ENNReal.ofReal ε
⊢ ∫⁻ (x : α), ↑‖Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
convert hM M le_rfl
[GOAL]
case h.e'_3.h.e'_4.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this :
∀ (ε : ℝ≥0∞),
ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ε
M : ℕ
hM : ∀ (n : ℕ), M ≤ n → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ∂μ ≤ ENNReal.ofReal ε
x✝ : α
⊢ ↑‖Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x✝‖₊ = ENNReal.ofReal ‖Set.indicator {x | ↑M ≤ ‖f x‖₊} f x✝‖
[PROOFSTEP]
simp only [coe_nnnorm, ENNReal.ofReal_eq_coe_nnreal (norm_nonneg _)]
[GOAL]
case h.e'_3.h.e'_4.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas✝ : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
htendsto : ∀ᵐ (x : α) ∂μ, Tendsto (fun M => Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f x) atTop (𝓝 0)
hmeas : ∀ (M : ℕ), AEStronglyMeasurable (Set.indicator {x | ↑M ≤ ↑‖f x‖₊} f) μ
hbound : HasFiniteIntegral fun x => ‖f x‖
this :
∀ (ε : ℝ≥0∞),
ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a - 0‖ ∂μ ≤ ε
M : ℕ
hM : ∀ (n : ℕ), M ≤ n → ∫⁻ (a : α), ENNReal.ofReal ‖Set.indicator {x | ↑n ≤ ‖f x‖₊} f a‖ ∂μ ≤ ENNReal.ofReal ε
x✝ : α
⊢ ↑‖Set.indicator {x | ↑M ≤ ‖f x‖} f x✝‖₊ =
↑{ val := ‖Set.indicator {x | ↑M ≤ ‖f x‖₊} f x✝‖, property := (_ : 0 ≤ ‖Set.indicator {x | ↑M ≤ ‖f x‖₊} f x✝‖) }
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hM : ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
⊢ ∫⁻ (x : α), ↑‖Set.indicator {x | max M 0 ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simpa
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
ε : ℝ
hε : 0 < ε
⊢ ∃ M, 0 ≤ M ∧ ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hf_mk : Memℒp (hf.1.mk f) 1 μ := (memℒp_congr_ae hf.1.ae_eq_mk).mp hf
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
ε : ℝ
hε : 0 < ε
hf_mk : Memℒp (AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) 1
⊢ ∃ M, 0 ≤ M ∧ ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨M, hM_pos, hfM⟩ := hf_mk.integral_indicator_norm_ge_nonneg_le_of_meas μ hf.1.stronglyMeasurable_mk hε
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
ε : ℝ
hε : 0 < ε
hf_mk : Memℒp (AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) 1
M : ℝ
hM_pos : 0 ≤ M
hfM :
∫⁻ (x : α),
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊ ∂μ ≤
ENNReal.ofReal ε
⊢ ∃ M, 0 ≤ M ∧ ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨M, hM_pos, (le_of_eq _).trans hfM⟩
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
ε : ℝ
hε : 0 < ε
hf_mk : Memℒp (AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) 1
M : ℝ
hM_pos : 0 ≤ M
hfM :
∫⁻ (x : α),
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊ ∂μ ≤
ENNReal.ofReal ε
⊢ ∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ ∂μ =
∫⁻ (x : α),
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊ ∂μ
[PROOFSTEP]
refine' lintegral_congr_ae _
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
ε : ℝ
hε : 0 < ε
hf_mk : Memℒp (AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) 1
M : ℝ
hM_pos : 0 ≤ M
hfM :
∫⁻ (x : α),
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊ ∂μ ≤
ENNReal.ofReal ε
⊢ (fun x => ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊) =ᵐ[μ] fun x =>
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊
[PROOFSTEP]
filter_upwards [hf.1.ae_eq_mk] with x hx
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f 1
ε : ℝ
hε : 0 < ε
hf_mk : Memℒp (AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) 1
M : ℝ
hM_pos : 0 ≤ M
hfM :
∫⁻ (x : α),
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊ ∂μ ≤
ENNReal.ofReal ε
x : α
hx : f x = AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x
⊢ ↑‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖₊ =
↑‖Set.indicator {x | M ≤ ↑‖AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ) x‖₊}
(AEStronglyMeasurable.mk f (_ : AEStronglyMeasurable f μ)) x‖₊
[PROOFSTEP]
simp only [Set.indicator_apply, coe_nnnorm, Set.mem_setOf_eq, ENNReal.coe_eq_coe, hx.symm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
⊢ ∃ M, snormEssSup (Set.indicator {x | M ≤ ↑‖f x‖₊} f) μ = 0
[PROOFSTEP]
have hbdd : snormEssSup f μ < ∞ := hf.snorm_lt_top
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ ∃ M, snormEssSup (Set.indicator {x | M ≤ ↑‖f x‖₊} f) μ = 0
[PROOFSTEP]
refine' ⟨(snorm f ∞ μ + 1).toReal, _⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ snormEssSup (Set.indicator {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊} f) μ = 0
[PROOFSTEP]
rw [snormEssSup_indicator_eq_snormEssSup_restrict]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ snormEssSup f (Measure.restrict μ {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊}) = 0
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ MeasurableSet {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊}
[PROOFSTEP]
have : μ.restrict {x : α | (snorm f ⊤ μ + 1).toReal ≤ ‖f x‖₊} = 0 :=
by
simp only [coe_nnnorm, snorm_exponent_top, Measure.restrict_eq_zero]
have : {x : α | (snormEssSup f μ + 1).toReal ≤ ‖f x‖} ⊆ {x : α | snormEssSup f μ < ‖f x‖₊} :=
by
intro x hx
rw [Set.mem_setOf_eq, ← ENNReal.toReal_lt_toReal hbdd.ne ENNReal.coe_lt_top.ne, ENNReal.coe_toReal, coe_nnnorm]
refine' lt_of_lt_of_le _ hx
rw [ENNReal.toReal_lt_toReal hbdd.ne]
· exact ENNReal.lt_add_right hbdd.ne one_ne_zero
· exact (ENNReal.add_lt_top.2 ⟨hbdd, ENNReal.one_lt_top⟩).ne
rw [← nonpos_iff_eq_zero]
refine' (measure_mono this).trans _
have hle := coe_nnnorm_ae_le_snormEssSup f μ
simp_rw [ae_iff, not_le] at hle
exact nonpos_iff_eq_zero.2 hle
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ Measure.restrict μ {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊} = 0
[PROOFSTEP]
simp only [coe_nnnorm, snorm_exponent_top, Measure.restrict_eq_zero]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ ↑↑μ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} = 0
[PROOFSTEP]
have : {x : α | (snormEssSup f μ + 1).toReal ≤ ‖f x‖} ⊆ {x : α | snormEssSup f μ < ‖f x‖₊} :=
by
intro x hx
rw [Set.mem_setOf_eq, ← ENNReal.toReal_lt_toReal hbdd.ne ENNReal.coe_lt_top.ne, ENNReal.coe_toReal, coe_nnnorm]
refine' lt_of_lt_of_le _ hx
rw [ENNReal.toReal_lt_toReal hbdd.ne]
· exact ENNReal.lt_add_right hbdd.ne one_ne_zero
· exact (ENNReal.add_lt_top.2 ⟨hbdd, ENNReal.one_lt_top⟩).ne
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ⊆ {x | snormEssSup f μ < ↑‖f x‖₊}
[PROOFSTEP]
intro x hx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
x : α
hx : x ∈ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖}
⊢ x ∈ {x | snormEssSup f μ < ↑‖f x‖₊}
[PROOFSTEP]
rw [Set.mem_setOf_eq, ← ENNReal.toReal_lt_toReal hbdd.ne ENNReal.coe_lt_top.ne, ENNReal.coe_toReal, coe_nnnorm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
x : α
hx : x ∈ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖}
⊢ ENNReal.toReal (snormEssSup f μ) < ‖f x‖
[PROOFSTEP]
refine' lt_of_lt_of_le _ hx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
x : α
hx : x ∈ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖}
⊢ ENNReal.toReal (snormEssSup f μ) < ENNReal.toReal (snormEssSup f μ + 1)
[PROOFSTEP]
rw [ENNReal.toReal_lt_toReal hbdd.ne]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
x : α
hx : x ∈ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖}
⊢ snormEssSup f μ < snormEssSup f μ + 1
[PROOFSTEP]
exact ENNReal.lt_add_right hbdd.ne one_ne_zero
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
x : α
hx : x ∈ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖}
⊢ snormEssSup f μ + 1 ≠ ⊤
[PROOFSTEP]
exact (ENNReal.add_lt_top.2 ⟨hbdd, ENNReal.one_lt_top⟩).ne
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
this : {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ⊆ {x | snormEssSup f μ < ↑‖f x‖₊}
⊢ ↑↑μ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} = 0
[PROOFSTEP]
rw [← nonpos_iff_eq_zero]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
this : {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ⊆ {x | snormEssSup f μ < ↑‖f x‖₊}
⊢ ↑↑μ {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ≤ 0
[PROOFSTEP]
refine' (measure_mono this).trans _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
this : {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ⊆ {x | snormEssSup f μ < ↑‖f x‖₊}
⊢ ↑↑μ {x | snormEssSup f μ < ↑‖f x‖₊} ≤ 0
[PROOFSTEP]
have hle := coe_nnnorm_ae_le_snormEssSup f μ
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
this : {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ⊆ {x | snormEssSup f μ < ↑‖f x‖₊}
hle : ∀ᵐ (x : α) ∂μ, ↑‖f x‖₊ ≤ snormEssSup f μ
⊢ ↑↑μ {x | snormEssSup f μ < ↑‖f x‖₊} ≤ 0
[PROOFSTEP]
simp_rw [ae_iff, not_le] at hle
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
this : {x | ENNReal.toReal (snormEssSup f μ + 1) ≤ ‖f x‖} ⊆ {x | snormEssSup f μ < ↑‖f x‖₊}
hle : ↑↑μ {a | snormEssSup f μ < ↑‖f a‖₊} = 0
⊢ ↑↑μ {x | snormEssSup f μ < ↑‖f x‖₊} ≤ 0
[PROOFSTEP]
exact nonpos_iff_eq_zero.2 hle
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
this : Measure.restrict μ {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊} = 0
⊢ snormEssSup f (Measure.restrict μ {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊}) = 0
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ MeasurableSet {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊}
[PROOFSTEP]
rw [this, snormEssSup_measure_zero]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f ⊤
hmeas : StronglyMeasurable f
hbdd : snormEssSup f μ < ⊤
⊢ MeasurableSet {x | ENNReal.toReal (snorm f ⊤ μ + 1) ≤ ↑‖f x‖₊}
[PROOFSTEP]
exact measurableSet_le measurable_const hmeas.nnnorm.measurable.subtype_coe
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hp_ne_zero : p = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : p = 0
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨1, hp_ne_zero.symm ▸ _⟩
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : p = 0
⊢ snorm (Set.indicator {x | 1 ≤ ↑‖f x‖₊} f) 0 μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp [snorm_exponent_zero]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hp_ne_top : p = ∞
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : p = ⊤
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
subst hp_ne_top
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hf : Memℒp f ⊤
hp_ne_zero : ¬⊤ = 0
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) ⊤ μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨M, hM⟩ := hf.snormEssSup_indicator_norm_ge_eq_zero μ hmeas
[GOAL]
case pos.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hf : Memℒp f ⊤
hp_ne_zero : ¬⊤ = 0
M : ℝ
hM : snormEssSup (Set.indicator {x | M ≤ ↑‖f x‖₊} f) μ = 0
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) ⊤ μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨M, _⟩
[GOAL]
case pos.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
f : α → β
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hf : Memℒp f ⊤
hp_ne_zero : ¬⊤ = 0
M : ℝ
hM : snormEssSup (Set.indicator {x | M ≤ ↑‖f x‖₊} f) μ = 0
⊢ snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) ⊤ μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp only [snorm_exponent_top, hM, zero_le]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨M, hM', hM⟩ :=
Memℒp.integral_indicator_norm_ge_nonneg_le (μ := μ) (hf.norm_rpow hp_ne_zero hp_ne_top)
(Real.rpow_pos_of_pos hε p.toReal)
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
⊢ ∃ M, snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨M ^ (1 / p.toReal), _⟩
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
⊢ snorm (Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [snorm_eq_lintegral_rpow_nnnorm hp_ne_zero hp_ne_top, ← ENNReal.rpow_one (ENNReal.ofReal ε)]
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
⊢ (∫⁻ (x : α), ↑‖Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} f x‖₊ ^ ENNReal.toReal p ∂μ) ^
(1 / ENNReal.toReal p) ≤
ENNReal.ofReal ε ^ 1
[PROOFSTEP]
conv_rhs => rw [← mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
| ENNReal.ofReal ε ^ 1
[PROOFSTEP]
rw [← mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
| ENNReal.ofReal ε ^ 1
[PROOFSTEP]
rw [← mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
| ENNReal.ofReal ε ^ 1
[PROOFSTEP]
rw [← mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm]
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
⊢ (∫⁻ (x : α), ↑‖Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} f x‖₊ ^ ENNReal.toReal p ∂μ) ^
(1 / ENNReal.toReal p) ≤
ENNReal.ofReal ε ^ (ENNReal.toReal p * (1 / ENNReal.toReal p))
[PROOFSTEP]
rw [ENNReal.rpow_mul, ENNReal.rpow_le_rpow_iff (one_div_pos.2 <| ENNReal.toReal_pos hp_ne_zero hp_ne_top),
ENNReal.ofReal_rpow_of_pos hε]
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
⊢ ∫⁻ (x : α), ↑‖Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} f x‖₊ ^ ENNReal.toReal p ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
[PROOFSTEP]
convert hM
[GOAL]
case h.e'_3.h.e'_4.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x✝ : α
⊢ ↑‖Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} f x✝‖₊ ^ ENNReal.toReal p =
↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x✝‖₊
[PROOFSTEP]
rename_i x
[GOAL]
case h.e'_3.h.e'_4.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
⊢ ↑‖Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} f x‖₊ ^ ENNReal.toReal p =
↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊
[PROOFSTEP]
rw [ENNReal.coe_rpow_of_nonneg _ ENNReal.toReal_nonneg, nnnorm_indicator_eq_indicator_nnnorm,
nnnorm_indicator_eq_indicator_nnnorm]
[GOAL]
case h.e'_3.h.e'_4.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
⊢ ↑(Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} (fun a => ‖f a‖₊) x ^ ENNReal.toReal p) =
↑(Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun a => ‖‖f a‖ ^ ENNReal.toReal p‖₊) x)
[PROOFSTEP]
have hiff : M ^ (1 / p.toReal) ≤ ‖f x‖₊ ↔ M ≤ ‖‖f x‖ ^ p.toReal‖₊ := by
rw [coe_nnnorm, coe_nnnorm, Real.norm_rpow_of_nonneg (norm_nonneg _), norm_norm, ←
Real.rpow_le_rpow_iff hM' (Real.rpow_nonneg_of_nonneg (norm_nonneg _) _)
(one_div_pos.2 <| ENNReal.toReal_pos hp_ne_zero hp_ne_top),
← Real.rpow_mul (norm_nonneg _), mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm,
Real.rpow_one]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
⊢ M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
[PROOFSTEP]
rw [coe_nnnorm, coe_nnnorm, Real.norm_rpow_of_nonneg (norm_nonneg _), norm_norm, ←
Real.rpow_le_rpow_iff hM' (Real.rpow_nonneg_of_nonneg (norm_nonneg _) _)
(one_div_pos.2 <| ENNReal.toReal_pos hp_ne_zero hp_ne_top),
← Real.rpow_mul (norm_nonneg _), mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm, Real.rpow_one]
[GOAL]
case h.e'_3.h.e'_4.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
⊢ ↑(Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} (fun a => ‖f a‖₊) x ^ ENNReal.toReal p) =
↑(Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun a => ‖‖f a‖ ^ ENNReal.toReal p‖₊) x)
[PROOFSTEP]
by_cases hx : x ∈ {x : α | M ^ (1 / p.toReal) ≤ ‖f x‖₊}
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ ↑(Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} (fun a => ‖f a‖₊) x ^ ENNReal.toReal p) =
↑(Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun a => ‖‖f a‖ ^ ENNReal.toReal p‖₊) x)
[PROOFSTEP]
rw [Set.indicator_of_mem hx, Set.indicator_of_mem, Real.nnnorm_of_nonneg]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ ↑(‖f x‖₊ ^ ENNReal.toReal p) = ↑{ val := ‖f x‖ ^ ENNReal.toReal p, property := ?pos✝ }
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ 0 ≤ ‖f x‖ ^ ENNReal.toReal p
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ x ∈ {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊}
[PROOFSTEP]
rfl
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ x ∈ {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊}
[PROOFSTEP]
rw [Set.mem_setOf_eq]
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
[PROOFSTEP]
rwa [← hiff]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : ¬x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ ↑(Set.indicator {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊} (fun a => ‖f a‖₊) x ^ ENNReal.toReal p) =
↑(Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun a => ‖‖f a‖ ^ ENNReal.toReal p‖₊) x)
[PROOFSTEP]
rw [Set.indicator_of_not_mem hx, Set.indicator_of_not_mem]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : ¬x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ ↑(0 ^ ENNReal.toReal p) = ↑0
[PROOFSTEP]
simp [(ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : ¬x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ ¬x ∈ {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊}
[PROOFSTEP]
rw [Set.mem_setOf_eq]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
hp_ne_zero : ¬p = 0
hp_ne_top : ¬p = ⊤
M : ℝ
hM' : 0 ≤ M
hM :
∫⁻ (x : α), ↑‖Set.indicator {x | M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊} (fun x => ‖f x‖ ^ ENNReal.toReal p) x‖₊ ∂μ ≤
ENNReal.ofReal (ε ^ ENNReal.toReal p)
x : α
hiff : M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊ ↔ M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
hx : ¬x ∈ {x | M ^ (1 / ENNReal.toReal p) ≤ ↑‖f x‖₊}
⊢ ¬M ≤ ↑‖‖f x‖ ^ ENNReal.toReal p‖₊
[PROOFSTEP]
rwa [← hiff]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
⊢ ∃ M, 0 < M ∧ snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨M, hM⟩ := hf.snorm_indicator_norm_ge_le μ hmeas hε
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ∃ M, 0 < M ∧ snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), le_trans (snorm_mono fun x => _) hM⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x : α
⊢ ‖Set.indicator {x | max M 1 ≤ ↑‖f x‖₊} f x‖ ≤ ‖Set.indicator {x | M ≤ ↑‖f x‖₊} f x‖
[PROOFSTEP]
rw [norm_indicator_eq_indicator_norm, norm_indicator_eq_indicator_norm]
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x : α
⊢ Set.indicator {x | max M 1 ≤ ↑‖f x‖₊} (fun a => ‖f a‖) x ≤ Set.indicator {x | M ≤ ↑‖f x‖₊} (fun a => ‖f a‖) x
[PROOFSTEP]
refine' Set.indicator_le_indicator_of_subset (fun x hx => _) (fun x => norm_nonneg (f x)) x
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x✝ x : α
hx : x ∈ {x | max M 1 ≤ ↑‖f x‖₊}
⊢ x ∈ {x | M ≤ ↑‖f x‖₊}
[PROOFSTEP]
rw [Set.mem_setOf_eq] at hx
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x✝ x : α
hx : max M 1 ≤ ↑‖f x‖₊
⊢ x ∈ {x | M ≤ ↑‖f x‖₊}
[PROOFSTEP]
exact (max_le_iff.1 hx).1
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hM : M ≤ 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : M ≤ 0
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨1, zero_lt_one, fun s _ _ => _⟩
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : M ≤ 0
s : Set α
x✝¹ : MeasurableSet s
x✝ : ↑↑μ s ≤ ENNReal.ofReal 1
⊢ snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [(_ : f = 0)]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : M ≤ 0
s : Set α
x✝¹ : MeasurableSet s
x✝ : ↑↑μ s ≤ ENNReal.ofReal 1
⊢ snorm (indicator s 0) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp [hε.le]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : M ≤ 0
s : Set α
x✝¹ : MeasurableSet s
x✝ : ↑↑μ s ≤ ENNReal.ofReal 1
⊢ f = 0
[PROOFSTEP]
ext x
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : M ≤ 0
s : Set α
x✝¹ : MeasurableSet s
x✝ : ↑↑μ s ≤ ENNReal.ofReal 1
x : α
⊢ f x = OfNat.ofNat 0 x
[PROOFSTEP]
rw [Pi.zero_apply, ← norm_le_zero_iff]
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : M ≤ 0
s : Set α
x✝¹ : MeasurableSet s
x✝ : ↑↑μ s ≤ ENNReal.ofReal 1
x : α
⊢ ‖f x‖ ≤ 0
[PROOFSTEP]
exact (lt_of_lt_of_le (hf x) hM).le
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : ¬M ≤ 0
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [not_le] at hM
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨(ε / M) ^ p.toReal, Real.rpow_pos_of_pos (div_pos hε hM) _, fun s hs hμ => _⟩
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
⊢ snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hp : p = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : p = 0
⊢ snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp [hp]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
⊢ snorm (indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [snorm_indicator_eq_snorm_restrict hs]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
⊢ snorm f p (Measure.restrict μ s) ≤ ENNReal.ofReal ε
[PROOFSTEP]
have haebdd : ∀ᵐ x ∂μ.restrict s, ‖f x‖ ≤ M := by
filter_upwards
exact fun x => (hf x).le
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
⊢ ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
[PROOFSTEP]
filter_upwards
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
⊢ ∀ (a : α), ‖f a‖ ≤ M
[PROOFSTEP]
exact fun x => (hf x).le
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
haebdd : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
⊢ snorm f p (Measure.restrict μ s) ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' le_trans (snorm_le_of_ae_bound haebdd) _
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
haebdd : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
⊢ ↑↑(Measure.restrict μ s) univ ^ (ENNReal.toReal p)⁻¹ * ENNReal.ofReal M ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [Measure.restrict_apply MeasurableSet.univ, Set.univ_inter, ←
ENNReal.le_div_iff_mul_le (Or.inl _) (Or.inl ENNReal.ofReal_ne_top)]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
haebdd : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
⊢ ↑↑μ s ^ (ENNReal.toReal p)⁻¹ ≤ ENNReal.ofReal ε / ENNReal.ofReal M
[PROOFSTEP]
rw [← one_div, ENNReal.rpow_one_div_le_iff (ENNReal.toReal_pos hp hp_top)]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
haebdd : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
⊢ ↑↑μ s ≤ (ENNReal.ofReal ε / ENNReal.ofReal M) ^ ENNReal.toReal p
[PROOFSTEP]
refine' le_trans hμ _
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
haebdd : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
⊢ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p) ≤ (ENNReal.ofReal ε / ENNReal.ofReal M) ^ ENNReal.toReal p
[PROOFSTEP]
rw [← ENNReal.ofReal_rpow_of_pos (div_pos hε hM), ENNReal.rpow_le_rpow_iff (ENNReal.toReal_pos hp hp_top),
ENNReal.ofReal_div_of_pos hM]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
M : ℝ
hf : ∀ (x : α), ‖f x‖ < M
hM : 0 < M
s : Set α
hs : MeasurableSet s
hμ : ↑↑μ s ≤ ENNReal.ofReal ((ε / M) ^ ENNReal.toReal p)
hp : ¬p = 0
haebdd : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖f x‖ ≤ M
⊢ ENNReal.ofReal M ≠ 0
[PROOFSTEP]
simpa only [ENNReal.ofReal_eq_zero, not_le, Ne.def]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
⊢ ∃ δ hδ,
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨M, hMpos, hM⟩ := hf.snorm_indicator_norm_ge_pos_le μ hmeas hε
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ hδ,
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδpos, hδ⟩ :=
snorm_indicator_le_of_bound μ (f := {x | ‖f x‖ < M}.indicator f) hp_top hε
(by
intro x
rw [norm_indicator_eq_indicator_norm, Set.indicator_apply]
split_ifs with h
exacts [h, hMpos])
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ∀ (x : α), ‖Set.indicator {x | ‖f x‖ < M} f x‖ < ?m.135727
[PROOFSTEP]
intro x
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x : α
⊢ ‖Set.indicator {x | ‖f x‖ < M} f x‖ < ?m.135727
[PROOFSTEP]
rw [norm_indicator_eq_indicator_norm, Set.indicator_apply]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x : α
⊢ (if x ∈ {x | ‖f x‖ < M} then ‖f x‖ else 0) < ?m.135727
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ℝ
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ℝ
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x : α
h : x ∈ {x | ‖f x‖ < M}
⊢ ‖f x‖ < ?m.135727
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
x : α
h : ¬x ∈ {x | ‖f x‖ < M}
⊢ 0 < ?m.135727
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ℝ
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
⊢ ℝ
[PROOFSTEP]
exacts [h, hMpos]
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ hδ,
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδpos, fun s hs hμs => _⟩
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal ε
[PROOFSTEP]
rw [(_ : f = {x : α | M ≤ ‖f x‖₊}.indicator f + {x : α | ‖f x‖ < M}.indicator f)]
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator s (Set.indicator {x | M ≤ ↑‖f x‖₊} f + Set.indicator {x | ‖f x‖ < M} f)) p μ ≤
2 * ENNReal.ofReal ε
[PROOFSTEP]
rw [snorm_indicator_eq_snorm_restrict hs]
[GOAL]
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f + Set.indicator {x | ‖f x‖ < M} f) p (Measure.restrict μ s) ≤
2 * ENNReal.ofReal ε
[PROOFSTEP]
refine' le_trans (snorm_add_le _ _ hp_one) _
[GOAL]
case intro.intro.intro.intro.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ AEStronglyMeasurable (Set.indicator {x | M ≤ ↑‖f x‖₊} f) (Measure.restrict μ s)
[PROOFSTEP]
exact
StronglyMeasurable.aestronglyMeasurable
(hmeas.indicator (measurableSet_le measurable_const hmeas.nnnorm.measurable.subtype_coe))
[GOAL]
case intro.intro.intro.intro.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ AEStronglyMeasurable (Set.indicator {x | ‖f x‖ < M} f) (Measure.restrict μ s)
[PROOFSTEP]
exact
StronglyMeasurable.aestronglyMeasurable
(hmeas.indicator (measurableSet_lt hmeas.nnnorm.measurable.subtype_coe measurable_const))
[GOAL]
case intro.intro.intro.intro.refine'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p (Measure.restrict μ s) +
snorm (Set.indicator {x | ‖f x‖ < M} f) p (Measure.restrict μ s) ≤
2 * ENNReal.ofReal ε
[PROOFSTEP]
rw [two_mul]
[GOAL]
case intro.intro.intro.intro.refine'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p (Measure.restrict μ s) +
snorm (Set.indicator {x | ‖f x‖ < M} f) p (Measure.restrict μ s) ≤
ENNReal.ofReal ε + ENNReal.ofReal ε
[PROOFSTEP]
refine' add_le_add (le_trans (snorm_mono_measure _ Measure.restrict_le_self) hM) _
[GOAL]
case intro.intro.intro.intro.refine'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator {x | ‖f x‖ < M} f) p (Measure.restrict μ s) ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [← snorm_indicator_eq_snorm_restrict hs]
[GOAL]
case intro.intro.intro.intro.refine'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact hδ s hs hμs
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ f = Set.indicator {x | M ≤ ↑‖f x‖₊} f + Set.indicator {x | ‖f x‖ < M} f
[PROOFSTEP]
ext x
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
⊢ f x = (Set.indicator {x | M ≤ ↑‖f x‖₊} f + Set.indicator {x | ‖f x‖ < M} f) x
[PROOFSTEP]
by_cases hx : M ≤ ‖f x‖
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : M ≤ ‖f x‖
⊢ f x = (Set.indicator {x | M ≤ ↑‖f x‖₊} f + Set.indicator {x | ‖f x‖ < M} f) x
[PROOFSTEP]
rw [Pi.add_apply, Set.indicator_of_mem, Set.indicator_of_not_mem, add_zero]
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : M ≤ ‖f x‖
⊢ ¬x ∈ {x | ‖f x‖ < M}
[PROOFSTEP]
simpa
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : M ≤ ‖f x‖
⊢ x ∈ {x | M ≤ ↑‖f x‖₊}
[PROOFSTEP]
simpa
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : ¬M ≤ ‖f x‖
⊢ f x = (Set.indicator {x | M ≤ ↑‖f x‖₊} f + Set.indicator {x | ‖f x‖ < M} f) x
[PROOFSTEP]
rw [Pi.add_apply, Set.indicator_of_not_mem, Set.indicator_of_mem, zero_add]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : ¬M ≤ ‖f x‖
⊢ x ∈ {x | ‖f x‖ < M}
[PROOFSTEP]
simpa using hx
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
M : ℝ
hMpos : 0 < M
hM : snorm (Set.indicator {x | M ≤ ↑‖f x‖₊} f) p μ ≤ ENNReal.ofReal ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s (Set.indicator {x | ‖f x‖ < M} f)) p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
x : α
hx : ¬M ≤ ‖f x‖
⊢ ¬x ∈ {x | M ≤ ↑‖f x‖₊}
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδpos, hδ⟩ := hf.snorm_indicator_le' μ hp_one hp_top hmeas (half_pos hε)
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal (ε / 2)
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδpos, fun s hs hμs => le_trans (hδ s hs hμs) _⟩
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal (ε / 2)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ 2 * ENNReal.ofReal (ε / 2) ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [ENNReal.ofReal_div_of_pos zero_lt_two, (by norm_num : ENNReal.ofReal 2 = 2), ENNReal.mul_div_cancel']
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal (ε / 2)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ ENNReal.ofReal 2 = 2
[PROOFSTEP]
norm_num
[GOAL]
case intro.intro.h0
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal (ε / 2)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ 2 ≠ 0
[PROOFSTEP]
norm_num
[GOAL]
case intro.intro.hI
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
hmeas : StronglyMeasurable f
ε : ℝ
hε : 0 < ε
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ 2 * ENNReal.ofReal (ε / 2)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ 2 ≠ ⊤
[PROOFSTEP]
norm_num
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
ε : ℝ
hε : 0 < ε
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hℒp := hf
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : Memℒp f p
ε : ℝ
hε : 0 < ε
hℒp : Memℒp f p
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨⟨f', hf', heq⟩, _⟩ := hf
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
hℒp : Memℒp f p
right✝ : snorm f p μ < ⊤
f' : α → β
hf' : StronglyMeasurable f'
heq : f =ᵐ[μ] f'
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδpos, hδ⟩ := (hℒp.ae_eq heq).snorm_indicator_le_of_meas μ hp_one hp_top hf' hε
[GOAL]
case intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
hℒp : Memℒp f p
right✝ : snorm f p μ < ⊤
f' : α → β
hf' : StronglyMeasurable f'
heq : f =ᵐ[μ] f'
δ : ℝ
hδpos : 0 < δ
hδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f') p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ hδ, ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδpos, fun s hs hμs => _⟩
[GOAL]
case intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
hℒp : Memℒp f p
right✝ : snorm f p μ < ⊤
f' : α → β
hf' : StronglyMeasurable f'
heq : f =ᵐ[μ] f'
δ : ℝ
hδpos : 0 < δ
hδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f') p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator s f) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
convert hδ s hs hμs using 1
[GOAL]
case h.e'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
hℒp : Memℒp f p
right✝ : snorm f p μ < ⊤
f' : α → β
hf' : StronglyMeasurable f'
heq : f =ᵐ[μ] f'
δ : ℝ
hδpos : 0 < δ
hδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f') p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (Set.indicator s f) p μ = snorm (Set.indicator s f') p μ
[PROOFSTEP]
rw [snorm_indicator_eq_snorm_restrict hs, snorm_indicator_eq_snorm_restrict hs]
[GOAL]
case h.e'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
ε : ℝ
hε : 0 < ε
hℒp : Memℒp f p
right✝ : snorm f p μ < ⊤
f' : α → β
hf' : StronglyMeasurable f'
heq : f =ᵐ[μ] f'
δ : ℝ
hδpos : 0 < δ
hδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (Set.indicator s f') p μ ≤ ENNReal.ofReal ε
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm f p (Measure.restrict μ s) = snorm f' p (Measure.restrict μ s)
[PROOFSTEP]
refine' snorm_congr_ae heq.restrict
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : α → β
hp : 1 ≤ p
hp_ne_top : p ≠ ⊤
hg : Memℒp g p
⊢ UnifIntegrable (fun x => g) p μ
[PROOFSTEP]
intro ε hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : α → β
hp : 1 ≤ p
hp_ne_top : p ≠ ⊤
hg : Memℒp g p
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((fun x => g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδ_pos, hgδ⟩ := hg.snorm_indicator_le μ hp hp_ne_top hε
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : α → β
hp : 1 ≤ p
hp_ne_top : p ≠ ⊤
hg : Memℒp g p
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ_pos : 0 < δ
hgδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s g) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((fun x => g) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact ⟨δ, hδ_pos, fun _ => hgδ⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
⊢ UnifIntegrable f p μ
[PROOFSTEP]
intro ε hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hι : Nonempty ι
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
hι : Nonempty ι
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
cases' hι with i
[GOAL]
case pos.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
i : ι
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδpos, hδ⟩ := (hf i).snorm_indicator_le μ hp_one hp_top hε
[GOAL]
case pos.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
i : ι
δ : ℝ
hδpos : 0 < δ
hδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδpos, fun j s hs hμs => _⟩
[GOAL]
case pos.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
i : ι
δ : ℝ
hδpos : 0 < δ
hδ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
j : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (indicator s (f j)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
convert hδ s hs hμs
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Subsingleton ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
hι : ¬Nonempty ι
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact ⟨1, zero_lt_one, fun i => False.elim <| hι <| Nonempty.intro i⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
f : Fin n → α → β
hf : ∀ (i : Fin n), Memℒp (f i) p
⊢ UnifIntegrable f p μ
[PROOFSTEP]
revert f
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
⊢ ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
[PROOFSTEP]
induction' n with n h
[GOAL]
case zero
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
⊢ ∀ {f : Fin Nat.zero → α → β}, (∀ (i : Fin Nat.zero), Memℒp (f i) p) → UnifIntegrable f p μ
[PROOFSTEP]
intro f hf
[GOAL]
case zero
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : Fin Nat.zero → α → β
hf : ∀ (i : Fin Nat.zero), Memℒp (f i) p
⊢ UnifIntegrable f p μ
[PROOFSTEP]
have : Subsingleton (Fin Nat.zero) := subsingleton_fin_zero
[GOAL]
case zero
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : Fin Nat.zero → α → β
hf : ∀ (i : Fin Nat.zero), Memℒp (f i) p
this : Subsingleton (Fin Nat.zero)
⊢ UnifIntegrable f p μ
[PROOFSTEP]
exact unifIntegrable_subsingleton μ hp_one hp_top hf
[GOAL]
case succ
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
⊢ ∀ {f : Fin (Nat.succ n) → α → β}, (∀ (i : Fin (Nat.succ n)), Memℒp (f i) p) → UnifIntegrable f p μ
[PROOFSTEP]
intro f hfLp ε hε
[GOAL]
case succ
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : Fin (Nat.succ n)) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
let g : Fin n → α → β := fun k => f k
[GOAL]
case succ
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
⊢ ∃ δ x,
∀ (i : Fin (Nat.succ n)) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hgLp : ∀ i, Memℒp (g i) p μ := fun i => hfLp i
[GOAL]
case succ
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
⊢ ∃ δ x,
∀ (i : Fin (Nat.succ n)) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ₁, hδ₁pos, hδ₁⟩ := h hgLp hε
[GOAL]
case succ.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : Fin (Nat.succ n)) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ₂, hδ₂pos, hδ₂⟩ := (hfLp n).snorm_indicator_le μ hp_one hp_top hε
[GOAL]
case succ.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : Fin (Nat.succ n)) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨min δ₁ δ₂, lt_min hδ₁pos hδ₂pos, fun i s hs hμs => _⟩
[GOAL]
case succ.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hi : i.val < n
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ↑i < n
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [(_ : f i = g ⟨i.val, hi⟩)]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ↑i < n
⊢ snorm (indicator s (g { val := ↑i, isLt := hi })) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact hδ₁ _ s hs (le_trans hμs <| ENNReal.ofReal_le_ofReal <| min_le_left _ _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ↑i < n
⊢ f i = g { val := ↑i, isLt := hi }
[PROOFSTEP]
simp
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ¬↑i < n
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [(_ : i = n)]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ¬↑i < n
⊢ snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact hδ₂ _ hs (le_trans hμs <| ENNReal.ofReal_le_ofReal <| min_le_right _ _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ¬↑i < n
⊢ i = ↑n
[PROOFSTEP]
have hi' := Fin.is_lt i
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ¬↑i < n
hi' : ↑i < Nat.succ n
⊢ i = ↑n
[PROOFSTEP]
rw [Nat.lt_succ_iff] at hi'
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : ¬↑i < n
hi' : ↑i ≤ n
⊢ i = ↑n
[PROOFSTEP]
rw [not_lt] at hi
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : n ≤ ↑i
hi' : ↑i ≤ n
⊢ i = ↑n
[PROOFSTEP]
ext
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : n ≤ ↑i
hi' : ↑i ≤ n
⊢ ↑i = ↑↑n
[PROOFSTEP]
symm
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
n : ℕ
h : ∀ {f : Fin n → α → β}, (∀ (i : Fin n), Memℒp (f i) p) → UnifIntegrable f p μ
f : Fin (Nat.succ n) → α → β
hfLp : ∀ (i : Fin (Nat.succ n)), Memℒp (f i) p
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := fun k => f ↑↑k
hgLp : ∀ (i : Fin n), Memℒp (g i) p
δ₁ : ℝ
hδ₁pos : 0 < δ₁
hδ₁ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
δ₂ : ℝ
hδ₂pos : 0 < δ₂
hδ₂ : ∀ (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s (f ↑n)) p μ ≤ ENNReal.ofReal ε
i : Fin (Nat.succ n)
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal (min δ₁ δ₂)
hi : n ≤ ↑i
hi' : ↑i ≤ n
⊢ ↑↑n = ↑i
[PROOFSTEP]
rw [Fin.coe_ofNat_eq_mod, le_antisymm hi' hi, Nat.mod_succ_eq_iff_lt, Nat.lt_succ]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
⊢ UnifIntegrable f p μ
[PROOFSTEP]
obtain ⟨n, hn⟩ := Finite.exists_equiv_fin ι
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
⊢ UnifIntegrable f p μ
[PROOFSTEP]
intro ε hε
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
set g : Fin n → α → β := f ∘ hn.some.symm with hgeq
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := f ∘ ↑(Nonempty.some hn).symm
hgeq : g = f ∘ ↑(Nonempty.some hn).symm
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hg : ∀ i, Memℒp (g i) p μ := fun _ => hf _
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := f ∘ ↑(Nonempty.some hn).symm
hgeq : g = f ∘ ↑(Nonempty.some hn).symm
hg : ∀ (i : Fin n), Memℒp (g i) p
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδpos, hδ⟩ := unifIntegrable_fin μ hp_one hp_top hg hε
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := f ∘ ↑(Nonempty.some hn).symm
hgeq : g = f ∘ ↑(Nonempty.some hn).symm
hg : ∀ (i : Fin n), Memℒp (g i) p
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδpos, fun i s hs hμs => _⟩
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := f ∘ ↑(Nonempty.some hn).symm
hgeq : g = f ∘ ↑(Nonempty.some hn).symm
hg : ∀ (i : Fin n), Memℒp (g i) p
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : Fin n) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s ((fun i => g i) i)) p μ ≤ ENNReal.ofReal ε
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
specialize hδ (hn.some i) s hs hμs
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := f ∘ ↑(Nonempty.some hn).symm
hgeq : g = f ∘ ↑(Nonempty.some hn).symm
hg : ∀ (i : Fin n), Memℒp (g i) p
δ : ℝ
hδpos : 0 < δ
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
hδ : snorm (indicator s ((fun i => g i) (↑(Nonempty.some hn) i))) p μ ≤ ENNReal.ofReal ε
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp_rw [hgeq, Function.comp_apply, Equiv.symm_apply_apply] at hδ
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), Memℒp (f i) p
n : ℕ
hn : Nonempty (ι ≃ Fin n)
ε : ℝ
hε : 0 < ε
g : Fin n → α → β := f ∘ ↑(Nonempty.some hn).symm
hgeq : g = f ∘ ↑(Nonempty.some hn).symm
hg : ∀ (i : Fin n), Memℒp (g i) p
δ : ℝ
hδpos : 0 < δ
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ
hδ : snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
assumption
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
⊢ snorm (indicator s (f - g)) p μ ≤ ENNReal.ofReal c * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
by_cases hp : p = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : p = 0
⊢ snorm (indicator s (f - g)) p μ ≤ ENNReal.ofReal c * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
simp [hp]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
⊢ snorm (indicator s (f - g)) p μ ≤ ENNReal.ofReal c * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
have : ∀ x, ‖s.indicator (f - g) x‖ ≤ ‖s.indicator (fun _ => c) x‖ :=
by
intro x
by_cases hx : x ∈ s
· rw [Set.indicator_of_mem hx, Set.indicator_of_mem hx, Pi.sub_apply, ← dist_eq_norm, Real.norm_eq_abs,
abs_of_nonneg hc]
exact hf x hx
· simp [Set.indicator_of_not_mem hx]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
⊢ ∀ (x : α), ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
[PROOFSTEP]
intro x
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
x : α
⊢ ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
[PROOFSTEP]
by_cases hx : x ∈ s
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
x : α
hx : x ∈ s
⊢ ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
[PROOFSTEP]
rw [Set.indicator_of_mem hx, Set.indicator_of_mem hx, Pi.sub_apply, ← dist_eq_norm, Real.norm_eq_abs, abs_of_nonneg hc]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
x : α
hx : x ∈ s
⊢ dist (f x) (g x) ≤ c
[PROOFSTEP]
exact hf x hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
x : α
hx : ¬x ∈ s
⊢ ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
[PROOFSTEP]
simp [Set.indicator_of_not_mem hx]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
this : ∀ (x : α), ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
⊢ snorm (indicator s (f - g)) p μ ≤ ENNReal.ofReal c * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
refine' le_trans (snorm_mono this) _
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
this : ∀ (x : α), ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
⊢ snorm (fun x => indicator s (fun x => c) x) p μ ≤ ENNReal.ofReal c * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
rw [snorm_indicator_const hs hp hp']
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
this : ∀ (x : α), ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
⊢ ↑‖c‖₊ * ↑↑μ s ^ (1 / ENNReal.toReal p) ≤ ENNReal.ofReal c * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
refine' mul_le_mul_right' (le_of_eq _) _
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p✝ p : ℝ≥0∞
hp' : p ≠ ⊤
s : Set α
hs : MeasurableSet s
f g : α → β
c : ℝ
hc : 0 ≤ c
hf : ∀ (x : α), x ∈ s → dist (f x) (g x) ≤ c
hp : ¬p = 0
this : ∀ (x : α), ‖indicator s (f - g) x‖ ≤ ‖indicator s (fun x => c) x‖
⊢ ↑‖c‖₊ = ENNReal.ofReal c
[PROOFSTEP]
rw [← ofReal_norm_eq_coe_nnnorm, Real.norm_eq_abs, abs_of_nonneg hc]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
⊢ Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
[PROOFSTEP]
rw [ENNReal.tendsto_atTop_zero]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
⊢ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
intro ε hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
by_cases ε < ∞
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
by_cases ε < ∞
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ¬ε < ⊤
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
swap
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ¬ε < ⊤
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
rw [not_lt, top_le_iff] at h
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε = ⊤
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
exact ⟨0, fun n _ => by simp [h]⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε = ⊤
n : ℕ
x✝ : n ≥ 0
⊢ snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
simp [h]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
by_cases hμ : μ = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : μ = 0
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
exact ⟨0, fun n _ => by simp [hμ]⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : μ = 0
n : ℕ
x✝ : n ≥ 0
⊢ snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
simp [hμ]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
have hε' : 0 < ε.toReal / 3 := div_pos (ENNReal.toReal_pos (gt_iff_lt.1 hε).ne.symm h.ne) (by norm_num)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
⊢ 0 < 3
[PROOFSTEP]
norm_num
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
have hdivp : 0 ≤ 1 / p.toReal := by
refine' one_div_nonneg.2 _
rw [← ENNReal.zero_toReal, ENNReal.toReal_le_toReal ENNReal.zero_ne_top hp']
exact le_trans (zero_le _) hp
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
⊢ 0 ≤ 1 / ENNReal.toReal p
[PROOFSTEP]
refine' one_div_nonneg.2 _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
⊢ 0 ≤ ENNReal.toReal p
[PROOFSTEP]
rw [← ENNReal.zero_toReal, ENNReal.toReal_le_toReal ENNReal.zero_ne_top hp']
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
⊢ 0 ≤ p
[PROOFSTEP]
exact le_trans (zero_le _) hp
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
have hpow : 0 < measureUnivNNReal μ ^ (1 / p.toReal) := Real.rpow_pos_of_pos (measureUnivNNReal_pos hμ) _
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
obtain ⟨δ₁, hδ₁, hsnorm₁⟩ := hui hε'
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
obtain ⟨δ₂, hδ₂, hsnorm₂⟩ := hg'.snorm_indicator_le μ hp hp' hε'
[GOAL]
case neg.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
obtain ⟨t, htm, ht₁, ht₂⟩ := tendstoUniformlyOn_of_ae_tendsto' hf hg hfg (lt_min hδ₁ hδ₂)
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
ht₂ : TendstoUniformlyOn (fun n => f n) g atTop tᶜ
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
rw [Metric.tendstoUniformlyOn_iff] at ht₂
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
ht₂ : ∀ (ε : ℝ), ε > 0 → ∀ᶠ (n : ℕ) in atTop, ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ε
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
specialize
ht₂ (ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal)))
(div_pos (ENNReal.toReal_pos (gt_iff_lt.1 hε).ne.symm h.ne) (mul_pos (by norm_num) hpow))
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
ht₂ : ∀ (ε : ℝ), ε > 0 → ∀ᶠ (n : ℕ) in atTop, ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ε
⊢ 0 < 3
[PROOFSTEP]
norm_num
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
ht₂ :
∀ᶠ (n : ℕ) in atTop,
∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
obtain ⟨N, hN⟩ := eventually_atTop.1 ht₂
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
ht₂ :
∀ᶠ (n : ℕ) in atTop,
∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
clear ht₂
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
refine' ⟨N, fun n hn => _⟩
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ snorm (f n - g) p μ ≤ ε
[PROOFSTEP]
rw [← t.indicator_self_add_compl (f n - g)]
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ snorm (indicator t (f n - g) + indicator tᶜ (f n - g)) p μ ≤ ε
[PROOFSTEP]
refine'
le_trans
(snorm_add_le (((hf n).sub hg).indicator htm).aestronglyMeasurable
(((hf n).sub hg).indicator htm.compl).aestronglyMeasurable hp)
_
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ snorm (indicator t (f n - g)) p μ + snorm (indicator tᶜ (f n - g)) p μ ≤ ε
[PROOFSTEP]
rw [sub_eq_add_neg, Set.indicator_add' t, Set.indicator_neg']
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ snorm (indicator t (f n) + -indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
refine'
le_trans
(add_le_add_right
(snorm_add_le ((hf n).indicator htm).aestronglyMeasurable (hg.indicator htm).neg.aestronglyMeasurable hp) _)
_
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ snorm (indicator t (f n)) p μ + snorm (-indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
have hnf : snorm (t.indicator (f n)) p μ ≤ ENNReal.ofReal (ε.toReal / 3) :=
by
refine' hsnorm₁ n t htm (le_trans ht₁ _)
rw [ENNReal.ofReal_le_ofReal_iff hδ₁.le]
exact min_le_left _ _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
refine' hsnorm₁ n t htm (le_trans ht₁ _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ ENNReal.ofReal (min δ₁ δ₂) ≤ ENNReal.ofReal δ₁
[PROOFSTEP]
rw [ENNReal.ofReal_le_ofReal_iff hδ₁.le]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
⊢ min δ₁ δ₂ ≤ δ₁
[PROOFSTEP]
exact min_le_left _ _
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ snorm (indicator t (f n)) p μ + snorm (-indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
have hng : snorm (t.indicator g) p μ ≤ ENNReal.ofReal (ε.toReal / 3) :=
by
refine' hsnorm₂ t htm (le_trans ht₁ _)
rw [ENNReal.ofReal_le_ofReal_iff hδ₂.le]
exact min_le_right _ _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
refine' hsnorm₂ t htm (le_trans ht₁ _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ ENNReal.ofReal (min δ₁ δ₂) ≤ ENNReal.ofReal δ₂
[PROOFSTEP]
rw [ENNReal.ofReal_le_ofReal_iff hδ₂.le]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ min δ₁ δ₂ ≤ δ₂
[PROOFSTEP]
exact min_le_right _ _
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ snorm (indicator t (f n)) p μ + snorm (-indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
have hlt : snorm (tᶜ.indicator (f n - g)) p μ ≤ ENNReal.ofReal (ε.toReal / 3) :=
by
specialize hN n hn
have : 0 ≤ ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal)) :=
by
rw [div_mul_eq_div_mul_one_div]
exact mul_nonneg hε'.le (one_div_nonneg.2 hpow.le)
have :=
snorm_sub_le_of_dist_bdd μ hp' htm.compl this fun x hx =>
(dist_comm (g x) (f n x) ▸ (hN x hx).le :
dist (f n x) (g x) ≤ ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal)))
refine' le_trans this _
rw [div_mul_eq_div_mul_one_div, ← ENNReal.ofReal_toReal (measure_lt_top μ tᶜ).ne,
ENNReal.ofReal_rpow_of_nonneg ENNReal.toReal_nonneg hdivp, ← ENNReal.ofReal_mul, mul_assoc]
· refine' ENNReal.ofReal_le_ofReal (mul_le_of_le_one_right hε'.le _)
rw [mul_comm, mul_one_div, div_le_one]
· refine'
Real.rpow_le_rpow ENNReal.toReal_nonneg (ENNReal.toReal_le_of_le_ofReal (measureUnivNNReal_pos hμ).le _) hdivp
rw [ENNReal.ofReal_coe_nnreal, coe_measureUnivNNReal]
exact measure_mono (Set.subset_univ _)
· exact Real.rpow_pos_of_pos (measureUnivNNReal_pos hμ) _
· refine' mul_nonneg hε'.le (one_div_nonneg.2 hpow.le)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
specialize hN n hn
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
have : 0 ≤ ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal)) :=
by
rw [div_mul_eq_div_mul_one_div]
exact mul_nonneg hε'.le (one_div_nonneg.2 hpow.le)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
[PROOFSTEP]
rw [div_mul_eq_div_mul_one_div]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ 0 ≤ ENNReal.toReal ε / 3 * (1 / ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
[PROOFSTEP]
exact mul_nonneg hε'.le (one_div_nonneg.2 hpow.le)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
⊢ snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
have :=
snorm_sub_le_of_dist_bdd μ hp' htm.compl this fun x hx =>
(dist_comm (g x) (f n x) ▸ (hN x hx).le :
dist (f n x) (g x) ≤ ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal)))
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
refine' le_trans this _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p) ≤
ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
rw [div_mul_eq_div_mul_one_div, ← ENNReal.ofReal_toReal (measure_lt_top μ tᶜ).ne,
ENNReal.ofReal_rpow_of_nonneg ENNReal.toReal_nonneg hdivp, ← ENNReal.ofReal_mul, mul_assoc]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ ENNReal.ofReal
(ENNReal.toReal ε / 3 *
(1 / ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p) * ENNReal.toReal (↑↑μ tᶜ) ^ (1 / ENNReal.toReal p))) ≤
ENNReal.ofReal (ENNReal.toReal ε / 3)
[PROOFSTEP]
refine' ENNReal.ofReal_le_ofReal (mul_le_of_le_one_right hε'.le _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ 1 / ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p) * ENNReal.toReal (↑↑μ tᶜ) ^ (1 / ENNReal.toReal p) ≤ 1
[PROOFSTEP]
rw [mul_comm, mul_one_div, div_le_one]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ ENNReal.toReal (↑↑μ tᶜ) ^ (1 / ENNReal.toReal p) ≤ ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
refine' Real.rpow_le_rpow ENNReal.toReal_nonneg (ENNReal.toReal_le_of_le_ofReal (measureUnivNNReal_pos hμ).le _) hdivp
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ ↑↑μ tᶜ ≤ ENNReal.ofReal ↑(measureUnivNNReal μ)
[PROOFSTEP]
rw [ENNReal.ofReal_coe_nnreal, coe_measureUnivNNReal]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ ↑↑μ tᶜ ≤ ↑↑μ univ
[PROOFSTEP]
exact measure_mono (Set.subset_univ _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
exact Real.rpow_pos_of_pos (measureUnivNNReal_pos hμ) _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hN : ∀ (x : α), x ∈ tᶜ → dist (g x) (f n x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this✝ : 0 ≤ ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
this :
snorm (indicator tᶜ ((fun x => f n x) - fun x => g x)) p μ ≤
ENNReal.ofReal (ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))) *
↑↑μ tᶜ ^ (1 / ENNReal.toReal p)
⊢ 0 ≤ ENNReal.toReal ε / 3 * (1 / ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
[PROOFSTEP]
refine' mul_nonneg hε'.le (one_div_nonneg.2 hpow.le)
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ snorm (indicator t (f n)) p μ + snorm (-indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
have : ENNReal.ofReal (ε.toReal / 3) = ε / 3 :=
by
rw [ENNReal.ofReal_div_of_pos (show (0 : ℝ) < 3 by norm_num), ENNReal.ofReal_toReal h.ne]
simp
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ ENNReal.ofReal (ENNReal.toReal ε / 3) = ε / 3
[PROOFSTEP]
rw [ENNReal.ofReal_div_of_pos (show (0 : ℝ) < 3 by norm_num), ENNReal.ofReal_toReal h.ne]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ 0 < 3
[PROOFSTEP]
norm_num
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
⊢ ε / ENNReal.ofReal 3 = ε / 3
[PROOFSTEP]
simp
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hng : snorm (indicator t g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
this : ENNReal.ofReal (ENNReal.toReal ε / 3) = ε / 3
⊢ snorm (indicator t (f n)) p μ + snorm (-indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
rw [this] at hnf hng hlt
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ε / 3
hng : snorm (indicator t g) p μ ≤ ε / 3
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ε / 3
this : ENNReal.ofReal (ENNReal.toReal ε / 3) = ε / 3
⊢ snorm (indicator t (f n)) p μ + snorm (-indicator t g) p μ + snorm (indicator tᶜ (f n + -g)) p μ ≤ ε
[PROOFSTEP]
rw [snorm_neg, ← ENNReal.add_thirds ε, ← sub_eq_add_neg]
[GOAL]
case neg.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hg' : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ≥0∞
hε : ε > 0
h : ε < ⊤
hμ : ¬μ = 0
hε' : 0 < ENNReal.toReal ε / 3
hdivp : 0 ≤ 1 / ENNReal.toReal p
hpow : 0 < ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p)
δ₁ : ℝ
hδ₁ : 0 < δ₁
hsnorm₁ :
∀ (i : ℕ) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
δ₂ : ℝ
hδ₂ : 0 < δ₂
hsnorm₂ :
∀ (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₂ → snorm (indicator s g) p μ ≤ ENNReal.ofReal (ENNReal.toReal ε / 3)
t : Set α
htm : MeasurableSet t
ht₁ : ↑↑μ t ≤ ENNReal.ofReal (min δ₁ δ₂)
N : ℕ
hN :
∀ (b : ℕ),
b ≥ N →
∀ (x : α), x ∈ tᶜ → dist (g x) (f b x) < ENNReal.toReal ε / (3 * ↑(measureUnivNNReal μ) ^ (1 / ENNReal.toReal p))
n : ℕ
hn : n ≥ N
hnf : snorm (indicator t (f n)) p μ ≤ ε / 3
hng : snorm (indicator t g) p μ ≤ ε / 3
hlt : snorm (indicator tᶜ (f n - g)) p μ ≤ ε / 3
this : ENNReal.ofReal (ENNReal.toReal ε / 3) = ε / 3
⊢ snorm (indicator t (f n)) p μ + snorm (indicator t g) p μ + snorm (indicator tᶜ (f n - g)) p μ ≤ ε / 3 + ε / 3 + ε / 3
[PROOFSTEP]
exact add_le_add_three hnf hng hlt
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
⊢ Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
[PROOFSTEP]
have : ∀ n, snorm (f n - g) p μ = snorm ((hf n).mk (f n) - hg.1.mk g) p μ := fun n =>
snorm_congr_ae ((hf n).ae_eq_mk.sub hg.1.ae_eq_mk)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
⊢ Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
[PROOFSTEP]
simp_rw [this]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
⊢ Tendsto
(fun n =>
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ)
atTop (𝓝 0)
[PROOFSTEP]
refine'
tendsto_Lp_of_tendsto_ae_of_meas μ hp hp' (fun n => (hf n).stronglyMeasurable_mk) hg.1.stronglyMeasurable_mk
(hg.ae_eq hg.1.ae_eq_mk) (hui.ae_eq fun n => (hf n).ae_eq_mk) _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
⊢ ∀ᵐ (x : α) ∂μ,
Tendsto (fun n => AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x) atTop
(𝓝 (AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x))
[PROOFSTEP]
have h_ae_forall_eq : ∀ᵐ x ∂μ, ∀ n, f n x = (hf n).mk (f n) x :=
by
rw [ae_all_iff]
exact fun n => (hf n).ae_eq_mk
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
⊢ ∀ᵐ (x : α) ∂μ, ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
[PROOFSTEP]
rw [ae_all_iff]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
⊢ ∀ (i : ℕ), ∀ᵐ (a : α) ∂μ, f i a = AEStronglyMeasurable.mk (f i) (_ : AEStronglyMeasurable (f i) μ) a
[PROOFSTEP]
exact fun n => (hf n).ae_eq_mk
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
h_ae_forall_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
⊢ ∀ᵐ (x : α) ∂μ,
Tendsto (fun n => AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x) atTop
(𝓝 (AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x))
[PROOFSTEP]
filter_upwards [hfg, h_ae_forall_eq, hg.1.ae_eq_mk] with x hx_tendsto hxf_eq hxg_eq
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
h_ae_forall_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
x : α
hx_tendsto : Tendsto (fun n => f n x) atTop (𝓝 (g x))
hxf_eq : ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
hxg_eq : g x = AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x
⊢ Tendsto (fun n => AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x) atTop
(𝓝 (AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x))
[PROOFSTEP]
rw [← hxg_eq]
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
h_ae_forall_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
x : α
hx_tendsto : Tendsto (fun n => f n x) atTop (𝓝 (g x))
hxf_eq : ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
hxg_eq : g x = AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x
⊢ Tendsto (fun n => AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x) atTop (𝓝 (g x))
[PROOFSTEP]
convert hx_tendsto using 1
[GOAL]
case h.e'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
h_ae_forall_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
x : α
hx_tendsto : Tendsto (fun n => f n x) atTop (𝓝 (g x))
hxf_eq : ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
hxg_eq : g x = AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x
⊢ (fun n => AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x) = fun n => f n x
[PROOFSTEP]
ext1 n
[GOAL]
case h.e'_3.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ℕ → α → β
g : α → β
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
this :
∀ (n : ℕ),
snorm (f n - g) p μ =
snorm
(AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) -
AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ))
p μ
h_ae_forall_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
x : α
hx_tendsto : Tendsto (fun n => f n x) atTop (𝓝 (g x))
hxf_eq : ∀ (n : ℕ), f n x = AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x
hxg_eq : g x = AEStronglyMeasurable.mk g (_ : AEStronglyMeasurable g μ) x
n : ℕ
⊢ AEStronglyMeasurable.mk (f n) (_ : AEStronglyMeasurable (f n) μ) x = f n x
[PROOFSTEP]
exact (hxf_eq n).symm
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : Tendsto (fun n => snorm (f n) p μ) atTop (𝓝 0)
⊢ UnifIntegrable f p μ
[PROOFSTEP]
intro ε hε
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : Tendsto (fun n => snorm (f n) p μ) atTop (𝓝 0)
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [ENNReal.tendsto_atTop_zero] at hf_tendsto
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨N, hN⟩ := hf_tendsto (ENNReal.ofReal ε) (by simpa)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
⊢ ENNReal.ofReal ε > 0
[PROOFSTEP]
simpa
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
let F : Fin N → α → β := fun n => f n
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
F : Fin N → α → β := fun n => f ↑n
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hF : ∀ n, Memℒp (F n) p μ := fun n => hf n
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
F : Fin N → α → β := fun n => f ↑n
hF : ∀ (n : Fin N), Memℒp (F n) p
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ₁, hδpos₁, hδ₁⟩ := unifIntegrable_fin μ hp hp' hF hε
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
F : Fin N → α → β := fun n => f ↑n
hF : ∀ (n : Fin N), Memℒp (F n) p
δ₁ : ℝ
hδpos₁ : 0 < δ₁
hδ₁ :
∀ (i : Fin N) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => F i) i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ₁, hδpos₁, fun n s hs hμs => _⟩
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
F : Fin N → α → β := fun n => f ↑n
hF : ∀ (n : Fin N), Memℒp (F n) p
δ₁ : ℝ
hδpos₁ : 0 < δ₁
hδ₁ :
∀ (i : Fin N) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => F i) i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ₁
⊢ snorm (indicator s (f n)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hn : n < N
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
F : Fin N → α → β := fun n => f ↑n
hF : ∀ (n : Fin N), Memℒp (F n) p
δ₁ : ℝ
hδpos₁ : 0 < δ₁
hδ₁ :
∀ (i : Fin N) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => F i) i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ₁
hn : n < N
⊢ snorm (indicator s (f n)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact hδ₁ ⟨n, hn⟩ s hs hμs
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hf_tendsto : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ε
ε : ℝ
hε : 0 < ε
N : ℕ
hN : ∀ (n : ℕ), n ≥ N → snorm (f n) p μ ≤ ENNReal.ofReal ε
F : Fin N → α → β := fun n => f ↑n
hF : ∀ (n : Fin N), Memℒp (F n) p
δ₁ : ℝ
hδpos₁ : 0 < δ₁
hδ₁ :
∀ (i : Fin N) (s : Set α),
MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ₁ → snorm (indicator s ((fun i => F i) i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal δ₁
hn : ¬n < N
⊢ snorm (indicator s (f n)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact (snorm_indicator_le _).trans (hN n (not_lt.1 hn))
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
⊢ UnifIntegrable f p μ
[PROOFSTEP]
have : f = (fun _ => g) + fun n => f n - g := by ext1 n; simp
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
⊢ f = (fun x => g) + fun n => f n - g
[PROOFSTEP]
ext1 n
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
n : ℕ
⊢ f n = ((fun x => g) + fun n => f n - g) n
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
this : f = (fun x => g) + fun n => f n - g
⊢ UnifIntegrable f p μ
[PROOFSTEP]
rw [this]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
this : f = (fun x => g) + fun n => f n - g
⊢ UnifIntegrable ((fun x => g) + fun n => f n - g) p μ
[PROOFSTEP]
refine' UnifIntegrable.add _ _ hp (fun _ => hg.aestronglyMeasurable) fun n => (hf n).1.sub hg.aestronglyMeasurable
[GOAL]
case refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
this : f = (fun x => g) + fun n => f n - g
⊢ UnifIntegrable (fun x => g) p μ
[PROOFSTEP]
exact unifIntegrable_const μ hp hp' hg
[GOAL]
case refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), Memℒp (f n) p
hg : Memℒp g p
hfg : Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
this : f = (fun x => g) + fun n => f n - g
⊢ UnifIntegrable (fun n => f n - g) p μ
[PROOFSTEP]
exact unifIntegrable_of_tendsto_Lp_zero μ hp hp' (fun n => (hf n).sub hg) hfg
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : TendstoInMeasure μ f atTop g
⊢ Tendsto (fun n => snorm (f n - g) p μ) atTop (𝓝 0)
[PROOFSTEP]
refine' tendsto_of_subseq_tendsto fun ns hns => _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : TendstoInMeasure μ f atTop g
ns : ℕ → ℕ
hns : Tendsto ns atTop atTop
⊢ ∃ ms, Tendsto (fun n => snorm (f (ns (ms n)) - g) p μ) atTop (𝓝 0)
[PROOFSTEP]
obtain ⟨ms, _, hms'⟩ := TendstoInMeasure.exists_seq_tendsto_ae fun ε hε => (hfg ε hε).comp hns
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ℕ → α → β
g : α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ
hg : Memℒp g p
hui : UnifIntegrable f p μ
hfg : TendstoInMeasure μ f atTop g
ns : ℕ → ℕ
hns : Tendsto ns atTop atTop
ms : ℕ → ℕ
left✝ : StrictMono ms
hms' : ∀ᵐ (x : α) ∂μ, Tendsto (fun i => f (ns (ms i)) x) atTop (𝓝 (g x))
⊢ ∃ ms, Tendsto (fun n => snorm (f (ns (ms n)) - g) p μ) atTop (𝓝 0)
[PROOFSTEP]
exact
⟨ms,
tendsto_Lp_of_tendsto_ae μ hp hp' (fun _ => hf _) hg
(fun ε hε =>
let ⟨δ, hδ, hδ'⟩ := hui hε
⟨δ, hδ, fun i s hs hμs => hδ' _ s hs hμs⟩)
hms'⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ UnifIntegrable f p μ
[PROOFSTEP]
have hpzero := (lt_of_lt_of_le zero_lt_one hp).ne.symm
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
⊢ UnifIntegrable f p μ
[PROOFSTEP]
by_cases hμ : μ Set.univ = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ↑↑μ univ = 0
⊢ UnifIntegrable f p μ
[PROOFSTEP]
rw [Measure.measure_univ_eq_zero] at hμ
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : μ = 0
⊢ UnifIntegrable f p μ
[PROOFSTEP]
exact hμ.symm ▸ unifIntegrable_zero_meas
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
⊢ UnifIntegrable f p μ
[PROOFSTEP]
intro ε hε
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨C, hCpos, hC⟩ := h (ε / 2) (half_pos hε)
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
⊢ ∃ δ x,
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine'
⟨(ε / (2 * C)) ^ ENNReal.toReal p, Real.rpow_pos_of_pos (div_pos hε (mul_pos two_pos (NNReal.coe_pos.2 hCpos))) _,
fun i s hs hμs => _⟩
[GOAL]
case neg.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hμs' : μ s = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ↑↑μ s = 0
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [(snorm_eq_zero_iff ((hf i).indicator hs).aestronglyMeasurable hpzero).2 (indicator_meas_zero hμs')]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ↑↑μ s = 0
⊢ 0 ≤ ENNReal.ofReal ε
[PROOFSTEP]
norm_num
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
calc
snorm (Set.indicator s (f i)) p μ ≤
snorm (Set.indicator (s ∩ {x | C ≤ ‖f i x‖₊}) (f i)) p μ +
snorm (Set.indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i)) p μ :=
by
refine'
le_trans (Eq.le _)
(snorm_add_le
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator (hs.inter (stronglyMeasurable_const.measurableSet_le (hf i).nnnorm))))
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator (hs.inter ((hf i).nnnorm.measurableSet_lt stronglyMeasurable_const))))
hp)
congr
change _ = fun x => (s ∩ {x : α | C ≤ ‖f i x‖₊}).indicator (f i) x + (s ∩ {x : α | ‖f i x‖₊ < C}).indicator (f i) x
rw [← Set.indicator_union_of_disjoint]
· congr
rw [← Set.inter_union_distrib_left,
(by ext; simp [le_or_lt] : {x : α | C ≤ ‖f i x‖₊} ∪ {x : α | ‖f i x‖₊ < C} = Set.univ), Set.inter_univ]
· refine' (Disjoint.inf_right' _ _).inf_left' _
rw [disjoint_iff_inf_le]
rintro x ⟨hx₁, hx₂⟩
rw [Set.mem_setOf_eq] at hx₁ hx₂
exact False.elim (hx₂.ne (eq_of_le_of_not_lt hx₁ (not_lt.2 hx₂.le)).symm)
_ ≤ snorm (Set.indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ + (C : ℝ≥0∞) * μ s ^ (1 / ENNReal.toReal p) :=
by
refine' add_le_add (snorm_mono fun x => norm_indicator_le_of_subset (Set.inter_subset_right _ _) _ _) _
rw [← Set.indicator_indicator]
rw [snorm_indicator_eq_snorm_restrict hs]
have : ∀ᵐ x ∂μ.restrict s, ‖{x : α | ‖f i x‖₊ < C}.indicator (f i) x‖ ≤ C :=
by
refine' ae_of_all _ _
simp_rw [norm_indicator_eq_indicator_norm]
exact Set.indicator_le' (fun x (hx : _ < _) => hx.le) fun _ _ => NNReal.coe_nonneg _
refine' le_trans (snorm_le_of_ae_bound this) _
rw [mul_comm, Measure.restrict_apply' hs, Set.univ_inter, ENNReal.ofReal_coe_nnreal, one_div]
_ ≤ ENNReal.ofReal (ε / 2) + C * ENNReal.ofReal (ε / (2 * C)) :=
by
refine' add_le_add (hC i) (mul_le_mul_left' _ _)
rwa [ENNReal.rpow_one_div_le_iff (ENNReal.toReal_pos hpzero hp'),
ENNReal.ofReal_rpow_of_pos (div_pos hε (mul_pos two_pos (NNReal.coe_pos.2 hCpos)))]
_ ≤ ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2) :=
by
refine' add_le_add_left _ _
rw [← ENNReal.ofReal_coe_nnreal, ← ENNReal.ofReal_mul (NNReal.coe_nonneg _), ← div_div,
mul_div_cancel' _ (NNReal.coe_pos.2 hCpos).ne.symm]
_ ≤ ENNReal.ofReal ε := by rw [← ENNReal.ofReal_add (half_pos hε).le (half_pos hε).le, add_halves]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator s (f i)) p μ ≤
snorm (indicator (s ∩ {x | C ≤ ‖f i x‖₊}) (f i)) p μ + snorm (indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i)) p μ
[PROOFSTEP]
refine'
le_trans (Eq.le _)
(snorm_add_le
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator (hs.inter (stronglyMeasurable_const.measurableSet_le (hf i).nnnorm))))
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator (hs.inter ((hf i).nnnorm.measurableSet_lt stronglyMeasurable_const))))
hp)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator s (f i)) p μ =
snorm (indicator (s ∩ {x | C ≤ ‖f i x‖₊}) (f i) + indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i)) p μ
[PROOFSTEP]
congr
[GOAL]
case e_f
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ indicator s (f i) = indicator (s ∩ {x | C ≤ ‖f i x‖₊}) (f i) + indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i)
[PROOFSTEP]
change _ = fun x => (s ∩ {x : α | C ≤ ‖f i x‖₊}).indicator (f i) x + (s ∩ {x : α | ‖f i x‖₊ < C}).indicator (f i) x
[GOAL]
case e_f
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ indicator s (f i) = fun x => indicator (s ∩ {x | C ≤ ‖f i x‖₊}) (f i) x + indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i) x
[PROOFSTEP]
rw [← Set.indicator_union_of_disjoint]
[GOAL]
case e_f
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ indicator s (f i) = indicator (s ∩ {x | C ≤ ‖f i x‖₊} ∪ s ∩ {x | ‖f i x‖₊ < C}) (f i)
[PROOFSTEP]
congr
[GOAL]
case e_f
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ indicator s (f i) = indicator (s ∩ {x | C ≤ ‖f i x‖₊} ∪ s ∩ {x | ‖f i x‖₊ < C}) (f i)
[PROOFSTEP]
rw [← Set.inter_union_distrib_left,
(by ext; simp [le_or_lt] : {x : α | C ≤ ‖f i x‖₊} ∪ {x : α | ‖f i x‖₊ < C} = Set.univ), Set.inter_univ]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ {x | C ≤ ‖f i x‖₊} ∪ {x | ‖f i x‖₊ < C} = univ
[PROOFSTEP]
ext
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
x✝ : α
⊢ x✝ ∈ {x | C ≤ ‖f i x‖₊} ∪ {x | ‖f i x‖₊ < C} ↔ x✝ ∈ univ
[PROOFSTEP]
simp [le_or_lt]
[GOAL]
case e_f.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ Disjoint (s ∩ {x | C ≤ ‖f i x‖₊}) (s ∩ {x | ‖f i x‖₊ < C})
[PROOFSTEP]
refine' (Disjoint.inf_right' _ _).inf_left' _
[GOAL]
case e_f.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ Disjoint {x | C ≤ ‖f i x‖₊} {x | ‖f i x‖₊ < C}
[PROOFSTEP]
rw [disjoint_iff_inf_le]
[GOAL]
case e_f.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ {x | C ≤ ‖f i x‖₊} ⊓ {x | ‖f i x‖₊ < C} ≤ ⊥
[PROOFSTEP]
rintro x ⟨hx₁, hx₂⟩
[GOAL]
case e_f.h.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
x : α
hx₁ : x ∈ {x | C ≤ ‖f i x‖₊}
hx₂ : x ∈ {x | ‖f i x‖₊ < C}
⊢ x ∈ ⊥
[PROOFSTEP]
rw [Set.mem_setOf_eq] at hx₁ hx₂
[GOAL]
case e_f.h.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
x : α
hx₁ : C ≤ ‖f i x‖₊
hx₂ : ‖f i x‖₊ < C
⊢ x ∈ ⊥
[PROOFSTEP]
exact False.elim (hx₂.ne (eq_of_le_of_not_lt hx₁ (not_lt.2 hx₂.le)).symm)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator (s ∩ {x | C ≤ ‖f i x‖₊}) (f i)) p μ + snorm (indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i)) p μ ≤
snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ + ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
refine' add_le_add (snorm_mono fun x => norm_indicator_le_of_subset (Set.inter_subset_right _ _) _ _) _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator (s ∩ {x | ‖f i x‖₊ < C}) (f i)) p μ ≤ ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
rw [← Set.indicator_indicator]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator s (indicator {x | ‖f i x‖₊ < C} (f i))) p μ ≤ ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
rw [snorm_indicator_eq_snorm_restrict hs]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator {x | ‖f i x‖₊ < C} (f i)) p (Measure.restrict μ s) ≤ ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
have : ∀ᵐ x ∂μ.restrict s, ‖{x : α | ‖f i x‖₊ < C}.indicator (f i) x‖ ≤ C :=
by
refine' ae_of_all _ _
simp_rw [norm_indicator_eq_indicator_norm]
exact Set.indicator_le' (fun x (hx : _ < _) => hx.le) fun _ _ => NNReal.coe_nonneg _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖ ≤ ↑C
[PROOFSTEP]
refine' ae_of_all _ _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ∀ (a : α), ‖indicator {x | ‖f i x‖₊ < C} (f i) a‖ ≤ ↑C
[PROOFSTEP]
simp_rw [norm_indicator_eq_indicator_norm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ∀ (a : α), indicator {x | ‖f i x‖₊ < C} (fun a => ‖f i a‖) a ≤ ↑C
[PROOFSTEP]
exact Set.indicator_le' (fun x (hx : _ < _) => hx.le) fun _ _ => NNReal.coe_nonneg _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
this : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖ ≤ ↑C
⊢ snorm (indicator {x | ‖f i x‖₊ < C} (f i)) p (Measure.restrict μ s) ≤ ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
refine' le_trans (snorm_le_of_ae_bound this) _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
this : ∀ᵐ (x : α) ∂Measure.restrict μ s, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖ ≤ ↑C
⊢ ↑↑(Measure.restrict μ s) univ ^ (ENNReal.toReal p)⁻¹ * ENNReal.ofReal ↑C ≤ ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
rw [mul_comm, Measure.restrict_apply' hs, Set.univ_inter, ENNReal.ofReal_coe_nnreal, one_div]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ + ↑C * ↑↑μ s ^ (1 / ENNReal.toReal p) ≤
ENNReal.ofReal (ε / 2) + ↑C * ENNReal.ofReal (ε / (2 * ↑C))
[PROOFSTEP]
refine' add_le_add (hC i) (mul_le_mul_left' _ _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ↑↑μ s ^ (1 / ENNReal.toReal p) ≤ ENNReal.ofReal (ε / (2 * ↑C))
[PROOFSTEP]
rwa [ENNReal.rpow_one_div_le_iff (ENNReal.toReal_pos hpzero hp'),
ENNReal.ofReal_rpow_of_pos (div_pos hε (mul_pos two_pos (NNReal.coe_pos.2 hCpos)))]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ENNReal.ofReal (ε / 2) + ↑C * ENNReal.ofReal (ε / (2 * ↑C)) ≤ ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2)
[PROOFSTEP]
refine' add_le_add_left _ _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ↑C * ENNReal.ofReal (ε / (2 * ↑C)) ≤ ENNReal.ofReal (ε / 2)
[PROOFSTEP]
rw [← ENNReal.ofReal_coe_nnreal, ← ENNReal.ofReal_mul (NNReal.coe_nonneg _), ← div_div,
mul_div_cancel' _ (NNReal.coe_pos.2 hCpos).ne.symm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, 0 < C ∧ ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hpzero : p ≠ 0
hμ : ¬↑↑μ univ = 0
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hCpos : 0 < C
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal (ε / 2)
i : ι
s : Set α
hs : MeasurableSet s
hμs : ↑↑μ s ≤ ENNReal.ofReal ((ε / (2 * ↑C)) ^ ENNReal.toReal p)
hμs' : ¬↑↑μ s = 0
⊢ ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2) ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [← ENNReal.ofReal_add (half_pos hε).le (half_pos hε).le, add_halves]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ UnifIntegrable f p μ
[PROOFSTEP]
set g : ι → α → β := fun i => (hf i).choose
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
⊢ UnifIntegrable f p μ
[PROOFSTEP]
refine'
(unifIntegrable_of' μ hp hp' (fun i => (Exists.choose_spec <| hf i).1) fun ε hε => _).ae_eq fun i =>
(Exists.choose_spec <| hf i).2.symm
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
⊢ ∃ C,
0 < C ∧
∀ (i : ι),
snorm
(indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)))
p μ ≤
ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨C, hC⟩ := h ε hε
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C,
0 < C ∧
∀ (i : ι),
snorm
(indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)))
p μ ≤
ENNReal.ofReal ε
[PROOFSTEP]
have hCg : ∀ i, snorm ({x | C ≤ ‖g i x‖₊}.indicator (g i)) p μ ≤ ENNReal.ofReal ε :=
by
intro i
refine' le_trans (le_of_eq <| snorm_congr_ae _) (hC i)
filter_upwards [(Exists.choose_spec <| hf i).2] with x hx
by_cases hfx : x ∈ {x | C ≤ ‖f i x‖₊}
· rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx]
rwa [Set.mem_setOf, hx] at hfx
· rw [Set.indicator_of_not_mem hfx, Set.indicator_of_not_mem]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
intro i
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
⊢ snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' le_trans (le_of_eq <| snorm_congr_ae _) (hC i)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
⊢ indicator {x | C ≤ ‖g i x‖₊} (g i) =ᵐ[μ] indicator {x | C ≤ ‖f i x‖₊} (f i)
[PROOFSTEP]
filter_upwards [(Exists.choose_spec <| hf i).2] with x hx
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
⊢ indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x =
indicator {x | C ≤ ‖f i x‖₊} (f i) x
[PROOFSTEP]
by_cases hfx : x ∈ {x | C ≤ ‖f i x‖₊}
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : x ∈ {x | C ≤ ‖f i x‖₊}
⊢ indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x =
indicator {x | C ≤ ‖f i x‖₊} (f i) x
[PROOFSTEP]
rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx]
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : x ∈ {x | C ≤ ‖f i x‖₊}
⊢ x ∈ {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
[PROOFSTEP]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : ¬x ∈ {x | C ≤ ‖f i x‖₊}
⊢ indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x =
indicator {x | C ≤ ‖f i x‖₊} (f i) x
[PROOFSTEP]
rw [Set.indicator_of_not_mem hfx, Set.indicator_of_not_mem]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : ¬x ∈ {x | C ≤ ‖f i x‖₊}
⊢ ¬x ∈ {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
[PROOFSTEP]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hCg : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C,
0 < C ∧
∀ (i : ι),
snorm
(indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)))
p μ ≤
ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨max C 1, lt_max_of_lt_right one_pos, fun i => le_trans (snorm_mono fun x => _) (hCg i)⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hCg : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
⊢ ‖indicator {x | max C 1 ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x‖ ≤
‖indicator {x | C ≤ ‖g i x‖₊} (g i) x‖
[PROOFSTEP]
rw [norm_indicator_eq_indicator_norm, norm_indicator_eq_indicator_norm]
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ℕ → α → β
g✝ : α → β
hp : 1 ≤ p
hp' : p ≠ ⊤
f : ι → α → β
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
hCg : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
⊢ indicator {x | max C 1 ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(fun a => ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) a‖) x ≤
indicator {x | C ≤ ‖g i x‖₊} (fun a => ‖g i a‖) x
[PROOFSTEP]
exact
Set.indicator_le_indicator_of_subset (fun x hx => Set.mem_setOf_eq ▸ le_trans (le_max_left _ _) hx)
(fun _ => norm_nonneg _) _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : ι → α → β
hf : UniformIntegrable f p μ
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
⊢ UniformIntegrable g p μ
[PROOFSTEP]
obtain ⟨hfm, hunif, C, hC⟩ := hf
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : ι → α → β
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
hfm : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hunif : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (f i) p μ ≤ ↑C
⊢ UniformIntegrable g p μ
[PROOFSTEP]
refine' ⟨fun i => (hfm i).congr (hfg i), (unifIntegrable_congr_ae hfg).1 hunif, C, fun i => _⟩
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : ι → α → β
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
hfm : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hunif : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (f i) p μ ≤ ↑C
i : ι
⊢ snorm (g i) p μ ≤ ↑C
[PROOFSTEP]
rw [← snorm_congr_ae (hfg i)]
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f g : ι → α → β
hfg : ∀ (n : ι), f n =ᵐ[μ] g n
hfm : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hunif : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (f i) p μ ≤ ↑C
i : ι
⊢ snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
exact hC i
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : ∀ (i : ι), Memℒp (f i) p
⊢ UniformIntegrable f p μ
[PROOFSTEP]
cases nonempty_fintype ι
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : ∀ (i : ι), Memℒp (f i) p
val✝ : Fintype ι
⊢ UniformIntegrable f p μ
[PROOFSTEP]
refine' ⟨fun n => (hf n).1, unifIntegrable_finite μ hp_one hp_top hf, _⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : ∀ (i : ι), Memℒp (f i) p
val✝ : Fintype ι
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
by_cases hι : Nonempty ι
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : ∀ (i : ι), Memℒp (f i) p
val✝ : Fintype ι
hι : Nonempty ι
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
choose _ hf using hf
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
set C :=
(Finset.univ.image fun i : ι => snorm (f i) p μ).max'
⟨snorm (f hι.some) p μ, Finset.mem_image.2 ⟨hι.some, Finset.mem_univ _, rfl⟩⟩
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
refine' ⟨C.toNNReal, fun i => _⟩
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
i : ι
⊢ snorm (f i) p μ ≤ ↑(ENNReal.toNNReal C)
[PROOFSTEP]
rw [ENNReal.coe_toNNReal]
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
i : ι
⊢ snorm (f i) p μ ≤ C
[PROOFSTEP]
exact Finset.le_max' (α := ℝ≥0∞) _ _ (Finset.mem_image.2 ⟨i, Finset.mem_univ _, rfl⟩)
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
i : ι
⊢ C ≠ ⊤
[PROOFSTEP]
refine' ne_of_lt ((Finset.max'_lt_iff _ _).2 fun y hy => _)
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
i : ι
y : ℝ≥0∞
hy : y ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ
⊢ y < ⊤
[PROOFSTEP]
rw [Finset.mem_image] at hy
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
i : ι
y : ℝ≥0∞
hy : ∃ a, a ∈ Finset.univ ∧ snorm (f a) p μ = y
⊢ y < ⊤
[PROOFSTEP]
obtain ⟨i, -, rfl⟩ := hy
[GOAL]
case pos.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
val✝ : Fintype ι
hι : Nonempty ι
h✝ : ∀ (i : ι), AEStronglyMeasurable (f i) μ
hf : ∀ (i : ι), snorm (f i) p μ < ⊤
C : ℝ≥0∞ :=
Finset.max' (Finset.image (fun i => snorm (f i) p μ) Finset.univ)
(_ : ∃ x, x ∈ Finset.image (fun i => snorm (f i) p μ) Finset.univ)
i✝ i : ι
⊢ snorm (f i) p μ < ⊤
[PROOFSTEP]
exact hf i
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : Finite ι
hp_one : 1 ≤ p
hp_top : p ≠ ⊤
hf : ∀ (i : ι), Memℒp (f i) p
val✝ : Fintype ι
hι : ¬Nonempty ι
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
exact ⟨0, fun i => False.elim <| hι <| Nonempty.intro i⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ UniformIntegrable f p μ
[PROOFSTEP]
refine' ⟨fun i => (hf i).aestronglyMeasurable, unifIntegrable_of μ hp hp' (fun i => (hf i).aestronglyMeasurable) h, _⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
obtain ⟨C, hC⟩ := h 1 one_pos
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
⊢ ∃ C, ∀ (i : ι), snorm (f i) p μ ≤ ↑C
[PROOFSTEP]
refine' ⟨((C : ℝ≥0∞) * μ Set.univ ^ p.toReal⁻¹ + 1).toNNReal, fun i => _⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ snorm (f i) p μ ≤ ↑(ENNReal.toNNReal (↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ + 1))
[PROOFSTEP]
calc
snorm (f i) p μ ≤
snorm ({x : α | ‖f i x‖₊ < C}.indicator (f i)) p μ + snorm ({x : α | C ≤ ‖f i x‖₊}.indicator (f i)) p μ :=
by
refine'
le_trans (snorm_mono fun x => _)
(snorm_add_le
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator ((hf i).nnnorm.measurableSet_lt stronglyMeasurable_const)))
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator (stronglyMeasurable_const.measurableSet_le (hf i).nnnorm)))
hp)
· rw [Pi.add_apply, Set.indicator_apply]
split_ifs with hx
· rw [Set.indicator_of_not_mem, add_zero]
simpa using hx
· rw [Set.indicator_of_mem, zero_add]
simpa using hx
_ ≤ (C : ℝ≥0∞) * μ Set.univ ^ p.toReal⁻¹ + 1 :=
by
have : ∀ᵐ x ∂μ, ‖{x : α | ‖f i x‖₊ < C}.indicator (f i) x‖₊ ≤ C :=
by
refine' eventually_of_forall _
simp_rw [nnnorm_indicator_eq_indicator_nnnorm]
exact Set.indicator_le fun x (hx : _ < _) => hx.le
refine' add_le_add (le_trans (snorm_le_of_ae_bound this) _) (ENNReal.ofReal_one ▸ hC i)
simp_rw [NNReal.val_eq_coe, ENNReal.ofReal_coe_nnreal, mul_comm]
exact le_rfl
_ = ((C : ℝ≥0∞) * μ Set.univ ^ p.toReal⁻¹ + 1 : ℝ≥0∞).toNNReal :=
by
rw [ENNReal.coe_toNNReal]
exact
ENNReal.add_ne_top.2
⟨ENNReal.mul_ne_top ENNReal.coe_ne_top
(ENNReal.rpow_ne_top_of_nonneg (inv_nonneg.2 ENNReal.toReal_nonneg) (measure_lt_top _ _).ne),
ENNReal.one_ne_top⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ snorm (f i) p μ ≤ snorm (indicator {x | ‖f i x‖₊ < C} (f i)) p μ + snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ
[PROOFSTEP]
refine'
le_trans (snorm_mono fun x => _)
(snorm_add_le
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator ((hf i).nnnorm.measurableSet_lt stronglyMeasurable_const)))
(StronglyMeasurable.aestronglyMeasurable
((hf i).indicator (stronglyMeasurable_const.measurableSet_le (hf i).nnnorm)))
hp)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
x : α
⊢ ‖f i x‖ ≤ ‖(indicator {x | ‖f i x‖₊ < C} (f i) + indicator {x | C ≤ ‖f i x‖₊} (f i)) x‖
[PROOFSTEP]
rw [Pi.add_apply, Set.indicator_apply]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
x : α
⊢ ‖f i x‖ ≤ ‖(if x ∈ {x | ‖f i x‖₊ < C} then f i x else 0) + indicator {x | C ≤ ‖f i x‖₊} (f i) x‖
[PROOFSTEP]
split_ifs with hx
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
x : α
hx : x ∈ {x | ‖f i x‖₊ < C}
⊢ ‖f i x‖ ≤ ‖f i x + indicator {x | C ≤ ‖f i x‖₊} (f i) x‖
[PROOFSTEP]
rw [Set.indicator_of_not_mem, add_zero]
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
x : α
hx : x ∈ {x | ‖f i x‖₊ < C}
⊢ ¬x ∈ {x | C ≤ ‖f i x‖₊}
[PROOFSTEP]
simpa using hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
x : α
hx : ¬x ∈ {x | ‖f i x‖₊ < C}
⊢ ‖f i x‖ ≤ ‖0 + indicator {x | C ≤ ‖f i x‖₊} (f i) x‖
[PROOFSTEP]
rw [Set.indicator_of_mem, zero_add]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
x : α
hx : ¬x ∈ {x | ‖f i x‖₊ < C}
⊢ x ∈ {x | C ≤ ‖f i x‖₊}
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ snorm (indicator {x | ‖f i x‖₊ < C} (f i)) p μ + snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤
↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ + 1
[PROOFSTEP]
have : ∀ᵐ x ∂μ, ‖{x : α | ‖f i x‖₊ < C}.indicator (f i) x‖₊ ≤ C :=
by
refine' eventually_of_forall _
simp_rw [nnnorm_indicator_eq_indicator_nnnorm]
exact Set.indicator_le fun x (hx : _ < _) => hx.le
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ ∀ᵐ (x : α) ∂μ, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖₊ ≤ C
[PROOFSTEP]
refine' eventually_of_forall _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ ∀ (x : α), ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖₊ ≤ C
[PROOFSTEP]
simp_rw [nnnorm_indicator_eq_indicator_nnnorm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ ∀ (x : α), indicator {x | ‖f i x‖₊ < C} (fun a => ‖f i a‖₊) x ≤ C
[PROOFSTEP]
exact Set.indicator_le fun x (hx : _ < _) => hx.le
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
this : ∀ᵐ (x : α) ∂μ, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖₊ ≤ C
⊢ snorm (indicator {x | ‖f i x‖₊ < C} (f i)) p μ + snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤
↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ + 1
[PROOFSTEP]
refine' add_le_add (le_trans (snorm_le_of_ae_bound this) _) (ENNReal.ofReal_one ▸ hC i)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
this : ∀ᵐ (x : α) ∂μ, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖₊ ≤ C
⊢ ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ * ENNReal.ofReal ((fun a => ↑a) C) ≤ ↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹
[PROOFSTEP]
simp_rw [NNReal.val_eq_coe, ENNReal.ofReal_coe_nnreal, mul_comm]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
this : ∀ᵐ (x : α) ∂μ, ‖indicator {x | ‖f i x‖₊ < C} (f i) x‖₊ ≤ C
⊢ ↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ ≤ ↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹
[PROOFSTEP]
exact le_rfl
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ ↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ + 1 = ↑(ENNReal.toNNReal (↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ + 1))
[PROOFSTEP]
rw [ENNReal.coe_toNNReal]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal 1
i : ι
⊢ ↑C * ↑↑μ univ ^ (ENNReal.toReal p)⁻¹ + 1 ≠ ⊤
[PROOFSTEP]
exact
ENNReal.add_ne_top.2
⟨ENNReal.mul_ne_top ENNReal.coe_ne_top
(ENNReal.rpow_ne_top_of_nonneg (inv_nonneg.2 ENNReal.toReal_nonneg) (measure_lt_top _ _).ne),
ENNReal.one_ne_top⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ UniformIntegrable f p μ
[PROOFSTEP]
set g : ι → α → β := fun i => (hf i).choose
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
⊢ UniformIntegrable f p μ
[PROOFSTEP]
have hgmeas : ∀ i, StronglyMeasurable (g i) := fun i => (Exists.choose_spec <| hf i).1
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
⊢ UniformIntegrable f p μ
[PROOFSTEP]
have hgeq : ∀ i, g i =ᵐ[μ] f i := fun i => (Exists.choose_spec <| hf i).2.symm
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
⊢ UniformIntegrable f p μ
[PROOFSTEP]
refine' (uniformIntegrable_of' hp hp' hgmeas fun ε hε => _).ae_eq hgeq
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨C, hC⟩ := h ε hε
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨C, fun i => le_trans (le_of_eq <| snorm_congr_ae _) (hC i)⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
⊢ indicator {x | C ≤ ‖g i x‖₊} (g i) =ᵐ[μ] indicator {x | C ≤ ‖f i x‖₊} (f i)
[PROOFSTEP]
filter_upwards [(Exists.choose_spec <| hf i).2] with x hx
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
⊢ indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x =
indicator {x | C ≤ ‖f i x‖₊} (f i) x
[PROOFSTEP]
by_cases hfx : x ∈ {x | C ≤ ‖f i x‖₊}
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : x ∈ {x | C ≤ ‖f i x‖₊}
⊢ indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x =
indicator {x | C ≤ ‖f i x‖₊} (f i) x
[PROOFSTEP]
rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx]
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : x ∈ {x | C ≤ ‖f i x‖₊}
⊢ x ∈ {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
[PROOFSTEP]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : ¬x ∈ {x | C ≤ ‖f i x‖₊}
⊢ indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x =
indicator {x | C ≤ ‖f i x‖₊} (f i) x
[PROOFSTEP]
rw [Set.indicator_of_not_mem hfx, Set.indicator_of_not_mem]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝¹ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
inst✝ : IsFiniteMeasure μ
hp : 1 ≤ p
hp' : p ≠ ⊤
hf : ∀ (i : ι), AEStronglyMeasurable (f i) μ
h : ∀ (ε : ℝ), 0 < ε → ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgeq : ∀ (i : ι), g i =ᵐ[μ] f i
ε : ℝ
hε : 0 < ε
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : ¬x ∈ {x | C ≤ ‖f i x‖₊}
⊢ ¬x ∈ {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
[PROOFSTEP]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨-, hfu, M, hM⟩ := hfu
[GOAL]
case intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδpos, hδ⟩ := hfu hε
[GOAL]
case intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨C, hC⟩ : ∃ C : ℝ≥0, ∀ i, μ {x | C ≤ ‖f i x‖₊} ≤ ENNReal.ofReal δ :=
by
by_contra hcon; push_neg at hcon
choose ℐ hℐ using hcon
lift δ to ℝ≥0 using hδpos.le
have : ∀ C : ℝ≥0, C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ snorm (f (ℐ C)) p μ :=
by
intro C
calc
C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ C • μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / p.toReal) :=
by
rw [ENNReal.smul_def, ENNReal.smul_def, smul_eq_mul, smul_eq_mul]
simp_rw [ENNReal.ofReal_coe_nnreal] at hℐ
refine' mul_le_mul' le_rfl (ENNReal.rpow_le_rpow (hℐ C).le (one_div_nonneg.2 ENNReal.toReal_nonneg))
_ ≤ snorm ({x | C ≤ ‖f (ℐ C) x‖₊}.indicator (f (ℐ C))) p μ :=
by
refine'
snorm_indicator_ge_of_bdd_below hp hp' _ (measurableSet_le measurable_const (hf _).nnnorm.measurable)
(eventually_of_forall fun x hx => _)
rwa [nnnorm_indicator_eq_indicator_nnnorm, Set.indicator_of_mem hx]
_ ≤ snorm (f (ℐ C)) p μ := snorm_indicator_le _
specialize this (2 * max M 1 * HPow.hPow δ⁻¹ (1 / p.toReal))
rw [ENNReal.coe_rpow_of_nonneg _ (one_div_nonneg.2 ENNReal.toReal_nonneg), ← ENNReal.coe_smul, smul_eq_mul, mul_assoc,
NNReal.inv_rpow, inv_mul_cancel (NNReal.rpow_pos (NNReal.coe_pos.1 hδpos)).ne.symm, mul_one, ENNReal.coe_mul, ←
NNReal.inv_rpow] at this
refine'
(lt_of_le_of_lt (le_trans (hM <| ℐ <| 2 * max M 1 * HPow.hPow δ⁻¹ (1 / p.toReal)) (le_max_left (M : ℝ≥0∞) 1))
(lt_of_lt_of_le _ this)).ne
rfl
rw [← ENNReal.coe_one, ← ENNReal.coe_max, ← ENNReal.coe_mul, ENNReal.coe_lt_coe]
exact lt_two_mul_self (lt_max_of_lt_right one_pos)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C, ∀ (i : ι), ↑↑μ {x | C ≤ ‖f i x‖₊} ≤ ENNReal.ofReal δ
[PROOFSTEP]
by_contra hcon
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hcon : ¬∃ C, ∀ (i : ι), ↑↑μ {x | C ≤ ‖f i x‖₊} ≤ ENNReal.ofReal δ
⊢ False
[PROOFSTEP]
push_neg at hcon
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hcon : ∀ (C : ℝ≥0), ∃ i, ENNReal.ofReal δ < ↑↑μ {x | C ≤ ‖f i x‖₊}
⊢ False
[PROOFSTEP]
choose ℐ hℐ using hcon
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
ℐ : ℝ≥0 → ι
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
⊢ False
[PROOFSTEP]
lift δ to ℝ≥0 using hδpos.le
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
⊢ False
[PROOFSTEP]
have : ∀ C : ℝ≥0, C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ snorm (f (ℐ C)) p μ :=
by
intro C
calc
C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ C • μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / p.toReal) :=
by
rw [ENNReal.smul_def, ENNReal.smul_def, smul_eq_mul, smul_eq_mul]
simp_rw [ENNReal.ofReal_coe_nnreal] at hℐ
refine' mul_le_mul' le_rfl (ENNReal.rpow_le_rpow (hℐ C).le (one_div_nonneg.2 ENNReal.toReal_nonneg))
_ ≤ snorm ({x | C ≤ ‖f (ℐ C) x‖₊}.indicator (f (ℐ C))) p μ :=
by
refine'
snorm_indicator_ge_of_bdd_below hp hp' _ (measurableSet_le measurable_const (hf _).nnnorm.measurable)
(eventually_of_forall fun x hx => _)
rwa [nnnorm_indicator_eq_indicator_nnnorm, Set.indicator_of_mem hx]
_ ≤ snorm (f (ℐ C)) p μ := snorm_indicator_le _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
⊢ ∀ (C : ℝ≥0), C • ↑δ ^ (1 / ENNReal.toReal p) ≤ snorm (f (ℐ C)) p μ
[PROOFSTEP]
intro C
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
C : ℝ≥0
⊢ C • ↑δ ^ (1 / ENNReal.toReal p) ≤ snorm (f (ℐ C)) p μ
[PROOFSTEP]
calc
C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ C • μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / p.toReal) :=
by
rw [ENNReal.smul_def, ENNReal.smul_def, smul_eq_mul, smul_eq_mul]
simp_rw [ENNReal.ofReal_coe_nnreal] at hℐ
refine' mul_le_mul' le_rfl (ENNReal.rpow_le_rpow (hℐ C).le (one_div_nonneg.2 ENNReal.toReal_nonneg))
_ ≤ snorm ({x | C ≤ ‖f (ℐ C) x‖₊}.indicator (f (ℐ C))) p μ :=
by
refine'
snorm_indicator_ge_of_bdd_below hp hp' _ (measurableSet_le measurable_const (hf _).nnnorm.measurable)
(eventually_of_forall fun x hx => _)
rwa [nnnorm_indicator_eq_indicator_nnnorm, Set.indicator_of_mem hx]
_ ≤ snorm (f (ℐ C)) p μ := snorm_indicator_le _
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
C : ℝ≥0
⊢ C • ↑δ ^ (1 / ENNReal.toReal p) ≤ C • ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
rw [ENNReal.smul_def, ENNReal.smul_def, smul_eq_mul, smul_eq_mul]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
C : ℝ≥0
⊢ ↑C * ↑δ ^ (1 / ENNReal.toReal p) ≤ ↑C * ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
simp_rw [ENNReal.ofReal_coe_nnreal] at hℐ
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hℐ : ∀ (C : ℝ≥0), ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
⊢ ↑C * ↑δ ^ (1 / ENNReal.toReal p) ≤ ↑C * ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / ENNReal.toReal p)
[PROOFSTEP]
refine' mul_le_mul' le_rfl (ENNReal.rpow_le_rpow (hℐ C).le (one_div_nonneg.2 ENNReal.toReal_nonneg))
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
C : ℝ≥0
⊢ C • ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊} ^ (1 / ENNReal.toReal p) ≤ snorm (indicator {x | C ≤ ‖f (ℐ C) x‖₊} (f (ℐ C))) p μ
[PROOFSTEP]
refine'
snorm_indicator_ge_of_bdd_below hp hp' _ (measurableSet_le measurable_const (hf _).nnnorm.measurable)
(eventually_of_forall fun x hx => _)
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
C : ℝ≥0
x : α
hx : x ∈ {x | C ≤ ‖f (ℐ C) x‖₊}
⊢ C ≤ ‖indicator {x | C ≤ ‖f (ℐ C) x‖₊} (f (ℐ C)) x‖₊
[PROOFSTEP]
rwa [nnnorm_indicator_eq_indicator_nnnorm, Set.indicator_of_mem hx]
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
this : ∀ (C : ℝ≥0), C • ↑δ ^ (1 / ENNReal.toReal p) ≤ snorm (f (ℐ C)) p μ
⊢ False
[PROOFSTEP]
specialize this (2 * max M 1 * HPow.hPow δ⁻¹ (1 / p.toReal))
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
this :
(2 * max M 1 * δ⁻¹ ^ (1 / ENNReal.toReal p)) • ↑δ ^ (1 / ENNReal.toReal p) ≤
snorm (f (ℐ (2 * max M 1 * δ⁻¹ ^ (1 / ENNReal.toReal p)))) p μ
⊢ False
[PROOFSTEP]
rw [ENNReal.coe_rpow_of_nonneg _ (one_div_nonneg.2 ENNReal.toReal_nonneg), ← ENNReal.coe_smul, smul_eq_mul, mul_assoc,
NNReal.inv_rpow, inv_mul_cancel (NNReal.rpow_pos (NNReal.coe_pos.1 hδpos)).ne.symm, mul_one, ENNReal.coe_mul, ←
NNReal.inv_rpow] at this
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
this : ↑2 * ↑(max M 1) ≤ snorm (f (ℐ (2 * max M 1 * δ⁻¹ ^ (1 / ENNReal.toReal p)))) p μ
⊢ False
[PROOFSTEP]
refine'
(lt_of_le_of_lt (le_trans (hM <| ℐ <| 2 * max M 1 * HPow.hPow δ⁻¹ (1 / p.toReal)) (le_max_left (M : ℝ≥0∞) 1))
(lt_of_lt_of_le _ this)).ne
rfl
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
this : ↑2 * ↑(max M 1) ≤ snorm (f (ℐ (2 * max M 1 * δ⁻¹ ^ (1 / ENNReal.toReal p)))) p μ
⊢ max (↑M) 1 < ↑2 * ↑(max M 1)
[PROOFSTEP]
rw [← ENNReal.coe_one, ← ENNReal.coe_max, ← ENNReal.coe_mul, ENNReal.coe_lt_coe]
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
ℐ : ℝ≥0 → ι
δ : ℝ≥0
hδpos : 0 < ↑δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal ↑δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
hℐ : ∀ (C : ℝ≥0), ENNReal.ofReal ↑δ < ↑↑μ {x | C ≤ ‖f (ℐ C) x‖₊}
this : ↑2 * ↑(max M 1) ≤ snorm (f (ℐ (2 * max M 1 * δ⁻¹ ^ (1 / ENNReal.toReal p)))) p μ
⊢ max M 1 < 2 * max M 1
[PROOFSTEP]
exact lt_two_mul_self (lt_max_of_lt_right one_pos)
[GOAL]
case intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hf : ∀ (i : ι), StronglyMeasurable (f i)
ε : ℝ
hε : 0 < ε
hfu : UnifIntegrable f p μ
M : ℝ≥0
hM : ∀ (i : ι), snorm (f i) p μ ≤ ↑M
δ : ℝ
hδpos : 0 < δ
hδ :
∀ (i : ι) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
C : ℝ≥0
hC : ∀ (i : ι), ↑↑μ {x | C ≤ ‖f i x‖₊} ≤ ENNReal.ofReal δ
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
exact ⟨C, fun i => hδ i _ (measurableSet_le measurable_const (hf i).nnnorm.measurable) (hC i)⟩
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
set g : ι → α → β := fun i => (hfu.1 i).choose
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hgmeas : ∀ i, StronglyMeasurable (g i) := fun i => (Exists.choose_spec <| hfu.1 i).1
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have hgunif : UniformIntegrable g p μ := hfu.ae_eq fun i => (Exists.choose_spec <| hfu.1 i).2
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨C, hC⟩ := hgunif.spec' hp hp' hgmeas hε
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ C, ∀ (i : ι), snorm (indicator {x | C ≤ ‖f i x‖₊} (f i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨C, fun i => le_trans (le_of_eq <| snorm_congr_ae _) (hC i)⟩
[GOAL]
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
⊢ indicator {x | C ≤ ‖f i x‖₊} (f i) =ᵐ[μ] indicator {x | C ≤ ‖g i x‖₊} (g i)
[PROOFSTEP]
filter_upwards [(Exists.choose_spec <| hfu.1 i).2] with x hx
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
⊢ indicator {x | C ≤ ‖f i x‖₊} (f i) x =
indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x
[PROOFSTEP]
by_cases hfx : x ∈ {x | C ≤ ‖f i x‖₊}
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : x ∈ {x | C ≤ ‖f i x‖₊}
⊢ indicator {x | C ≤ ‖f i x‖₊} (f i) x =
indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x
[PROOFSTEP]
rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx]
[GOAL]
case pos.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : x ∈ {x | C ≤ ‖f i x‖₊}
⊢ x ∈ {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
[PROOFSTEP]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : ¬x ∈ {x | C ≤ ‖f i x‖₊}
⊢ indicator {x | C ≤ ‖f i x‖₊} (f i) x =
indicator {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
(Exists.choose (_ : AEStronglyMeasurable (f i) μ)) x
[PROOFSTEP]
rw [Set.indicator_of_not_mem hfx, Set.indicator_of_not_mem]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f : ι → α → β
hp : p ≠ 0
hp' : p ≠ ⊤
hfu : UniformIntegrable f p μ
ε : ℝ
hε : 0 < ε
g : ι → α → β := fun i => Exists.choose (_ : AEStronglyMeasurable (f i) μ)
hgmeas : ∀ (i : ι), StronglyMeasurable (g i)
hgunif : UniformIntegrable g p μ
C : ℝ≥0
hC : ∀ (i : ι), snorm (indicator {x | C ≤ ‖g i x‖₊} (g i)) p μ ≤ ENNReal.ofReal ε
i : ι
x : α
hx : f i x = Exists.choose (_ : AEStronglyMeasurable (f i) μ) x
hfx : ¬x ∈ {x | C ≤ ‖f i x‖₊}
⊢ ¬x ∈ {x | C ≤ ‖Exists.choose (_ : AEStronglyMeasurable (f i) μ) x‖₊}
[PROOFSTEP]
rwa [Set.mem_setOf, hx] at hfx
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf : UniformIntegrable f p μ
⊢ UniformIntegrable (fun n => (∑ i in Finset.range n, f i) / ↑n) p μ
[PROOFSTEP]
obtain ⟨hf₁, hf₂, hf₃⟩ := hf
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
⊢ UniformIntegrable (fun n => (∑ i in Finset.range n, f i) / ↑n) p μ
[PROOFSTEP]
refine' ⟨fun n => _, fun ε hε => _, _⟩
[GOAL]
case intro.intro.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
⊢ AEStronglyMeasurable ((fun n => (∑ i in Finset.range n, f i) / ↑n) n) μ
[PROOFSTEP]
simp_rw [div_eq_mul_inv]
[GOAL]
case intro.intro.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
⊢ AEStronglyMeasurable ((∑ i in Finset.range n, f i) * (↑n)⁻¹) μ
[PROOFSTEP]
exact
(Finset.aestronglyMeasurable_sum' _ fun i _ => hf₁ i).mul
(aestronglyMeasurable_const : AEStronglyMeasurable (fun _ => (↑n : ℝ)⁻¹) μ)
[GOAL]
case intro.intro.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ →
snorm (indicator s ((fun n => (∑ i in Finset.range n, f i) / ↑n) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
obtain ⟨δ, hδ₁, hδ₂⟩ := hf₂ hε
[GOAL]
case intro.intro.refine'_2.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
⊢ ∃ δ x,
∀ (i : ℕ) (s : Set α),
MeasurableSet s →
↑↑μ s ≤ ENNReal.ofReal δ →
snorm (indicator s ((fun n => (∑ i in Finset.range n, f i) / ↑n) i)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' ⟨δ, hδ₁, fun n s hs hle => _⟩
[GOAL]
case intro.intro.refine'_2.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (indicator s ((fun n => (∑ i in Finset.range n, f i) / ↑n) n)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp_rw [div_eq_mul_inv, Finset.sum_mul, Set.indicator_finset_sum]
[GOAL]
case intro.intro.refine'_2.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ snorm (∑ i in Finset.range n, indicator s (f i * (↑n)⁻¹)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' le_trans (snorm_sum_le (fun i _ => ((hf₁ i).mul_const (↑n)⁻¹).indicator hs) hp) _
[GOAL]
case intro.intro.refine'_2.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ ∑ i in Finset.range n, snorm (indicator s (f i * (↑n)⁻¹)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
have : ∀ i, s.indicator (f i * (n : α → ℝ)⁻¹) = (↑n : ℝ)⁻¹ • s.indicator (f i) :=
by
intro i
rw [mul_comm, (_ : (↑n)⁻¹ * f i = fun ω => (↑n : ℝ)⁻¹ • f i ω)]
· rw [Set.indicator_const_smul s (↑n : ℝ)⁻¹ (f i)]
rfl
· rfl
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
⊢ ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
[PROOFSTEP]
intro i
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
i : ℕ
⊢ indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
[PROOFSTEP]
rw [mul_comm, (_ : (↑n)⁻¹ * f i = fun ω => (↑n : ℝ)⁻¹ • f i ω)]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
i : ℕ
⊢ (indicator s fun ω => (↑n)⁻¹ • f i ω) = (↑n)⁻¹ • indicator s (f i)
[PROOFSTEP]
rw [Set.indicator_const_smul s (↑n : ℝ)⁻¹ (f i)]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
i : ℕ
⊢ (fun x => (↑n)⁻¹ • indicator s (f i) x) = (↑n)⁻¹ • indicator s (f i)
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
i : ℕ
⊢ (↑n)⁻¹ * f i = fun ω => (↑n)⁻¹ • f i ω
[PROOFSTEP]
rfl
[GOAL]
case intro.intro.refine'_2.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
⊢ ∑ i in Finset.range n, snorm (indicator s (f i * (↑n)⁻¹)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp_rw [this, snorm_const_smul, ← Finset.mul_sum, nnnorm_inv, Real.nnnorm_coe_nat]
[GOAL]
case intro.intro.refine'_2.intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (indicator s (f x)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
by_cases hn : (↑(↑n : ℝ≥0)⁻¹ : ℝ≥0∞) = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (indicator s (f x)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp only [hn, zero_mul, zero_le]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (indicator s (f x)) p μ ≤ ENNReal.ofReal ε
[PROOFSTEP]
refine' le_trans _ (_ : ↑(↑n : ℝ≥0)⁻¹ * n • ENNReal.ofReal ε ≤ ENNReal.ofReal ε)
[GOAL]
case neg.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (indicator s (f x)) p μ ≤ ↑(↑n)⁻¹ * n • ENNReal.ofReal ε
[PROOFSTEP]
refine' (ENNReal.mul_le_mul_left hn ENNReal.coe_ne_top).2 _
[GOAL]
case neg.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
⊢ ∑ x in Finset.range n, snorm (indicator s (f x)) p μ ≤ n • ENNReal.ofReal ε
[PROOFSTEP]
conv_rhs => rw [← Finset.card_range n]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
| n • ENNReal.ofReal ε
[PROOFSTEP]
rw [← Finset.card_range n]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
| n • ENNReal.ofReal ε
[PROOFSTEP]
rw [← Finset.card_range n]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
| n • ENNReal.ofReal ε
[PROOFSTEP]
rw [← Finset.card_range n]
[GOAL]
case neg.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
⊢ ∑ x in Finset.range n, snorm (indicator s (f x)) p μ ≤ Finset.card (Finset.range n) • ENNReal.ofReal ε
[PROOFSTEP]
exact Finset.sum_le_card_nsmul _ _ _ fun i _ => hδ₂ _ _ hs hle
[GOAL]
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * n • ENNReal.ofReal ε ≤ ENNReal.ofReal ε
[PROOFSTEP]
simp only [ENNReal.coe_eq_zero, inv_eq_zero, Nat.cast_eq_zero] at hn
[GOAL]
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬n = 0
⊢ ↑(↑n)⁻¹ * n • ENNReal.ofReal ε ≤ ENNReal.ofReal ε
[PROOFSTEP]
rw [nsmul_eq_mul, ← mul_assoc, ENNReal.coe_inv, ENNReal.coe_nat, ENNReal.inv_mul_cancel _ (ENNReal.nat_ne_top _),
one_mul]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬n = 0
⊢ ↑n ≠ 0
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬n = 0
⊢ ↑n ≠ 0
[PROOFSTEP]
all_goals simpa only [Ne.def, Nat.cast_eq_zero]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬n = 0
⊢ ↑n ≠ 0
[PROOFSTEP]
simpa only [Ne.def, Nat.cast_eq_zero]
[GOAL]
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
ε : ℝ
hε : 0 < ε
δ : ℝ
hδ₁ : 0 < δ
hδ₂ :
∀ (i : ℕ) (s : Set α), MeasurableSet s → ↑↑μ s ≤ ENNReal.ofReal δ → snorm (indicator s (f i)) p μ ≤ ENNReal.ofReal ε
n : ℕ
s : Set α
hs : MeasurableSet s
hle : ↑↑μ s ≤ ENNReal.ofReal δ
this : ∀ (i : ℕ), indicator s (f i * (↑n)⁻¹) = (↑n)⁻¹ • indicator s (f i)
hn : ¬n = 0
⊢ ↑n ≠ 0
[PROOFSTEP]
simpa only [Ne.def, Nat.cast_eq_zero]
[GOAL]
case intro.intro.refine'_3
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
hf₃ : ∃ C, ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
⊢ ∃ C, ∀ (i : ℕ), snorm ((fun n => (∑ i in Finset.range n, f i) / ↑n) i) p μ ≤ ↑C
[PROOFSTEP]
obtain ⟨C, hC⟩ := hf₃
[GOAL]
case intro.intro.refine'_3.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
⊢ ∃ C, ∀ (i : ℕ), snorm ((fun n => (∑ i in Finset.range n, f i) / ↑n) i) p μ ≤ ↑C
[PROOFSTEP]
simp_rw [div_eq_mul_inv, Finset.sum_mul]
[GOAL]
case intro.intro.refine'_3.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
⊢ ∃ C, ∀ (i : ℕ), snorm (∑ x in Finset.range i, f x * (↑i)⁻¹) p μ ≤ ↑C
[PROOFSTEP]
refine' ⟨C, fun n => (snorm_sum_le (fun i _ => (hf₁ i).mul_const (↑n)⁻¹) hp).trans _⟩
[GOAL]
case intro.intro.refine'_3.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
⊢ ∑ i in Finset.range n, snorm (fun x => f i x * (↑n)⁻¹) p μ ≤ ↑C
[PROOFSTEP]
have : ∀ i, (fun ω => f i ω * (↑n)⁻¹) = (↑n : ℝ)⁻¹ • fun ω => f i ω :=
by
intro i
ext ω
simp only [mul_comm, Pi.smul_apply, Algebra.id.smul_eq_mul]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
⊢ ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
[PROOFSTEP]
intro i
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n i : ℕ
⊢ (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
[PROOFSTEP]
ext ω
[GOAL]
case h
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n i : ℕ
ω : α
⊢ f i ω * (↑n)⁻¹ = ((↑n)⁻¹ • fun ω => f i ω) ω
[PROOFSTEP]
simp only [mul_comm, Pi.smul_apply, Algebra.id.smul_eq_mul]
[GOAL]
case intro.intro.refine'_3.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
⊢ ∑ i in Finset.range n, snorm (fun x => f i x * (↑n)⁻¹) p μ ≤ ↑C
[PROOFSTEP]
simp_rw [this, snorm_const_smul, ← Finset.mul_sum, nnnorm_inv, Real.nnnorm_coe_nat]
[GOAL]
case intro.intro.refine'_3.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (fun ω => f x ω) p μ ≤ ↑C
[PROOFSTEP]
by_cases hn : (↑(↑n : ℝ≥0)⁻¹ : ℝ≥0∞) = 0
[GOAL]
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (fun ω => f x ω) p μ ≤ ↑C
[PROOFSTEP]
simp only [hn, zero_mul, zero_le]
[GOAL]
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (fun ω => f x ω) p μ ≤ ↑C
[PROOFSTEP]
refine' le_trans _ (_ : ↑(↑n : ℝ≥0)⁻¹ * (n • C : ℝ≥0∞) ≤ C)
[GOAL]
case neg.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ∑ x in Finset.range n, snorm (fun ω => f x ω) p μ ≤ ↑(↑n)⁻¹ * ↑(n • C)
[PROOFSTEP]
refine' (ENNReal.mul_le_mul_left hn ENNReal.coe_ne_top).2 _
[GOAL]
case neg.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
⊢ ∑ x in Finset.range n, snorm (fun ω => f x ω) p μ ≤ ↑(n • C)
[PROOFSTEP]
conv_rhs =>
rw [← Finset.card_range n]
-- Porting note: Originally `exact Finset.sum_le_card_nsmul _ _ _ fun i hi => hC i`
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
| ↑(n • C)
[PROOFSTEP]
rw [← Finset.card_range n]
-- Porting note: Originally `exact Finset.sum_le_card_nsmul _ _ _ fun i hi => hC i`
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
| ↑(n • C)
[PROOFSTEP]
rw [← Finset.card_range n]
-- Porting note: Originally `exact Finset.sum_le_card_nsmul _ _ _ fun i hi => hC i`
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
| ↑(n • C)
[PROOFSTEP]
rw [← Finset.card_range n]
-- Porting note: Originally `exact Finset.sum_le_card_nsmul _ _ _ fun i hi => hC i`
[GOAL]
case neg.refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
⊢ ∑ x in Finset.range n, snorm (fun ω => f x ω) p μ ≤ ↑(Finset.card (Finset.range n) • C)
[PROOFSTEP]
convert Finset.sum_le_card_nsmul _ _ _ fun i _ => hC i
[GOAL]
case h.e'_4
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(Finset.card (Finset.range n) • C) = Finset.card (Finset.range n) • ↑C
[PROOFSTEP]
rw [ENNReal.coe_smul]
[GOAL]
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬↑(↑n)⁻¹ = 0
⊢ ↑(↑n)⁻¹ * ↑(n • C) ≤ ↑C
[PROOFSTEP]
simp only [ENNReal.coe_eq_zero, inv_eq_zero, Nat.cast_eq_zero] at hn
[GOAL]
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬n = 0
⊢ ↑(↑n)⁻¹ * ↑(n • C) ≤ ↑C
[PROOFSTEP]
rw [ENNReal.coe_smul, nsmul_eq_mul, ← mul_assoc, ENNReal.coe_inv, ENNReal.coe_nat,
ENNReal.inv_mul_cancel _ (ENNReal.nat_ne_top _), one_mul]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬n = 0
⊢ ↑n ≠ 0
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬n = 0
⊢ ↑n ≠ 0
[PROOFSTEP]
all_goals simpa only [Ne.def, Nat.cast_eq_zero]
[GOAL]
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬n = 0
⊢ ↑n ≠ 0
[PROOFSTEP]
simpa only [Ne.def, Nat.cast_eq_zero]
[GOAL]
case neg.refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
μ : Measure α
inst✝ : NormedAddCommGroup β
p : ℝ≥0∞
f✝ : ι → α → β
hp : 1 ≤ p
f : ℕ → α → ℝ
hf₁ : ∀ (i : ℕ), AEStronglyMeasurable (f i) μ
hf₂ : UnifIntegrable f p μ
C : ℝ≥0
hC : ∀ (i : ℕ), snorm (f i) p μ ≤ ↑C
n : ℕ
this : ∀ (i : ℕ), (fun ω => f i ω * (↑n)⁻¹) = (↑n)⁻¹ • fun ω => f i ω
hn : ¬n = 0
⊢ ↑n ≠ 0
[PROOFSTEP]
simpa only [Ne.def, Nat.cast_eq_zero]
|
State Before: α : Type u_1
β : Type ?u.1531711
ι : Type ?u.1531714
E : Type u_2
F : Type ?u.1531720
𝕜 : Type ?u.1531723
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedAddCommGroup F
p : ℝ≥0∞
μ : Measure α
f : { x // x ∈ simpleFunc E p μ }
⊢ ↑(toSimpleFunc f) =ᵐ[μ] ↑↑↑f State After: case h.e'_5.h.e'_6
α : Type u_1
β : Type ?u.1531711
ι : Type ?u.1531714
E : Type u_2
F : Type ?u.1531720
𝕜 : Type ?u.1531723
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedAddCommGroup F
p : ℝ≥0∞
μ : Measure α
f : { x // x ∈ simpleFunc E p μ }
⊢ ↑↑f = AEEqFun.mk ↑(toSimpleFunc f) (_ : AEStronglyMeasurable (↑(toSimpleFunc f)) μ) Tactic: convert (AEEqFun.coeFn_mk (toSimpleFunc f)
(toSimpleFunc f).aestronglyMeasurable).symm using 2 State Before: case h.e'_5.h.e'_6
α : Type u_1
β : Type ?u.1531711
ι : Type ?u.1531714
E : Type u_2
F : Type ?u.1531720
𝕜 : Type ?u.1531723
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedAddCommGroup F
p : ℝ≥0∞
μ : Measure α
f : { x // x ∈ simpleFunc E p μ }
⊢ ↑↑f = AEEqFun.mk ↑(toSimpleFunc f) (_ : AEStronglyMeasurable (↑(toSimpleFunc f)) μ) State After: no goals Tactic: exact (Classical.choose_spec f.2).symm
|
Formal statement is: lemma contour_integral_part_circlepath_reverse: "contour_integral (part_circlepath c r a b) f = -contour_integral (part_circlepath c r b a) f" Informal statement is: The contour integral of a function $f$ along a part of a circle is equal to the negative of the contour integral of $f$ along the same part of the circle in the opposite direction.
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import topology.continuous_function.bounded
import topology.uniform_space.compact_separated
/-!
# Continuous functions on a compact space
Continuous functions `C(α, β)` from a compact space `α` to a metric space `β`
are automatically bounded, and so acquire various structures inherited from `α →ᵇ β`.
This file transfers these structures, and restates some lemmas
characterising these structures.
If you need a lemma which is proved about `α →ᵇ β` but not for `C(α, β)` when `α` is compact,
you should restate it here. You can also use
`bounded_continuous_function.equiv_continuous_map_of_compact` to move functions back and forth.
-/
noncomputable theory
open_locale topological_space classical nnreal bounded_continuous_function
open set filter metric
open bounded_continuous_function
namespace continuous_map
variables {α β E : Type*} [topological_space α] [compact_space α] [metric_space β] [normed_group E]
section
variables (α β)
/--
When `α` is compact, the bounded continuous maps `α →ᵇ β` are
equivalent to `C(α, β)`.
-/
@[simps { fully_applied := ff }]
def equiv_bounded_of_compact : C(α, β) ≃ (α →ᵇ β) :=
⟨mk_of_compact, to_continuous_map, λ f, by { ext, refl, }, λ f, by { ext, refl, }⟩
lemma uniform_inducing_equiv_bounded_of_compact :
uniform_inducing (equiv_bounded_of_compact α β) :=
uniform_inducing.mk'
begin
simp only [has_basis_compact_convergence_uniformity.mem_iff, uniformity_basis_dist_le.mem_iff],
exact λ s, ⟨λ ⟨⟨a, b⟩, ⟨ha, ⟨ε, hε, hb⟩⟩, hs⟩, ⟨{p | ∀ x, (p.1 x, p.2 x) ∈ b},
⟨ε, hε, λ _ h x, hb (by exact (dist_le hε.le).mp h x)⟩, λ f g h, hs (by exact λ x hx, h x)⟩,
λ ⟨t, ⟨ε, hε, ht⟩, hs⟩, ⟨⟨set.univ, {p | dist p.1 p.2 ≤ ε}⟩, ⟨compact_univ, ⟨ε, hε, λ _ h, h⟩⟩,
λ ⟨f, g⟩ h, hs _ _ (ht (by exact (dist_le hε.le).mpr (λ x, h x (mem_univ x))))⟩⟩,
end
lemma uniform_embedding_equiv_bounded_of_compact :
uniform_embedding (equiv_bounded_of_compact α β) :=
{ inj := (equiv_bounded_of_compact α β).injective,
.. uniform_inducing_equiv_bounded_of_compact α β }
/--
When `α` is compact, the bounded continuous maps `α →ᵇ 𝕜` are
additively equivalent to `C(α, 𝕜)`.
-/
@[simps apply symm_apply { fully_applied := ff }]
def add_equiv_bounded_of_compact [add_monoid β] [has_lipschitz_add β] :
C(α, β) ≃+ (α →ᵇ β) :=
({ .. to_continuous_map_add_hom α β,
.. (equiv_bounded_of_compact α β).symm, } : (α →ᵇ β) ≃+ C(α, β)).symm
instance : metric_space C(α, β) :=
(uniform_embedding_equiv_bounded_of_compact α β).comap_metric_space _
/--
When `α` is compact, and `β` is a metric space, the bounded continuous maps `α →ᵇ β` are
isometric to `C(α, β)`.
-/
@[simps to_equiv apply symm_apply { fully_applied := ff }]
def isometric_bounded_of_compact :
C(α, β) ≃ᵢ (α →ᵇ β) :=
{ isometry_to_fun := λ x y, rfl,
to_equiv := equiv_bounded_of_compact α β }
end
@[simp] lemma _root_.bounded_continuous_function.dist_mk_of_compact (f g : C(α, β)) :
dist (mk_of_compact f) (mk_of_compact g) = dist f g := rfl
@[simp] lemma _root_.bounded_continuous_function.dist_to_continuous_map (f g : α →ᵇ β) :
dist (f.to_continuous_map) (g.to_continuous_map) = dist f g := rfl
open bounded_continuous_function
section
variables {α β} {f g : C(α, β)} {C : ℝ}
/-- The pointwise distance is controlled by the distance between functions, by definition. -/
lemma dist_apply_le_dist (x : α) : dist (f x) (g x) ≤ dist f g :=
by simp only [← dist_mk_of_compact, dist_coe_le_dist, ← mk_of_compact_apply]
/-- The distance between two functions is controlled by the supremum of the pointwise distances -/
lemma dist_le (C0 : (0 : ℝ) ≤ C) : dist f g ≤ C ↔ ∀x:α, dist (f x) (g x) ≤ C :=
by simp only [← dist_mk_of_compact, dist_le C0, mk_of_compact_apply]
lemma dist_le_iff_of_nonempty [nonempty α] :
dist f g ≤ C ↔ ∀ x, dist (f x) (g x) ≤ C :=
by simp only [← dist_mk_of_compact, dist_le_iff_of_nonempty, mk_of_compact_apply]
lemma dist_lt_iff_of_nonempty [nonempty α] :
dist f g < C ↔ ∀x:α, dist (f x) (g x) < C :=
by simp only [← dist_mk_of_compact, dist_lt_iff_of_nonempty_compact, mk_of_compact_apply]
lemma dist_lt_of_nonempty [nonempty α] (w : ∀x:α, dist (f x) (g x) < C) : dist f g < C :=
(dist_lt_iff_of_nonempty).2 w
lemma dist_lt_iff (C0 : (0 : ℝ) < C) :
dist f g < C ↔ ∀x:α, dist (f x) (g x) < C :=
by simp only [← dist_mk_of_compact, dist_lt_iff_of_compact C0, mk_of_compact_apply]
end
instance [complete_space β] : complete_space (C(α, β)) :=
(isometric_bounded_of_compact α β).complete_space
@[continuity] lemma continuous_eval : continuous (λ p : C(α, β) × α, p.1 p.2) :=
continuous_eval.comp ((isometric_bounded_of_compact α β).continuous.prod_map continuous_id)
@[continuity] lemma continuous_evalx (x : α) : continuous (λ f : C(α, β), f x) :=
continuous_eval.comp (continuous_id.prod_mk continuous_const)
lemma continuous_coe : @continuous (C(α, β)) (α → β) _ _ coe_fn :=
continuous_pi continuous_evalx
-- TODO at some point we will need lemmas characterising this norm!
-- At the moment the only way to reason about it is to transfer `f : C(α,E)` back to `α →ᵇ E`.
instance : has_norm C(α, E) :=
{ norm := λ x, dist x 0 }
@[simp] lemma _root_.bounded_continuous_function.norm_mk_of_compact (f : C(α, E)) :
∥mk_of_compact f∥ = ∥f∥ := rfl
@[simp] lemma _root_.bounded_continuous_function.norm_to_continuous_map_eq (f : α →ᵇ E) :
∥f.to_continuous_map∥ = ∥f∥ :=
rfl
open bounded_continuous_function
instance : normed_group C(α, E) :=
{ dist_eq := λ x y,
begin
rw [← norm_mk_of_compact, ← dist_mk_of_compact, dist_eq_norm],
congr' 1,
exact ((add_equiv_bounded_of_compact α E).map_sub _ _).symm
end, }
section
variables (f : C(α, E))
-- The corresponding lemmas for `bounded_continuous_function` are stated with `{f}`,
-- and so can not be used in dot notation.
lemma norm_coe_le_norm (x : α) : ∥f x∥ ≤ ∥f∥ :=
(mk_of_compact f).norm_coe_le_norm x
/-- Distance between the images of any two points is at most twice the norm of the function. -/
lemma dist_le_two_norm (x y : α) : dist (f x) (f y) ≤ 2 * ∥f∥ :=
(mk_of_compact f).dist_le_two_norm x y
/-- The norm of a function is controlled by the supremum of the pointwise norms -/
lemma norm_le {C : ℝ} (C0 : (0 : ℝ) ≤ C) : ∥f∥ ≤ C ↔ ∀x:α, ∥f x∥ ≤ C :=
@bounded_continuous_function.norm_le _ _ _ _
(mk_of_compact f) _ C0
lemma norm_le_of_nonempty [nonempty α] {M : ℝ} : ∥f∥ ≤ M ↔ ∀ x, ∥f x∥ ≤ M :=
@bounded_continuous_function.norm_le_of_nonempty _ _ _ _ _ (mk_of_compact f) _
lemma norm_lt_iff {M : ℝ} (M0 : 0 < M) : ∥f∥ < M ↔ ∀ x, ∥f x∥ < M :=
@bounded_continuous_function.norm_lt_iff_of_compact _ _ _ _ _ (mk_of_compact f) _ M0
lemma norm_lt_iff_of_nonempty [nonempty α] {M : ℝ} :
∥f∥ < M ↔ ∀ x, ∥f x∥ < M :=
@bounded_continuous_function.norm_lt_iff_of_nonempty_compact _ _ _ _ _ _ (mk_of_compact f) _
lemma apply_le_norm (f : C(α, ℝ)) (x : α) : f x ≤ ∥f∥ :=
le_trans (le_abs.mpr (or.inl (le_refl (f x)))) (f.norm_coe_le_norm x)
lemma neg_norm_le_apply (f : C(α, ℝ)) (x : α) : -∥f∥ ≤ f x :=
le_trans (neg_le_neg (f.norm_coe_le_norm x)) (neg_le.mp (neg_le_abs_self (f x)))
lemma norm_eq_supr_norm : ∥f∥ = ⨆ x : α, ∥f x∥ :=
(mk_of_compact f).norm_eq_supr_norm
end
section
variables {R : Type*} [normed_ring R]
instance : normed_ring C(α,R) :=
{ norm_mul := λ f g, norm_mul_le (mk_of_compact f) (mk_of_compact g),
..(infer_instance : normed_group C(α,R)) }
end
section
variables {𝕜 : Type*} [normed_field 𝕜] [normed_space 𝕜 E]
instance : normed_space 𝕜 C(α,E) :=
{ norm_smul_le := λ c f, le_of_eq (norm_smul c (mk_of_compact f)) }
section
variables (α 𝕜 E)
/--
When `α` is compact and `𝕜` is a normed field,
the `𝕜`-algebra of bounded continuous maps `α →ᵇ β` is
`𝕜`-linearly isometric to `C(α, β)`.
-/
def linear_isometry_bounded_of_compact :
C(α, E) ≃ₗᵢ[𝕜] (α →ᵇ E) :=
{ map_smul' := λ c f, by { ext, simp, },
norm_map' := λ f, rfl,
.. add_equiv_bounded_of_compact α E }
end
-- this lemma and the next are the analogues of those autogenerated by `@[simps]` for
-- `equiv_bounded_of_compact`, `add_equiv_bounded_of_compact`
@[simp] lemma linear_isometry_bounded_of_compact_symm_apply (f : α →ᵇ E) :
(linear_isometry_bounded_of_compact α E 𝕜).symm f = f.to_continuous_map :=
rfl
@[simp] lemma linear_isometry_bounded_of_compact_apply_apply (f : C(α, E)) (a : α) :
(linear_isometry_bounded_of_compact α E 𝕜 f) a = f a :=
rfl
@[simp]
lemma linear_isometry_bounded_of_compact_to_isometric :
(linear_isometry_bounded_of_compact α E 𝕜).to_isometric = (isometric_bounded_of_compact α E) :=
rfl
@[simp]
lemma linear_isometry_bounded_of_compact_to_add_equiv :
(linear_isometry_bounded_of_compact α E 𝕜).to_linear_equiv.to_add_equiv =
(add_equiv_bounded_of_compact α E) :=
rfl
@[simp]
lemma linear_isometry_bounded_of_compact_of_compact_to_equiv :
(linear_isometry_bounded_of_compact α E 𝕜).to_linear_equiv.to_equiv =
(equiv_bounded_of_compact α E) :=
rfl
end
section
variables {𝕜 : Type*} {γ : Type*} [normed_field 𝕜] [normed_ring γ] [normed_algebra 𝕜 γ]
instance [nonempty α] : normed_algebra 𝕜 C(α, γ) :=
{ norm_algebra_map_eq := λ c, (norm_algebra_map_eq (α →ᵇ γ) c : _), }
end
end continuous_map
namespace continuous_map
section uniform_continuity
variables {α β : Type*}
variables [metric_space α] [compact_space α] [metric_space β]
/-!
We now set up some declarations making it convenient to use uniform continuity.
-/
lemma uniform_continuity
(f : C(α, β)) (ε : ℝ) (h : 0 < ε) :
∃ δ > 0, ∀ {x y}, dist x y < δ → dist (f x) (f y) < ε :=
metric.uniform_continuous_iff.mp
(compact_space.uniform_continuous_of_continuous f.continuous) ε h
/--
An arbitrarily chosen modulus of uniform continuity for a given function `f` and `ε > 0`.
-/
-- This definition allows us to separate the choice of some `δ`,
-- and the corresponding use of `dist a b < δ → dist (f a) (f b) < ε`,
-- even across different declarations.
def modulus (f : C(α, β)) (ε : ℝ) (h : 0 < ε) : ℝ :=
classical.some (uniform_continuity f ε h)
lemma modulus_pos (f : C(α, β)) {ε : ℝ} {h : 0 < ε} : 0 < f.modulus ε h :=
(classical.some_spec (uniform_continuity f ε h)).fst
lemma dist_lt_of_dist_lt_modulus
(f : C(α, β)) (ε : ℝ) (h : 0 < ε) {a b : α} (w : dist a b < f.modulus ε h) :
dist (f a) (f b) < ε :=
(classical.some_spec (uniform_continuity f ε h)).snd w
end uniform_continuity
end continuous_map
section comp_left
variables (X : Type*) {𝕜 β γ : Type*} [topological_space X] [compact_space X]
[nondiscrete_normed_field 𝕜]
variables [normed_group β] [normed_space 𝕜 β] [normed_group γ] [normed_space 𝕜 γ]
open continuous_map
/--
Postcomposition of continuous functions into a normed module by a continuous linear map is a
continuous linear map.
Transferred version of `continuous_linear_map.comp_left_continuous_bounded`,
upgraded version of `continuous_linear_map.comp_left_continuous`,
similar to `linear_map.comp_left`. -/
protected def continuous_linear_map.comp_left_continuous_compact (g : β →L[𝕜] γ) :
C(X, β) →L[𝕜] C(X, γ) :=
(linear_isometry_bounded_of_compact X γ 𝕜).symm.to_linear_isometry.to_continuous_linear_map.comp $
(g.comp_left_continuous_bounded X).comp $
(linear_isometry_bounded_of_compact X β 𝕜).to_linear_isometry.to_continuous_linear_map
@[simp] lemma continuous_linear_map.to_linear_comp_left_continuous_compact (g : β →L[𝕜] γ) :
(g.comp_left_continuous_compact X : C(X, β) →ₗ[𝕜] C(X, γ)) = g.comp_left_continuous 𝕜 X :=
by { ext f, refl }
@[simp] lemma continuous_linear_map.comp_left_continuous_compact_apply (g : β →L[𝕜] γ)
(f : C(X, β)) (x : X) :
g.comp_left_continuous_compact X f x = g (f x) :=
rfl
end comp_left
namespace continuous_map
/-!
We now setup variations on `comp_right_* f`, where `f : C(X, Y)`
(that is, precomposition by a continuous map),
as a morphism `C(Y, T) → C(X, T)`, respecting various types of structure.
In particular:
* `comp_right_continuous_map`, the bundled continuous map (for this we need `X Y` compact).
* `comp_right_homeomorph`, when we precompose by a homeomorphism.
* `comp_right_alg_hom`, when `T = R` is a topological ring.
-/
section comp_right
/--
Precomposition by a continuous map is itself a continuous map between spaces of continuous maps.
-/
def comp_right_continuous_map {X Y : Type*} (T : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y] [normed_group T]
(f : C(X, Y)) : C(C(Y, T), C(X, T)) :=
{ to_fun := λ g, g.comp f,
continuous_to_fun :=
begin
refine metric.continuous_iff.mpr _,
intros g ε ε_pos,
refine ⟨ε, ε_pos, λ g' h, _⟩,
rw continuous_map.dist_lt_iff ε_pos at h ⊢,
{ exact λ x, h (f x), },
end }
@[simp] lemma comp_right_continuous_map_apply {X Y : Type*} (T : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y] [normed_group T]
(f : C(X, Y)) (g : C(Y, T)) :
(comp_right_continuous_map T f) g = g.comp f :=
rfl
/--
Precomposition by a homeomorphism is itself a homeomorphism between spaces of continuous maps.
-/
def comp_right_homeomorph {X Y : Type*} (T : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y] [normed_group T]
(f : X ≃ₜ Y) : C(Y, T) ≃ₜ C(X, T) :=
{ to_fun := comp_right_continuous_map T f.to_continuous_map,
inv_fun := comp_right_continuous_map T f.symm.to_continuous_map,
left_inv := by tidy,
right_inv := by tidy, }
/--
Precomposition of functions into a normed ring by continuous map is an algebra homomorphism.
-/
def comp_right_alg_hom {X Y : Type*} (R : Type*)
[topological_space X] [topological_space Y] [normed_comm_ring R] (f : C(X, Y)) :
C(Y, R) →ₐ[R] C(X, R) :=
{ to_fun := λ g, g.comp f,
map_zero' := by { ext, simp, },
map_add' := λ g₁ g₂, by { ext, simp, },
map_one' := by { ext, simp, },
map_mul' := λ g₁ g₂, by { ext, simp, },
commutes' := λ r, by { ext, simp, }, }
@[simp] lemma comp_right_alg_hom_apply {X Y : Type*} (R : Type*)
[topological_space X] [topological_space Y] [normed_comm_ring R] (f : C(X, Y)) (g : C(Y, R)) :
(comp_right_alg_hom R f) g = g.comp f :=
rfl
lemma comp_right_alg_hom_continuous {X Y : Type*} (R : Type*)
[topological_space X] [compact_space X] [topological_space Y] [compact_space Y]
[normed_comm_ring R] (f : C(X, Y)) :
continuous (comp_right_alg_hom R f) :=
begin
change continuous (comp_right_continuous_map R f),
continuity,
end
end comp_right
end continuous_map
|
------------------------------------------------------------------------
-- Very stable booleans
------------------------------------------------------------------------
{-# OPTIONS --cubical --safe #-}
-- The module is parametrised by a notion of equality. The higher
-- constructor of the HIT defining the very stable booleans uses path
-- equality, but the supplied notion of equality is used for other
-- things.
import Equality.Path as P
module Bool.Very-stable
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq hiding (elim)
import Equality.Path.Univalence as PU
open import Prelude as Bool hiding (true; false)
open import Bijection equality-with-J using (_↔_)
import Bijection P.equality-with-J as PB
open import Equality.Decision-procedures equality-with-J
open import Equality.Path.Isomorphisms eq
open import Equality.Path.Isomorphisms.Univalence eq
open import Equivalence equality-with-J as Eq using (_≃_)
open import Erased.Cubical eq as Erased
import Erased.Cubical P.equality-with-paths as PE
open import Function-universe equality-with-J hiding (_∘_)
open import Injection equality-with-J using (Injective)
private
variable
a p : Level
A : Type a
P : A → Type p
b f r r-[] t : A
------------------------------------------------------------------------
-- Very stable booleans
-- Very stable booleans.
--
-- This type uses a construction due to Thierry Coquand and Fabian
-- Ruch. I think this construction is a variant of a construction due
-- to Rijke, Shulman and Spitters (see "Modalities in Homotopy Type
-- Theory").
data B̃ool : Type where
true false : B̃ool
stable : Erased B̃ool → B̃ool
stable-[]ᴾ : (b : B̃ool) → stable [ b ] P.≡ b
-- The constructor stable is a left inverse of [_].
stable-[] : (b : B̃ool) → stable [ b ] ≡ b
stable-[] = _↔_.from ≡↔≡ ∘ stable-[]ᴾ
-- B̃ool is very stable.
Very-stable-B̃ool : Very-stable B̃ool
Very-stable-B̃ool = Stable→Left-inverse→Very-stable stable stable-[]
------------------------------------------------------------------------
-- Eliminators
-- A dependent eliminator, expressed using paths.
elimᴾ :
(P : B̃ool → Type p) →
P true →
P false →
(r : ∀ b → Erased (P (erased b)) → P (stable b)) →
(∀ b (p : P b) →
P.[ (λ i → P (stable-[]ᴾ b i)) ] r [ b ] [ p ] ≡ p) →
∀ b → P b
elimᴾ P t f r r-[] = λ where
true → t
false → f
(stable b) → r b [ elimᴾ P t f r r-[] (erased b) ]
(stable-[]ᴾ b i) → r-[] b (elimᴾ P t f r r-[] b) i
-- A non-dependent eliminator, expressed using paths.
recᴾ :
A → A →
(r : Erased B̃ool → Erased A → A) →
(∀ b p → r [ b ] [ p ] P.≡ p) →
B̃ool → A
recᴾ = elimᴾ _
-- A dependent eliminator, expressed using equality.
elim :
(P : B̃ool → Type p) →
P true →
P false →
(r : ∀ b → Erased (P (erased b)) → P (stable b)) →
(∀ b (p : P b) → subst P (stable-[] b) (r [ b ] [ p ]) ≡ p) →
∀ b → P b
elim P t f r r-[] = elimᴾ P t f r (λ b p → subst≡→[]≡ (r-[] b p))
-- A "computation" rule.
elim-stable-[] :
dcong (elim P t f r r-[]) (stable-[] b) ≡
r-[] b (elim P t f r r-[] b)
elim-stable-[] = dcong-subst≡→[]≡ (refl _)
-- A non-dependent eliminator, expressed using equality.
rec :
A → A →
(r : Erased B̃ool → Erased A → A) →
(∀ b p → r [ b ] [ p ] ≡ p) →
B̃ool → A
rec t f r r-[] = recᴾ t f r (λ b p → _↔_.to ≡↔≡ (r-[] b p))
-- A "computation" rule.
rec-stable-[] :
cong (rec t f r r-[]) (stable-[] b) ≡
r-[] b (rec t f r r-[] b)
rec-stable-[] = cong-≡↔≡ (refl _)
-- A dependent eliminator that can be used when eliminating into very
-- stable type families.
elim-Very-stable :
(P : B̃ool → Type p) →
P true →
P false →
(∀ b → Very-stable (P b)) →
∀ b → P b
elim-Very-stable P t f s =
elim P t f
(λ b →
Erased (P (erased b)) ↝⟨ Erased.map (subst P (
erased b ≡⟨ sym $ stable-[] (erased b) ⟩∎
stable b ∎)) ⟩
Erased (P (stable b)) ↝⟨ Very-stable→Stable 0 (s (stable b)) ⟩□
P (stable b) □)
(λ b p →
Very-stable→Stable 1 (Very-stable→Very-stable-≡ 0 (s b)) _ _
[ subst P (stable-[] b)
(_≃_.from Eq.⟨ _ , s (stable [ b ]) ⟩
[ subst P (sym $ stable-[] b) p ]) ≡⟨ cong (subst P (stable-[] b)) $ sym $
_≃_.left-inverse-unique Eq.⟨ _ , s (stable [ b ]) ⟩ erased refl _ ⟩
subst P (stable-[] b)
(erased [ subst P (sym $ stable-[] b) p ]) ≡⟨⟩
subst P (stable-[] b) (subst P (sym $ stable-[] b) p) ≡⟨ subst-subst-sym _ _ _ ⟩∎
p ∎
])
-- A non-dependent eliminator that can be used when eliminating into
-- very stable type families.
rec-Very-stable : A → A → Very-stable A → B̃ool → A
rec-Very-stable t f s = elim-Very-stable _ t f (λ _ → s)
------------------------------------------------------------------------
-- Some properties
private
module Dummy where
-- A function mapping very stable booleans to types: true is mapped
-- to the unit type and false to the empty type.
private
T̃′ : B̃ool → Σ Type Very-stable
T̃′ = rec-Very-stable
(⊤ , Very-stable-⊤)
(⊥ , Very-stable-⊥)
(Very-stable-∃-Very-stable ext univ)
T̃ : B̃ool → Type
T̃ = proj₁ ∘ T̃′
-- Some computation rules that hold by definition.
_ : T̃ true ≡ ⊤
_ = refl _
_ : T̃ false ≡ ⊥
_ = refl _
-- The output of T̃ is very stable.
Very-stable-T̃ : ∀ b → Very-stable (T̃ b)
Very-stable-T̃ = proj₂ ∘ T̃′
-- The values true and false are not equal.
true≢false : true ≢ false
true≢false =
true ≡ false ↝⟨ cong T̃ ⟩
T̃ true ≡ T̃ false ↔⟨⟩
⊤ ≡ ⊥ ↝⟨ (λ eq → ≡⇒↝ _ eq _) ⟩□
⊥ □
module Alternative-T̃ where
-- A direct implementation of T̃.
private
T̃′ : B̃ool → Σ Type PE.Very-stable
T̃ : B̃ool → Type
T̃ b = proj₁ (T̃′ b)
Very-stable-T̃ : ∀ b → PE.Very-stable (T̃ b)
Very-stable-T̃ b = proj₂ (T̃′ b)
T̃′ true = ⊤ , PE.Very-stable-⊤
T̃′ false = ⊥ , PE.Very-stable-⊥
T̃′ (stable [ b ]) = PE.Erased (T̃ b) , PE.Very-stable-Erased
T̃′ (stable-[]ᴾ b i) = lemma₁ i , lemma₂ i
where
lemma₁ : PE.Erased (T̃ b) P.≡ T̃ b
lemma₁ = PU.≃⇒≡ (PE.Very-stable→Stable 0 (Very-stable-T̃ b))
lemma₂ :
P.[ (λ i → PE.Very-stable (lemma₁ i)) ]
PE.Very-stable-Erased ≡ Very-stable-T̃ b
lemma₂ =
P.heterogeneous-irrelevance₀
(PE.Very-stable-propositional P.ext)
-- Some computation rules that hold by definition.
_ : T̃ true ≡ ⊤
_ = refl _
_ : T̃ false ≡ ⊥
_ = refl _
_ : T̃ (stable [ b ]) ≡ PE.Erased (T̃ b)
_ = refl _
open Dummy public
-- A function from booleans to very stable booleans.
from-Bool : Bool → B̃ool
from-Bool = if_then true else false
-- The function from-Bool is injective.
--
-- This lemma was suggested by Mike Shulman.
from-Bool-injective : Injective from-Bool
from-Bool-injective {x = Bool.true} {y = Bool.true} = λ _ → refl _
from-Bool-injective {x = Bool.true} {y = Bool.false} = ⊥-elim ∘ true≢false
from-Bool-injective {x = Bool.false} {y = Bool.true} = ⊥-elim ∘ true≢false ∘ sym
from-Bool-injective {x = Bool.false} {y = Bool.false} = λ _ → refl _
-- B̃ool is equivalent to Erased Bool.
--
-- This lemma was suggested by Mike Shulman.
B̃ool≃Erased-Bool : B̃ool ≃ Erased Bool
B̃ool≃Erased-Bool = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = λ b →
Very-stable→Stable 0
(Very-stable→Very-stable-≡ 0 Very-stable-Erased _ _)
[ to (from b) ≡⟨⟩
to (stable [ from-Bool (erased b) ]) ≡⟨ cong to (stable-[] _) ⟩
to (from-Bool (erased b)) ≡⟨ lemma (erased b) ⟩
[ erased b ] ≡⟨⟩
b ∎
]
}
; left-inverse-of = elim-Very-stable
_
(stable-[] true)
(stable-[] false)
(λ _ → Very-stable→Very-stable-≡ 0 Very-stable-B̃ool _ _)
})
where
to = rec-Very-stable [ Bool.true ] [ Bool.false ] Very-stable-Erased
from = stable ∘ Erased.map from-Bool
lemma : ∀ b → to (from-Bool b) ≡ [ b ]
lemma Bool.true = refl _
lemma Bool.false = refl _
------------------------------------------------------------------------
-- An example
private
-- At the time of writing it is unclear if there is a reasonable way
-- to compile very stable booleans. The constructors true and false
-- are distinct, and it is reasonable to think that a compiler will
-- compile them in different ways. Now consider the following two
-- very stable booleans:
b₁ : B̃ool
b₁ = stable [ true ]
b₂ : B̃ool
b₂ = stable [ false ]
-- The first one is equal to true, and the second one is equal to
-- false:
_ : b₁ ≡ true
_ = stable-[] true
_ : b₂ ≡ false
_ = stable-[] false
-- However, unlike the constructors true and false, b₁ and b₂ should
-- be compiled in the same way, because the argument to [_] is
-- erased.
-- One question, raised by Andrea Vezzosi, is whether it is possible
-- to write a program that gives /observably/ different results
-- (after erasure) for true and false. If this is the case, then the
-- erasure mechanism is not well-behaved.
|
module Types_mod
implicit none
integer, parameter :: SP = 4
integer, parameter :: DP = 8
integer, parameter :: SI = 4
integer, parameter :: DI = 8
public :: SP, DP, SI, DI
contains
end module Types_mod
|
lemma holomorphic_transform: "\<lbrakk>f holomorphic_on s; \<And>x. x \<in> s \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> g holomorphic_on s"
|
(*
Title: The pi-calculus
Author/Maintainer: Jesper Bengtson (jebe.dk), 2012
*)
theory Strong_Early_Bisim_Subst_Pres
imports Strong_Early_Bisim_Subst Strong_Early_Bisim_Pres
begin
lemma tauPres:
fixes P :: pi
and Q :: pi
assumes "P \<sim>\<^sup>s Q"
shows "\<tau>.(P) \<sim>\<^sup>s \<tau>.(Q)"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.tauPres)
lemma inputPres:
fixes P :: pi
and Q :: pi
and a :: name
and x :: name
assumes "P \<sim>\<^sup>s Q"
shows "a<x>.P \<sim>\<^sup>s a<x>.Q"
proof(auto simp add: substClosed_def)
fix \<sigma> :: "(name \<times> name) list"
{
fix P Q a x \<sigma>
assume "P \<sim>\<^sup>s Q"
then have "P[<\<sigma>>] \<sim>\<^sup>s Q[<\<sigma>>]" by(rule partUnfold)
then have "\<forall>y. (P[<\<sigma>>])[x::=y] \<sim> (Q[<\<sigma>>])[x::=y]"
apply(auto simp add: substClosed_def)
by(erule_tac x="[(x, y)]" in allE) auto
moreover assume "x \<sharp> \<sigma>"
ultimately have "(a<x>.P)[<\<sigma>>] \<sim> (a<x>.Q)[<\<sigma>>]"
by(force intro: Strong_Early_Bisim_Pres.inputPres)
}
note Goal = this
obtain y::name where "y \<sharp> P" and "y \<sharp> Q" and "y \<sharp> \<sigma>"
by(generate_fresh "name") auto
from `P \<sim>\<^sup>s Q` have "([(x, y)] \<bullet> P) \<sim>\<^sup>s ([(x, y)] \<bullet> Q)" by(rule eqvtI)
hence "(a<y>.([(x, y)] \<bullet> P))[<\<sigma>>] \<sim> (a<y>.([(x, y)] \<bullet> Q))[<\<sigma>>]" using `y \<sharp> \<sigma>` by(rule Goal)
moreover from `y \<sharp> P` `y \<sharp> Q` have "a<x>.P = a<y>.([(x, y)] \<bullet> P)" and "a<x>.Q = a<y>.([(x, y)] \<bullet> Q)"
by(simp add: alphaInput)+
ultimately show "(a<x>.P)[<\<sigma>>] \<sim> (a<x>.Q)[<\<sigma>>]" by simp
qed
lemma outputPres:
fixes P :: pi
and Q :: pi
assumes "P \<sim>\<^sup>s Q"
shows "a{b}.P \<sim>\<^sup>s a{b}.Q"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.outputPres)
assumes "P \<sim>\<^sup>s Q"
shows "[a\<frown>b]P \<sim>\<^sup>s [a\<frown>b]Q"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.matchPres)
lemma mismatchPres:
fixes P :: pi
and Q :: pi
and a :: name
and b :: name
assumes "P \<sim>\<^sup>s Q"
shows "[a\<noteq>b]P \<sim>\<^sup>s [a\<noteq>b]Q"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.mismatchPres)
lemma sumPres:
fixes P :: pi
and Q :: pi
and R :: pi
assumes "P \<sim>\<^sup>s Q"
shows "P \<oplus> R \<sim>\<^sup>s Q \<oplus> R"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.sumPres)
lemma parPres:
fixes P :: pi
and Q :: pi
and R :: pi
assumes "P \<sim>\<^sup>s Q"
shows "P \<parallel> R \<sim>\<^sup>s Q \<parallel> R"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.parPres)
assumes PeqQ: "P \<sim>\<^sup>s Q"
shows "<\<nu>x>P \<sim>\<^sup>s <\<nu>x>Q"
proof(auto simp add: substClosed_def)
fix s::"(name \<times> name) list"
have Res: "\<And>P Q x s. \<lbrakk>P[<s>] \<sim> Q[<s>]; x \<sharp> s\<rbrakk> \<Longrightarrow> (<\<nu>x>P)[<s>] \<sim> (<\<nu>x>Q)[<s>]"
by(force intro: Strong_Early_Bisim_Pres.resPres)
have "\<exists>c::name. c \<sharp> (P, Q, s)" by(blast intro: name_exists_fresh)
then obtain c::name where cFreshP: "c \<sharp> P" and cFreshQ: "c \<sharp> Q" and cFreshs: "c \<sharp> s"
by(force simp add: fresh_prod)
from PeqQ have "P[<([(x, c)] \<bullet> s)>] \<sim> Q[<([(x, c)] \<bullet> s)>]" by(simp add: substClosed_def)
hence "([(x, c)] \<bullet> P[<([(x, c)] \<bullet> s)>]) \<sim> ([(x, c)] \<bullet> Q[<([(x, c)] \<bullet> s)>])" by(rule Strong_Early_Bisim.bisimClosed)
hence "([(x, c)] \<bullet> P)[<s>] \<sim> ([(x, c)] \<bullet> Q)[<s>]" by simp
hence "(<\<nu>c>([(x, c)] \<bullet> P))[<s>] \<sim> (<\<nu>c>([(x, c)] \<bullet> Q))[<s>]" using cFreshs by(rule Res)
moreover from cFreshP cFreshQ have "<\<nu>x>P = <\<nu>c>([(x, c)] \<bullet> P)" and "<\<nu>x>Q = <\<nu>c>([(x, c)] \<bullet> Q)"
by(simp add: alphaRes)+
ultimately show "(<\<nu>x>P)[<s>] \<sim> (<\<nu>x>Q)[<s>]" by simp
qed
shows "!P \<sim>\<^sup>s !Q"
using assms
by(force simp add: substClosed_def intro: Strong_Early_Bisim_Pres.bangPres)
end
|
theory Carries
imports Bits_Digits
begin
section \<open>Carries in base-b expansions\<close>
text \<open>Some auxiliary lemmas\<close>
lemma rev_induct[consumes 1, case_names base step]:
fixes i k :: nat
assumes le: "i \<le> k"
and base: "P k"
and step: "\<And>i. i \<le> k \<Longrightarrow> P i \<Longrightarrow> P (i - 1)"
shows "P i"
proof -
have "\<And>i::nat. n = k-i \<Longrightarrow> i \<le> k \<Longrightarrow> P i" for n
proof (induct n)
case 0
then have "i = k" by arith
with base show "P i" by simp
next
case (Suc n)
then have "n = (k - (i + 1))" by arith
moreover have k: "i + 1 \<le> k" using Suc.prems by arith
ultimately have "P (i + 1)" by (rule Suc.hyps)
from step[OF k this] show ?case by simp
qed
with le show ?thesis by fast
qed
subsection \<open>Definition of carry received at position k\<close>
text \<open>When adding two numbers m and n, the carry is \emph{introduced}
at position 1 but is \emph{received} at position 2. The function below
accounts for the latter case.
\begin{center} \begin{verbatim}
k: 6 5 4 3 2 1 0
c: 1
- - - - - - - - - - - -
m: 1 0 1 0 1 0
n: 1 1
----------------------
m + n: 0 1 0 1 1 0 0
\end{verbatim} \end{center} \<close>
definition bin_carry :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where
"bin_carry a b k = (a mod 2^k + b mod 2^k) div 2^k"
text \<open>Carry in the subtraction of two natural numbers\<close>
definition bin_narry :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where
"bin_narry a b k = (if b mod 2^k > a mod 2^k then 1 else 0)"
text \<open>Equivalent definition\<close>
definition bin_narry2 :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where
"bin_narry2 a b k = ((2^k + a mod 2^k - b mod 2^k) div 2^k + 1) mod 2"
lemma bin_narry_equiv: "bin_narry a b c = bin_narry2 a b c"
apply (auto simp add: bin_narry_def bin_narry2_def)
subgoal by (smt add.commute div_less dvd_0_right even_Suc le_add_diff_inverse2 less_add_eq_less
mod_greater_zero_iff_not_dvd neq0_conv not_mod2_eq_Suc_0_eq_0 order_le_less zero_less_diff
zero_less_numeral zero_less_power)
subgoal by (simp add: le_div_geq less_imp_diff_less)
done
subsection \<open>Properties of carries\<close>
lemma div_sub:
fixes a b c :: nat
shows "(a - b) div c = (if(a mod c < b mod c) then a div c - b div c - 1 else a div c - b div c)"
proof-
consider (alb) "a<b" | (ageb) "a\<ge>b" by linarith
then show ?thesis
proof cases
case alb
then show ?thesis using div_le_mono by auto
next
case ageb
obtain a1 a2 where a1_def: "a1 = a div c" and a2_def: "a2 = a mod c" and a_def: "a=a1*c+a2"
using mod_div_decomp by blast
obtain b1 b2 where b1_def: "b1 = b div c" and b2_def: "b2 = b mod c" and b_def: "b=b1*c+b2"
using mod_div_decomp by blast
have a1geb1: "a1\<ge>b1" using ageb a1_def b1_def using div_le_mono by blast
show ?thesis
proof(cases "c=0")
assume "c=0"
then show ?thesis by simp
next
assume cneq0: "c \<noteq> 0"
then show ?thesis
proof(cases "a2 < b2")
assume a2lb2: "a2 < b2"
then show ?thesis
proof(cases "a1=b1")
case True
then show ?thesis using ageb a2lb2 a_def b_def by force
next
assume "\<not>(a1=b1)"
hence a1gb1: "a1>b1" using a1geb1 by auto
have boundc: "a2+c-b2<c" using a2lb2 cneq0 by linarith
have "a-b = (a1 - b1) * c + a2 - b2"
using a_def b_def a1geb1 nat_diff_add_eq1[of b1 a1 c a2 b2] by auto
also have "... = (a1 - b1-1+1) * c + a2 - b2"
using a1gb1 Suc_diff_Suc[of b1 a1] by auto
also have "... = (a1 - b1 - 1) * c + (a2 + c - b2)"
using div_eq_0_iff[of b2 c] mod_div_trivial[of b c] b2_def by force
finally have "(a-b) div c = a1 - b1 - 1 + (a2 + c - b2) div c"
using a_def b_def cneq0 by auto
then show ?thesis
using boundc div_less by (simp add: a1_def a2_def b1_def b2_def)
qed
next
assume a2geb2: "\<not> a2 < b2"
then have "(a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c"
using a1geb1 a_def b_def nat_diff_add_eq1 by auto
then show ?thesis using a2geb2 div_add1_eq[of "(a1-b1)*c" "a2-b2" c]
by(auto simp add: b2_def a2_def a1_def b1_def less_imp_diff_less)
qed
qed
qed
qed
lemma dif_digit_formula:"a \<ge> b \<longrightarrow> (a - b)\<exclamdown>k = (a\<exclamdown>k + b\<exclamdown>k + bin_narry a b k) mod 2"
proof -
{
presume asm: "a\<ge>b" "a mod 2 ^ k < b mod 2 ^ k"
then have "Suc((a - b) div 2 ^ k) = a div 2 ^ k - b div 2 ^ k"
by (smt Nat.add_diff_assoc One_nat_def Suc_pred add.commute diff_is_0_eq div_add_self1
div_le_mono div_sub mod_add_self1 nat_le_linear neq0_conv plus_1_eq_Suc power_not_zero
zero_neq_numeral)
then have "(a - b) div 2 ^ k mod 2 = Suc (a div 2 ^ k mod 2 + b div 2 ^ k mod 2) mod 2"
by (smt diff_is_0_eq even_Suc even_diff_nat even_iff_mod_2_eq_zero le_less mod_add_eq
nat.simps(3) not_mod_2_eq_1_eq_0)
}
moreover
{
presume asm2: "\<not> a mod 2 ^ k < b mod 2 ^ k" "b \<le> a"
then have "(a - b) div 2 ^ k mod 2 = (a div 2 ^ k mod 2 + b div 2 ^ k mod 2) mod 2"
using div_sub[of b "2^k" a] div_le_mono even_add even_iff_mod_2_eq_zero
le_add_diff_inverse2[of "b div 2 ^ k" "a div 2 ^ k"] mod_mod_trivial[of _ 2]
not_less[of "a mod 2 ^ k" "b mod 2 ^ k"] not_mod_2_eq_1_eq_0 div_sub by smt
}
ultimately show ?thesis
by (auto simp add: bin_narry_def nth_bit_def)
qed
lemma dif_narry_formula:
"a\<ge>b \<longrightarrow> bin_narry a b (k + 1) = (if (a\<exclamdown>k < b\<exclamdown>k + bin_narry a b k) then 1 else 0)"
proof -
{
presume a1: "a mod (2 * 2 ^ k) < b mod (2 * 2 ^ k)"
presume a2: "\<not> a div 2 ^ k mod 2 < Suc (b div 2 ^ k mod 2)"
have f3: "2 ^ k \<noteq> (0::nat)"
by simp
have f4: "a div 2 ^ k mod 2 = 1"
using a2 by (meson le_less_trans mod2_eq_if mod_greater_zero_iff_not_dvd not_less
zero_less_Suc)
then have "b mod (2 * 2 ^ k) = b mod 2 ^ k"
using a2 by (metis (no_types) One_nat_def le_simps(3) mod_less_divisor mod_mult2_eq
mult.left_neutral neq0_conv not_less semiring_normalization_rules(7))
then have "False"
using f4 f3 a1 by (metis One_nat_def add.commute div_add_self1 div_le_mono less_imp_le
mod_div_trivial mod_mult2_eq mult.left_neutral not_less plus_1_eq_Suc
semiring_normalization_rules(7) zero_less_Suc)
}
moreover
{
presume a1: "\<not> a mod 2 ^ k < b mod 2 ^ k"
presume a2: "a mod (2 * 2 ^ k) < b mod (2 * 2 ^ k)"
presume a3: "\<not> a div 2 ^ k mod 2 < b div 2 ^ k mod 2"
presume a4: "b \<le> a"
have f6: "a mod 2 ^ Suc k < b mod 2 ^ Suc k"
using a2 by simp
obtain nn :: "nat \<Rightarrow> nat \<Rightarrow> nat" where f7: "b + nn a b = a" using a4 le_add_diff_inverse by auto
have "(a div 2 ^ k - b div 2 ^ k) div 2 = a div 2 ^ k div 2 - b div 2 ^ k div 2"
using a3 div_sub by presburger
then have f8: "(a - b) div 2 ^ Suc k = a div 2 ^ Suc k - b div 2 ^ Suc k"
using a1 by (metis (no_types) div_mult2_eq div_sub power_Suc power_commutes)
have f9: "\<forall>n na. Suc (na div n) = (n + na) div n \<or> 0 = n"
by (metis (no_types) add_Suc_right add_cancel_left_right div_add_self1 lessI
less_Suc_eq_0_disj less_one zero_neq_one)
then have "\<forall>n na nb. (na + nb - n) div na = Suc (nb div na) - n div na - 1 \<or>
\<not> (na + nb) mod na < n mod na \<or> 0 = na" by (metis (no_types) div_sub)
then have f10: "\<forall>n na nb. \<not> (nb::nat) mod na < n mod na \<or> nb div na - n div na
= (na + nb - n) div na \<or> 0 = na"
by (metis (no_types) diff_Suc_Suc diff_commute diff_diff_left mod_add_self1 plus_1_eq_Suc)
have "\<forall>n. Suc n \<noteq> n" by linarith
then have "(0::nat) = 2 ^ Suc k"
using f10 f9 f8 f7 f6 a4 by (metis add_diff_cancel_left' add_diff_assoc)
then have "False"
by simp
}
ultimately show ?thesis
apply (auto simp add: nth_bit_def not_less bin_narry_def)
subgoal by (smt add_0_left add_less_cancel_left Divides.divmod_digit_0(2) le_less_trans mod_less_divisor
mod_mult2_eq mult_zero_right nat_neq_iff not_less not_mod2_eq_Suc_0_eq_0
semiring_normalization_rules(7) zero_less_numeral zero_less_power)
subgoal by (smt One_nat_def add.left_neutral Divides.divmod_digit_0(1) le_less_trans less_imp_le
mod_less_divisor mod_mult2_eq mod_mult_self1_is_0 mult_zero_right not_less
not_mod2_eq_Suc_0_eq_0 not_one_le_zero semiring_normalization_rules(7) zero_less_numeral
zero_less_power)
done
qed
lemma sum_digit_formula:"(a + b)\<exclamdown>k =(a\<exclamdown>k + b\<exclamdown>k + bin_carry a b k) mod 2"
by (simp add: bin_carry_def nth_bit_def) (metis div_add1_eq mod_add_eq)
lemma sum_carry_formula:"bin_carry a b (k + 1) =(a\<exclamdown>k + b\<exclamdown>k + bin_carry a b k) div 2"
by (simp add: bin_carry_def nth_bit_def)
(smt div_mult2_eq div_mult_self4 mod_mult2_eq power_not_zero semiring_normalization_rules(20)
semiring_normalization_rules(34) semiring_normalization_rules(7) zero_neq_numeral)
lemma bin_carry_bounded:
shows "bin_carry a b k = bin_carry a b k mod 2"
proof-
have "a mod 2 ^ k < 2 ^k" by simp
moreover have "b mod 2 ^ k < 2 ^ k" by simp
ultimately have "(a mod 2 ^ k + b mod 2 ^ k) < 2 ^(Suc k)" by (simp add: mult_2 add_strict_mono)
then have "(a mod 2 ^ k + b mod 2 ^ k) div 2^k \<le> 1" using less_mult_imp_div_less by force
then have "bin_carry a b k \<le> 1" using div_le_mono bin_carry_def by fastforce
then show ?thesis by auto
qed
lemma carry_bounded: "bin_carry a b k \<le> 1"
using bin_carry_bounded not_mod_2_eq_1_eq_0[of "bin_carry a b k"] by auto
lemma no_carry:
"(\<forall>r< n.((nth_bit a r) + (nth_bit b r) \<le> 1)) \<Longrightarrow>
(nth_bit (a + b) n) = (nth_bit a n + nth_bit b n) mod 2"
(is "?P \<Longrightarrow> ?Q n")
proof (rule ccontr)
assume p: "?P"
assume nq: "\<not>?Q n"
then obtain k where k1:"\<not>?Q k" and k2:"\<forall>r<k. ?Q r" by (auto dest: obtain_smallest)
have c1: "1 = bin_carry a b k"
using k1 sum_digit_formula bin_carry_bounded
by auto (metis add.commute not_mod2_eq_Suc_0_eq_0 plus_nat.add_0)
have "bin_carry a b (k-1) = 0" using sum_digit_formula
by (metis bin_carry_bounded bin_carry_def diff_is_0_eq' diff_less div_by_1 even_add
even_iff_mod_2_eq_zero k2 less_numeral_extra(1) mod_by_1 neq0_conv nth_bit_bounded
power_0)
moreover have "a \<exclamdown> (k-1) + b \<exclamdown> (k-1) < 1"
by (smt add.right_neutral c1 calculation diff_le_self k2 leI le_add_diff_inverse2 le_less_trans
mod_by_1 mod_if nat_less_le nq one_div_two_eq_zero one_neq_zero p sum_carry_formula)
ultimately have "0 = bin_carry a b k" using k2 sum_carry_formula
by auto (metis Suc_eq_plus1_left add_diff_inverse_nat less_imp_diff_less mod_0 mod_Suc
mod_add_self1 mod_div_trivial mod_less n_not_Suc_n plus_nat.add_0)
then show False using c1 by auto
qed
lemma no_carry_mult_equiv:"(\<forall>k. nth_bit a k * nth_bit b k = 0) \<longleftrightarrow> (\<forall>k. bin_carry a b k = 0)"
(is "?P \<longleftrightarrow> ?Q")
proof
assume P: ?P
{
fix k
from P have "bin_carry a b k = 0"
proof (induction k)
case 0
then show ?case using bin_carry_def by (simp)
next
case (Suc k)
then show ?case using sum_carry_formula P
by (metis One_nat_def Suc_eq_plus1 add.right_neutral div_less lessI
mult_is_0 not_mod_2_eq_0_eq_1 nth_bit_def numeral_2_eq_2 zero_less_Suc)
qed
}
then show ?Q by auto
next
assume Q: ?Q
{
fix k
from Q have "a \<exclamdown> k * b \<exclamdown> k = 0"
proof (induction k)
case 0
then show ?case using bin_carry_def nth_bit_def
by simp (metis add_self_div_2 not_mod2_eq_Suc_0_eq_0 power_one_right)
next
case (Suc k)
then show ?case
using nth_bit_def sum_carry_formula
by simp (metis One_nat_def add.right_neutral add_self_div_2 not_mod_2_eq_1_eq_0 power_Suc)+
qed
}
then show ?P by auto
qed
(* NEW LEMMAS FROM DIGIT COMPARISON *)
lemma carry_digit_impl: "bin_carry a b k \<noteq> 0 \<Longrightarrow> \<exists>r<k. a \<exclamdown> r + b \<exclamdown> r = 2"
proof(rule ccontr)
assume "\<not> (\<exists>r<k. a \<exclamdown> r + b \<exclamdown> r = 2)"
hence bound: "\<forall>r<k. a \<exclamdown> r + b \<exclamdown> r \<le> 1" using nth_bit_def by auto
assume bk:"bin_carry a b k \<noteq> 0"
hence base: "bin_carry a b k = 1" using carry_bounded le_less[of "bin_carry a b k" 1] by auto
have step: "i \<le> k \<Longrightarrow> bin_carry a b i = 1 \<Longrightarrow> bin_carry a b (i - 1) = 1" for i
proof(rule ccontr)
assume ik: "i \<le> k"
assume carry: "bin_carry a b i = 1"
assume "bin_carry a b (i- 1) \<noteq> 1"
hence "bin_carry a b (i - 1) = 0" using bin_carry_bounded not_mod_2_eq_1_eq_0[of "bin_carry a b (i - 1)"] by auto
then show False using ik carry bound sum_carry_formula[of a b "i-1"]
apply simp
by (metis Suc_eq_plus1 Suc_pred add_lessD1 bot_nat_0.not_eq_extremum carry diff_is_0_eq' div_le_mono le_eq_less_or_eq less_add_one one_div_two_eq_zero)
qed
have "\<forall>i\<le>k. bin_carry a b i = 1" using rev_induct[where ?P="\<lambda>c.(bin_carry a b c = 1)"] step base by blast
moreover have "bin_carry a b 0 = 0" using bin_carry_def by simp
ultimately show False by auto
qed
end
|
/**
* \author Sylvain Marsat, University of Maryland - NASA GSFC
*
* \brief C header for functions computing coeffcients of Not-A-Knot and Quadratic splines in matrix form.
*
*/
#ifndef _SPLINECOEFFS_H
#define _SPLINECOEFFS_H
#define _XOPEN_SOURCE 500
#ifdef __GNUC__
#define UNUSED __attribute__ ((unused))
#else
#define UNUSED
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include <time.h>
#include <unistd.h>
#include <getopt.h>
#include <stdbool.h>
#include <string.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_bspline.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_min.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_complex.h>
#include "constants.h"
#include "struct.h"
#if defined(__cplusplus)
extern "C" {
#elif 0
} /* so that editors will match preceding brace */
#endif
void BuildNotAKnotSpline(
gsl_matrix* splinecoeffs, /* Output: matrix containing all the spline coeffs (already allocated) */
gsl_vector* vectx, /* Input: vector x*/
gsl_vector* vecty, /* Input: vector y */
int n); /* Size of x, y, and of output matrix */
void BuildQuadSpline(
gsl_matrix* splinecoeffs, /* Output: matrix containing all the spline coeffs (already allocated) */
gsl_vector* vectx, /* Input: vector x*/
gsl_vector* vecty, /* Input: vector y */
int n); /* Size of x, y, and of output matrix */
void BuildSplineCoeffs(
CAmpPhaseSpline** splines, /* */
CAmpPhaseFrequencySeries* freqseries); /* */
void BuildListmodesCAmpPhaseSpline(
ListmodesCAmpPhaseSpline** listspline, /* Output: list of modes of splines in matrix form */
ListmodesCAmpPhaseFrequencySeries* listh); /* Input: list of modes in amplitude/phase form */
/* Functions for spline evaluation */
/* Note: for the spines in matrix form, the first column contains the x values, so the coeffs start at 1 */
double EvalCubic(
gsl_vector* coeffs, /**/
double eps, /**/
double eps2, /**/
double eps3); /**/
double EvalQuad(
gsl_vector* coeffs, /**/
double eps, /**/
double eps2); /**/
void EvalCAmpPhaseSpline(
CAmpPhaseSpline* splines, //input
CAmpPhaseFrequencySeries* freqseries); //in/out defines CAmpPhase from defined freqs
#if 0
{ /* so that editors will match succeeding brace */
#elif defined(__cplusplus)
}
#endif
#endif /* _SPLINECOEFFS_H */
|
section \<open>Peano's axioms for Natural Numbers\<close>
theory Peano_Axioms
imports Main
begin
locale peano = \<comment> \<open>or: \<^theory_text>\<open>class\<close>\<close>
fixes zero :: 'a
fixes succ :: "'a \<Rightarrow> 'a"
assumes succ_neq_zero [simp]: "succ m \<noteq> zero"
assumes succ_inject [simp]: "succ m = succ n \<longleftrightarrow> m = n"
assumes induct [case_names zero succ, induct type: 'a]:
"P zero \<Longrightarrow> (\<And>n. P n \<Longrightarrow> P (succ n)) \<Longrightarrow> P n"
begin
lemma zero_neq_succ [simp]: "zero \<noteq> succ m"
by (rule succ_neq_zero [symmetric])
text \<open>\<^medskip> Primitive recursion as a (functional) relation -- polymorphic!\<close>
inductive Rec :: "'b \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
for e :: 'b and r :: "'a \<Rightarrow> 'b \<Rightarrow> 'b"
where
Rec_zero: "Rec e r zero e"
| Rec_succ: "Rec e r m n \<Longrightarrow> Rec e r (succ m) (r m n)"
lemma Rec_functional: "\<exists>!y::'b. Rec e r x y" for x :: 'a
proof -
let ?R = "Rec e r"
show ?thesis
proof (induct x)
case zero
show "\<exists>!y. ?R zero y"
proof
show "?R zero e" ..
show "y = e" if "?R zero y" for y
using that by cases simp_all
qed
next
case (succ m)
from \<open>\<exists>!y. ?R m y\<close>
obtain y where y: "?R m y" and yy': "\<And>y'. ?R m y' \<Longrightarrow> y = y'"
by blast
show "\<exists>!z. ?R (succ m) z"
proof
from y show "?R (succ m) (r m y)" ..
next
fix z
assume "?R (succ m) z"
then obtain u where "z = r m u" and "?R m u"
by cases simp_all
with yy' show "z = r m y"
by (simp only:)
qed
qed
qed
text \<open>\<^medskip> The recursion operator -- polymorphic!\<close>
definition rec :: "'b \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
where "rec e r x = (THE y. Rec e r x y)"
lemma rec_eval:
assumes Rec: "Rec e r x y"
shows "rec e r x = y"
unfolding rec_def
using Rec_functional and Rec by (rule the1_equality)
lemma rec_zero [simp]: "rec e r zero = e"
proof (rule rec_eval)
show "Rec e r zero e" ..
qed
lemma rec_succ [simp]: "rec e r (succ m) = r m (rec e r m)"
proof (rule rec_eval)
let ?R = "Rec e r"
have "?R m (rec e r m)"
unfolding rec_def using Rec_functional by (rule theI')
then show "?R (succ m) (r m (rec e r m))" ..
qed
text \<open>\<^medskip> Example: addition (monomorphic)\<close>
definition add :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
where "add m n = rec n (\<lambda>_ k. succ k) m"
lemma add_zero [simp]: "add zero n = n"
and add_succ [simp]: "add (succ m) n = succ (add m n)"
unfolding add_def by simp_all
lemma add_zero_right: "add m zero = m"
by (induct m) simp_all
lemma add_succ_right: "add m (succ n) = succ (add m n)"
by (induct m) simp_all
lemma "add (succ (succ (succ zero))) (succ (succ zero)) =
succ (succ (succ (succ (succ zero))))"
by simp
text \<open>\<^medskip> Example: replication (polymorphic)\<close>
definition repl :: "'a \<Rightarrow> 'b \<Rightarrow> 'b list"
where "repl n x = rec [] (\<lambda>_ xs. x # xs) n"
lemma repl_zero [simp]: "repl zero x = []"
and repl_succ [simp]: "repl (succ n) x = x # repl n x"
unfolding repl_def by simp_all
lemma "repl (succ (succ (succ zero))) True = [True, True, True]"
by simp
end
text \<open>\<^medskip> Just see that our abstract specification makes sense \dots\<close>
interpretation peano 0 Suc
proof
fix m n
show "Suc m \<noteq> 0" by simp
show "Suc m = Suc n \<longleftrightarrow> m = n" by simp
show "P n"
if zero: "P 0"
and succ: "\<And>n. P n \<Longrightarrow> P (Suc n)"
for P
proof (induct n)
case 0
show ?case by (rule zero)
next
case Suc
then show ?case by (rule succ)
qed
qed
end
|
State Before: α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
hs : s ∈ 𝓝 a
⊢ closure (i '' s) ∈ 𝓝 (i a) State After: α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
hs : ∃ i_1, (i a ∈ i_1 ∧ IsOpen i_1) ∧ i ⁻¹' i_1 ⊆ s
⊢ closure (i '' s) ∈ 𝓝 (i a) Tactic: rw [di.nhds_eq_comap a, ((nhds_basis_opens _).comap _).mem_iff] at hs State Before: α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
hs : ∃ i_1, (i a ∈ i_1 ∧ IsOpen i_1) ∧ i ⁻¹' i_1 ⊆ s
⊢ closure (i '' s) ∈ 𝓝 (i a) State After: case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
U : Set β
sub : i ⁻¹' U ⊆ s
haU : i a ∈ U
hUo : IsOpen U
⊢ closure (i '' s) ∈ 𝓝 (i a) Tactic: rcases hs with ⟨U, ⟨haU, hUo⟩, sub : i ⁻¹' U ⊆ s⟩ State Before: case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
U : Set β
sub : i ⁻¹' U ⊆ s
haU : i a ∈ U
hUo : IsOpen U
⊢ closure (i '' s) ∈ 𝓝 (i a) State After: case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
U : Set β
sub : i ⁻¹' U ⊆ s
haU : i a ∈ U
hUo : IsOpen U
⊢ U ⊆ closure (i '' s) Tactic: refine' mem_of_superset (hUo.mem_nhds haU) _ State Before: case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type ?u.1224
δ : Type ?u.1227
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalSpace β
i : α → β
di✝ : DenseInducing i
s : Set α
a : α
di : DenseInducing i
U : Set β
sub : i ⁻¹' U ⊆ s
haU : i a ∈ U
hUo : IsOpen U
⊢ U ⊆ closure (i '' s) State After: no goals Tactic: calc
U ⊆ closure (i '' (i ⁻¹' U)) := di.dense.subset_closure_image_preimage_of_isOpen hUo
_ ⊆ closure (i '' s) := closure_mono (image_subset i sub)
|
% Replace with the location you download the datasets to
data_dir = [getenv('USERPROFILE') '/Dropbox/AAM/test data/'];
% location of datasets, the datasets are acquired from http://ibug.doc.ic.ac.uk/resources/300-W/
dataset_locs = { [data_dir, '/AFW/'];
[data_dir, '/helen/trainset/'];
[data_dir, '/helen/testset/'];
[data_dir, '/ibug/'];
[data_dir, 'lfpw/testset/'];
[data_dir, '/lfpw/trainset/'];};
bb_locs = {[data_dir, '/Bounding Boxes/bounding_boxes_afw.mat'];
[data_dir, '/Bounding Boxes/bounding_boxes_helen_trainset.mat'];
[data_dir, '/Bounding Boxes/bounding_boxes_helen_testset.mat'];
[data_dir, '/Bounding Boxes/bounding_boxes_ibug.mat'];
[data_dir, '/Bounding Boxes/bounding_boxes_lfpw_testset.mat'];
[data_dir, '/Bounding Boxes/bounding_boxes_lfpw_trainset.mat'];};
for d=1:numel(dataset_locs)
load(bb_locs{d});
for i=1:numel(bounding_boxes)
img_name = bounding_boxes{i}.imgName;
[~, name, ~] = fileparts(img_name);
% image = imread([dataset_locs{d}, img_name]);
% imshow(image);
bbox = bounding_boxes{i}.bb_detector;
f = fopen([dataset_locs{d}, name, '.txt'], 'w');
fprintf(f, '%f %f %f %f\r\n', bbox(1), bbox(2), bbox(3), bbox(4));
fclose(f);
% rectangle('Position', [bbox(1), bbox(2), bbox(3)-bbox(1), bbox(4)-bbox(2)]);
% drawnow expose
% pause(0);
end
end
|
-- Andreas, 2018-12-30, issue #3480
-- Parse error should be reported close to the incomplete "module _"
-- rather than at the end of the file, which is miles away.
module _
{- A long comment:
Per Martin-L"of
ON THE MEANINGS OF THE LOGICAL
CONSTANTS AND THE JUSTIFICATIONS
OF THE LOGICAL LAWS
Preface
The following three lectures were given in the form of a short course
at the meeting Teoria della Dimostrazione e Filosofia della Logica,
organized in Siena, 6-9 April 1983, by the Scuola di Specializzazione in
Logica Matematica of the Universit`a degli Studi di Siena. I am very
grateful to Giovanni Sambin and Aldo Ursini of that school, not only
for recording the lectures on tape, but, above all, for transcribing the
tapes produced by the recorder: no machine could have done that work.
This written version of the lectures is based on their transcription. The
changes that I have been forced to make have mostly been of a stylistic
nature, except at one point. In the second lecture, as I actually gave
it, the order of conceptual priority between the notions of proof and
immediate inference was wrong. Since I discovered my mistake later
the same month as the meeting was held, I thought it better to let
the written text diverge from the oral presentation rather than possibly
confusing others by letting the mistake remain. The oral origin of
these lectures is the source of the many redundancies of the written
text. It is also my sole excuse for the lack of detailed references.
First lecture
When I was asked to give these lectures about a year ago, I suggested
the title On the Meanings of the Logical Constants and the
Justifications of the Logical Laws. So that is what I shall talk about,
eventually, but, first of all, I shall have to say something about, on
the one hand, the things that the logical operations operate on, which
we normally call propositions and propositional functions, and, on the
Nordic Journal of Philosophical Logic, Vol. 1, No. 1, pp. 11-60.
cfl 1996 Scandinavian University Press.
12 per martin-l"of
other hand, the things that the logical laws, by which I mean the rules
of inference, operate on, which we normally call assertions. We must
remember that, even if a logical inference, for instance, a conjunction
introduction, is written
A B
A & B
which is the way in which we would normally write it, it does not take
us from the propositions A and B to the proposition A & B. Rather, it
takes us from the affirmation of A and the affirmation of B to the
affirmation of A & B, which we may make explicit, using Frege's notation,
by writing it `
A ` B
` A & B
instead. It is always made explicit in this way by Frege in his writings,
and in Principia, for instance. Thus we have two kinds of entities here:
we have the entities that the logical operations operate on, which we
call propositions, and we have those that we prove and that appear
as premises and conclusion of a logical inference, which we call assertions. It turns out that, in order to clarify the meanings of the logical
constants and justify the logical laws, a considerable portion of the
philosophical work lies already in clarifying the notion of proposition
and the notion of assertion. Accordingly, a large part of my lectures
will be taken up by a philosophical analysis of these two notions.
Let us first look at the term proposition. It has its origin in the Gr.
pri`tasij, used by Aristotle in the Prior Analytics, the third part of the
Organon. It was translated, apparently by Cicero, into Lat. propositio,
which has its modern counterparts in It. proposizione, Eng. proposition and Ger. Satz. In the old, traditional use of the word proposition,
propositions are the things that we prove. We talk about proposition
and proof, of course, in mathematics: we put up a proposition and let
it be followed by its proof. In particular, the premises and conclusion
of an inference were propositions in this old terminology. It was the
standard use of the word up to the last century. And it is this use
which is retained in mathematics, where a theorem is sometimes called
a proposition, sometimes a theorem. Thus we have two words for the
things that we prove, proposition and theorem. The word proposition,
Gr. pri`tasij, comes from Aristotle and has dominated the logical tradition, whereas the word theorem, Gr. qey"rhma, is in Euclid, I believe,
and has dominated the mathematical tradition.
With Kant, something important happened, namely, that the
term judgement, Ger. Urteil, came to be used instead of proposition.
on the meanings of the logical constants 13
Perhaps one reason is that proposition, or a word with that stem, at
least, simply does not exist in German: the corresponding German
word would be Lehrsatz, or simply Satz. Be that as it may, what happened with Kant and the ensuing German philosophical tradition was
that the word judgement came to replace the word proposition. Thus,
in that tradition, a proof, Ger. Beweis, is always a proof of a judgement. In particular, the premises and conclusion of a logical inference
are always called judgements. And it was the judgements, or the categorical judgements, rather, which were divided into affirmations and
denials, whereas earlier it was the propositions which were so divided.
The term judgement also has a long history. It is the Gr. krDHsij,
translated into Lat. judicium, It. giudizio, Eng. judgement, and Ger.
Urteil. Now, since it has as long a history as the word proposition,
these two were also previously used in parallel. The traditional way of
relating the notions of judgement and proposition was by saying that a
proposition is the verbal expression of a judgement. This is, as far as I
know, how the notions of proposition and judgement were related during the scholastic period, and it is something which is repeated in the
Port Royal Logic, for instance. You still find it repeated by Brentano
in this century. Now, this means that, when, in German philosophy
beginning with Kant, what was previously called a proposition came
to be called a judgement, the term judgement acquired a double meaning. It came to be used, on the one hand, for the act of judging, just
as before, and, on the other hand, it came to be used instead of the old
proposition. Of course, when you say that a proposition is the verbal
expression of a judgement, you mean by judgement the act of judging,
the mental act of judging in scholastic terms, and the proposition is the
verbal expression by means of which you make the mental judgement
public, so to say. That is, I think, how one thought about it. Thus,
with Kant, the term judgement became ambiguous between the act of
judging and that which is judged, or the judgement made, if you prefer.
German has here the excellent expression gef"alltes Urteil, which has no
good counterpart in English.
judgement
z ""-- -
the act of judging that which is judged
old tradition judgement proposition
Kant Urteil(sakt) (gef"alltes) Urteil
This ambiguity is not harmful, and sometimes it is even convenient,
because, after all, it is a kind of ambiguity that the word judgement
14 per martin-l"of
shares with other nouns of action. If you take the word proposition,
for instance, it is just as ambiguous between the act of propounding
and that which is propounded. Or, if you take the word affirmation, it
is ambiguous between the act of affirming and that which is affirmed,
and so on.
It should be clear, from what I said in the beginning, that there is
a difference between what we now call a proposition and a proposition
in the old sense. In order to trace the emergence of the modern notion
of proposition, I first have to consider the division of propositions in
the old sense into affirmations and denials. Thus the propositions, or
the categorical propositions, rather, were divided into affirmations and
denials.
(categorical) proposition
z ""-- -
affirmation denial
And not only were the categorical propositions so divided: the very
definition of a categorical proposition was that a categorical proposition
is an affirmation or a denial. Correlatively, to judge was traditionally,
by which I mean before Kant, defined as to combine or separate ideas
in the mind, that is, to affirm or deny. Those were the traditional
definitions of the notions of proposition and judgement.
The notions of affirmation and denial have fortunately remained
stable, like the notion of proof, and are therefore easy to use without
ambiguity. Both derive from Aristotle. Affirmation is Gr. katL'fasij,
Lat. affirmatio, It. affermazione, and Ger. Bejahung, whereas denial
is Gr. C'pi`fasij, Lat. negatio, It. negazione, and Ger. Verneinung. In
Aristotelian logic, an affirmation was defined as a proposition in which
something, called the predicate, is affirmed of something else, called
the subject, and a denial was defined as a proposition in which the
predicate is denied of the subject. Now, this is something that we have
certainly abandoned in modern logic. Neither do we take categorical
judgements to have subject-predicate form, nor do we treat affirmation
and denial symmetrically. It seems to have been Bolzano who took the
crucial step of replacing the Aristotelian forms of judgement by the
single form
A is, A is true, or A holds.
In this, he was followed by Brentano, who also introduced the opposite
form
A is not, or A is false,
on the meanings of the logical constants 15
and Frege. And, through Frege's influence, the whole of modern logic
has come to be based on the single form of judgement, or assertion, A
is true.
Once this step was taken, the question arose, What sort of thing
is it that is affirmed in an affirmation and denied in a denial? that is,
What sort of thing is the A here? The isolation of this concept belongs
to the, if I may so call it, objectivistically oriented branch of German
philosophy in the last century. By that, I mean the tradition which you
may delimit by mentioning the names of, say, Bolzano, Lotze, Frege,
Brentano, and the Brentano disciples Stumpf, Meinong, and Husserl,
although, with Husserl, I think one should say that the split between
the objectivistic and the Kantian branches of German philosophy is
finally overcome. The isolation of this concept was a step which was
entirely necessary for the development of modern logic. Modern logic
simply would not work unless we had this concept, because it is on the
things that fall under it that the logical operations operate.
This new concept, which simply did not exist before the last century, was variously called. And, since it was something that one had not
met before, one had difficulties with what one should call it. Among
the terms that were used, I think the least committing one is Ger.
Urteilsinhalt, content of a judgement, by which I mean that which is
affirmed in an affirmation and denied in a denial. Bolzano, who was
the first to introduce this concept, called it proposition in itself, Ger.
Satz an sich. Frege also grappled with this terminological problem.
In Begriffsschrift, he called it judgeable content, Ger. beurteilbarer Inhalt. Later on, corresponding to his threefold division into expression, sense, and reference, in the case of this kind of entity, what was
the expression, he called sentence, Ger. Satz, what was the sense, he
called thought, Ger. Gedanke, and what was the reference, he called
truth value, Ger. Wahrheitswert. So the question arises, What should
I choose here? Should I choose sentence, thought, or truth value? The
closest possible correspondence is achieved, I think, if I choose Gedanke,
that is, thought, for late Frege. This is confirmed by the fact that, in
his very late logical investigations, he called the logical operations the
Gedankengef"uge. Thus judgeable content is early Frege and thought
is late Frege. We also have the term state of affairs, Ger. Sachverhalt,
which was introduced by Stumpf and used by Wittgenstein in the Tractatus. And, finally, we have the term objective, Ger. Objektiv, which
was the term used by Meinong. Maybe there were other terms as well
in circulation, but these are the ones that come immediately to my
mind.
Now, Russell used the term proposition for this new notion, which
16 per martin-l"of
has become the standard term in Anglo-Saxon philosophy and in modern logic. And, since he decided to use the word proposition in this
new sense, he had to use another word for the things that we prove and
that figure as premises and conclusion of a logical inference. His choice
was to translate Frege's Urteil, not by judgement, as one would expect,
but by assertion. And why, one may ask, did he choose the word assertion rather than translate Urteil literally by judgement? I think it
was to avoid any association with Kantian philosophy, because Urteil
was after all the central notion of logic as it was done in the Kantian
tradition. For instance, in his transcendental logic, which forms part
of the Kritik der reinen Vernunft, Kant arrives at his categories by
analysing the various forms that a judgement may have. That was his
clue to the discovery of all pure concepts of reason, as he called it.
Thus, in Russell's hands, Frege's Urteil came to be called assertion,
and the combination of Frege's Urteilsstrich, judgement stroke, and
Inhaltsstrich, content stroke, came to be called the assertion sign.
Observe now where we have arrived through this development,
namely, at a notion of proposition which is entirely different, or different, at least, from the old one, that is, from the Gr. pri`tasij and
the Lat. propositio. To repeat, the things that we prove, in particular, the premises and conclusion of a logical inference, are no longer
propositions in Russell's terminology, but assertions. Conversely, the
things that we combine by means of the logical operations, the connectives and the quantifiers, are not propositions in the old sense, that
is, what Russell calls assertions, but what he calls propositions. And,
as I said in the very beginning, the rule of conjunction introduction,
for instance, really allows us to affirm A & B, having affirmed A and
having affirmed B, `
A ` B
` A & B
It is another matter, of course, that we may adopt conventions that
allow us to suppress the assertion sign, if it becomes too tedious to
write it out. Conceptually, it would nevertheless be there, whether I
write it as above or A true B true
A & B true
as I think that I shall do in the following.
So far, I have made no attempt at defining the notions of judgement, or assertion, and proposition. I have merely wanted to give a
preliminary hint at the difference between the two by showing how the
terminology has evolved.
on the meanings of the logical constants 17
To motivate my next step, consider any of the usual inference rules
of the propositional or predicate calculus. Let me take the rule of
disjunction introduction this time, for some change,
A
A . B
or, writing out the affirmation,
A true
A . B true
Now, what do the variables A and B range over in a rule like this?
That is, what are you allowed to insert into the places indicated by
these variables? The standard answer to this question, by someone
who has received the now current logical education, would be to say
that A and B range over arbitrary formulas of the language that you are
considering. Thus, if the language is first order arithmetic, say, then
A and B should be arithmetical formulas. When you start thinking
about this answer, you will see that there is something strange about
it, namely, its language dependence. Because it is clearly irrelevant for
the validity of the rule whether A and B are arithmetical formulas, corresponding to the language of first order arithmetic, or whether they
contain, say, predicates defined by transfinite, or generalized, induction. The unary predicate expressing that a natural number encodes
an ordinal of the constructive second number class, for instance, is certainly not expressible in first order arithmetic, and there is no reason
at all why A and B should not be allowed to contain that predicate.
Or, surely, for the validity of the rule, A and B might just as well
be set theoretical formulas, supposing that we have given such a clear
sense to them that we clearly recognize that they express propositions.
Thus what is important for the validity of the rule is merely that A and
B are propositions, that is, that the expressions which we insert into
the places indicated by the variables A and B express propositions. It
seems, then, that the deficiency of the first answer, by which I mean
the answer that A and B should range over formulas, is eliminated
by saying that the variables A and B should range over propositions
instead of formulas. And this is entirely natural, because, after all, the
notion of formula, as given by the usual inductive definition, is nothing
but the formalistic substitute for the notion of proposition: when you
divest a proposition in some language of all sense, what remains is the
mere formula. But then, supposing we agree that the natural way out
of the first difficulty is to say that A and B should range over arbitrary
18 per martin-l"of
propositions, another difficulty arises, because, whereas the notion of
formula is a syntactic notion, a formula being defined as an expression
that can be formed by means of certain formation rules, the notion
of proposition is a semantic notion, which means that the rule is no
longer completely formal in the strict sense of formal logic. That a rule
of inference is completely formal means precisely that there must be
no semantic conditions involved in the rule: it may only put conditions
on the forms of the premises and conclusion. The only way out of this
second difficulty seems to be to say that, really, the rule has not one
but three premises, so that, if we were to write them all out, it would
read A prop B prop A true
A . B true
that is, from A and B being propositions and from the truth of A, we
are allowed to conclude the truth of A . B. Here I am using
A prop
as an abbreviated way of saying that
A is a proposition.
Now the complete formality of the rule has been restored. Indeed, for
the variables A and B, as they occur in this rule, we may substitute
anything we want, and, by anything, I mean any expressions. Or, to
be more precise, if we categorize the expressions, as Frege did, into
complete, or saturated, expressions and incomplete, unsaturated, or
functional, expressions, then we should say that we may substitute for
A and B any complete expressions we want, because propositions are
always expressed by complete expressions, not by functional expressions. Thus A and B now range over arbitrary complete expressions.
Of course, there would be needed here an analysis of what is understood by an expression, but that is something which I shall not go into
in these lectures, in the belief that it is a comparatively trivial matter,
as compared with explaining the notions of proposition and judgement.
An expression in the most general sense of the word is nothing but a
form, that is, something that we can passively recognize as the same in
its manifold occurrences and actively reproduce in many copies. But
I think that I shall have to rely here upon an agreement that we have
such a general notion of expression, which is formal in character, so
that the rule can now count as a formal rule.
Now, if we stick to our previous decision to call what we prove, in
particular, the premises and conclusion of a logical inference, by the
on the meanings of the logical constants 19
word judgement, or assertion, the outcome of the preceding considerations is that we are faced with a new form of judgement. After all, A
prop and B prop have now become premises of the rule of disjunction
introduction. Hence, if premises are always judgements,
A is a proposition
must count as a form of judgement. This immediately implies that the
traditional definition of the act of judging as an affirming or denying
and of the judgement, that is, the proposition in the terminology then
used, as an affirmation or denial has to be rejected, because A prop is
certainly neither an affirmation nor a denial. Or, rather, we are faced
with the choice of either keeping the old definition of judgement as
an affirmation or a denial, in which case we would have to invent a
new term for the things that we prove and that figure as premises and
conclusion of a logical inference, or else abandoning the old definition
of judgement, widening it so as to make room for A is a proposition
as a new form of judgement. I have chosen the latter alternative, well
aware that, in so doing, I am using the word judgement in a new way.
Having rejected the traditional definition of a judgement as an affirmation or a denial, by what should we replace it? How should we
now delimit the notion of judgement, so that A is a proposition, A
is true, and A is false all become judgements? And there are other
forms of judgement as well, which we shall meet in due course. Now,
the question, What is a judgement? is no small question, because the
notion of judgement is just about the first of all the notions of logic,
the one that has to be explained before all the others, before even the
notions of proposition and truth, for instance. There is therefore an
intimate relation between the answer to the question what a judgement
is and the very question what logic itself is. I shall start by giving a
very simple answer, which is essentially right: after some elaboration,
at least, I hope that we shall have a sufficiently clear understanding of
it. And the definition would simply be that, when understood as an act
of judging, a judgement is nothing but an act of knowing, and, when
understood as that which is judged, it is a piece or, more solemnly, an
object of knowledge.
judgement
z ""-- -
the act of judging that which is judged
the act of knowing the object of knowledge
Thus, first of all, we have the ambiguity of the term judgement between
the act of judging and that which is judged. What I say is that an act
20 per martin-l"of
of judging is essentially nothing but an act of knowing, so that to judge
is the same as to know, and that what is judged is a piece, or an object,
of knowledge. Unfortunately, the English language has no counterpart
of Ger. eine Erkenntnis, a knowledge.
This new definition of the notion of judgement, so central to logic,
should be attributed in the first place to Kant, I think, although it may
be difficult to find him ever explicitly saying that the act of judging is
the same as the act of knowing, and that what is judged is the object of
knowledge. Nevertheless, it is behind all of Kant's analysis of the notion
of judgement that to judge amounts to the same as to know. It was
he who broke with the traditional, Aristotelian definition of judgement
as an affirmation or a denial. Explicitly, the notions of judgement
and knowledge were related by Bolzano, who simply defined knowledge
as evident judgement. Thus, for him, the order of priority was the
reverse: knowledge was defined in terms of judgement rather than the
other way round. The important thing to realize is of course that to
judge and to know, and, correlatively, judgement and knowledge, are
essentially the same. And, when the relation between judgement, or
assertion, if you prefer, and knowledge is understood in this way, logic
itself is naturally understood as the theory of knowledge, that is, of
demonstrative knowledge, Aristotle's a^pista*mh C'podeiktika*. Thus logic
studies, from an objective point of view, our pieces of knowledge as
they are organized in demonstrative science, or, if you think about it
from the act point of view, it studies our acts of judging, or knowing,
and how they are interrelated.
As I said a moment ago, this is only a first approximation, because
it would actually have been better if I had not said that an act of
judging is an act of knowing, but if I had said that it is an act of, and
here there are many words that you may use, either understanding,
or comprehending, or grasping, or seeing, in the metaphorical sense
of the word see in which it is synonymous with understand. I would
prefer this formulation, because the relation between the verb to know
and the verb to understand, comprehend, grasp, or see, is given by the
equation
to know = to have understood, comprehended, grasped, seen,
which has the converse
to understand, comprehend, grasp, see = to get to know.
The reason why the first answer needs elaboration is that you may
use know in English both in the sense of having understood and in
the sense of getting to understand. Now, the first of the preceding
on the meanings of the logical constants 21
two equations brings to expression something which is deeply rooted
in the Indo-European languages. For instance, Gr. oU'da, I know, is the
perfect form of the verb whose present form is Gr. eO`dw, I see. Thus
to know is to have seen merely by the way the verb has been formed
in Greek. It is entirely similar in Latin. You have Lat. nosco, I get to
know, which has present form, and Lat. novi, I know, which has perfect
form. So, in these and other languages, the verb to know has present
sense but perfect form. And the reason for the perfect form is that to
know is to have seen. Observe also the two metaphors for the act of
understanding which you seem to have in one form or the other in all
European languages: the metaphor of seeing, first of all, which was so
much used by the Greeks, and which we still use, for instance, when
saying that we see that there are infinitely many prime numbers, and,
secondly, the metaphor of grasping, which you also find in the verb to
comprehend, derived as it is from Lat. prehendere, to seize. The same
metaphor is found in Ger. fassen and begreifen, and I am sure that you
also have it in Italian. (Chorus. Afferare!) Of course, these are two
metaphors that we use for this particular act of the mind: the mental
act of understanding is certainly as different from the perceptual act
of seeing something as from the physical act of grasping something.
Is a judgement a judgement already before it is grasped, that is,
becomes known, or does it become a judgement only through our act
of judging? And, in the latter case, what should we call a judgement
before it has been judged, that is, has become known? For example, if
you let G be the proposition that every even number is the sum of two
prime numbers, and then look at
G is true,
is it a judgement, or is it not a judgement? Clearly, in one sense, it
is, and, in another sense, it is not. It is not a judgement in the sense
that it is not known, that is, that it has not been proved, or grasped.
But, in another sense, it is a judgement, namely, in the sense that G
is true makes perfectly good sense, because G is a proposition which
we all understand, and, presumably, we understand what it means
for a proposition to be true. The distinction I am hinting at is the
distinction which was traditionally made between an enunciation and a
proposition. Enunciation is not a word of much currency in English, but
I think that its Italian counterpart has fared better. The origin is the
Gr. C'pi`fansij as it appears in De Interpretatione, the second part of
the Organon. It has been translated into Lat. enuntiatio, It. enunciato,
and Ger. Aussage. An enunciation is what a proposition, in the old
sense of the word, is before it has been proved, or become known. Thus
22 per martin-l"of
it is a proposition stripped of its epistemic force. For example, in this
traditional terminology, which would be fine if it were still living, G is
true is a perfectly good enunciation, but it is not a proposition, not yet
at least. But now that we have lost the term proposition in its old sense,
having decided to use it in the sense in which it started to be used by
Russell and is now used in Anglo-Saxon philosophy and modern logic,
I think we must admit that we have also lost the traditional distinction
between an enunciation and a proposition. Of course, we still have
the option of keeping the term enunciation, but it is no longer natural.
Instead, since I have decided to replace the term proposition in its old
sense, as that which we prove and which may appear as premise or
conclusion of a logical inference, by the term judgement, as it has been
used in German philosophy from Kant and onwards, it seems better,
when there is a need of making the distinction between an enunciation
and a proposition, that is, between a judgement before and after it has
been proved, or become known, to speak of a judgement and an evident
judgement, respectively. This is a wellestablished usage in the writings
of Bolzano, Brentano, and Husserl, that is, within the objectivistically
oriented branch of German philosophy that I mentioned earlier. If we
adopt this terminology, then we are faced with a fourfold table, which
I shall end by writing up.
judgement proposition
evident judgement true proposition
Thus, correlated with the distinction between judgement and proposition, there is the distinction between evidence of a judgement and
truth of a proposition.
So far, I have said very little about the notions of proposition and
truth. The essence of what I have said is merely that to judge is the
same as to know, so that an evident judgement is the same as a piece,
or an object, of knowledge, in agreement with Bolzano's definition of
knowledge as evident judgement. Tomorrow's lecture will have to be
taken up by an attempt to clarify the notion of evidence and the notions
of proposition and truth.
Second lecture
Under what condition is it right, or correct, to make a judgement,
one of the form
A is true,
on the meanings of the logical constants 23
which is certainly the most basic form of judgement, for instance?
When one is faced with this question for the first time, it is tempting to answer simply that it is right to say that A is true provided that
A is true, and that it is wrong to say that A is true provided that A is
not true, that is, provided that A is false. In fact, this is what Aristotle
says in his definition of truth in the Metaphysics. For instance, he says
that it is not because you rightly say that you are white that you are
white, but because you are white that what you say is correct. But a
moment's reflection shows that this first answer is simply wrong. Even
if every even number is the sum of two prime numbers, it is wrong of
me to say that unless I know it, that is, unless I have proved it. And it
would have been wrong of me to say that every map can be coloured
by four colours before the recent proof was given, that is, before I acquired that knowledge, either by understanding the proof myself, or
by trusting its discoverers. So the condition for it to be right of me to
affirm a proposition A, that is, to say that A is true, is not that A is
true, but that I know that A is true. This is a point which has been
made by Dummett and, before him, by Brentano, who introduced the
apt term blind judgement for a judgement which is made by someone
who does not know what he is saying, although what he says is correct
in the weaker sense that someone else knows it, or, perhaps, that he
himself gets to know it at some later time. When you are forced into
answering a yes or no question, although you do not know the answer,
and happen to give the right answer, right as seen by someone else, or
by you yourself when you go home and look it up, then you make a
blind judgement. Thus you err, although the teacher does not discover
your error. Not to speak of the fact that the teacher erred more greatly
by not giving you the option of giving the only the answer which would
have been honest, namely, that you did not know.
The preceding consideration does not depend on the particular form
of judgement, in this case, A is true, that I happened to use as an
example. Quite generally, the condition for it to be right of you to
make a judgement is that you know it, or, what amounts to the same,
that it is evident to you. The notion of evidence is related to the notion
of knowledge by the equation
evident = known.
When you say that a judgement is evident, you merely express that
you have understood, comprehended, grasped, or seen it, that is, that
you know it, because to have understood is to know. This is reflected
in the etymology of the word evident, which comes from Lat. ex, out
of, from, and videre, to see, in the metaphorical sense, of course.
24 per martin-l"of
There is absolutely no question of a judgement being evident in
itself, independently of us and our cognitive activity. That would be
just as absurd as to speak of a judgement as being known, not by
somebody, you or me, but in itself. To be evident is to be evident to
somebody, as inevitably as to be known is to be known by somebody.
That is what Brouwer meant by saying, in Consciousness, Philosophy,
and Mathematics, that there are no nonexperienced truths, a basic
intuitionistic tenet. This has been puzzling, because it has been understood as referring to the truth of a proposition, and clearly there are
true propositions whose truth has not been experienced, that is, propositions which can be shown to be true in the future, although they have
not been proved to be true now. But what Brouwer means here is not
that. He does not speak about propositions and truth: he speaks about
judgements and evidence, although he uses the term truth instead of
the term evidence. And what he says is then perfectly right: there is
no evident judgement whose evidence has not been experienced, and
experience it is what you do when you understand, comprehend, grasp,
or see it. There is no evidence outside our actual or possible experience of it. The notion of evidence is by its very nature subject related,
relative to the knowing subject, that is, in Kantian terminology.
As I already said, when you make, or utter, a judgement under
normal circumstances, you thereby express that you know it. There is
no need to make this explicit by saying,
I know that . . .
For example, when you make a judgement of the form
A is true
under normal circumstances, by so doing, you already express that you
know that A is true, without having to make this explicit by saying,
I know that A is true,
or the like. A judgement made under normal circumstances claims by
itself to be evident: it carries its claim of evidence automatically with
it. This is a point which was made by Wittgenstein in the Tractatus
by saying that Frege's Urteilsstrich, judgement stroke, is logically quite
meaningless, since it merely indicates that the proposition to which it
is prefixed is held true by the author, although it would perhaps have
been better to say, not that it is meaningless, but that it is superfluous,
since, when you make a judgement, it is clear already from its form that
you claim to know it. In speech act philosophy, this is expressed by
on the meanings of the logical constants 25
saying that knowing is an illocutionary force: it is not an explicit part
of what you say that you know it, but it is implicit in your saying of
it. This is the case, not only with judgements, that is, acts of knowing,
but also with other kinds of acts. For instance, if you say,
Would she come tonight!
it is clear from the form of your utterance that you express a wish.
There is no need of making this explicit by saying,
I wish that she would come tonight.
Some languages, like Greek, use the optative mood to make it clear
that an utterance expresses a wish or desire.
Consider the pattern that we have arrived at now,
I
act
z ""-- -know objectz ""-- -
A is true
Here the grammatical subject I refers to the subject, self, or ego, and
the grammatical predicate know to the act, which in this particular
case is an act of knowing, but might as well have been an act of conjecturing, doubting, wishing, fearing, etc. Thus the predicate know
indicates the modality of the act, that is, the way in which the subject
relates to the object, or the particular force which is involved, in this
case, the epistemic force. Observe that the function of the grammatical
moods, indicative, subjunctive, imperative, and optative, is to express
modalities in this sense. Finally, A is true is the judgement or, in general, the object of the act, which in this case is an object of knowledge,
but might have been an object of conjecture, doubt, wish, fear, etc.
The closest possible correspondence between the analysis that I am
giving and Frege's notation for a judgement
` A
is obtained by thinking of the vertical, judgement stroke as carrying
the epistemic force
I know . . .
and the horizontal, content stroke as expressing the affirmation
. . . is true.
26 per martin-l"of
Then it is the vertical stroke which is superfluous, whereas the horizontal stroke is needed to show that the judgement has the form of an
affirmation. But this can hardly be read out of Frege's own account of
the assertion sign: you have to read it into his text.
What is a judgement before it has become evident, or known? That
is, of the two, judgement and evident judgement, how is the first to be
defined? The characteristic of a judgement in this sense is merely that
it has been laid down what knowledge is expressed by it, that is, what
you must know in order to have the right to make, or utter, it. And
this is something which depends solely on the form of the judgement.
For example, if we consider the two forms of judgement
A is a proposition
and
A is true,
then there is something that you must know in order to have the right
to make a judgement of the first form, and there is something else
which you must know, in addition, in order to have the right to make
a judgement of the second form. And what you must know depends
in neither case on A, but only on the form of the judgement, . . . is
a proposition or . . . is true, respectively. Quite generally, I may say
that a judgement in this sense, that is, a not yet known, and perhaps
even unknowable, judgement, is nothing but an instance of a form
of judgement, because it is for the various forms of judgement that
I lay down what you must know in order to have the right to make
a judgement of one of those forms. Thus, as soon as something has
the form of a judgement, it is already a judgement in this sense. For
example, A is a proposition is a judgement in this sense, because it
has a form for which I have laid down, or rather shall lay down, what
you must know in order to have the right to make a judgement of that
form. I think that I may make things a bit clearer by showing again
in a picture what is involved here. Let me take the first form to begin
with.
I
evident judgement
z ""-- -
know
judgement
z ""-- -\Upsilon
\Sigma
\Xi
\Pi
\Lambda
\Theta
\Gamma
\Delta A is a proposition
expression\Delta \Delta form of judgementA
on the meanings of the logical constants 27
Here is involved, first, an expression A, which should be a complete
expression. Second, we have the form . . . is a proposition, which is
the form of judgement. Composing these two, we arrive at A is a
proposition, which is a judgement in the first sense. And then, third,
we have the act in which I grasp this judgement, and through which it
becomes evident. Thus it is my act of grasping which is the source of
the evidence. These two together, that is, the judgement and my act
of grasping it, become the evident judgement. And a similar analysis
can be given of a judgement of the second form.
I
evident judgement
z ""-- -
know
judgement
z ""-- -\Upsilon
\Sigma
\Xi
\Pi
\Lambda
\Theta
\Gamma
\Delta A is true
proposition\Delta \Delta form of judgementA
Such a judgement has the form . . . is true, but what fills the open place,
or hole, in the form is not an expression any longer, but a proposition.
And what is a proposition? A proposition is an expression for which
the previous judgement has already been grasped, because there is no
question of something being true unless you have previously grasped it
as a proposition. But otherwise the picture remains the same here.
Now I must consider the discussion of the notion of judgement finished and pass on to the notion of proof. Proof is a good word, because,
unlike the word proposition, it has not changed its meaning. Proof apparently means the same now as it did when the Greeks discovered
the notion of proof, and therefore no terminological difficulties arise.
Observe that both Lat. demonstratio and the corresponding words in
the modern languages, like It. dimostrazione, Eng. demonstration, and
Ger. Beweis, are literal translations of Gr. C'pi`deicij, deriving as it does
from Gr. deDHknumi, I show, which has the same meaning as Lat. monstrare and Ger. weisen.
If you want to have a first approximation to the notion of proof, a
first definition of what a proof is, the strange thing is that you cannot look it up in any modern textbook of logic, because what you get
out of the standard textbooks of modern logic is the definition of what
a formal proof is, at best with a careful discussion clarifying that a
formal proof in the sense of this definition is not what we ordinarily
call a proof in mathematics. That is, you get a formal proof defined
as a finite sequence of formulas, each one of them being an immediate
consequence of some of the preceding ones, where the notion of immediate consequence, in turn, is defined by saying that a formula is an
28 per martin-l"of
immediate consequence of some other formulas if there is an instance
of one of the figures, called rules of inference, which has the other formulas as premises and the formula itself as conclusion. Now, this is not
what a real proof is. That is why you have the warning epithet formal
in front of it, and do not simply say proof.
What is a proof in the original sense of the word? The ordinary
dictionary definition says, with slight variations, that a proof is that
which establishes the truth of a statement. Thus a proof is that which
makes a mathematical statement, or enunciation, into a theorem, or
proposition, in the old sense of the word which is retained in mathematics. Now, remember that I have reserved the term true for true
propositions, in the modern sense of the word, and that the things
that we prove are, in my terminology, judgements. Moreover, to avoid
terminological confusion, judgements qualify as evident rather than
true. Hence, translated into the terminology that I have decided upon,
the dictionary definition becomes simply,
A proof is what makes a judgement evident.
Accepting this, that is, that the proof of a judgement is that which
makes it evident, we might just as well say that the proof of a judgement is the evidence for it. Thus proof is the same as evidence. Combining this with the outcome of the previous discussion of the notion of
evidence, which was that it is the act of understanding, comprehending, grasping, or seeing a judgement which confers evidence on it, the
inevitable conclusion is that the proof of a judgement is the very act
of grasping it. Thus a proof is, not an object, but an act. This is what
Brouwer wanted to stress by saying that a proof is a mental construction, because what is mental, or psychic, is precisely our acts, and the
word construction, as used by Brouwer, is but a synonym for proof.
Thus he might just as well have said that the proof of a judgement is
the act of proving, or grasping, it. And the act is primarily the act as it
is being performed. Only secondarily, and irrevocably, does it become
the act that has been performed.
As is often the case, it might have been better to start with the verb
rather than the noun, in this case, with the verb to prove rather than
with the noun proof. If a proof is what makes a judgement evident,
then, clearly, to prove a judgement is to make it evident, or known.
To prove something to yourself is simply to get to know it. And to
prove something to someone else is to try to get him, or her, to know
it. Hence
to prove = to get to know = to understand,
comprehend, grasp, or see.
on the meanings of the logical constants 29
This means that prove is but another synonym for understand, comprehend, grasp, or see. And, passing to the perfect tense,
to have proved = to know = to have understood,
comprehended, grasped, or seen.
We also speak of acquiring and possessing knowledge. To possess
knowledge is the same as to have acquired it, just as to know something
is the same as to have understood, comprehended, grasped, or seen it.
Thus the relation between the plain verb to know and the venerable
expressions to acquire and to possess knowledge is given by the two
equations,
to get to know = to acquire knowledge
and
to know = to possess knowledge.
On the other hand, the verb to prove and the noun proof are related
by the two similar equations,
to prove = to acquire, or construct, a proof
and
to have proved = to possess a proof.
It is now manifest, from these equations, that proof and knowledge are
the same. Thus, if proof theory is construed, not in Hilbert's sense,
as metamathematics, but simply as the study of proofs in the original
sense of the word, then proof theory is the same as theory of knowledge,
which, in turn, is the same as logic in the original sense of the word, as
the study of reasoning, or proof, not as metamathematics.
Remember that the proof of a judgement is the very act of knowing
it. If this act is atomic, or indivisible, then the proof is said to be immediate. Otherwise, that is, if the proof consists of a whole sequence,
or chain, of atomic actions, it is mediate. And, since proof and knowledge are the same, the attributes immediate and mediate apply equally
well to knowledge. In logic, we are no doubt more used to saying of
inferences, rather than proofs, that they are immediate or mediate, as
the case may be. But that makes no difference, because inference and
proof are the same. It does not matter, for instance, whether we say
rules of inference or proof rules, as has become the custom in programming. And, to take another example, it does not matter whether we
say that a mediate proof is a chain of immediate inferences or a chain
30 per martin-l"of
of immediate proofs. The notion of formal proof that I referred to in
the beginning of my discussion of the notion of proof has been arrived
at by formalistically interpreting what you mean by an immediate inference, by forgetting about the difference between a judgement and
a proposition, and, finally, by interpreting the notion of proposition
formalistically, that is, by replacing it by the notion of formula. But a
real proof is and remains what it has always been, namely, that which
makes a judgement evident, or simply, the evidence for it. Thus, if we
do not have the notion of evidence, we do not have the notion of proof.
That is why the notion of proof has fared so badly in those branches
of philosophy where the notion of evidence has fallen into disrepute.
We also speak of a judgement being immediately and mediately
evident, respectively. Which of the two is the case depends of course on
the proof which constitutes the evidence for the judgement. If the proof
is immediate, then the judgement is said to be immediately evident.
And an immediately evident judgement is what we call an axiom. Thus
an axiom is a judgement which is evident by itself, not by virtue of
some previously proved judgements, but by itself, that is, a self-evident
judgement, as one has always said. That is, always before the notion
of evidence became disreputed, in which case the notion of axiom and
the notion of proof simply become deflated: we cannot make sense
of the notion of axiom and the notion of proof without access to the
notion of evidence. If, on the other hand, the proof which constitutes
the evidence for a judgement is a mediate one, so that the judgement
is evident, not by itself, but only by virtue of some previously proved
judgements, then the judgement is said to be mediately evident. And
a mediately evident judgement is what we call a theorem, as opposed
to an axiom. Thus an evident judgement, that is, a proposition in the
old sense of the word which is retained in mathematics, is either an
axiom or a theorem.
Instead of applying the attributes immediate and mediate to proof,
or knowledge, I might have chosen to speak of intuitive and discursive
proof, or knowledge, respectively. That would have implied no difference of sense. The proof of an axiom can only be intuitive, which is
to say that an axiom has to be grasped immediately, in a single act.
The word discursive, on the other hand, comes from Lat. discurrere,
to run to and fro. Thus a discursive proof is one which runs, from
premises to conclusion, in several steps. It is the opposite of an intuitive proof, which brings you to the conclusion immediately, in a single
step. When one says that the immediate propositions in the old sense
of the word proposition, that is, the immediately evident judgements
in my terminology, are unprovable, what is meant is of course only that
on the meanings of the logical constants 31
they cannot be proved discursively. Their proofs have to rest intuitive.
This seems to be all that I have to say about the notion of proof at the
moment, so let me pass on to the next item on the agenda, the forms
of judgement and their semantical explanations.
The forms of judgement have to be displayed in a table, simply,
and the corresponding semantical explanations have to be given, one
for each of those forms. A form of judgement is essentially just what
is called a category, not in the sense of category theory, but in the
logical, or philosophical, sense of the word. Thus I have to say what
my forms of judgement, or categories, are, and, for each one of those
forms, I have to explain what you must know in order to have the right
to make a judgement of that form. By the way, the forms of judgement
have to be introduced in a specific order. Actually, not only the forms
of judgement, but all the notions that I am undertaking to explain
here have to come in a specific order. Thus, for instance, the notion
of judgement has to come before the notion of proposition, and the
notion of logical consequence has to be dealt with before explaining
the notion of implication. There is an absolute rigidity in this order.
The notion of proof, for instance, has to come precisely where I have
put it here, because it is needed in some other explanations further on,
where it is presupposed already. Revealing this rigid order, thereby
arriving eventually at the concepts which have to be explained prior
to all other concepts, turns out to be surprisingly difficult: you seem
to arrive at the very first concepts last of all. I do not know what
it should best be called, maybe the order of conceptual priority, one
concept being conceptually prior to another concept if it has to be
explained before the other concept can be explained.
Let us now consider the first form of judgement,
A is a proposition,
or, as I shall continue to abbreviate it,
A prop.
What I have just displayed to you is a linguistic form, and I hope that
you can recognize it. What you cannot see from the form, and which
I therefore proceed to explain to you, is of course its meaning, that is,
what knowledge is expressed by, or embodied in, a judgement of this
form. The question that I am going to answer is, in ontological terms,
What is a proposition?
This is the usual Socratic way of formulating questions of this sort. Or
I could ask, in more knowledge theoretical terminology,
32 per martin-l"of
What is it to know a proposition?
or, if you prefer,
What knowledge is expressed by a judgement
of the form A is a proposition?
or, this may be varied endlessly,
What does a judgement of the form A is a proposition mean?
These various ways of posing essentially the same question reflect
roughly the historical development, from a more ontological to a more
knowledge theoretical way of posing, and answering, questions of this
sort, finally ending up with something which is more linguistic in nature, having to do with form and meaning.
Now, one particular answer to this question, however it be formulated, is that a proposition is something that is true or false, or, to use
Aristotle's formulation, that has truth or falsity in it. Here we have
to be careful, however, because what I am going to explain is what a
proposition in the modern sense is, whereas what Aristotle explained
was what an enunciation, being the translation of Gr. C'pi`fansij, is.
And it was this explanation that he phrased by saying that an enunciation is something that has truth or falsity in it. What he meant by
this was that it is an expression which has a form of speech such that,
when you utter it, you say something, whether truly or falsely. That
is certainly not how we now interpret the definition of a proposition as
something which is true or false, but it is nevertheless correct that it
echoes Aristotle's formulation, especially in its symmetric treatment of
truth and falsity.
An elaboration of the definition of a proposition as something that
is true or false is to say that a proposition is a truth value, the true
or the false, and hence that a declarative sentence is an expression
which denotes a truth value, or is the name of a truth value. This
was the explanation adopted by Frege in his later writings. If a proposition is conceived in this way, that is, simply as a truth value, then
there is no difficulty in justifying the laws of the classical propositional
calculus and the laws of quantification over finite, explicitly listed, domains. The trouble arises when you come to the laws for forming
quantified propositions, the quantifiers not being restricted to finite
domains. That is, the trouble is to make the two laws
A(x) prop
(8x)A(x) prop
A(x) prop
(9x)A(x) prop
on the meanings of the logical constants 33
evident when propositions are conceived as nothing but truth values.
To my mind, at least, they simply fail to be evident. And I need not
be ashamed of the reference to myself in this connection: as I said
in my discussion of the notion of evidence, it is by its very nature
subject related. Others must make up their minds whether these laws
are really evident to them when they conceive of propositions simply
as truth values. Although we have had this notion of proposition and
these laws for forming quantified propositions for such a long time,
we still have no satisfactory explanations which serve to make them
evident on this conception of the notion of proposition. It does not
help to restrict the quantifiers, that is, to consider instead the laws
(x 2 A)
B(x) prop
(8x 2 A)B(x) prop
(x 2 A)
B(x) prop
(9x 2 A)B(x) prop
unless we restrict the quantifiers so severely as to take the set A here
to be a finite set, that is, to be given by a list of its elements. Then, of
course, there is no trouble with these rules. But, as soon as A is the set
of natural numbers, say, you have the full trouble already. Since, as I
said earlier, the law of the excluded middle, indeed, all the laws of the
classical propositional calculus, are doubtlessly valid on this conception
of the notion of proposition, this means that the rejection of the law
of excluded middle is implicitly also a rejection of the conception of a
proposition as something which is true or false. Hence the rejection of
this notion of proposition is something which belongs to Brouwer. On
the other hand, he did not say explicitly by what it should be replaced.
Not even the wellknown papers by Kolmogorov and Heyting, in which
the formal laws of intuitionistic logic were formulated for the first time,
contain any attempt at explaining the notion of proposition in terms of
which these laws become evident. It appears only in some later papers
by Heyting and Kolmogorov from the early thirties. In the first of these,
written by Heyting in 1930, he suggested that we should think about
a proposition as a problem, Fr. probl`eme, or expectation, Fr. attente.
And, in the wellknown paper of the following year, which appeared
in Erkenntnis, he used the terms expectation, Ger. Erwartung, and
intention, Ger. Intention. Thus he suggested that one should think of
a proposition as a problem, or as an expectation, or as an intention.
And, another year later, there appeared a second paper by Kolmogorov,
in which he observed that the laws of the intuitionistic propositional
calculus become evident upon thinking of the propositional variables
as ranging over problems, or tasks. The term he actually used was
34 per martin-l"of
Ger. Aufgabe. On the other hand, he explicitly said that he did not
want to equate the notion of proposition with the notion of problem
and, correlatively, the notion of truth of a proposition with the notion
of solvability of a problem. He merely proposed the interpretation of
propositions as problems, or tasks, as an alternative interpretation,
validating the laws of the intuitionistic propositional calculus.
Returning now to the form of judgement
A is a proposition,
the semantical explanation which goes together with it is this, and here
I am using the knowledge theoretical formulation, that to know a proposition, which may be replaced, if you want, by problem, expectation,
or intention, you must know what counts as a verification, solution,
fulfillment, or realization of it. Here verification matches with proposition, solution with problem, fulfillment with expectation as well as
with intention, and realization with intention. Realization is the term
introduced by Kleene, but here I am of course not using it in his sense:
Kleene's realizability interpretation is a nonstandard, or nonintended,
interpretation of intuitionistic logic and arithmetic. The terminology
of intention and fulfillment was taken over by Heyting from Husserl, via
Oskar Becker, apparently. There is a long chapter in the sixth, and last,
of his Logische Untersuchungen which bears the title Bedeutungsintention und Bedeutungserf"ullung, and it is these two terms, intention and
fulfillment, Ger. Erf"ullung, that Heyting applied in his analysis of the
notions of proposition and truth. And he did not just take the terms
from Husserl: if you observe how Husserl used these terms, you will see
that they were appropriately applied by Heyting. Finally, verification
seems to be the perfect term to use together with proposition, coming
as it does from Lat. verus, true, and facere, to make. So to verify is to
make true, and verification is the act, or process, of verifying something.
For a long time, I tried to avoid using the term verification, because
it immediately gives rise to discussions about how the present account
of the notions of proposition and truth is related to the verificationism
that was discussed so much in the thirties. But, fortunately, this is fifty
years ago now, and, since we have a word which lends itself perfectly
to expressing what needs to be expressed, I shall simply use it, without
wanting to get into discussion about how the present semantical theory
is related to the verificationism of the logical positivists.
What would an example be? If you take a proposition like,
The sun is shining,
on the meanings of the logical constants 35
to know that proposition, you must know what counts as a verification
of it, which in this case would be the direct seeing of the shining sun.
Or, if you take the proposition,
The temperature is 10ffi C,
then it would be a direct thermometer reading. What is more interesting, of course, is what the corresponding explanations look like for the
logical operations, which I shall come to in my last lecture.
Coupled with the preceding explanation of what a proposition is, is
the following explanation of what a truth is, that is, of what it means
for a proposition to be true. Assume first that
A is a proposition,
and, because of the omnipresence of the epistemic force, I am really
asking you to assume that you know, that is, have grasped, that A
is a proposition. On that assumption, I shall explain to you what a
judgement of the form
A is true,
or, briefly,
A true,
means, that is, what you must know in order to have the right to
make a judgement of this form. And the explanation would be that, to
know that a proposition is true, a problem is solvable, an expectation
is fulfillable, or an intention is realizable, you must know how to verify,
solve, fulfill, or realize it, respectively. Thus this explanation equates
truth with verifiability, solvability, fulfillability, or realizability. The
important point to observe here is the change from is in A is true to
can in A can be verified, or A is verifiable. Thus what is expressed in
terms of being in the first formulation really has the modal character
of possibility.
Now, as I said earlier in this lecture, to know a judgement is the
same as to possess a proof of it, and to know a judgement of the
particular form A is true is the same as to know how, or be able, to
verify the proposition A. Thus knowledge of a judgement of this form
is knowledge how in Ryle's terminology. On the other hand, to know
how to do something is the same as to possess a way, or method, of
doing it. This is reflected in the etymology of the word method, which
is derived from Gr. metL', after, and a*di`j, way. Taking all into account,
we arrive at the conclusion that a proof that a proposition A is true
36 per martin-l"of
is the same as a method of verifying, solving, fulfilling, or realizing A.
This is the explanation for the frequent appearance of the word method
in Heyting's explanations of the meanings of the logical constants. In
connection with the word method, notice the tendency of our language
towards hypostatization. I can do perfectly well without the concept of
method in my semantical explanations: it is quite sufficient for me to
have access to the expression know how, or knowledge how. But it is in
the nature of our language that, when we know how to do something,
we say that we possess a method of doing it.
Summing up, I have now explained the two forms of categorical
judgement,
A is a proposition
and
A is true,
respectively, and they are the only forms of categorical judgement that
I shall have occasion to consider. Observe that knowledge of a judgement of the second form is knowledge how, more precisely, knowledge
how to verify A, whereas knowledge of a judgement of the first form
is knowledge of a problem, expectation, or intention, which is knowledge what to do, simply. Here I am introducing knowledge what as a
counterpart of Ryle's knowledge how. So the difference between these
two kinds of knowledge is the difference between knowledge what to do
and knowledge how to do it. And, of course, there can be no question
of knowing how to do something before you know what it is that is to
be done. The difference between the two kinds of knowledge is a categorical one, and, as you see, what Ryle calls knowledge that, namely,
knowledge that a proposition is true, is equated with knowledge how
on this analysis. Thus the distinction between knowledge how and
knowledge that evaporates on the intuitionistic analysis of the notion
of truth.
Third lecture
The reason why I said that the word verification may be dangerous
is that the principle of verification formulated by the logical positivists
in the thirties said that a proposition is meaningful if and only if it is
verifiable, or that the meaning of a proposition is its method of verification. Now that is to confuse meaningfulness and truth. I have
indeed used the word verifiable and the expression method of verification. But what is equated with verifiability is not the meaningfulness
on the meanings of the logical constants 37
but the truth of a proposition, and what qualifies as a method of verification is a proof that a proposition is true. Thus the meaning of a
proposition is not its method of verification. Rather, the meaning of a
proposition is determined by what it is to verify it, or what counts as
a verification of it.
The next point that I want to bring up is the question,
Are there propositions which are true,
but which cannot be proved to be true?
And it suffices to think of mathematical propositions here, like the
Goldbach conjecture, the Riemann hypothesis, or Fermat's last theorem. This fundamental question was once posed to me outright by a
colleague of mine in the mathematics department, which shows that
even working mathematicians may find themselves puzzled by deep
philosophical questions. At first sight, at least, there seem to be two
possible answers to this question. One is simply,
No,
and the other is,
Perhaps,
although it is of course impossible for anybody to exhibit an example
of such a proposition, because, in order to do that, he would already
have to know it to be true. If you are at all puzzled by this question,
it is an excellent subject of meditation, because it touches the very
conflict between idealism and realism in the theory of knowledge, the
first answer, No, being indicative of idealism, and the second answer,
Perhaps, of realism. It should be clear, from any point of view, that
the answer depends on how you interpret the three notions in terms
of which the question is formulated, that is, the notion of proposition,
the notion of truth, and the notion of proof. And it should already be
clear, I believe, from the way in which I have explained these notions,
that the question simply ceases to be a problem, and that it is the first
answer which is favoured.
To see this, assume first of all that A is a proposition, or problem.
Then
A is true
is a judgement which gives rise to a new problem, namely, the problem
of proving that A is true. To say that that problem is solvable is precisely the same as saying that the judgement that A is true is provable.
Now, the solvability of a problem is always expressed by a judgement.
Hence
38 per martin-l"of
(A is true) is provable
is a new judgement. What I claim is that we have the right to make this
latter judgement if and only if we have the right to make the former
judgement, that is, that the proof rule
A is true
(A is true) is provable
as well as its inverse
(A is true) is provable
A is true
are both valid. This is the sense of saying that A is true if and only if
A can be proved to be true. To justify the first rule, assume that you
know its premise, that is, that you have proved that A is true. But, if
you have proved that A is true, then you can, or know how to, prove
that A is true, which is what you need to know in order to have the
right to judge the conclusion. In this step, I have relied on the principle
that, if something has been done, then it can be done. To justify the
second rule, assume that you know its premise, that is, that you know
how to prove the judgement A is true. On that assumption, I have to
explain the conclusion to you, which is to say that I have to explain
how to verify the proposition A. This is how you do it. First, put your
knowledge of the premise into practice. That yields as result a proof
that A is true. Now, such a proof is nothing but knowledge how to
verify, or a method of verifying, the proposition A. Hence, putting it,
in turn, into practice, you end up with a verification of the proposition
A, as required. Observe that the inference in this direction is essentially
a contraction of two possibilities into one: if you know how to know
how to do something, then you know how to do it.
All this is very easy to say, but, if one is at all puzzled by the question whether there are unprovable truths, then it is not an easy thing to
make up one's mind about. For instance, it seems, from Heyting's writings on the semantics of intuitionistic logic in the early thirties, that
he had not arrived at this position at that time. The most forceful and
persistent criticism of the idea of a knowledge independent, or knowledge transcendent, notion of truth has been delivered by Dummett,
although it seems difficult to find him ever explicitly committing himself in his writings to the view that, if a proposition is true, then it can
also be proved to be true. Prawitz seems to be leaning towards this
nonrealistic principle of truth, as he calls it, in his paper Intuitionistic
on the meanings of the logical constants 39
Logic: A Philosophical Challenge. And, in his book Det Os"agbara,
printed in the same year, Stenlund explicitly rejects the idea of true
propositions that are in principle unknowable. The Swedish proof theorists seem to be arriving at a common philosophical position.
Next I have to say something about hypothetical judgements, before I proceed to the final piece, which consists of the explanations
of the meanings of the logical constants and the justifications of the
logical laws. So far, I have only introduced the two forms of categorical judgement A is a proposition and A is true. The only forms of
judgement that I need to introduce, besides these, are forms of hypothetical judgement. Hypothetical means of course the same as under
assumptions. The Gr. I'pi`qesij, hypothesis, was translated into Lat.
suppositio, supposition, and they both mean the same as assumption.
Now, what is the rule for making assumptions, quite generally? It is
simple. Whenever you have a judgement in the sense that I am using
the word, that is, a judgement in the sense of an instance of a form of
judgement, then it has been laid down what you must know in order
to have the right to make it. And that means that it makes perfectly
good sense to assume it, which is the same as to assume that you know
it, which, in turn, is the same as to assume that you have proved it.
Why is it the same to assume it as to assume that you know it? Because of the constant tacit convention that the epistemic force, I know
. . . , is there, even if it is not made explicit. Thus, when you assume
something, what you do is that you assume that you know it, that is,
that you have proved it. And, to repeat, the rule for making assumptions is simply this: whenever you have a judgement, in the sense of an
instance of a form of judgement, you may assume it. That gives rise
to the notion of hypothetical judgement and the notion of hypothetical
proof, or proof under hypotheses.
The forms of hypothetical judgement that I shall need are not so
many. Many more can be introduced, and they are needed for other
purposes. But what is absolutely necessary for me is to have access to
the form
A1 true; : : : ; An true j A prop;
which says that A is a proposition under the assumptions that
A1; : : : ; An are all true, and, on the other hand, the form
A1 true; : : : ; An true j A true;
which says that the proposition A is true under the assumptions that
A1; : : : ; An are all true. Here I am using the vertical bar for the relation
of logical consequence, that is, for what Gentzen expressed by means of
40 per martin-l"of
the arrow ! in his sequence calculus, and for which the double arrow
) is also a common notation. It is the relation of logical consequence,
which must be carefully distinguished from implication. What stands
to the left of the consequence sign, we call the hypotheses, in which
case what follows the consequence sign is called the thesis, or we call
the judgements that precede the consequence sign the antecedents and
the judgement that follows after the consequence sign the consequent.
This is the terminology which Gentzen took over from the scholastics,
except that, for some reason, he changed consequent into succedent and
consequence into sequence, Ger. Sequenz, usually improperly rendered
by sequent in English.
hypothetical judgement
(logical) consequence
z ""-- -
A1 true; : : : ; An true j A prop
A1 true; : : : ; An true j A true
-- -z "" -- -z ""
antecedents consequent
hypotheses thesis
Since I am making the assumptions A1 true; : : : ; An true, I must be
presupposing something here, because, surely, I cannot make those
assumptions unless they are judgements. Specifically, in order for A1
true to be a judgement, A1 must be a proposition, and, in order for
A2 true to be a judgement, A2 must be a proposition, but now merely
under the assumption that A1 is true, . . . , and, in order for An true
to be a judgement, An must be a proposition under the assumptions
that A1; : : : ; An\Gamma 1 are all true. Unlike in Gentzen's sequence calculus,
the order of the assumptions is important here. This is because of the
generalization that something being a proposition may depend on other
things being true. Thus, for the assumptions to make sense, we must
presuppose
A1 prop;
A1 true j A2 prop;
...
A1 true; : : : ; An\Gamma 1 true j An prop.
Supposing this, that is, supposing that we know this, it makes perfectly
good sense to assume, first, that A1 is true, second, that A2 is true,
. . . , finally, that An is true, and hence
A1 true; : : : ; An true j A prop
on the meanings of the logical constants 41
is a perfectly good judgement whatever expression A is, that is, whatever expression you insert into the place indicated by the variable A.
And why is it a good judgement? To answer that question, I must
explain to you what it is to know such a judgement, that is, what
constitutes knowledge, or proof, of such a judgement. Now, quite generally, a proof of a hypothetical judgement, or logical consequence, is
nothing but a hypothetical proof of the thesis, or consequent, from the
hypotheses, or antecedents. The notion of hypothetical proof, in turn,
which is a primitive notion, is explained by saying that it is a proof
which, when supplemented by proofs of the hypotheses, or antecedents,
becomes a proof of the thesis, or consequent. Thus the notion of categorical proof precedes the notion of hypothetical proof, or inference, in
the order of conceptual priority. Specializing this general explanation
of what a proof of a hypothetical judgement is to the particular form
of hypothetical judgement
A1 true; : : : ; An true j A prop
that we are in the process of considering, we see that the defining
property of a proof
A1 true \Delta \Delta \Delta An true
\Delta \Delta \Delta \Delta \Delta \Delta
A prop
of such a judgement is that, when it is supplemented by proofs
...
A1 true \Delta \Delta \Delta
...
An true
of the hypotheses, or antecedents, it becomes a proof
...
A1 true \Delta \Delta \Delta
...
An true
\Delta \Delta \Delta \Delta \Delta \Delta
A prop
of the thesis, or consequent.
Consider now a judgement of the second form
A1 true; : : : ; An true j A true:
For it to make good sense, that is, to be a judgement, we must know,
not only
42 per martin-l"of
A1 prop;
A1 true j A2 prop;
...
A1 true; : : : ; An\Gamma 1 true j An prop;
as in the case of the previous form of judgement, but also
A1 true; : : : ; An true j A prop:
Otherwise, it does not make sense to ask oneself whether A is true
under the assumptions A1 true, . . . , An true. As with any proof of a
hypothetical judgement, the defining characteristic of a proof
A1 true \Delta \Delta \Delta An true
\Delta \Delta \Delta \Delta \Delta \Delta
A true
of a hypothetical judgement of the second form is that, when supplemented by proofs
...
A1 true \Delta \Delta \Delta
...
An true
of the antecedents, it becomes a categorical proof
...
A1 true \Delta \Delta \Delta
...
An true
\Delta \Delta \Delta \Delta \Delta \Delta
A true
of the consequent.
I am sorry that I have had to be so brief in my treatment of hypothetical judgements, but what I have said is sufficient for the following,
except that I need to generalize the two forms of hypothetical judgement so as to allow generality in them. Thus I need judgements which
are, not only hypothetical, but also general, which means that the first
form is turned into
A1(x1; : : : ; xm) true; : : : ; An(x1; : : : ; xm) true jx1;:::;x
m A(x1; : : : ; xm) prop
and the second form into
A1(x1; : : : ; xm) true; : : : ; An(x1; : : : ; xm) true jx1;:::;x
m A(x1; : : : ; xm) true:
Both of these forms involve a generality, indicated by subscribing the
variables that are being generalized to the consequence sign, which
must be carefully distinguished from, and which must be explained
on the meanings of the logical constants 43
prior to, the generality which is expressed by means of the universal
quantifier. It was only to avoid introducing all complications at once
that I treated the case without generality first. Now, the meaning of
a hypothetico-general judgement is explained by saying that, to have
the right to make such a judgement, you must possess a free variable
proof of the thesis, or consequent, from the hypotheses, or antecedents.
And what is a free variable proof? It is a proof which remains a proof
when you substitute anything you want for its free variables, that is,
any expressions you want, of the same arities as those variables. Thus
A1(x1; : : : ; xm) true \Delta \Delta \Delta An(x1; : : : ; xm) true
\Delta \Delta \Delta \Delta \Delta \Delta
A(x1; : : : ; xm) prop
is a proof of a hypothetico-general judgement of the first form provided
it becomes a categorical proof
...
A1(a1; : : : ; am) true \Delta \Delta \Delta
...
An(a1; : : : ; am) true
\Delta \Delta \Delta \Delta \Delta \Delta
A(a1; : : : ; am) prop
when you first substitute arbitrary expressions a1; : : : ; am, of the same
respective arities as the variables x1; : : : ; xm, for those variables, and
then supplement it with proofs
...
A1(a1; : : : ; am) true \Delta \Delta \Delta
...
An(a1; : : : ; am) true
of the resulting substitution instances of the antecedents. The explanation of what constitutes a proof of a hypothetico-general judgement
of the second form is entirely similar.
The difference between an inference and a logical consequence, or
hypothetical judgement, is that an inference is a proof of a logical consequence. Thus an inference is the same as a hypothetical proof. Now,
when we infer, or prove, we infer the conclusion from the premises.
Thus, just as a categorical proof is said to be a proof of its conclusion,
a hypothetical proof is said to be a proof, or an inference, of its conclusion from its premises. This makes it clear what is the connection
as well as what is the difference between an inference with its premises
and conclusion on the one hand, and a logical consequence with its
antecedents and consequent on the other hand. And the difference is
precisely that it is the presence of a proof of a logical consequence that
44 per martin-l"of
turns its antecedents into premises and the consequent into conclusion
of the proof in question. For example, if A is a proposition, then
A true j ? true
is a perfectly good logical consequence with A true as antecedent and
? true as consequent, but
A true
? true
is not an inference, not a valid inference, that is, unless A is false. In
that case, only, may the conclusion ? true be inferred from the premise
A true.
Let us now pass on to the rules of inference, or proof rules, and their
semantical explanations. I shall begin with the rules of implication.
Now, since I am treating A is a proposition as a form of judgement,
which is on a par with the form of judgement A is true, what we
ordinarily call formation rules will count as rules of inference, but that
is merely a terminological matter. So let us look at the formation rule
for implication.
oe-formation.
A prop
(A true)
B prop
A oe B prop
This rule says, in words, that, if A is a proposition and B is a proposition provided that A is true, then A oe B is a proposition. In the
second premise, I might just as well have used the notation for logical
consequence
A true j B prop
that I introduced earlier in this lecture, because to have a proof of
this logical consequence is precisely the same as to have a hypothetical
proof of B prop from the assumption A true. But, for the moment, I
shall use the more suggestive notation
(A true)
B prop
in imitation of Gentzen. It does not matter, of course, which notation
of the two that I employ. The meaning is in any case the same.
Explanation. The rule of implication formation is a rule of immediate inference, which means that you must make the conclusion evident
on the meanings of the logical constants 45
to yourself immediately, without any intervening steps, on the assumption that you know the premises. So assume that you do know the
premises, that is, that you know the proposition A, which is to say
that you know what counts as a verification of it, and that you know
that B is a proposition under the assumption that A is true. My obligation is to explain to you what proposition A oe B is. Thus I have
to explain to you what counts as a verification, or solution, of this
proposition, or problem. And the explanation is that what counts as a
verification of A oe B is a hypothetical proof
A true.
..
B true
that B is true under the assumption that A is true. In the Kolmogorov
interpretation, such a hypothetical proof appears as a method of solving
the problem B provided that the problem A can be solved, that is,
a method which together with a method of solving the problem A
becomes a method of solving the problem B. The explanation of the
meaning of implication, which has just been given, illustrates again the
rigidity of the order of conceptual priority: the notions of hypothetical
judgement, or logical consequence, and hypothetical proof have to be
explained before the notion of implication, because, when you explain
implication, they are already presupposed.
Given the preceding explanation of the meaning of implication, it
is not difficult to justify the rule of implication introduction.
oe-introduction. (A true)
B true
A oe B true
As you see, I am writing it in the standard way, although, of course, it
is still presupposed that A is a proposition and that B is a proposition
under the assumption that A is true. Thus you must know the premises
of the formation rule and the premise of the introduction rule in order
to be able to grasp its conclusion.
Explanation. Again, the rule of implication introduction is a rule of
immediate inference, which means that you must make the conclusion
immediately evident to yourself granted that you know the premises,
that is, granted that you possess a hypothetical proof that B is true
from the hypothesis that A is true. By the definition of implication,
such a proof is nothing but a verification of the proposition A oe B.
And what is it that you must know in order to have the right to judge
46 per martin-l"of
A oe B to be true? You must know how to get yourself a verification
of A oe B. But, since you already possess it, you certainly know how
to acquire it: just take what you already have. This is all that there
is to be seen in this particular rule. Observe that its justification rests
again on the principle that, if something has been done, then it can be
done.
Next we come to the elimination rule for implication, which I shall
formulate in the standard way, as modus ponens, although, if you want
all elimination rules to follow the same pattern, that is, the pattern
exhibited by the rules of falsehood, disjunction, and existence elimination, there is another formulation that you should consider, and which
has been considered by Schroeder-Heister. But I shall have to content
myself with the standard formulation in these lectures.
oe-elimination. A oe B true A true
B true
Here it is still assumed, of course, that A is a proposition and that B
is a proposition provided that A is true.
Explanation. This is a rule of immediate inference, so assume that
you know the premises, that is, that you possess proofs
...
A oe B true
and ...
A true
of them, and I shall try to make the conclusion evident to you. Now, by
the definitions of the notion of proof and the notion of truth, the proof
of the first premise is knowledge how to verify the proposition A oe B.
So put that knowledge of yours into practice. What you then end up
with is a verification of A oe B, and, because of the way implication
was defined, that verification is nothing but a hypothetical proof
A true.
..
B true
that B is true from the assumption that A is true. Now take your proof
of the right premise and adjoin it to the verification of A oe B. Then
you get a categorical proof ..
.
A true.
..
B true
on the meanings of the logical constants 47
of the conclusion that B is true. Here, of course, I am implicitly using
the principle that, if you supplement a hypothetical proof with proofs
of its hypotheses, then you get a proof of its conclusion. But this is in
the nature of a hypothetical proof: it is that property which makes a
hypothetical proof into what it is. So now you have a proof that B is
true, a proof which is knowledge how to verify B. Putting it, in turn,
into practice, you end up with a verification of B. This finishes my
explanation of how the proposition B is verified.
In the course of my semantical explanation of the elimination rule
for implication, I have performed certain transformations which are
very much like an implication reduction in the sense of Prawitz. Indeed,
I have explained the semantical role of this syntactical transformation.
The place where it belongs in the meaning theory is precisely in the
semantical explanation, or justification, of the elimination rule for implication. Similarly, the reduction rules for the other logical constants
serve to explain the elimination rules associated with those constants.
The key to seeing the relationship between the reduction rules and
the semantical explanations of the elimination rules is this: to verify
a proposition by putting a proof of yours that it is true into practice
corresponds to reducing a natural deduction to introductory form and
deleting the last inference. This takes for granted, as is in fact the
case, that an introduction is an inference in which you conclude, from
the possession of a verification of a proposition, that you know how to
verify it. In particular, verifying a proposition B by means of a proof
that B is true ...
A oe B true
...
A true
B true
which ends with an application of modus ponens, corresponds to reducing the proof of the left premise to introductory form
(A true).
..
B true
A oe B true
...
A true
B true
then performing an implication reduction in the sense of Prawitz, which
yields the proof
48 per martin-l"of
...
A true.
..
B true
as result, and finally reducing the latter proof to introductory form
and deleting its last, introductory inference. This is the syntactical
counterpart of the semantical explanation of the elimination rule for
implication.
The justifications of the remaining logical laws follow the same pattern. Let me take the rules of conjunction next.
& -formation.
A prop B prop
A & B prop
Explanation. Again, assume that you know the premises, and I
shall explain the conclusion to you, that is, I shall tell you what counts
as a verification of A & B. The explanation is that a verification of
A & B consists of a proof that A is true and a proof that B is true,
...
A true
and ...
B true
that is, of a method of verifying A and a method of verifying B. In
the Kolmogorov interpretation, A & B appears as the problem which
you solve by constructing both a method of solving A and a method of
solving B.
& -introduction. A true B true
A & B true
Here the premises of the formation rule are still in force, although not
made explicit, which is to say that A and B are still assumed to be
propositions.
Explanation. Assume that you know the premises, that is, that you
possess proofs ..
.
A true
and ...
B true
of them. Because of the meaning of conjunction, just explained, this
means that you have verified A & B. Then you certainly can, or know
how to, verify the proposition A & B, by the principle that, if something
has been done, then it can be done. And this is precisely what you need
to know in order to have the right to judge A & B to be true.
on the meanings of the logical constants 49
If you want the elimination rule for conjunction to exhibit the same
pattern as the elimination rules for falsehood, disjunction, and existence, it should be formulated differently, but, in its standard formulation, it reads as follows.
& -elimination.
A & B true
A true
A & B true
B true
Thus, in this formulation, there are two rules and not only one. Also,
it is still presupposed, of course, that A and B are propositions.
Explanation. It suffices for me to explain one of the rules, say the
first, because the explanation of the other is completely analogous. To
this end, assume that you know the premise, and I shall explain to you
the conclusion, which is to say that I shall explain how to verify A.
This is how you do it. First use your knowledge of the premise to get a
verification of A & B. By the meaning of conjunction, just explained,
that verification consists of a proof that A is true as well as a proof
that B is true, ..
.
A true
and ...
B true
Now select the first of these two proofs. By the definitions of the
notions of proof and truth, that proof is knowledge how to verify A.
So, putting it into practice, you end up with a verification of A. This
finishes the explanations of the rules of conjunction.
The next logical operation to be treated is disjunction. And, as
always, the formation rule must be explained first.
.-formation.
A prop B prop
A . B prop
Explanation. To justify it, assume that you know the premises, that
is, that you know what it is to verify A as well as what it is to verify
B. On that assumption, I explain to you what proposition A . B is by
saying that a verification of A . B is either a proof that A is true or a
proof that B is true, ..
.
A true
or ...
B true
Thus, in the wording of the Kolmogorov interpretation, a solution to
the problem A . B is either a method of solving the problem A or a
method of solving the problem B.
50 per martin-l"of
.-introduction.
A true
A . B true
B true
A . B true
In both of these rules, the premises of the formation rule, which say
that A and B are propositions, are still in force.
Explanation. Assume that you know the premise of the first rule
of disjunction introduction, that is, that you have proved, or possess a
proof of, the judgement that A is true. By the definition of disjunction,
this proof is a verification of the proposition A . B. Hence, by the
principle that, if something has been done, then it can be done, you
certainly can, or know how to, verify the proposition A . B. And it is
this knowledge which you express by judging the conclusion of the rule,
that is, by judging the proposition A . B to be true. The explanation
of the second rule of disjunction introduction is entirely similar.
.-elimination.
A . B true
(A true)
C true
(B true)
C true
C true
Here it is presupposed, not only that A and B are propositions, but also
that C is a proposition provided that A . B is true. Observe that, in
this formulation of the rule of disjunction elimination, C is presupposed
to be a proposition, not outright, but merely on the hypothesis that
A . B is true. Otherwise, it is just like the Gentzen rule.
Explanation. Assume that you know, or have proved, the premises.
By the definition of truth, your knowledge of the first premise is knowledge how to verify the proposition A . B. Put that knowledge of yours
into practice. By the definition of disjunction, you then end up either
with a proof that A is true or with a proof that B is true,
...
A true
or ...
B true
In the first case, join the proof that A is true to the proof that you
already possess of the second premise, which is a hypothetical proof
that C is true under the hypothesis that A is true,
A true.
..
C true
You then get a categorical, or nonhypothetical, proof that C is true,
on the meanings of the logical constants 51
...
A true.
..
C true
Again, by the definition of truth, this proof is knowledge how to verify
the proposition C. So, putting this knowledge of yours into practice,
you verify C. In the second case, join the proof that B is true, which
you ended up with as a result of putting your knowledge of the first
premise into practice, to the proof that you already possess of the
third premise, which is a hypothetical proof that C is true under the
hypothesis that B is true,
B true.
..
C true
You then get a categorical proof that C is true,
...
B true.
..
C true
As in the first case, by the definition of truth, this proof is knowledge how to verify the proposition C. So, putting this knowledge into
practice, you verify C. This finishes my explanation how to verify the
proposition C, which is precisely what you need to know in order to
have the right to infer the conclusion that C is true.
?-formation.
? prop
Explanation. This is an axiom, but not in its capacity of mere
figure: to become an axiom, it has to be made evident. And, to make
it evident, I have to explain what counts as a verification of ?. The
explanation is that there is nothing that counts as a verification of
the proposition ?. Under no condition is it true. Thinking of ? as a
problem, as in the Kolmogorov interpretation, it is the problem which
is defined to have no solution.
An introduction is an inference in which you conclude that a proposition is true, or can be verified, on the ground that you have verified it,
that is, that you possess a verification of it. Therefore, ? being defined
by the stipulation that there is nothing that counts as a verification of
it, there is no introduction rule for falsehood.
52 per martin-l"of
?-elimination. ? true
C true
Here, in analogy with the rule of disjunction elimination, C is presupposed to be a proposition, not outright, but merely under the assumption that ? is true. This is the only divergence from Gentzen's
formulation of ex falso quodlibet.
Explanation. When you infer by this rule, you undertake to verify
the proposition C when you are provided with a proof that ? is true,
that is, by the definition of truth, with a method of verifying ?. But
this is something that you can safely undertake, because, by the definition of falsehood, there is nothing that counts as a verification of ?.
Hence ? is false, that is, cannot be verified, and hence it is impossible
that you ever be provided with a proof that ? is true. Observe the
step here from the falsity of the proposition ? to the unprovability of
the judgement that ? is true. The undertaking that you make when
you infer by the rule of falsehood elimination is therefore like saying,
I shall eat up my hat if you do such and such,
where such and such is something of which you know, that is, are
certain, that it cannot be done.
Observe that the justification of the elimination rule for falsehood
only rests on the knowledge that ? is false. Thus, if A is a proposition,
not necessarily ?, and C is a proposition provided that A is true, then
the inference A true
C true
is valid as soon as A is false. Choosing C to be ?, we can conclude, by
implication introduction, that A oe ? is true provided that A is false.
Conversely, if A oe ? is true and A is true, then, by modus ponens, ?
would be true, which it is not. Hence A is false if A oe ? is true. These
two facts together justify the nominal definition of ,A, the negation of
A, as A oe ?, which is commonly made in intuitionistic logic. However,
the fact that A is false if and only if ,A is true should not tempt one
to define the notion of denial by saying that
A is false
means that
,A is true.
on the meanings of the logical constants 53
That the proposition A is false still means that it is impossible to verify
A, and this is a notion which cannot be reduced to the notions of negation, negation of propositions, that is, and truth. Denial comes before
negation in the order of conceptual priority, just as logical consequence
comes before implication, and the kind of generality which a judgement
may have comes before universal quantification.
As has been implicit in what I have just said,
A is false = A is not true = A is not verifiable
= A cannot be verified.
Moreover, in the course of justifying the rule of falsehood elimination,
I proved that ? is false, that is, that ? is not true. Now, remember
that, in the very beginning of this lecture, we convinced ourselves that a
proposition is true if and only if the judgement that it is true is provable.
Hence, negating both members, a proposition is false if and only if the
judgement that it is true cannot be proved, that is, is unprovable. Using
this in one direction, we can conclude, from the already established
falsity of ?, that the judgement that ? is true is unprovable. This is,
if you want, an absolute consistency proof: it is a proof of consistency
with respect to the unlimited notion of provability, or knowability, that
pervades these lectures. And
(? is true) is unprovable
is the judgement which expresses the absolute consistency, if I may call
it so. By my chain of explanations, I hope that I have succeeded in
making it evident.
The absolute consistency brings with it as a consequence the relative consistency of any system of correct, or valid, inference rules.
Suppose namely that you have a certain formal system, a system of
inference rules, and that you have a formal proof in that system of the
judgement that ? is true. Because of the absolute consistency, that is,
the unprovability of the judgement that ? is true, that formal proof, although formally correct, is no proof, not a real proof, that is. How can
that come about? Since a formal proof is a chain of formally immediate
inferences, that is, instances of the inference rules of the system, that
can only come about as a result of there being some rule of inference
which is incorrect. Thus, if you have a formal system, and you have
convinced yourself of the correctness of the inference rules that belong
to it, then you are sure that the judgement that ? is true cannot be
proved in the system. This means that the consistency problem is really the problem of the correctness of the rules of inference, and that, at
some stage or another, you cannot avoid having to convince yourself
54 per martin-l"of
of their correctness. Of course if you take any old formal system, it
may be that you can carry out a metamathematical consistency proof
for it, but that consistency proof will rely on the intuitive correctness
of the principles of reasoning that you use in that proof, which means
that you are nevertheless relying on the correctness of certain forms
of inference. Thus the consistency problem is really the problem of
the correctness of the rules of inference that you follow, consciously or
unconsciously, in your reasoning.
After this digression on consistency, we must return to the semantical explanations of the rules of inference. The ones that remain are
the quantifier rules.
8-formation.
A(x) prop
(8x)A(x) prop
Explanation. The premise of this rule is a judgement which has
generality in it. If I were to make it explicit, I would have to write it
jx A(x) prop:
It is a judgement which has generality in it, although it is free from
hypotheses. And remember what it is to know such a judgement: it is
to possess a free variable proof of it. Now, assume that you do know
the premise of this rule, that is, that you possess a free variable proof
of the judgement that A(x) is a proposition. On that assumption, I
explain the conclusion to you by stipulating that a verification of the
proposition (8x)A(x) consists of a free variable proof that A(x) is true,
graphically, ..
.
A(x) true
By definition, that is a proof in which the variable x may be replaced
by anything you want, that is, any expression you want of the same
arity as the variable x. Thus, if x is a variable ranging over complete
expressions, then you must substitute a complete expression for it, and,
similarly, if it ranges over incomplete expressions of some arity. In the
Kolmogorov interpretation, the explanation of the meaning of the universal quantifier would be phrased by saying that (8x)A(x) expresses
the problem of constructing a general method of solving the problem
A(x) for arbitrary x.
8-introduction. A(x) true
(8x)A(x) true
on the meanings of the logical constants 55
Here the premise of the formation rule, to the effect that A(x) is a
proposition for arbitrary x, is still in force.
Explanation. Again, the premise of this rule is a general judgement,
which would read
jx A(x) true
if I were to employ the systematic notation that I introduced earlier
in this lecture. Now, assume that you know this, that is, assume that
you possess a free variable proof of the judgement that A(x) is true.
Then, by the principle that, if something has been done, then it can
be done, you certainly can give such a proof, and this is precisely what
you must be able, or know how, to do in order to have the right to infer
the conclusion of the rule.
8-elimination. (8x)A(x) true
A(a) true
Here it is presupposed, of course, that A(x) is a proposition for arbitrary x. And, as you see, I have again chosen the usual formulation
of the elimination rule for the universal quantifier rather than the one
which is patterned upon the elimination rules for falsehood, disjunction, and existence.
Explanation. First of all, observe that, because of the tacit assumption that A(x) is a proposition for arbitrary x, both (8x)A(x) and A(a)
are propositions, where a is an expression of the same arity as the variable x. Now, assume that you know the premise, that is, that you know
how to verify the proposition (8x)A(x), and I shall explain to you how
to verify the proposition A(a). To begin with, put your knowledge of
the premise into practice. That will give you a verification of (8x)A(x),
which, by the definition of the universal quantifier, is a free variable
proof that A(x) is true, ..
.
A(x) true
Now, this being a free variable proof means precisely that it remains a
proof whatever you substitute for x. In particular, it remains a proof
when you substitute a for x so as to get
...
A(a) true
So now you have acquired a proof that A(a) is true. By the definitions
of the notions of proof and truth, this proof is knowledge how to verify
56 per martin-l"of
the proposition A(a). Thus, putting it into practice, you end up with
a verification of A(a), as required.
9-formation.
A(x) prop
(9x)A(x) prop
Explanation. Just as in the formation rule associated with the universal quantifier, the premise of this rule is really the general judgement
jx A(x) prop;
although I have not made the generality explicit in the formulation of
the rule. Assume that you know the premise, that is, assume that you
possess a free variable proof
...
A(x) prop
guaranteeing that A(x) is a proposition, and I shall explain to you what
proposition (9x)A(x) is, that is, what counts as a verification of it. The
explanation is that a verification of (9x)A(x) consists of an expression
a of the same arity as the variable x and a proof
...
A(a) true
showing that the proposition A(a) is true. Observe that the knowledge
of the premise is needed in order to guarantee that A(a) is a proposition,
so that it makes sense to talk about a proof that A(a) is true. In
the Kolmogorov interpretation, (9x)A(x) would be explained as the
problem of finding an expression a, of the same arity as the variable x,
and a method of solving the problem A(a).
9-introduction. A(a) true
(9x)A(x) true
Here, as usual, the premise of the formation rule is still in force, which
is to say that A(x) is assumed to be a proposition for arbitrary x.
Explanation. Assume that you know the premise, that is, assume
that you possess a proof that A(a) is true,
...
A(a) true
on the meanings of the logical constants 57
By the preceding explanation of the meaning of the existential quantifier, the expression a together with this proof make up a verification of
the proposition (9x)A(x). And, possessing a verification of the proposition (9x)A(x), you certainly know how to verify it, which is what you
must know in order to have the right to conclude that (9x)A(x) is true.
Like in my explanations of all the other introduction rules, I have here
taken for granted the principle that, if something has been done, then
it can be done.
9-elimination.
(9x)A(x) true
(A(x) true)
C true
C true
Here it is presupposed, not only that A(x) is a proposition for arbitrary
x, like in the introduction rule, but also that C is a proposition provided
that the proposition (9x)A(x) is true.
Explanation. First of all, in order to make it look familiar, I have
written the second premise in Gentzen's notation
(A(x) true)
C true
rather than in the notation
A(x) true jx C true;
but there is no difference whatever in sense. Thus the second premise
is really a hypothetico-general judgement. Now, assume that you know
the premises. By the definition of the notion of truth, your knowledge of
the first premise is knowledge how to verify the proposition (9x)A(x).
Put that knowledge of yours into practice. You then end up with
a verification of the proposition (9x)A(x). By the definition of the
existential quantifier, this verification consists of an expression a of the
same arity as the variable x and a proof that the proposition A(a) is
true, ..
.
A(a) true
Now use your knowledge, or proof, of the second premise. Because of
the meaning of a hypothetico-general judgement, this proof
A(x) true.
..
C true
58 per martin-l"of
is a free variable proof that C is true from the hypothesis that A(x)
is true. Being a free variable proof means that you may substitute
anything you want, in particular, the expression a, for the variable x.
You then get a hypothetical proof
A(a) true.
..
C true
that C is true from the hypothesis that A(a) is true. Supplementing this
hypothetical proof with the proof that A(a) is true that you obtained
as a result of putting your knowledge of the first premise into practice,
you get a proof ..
.
A(a) true.
..
C true
that C is true, and this proof is nothing but knowledge how to verify
the proposition C. Thus, putting it into practice, you end up having
verified the proposition C, as required.
The promise of the title of these lectures, On the Meanings of the
Logical Constants and the Justifications of the Logical Laws, has now
been fulfilled. As you have seen, the explanations of the meanings of
the logical constants are precisely the explanations belonging to the
formation rules. And the justifications of the logical laws are the explanations belonging to the introduction and elimination rules, which
are the rules that we normally call rules of inference. For lack of time,
I have only been able to deal with the pure logic in my semantical explanations. To develop some interesting parts of mathematics, you also
need axioms for ordinary inductive definitions, in particular, axioms of
computation and axioms for the natural numbers. And, if you need
predicates defined by transfinite, or generalized, induction, then you
will have to add the appropriate formation, introduction, and elimination rules for them.
I have already explained how you see the consistency of a formal
system of correct inference rules, that is, the impossibility of constructing a proof ..
.
? true
that falsehood is true which proceeds according to those rules, not by
studying metamathematically the proof figures divested of all sense, as
on the meanings of the logical constants 59
was Hilbert's program, but by doing just the opposite: not divesting
them of sense, but endowing them with sense. Similarly, suppose that
you have a proof ..
.
A true
that a proposition A is true which depends, neither on any assumptions,
nor on any free variables. By the definition of truth and the identification of proof and knowledge, such a proof is nothing but knowledge how
to verify the proposition A. And, as I remarked earlier in this lecture,
verifying the proposition A by putting that knowledge into practice is
the same as reducing the proof to introductory form and deleting the
last, introductory inference. Moreover, the way of reducing the proof
which corresponds to the semantical explanations, notably of the elimination rules, is precisely the way that I utilized for the first time in
my paper on iterated inductive definitions in the Proceedings of the
Second Scandinavian Logic Symposium, although merely because of
its naturalness, not for any genuine semantical reasons, at that time.
But no longer do we need to prove anything, that is, no longer do we
need to prove metamathematically that the proof figures, divested of
sense, reduce to introductory form. Instead of proving it, we endow
the proof figures with sense, and then we see it! Thus the definition
of convertibility, or computability, and the proof of normalization have
been transposed into genuine semantical explanations which allow you
to see this, just as you can see consistency semantically. And this is
the point that I had intended to reach in these lectures.
60 per martin-l"of
Postscript, Feb. 1996
The preceding three lectures were originally published in the Atti
degli Incontri di Logica Matematica, Vol. 2, Scuola di Specializzazione
in Logica Matematica, Dipartimento di Matematica, Universit`a di
Siena, 1985, pp. 203-281. Since they have been difficult to obtain,
and are now even out of print, they are reprinted here by kind permission of the Dipartimento di Matematica, Universit`a di Siena. Only
typing errors have been corrected. The reader who wishes to follow
the further development of the ideas that were brought up for the first
time in these lectures is referred to the papers listed below.
Per Martin-L"of (1987) Truth of a proposition, evidence of a judgement,
validity of a proof. Synthese, 73, pp. 407-420.
---- (1991) A path from logic to metaphysics. In Atti del Congresso
Nuovi Problemi della Logica e della Filosofia della Scienza, Viareggio, 8-13 gennaio 1990, Vol. II, pp. 141-149. CLUEB, Bologna.
---- (1994) Analytic and synthetic judgements in type theory. In
Paolo Parrini (ed.), Kant and Contemporary Epistemology, pp. 87-
99. Kluwer Academic Publishers, Dordrecht/Boston/London.
---- (1995) Verificationism then and now. In W. DePauli-Schimanovich,
E. K"ohler, and F. Stadler (eds.), The Foundational Debate: Complexity and Constructivity in Mathematics and Physics, pp. 187-
196. Kluwer Academic Publishers, Dordrecht/Boston/London.
---- (1996) Truth and knowability: on the principles C and K of
Michael Dummett. In H. G. Dales and G. Oliveri (eds.), Truth
in Mathematics. Clarendon Press, Oxford. Forthcoming.
Department of Mathematics
University of Stockholm
Sweden
-}
-- record -- WORKS with this additional token
|
###############################################################################
# 03-generating-html.r
###############################################################################
setwd("~/Dropbox/PAPERS/textasdata")
# loading relevant files
load("05-dashboard/qois.rdata")
load("05-dashboard/rs-tweets.rdata")
load("05-dashboard/media-rs-tweets.rdata")
#load("05-dashboard/rs-nyt.rdata")
load("05-dashboard/top-mcs.rdata")
K <- 100 #topics
for (k in 1:K){
## generating topic dropdown
topic.list <- scan("05-dashboard/topic-list.txt", what="character", sep="\n")
dropdown <- paste0("<option value=topic-", 1:K, ".html>", topic.list, "</option>")
dropdown[k] <- gsub('option ', 'option selected="selected" ', dropdown[k])
# generating lines with values of interest
qois1 <- paste0(
"Topic usage by elites: ", sprintf('%0.2f', qois$prop[k]), "% all, ",
'<font color="blue">', sprintf('%0.2f', qois$prop_sen_dems[k]), "% Senate Democrats</font>, ",
'<font color="red">', sprintf('%0.2f', qois$prop_sen_reps[k]), "% Senate Republicans</font>, ",
'<font color="blue">', sprintf('%0.2f', qois$prop_house_dems[k]), "% House Democrats</font>, ",
'<font color="red">', sprintf('%0.2f', qois$prop_house_reps[k]), "% House Republicans</font>.</br>")
qois2 <- paste0('Top Members of Congress:',
topmcs$text[topmcs$topic==k][1], ',',
topmcs$text[topmcs$topic==k][2], ',',
topmcs$text[topmcs$topic==k][3], ',',
topmcs$text[topmcs$topic==k][4], ',',
topmcs$text[topmcs$topic==k][5], '</br>')
qois3 <- paste0(
"Topic usage by media and public: ", sprintf('%0.2f', qois$media[k]), "% Media, ",
sprintf('%0.2f', qois$public[k]), "% informed public, ",
sprintf('%0.2f', qois$random[k]), "% random users, ",
'<font color="blue">', sprintf('%0.2f', qois$democrats[k]), "% Democratic supporters</font>, ",
'<font color="red">', sprintf('%0.2f', qois$republicans[k]), "% Republican supporters</font>.</br>")
# image line
img.line <- paste0("<img src='img/words-plot-", k, ".png'>")
# data location
d.loc <- paste0('"data/ts-', k, '.csv", // path to CSV file')
# html text
html <- paste0(
'<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="js/dygraph-combined.js"></script>
<script src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
#sitemap { position: absolute; left: 50%; margin-left: -400px; top: 1%; margin-top: 50 px; }
#header1 { position: absolute; left: 50%; margin-left: -500px; top: 0%; margin-top: 30px; }
#div1 { position: absolute; left: 50%; margin-left: -500px; top: 0%; margin-top: 90px; }
#div2 { position: absolute; left: 50%; margin-left: 150; top: 0%; margin-top: 90px; }
#div3 { position: absolute; left: 50%; margin-left: -500; top: 0%; margin-top: 440px; }
#div4 { position: absolute; left: 50%; margin-left: -500; top: 0%; margin-top: 480px; }
#header2 { position: absolute; left: 50%; margin-left: -500px; top: 0%; margin-top: 550px; }
#div5 { position: absolute; left: 50%; margin-left: -500px; top: 0%; margin-top: 600px; }
#div6 { position: absolute; left: 50%; margin-left: 0; top: 0%; margin-top: 600px; }
#header3 { position: absolute; left: 50%; margin-left: -500px; top: 0%; margin-top: 1250px; }
#div7 { position: absolute; left: 50%; margin-left: -500px; top: 0%; margin-top: 1300px; }
#div8 { position: absolute; left: 50%; margin-left: 0; top: 0%; margin-top: 1300px; }
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<body>
<div id="sitemap">
<b> « <a href="index.html">Back to Index</a> • Topic selection: </b>
<select onchange="if (this.value) window.location.href=this.value" class="input-xxlarge">
',
paste(dropdown, collapse="\n"),
'
</select>
</div>
<div id="header1"><h3>Topic Usage Over Time:</h3></div>
<div id="div1" style="width:600px">
</div>
<div id="div2" style="width:300px">
',
img.line,
'
</div>
<div id="div3">
<form class="form-inline">
<b>Display: </b>
<label class="checkbox-inline">
<input type="checkbox" id=0 onClick="change(this)" checked> Democrats
</label>
<label class="checkbox-inline">
<input type="checkbox" id=1 onClick="change(this)" checked> Republicans
</label>
<label class="checkbox-inline">
<input type="checkbox" id=2 onClick="change(this)" unchecked> Media
</label>
<label class="checkbox-inline">
<input type="checkbox" id=3 onClick="change(this)" unchecked> Public
</label>
<label class="checkbox-inline">
<input type="checkbox" id=4 onClick="change(this)" unchecked> Dem. Supporters
</label>
<label class="checkbox-inline">
<input type="checkbox" id=5 onClick="change(this)" unchecked> Rep. Supporters
</label>
<label class="checkbox-inline">
<input type="checkbox" id=6 onClick="change(this)" unchecked> Random Sample
</label>
• <b> Smoothing period:</b>
<input type="number" value="7" id="input" min="1" step="1" style = "width:50px;height:30px" onchange="changeRoll()">
days
</form>
</div>
<div id="div4">
',
qois1, qois2, qois3,
'
</div>
<div id="header2"><h3>Sample of representative tweets by Members of Congress:</h3></div>
<div id="div5" style="width:500px">
',
rs$embed[rs$topic==k][1],
rs$embed[rs$topic==k][3],
rs$embed[rs$topic==k][5],
'
</div>
<div id="div6" style="width:500px">
',
rs$embed[rs$topic==k][2],
rs$embed[rs$topic==k][4],
rs$embed[rs$topic==k][6],
'
</div>
<div id="header3"><h3>Sample of representative media tweets:</h3></div>
<div id="div7" style="width:500px">
',
media_rs$embed[media_rs$topic==k][1],
media_rs$embed[media_rs$topic==k][3],
media_rs$embed[media_rs$topic==k][5],
'
</div>
<div id="div8" style="width:500px">
',
media_rs$embed[media_rs$topic==k][2],
media_rs$embed[media_rs$topic==k][4],
media_rs$embed[media_rs$topic==k][6],
'
</div>
<br><br>
</div>
<script type="text/javascript">
var g;
g = new Dygraph(
document.getElementById("div1"),
',
d.loc,
'
{
showRangeSelector: false,
rollPeriod: 7,
title: "",
ylabel: "Pr(topic)",
legend: "always",
labelsDivStyles: { "textAlign": "right" , "background": "none"},
colors: ["blue", "red", "black", "green", "darkblue", "darkred", "darkgray"],
visibility: [true, true, false, false, false, false, false],
labelsSeparateLines: true,
labelsKMB: true,
} // options
);
function change(el) {
g.setVisibility(el.id, el.checked);
}
function changeRoll(){
value = input.value;
g.adjustRoll(value);
}
</script>
</body>
</html>
')
writeLines(html, con=paste0("05-dashboard/files/topic-", k, ".html"))
}
|
#pragma once
#include <boost/asio.hpp>
#include <opencv2/core.hpp>
#include <cstddef>
#include <optional>
#include <string>
#include "pair.hpp"
class Sentry {
public:
Sentry(std::string tty, std::uint32_t baud_rate=115200, pair rate={5000, 4000}, pair acc={1000, 1000}, std::uint32_t feed_rate=9000);
~Sentry();
bool failed = true;
void jog(const pair_base<float>& shift);
std::size_t send(const std::string& cmd);
std::optional<std::string> recv_all();
bool recv();
bool complete();
void set_rate(const pair& rate);
void set_acc(const pair& acc);
private:
static const std::string hello;
static const std::string ok;
std::string tty;
std::uint32_t baud_rate;
boost::asio::io_service io;
boost::asio::serial_port serial;
pair rate, acc;
std::uint32_t feed_rate;
pair_base<float> position;
};
|
subroutine sparse_check( neq, irow, icoln, maxan, ncof, maxn )
implicit integer (a-z)
c
dimension irow(*), icoln(*), maxan(*)
allocatable jtemp(:)
c
c nt number of terms in adjncy
c
allocate( jtemp(neq+1) )
jtemp(1:neq) = 0
icont = 1
c
do i = 1, neq
do j = 1, irow(i)
iix = icoln(icont)
jtemp(iix) = jtemp(iix) + 1
jtemp(i) = jtemp(i) + 1
icont = icont + 1
end do
end do
c
jmax = 0
maxan(1) = 1
do i = 1, neq
jmax = max(jmax,jtemp(i))
maxan(i+1) = maxan(i) + jtemp(i)
end do
maxn = jmax + 5
ncof = maxan(neq+1)
c
deallocate( jtemp )
c
return
end
|
(* This Isabelle theory is produced using the TIP tool offered at the following website:
https://github.com/tip-org/tools
This file was originally provided as part of TIP benchmark at the following website:
https://github.com/tip-org/benchmarks
Yutaka Nagashima at CIIRC, CTU changed the TIP output theory file slightly
to make it compatible with Isabelle2017.*)
theory TIP_int_add_inv_left
imports "../../Test_Base"
begin
datatype Nat = Z | S "Nat"
datatype Integer = P "Nat" | N "Nat"
definition(*fun*) zero :: "Integer" where
"zero = P Z"
fun pred :: "Nat => Nat" where
"pred (S y) = y"
fun plus :: "Nat => Nat => Nat" where
"plus (Z) y = y"
| "plus (S z) y = S (plus z y)"
fun neg :: "Integer => Integer" where
"neg (P (Z)) = P Z"
| "neg (P (S z)) = N z"
| "neg (N n) = P (plus (S Z) n)"
fun t2 :: "Nat => Nat => Integer" where
"t2 x y =
(let fail :: Integer =
(case y of
Z => P x
| S z =>
(case x of
Z => N y
| S x2 => t2 x2 z))
in (case x of
Z =>
(case y of
Z => P Z
| S x4 => fail)
| S x3 => fail))"
fun plus2 :: "Integer => Integer => Integer" where
"plus2 (P m) (P n) = P (plus m n)"
| "plus2 (P m) (N o2) = t2 m (plus (S Z) o2)"
| "plus2 (N m2) (P n2) = t2 n2 (plus (S Z) m2)"
| "plus2 (N m2) (N n3) = N (plus (plus (S Z) m2) n3)"
theorem property0 :
"((plus2 (neg x) x) = zero)"
oops
end
|
#pragma once
#include <gsl\gsl>
#include <winrt\Windows.Foundation.h>
#include <d3d11.h>
#include <map>
#include "DrawableGameComponent.h"
#include "FullScreenRenderTarget.h"
#include "FullScreenQuad.h"
#include "MatrixHelper.h"
namespace Library
{
class PixelShader;
}
namespace Rendering
{
class DiffuseLightingDemo;
enum class ColorFilters
{
GrayScale = 0,
Inverse,
Sepia,
Generic,
End
};
class ColorFilteringDemo final : public Library::DrawableGameComponent
{
public:
ColorFilteringDemo(Library::Game& game, const std::shared_ptr<Library::Camera>& camera);
ColorFilteringDemo(const ColorFilteringDemo&) = delete;
ColorFilteringDemo(ColorFilteringDemo&&) = default;
ColorFilteringDemo& operator=(const ColorFilteringDemo&) = default;
ColorFilteringDemo& operator=(ColorFilteringDemo&&) = default;
~ColorFilteringDemo();
std::shared_ptr<DiffuseLightingDemo> DiffuseLighting() const;
ColorFilters ActiveColorFilter() const;
void SetActiveColorFilter(ColorFilters colorFilter);
float GenericFilterBrightness() const;
void SetGenericFilterBrightness(float brightness);
static const std::map<ColorFilters, std::string> ColorFilterNames;
virtual void Initialize() override;
virtual void Update(const Library::GameTime& gameTime) override;
virtual void Draw(const Library::GameTime& gameTime) override;
private:
struct GenericColorFilterPSConstantBuffer
{
DirectX::XMFLOAT4X4 ColorFilter{ Library::MatrixHelper::Identity };
};
std::shared_ptr<DiffuseLightingDemo> mDiffuseLightingDemo;
Library::FullScreenRenderTarget mRenderTarget;
Library::FullScreenQuad mFullScreenQuad;
std::map<ColorFilters, std::shared_ptr<Library::PixelShader>> mPixelShadersByColorFilter;
ColorFilters mActiveColorFilter;
winrt::com_ptr<ID3D11Buffer> mGenericColorFilterPSConstantBuffer;
GenericColorFilterPSConstantBuffer mGenericColorFilterPSConstantBufferData;
};
}
|
function [Itheta,SigmaTheta,deltaMuTheta,suffStat] = VBA_Itheta(theta,y,posterior,suffStat,dim,u,options)
% Gauss-Newton update of the evolution parameters
if options.DisplayWin % Display progress
set(options.display.hm(1),'string',...
'VB Gauss-Newton on evolution parameters... ');
set(options.display.hm(2),'string','0%');
drawnow
end
% Look-up which evolution parameter to update
indIn = options.params2update.theta;
indInx = options.params2update.x;
% Get precision parameters
alphaHat = posterior.a_alpha./posterior.b_alpha;
% Preallocate intermediate variables
iQx = options.priors.iQx;
Q = options.priors.SigmaTheta(indIn,indIn);
iQ = VBA_inv(Q);
muTheta0 = options.priors.muTheta;
Theta = muTheta0;
Theta(indIn) = theta;
dtheta0 = muTheta0-Theta;
dx = zeros(dim.n,dim.n_t);
div = 0;
%--- Initial condition ---%
% evaluate evolution function at current mode
[fx,dF_dX,dF_dTheta] = VBA_evalFun('f',posterior.muX0,Theta,u(:,1),options,dim,1);
% check infinite precision transition pdf
iQ2 = VBA_inv(iQx{1},indInx{1},'replace');
% posterior covariance matrix terms
d2fdx2 = dF_dTheta*iQ2*dF_dTheta';
% error terms
dx(:,1) = (posterior.muX(:,1) - fx);
dx2 = dx(:,1)'*iQ2*dx(:,1);
ddxdtheta = dF_dTheta*iQ2*dx(:,1);
%--- Loop over time series ---%
for t=1:dim.n_t-1
% check infinite precision transition pdf
iQ2 = VBA_inv(iQx{t+1},indInx{t+1},'replace');
% evaluate evolution function at current mode
[fx,dF_dX,dF_dTheta] = VBA_evalFun('f',posterior.muX(:,t),Theta,u(:,t+1),options,dim,t+1);
% posterior covariance matrix terms
d2fdx2 = d2fdx2 + dF_dTheta*iQ2*dF_dTheta';
% error terms
dx(:,t+1) = (posterior.muX(:,t+1) - fx);
dx2 = dx2 + dx(:,t+1)'*iQ2*dx(:,t+1);
ddxdtheta = ddxdtheta + dF_dTheta*iQ2*dx(:,t+1);
% Display progress
if options.DisplayWin && mod(t,dim.n_t./10) < 1
set(options.display.hm(2),'string',[num2str(floor(100*t/dim.n_t)),'%']);
drawnow
end
% Accelerate divergent update
if VBA_isWeird ({dx2, dF_dX, dF_dTheta})
div = 1;
break
end
end
if options.DisplayWin % Display progress
set(options.display.hm(2),'string','OK');
drawnow
end
% posterior covariance matrix
iSigmaTheta = iQ + alphaHat.*d2fdx2(indIn,indIn);
SigmaTheta = VBA_inv(iSigmaTheta);
% mode
tmp = iQ*dtheta0(indIn) + alphaHat.*ddxdtheta(indIn);
deltaMuTheta = SigmaTheta*tmp;
% variational energy
Itheta = -0.5.*dtheta0(indIn)'*iQ*dtheta0(indIn) -0.5*alphaHat.*dx2;
if VBA_isWeird ({Itheta, SigmaTheta}) || div
Itheta = -Inf;
end
% update sufficient statistics
suffStat.Itheta = Itheta;
suffStat.dx = dx;
suffStat.dx2 = dx2;
suffStat.dtheta = dtheta0;
suffStat.div = div;
|
#redirect Users/JerseyCity
|
classdef Jab < handle
% .jab files
methods (Static)
function J = load(jabfile)
% J = load(jabfile)
%
% J: Modernized Macguffin object
assert(ischar(jabfile) && exist(jabfile,'file')==2,...
'Cannot find jabfile ''%s''.',jabfile);
J = loadAnonymous(jabfile);
if isstruct(J)
J = Macguffin(J);
end
J.modernize();
end
function save(J,jabfile)
saveAnonymous(jabfile,J);
end
function savePrompt(J,jabfile)
if exist('jabfile','var')==0
jabfile = [];
end
[fname,pname] = uiputfile('*.jab','Save',jabfile);
fname = fullfile(pname,fname);
Jab.save(J,fname);
end
function [tfsuccess,jabfiles] = uiGetJabFiles(varargin)
% [tfsuccess,jabfiles] = uiGetJabFiles(p1,v1,...)
%
% Nice(r) GUI for multiple jab selection.
%
% Optional PVs:
% * promptstr, char.
%
% tfsuccess: if false, user canceled GUI
% jabfiles: cellstr
promptstr = myparse(varargin,...
'promptstr','Select jab files');
%jabpath = ExpPP.loadConfigVal('jabpath');
jabpath = [];
if isempty(jabpath)
jabpath = pwd;
end
jabfiles = uipickfiles('Prompt',promptstr,...
'FilterSpec',jabpath,'Type',{'*.jab','JAB-files'},'SmartAdd',true);
if ~iscell(jabfiles) || isempty(jabfiles), % canceled
tfsuccess = false;
jabfiles = [];
else
tfsuccess = true;
%jabpath = fileparts(jabfiles{1});
%ExpPP.saveConfigVal('jabpath',jabpath);
end
end
function clearLabels(jabfile,realbeh)
% Clear all labels for realbeh and No-realbeh
J = Jab.load(jabfile);
jabrealbehs = J.behaviors.names(1:J.behaviors.nbeh);
tf = strcmpi(realbeh,jabrealbehs);
assert(any(tf),'Specified behavior ''%s'' not present in jabfile.',realbeh);
assert(nnz(tf)==1);
realbeh = jabrealbehs{tf}; % case could be different
tfMultiCls = J.behaviors.nbeh>1;
if tfMultiCls
nobeh = Labels.noBehaviorName(realbeh);
else
nobeh = 'None';
end
J.labels = Labels.clearLabels(J.labels,realbeh,realbeh);
J.labels = Labels.clearLabels(J.labels,nobeh,realbeh);
J.savePrompt(J,jabfile);
end
function tf = isMultiClassifier(jabfile)
% tf = isMultiClassifier(jabfile)
J = Jab.load(jabfile);
tf = J.isMultiClassifier();
end
function rmClassifier(jabfile,clsnames)
% rmClassifier(jabfile,clsnames)
%
% jab: char, jab filename
% clsname: char or cellstr
J = Jab.load(jabfile);
Jbeh = J.behaviors;
Jclsnames = Jbeh.names(1:Jbeh.nbeh);
if exist('clsnames','var')>0
if ischar(clsnames)
clsnames = cellstr(clsnames);
end
assert(iscellstr(clsnames),'Expected ''clsname'' argument to be a char or cellstr.');
else
[sel,ok] = listdlg('PromptString','Select classifiers to remove:',...
'ListString',Jclsnames,...
'ListSize',[240 240]);
if ~ok
return;
end
clsnames = Jclsnames(sel);
end
[tf,iClsRm] = ismember(clsnames,Jclsnames);
if ~all(tf)
clsmissing = clsnames(~tf);
error('Jab:rmClassifier','Classifier(s) %s not present in jabfile.',...
civilizedStringFromCellArrayOfStrings(clsmissing));
end
nClsRm = numel(iClsRm);
nClsNew = Jbeh.nbeh - nClsRm;
if nClsNew==0
error('Jab:rmClassifier','Cannot remove all classifiers from a .jab file.');
end
iLblsRm = [iClsRm iClsRm+Jbeh.nbeh];
origBehs = J.behaviors.names(iClsRm);
origNoBehs = J.behaviors.names(iClsRm+Jbeh.nbeh);
J.behaviors.names(iLblsRm) = [];
J.behaviors.labelcolors(iLblsRm,:) = [];
J.behaviors.nbeh = nClsNew;
J.file.scorefilename(iClsRm) = [];
J.windowFeaturesParams(iClsRm) = [];
for iCls = 1:nClsRm
J.labels = Labels.removeClassifier(J.labels,origBehs{iCls},origNoBehs{iCls});
J.gtLabels = Labels.removeClassifier(J.gtLabels,origBehs{iCls},origNoBehs{iCls});
end
J.classifierStuff(iClsRm) = [];
% Quirk, no-beh name for single-classifier projs
if nClsNew==1
oldNoBehavior = J.behaviors.names{2};
newNoBehavior = 'None';
J.behaviors.names{2} = newNoBehavior;
J.labels = Labels.renameBehaviorRaw(J.labels,oldNoBehavior,newNoBehavior);
J.gtLabels = Labels.renameBehaviorRaw(J.gtLabels,oldNoBehavior,newNoBehavior);
% ALXXX to be fixed
warning('Jab:rmClassifier',...
'Going from multi-classifier to single-classifier project. Label importance may not be set correctly for GT mode.');
end
Jab.savePrompt(J,jabfile);
end
function tf = formatChangedBetweenVersions(v1,v2)
% v2 should be later-than-or-equal-to-v1.
%
% This method introduced in version 0.6.0. Jabs saved in prior
% versions have version prop enclosed in double-cell array. We avoid
% the complications for now and just return true if v2 is 0.6.0 and
% v1 is not. This will need to be updated with subsequent versions.
tf = strcmp(v2,'0.6.0') && ~strcmp(v1,'0.6.0');
end
function merge(jabfiles,jabout)
% jabMerge(jabfiles,jabout)
% Merge two or more jab files.
%
% Behaviors with the same name (precisely, case-sensitive, etc) are
% treated as the same classifier. Experiment names/directories should
% be in a consistent format.
%
% jabfiles: optional. cellstr of jab filenames
% jabout: optional. output jab filename
if ~exist('jabfiles','var') || isempty(jabfiles)
[tfsuccess,jabfiles] = Jab.uiGetJabFiles('promptstr','Select jab files to combine');
if ~tfsuccess
return;
end
end
if ischar(jabfiles)
jabfiles = cellstr(jabfiles);
end
assert(iscellstr(jabfiles),'Expected ''jabfiles'' to be a cellstr of jab filenames.');
Js = cellfun(@Jab.load,jabfiles,'uni',0);
Js = cat(1,Js{:});
Jmerge = Macguffin(Js);
% come up with a proposed name for combined jab
if ~exist('jabout','var') || isempty(jabout)
MAXFILENAMELENGTH = 45;
behnames = Labels.verifyBehaviorNames(Jmerge.behaviors.names);
combjabname = '';
for i = 1:numel(behnames)
combjabname = [combjabname behnames{i} '.']; %#ok<AGROW>
if numel(combjabname)>MAXFILENAMELENGTH
combjabname = [combjabname 'etc.']; %#ok<AGROW>
break;
end
end
combjabname = [combjabname 'jab'];
%jabpath = ExpPP.loadConfigVal('jabpath');
jabpath = [];
if isempty(jabpath)
jabpath = pwd;
end
[filename,pathname] = ...
uiputfile({'*.jab','JAABA files (*.jab)'},'Save combined jabfile',fullfile(jabpath,combjabname));
if ~ischar(filename),
% user hit cancel
return;
end
jabout = fullfile(pathname,filename);
else
if exist(jabout,'file')
uiwait(warndlg(sprintf('Output file ''%s'' exists and will be overwritten.',jabout)));
end
end
Jab.save(Jmerge,jabout);
%ExpPP.saveConfigVal('jabpath',fileparts(jabout));
end
function [scorefiles,behaviors] = jabfileScoresBehs(jabname)
% [scorefiles,behaviors] = jabfileScoresBehs(jabname)
% scorefile: cellstr of score files
% behaviors: cellstr of "real" behaviors (doesn't include No_<beh>)
x = loadAnonymous(jabname);
scorefiles = x.file.scorefilename;
if ischar(scorefiles)
scorefiles = cellstr(scorefiles);
end
behaviors = Labels.verifyBehaviorNames(x.behaviors.names);
assert(numel(scorefiles)==numel(behaviors));
end
end
end
|
// Copyright 2020 The Defold Foundation
// Licensed under the Defold License version 1.0 (the "License"); you may not use
// this file except in compliance with the License.
//
// You may obtain a copy of the License, together with FAQs at
// https://www.defold.com/license
//
// 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 <stdlib.h>
#include <dlib/dstrings.h>
#include "../script.h"
#include "../script_private.h"
#define JC_TEST_IMPLEMENTATION
#include <jc_test/jc_test.h>
class PushTableLoggerTest : public jc_test_base_class
{
protected:
virtual void SetUp()
{
m_Result[PUSH_TABLE_LOGGER_CAPACITY] = '\0';
}
char m_Result[PUSH_TABLE_LOGGER_STR_SIZE];
dmScript::PushTableLogger m_Logger;
};
TEST_F(PushTableLoggerTest, EmptyLog)
{
ASSERT_EQ(0x0, m_Logger.m_Log[0]);
ASSERT_EQ(0, m_Logger.m_Size);
ASSERT_EQ(0, m_Logger.m_Cursor);
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("", m_Result);
}
TEST_F(PushTableLoggerTest, AddCharAndPrint)
{
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("", m_Result);
PushTableLogChar(m_Logger, 'A');
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("A", m_Result);
ASSERT_EQ(1, m_Logger.m_Size);
PushTableLogChar(m_Logger, 'B');
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("AB", m_Result);
ASSERT_EQ(2, m_Logger.m_Size);
const char tmp[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i = 0;
// Fill until 1 char left of capacity
// "AB" + 1 empty char = 3
for (; i < PUSH_TABLE_LOGGER_CAPACITY-3; i++)
{
PushTableLogChar(m_Logger, tmp[i%sizeof(tmp)]);
}
PushTableLogPrint(m_Logger, m_Result);
ASSERT_EQ(PUSH_TABLE_LOGGER_CAPACITY-1, m_Logger.m_Size);
ASSERT_EQ(0x0, m_Result[PUSH_TABLE_LOGGER_CAPACITY-1]);
// Add one more char (fills capacity)
char first_char = m_Result[0];
PushTableLogChar(m_Logger, '+');
PushTableLogPrint(m_Logger, m_Result);
ASSERT_EQ(PUSH_TABLE_LOGGER_CAPACITY, m_Logger.m_Size);
ASSERT_EQ('+', m_Result[PUSH_TABLE_LOGGER_CAPACITY-1]);
ASSERT_EQ(first_char, m_Result[0]);
// Add one more char, will throw out first char (replaced with second in line).
char second_char = m_Result[1];
PushTableLogChar(m_Logger, '-');
PushTableLogPrint(m_Logger, m_Result);
ASSERT_EQ(PUSH_TABLE_LOGGER_CAPACITY, m_Logger.m_Size);
ASSERT_EQ('-', m_Result[PUSH_TABLE_LOGGER_CAPACITY-1]);
ASSERT_EQ(second_char, m_Result[0]);
}
TEST_F(PushTableLoggerTest, AddStringAndPrint)
{
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("", m_Result);
PushTableLogString(m_Logger, "A");
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("A", m_Result);
PushTableLogString(m_Logger, "BCDE");
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("ABCDE", m_Result);
}
TEST_F(PushTableLoggerTest, FormatAndPrint)
{
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("", m_Result);
PushTableLogString(m_Logger, "A");
PushTableLogPrint(m_Logger, m_Result);
ASSERT_STREQ("A", m_Result);
char t_fmt1[] = "B%dC";
int t_data1 = 1234567890;
char t_str1[128];
dmSnPrintf(t_str1, sizeof(t_str1), t_fmt1, t_data1);
PushTableLogFormat(m_Logger, t_fmt1, t_data1);
PushTableLogPrint(m_Logger, m_Result);
ASSERT_EQ('A', m_Result[0]); // 'A' should still be first char
ASSERT_STREQ(t_str1, m_Result+1); // Formated string should be the rest of the string.
}
static const char g_GuardStr[] = "GUARD";
static const size_t g_GuardStrSize = sizeof(g_GuardStr);
static bool CheckGuardBytes(const char* buf)
{
return (memcmp(buf, g_GuardStr, sizeof(g_GuardStr)) == 0);
}
TEST_F(PushTableLoggerTest, OOB)
{
char oob_test_wrap[PUSH_TABLE_LOGGER_STR_SIZE+g_GuardStrSize+g_GuardStrSize];
char* guard_start = oob_test_wrap;
char* guard_end = oob_test_wrap+PUSH_TABLE_LOGGER_STR_SIZE+g_GuardStrSize;
// write guard string to beginning and end of result buffer wrap
memcpy(guard_start, g_GuardStr, g_GuardStrSize);
memcpy(guard_end, g_GuardStr, g_GuardStrSize);
ASSERT_TRUE(CheckGuardBytes(guard_start));
ASSERT_TRUE(CheckGuardBytes(guard_end));
for (int i = 0; i < PUSH_TABLE_LOGGER_CAPACITY*2; ++i)
{
PushTableLogChar(m_Logger, 'X');
ASSERT_TRUE(CheckGuardBytes(guard_start));
ASSERT_TRUE(CheckGuardBytes(guard_end));
}
}
int main(int argc, char **argv)
{
jc_test_init(&argc, argv);
return jc_test_run_all();
}
|
/* PSICOV - Protein Sparse Inverse COVariance analysis program */
/* by David T. Jones August 2011 - Copyright (C) 2011 University College London */
/* Version 1.05 - Last Edit 13/2/12 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <unistd.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>
#define FALSE 0
#define TRUE 1
#define SQR(x) ((x)*(x))
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAXSEQLEN 5000
#define MINSEQS 50
#define MINEFSEQS 100
extern glasso_(int *, double *, double *, int *, int *, int *, int *, double *, int *, double *, double *, int *, double *, int *);
/* Dump a rude message to standard error and exit */
void
fail(char *errstr)
{
fprintf(stderr, "\n*** %s\n\n", errstr);
exit(-1);
}
/* Convert AA letter to numeric code (0-21) */
int
aanum(int ch)
{
const static int aacvs[] =
{
999, 0, 3, 4, 3, 6, 13, 7, 8, 9, 21, 11, 10, 12, 2,
21, 14, 5, 1, 15, 16, 21, 19, 17, 21, 18, 6
};
return (isalpha(ch) ? aacvs[ch & 31] : 20);
}
/* Allocate matrix */
void *allocmat(int rows, int columns, int size)
{
int i;
void **p, *rp;
rp = malloc(rows * sizeof(void *) + sizeof(int));
if (rp == NULL)
fail("allocmat: malloc [] failed!");
*((int *)rp) = rows;
p = rp + sizeof(int);
for (i = 0; i < rows; i++)
if ((p[i] = calloc(columns, size)) == NULL)
fail("allocmat: malloc [][] failed!");
return p;
}
/* Free matrix */
void
freemat(void *rp)
{
int rows;
void **p = rp;
rows = *((int *)(rp - sizeof(int)));
while (rows--)
free(p[rows]);
free(rp - sizeof(int));
}
/* Allocate vector */
void *allocvec(int columns, int size)
{
void *p;
p = calloc(columns, size);
if (p == NULL)
fail("allocvec: calloc failed!");
return p;
}
struct sc_entry
{
float sc;
int i, j;
} *sclist;
/* Sort descending */
int cmpfn(const void *a, const void *b)
{
if (((struct sc_entry *)a)->sc == ((struct sc_entry *)b)->sc)
return 0;
if (((struct sc_entry *)a)->sc < ((struct sc_entry *)b)->sc)
return 1;
return -1;
}
int main(int argc, char **argv)
{
int a, b, i, j, k, seqlen, nids, s, nseqs, ncon, opt, ndim, approxflg=0, initflg=0, debugflg=0, diagpenflg=1, apcflg=1, maxit=10000, npair, nnzero, niter, jerr, shrinkflg=1, rawscflg = 1, pseudoc = 1, minseqsep = 5;
unsigned int *wtcount;
double thresh=1e-4, del, sum, score, (**pab)[21][21], **pa, wtsum, pc, **pcmat, *pcsum, pcmean, rhodefault = -1.0, lambda, smean, fnzero, lastfnzero, trialrho, rfact, r2, targfnzero = 0.0, scsum, scsumsq, mean, sd, zscore, ppv;
float *weight, idthresh = -1.0, maxgapf = 0.9;
char buf[4096], seq[MAXSEQLEN], *blockfn = NULL, **aln;
FILE *ifp;
while ((opt = getopt(argc, argv, "alnpr:b:i:t:c:g:d:j:")) >= 0)
switch (opt)
{
case 'a':
approxflg = 1;
break;
case 'n':
shrinkflg = 0;
break;
case 'p':
rawscflg = 0;
break;
case 'l':
apcflg = 0;
break;
case 'r':
rhodefault = atof(optarg);
break;
case 'd':
targfnzero = atof(optarg);
break;
case 't':
thresh = atof(optarg);
break;
case 'i':
idthresh = 1.0 - atof(optarg)/100.0;
break;
case 'c':
pseudoc = atoi(optarg);
break;
case 'j':
minseqsep = atoi(optarg);
break;
case 'b':
blockfn = strdup(optarg);
break;
case 'g':
maxgapf = atof(optarg);
break;
case '?':
exit(-1);
}
if (optind >= argc)
fail("Usage: psicov [options] alnfile\n\nOptions:\n-a\t: use approximate Lasso algorithm\n-n\t: don't pre-shrink the sample covariance matrix\n-p\t: output PPV estimates rather than raw scores\n-l\t: don't apply APC to Lasso output\n-r nnn\t: set initial rho parameter\n-d nnn\t: set target precision matrix sparsity (default 0 = not specified)\n-t nnn\t: set Lasso convergence threshold (default 1e-4)\n-i nnn\t: select BLOSUM weighting with given identity threshold (default selects threshold automatically)\n-c nnn\t: set pseudocount value (default 1)\n-j nnn\t: set minimum sequence separation (default 5)\n-g nnn\t: maximum fraction of gaps (default 0.9)\n-b file\t: read rho parameter file\n");
ifp = fopen(argv[optind], "r");
if (!ifp)
fail("Unable to open alignment file!");
for (nseqs=0;; nseqs++)
if (!fgets(seq, MAXSEQLEN, ifp))
break;
aln = allocvec(nseqs, sizeof(char *));
weight = allocvec(nseqs, sizeof(float));
wtcount = allocvec(nseqs, sizeof(unsigned int));
rewind(ifp);
if (!fgets(seq, MAXSEQLEN, ifp))
fail("Bad alignment file!");
seqlen = strlen(seq)-1;
if (nseqs < MINSEQS)
fail("Alignment too small - not enough homologous sequences to proceed (or change MINSEQS at your own risk!)");
if (!(aln[0] = malloc(seqlen)))
fail("Out of memory!");
for (j=0; j<seqlen; j++)
aln[0][j] = aanum(seq[j]);
for (i=1; i<nseqs; i++)
{
if (!fgets(seq, MAXSEQLEN, ifp))
break;
if (seqlen != strlen(seq)-1)
fail("Length mismatch in alignment file!");
if (!(aln[i] = malloc(seqlen)))
fail("Out of memory!");
for (j=0; j<seqlen; j++)
aln[i][j] = aanum(seq[j]);
}
/* Calculate sequence weights */
if (idthresh < 0.0)
{
double meanfracid = 0.0;
for (i=0; i<nseqs; i++)
for (j=i+1; j<nseqs; j++)
{
int nids;
float fracid;
for (nids=k=0; k<seqlen; k++)
if (aln[i][k] == aln[j][k])
nids++;
fracid = (float)nids / seqlen;
meanfracid += fracid;
}
meanfracid /= 0.5 * nseqs * (nseqs - 1.0);
idthresh = 0.38 * 0.32 / meanfracid;
}
for (i=0; i<nseqs; i++)
for (j=i+1; j<nseqs; j++)
{
int nthresh = seqlen * idthresh;
for (k=0; nthresh > 0 && k<seqlen; k++)
if (aln[i][k] != aln[j][k])
nthresh--;
if (nthresh > 0)
{
wtcount[i]++;
wtcount[j]++;
}
}
for (wtsum=i=0; i<nseqs; i++)
wtsum += (weight[i] = 1.0 / (1 + wtcount[i]));
if (wtsum < MINEFSEQS)
puts("\n*** WARNING - not enough sequence variation - or change MINEFSEQS at your own risk! ***\n");
pa = allocmat(seqlen, 21, sizeof(double));
pab = allocmat(seqlen, seqlen, 21*21*sizeof(double));
/* Calculate singlet frequencies with pseudocount */
for (i=0; i<seqlen; i++)
{
for (a=0; a<21; a++)
pa[i][a] = pseudoc;
for (k=0; k<nseqs; k++)
{
a = aln[k][i];
if (a < 21)
pa[i][a] += weight[k];
}
for (a=0; a<21; a++)
pa[i][a] /= pseudoc * 21.0 + wtsum;
}
/* Calculate pair frequencies with pseudocount */
for (i=0; i<seqlen; i++)
{
for (j=i+1; j<seqlen; j++)
{
for (a=0; a<21; a++)
for (b=0; b<21; b++)
pab[i][j][a][b] = pseudoc / 21.0;
for (k=0; k<nseqs; k++)
{
a = aln[k][i];
b = aln[k][j];
if (a < 21 && b < 21)
pab[i][j][a][b] += weight[k];
}
for (a=0; a<21; a++)
for (b=0; b<21; b++)
{
pab[i][j][a][b] /= pseudoc * 21.0 + wtsum;
pab[j][i][b][a] = pab[i][j][a][b];
// printf("%d/%d %d/%d %f %f %f %f\n", i+1, a, j+1, b, pab[i][j][a][b], pa[i][a] , pa[j][b], pab[i][j][a][b] - pa[i][a] * pa[j][b]);
}
}
}
for (i=0; i<seqlen; i++)
for (a=0; a<21; a++)
for (b=0; b<21; b++)
pab[i][i][a][b] = (a == b) ? pa[i][a] : 0.0;
gsl_matrix *cmat, *rho, *ww, *wwi, *tempmat;
ndim = seqlen * 21;
cmat = gsl_matrix_calloc(ndim, ndim);
/* Form the covariance matrix */
for (i=0; i<seqlen; i++)
for (j=0; j<seqlen; j++)
for (a=0; a<21; a++)
for (b=0; b<21; b++)
if (i != j)
gsl_matrix_set(cmat, i*21+a, j*21+b, pab[i][j][a][b] - pa[i][a] * pa[j][b]);
else if (a == b)
gsl_matrix_set(cmat, i*21+a, j*21+b, pab[i][j][a][b] - pa[i][a] * pa[j][b]);
freemat(pab);
/* Shrink sample covariance matrix towards shrinkage target F = Diag(1,1,1,...,1) * smean */
if (shrinkflg)
{
for (smean=i=0; i<ndim; i++)
smean += gsl_matrix_get(cmat, i, i);
smean /= (float)ndim;
lambda = 0.1;
// smean = 1;
tempmat = gsl_matrix_calloc(ndim, ndim);
gsl_set_error_handler_off();
for (;;)
{
gsl_matrix_memcpy(tempmat, cmat);
/* Test if positive definite using Cholesky decomposition */
if (!gsl_linalg_cholesky_decomp(tempmat))
break;
for (i=0; i<seqlen; i++)
for (j=0; j<seqlen; j++)
for (a=0; a<21; a++)
for (b=0; b<21; b++)
if (i != j)
gsl_matrix_set(cmat, i*21+a, j*21+b, (1.0 - lambda) * gsl_matrix_get(cmat, i*21+a, j*21+b));
else if (a == b)
gsl_matrix_set(cmat, i*21+a, j*21+b, smean * lambda + (1.0 - lambda) * gsl_matrix_get(cmat, i*21+a, j*21+b));
}
gsl_matrix_free(tempmat);
}
rho = gsl_matrix_alloc(ndim, ndim);
ww = gsl_matrix_alloc(ndim, ndim);
wwi = gsl_matrix_alloc(ndim, ndim);
lastfnzero=0.0;
/* Guess at a reasonable starting rho value if undefined */
if (rhodefault < 0.0)
trialrho = MAX(0.001, 1.0 / wtsum);
else
trialrho = rhodefault;
rfact = 0.0;
for (;;)
{
if (trialrho <= 0.0 || trialrho >= 1.0)
fail("Sorry - failed to find suitable value for rho (0 < rho < 1)!");
gsl_matrix_set_all(rho, trialrho);
for (i=0; i<seqlen; i++)
for (j=0; j<seqlen; j++)
for (a=0; a<21; a++)
for (b=0; b<21; b++)
if ((a != b && i == j) || pa[i][20] > maxgapf || pa[j][20] > maxgapf)
gsl_matrix_set(rho, i*21+a, j*21+b, 1e9);
/* Mask out regions if block-out list provided */
if (blockfn != NULL)
{
ifp = fopen(blockfn, "r");
for (;;)
{
if (fscanf(ifp, "%d %d %lf", &i, &j, &score) != 3)
break;
for (a=0; a<21; a++)
for (b=0; b<21; b++)
{
gsl_matrix_set(rho, (i-1)*21+a, (j-1)*21+b, score);
gsl_matrix_set(rho, (j-1)*21+b, (i-1)*21+a, score);
}
}
fclose(ifp);
}
/* All matrices are symmetric so no need to transpose before/after calling Fortran code */
glasso_(&ndim, cmat->data, rho->data, &approxflg, &initflg, &debugflg, &diagpenflg, &thresh, &maxit, ww->data, wwi->data, &niter, &del, &jerr);
if (targfnzero <= 0.0)
break;
for (npair=nnzero=i=0; i<ndim; i++)
for (j=i+1; j<ndim; j++,npair++)
if (gsl_matrix_get(wwi, i, j) != 0.0)
nnzero++;
fnzero = (double) nnzero / npair;
// printf("rho=%f fnzero = %f\n", trialrho, fnzero);
/* Stop iterating if we have achieved the target sparsity level */
if (fabs(fnzero - targfnzero)/targfnzero < 0.01)
break;
if (fnzero == 0.0)
{
/* As we have guessed far too high, halve rho and try again */
trialrho *= 0.5;
continue;
}
if (lastfnzero > 0.0 && fnzero != lastfnzero)
{
// printf("fnzero=%f lastfnzero=%f trialrho=%f oldtrialrho=%f\n", fnzero, lastfnzero, trialrho, trialrho/rfact);
rfact = pow(rfact, log(targfnzero / fnzero) / log(fnzero / lastfnzero));
// printf("New rfact = %f\n", rfact);
}
lastfnzero = fnzero;
/* Make a small trial step in the appropriate direction */
if (rfact == 0.0)
rfact = (fnzero < targfnzero) ? 0.9 : 1.1;
trialrho *= rfact;
}
gsl_matrix_free(rho);
gsl_matrix_free(ww);
/* Calculate background corrected scores using average product correction */
pcmat = allocmat(seqlen, seqlen, sizeof(double));
pcsum = allocvec(seqlen, sizeof(double));
pcmean = 0.0;
for (i=0; i<seqlen; i++)
for (j=i+1; j<seqlen; j++)
{
for (pc=a=0; a<20; a++)
for (b=0; b<20; b++)
pc += fabs(gsl_matrix_get(wwi, i*21+a, j*21+b));
pcmat[i][j] = pcmat[j][i] = pc;
pcsum[i] += pc;
pcsum[j] += pc;
pcmean += pc;
}
pcmean /= seqlen * (seqlen - 1) * 0.5;
/* Build final list of predicted contacts */
sclist = allocvec(seqlen * (seqlen - 1) / 2, sizeof(struct sc_entry));
for (scsum=scsumsq=ncon=i=0; i<seqlen; i++)
for (j=i+minseqsep; j<seqlen; j++)
if (pcmat[i][j] > 0.0)
{
/* Calculate APC score */
if (apcflg)
sclist[ncon].sc = pcmat[i][j] - pcsum[i] * pcsum[j] / SQR(seqlen - 1.0) / pcmean;
else
sclist[ncon].sc = pcmat[i][j];
scsum += sclist[ncon].sc;
scsumsq += SQR(sclist[ncon].sc);
sclist[ncon].i = i;
sclist[ncon++].j = j;
}
qsort(sclist, ncon, sizeof(struct sc_entry), cmpfn);
mean = scsum / ncon;
sd = sqrt(scsumsq / ncon - SQR(mean));
/* Print output in CASP RR format with optional PPV estimated from final Z-score */
if (rawscflg)
for (i=0; i<ncon; i++)
printf("%d %d 0 8 %f\n", sclist[i].i+1, sclist[i].j+1, sclist[i].sc);
else
for (i=0; i<ncon; i++)
{
zscore = (sclist[i].sc - mean) / sd;
ppv = 0.904 / (1.0 + 16.61 * exp(-0.8105 * zscore));
printf("%d %d 0 8 %f\n", sclist[i].i+1, sclist[i].j+1, ppv);
}
return 0;
}
|
State Before: α : Type u_1
β : Type u_3
γ : Type u_2
ι : Sort ?u.34009
π : α → Type ?u.34014
s s₁ s₂ : Set α
t t₁ t₂ : Set β
p : Set γ
f f₁ f₂ f₃ : α → β
g g₁ g₂ : β → γ
f' f₁' f₂' : β → α
g' : γ → β
a : α
b : β
h : Injective (g ∘ f)
⊢ InjOn g (range f) State After: case intro.intro
α : Type u_1
β : Type u_3
γ : Type u_2
ι : Sort ?u.34009
π : α → Type ?u.34014
s s₁ s₂ : Set α
t t₁ t₂ : Set β
p : Set γ
f f₁ f₂ f₃ : α → β
g g₁ g₂ : β → γ
f' f₁' f₂' : β → α
g' : γ → β
a : α
b : β
h : Injective (g ∘ f)
x y : α
H : g (f x) = g (f y)
⊢ f x = f y Tactic: rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ H State Before: case intro.intro
α : Type u_1
β : Type u_3
γ : Type u_2
ι : Sort ?u.34009
π : α → Type ?u.34014
s s₁ s₂ : Set α
t t₁ t₂ : Set β
p : Set γ
f f₁ f₂ f₃ : α → β
g g₁ g₂ : β → γ
f' f₁' f₂' : β → α
g' : γ → β
a : α
b : β
h : Injective (g ∘ f)
x y : α
H : g (f x) = g (f y)
⊢ f x = f y State After: no goals Tactic: exact congr_arg f (h H)
|
[STATEMENT]
lemma foldli_pick:
assumes "l\<noteq>[]"
obtains k v where "(k,v)\<in>set l"
and "(foldli l (case_option True (\<lambda>_. False)) (\<lambda>x _. Some x) None)
= Some (k,v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>k v. \<lbrakk>(k, v) \<in> set l; foldli l (case_option True (\<lambda>_. False)) (\<lambda>x _. Some x) None = Some (k, v)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
l \<noteq> []
goal (1 subgoal):
1. (\<And>k v. \<lbrakk>(k, v) \<in> set l; foldli l (case_option True (\<lambda>_. False)) (\<lambda>x _. Some x) None = Some (k, v)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases l) auto
|
%=============================================================================
\subsection{Logging on with GridPP DIRAC}
\label{sec:logondirac}
%=============================================================================
There are many ways of accessing and using Grid resources. Larger
organisations - such as the four LHC experiments - have developed their
own frameworks, architectures and mechanisms to enable their members to
run jobs and access experimental data.
One such framework -- \term{DIRAC}~\cite{DIRAC2010} -- is used by
LHCb~\cite{LHCb2008}, but also many other Grid
projects, to manage grid jobs and storage.
You can read more about DIRAC
(Distributed Infrastructure with Remote Agent Control)
on their website\footnote{%
See \href{http://diracgrid.org}{http://diracgrid.org}}
or in~\cite{DIRAC2010},
but for our purposes all you need to
know for now is that DIRAC provides a way for you to access grid
resources without worrying too much about what's going on behind the
scenes.
%-----------------------------------------------------------------------------
\subsubsection{The GridPP DIRAC instance}
\label{the-gridpp-dirac-instance}
%-----------------------------------------------------------------------------
The Imperial College London GridPP Resource Centre (RC) hosts an
instance of DIRAC on behalf of GridPP~\cite{GRIDPPDIRAC2015a,GRIDPPDIRAC2015b}.
The GridPP DIRAC instance is is
capable of serving multiple VOs, providing grid job and data management
capabilities for smaller, non-LHC user communities wishing to make use
of GridPP resources. As a new user, you are automatically registered
with the GridPP DIRAC instance and the Virtual Organisations you have
joined. You can then test out various bits of grid functionality to
determine if grid computing will meet your needs and the needs of your
users.
You can interact with the Grid via the GridPP DIRAC web portal at:
\url{https://dirac.gridpp.ac.uk}
When you access the portal, you should
see yourself listed as a \textbf{Visitor} in drop-down menu in the
bottom-right corner of the browser. Once you have joined one or more
DIRAC-supported Virtual Organisations, you will be able to select which
VO you use DIRAC as using this drop-down menu.
\begin{infobox}{The GridPP DIRAC mailing list}
\emph{You should also join the GridPP DIRAC mailing list to keep informed of
the latest developments and receive notices of any downtime. You can
join the mailing list here.}
\end{infobox}
So you've accessed the GridPP DIRAC web portal. Congratulations!
However, as discussed, we'll be using GridPP DIRAC via the Ganga
interface. In order to do that, you'll need to install your Grid
certificate on your local machine - and the instructions for
doing this are in the next section.
|
(c) Juan Gomez 2019. Thanks to Universidad EAFIT for support. This material is part of the course Introduction to Finite Element Analysis
# Two-dimensional frame elements
The code can now be easily extended to consider also frame elements as the one shown in the figure in its local reference system:
<center></center>
In this case the element has infinite axial stiffness therefore in the local system the only degrees of freedom are the transverse displacement and the rotation. The generalized displacements vector reads:
$$
u^T=\begin{bmatrix}v_1&\theta_1&v_2&\theta_2\end{bmatrix}
$$
while the vector of generalized forces (shears and moments) is:
$$
f^T=\begin{bmatrix}f_1&m_1&f_2&m_2\end{bmatrix}
$$
The force-displacement stiffness matrix in the local reference system is:
$$
$$
\begin{bmatrix}12\frac{EI}{\mathcal l^3}&6\frac{EI}{\mathcal l^3}&-12\frac{EI}{\mathcal l^3}&6\frac{EI}{\mathcal l^2}\\6\frac{EI}{\mathcal l^3}&4\frac{EI}{\mathcal l}&-6\frac{EI}{\mathcal l^2}&2\frac{EI}{\mathcal l}\\12\frac{EI}{\mathcal l^3}&-6\frac{EI}{\mathcal l^2}&12\frac{EI}{\mathcal l^3}&-6\frac{EI}{\mathcal l^2}\\6\frac{EI}{\mathcal l^2}&2\frac{EI}{\mathcal l}&-6\frac{EI}{\mathcal l^2}&4\frac{EI}{\mathcal l}\end{bmatrix}
$$
$$
To obtain the total stiffness from the structure it is now necessary to consider the stiffness contribution from all the elements in a common (**Global**) reference system and for that purpose we proceed like in the two-dimensional truss problem giving for the elemental stiffness matrix in the global reference system:
$$K=\lambda^Tk\lambda$$
where $K$ is the stiffness matrix for the two-dimensional frame element in the global reference system. It must be observed that in the global reference system the element has now three degrees of freedom per node.
In the actual implementation all the information required to compute $K$ is passed as input paramters to the elemental subroutine **uel()** as described below.
### Simple framed strucure
Cosnsider the following three-elements assemblage (The required input files are available in the files folder from the REPO):
<center></center>
find the lateral displacement of the structure when subject to the lateral load $P.$
**Question: Find the rotational transformation matrix $\lambda$ required for the formulation of the stiffness matrix in the global reference system.**
The modifications that must be applied to the spring-elements based code are only related to the fact that now there are 3 degrees of freedom are each nodal point.
```python
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sympy as sym
```
Read the input files from the **files** folder.
```python
def readin():
nodes = np.loadtxt('files/' + 'Fnodes.txt', ndmin=2)
mats = np.loadtxt('files/' + 'Fmater.txt', ndmin=2)
elements = np.loadtxt('files/' + 'Feles.txt' , ndmin=2)
loads = np.loadtxt('files/' + 'Floads.txt', ndmin=2)
return nodes, mats, elements, loads
```
**eqcounter** counts equations and generates the boundary conditions array in its second instance.
```python
def eqcounter(nodes):
nnodes = nodes.shape[0]
IBC = np.zeros([nnodes, 3], dtype=np.integer)
for i in range(nnodes):
for k in range(3):
IBC[i, k] = int(nodes[i, k+3])
neq = 0
for i in range(nnodes):
for j in range(3):
if IBC[i, j] == 0:
IBC[i, j] = neq
neq = neq + 1
return neq, IBC
```
**DME** computes the assembly operator.
```python
def DME(nodes, elements):
nels = elements.shape[0]
IELCON = np.zeros([nels, 2], dtype=np.integer)
DME = np.zeros([nels, 6], dtype=np.integer)
neq, IBC = eqcounter(nodes)
ndof = 6
nnodes = 2
for i in range(nels):
for j in range(nnodes):
IELCON[i, j] = elements[i, j+3]
kk = IELCON[i, j]
for l in range(3):
DME[i, 3*j+l] = IBC[kk, l]
return DME, IBC, neq
```
**assembly** uses the model and the **DME** operator to compute the global stiffness matrix.
```python
def assembly(elements, mats, nodes, neq, DME, uel=None):
IELCON = np.zeros([2], dtype=np.integer)
KG = np.zeros((neq, neq))
nels = elements.shape[0]
nnodes = 2
ndof = 6
for el in range(nels):
elcoor = np.zeros([nnodes, 2])
im = np.int(elements[el, 2])
par0 = mats[im, 0]
par1 = mats[im, 1]
for j in range(nnodes):
IELCON[j] = elements[el, j+3]
elcoor[j, 0] = nodes[IELCON[j], 1]
elcoor[j, 1] = nodes[IELCON[j], 2]
kloc = uelbeam2DU(elcoor, par0, par1)
dme = DME[el, :ndof]
for row in range(ndof):
glob_row = dme[row]
if glob_row != -1:
for col in range(ndof):
glob_col = dme[col]
if glob_col != -1:
KG[glob_row, glob_col] = KG[glob_row, glob_col] +\
kloc[row, col]
return KG
```
**uelbeam2D** uses the nodal point coordinates and the material parameters to compute the local stiffness matrix transformed to the global reference system.
**Question: Add comments to explains the different steps in the following subroutine. In particular identify the computation of the rotational transformation matrix $\lambda$.**
```python
def uelbeam2DU(coord, I, Emod):
"""2D-2-noded beam element
without axial deformation
Parameters
----------
coord : ndarray
Coordinates for the nodes of the element (2, 2).
A : float
Cross section area.
Emod : float
Young modulus (>0).
Returns
-------
kl : ndarray
Local stiffness matrix for the element (4, 4).
"""
vec = coord[1, :] - coord[0, :]
nx = vec[0]/np.linalg.norm(vec)
ny = vec[1]/np.linalg.norm(vec)
L = np.linalg.norm(vec)
Q = np.array([
[-ny, nx, 0, 0, 0, 0],
[0, 0, 1.0, 0, 0, 0],
[0, 0, 0, -ny, nx, 0],
[0, 0, 0, 0, 0, 1.0]])
kl = (I*Emod/(L*L*L)) * np.array([
[12.0, 6, -12.0, 6*L],
[6, 4*L*L, -6*L, 2*L*L],
[-12.0, -6*L, 12.0, -6*L],
[6*L, 2*L*L, -6*L, 4*L*L]])
kG = np.dot(np.dot(Q.T, kl), Q)
return kG
```
**loadassem** forms the vector of nodal loads.
```python
def loadasem(loads, IBC, neq, nl):
"""Assembles the global Right Hand Side Vector RHSG
Parameters
----------
loads : ndarray
Array with the loads imposed in the system.
IBC : ndarray (int)
Array that maps the nodes with number of equations.
neq : int
Number of equations in the system after removing the nodes
with imposed displacements.
nl : int
Number of loads.
Returns
-------
RHSG : ndarray
Array with the right hand side vector.
"""
RHSG = np.zeros([neq])
for i in range(nl):
il = int(loads[i, 0])
ilx = IBC[il, 0]
ily = IBC[il, 1]
ilT = IBC[il, 2]
if ilx != -1:
RHSG[ilx] = loads[i, 1]
if ily != -1:
RHSG[ily] = loads[i, 2]
if ilT != -1:
RHSG[ilT] = loads[i, 3]
return RHSG
```
The main program still retains the same structure as follows:
* Reads the model
* Builds the DME() operator
* Assembles the global system of equations
* Solves for the global displacements $UG$
```python
nodes, mats, elements, loads = readin()
DME, IBC, neq = DME(nodes, elements)
KG = assembly(elements, mats, nodes, neq, DME)
RHSG = loadasem(loads, IBC, neq, 1)
UG = np.linalg.solve(KG, RHSG)
print(UG)
```
[ 2.25000000e+01 2.00000000e+01 1.27557539e-16 -1.25918779e-15
2.00000000e+01 4.88970566e-16]
### Proposed problems
#### Problem 1
Implement a subroutine to compute the nodal forces in each element and verify the equilibrium of the system.
#### Problem 2
Find the lateral stiffness of the structure using the relation:
$$k=\frac P\delta$$
#### Problem 3
Retrofit the structure in such a way that the lateral stiffness increases by a factor of 2.0.
#### Problem 4
Fix the framed structure shown in the figure by adding elements and/or imposing appropiate displacement boundary conditions. (Note: you must create a new set of input files.)
<center></center>
### References
* Bathe, Klaus-Jürgen. (2006) Finite element procedures. Klaus-Jurgen Bathe. Prentice Hall International.
* Juan Gómez, Nicolás Guarín-Zapata (2018). SolidsPy: 2D-Finite Element Analysis with Python, <https://github.com/AppliedMechanics-EAFIT/SolidsPy>.
```python
from IPython.core.display import HTML
def css_styling():
styles = open('./nb_style.css', 'r').read()
return HTML(styles)
css_styling()
```
<link href='http://fonts.googleapis.com/css?family=Fenix' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>
<style>
/*
Template for Notebooks for Modelación computacional.
Based on Lorena Barba template available at:
https://github.com/barbagroup/AeroPython/blob/master/styles/custom.css
*/
/* Fonts */
@font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}
/* Text */
div.cell{
width:800px;
margin-left:16% !important;
margin-right:auto;
}
h1 {
font-family: 'Alegreya Sans', sans-serif;
}
h2 {
font-family: 'Fenix', serif;
}
h3{
font-family: 'Fenix', serif;
margin-top:12px;
margin-bottom: 3px;
}
h4{
font-family: 'Fenix', serif;
}
h5 {
font-family: 'Alegreya Sans', sans-serif;
}
div.text_cell_render{
font-family: 'Alegreya Sans',Computer Modern, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
line-height: 135%;
font-size: 120%;
width:600px;
margin-left:auto;
margin-right:auto;
}
.CodeMirror{
font-family: "Source Code Pro";
font-size: 90%;
}
/* .prompt{
display: None;
}*/
.text_cell_render h1 {
font-weight: 200;
font-size: 50pt;
line-height: 100%;
color:#CD2305;
margin-bottom: 0.5em;
margin-top: 0.5em;
display: block;
}
.text_cell_render h5 {
font-weight: 300;
font-size: 16pt;
color: #CD2305;
font-style: italic;
margin-bottom: .5em;
margin-top: 0.5em;
display: block;
}
.warning{
color: rgb( 240, 20, 20 )
}
</style>
```python
```
|
[STATEMENT]
lemma array_foldl_foldl:
"array_foldl (\<lambda>n. f) b (Array a) = foldl f b a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. array_foldl (\<lambda>n. f) b (Array a) = foldl f b a
[PROOF STEP]
by(simp add: array_foldl_def foldl_snd_zip)
|
#ifndef BIGGLES_PARTITION_SAMPLER_ITEMS_HPP__
#define BIGGLES_PARTITION_SAMPLER_ITEMS_HPP__
#include <boost/tuple/tuple.hpp>
#include "model.hpp"
#include "partition.hpp"
#include "mh_moves/mh_moves.hpp"
namespace biggles {
/// @brief The sample type for the partition sampler.
///
/// Something as a hack, the samples drawn by the partition sampler are the partition itself <em>and</em> the proposal
/// move which generated it.
struct partition_sampler_sample {
partition_ptr_t partition_sample_ptr;
mh_moves::move_type proposed_move; /// \brief the move that has been attempted
mh_moves::move_type executed_move; /// \brief could be the proposed move, identity or maybe none
partition_sampler_sample () :
partition_sample_ptr(new partition()), proposed_move(mh_moves::NONE), executed_move(mh_moves::NONE) {}
partition_sampler_sample (
const partition_ptr_t& part, const mh_moves::move_type prop_move, const mh_moves::move_type exec_move)
: partition_sample_ptr(part), proposed_move(prop_move), executed_move(exec_move) {};
explicit partition_sampler_sample (const partition_ptr_t& part)
: partition_sample_ptr(part), proposed_move(mh_moves::NONE), executed_move(mh_moves::NONE) {};
};
struct partition_sampler_result_t {
partition_sampler_sample partition_sample;
float proposal_mass_ratio;
partition_sampler_result_t(const partition_sampler_sample& sample, const float& pmr) :
partition_sample(sample), proposal_mass_ratio(pmr) {}
};
/// @brief A proposal function for the Biggles sampler.
struct partition_proposal : public std::unary_function<const partition&, partition_sampler_result_t >
{
/// @brief we assume that the partition is valid
partition_proposal() : partition_is_valid(true) {}
/// @brief Propose a new sample given an input partition.
///
/// @param p
partition_sampler_result_t operator () (const partition_sampler_sample& p) const;
/// @brief is the partition OK for making valid proposals
///
/// if it is not posibble to make a valid proposal for partition an infinite loop will occur
bool partition_is_valid;
};
/// @brief Evaluate the partition posterior ditribution.
///
struct partition_distribution : public std::unary_function<const partition_sampler_sample&, float>
{
partition_distribution(const model::parameters& p = model::parameters()) : params(p) { }
float operator () (const partition_sampler_sample& sample) const {
return model::log_partition_given_parameters_and_data_density(*sample.partition_sample_ptr, params);
}
model::parameters params;
};
}
#endif
|
module Algebra.Theorems where
open import Algebra
open import Reasoning
+pre-idempotence : ∀ {A} {x : Graph A} -> x + x + ε ≡ x
+pre-idempotence {_} {x} =
begin
(x + x) + ε ≡⟨ L (L (symmetry *right-identity)) ⟩
(x * ε + x) + ε ≡⟨ L (R (symmetry *right-identity)) ⟩
(x * ε + x * ε) + ε ≡⟨ R (symmetry *right-identity) ⟩
(x * ε + x * ε) + ε * ε ≡⟨ symmetry decomposition ⟩
(x * ε) * ε ≡⟨ *right-identity ⟩
x * ε ≡⟨ *right-identity ⟩
x
∎
+identity : ∀ {A} {x : Graph A} -> x + ε ≡ x
+identity {_} {x} =
begin
x + ε ≡⟨ symmetry +pre-idempotence ⟩
((x + ε) + (x + ε)) + ε ≡⟨ L +associativity ⟩
(((x + ε) + x) + ε) + ε ≡⟨ L (L (symmetry +associativity)) ⟩
((x + (ε + x)) + ε) + ε ≡⟨ L (L (R +commutativity)) ⟩
((x + (x + ε)) + ε) + ε ≡⟨ L (L +associativity) ⟩
(((x + x) + ε) + ε) + ε ≡⟨ L (symmetry +associativity) ⟩
((x + x) + (ε + ε)) + ε ≡⟨ symmetry +associativity ⟩
(x + x) + ((ε + ε) + ε) ≡⟨ R +pre-idempotence ⟩
(x + x) + ε ≡⟨ +pre-idempotence ⟩
x
∎
+idempotence : ∀ {A} {x : Graph A} -> x + x ≡ x
+idempotence = transitivity (symmetry +identity) +pre-idempotence
saturation : ∀ {A} {x : Graph A} -> x * x * x ≡ x * x
saturation {_} {x} =
begin
(x * x) * x ≡⟨ decomposition ⟩
(x * x + x * x) + x * x ≡⟨ L +idempotence ⟩
x * x + x * x ≡⟨ +idempotence ⟩
x * x
∎
absorption : ∀ {A} {x y : Graph A} -> x * y + x + y ≡ x * y
absorption {_} {x} {y} =
begin
(x * y + x) + y ≡⟨ L (R (symmetry *right-identity)) ⟩
(x * y + x * ε) + y ≡⟨ R (symmetry *right-identity) ⟩
(x * y + x * ε) + y * ε ≡⟨ symmetry decomposition ⟩
(x * y) * ε ≡⟨ *right-identity ⟩
x * y
∎
-- Subgraph relation
⊆reflexivity : ∀ {A} {x : Graph A} -> x ⊆ x
⊆reflexivity = +idempotence
⊆antisymmetry : ∀ {A} {x y : Graph A} -> x ⊆ y -> y ⊆ x -> x ≡ y
⊆antisymmetry p q = symmetry q -- x = y + x
>> +commutativity -- y + x = x + y
>> p -- x + y = y
⊆transitivity : ∀ {A} {x y z : Graph A} -> x ⊆ y -> y ⊆ z -> x ⊆ z
⊆transitivity p q = symmetry
(symmetry q -- z = y + z
>> L (symmetry p) -- y + z = (x + y) + z
>> symmetry +associativity -- (x + y) + z = x + (y + z)
>> R q) -- x + (y + z) = x + z
⊆least-element : ∀ {A} {x : Graph A} -> ε ⊆ x
⊆least-element = +commutativity >> +identity
⊆overlay : ∀ {A} {x y : Graph A} -> x ⊆ (x + y)
⊆overlay = +associativity >> L +idempotence
⊆connect : ∀ {A} {x y : Graph A} -> (x + y) ⊆ (x * y)
⊆connect = +commutativity >> +associativity >> absorption
⊆left-overlay-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (x + z) ⊆ (y + z)
⊆left-overlay-monotony {_} {x} {y} {z} p =
begin
(x + z) + (y + z) ≡⟨ symmetry +associativity ⟩
x + (z + (y + z)) ≡⟨ R +commutativity ⟩
x + ((y + z) + z) ≡⟨ R (symmetry +associativity) ⟩
x + (y + (z + z)) ≡⟨ R (R +idempotence) ⟩
x + (y + z) ≡⟨ +associativity ⟩
(x + y) + z ≡⟨ L p ⟩
y + z
∎
⊆right-overlay-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (z + x) ⊆ (z + y)
⊆right-overlay-monotony {_} {x} {y} {z} p =
begin
(z + x) + (z + y) ≡⟨ +associativity ⟩
((z + x) + z) + y ≡⟨ L +commutativity ⟩
(z + (z + x)) + y ≡⟨ L +associativity ⟩
((z + z) + x) + y ≡⟨ L (L +idempotence) ⟩
(z + x) + y ≡⟨ symmetry +associativity ⟩
z + (x + y) ≡⟨ R p ⟩
z + y
∎
⊆left-connect-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (x * z) ⊆ (y * z)
⊆left-connect-monotony {_} {x} {y} {z} p =
begin
(x * z) + (y * z) ≡⟨ symmetry right-distributivity ⟩
(x + y) * z ≡⟨ L p ⟩
y * z
∎
⊆right-connect-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (z * x) ⊆ (z * y)
⊆right-connect-monotony {_} {x} {y} {z} p =
begin
(z * x) + (z * y) ≡⟨ symmetry left-distributivity ⟩
z * (x + y) ≡⟨ R p ⟩
z * y
∎
⊆left-monotony : ∀ {A} {op : BinaryOperator} {x y z : Graph A} -> x ⊆ y -> apply op x z ⊆ apply op y z
⊆left-monotony {_} {+op} {x} {y} {z} p = ⊆left-overlay-monotony p
⊆left-monotony {_} {*op} {x} {y} {z} p = ⊆left-connect-monotony p
⊆right-monotony : ∀ {A} {op : BinaryOperator} {x y z : Graph A} -> x ⊆ y -> apply op z x ⊆ apply op z y
⊆right-monotony {_} {+op} {x} {y} {z} p = ⊆right-overlay-monotony p
⊆right-monotony {_} {*op} {x} {y} {z} p = ⊆right-connect-monotony p
|
If $z$ is not in $S$, then the function $f(w) = 1/(w-z)$ is continuous on $S$.
|
lemma image_affinity_cbox: fixes m::real fixes a b c :: "'a::euclidean_space" shows "(\<lambda>x. m *\<^sub>R x + c) ` cbox a b = (if cbox a b = {} then {} else (if 0 \<le> m then cbox (m *\<^sub>R a + c) (m *\<^sub>R b + c) else cbox (m *\<^sub>R b + c) (m *\<^sub>R a + c)))"
|
!> @file
!! Other fortran file for f_malloc routines
!! @author
!! Copyright (C) 2012-2015 BigDFT group
!! This file is distributed under the terms of the
!! GNU General Public License, see ~/COPYING file
!! or http://www.gnu.org/copyleft/gpl.txt .
!! For the list of contributors, see ~/AUTHORS
!guess the rank
m%rank=0
if (present(lbounds)) then
m%rank=size(lbounds)
m%lbounds(1:m%rank)=int(lbounds,f_kind)
end if
if (present(sizes)) then
if (m%rank == 0) then
m%rank=size(sizes)
else if (m%rank/=size(sizes)) then
call f_err_throw('sizes not conformal with lbounds'//&
',array "'//trim(m%array_id)//'", routine "'//trim(m%routine_id)//'"',ERR_INVALID_MALLOC)
return
end if
m%shape(1:m%rank)=int(sizes,f_kind)
do i=1,m%rank
m%ubounds(i)=int(m%lbounds(i),f_kind)+m%shape(i)-1
end do
if (present(ubounds)) then
if (m%rank/=size(ubounds)) then
call f_err_throw('sizes not conformal with ubounds'//&
',array "'//trim(m%array_id)//'", routine "'//trim(m%routine_id)//'"',ERR_INVALID_MALLOC)
return
end if
do i=1,m%rank
if (m%ubounds(i) /=int(ubounds(i),f_kind)) then
call f_err_throw('ubounds not conformal with sizes and lbounds'//&
',array "'//trim(m%array_id)//'", routine "'//trim(m%routine_id)//'"',ERR_INVALID_MALLOC)
return
end if
end do
end if
else
if (present(ubounds)) then
if (m%rank == 0) then
m%rank=size(ubounds)
else if (m%rank/=size(ubounds)) then
call f_err_throw('ubounds not conformal with lbounds'//&
',array "'//trim(m%array_id)//'", routine "'//trim(m%routine_id)//'"',ERR_INVALID_MALLOC)
return
end if
m%ubounds(1:m%rank)=int(ubounds,f_kind)
do i=1,m%rank
m%shape(i)=m%ubounds(i)-m%lbounds(i)+1
end do
else
call f_err_throw('at least sizes or ubounds should be defined'//&
',array "'//trim(m%array_id)//'", routine "'//trim(m%routine_id)//'"',ERR_INVALID_MALLOC)
return
end if
end if
|
(* Title: Containers/Lexicographic_Order.thy
Author: Andreas Lochbihler, KIT *)
theory Lexicographic_Order imports
List_Fusion
"HOL-Library.Char_ord"
begin
hide_const (open) List.lexordp
section \<open>List fusion for lexicographic order\<close>
context linorder begin
lemma lexordp_take_index_conv:
"lexordp xs ys \<longleftrightarrow>
(length xs < length ys \<and> take (length xs) ys = xs) \<or>
(\<exists>i < min (length xs) (length ys). take i xs = take i ys \<and> xs ! i < ys ! i)"
(is "?lhs = ?rhs")
proof
assume ?lhs thus ?rhs
by induct (auto 4 3 del: disjCI intro: disjI2 exI[where x="Suc i" for i])
next
assume ?rhs (is "?prefix \<or> ?less") thus ?lhs
proof
assume "?prefix"
hence "ys = xs @ hd (drop (length xs) ys) # tl (drop (length xs) ys)"
by (metis append_Nil2 append_take_drop_id less_not_refl list.collapse)
thus ?thesis unfolding lexordp_iff by blast
next
assume "?less"
then obtain i where "i < min (length xs) (length ys)"
and "take i xs = take i ys" and nth: "xs ! i < ys ! i" by blast
hence "xs = take i xs @ xs ! i # drop (Suc i) xs" "ys = take i xs @ ys ! i # drop (Suc i) ys"
by -(subst append_take_drop_id[symmetric, of _ i], simp_all add: Cons_nth_drop_Suc)
with nth show ?thesis unfolding lexordp_iff by blast
qed
qed
\<comment> \<open>lexord is extension of partial ordering List.lex\<close>
lemma lexordp_lex: "(xs, ys) \<in> lex {(xs, ys). xs < ys} \<longleftrightarrow> lexordp xs ys \<and> length xs = length ys"
proof(induct xs arbitrary: ys)
case Nil thus ?case by clarsimp
next
case Cons thus ?case by(cases ys)(simp_all, safe, simp)
qed
end
subsection \<open>Setup for list fusion\<close>
context ord begin
definition lexord_fusion :: "('a, 's1) generator \<Rightarrow> ('a, 's2) generator \<Rightarrow> 's1 \<Rightarrow> 's2 \<Rightarrow> bool"
where [code del]: "lexord_fusion g1 g2 s1 s2 = lexordp (list.unfoldr g1 s1) (list.unfoldr g2 s2)"
definition lexord_eq_fusion :: "('a, 's1) generator \<Rightarrow> ('a, 's2) generator \<Rightarrow> 's1 \<Rightarrow> 's2 \<Rightarrow> bool"
where [code del]: "lexord_eq_fusion g1 g2 s1 s2 = lexordp_eq (list.unfoldr g1 s1) (list.unfoldr g2 s2)"
lemma lexord_fusion_code:
"lexord_fusion g1 g2 s1 s2 \<longleftrightarrow>
(if list.has_next g1 s1 then
if list.has_next g2 s2 then
let (x, s1') = list.next g1 s1;
(y, s2') = list.next g2 s2
in x < y \<or> \<not> y < x \<and> lexord_fusion g1 g2 s1' s2'
else False
else list.has_next g2 s2)"
unfolding lexord_fusion_def
by(subst (1 2) list.unfoldr.simps)(auto split: prod.split_asm)
lemma lexord_eq_fusion_code:
"lexord_eq_fusion g1 g2 s1 s2 \<longleftrightarrow>
(list.has_next g1 s1 \<longrightarrow>
list.has_next g2 s2 \<and>
(let (x, s1') = list.next g1 s1;
(y, s2') = list.next g2 s2
in x < y \<or> \<not> y < x \<and> lexord_eq_fusion g1 g2 s1' s2'))"
unfolding lexord_eq_fusion_def
by(subst (1 2) list.unfoldr.simps)(auto split: prod.split_asm)
end
lemmas [code] =
lexord_fusion_code ord.lexord_fusion_code
lexord_eq_fusion_code ord.lexord_eq_fusion_code
lemmas [symmetric, code_unfold] =
lexord_fusion_def ord.lexord_fusion_def
lexord_eq_fusion_def ord.lexord_eq_fusion_def
end
|
# GraphHopper Directions API
#
# You use the GraphHopper Directions API to add route planning, navigation and route optimization to your software. E.g. the Routing API has turn instructions and elevation data and the Route Optimization API solves your logistic problems and supports various constraints like time window and capacity restrictions. Also it is possible to get all distances between all locations with our fast Matrix API.
#
# OpenAPI spec version: 1.0.0
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' RoutePoint Class
#'
#' @field type
#' @field coordinates
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
RoutePoint <- R6::R6Class(
'RoutePoint',
public = list(
`type` = NULL,
`coordinates` = NULL,
initialize = function(`type`, `coordinates`){
if (!missing(`type`)) {
stopifnot(is.character(`type`), length(`type`) == 1)
self$`type` <- `type`
}
if (!missing(`coordinates`)) {
stopifnot(is.list(`coordinates`), length(`coordinates`) != 0)
lapply(`coordinates`, function(x) stopifnot(R6::is.R6(x)))
self$`coordinates` <- `coordinates`
}
},
toJSON = function() {
RoutePointObject <- list()
if (!is.null(self$`type`)) {
RoutePointObject[['type']] <- self$`type`
}
if (!is.null(self$`coordinates`)) {
RoutePointObject[['coordinates']] <- lapply(self$`coordinates`, function(x) x$toJSON())
}
RoutePointObject
},
fromJSON = function(RoutePointJson) {
RoutePointObject <- jsonlite::fromJSON(RoutePointJson)
if (!is.null(RoutePointObject$`type`)) {
self$`type` <- RoutePointObject$`type`
}
if (!is.null(RoutePointObject$`coordinates`)) {
self$`coordinates` <- lapply(RoutePointObject$`coordinates`, function(x) {
coordinatesObject <- TODO_OBJECT_MAPPING$new()
coordinatesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
coordinatesObject
})
}
},
toJSONString = function() {
sprintf(
'{
"type": %s,
"coordinates": [%s]
}',
self$`type`,
lapply(self$`coordinates`, function(x) paste(x$toJSON(), sep=","))
)
},
fromJSONString = function(RoutePointJson) {
RoutePointObject <- jsonlite::fromJSON(RoutePointJson)
self$`type` <- RoutePointObject$`type`
self$`coordinates` <- lapply(RoutePointObject$`coordinates`, function(x) TODO_OBJECT_MAPPING$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
}
)
)
|
#pragma once
#include <string_view>
#include <gsl/span>
#include <spirv_cross.hpp>
namespace glslang
{
class TShader;
}
namespace Babylon
{
class ShaderCompiler
{
public:
ShaderCompiler();
~ShaderCompiler();
struct ShaderInfo
{
std::unique_ptr<const spirv_cross::Compiler> Compiler;
gsl::span<uint8_t> Bytes;
};
void Compile(std::string_view vertexSource, std::string_view fragmentSource, std::function<void(ShaderInfo, ShaderInfo)> onCompiled);
protected:
// Invert dFdy operands similar to bgfx_shader.sh
// https://github.com/bkaradzic/bgfx/blob/7be225bf490bb1cd231cfb4abf7e617bf35b59cb/src/bgfx_shader.sh#L44-L45
// https://github.com/bkaradzic/bgfx/blob/7be225bf490bb1cd231cfb4abf7e617bf35b59cb/src/bgfx_shader.sh#L62-L65
static void InvertYDerivativeOperands(glslang::TShader& shader);
};
}
|
(* Title: Nominal2_Base
Authors: Christian Urban, Brian Huffman, Cezary Kaliszyk
Basic definitions and lemma infrastructure for
Nominal Isabelle.
*)
theory Nominal2_Base
imports "~~/src/HOL/Library/Old_Datatype"
"~~/src/HOL/Library/Infinite_Set"
"~~/src/HOL/Library/Multiset"
"~~/src/HOL/Library/FSet"
"~~/src/HOL/Library/FinFun"
keywords
"atom_decl" "equivariance" :: thy_decl
begin
declare [[typedef_overloaded]]
section {* Atoms and Sorts *}
text {* A simple implementation for @{text atom_sorts} is strings. *}
(* types atom_sort = string *)
text {* To deal with Church-like binding we use trees of
strings as sorts. *}
datatype atom_sort = Sort "string" "atom_sort list"
datatype atom = Atom atom_sort nat
text {* Basic projection function. *}
primrec
sort_of :: "atom \<Rightarrow> atom_sort"
where
"sort_of (Atom s n) = s"
primrec
nat_of :: "atom \<Rightarrow> nat"
where
"nat_of (Atom s n) = n"
text {* There are infinitely many atoms of each sort. *}
lemma INFM_sort_of_eq:
shows "INFM a. sort_of a = s"
proof -
have "INFM i. sort_of (Atom s i) = s" by simp
moreover have "inj (Atom s)" by (simp add: inj_on_def)
ultimately show "INFM a. sort_of a = s" by (rule INFM_inj)
qed
lemma infinite_sort_of_eq:
shows "infinite {a. sort_of a = s}"
using INFM_sort_of_eq unfolding INFM_iff_infinite .
lemma atom_infinite [simp]:
shows "infinite (UNIV :: atom set)"
using subset_UNIV infinite_sort_of_eq
by (rule infinite_super)
lemma obtain_atom:
fixes X :: "atom set"
assumes X: "finite X"
obtains a where "a \<notin> X" "sort_of a = s"
proof -
from X have "MOST a. a \<notin> X"
unfolding MOST_iff_cofinite by simp
with INFM_sort_of_eq
have "INFM a. sort_of a = s \<and> a \<notin> X"
by (rule INFM_conjI)
then obtain a where "a \<notin> X" "sort_of a = s"
by (auto elim: INFM_E)
then show ?thesis ..
qed
lemma atom_components_eq_iff:
fixes a b :: atom
shows "a = b \<longleftrightarrow> sort_of a = sort_of b \<and> nat_of a = nat_of b"
by (induct a, induct b, simp)
section {* Sort-Respecting Permutations *}
definition
"perm \<equiv> {f. bij f \<and> finite {a. f a \<noteq> a} \<and> (\<forall>a. sort_of (f a) = sort_of a)}"
typedef perm = "perm"
proof
show "id \<in> perm" unfolding perm_def by simp
qed
lemma permI:
assumes "bij f" and "MOST x. f x = x" and "\<And>a. sort_of (f a) = sort_of a"
shows "f \<in> perm"
using assms unfolding perm_def MOST_iff_cofinite by simp
lemma perm_is_bij: "f \<in> perm \<Longrightarrow> bij f"
unfolding perm_def by simp
lemma perm_is_finite: "f \<in> perm \<Longrightarrow> finite {a. f a \<noteq> a}"
unfolding perm_def by simp
lemma perm_is_sort_respecting: "f \<in> perm \<Longrightarrow> sort_of (f a) = sort_of a"
unfolding perm_def by simp
lemma perm_MOST: "f \<in> perm \<Longrightarrow> MOST x. f x = x"
unfolding perm_def MOST_iff_cofinite by simp
lemma perm_id: "id \<in> perm"
unfolding perm_def by simp
lemma perm_comp:
assumes f: "f \<in> perm" and g: "g \<in> perm"
shows "(f \<circ> g) \<in> perm"
apply (rule permI)
apply (rule bij_comp)
apply (rule perm_is_bij [OF g])
apply (rule perm_is_bij [OF f])
apply (rule MOST_rev_mp [OF perm_MOST [OF g]])
apply (rule MOST_rev_mp [OF perm_MOST [OF f]])
apply (simp)
apply (simp add: perm_is_sort_respecting [OF f])
apply (simp add: perm_is_sort_respecting [OF g])
done
lemma perm_inv:
assumes f: "f \<in> perm"
shows "(inv f) \<in> perm"
apply (rule permI)
apply (rule bij_imp_bij_inv)
apply (rule perm_is_bij [OF f])
apply (rule MOST_mono [OF perm_MOST [OF f]])
apply (erule subst, rule inv_f_f)
apply (rule bij_is_inj [OF perm_is_bij [OF f]])
apply (rule perm_is_sort_respecting [OF f, THEN sym, THEN trans])
apply (simp add: surj_f_inv_f [OF bij_is_surj [OF perm_is_bij [OF f]]])
done
lemma bij_Rep_perm: "bij (Rep_perm p)"
using Rep_perm [of p] unfolding perm_def by simp
lemma finite_Rep_perm: "finite {a. Rep_perm p a \<noteq> a}"
using Rep_perm [of p] unfolding perm_def by simp
lemma sort_of_Rep_perm: "sort_of (Rep_perm p a) = sort_of a"
using Rep_perm [of p] unfolding perm_def by simp
lemma Rep_perm_ext:
"Rep_perm p1 = Rep_perm p2 \<Longrightarrow> p1 = p2"
by (simp add: fun_eq_iff Rep_perm_inject [symmetric])
instance perm :: size ..
subsection {* Permutations form a (multiplicative) group *}
instantiation perm :: group_add
begin
definition
"0 = Abs_perm id"
definition
"- p = Abs_perm (inv (Rep_perm p))"
definition
"p + q = Abs_perm (Rep_perm p \<circ> Rep_perm q)"
definition
"(p1::perm) - p2 = p1 + - p2"
lemma Rep_perm_0: "Rep_perm 0 = id"
unfolding zero_perm_def
by (simp add: Abs_perm_inverse perm_id)
lemma Rep_perm_add:
"Rep_perm (p1 + p2) = Rep_perm p1 \<circ> Rep_perm p2"
unfolding plus_perm_def
by (simp add: Abs_perm_inverse perm_comp Rep_perm)
lemma Rep_perm_uminus:
"Rep_perm (- p) = inv (Rep_perm p)"
unfolding uminus_perm_def
by (simp add: Abs_perm_inverse perm_inv Rep_perm)
instance
apply standard
unfolding Rep_perm_inject [symmetric]
unfolding minus_perm_def
unfolding Rep_perm_add
unfolding Rep_perm_uminus
unfolding Rep_perm_0
by (simp_all add: o_assoc inv_o_cancel [OF bij_is_inj [OF bij_Rep_perm]])
end
section {* Implementation of swappings *}
definition
swap :: "atom \<Rightarrow> atom \<Rightarrow> perm" ("'(_ \<rightleftharpoons> _')")
where
"(a \<rightleftharpoons> b) =
Abs_perm (if sort_of a = sort_of b
then (\<lambda>c. if a = c then b else if b = c then a else c)
else id)"
lemma Rep_perm_swap:
"Rep_perm (a \<rightleftharpoons> b) =
(if sort_of a = sort_of b
then (\<lambda>c. if a = c then b else if b = c then a else c)
else id)"
unfolding swap_def
apply (rule Abs_perm_inverse)
apply (rule permI)
apply (auto simp: bij_def inj_on_def surj_def)[1]
apply (rule MOST_rev_mp [OF MOST_neq(1) [of a]])
apply (rule MOST_rev_mp [OF MOST_neq(1) [of b]])
apply (simp)
apply (simp)
done
lemmas Rep_perm_simps =
Rep_perm_0
Rep_perm_add
Rep_perm_uminus
Rep_perm_swap
lemma swap_different_sorts [simp]:
"sort_of a \<noteq> sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) = 0"
by (rule Rep_perm_ext) (simp add: Rep_perm_simps)
lemma swap_cancel:
shows "(a \<rightleftharpoons> b) + (a \<rightleftharpoons> b) = 0"
and "(a \<rightleftharpoons> b) + (b \<rightleftharpoons> a) = 0"
by (rule_tac [!] Rep_perm_ext)
(simp_all add: Rep_perm_simps fun_eq_iff)
lemma swap_self [simp]:
"(a \<rightleftharpoons> a) = 0"
by (rule Rep_perm_ext, simp add: Rep_perm_simps fun_eq_iff)
lemma minus_swap [simp]:
"- (a \<rightleftharpoons> b) = (a \<rightleftharpoons> b)"
by (rule minus_unique [OF swap_cancel(1)])
lemma swap_commute:
"(a \<rightleftharpoons> b) = (b \<rightleftharpoons> a)"
by (rule Rep_perm_ext)
(simp add: Rep_perm_swap fun_eq_iff)
lemma swap_triple:
assumes "a \<noteq> b" and "c \<noteq> b"
assumes "sort_of a = sort_of b" "sort_of b = sort_of c"
shows "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)"
using assms
by (rule_tac Rep_perm_ext)
(auto simp: Rep_perm_simps fun_eq_iff)
section {* Permutation Types *}
text {*
Infix syntax for @{text permute} has higher precedence than
addition, but lower than unary minus.
*}
class pt =
fixes permute :: "perm \<Rightarrow> 'a \<Rightarrow> 'a" ("_ \<bullet> _" [76, 75] 75)
assumes permute_zero [simp]: "0 \<bullet> x = x"
assumes permute_plus [simp]: "(p + q) \<bullet> x = p \<bullet> (q \<bullet> x)"
begin
lemma permute_diff [simp]:
shows "(p - q) \<bullet> x = p \<bullet> - q \<bullet> x"
using permute_plus [of p "- q" x] by simp
lemma permute_minus_cancel [simp]:
shows "p \<bullet> - p \<bullet> x = x"
and "- p \<bullet> p \<bullet> x = x"
unfolding permute_plus [symmetric] by simp_all
lemma permute_swap_cancel [simp]:
shows "(a \<rightleftharpoons> b) \<bullet> (a \<rightleftharpoons> b) \<bullet> x = x"
unfolding permute_plus [symmetric]
by (simp add: swap_cancel)
lemma permute_swap_cancel2 [simp]:
shows "(a \<rightleftharpoons> b) \<bullet> (b \<rightleftharpoons> a) \<bullet> x = x"
unfolding permute_plus [symmetric]
by (simp add: swap_commute)
lemma inj_permute [simp]:
shows "inj (permute p)"
by (rule inj_on_inverseI)
(rule permute_minus_cancel)
lemma surj_permute [simp]:
shows "surj (permute p)"
by (rule surjI, rule permute_minus_cancel)
lemma bij_permute [simp]:
shows "bij (permute p)"
by (rule bijI [OF inj_permute surj_permute])
lemma inv_permute:
shows "inv (permute p) = permute (- p)"
by (rule inv_equality) (simp_all)
lemma permute_minus:
shows "permute (- p) = inv (permute p)"
by (simp add: inv_permute)
lemma permute_eq_iff [simp]:
shows "p \<bullet> x = p \<bullet> y \<longleftrightarrow> x = y"
by (rule inj_permute [THEN inj_eq])
end
subsection {* Permutations for atoms *}
instantiation atom :: pt
begin
definition
"p \<bullet> a = (Rep_perm p) a"
instance
apply standard
apply(simp_all add: permute_atom_def Rep_perm_simps)
done
end
lemma sort_of_permute [simp]:
shows "sort_of (p \<bullet> a) = sort_of a"
unfolding permute_atom_def by (rule sort_of_Rep_perm)
lemma swap_atom:
shows "(a \<rightleftharpoons> b) \<bullet> c =
(if sort_of a = sort_of b
then (if c = a then b else if c = b then a else c) else c)"
unfolding permute_atom_def
by (simp add: Rep_perm_swap)
lemma swap_atom_simps [simp]:
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> a = b"
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> b = a"
"c \<noteq> a \<Longrightarrow> c \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> c = c"
unfolding swap_atom by simp_all
lemma perm_eq_iff:
fixes p q :: "perm"
shows "p = q \<longleftrightarrow> (\<forall>a::atom. p \<bullet> a = q \<bullet> a)"
unfolding permute_atom_def
by (metis Rep_perm_ext ext)
subsection {* Permutations for permutations *}
instantiation perm :: pt
begin
definition
"p \<bullet> q = p + q - p"
instance
apply standard
apply (simp add: permute_perm_def)
apply (simp add: permute_perm_def algebra_simps)
done
end
lemma permute_self:
shows "p \<bullet> p = p"
unfolding permute_perm_def
by (simp add: add.assoc)
lemma pemute_minus_self:
shows "- p \<bullet> p = p"
unfolding permute_perm_def
by (simp add: add.assoc)
subsection {* Permutations for functions *}
instantiation "fun" :: (pt, pt) pt
begin
definition
"p \<bullet> f = (\<lambda>x. p \<bullet> (f (- p \<bullet> x)))"
instance
apply standard
apply (simp add: permute_fun_def)
apply (simp add: permute_fun_def minus_add)
done
end
lemma permute_fun_app_eq:
shows "p \<bullet> (f x) = (p \<bullet> f) (p \<bullet> x)"
unfolding permute_fun_def by simp
lemma permute_fun_comp:
shows "p \<bullet> f = (permute p) o f o (permute (-p))"
by (simp add: comp_def permute_fun_def)
subsection {* Permutations for booleans *}
instantiation bool :: pt
begin
definition "p \<bullet> (b::bool) = b"
instance
apply standard
apply(simp_all add: permute_bool_def)
done
end
lemma permute_boolE:
fixes P::"bool"
shows "p \<bullet> P \<Longrightarrow> P"
by (simp add: permute_bool_def)
lemma permute_boolI:
fixes P::"bool"
shows "P \<Longrightarrow> p \<bullet> P"
by(simp add: permute_bool_def)
subsection {* Permutations for sets *}
instantiation "set" :: (pt) pt
begin
definition
"p \<bullet> X = {p \<bullet> x | x. x \<in> X}"
instance
apply standard
apply (auto simp: permute_set_def)
done
end
lemma permute_set_eq:
shows "p \<bullet> X = {x. - p \<bullet> x \<in> X}"
unfolding permute_set_def
by (auto) (metis permute_minus_cancel(1))
lemma permute_set_eq_image:
shows "p \<bullet> X = permute p ` X"
unfolding permute_set_def by auto
lemma permute_set_eq_vimage:
shows "p \<bullet> X = permute (- p) -` X"
unfolding permute_set_eq vimage_def
by simp
lemma permute_finite [simp]:
shows "finite (p \<bullet> X) = finite X"
unfolding permute_set_eq_vimage
using bij_permute by (rule finite_vimage_iff)
lemma swap_set_not_in:
assumes a: "a \<notin> S" "b \<notin> S"
shows "(a \<rightleftharpoons> b) \<bullet> S = S"
unfolding permute_set_def
using a by (auto simp: swap_atom)
lemma swap_set_in:
assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b"
shows "(a \<rightleftharpoons> b) \<bullet> S \<noteq> S"
unfolding permute_set_def
using a by (auto simp: swap_atom)
lemma swap_set_in_eq:
assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b"
shows "(a \<rightleftharpoons> b) \<bullet> S = (S - {a}) \<union> {b}"
unfolding permute_set_def
using a by (auto simp: swap_atom)
lemma swap_set_both_in:
assumes a: "a \<in> S" "b \<in> S"
shows "(a \<rightleftharpoons> b) \<bullet> S = S"
unfolding permute_set_def
using a by (auto simp: swap_atom)
lemma mem_permute_iff:
shows "(p \<bullet> x) \<in> (p \<bullet> X) \<longleftrightarrow> x \<in> X"
unfolding permute_set_def
by auto
lemma empty_eqvt:
shows "p \<bullet> {} = {}"
unfolding permute_set_def
by (simp)
lemma insert_eqvt:
shows "p \<bullet> (insert x A) = insert (p \<bullet> x) (p \<bullet> A)"
unfolding permute_set_eq_image image_insert ..
subsection {* Permutations for @{typ unit} *}
instantiation unit :: pt
begin
definition "p \<bullet> (u::unit) = u"
instance
by standard (simp_all add: permute_unit_def)
end
subsection {* Permutations for products *}
instantiation prod :: (pt, pt) pt
begin
primrec
permute_prod
where
Pair_eqvt: "p \<bullet> (x, y) = (p \<bullet> x, p \<bullet> y)"
instance
by standard auto
end
subsection {* Permutations for sums *}
instantiation sum :: (pt, pt) pt
begin
primrec
permute_sum
where
Inl_eqvt: "p \<bullet> (Inl x) = Inl (p \<bullet> x)"
| Inr_eqvt: "p \<bullet> (Inr y) = Inr (p \<bullet> y)"
instance
by standard (case_tac [!] x, simp_all)
end
subsection {* Permutations for @{typ "'a list"} *}
instantiation list :: (pt) pt
begin
primrec
permute_list
where
Nil_eqvt: "p \<bullet> [] = []"
| Cons_eqvt: "p \<bullet> (x # xs) = p \<bullet> x # p \<bullet> xs"
instance
by standard (induct_tac [!] x, simp_all)
end
lemma set_eqvt:
shows "p \<bullet> (set xs) = set (p \<bullet> xs)"
by (induct xs) (simp_all add: empty_eqvt insert_eqvt)
subsection {* Permutations for @{typ "'a option"} *}
instantiation option :: (pt) pt
begin
primrec
permute_option
where
None_eqvt: "p \<bullet> None = None"
| Some_eqvt: "p \<bullet> (Some x) = Some (p \<bullet> x)"
instance
by standard (induct_tac [!] x, simp_all)
end
subsection {* Permutations for @{typ "'a multiset"} *}
instantiation multiset :: (pt) pt
begin
definition
"p \<bullet> M = {# p \<bullet> x. x :# M #}"
instance
proof
fix M :: "'a multiset" and p q :: "perm"
show "0 \<bullet> M = M"
unfolding permute_multiset_def
by (induct_tac M) (simp_all)
show "(p + q) \<bullet> M = p \<bullet> q \<bullet> M"
unfolding permute_multiset_def
by (induct_tac M) (simp_all)
qed
end
lemma permute_multiset [simp]:
fixes M N::"('a::pt) multiset"
shows "(p \<bullet> {#}) = ({#} ::('a::pt) multiset)"
and "(p \<bullet> add_mset x M) = add_mset (p \<bullet> x) (p \<bullet> M)"
and "(p \<bullet> (M + N)) = (p \<bullet> M) + (p \<bullet> N)"
unfolding permute_multiset_def
by (simp_all)
subsection {* Permutations for @{typ "'a fset"} *}
instantiation fset :: (pt) pt
begin
context includes fset.lifting begin
lift_definition
"permute_fset" :: "perm \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
is "permute :: perm \<Rightarrow> 'a set \<Rightarrow> 'a set" by simp
end
context includes fset.lifting begin
instance
proof
fix x :: "'a fset" and p q :: "perm"
show "0 \<bullet> x = x" by transfer simp
show "(p + q) \<bullet> x = p \<bullet> q \<bullet> x" by transfer simp
qed
end
end
context includes fset.lifting
begin
lemma permute_fset [simp]:
fixes S::"('a::pt) fset"
shows "(p \<bullet> {||}) = ({||} ::('a::pt) fset)"
and "(p \<bullet> finsert x S) = finsert (p \<bullet> x) (p \<bullet> S)"
apply (transfer, simp add: empty_eqvt)
apply (transfer, simp add: insert_eqvt)
done
lemma fset_eqvt:
shows "p \<bullet> (fset S) = fset (p \<bullet> S)"
by transfer simp
end
subsection {* Permutations for @{typ "('a, 'b) finfun"} *}
instantiation finfun :: (pt, pt) pt
begin
lift_definition
permute_finfun :: "perm \<Rightarrow> ('a, 'b) finfun \<Rightarrow> ('a, 'b) finfun"
is
"permute :: perm \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)"
apply(simp add: permute_fun_comp)
apply(rule finfun_right_compose)
apply(rule finfun_left_compose)
apply(assumption)
apply(simp)
done
instance
apply standard
apply(transfer)
apply(simp)
apply(transfer)
apply(simp)
done
end
subsection {* Permutations for @{typ char}, @{typ nat}, and @{typ int} *}
instantiation char :: pt
begin
definition "p \<bullet> (c::char) = c"
instance
by standard (simp_all add: permute_char_def)
end
instantiation nat :: pt
begin
definition "p \<bullet> (n::nat) = n"
instance
by standard (simp_all add: permute_nat_def)
end
instantiation int :: pt
begin
definition "p \<bullet> (i::int) = i"
instance
by standard (simp_all add: permute_int_def)
end
section {* Pure types *}
text {* Pure types will have always empty support. *}
class pure = pt +
assumes permute_pure: "p \<bullet> x = x"
text {* Types @{typ unit} and @{typ bool} are pure. *}
instance unit :: pure
proof qed (rule permute_unit_def)
instance bool :: pure
proof qed (rule permute_bool_def)
text {* Other type constructors preserve purity. *}
instance "fun" :: (pure, pure) pure
by standard (simp add: permute_fun_def permute_pure)
instance set :: (pure) pure
by standard (simp add: permute_set_def permute_pure)
instance prod :: (pure, pure) pure
by standard (induct_tac x, simp add: permute_pure)
instance sum :: (pure, pure) pure
by standard (induct_tac x, simp_all add: permute_pure)
instance list :: (pure) pure
by standard (induct_tac x, simp_all add: permute_pure)
instance option :: (pure) pure
by standard (induct_tac x, simp_all add: permute_pure)
subsection {* Types @{typ char}, @{typ nat}, and @{typ int} *}
instance char :: pure
proof qed (rule permute_char_def)
instance nat :: pure
proof qed (rule permute_nat_def)
instance int :: pure
proof qed (rule permute_int_def)
section {* Infrastructure for Equivariance and @{text Perm_simp} *}
subsection {* Basic functions about permutations *}
ML_file "nominal_basics.ML"
subsection {* Eqvt infrastructure *}
text {* Setup of the theorem attributes @{text eqvt} and @{text eqvt_raw}. *}
ML_file "nominal_thmdecls.ML"
lemmas [eqvt] =
(* pt types *)
permute_prod.simps
permute_list.simps
permute_option.simps
permute_sum.simps
(* sets *)
empty_eqvt insert_eqvt set_eqvt
(* fsets *)
permute_fset fset_eqvt
(* multisets *)
permute_multiset
subsection {* @{text perm_simp} infrastructure *}
definition
"unpermute p = permute (- p)"
lemma eqvt_apply:
fixes f :: "'a::pt \<Rightarrow> 'b::pt"
and x :: "'a::pt"
shows "p \<bullet> (f x) \<equiv> (p \<bullet> f) (p \<bullet> x)"
unfolding permute_fun_def by simp
lemma eqvt_lambda:
fixes f :: "'a::pt \<Rightarrow> 'b::pt"
shows "p \<bullet> f \<equiv> (\<lambda>x. p \<bullet> (f (unpermute p x)))"
unfolding permute_fun_def unpermute_def by simp
lemma eqvt_bound:
shows "p \<bullet> unpermute p x \<equiv> x"
unfolding unpermute_def by simp
text {* provides @{text perm_simp} methods *}
ML_file "nominal_permeq.ML"
method_setup perm_simp =
{* Nominal_Permeq.args_parser >> Nominal_Permeq.perm_simp_meth *}
{* pushes permutations inside. *}
method_setup perm_strict_simp =
{* Nominal_Permeq.args_parser >> Nominal_Permeq.perm_strict_simp_meth *}
{* pushes permutations inside, raises an error if it cannot solve all permutations. *}
simproc_setup perm_simproc ("p \<bullet> t") = {* fn _ => fn ctxt => fn ctrm =>
case Thm.term_of (Thm.dest_arg ctrm) of
Free _ => NONE
| Var _ => NONE
| Const (@{const_name permute}, _) $ _ $ _ => NONE
| _ =>
let
val thm = Nominal_Permeq.eqvt_conv ctxt Nominal_Permeq.eqvt_strict_config ctrm
handle ERROR _ => Thm.reflexive ctrm
in
if Thm.is_reflexive thm then NONE else SOME(thm)
end
*}
subsubsection {* Equivariance for permutations and swapping *}
lemma permute_eqvt:
shows "p \<bullet> (q \<bullet> x) = (p \<bullet> q) \<bullet> (p \<bullet> x)"
unfolding permute_perm_def by simp
(* the normal version of this lemma would cause loops *)
lemma permute_eqvt_raw [eqvt_raw]:
shows "p \<bullet> permute \<equiv> permute"
apply(simp add: fun_eq_iff permute_fun_def)
apply(subst permute_eqvt)
apply(simp)
done
lemma zero_perm_eqvt [eqvt]:
shows "p \<bullet> (0::perm) = 0"
unfolding permute_perm_def by simp
lemma add_perm_eqvt [eqvt]:
fixes p p1 p2 :: perm
shows "p \<bullet> (p1 + p2) = p \<bullet> p1 + p \<bullet> p2"
unfolding permute_perm_def
by (simp add: perm_eq_iff)
lemma swap_eqvt [eqvt]:
shows "p \<bullet> (a \<rightleftharpoons> b) = (p \<bullet> a \<rightleftharpoons> p \<bullet> b)"
unfolding permute_perm_def
by (auto simp: swap_atom perm_eq_iff)
lemma uminus_eqvt [eqvt]:
fixes p q::"perm"
shows "p \<bullet> (- q) = - (p \<bullet> q)"
unfolding permute_perm_def
by (simp add: diff_add_eq_diff_diff_swap)
subsubsection {* Equivariance of Logical Operators *}
lemma eq_eqvt [eqvt]:
shows "p \<bullet> (x = y) \<longleftrightarrow> (p \<bullet> x) = (p \<bullet> y)"
unfolding permute_eq_iff permute_bool_def ..
lemma Not_eqvt [eqvt]:
shows "p \<bullet> (\<not> A) \<longleftrightarrow> \<not> (p \<bullet> A)"
by (simp add: permute_bool_def)
lemma conj_eqvt [eqvt]:
shows "p \<bullet> (A \<and> B) \<longleftrightarrow> (p \<bullet> A) \<and> (p \<bullet> B)"
by (simp add: permute_bool_def)
lemma imp_eqvt [eqvt]:
shows "p \<bullet> (A \<longrightarrow> B) \<longleftrightarrow> (p \<bullet> A) \<longrightarrow> (p \<bullet> B)"
by (simp add: permute_bool_def)
declare imp_eqvt[folded HOL.induct_implies_def, eqvt]
lemma all_eqvt [eqvt]:
shows "p \<bullet> (\<forall>x. P x) = (\<forall>x. (p \<bullet> P) x)"
unfolding All_def
by (perm_simp) (rule refl)
declare all_eqvt[folded HOL.induct_forall_def, eqvt]
lemma ex_eqvt [eqvt]:
shows "p \<bullet> (\<exists>x. P x) = (\<exists>x. (p \<bullet> P) x)"
unfolding Ex_def
by (perm_simp) (rule refl)
lemma ex1_eqvt [eqvt]:
shows "p \<bullet> (\<exists>!x. P x) = (\<exists>!x. (p \<bullet> P) x)"
unfolding Ex1_def
by (perm_simp) (rule refl)
lemma if_eqvt [eqvt]:
shows "p \<bullet> (if b then x else y) = (if p \<bullet> b then p \<bullet> x else p \<bullet> y)"
by (simp add: permute_fun_def permute_bool_def)
lemma True_eqvt [eqvt]:
shows "p \<bullet> True = True"
unfolding permute_bool_def ..
lemma False_eqvt [eqvt]:
shows "p \<bullet> False = False"
unfolding permute_bool_def ..
lemma disj_eqvt [eqvt]:
shows "p \<bullet> (A \<or> B) \<longleftrightarrow> (p \<bullet> A) \<or> (p \<bullet> B)"
by (simp add: permute_bool_def)
lemma all_eqvt2:
shows "p \<bullet> (\<forall>x. P x) = (\<forall>x. p \<bullet> P (- p \<bullet> x))"
by (perm_simp add: permute_minus_cancel) (rule refl)
lemma ex_eqvt2:
shows "p \<bullet> (\<exists>x. P x) = (\<exists>x. p \<bullet> P (- p \<bullet> x))"
by (perm_simp add: permute_minus_cancel) (rule refl)
lemma ex1_eqvt2:
shows "p \<bullet> (\<exists>!x. P x) = (\<exists>!x. p \<bullet> P (- p \<bullet> x))"
by (perm_simp add: permute_minus_cancel) (rule refl)
lemma the_eqvt:
assumes unique: "\<exists>!x. P x"
shows "(p \<bullet> (THE x. P x)) = (THE x. (p \<bullet> P) x)"
apply(rule the1_equality [symmetric])
apply(rule_tac p="-p" in permute_boolE)
apply(perm_simp add: permute_minus_cancel)
apply(rule unique)
apply(rule_tac p="-p" in permute_boolE)
apply(perm_simp add: permute_minus_cancel)
apply(rule theI'[OF unique])
done
lemma the_eqvt2:
assumes unique: "\<exists>!x. P x"
shows "(p \<bullet> (THE x. P x)) = (THE x. p \<bullet> P (- p \<bullet> x))"
apply(rule the1_equality [symmetric])
apply(simp only: ex1_eqvt2[symmetric])
apply(simp add: permute_bool_def unique)
apply(simp add: permute_bool_def)
apply(rule theI'[OF unique])
done
subsubsection {* Equivariance of Set operators *}
lemma mem_eqvt [eqvt]:
shows "p \<bullet> (x \<in> A) \<longleftrightarrow> (p \<bullet> x) \<in> (p \<bullet> A)"
unfolding permute_bool_def permute_set_def
by (auto)
lemma Collect_eqvt [eqvt]:
shows "p \<bullet> {x. P x} = {x. (p \<bullet> P) x}"
unfolding permute_set_eq permute_fun_def
by (auto simp: permute_bool_def)
lemma Bex_eqvt [eqvt]:
shows "p \<bullet> (\<exists>x \<in> S. P x) = (\<exists>x \<in> (p \<bullet> S). (p \<bullet> P) x)"
unfolding Bex_def by simp
lemma Ball_eqvt [eqvt]:
shows "p \<bullet> (\<forall>x \<in> S. P x) = (\<forall>x \<in> (p \<bullet> S). (p \<bullet> P) x)"
unfolding Ball_def by simp
lemma image_eqvt [eqvt]:
shows "p \<bullet> (f ` A) = (p \<bullet> f) ` (p \<bullet> A)"
unfolding image_def by simp
lemma Image_eqvt [eqvt]:
shows "p \<bullet> (R `` A) = (p \<bullet> R) `` (p \<bullet> A)"
unfolding Image_def by simp
lemma UNIV_eqvt [eqvt]:
shows "p \<bullet> UNIV = UNIV"
unfolding UNIV_def
by (perm_simp) (rule refl)
lemma inter_eqvt [eqvt]:
shows "p \<bullet> (A \<inter> B) = (p \<bullet> A) \<inter> (p \<bullet> B)"
unfolding Int_def by simp
lemma Inter_eqvt [eqvt]:
shows "p \<bullet> \<Inter>S = \<Inter>(p \<bullet> S)"
unfolding Inter_eq by simp
lemma union_eqvt [eqvt]:
shows "p \<bullet> (A \<union> B) = (p \<bullet> A) \<union> (p \<bullet> B)"
unfolding Un_def by simp
lemma Union_eqvt [eqvt]:
shows "p \<bullet> \<Union>A = \<Union>(p \<bullet> A)"
unfolding Union_eq
by perm_simp rule
lemma Diff_eqvt [eqvt]:
fixes A B :: "'a::pt set"
shows "p \<bullet> (A - B) = (p \<bullet> A) - (p \<bullet> B)"
unfolding set_diff_eq by simp
lemma Compl_eqvt [eqvt]:
fixes A :: "'a::pt set"
shows "p \<bullet> (- A) = - (p \<bullet> A)"
unfolding Compl_eq_Diff_UNIV by simp
lemma subset_eqvt [eqvt]:
shows "p \<bullet> (S \<subseteq> T) \<longleftrightarrow> (p \<bullet> S) \<subseteq> (p \<bullet> T)"
unfolding subset_eq by simp
lemma psubset_eqvt [eqvt]:
shows "p \<bullet> (S \<subset> T) \<longleftrightarrow> (p \<bullet> S) \<subset> (p \<bullet> T)"
unfolding psubset_eq by simp
lemma vimage_eqvt [eqvt]:
shows "p \<bullet> (f -` A) = (p \<bullet> f) -` (p \<bullet> A)"
unfolding vimage_def by simp
lemma foldr_eqvt[eqvt]:
"p \<bullet> foldr f xs = foldr (p \<bullet> f) (p \<bullet> xs)"
apply(induct xs)
apply(simp_all)
apply(perm_simp exclude: foldr)
apply(simp)
done
(* FIXME: eqvt attribute *)
lemma Sigma_eqvt:
shows "(p \<bullet> (X \<times> Y)) = (p \<bullet> X) \<times> (p \<bullet> Y)"
unfolding Sigma_def
by (perm_simp) (rule refl)
text {*
In order to prove that lfp is equivariant we need two
auxiliary classes which specify that (op <=) and
Inf are equivariant. Instances for bool and fun are
given.
*}
class le_eqvt = order +
assumes le_eqvt [eqvt]: "p \<bullet> (x \<le> y) = ((p \<bullet> x) \<le> (p \<bullet> (y::('a::{pt, order}))))"
class inf_eqvt = Inf +
assumes inf_eqvt [eqvt]: "p \<bullet> (Inf X) = Inf (p \<bullet> (X::('a::{pt, complete_lattice}) set))"
instantiation bool :: le_eqvt
begin
instance
apply standard
unfolding le_bool_def
apply(perm_simp)
apply(rule refl)
done
end
instantiation "fun" :: (pt, le_eqvt) le_eqvt
begin
instance
apply standard
unfolding le_fun_def
apply(perm_simp)
apply(rule refl)
done
end
instantiation bool :: inf_eqvt
begin
instance
apply standard
unfolding Inf_bool_def
apply(perm_simp)
apply(rule refl)
done
end
instantiation "fun" :: (pt, inf_eqvt) inf_eqvt
begin
instance
apply standard
unfolding Inf_fun_def
apply(perm_simp)
apply(rule refl)
done
end
lemma lfp_eqvt [eqvt]:
fixes F::"('a \<Rightarrow> 'b) \<Rightarrow> ('a::pt \<Rightarrow> 'b::{inf_eqvt, le_eqvt})"
shows "p \<bullet> (lfp F) = lfp (p \<bullet> F)"
unfolding lfp_def
by simp
lemma finite_eqvt [eqvt]:
shows "p \<bullet> finite A = finite (p \<bullet> A)"
unfolding finite_def
by simp
lemma fun_upd_eqvt[eqvt]:
shows "p \<bullet> (f(x := y)) = (p \<bullet> f)((p \<bullet> x) := (p \<bullet> y))"
unfolding fun_upd_def
by simp
lemma comp_eqvt [eqvt]:
shows "p \<bullet> (f \<circ> g) = (p \<bullet> f) \<circ> (p \<bullet> g)"
unfolding comp_def
by simp
subsubsection {* Equivariance for product operations *}
lemma fst_eqvt [eqvt]:
shows "p \<bullet> (fst x) = fst (p \<bullet> x)"
by (cases x) simp
lemma snd_eqvt [eqvt]:
shows "p \<bullet> (snd x) = snd (p \<bullet> x)"
by (cases x) simp
lemma split_eqvt [eqvt]:
shows "p \<bullet> (case_prod P x) = case_prod (p \<bullet> P) (p \<bullet> x)"
unfolding split_def
by simp
subsubsection {* Equivariance for list operations *}
lemma append_eqvt [eqvt]:
shows "p \<bullet> (xs @ ys) = (p \<bullet> xs) @ (p \<bullet> ys)"
by (induct xs) auto
lemma rev_eqvt [eqvt]:
shows "p \<bullet> (rev xs) = rev (p \<bullet> xs)"
by (induct xs) (simp_all add: append_eqvt)
lemma map_eqvt [eqvt]:
shows "p \<bullet> (map f xs) = map (p \<bullet> f) (p \<bullet> xs)"
by (induct xs) (simp_all)
lemma removeAll_eqvt [eqvt]:
shows "p \<bullet> (removeAll x xs) = removeAll (p \<bullet> x) (p \<bullet> xs)"
by (induct xs) (auto)
lemma filter_eqvt [eqvt]:
shows "p \<bullet> (filter f xs) = filter (p \<bullet> f) (p \<bullet> xs)"
apply(induct xs)
apply(simp)
apply(simp only: filter.simps permute_list.simps if_eqvt)
apply(simp only: permute_fun_app_eq)
done
lemma distinct_eqvt [eqvt]:
shows "p \<bullet> (distinct xs) = distinct (p \<bullet> xs)"
apply(induct xs)
apply(simp add: permute_bool_def)
apply(simp add: conj_eqvt Not_eqvt mem_eqvt set_eqvt)
done
lemma length_eqvt [eqvt]:
shows "p \<bullet> (length xs) = length (p \<bullet> xs)"
by (induct xs) (simp_all add: permute_pure)
subsubsection {* Equivariance for @{typ "'a option"} *}
lemma map_option_eqvt[eqvt]:
shows "p \<bullet> (map_option f x) = map_option (p \<bullet> f) (p \<bullet> x)"
by (cases x) (simp_all)
subsubsection {* Equivariance for @{typ "'a fset"} *}
context includes fset.lifting begin
lemma in_fset_eqvt [eqvt]:
shows "(p \<bullet> (x |\<in>| S)) = ((p \<bullet> x) |\<in>| (p \<bullet> S))"
by transfer simp
lemma union_fset_eqvt [eqvt]:
shows "(p \<bullet> (S |\<union>| T)) = ((p \<bullet> S) |\<union>| (p \<bullet> T))"
by (induct S) (simp_all)
lemma inter_fset_eqvt [eqvt]:
shows "(p \<bullet> (S |\<inter>| T)) = ((p \<bullet> S) |\<inter>| (p \<bullet> T))"
by transfer simp
lemma subset_fset_eqvt [eqvt]:
shows "(p \<bullet> (S |\<subseteq>| T)) = ((p \<bullet> S) |\<subseteq>| (p \<bullet> T))"
by transfer simp
lemma map_fset_eqvt [eqvt]:
shows "p \<bullet> (f |`| S) = (p \<bullet> f) |`| (p \<bullet> S)"
by transfer simp
end
subsubsection {* Equivariance for @{typ "('a, 'b) finfun"} *}
lemma finfun_update_eqvt [eqvt]:
shows "(p \<bullet> (finfun_update f a b)) = finfun_update (p \<bullet> f) (p \<bullet> a) (p \<bullet> b)"
by (transfer) (simp)
lemma finfun_const_eqvt [eqvt]:
shows "(p \<bullet> (finfun_const b)) = finfun_const (p \<bullet> b)"
by (transfer) (simp)
lemma finfun_apply_eqvt [eqvt]:
shows "(p \<bullet> (finfun_apply f b)) = finfun_apply (p \<bullet> f) (p \<bullet> b)"
by (transfer) (simp)
section {* Supp, Freshness and Supports *}
context pt
begin
definition
supp :: "'a \<Rightarrow> atom set"
where
"supp x = {a. infinite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}}"
definition
fresh :: "atom \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp> _" [55, 55] 55)
where
"a \<sharp> x \<equiv> a \<notin> supp x"
end
lemma supp_conv_fresh:
shows "supp x = {a. \<not> a \<sharp> x}"
unfolding fresh_def by simp
lemma swap_rel_trans:
assumes "sort_of a = sort_of b"
assumes "sort_of b = sort_of c"
assumes "(a \<rightleftharpoons> c) \<bullet> x = x"
assumes "(b \<rightleftharpoons> c) \<bullet> x = x"
shows "(a \<rightleftharpoons> b) \<bullet> x = x"
proof (cases)
assume "a = b \<or> c = b"
with assms show "(a \<rightleftharpoons> b) \<bullet> x = x" by auto
next
assume *: "\<not> (a = b \<or> c = b)"
have "((a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c)) \<bullet> x = x"
using assms by simp
also have "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)"
using assms * by (simp add: swap_triple)
finally show "(a \<rightleftharpoons> b) \<bullet> x = x" .
qed
lemma swap_fresh_fresh:
assumes a: "a \<sharp> x"
and b: "b \<sharp> x"
shows "(a \<rightleftharpoons> b) \<bullet> x = x"
proof (cases)
assume asm: "sort_of a = sort_of b"
have "finite {c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x}" "finite {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x}"
using a b unfolding fresh_def supp_def by simp_all
then have "finite ({c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x} \<union> {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x})" by simp
then obtain c
where "(a \<rightleftharpoons> c) \<bullet> x = x" "(b \<rightleftharpoons> c) \<bullet> x = x" "sort_of c = sort_of b"
by (rule obtain_atom) (auto)
then show "(a \<rightleftharpoons> b) \<bullet> x = x" using asm by (rule_tac swap_rel_trans) (simp_all)
next
assume "sort_of a \<noteq> sort_of b"
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by simp
qed
subsection {* supp and fresh are equivariant *}
lemma supp_eqvt [eqvt]:
shows "p \<bullet> (supp x) = supp (p \<bullet> x)"
unfolding supp_def by simp
lemma fresh_eqvt [eqvt]:
shows "p \<bullet> (a \<sharp> x) = (p \<bullet> a) \<sharp> (p \<bullet> x)"
unfolding fresh_def by simp
lemma fresh_permute_iff:
shows "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x"
by (simp only: fresh_eqvt[symmetric] permute_bool_def)
lemma fresh_permute_left:
shows "a \<sharp> p \<bullet> x \<longleftrightarrow> - p \<bullet> a \<sharp> x"
proof
assume "a \<sharp> p \<bullet> x"
then have "- p \<bullet> a \<sharp> - p \<bullet> p \<bullet> x" by (simp only: fresh_permute_iff)
then show "- p \<bullet> a \<sharp> x" by simp
next
assume "- p \<bullet> a \<sharp> x"
then have "p \<bullet> - p \<bullet> a \<sharp> p \<bullet> x" by (simp only: fresh_permute_iff)
then show "a \<sharp> p \<bullet> x" by simp
qed
section {* supports *}
definition
supports :: "atom set \<Rightarrow> 'a::pt \<Rightarrow> bool" (infixl "supports" 80)
where
"S supports x \<equiv> \<forall>a b. (a \<notin> S \<and> b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x)"
lemma supp_is_subset:
fixes S :: "atom set"
and x :: "'a::pt"
assumes a1: "S supports x"
and a2: "finite S"
shows "(supp x) \<subseteq> S"
proof (rule ccontr)
assume "\<not> (supp x \<subseteq> S)"
then obtain a where b1: "a \<in> supp x" and b2: "a \<notin> S" by auto
from a1 b2 have "\<forall>b. b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" unfolding supports_def by auto
then have "{b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x} \<subseteq> S" by auto
with a2 have "finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}" by (simp add: finite_subset)
then have "a \<notin> (supp x)" unfolding supp_def by simp
with b1 show False by simp
qed
lemma supports_finite:
fixes S :: "atom set"
and x :: "'a::pt"
assumes a1: "S supports x"
and a2: "finite S"
shows "finite (supp x)"
proof -
have "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
then show "finite (supp x)" using a2 by (simp add: finite_subset)
qed
lemma supp_supports:
fixes x :: "'a::pt"
shows "(supp x) supports x"
unfolding supports_def
proof (intro strip)
fix a b
assume "a \<notin> (supp x) \<and> b \<notin> (supp x)"
then have "a \<sharp> x" and "b \<sharp> x" by (simp_all add: fresh_def)
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh)
qed
lemma supports_fresh:
fixes x :: "'a::pt"
assumes a1: "S supports x"
and a2: "finite S"
and a3: "a \<notin> S"
shows "a \<sharp> x"
unfolding fresh_def
proof -
have "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
then show "a \<notin> (supp x)" using a3 by auto
qed
lemma supp_is_least_supports:
fixes S :: "atom set"
and x :: "'a::pt"
assumes a1: "S supports x"
and a2: "finite S"
and a3: "\<And>S'. finite S' \<Longrightarrow> (S' supports x) \<Longrightarrow> S \<subseteq> S'"
shows "(supp x) = S"
proof (rule equalityI)
show "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
with a2 have fin: "finite (supp x)" by (rule rev_finite_subset)
have "(supp x) supports x" by (rule supp_supports)
with fin a3 show "S \<subseteq> supp x" by blast
qed
lemma subsetCI:
shows "(\<And>x. x \<in> A \<Longrightarrow> x \<notin> B \<Longrightarrow> False) \<Longrightarrow> A \<subseteq> B"
by auto
lemma finite_supp_unique:
assumes a1: "S supports x"
assumes a2: "finite S"
assumes a3: "\<And>a b. \<lbrakk>a \<in> S; b \<notin> S; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x \<noteq> x"
shows "(supp x) = S"
using a1 a2
proof (rule supp_is_least_supports)
fix S'
assume "finite S'" and "S' supports x"
show "S \<subseteq> S'"
proof (rule subsetCI)
fix a
assume "a \<in> S" and "a \<notin> S'"
have "finite (S \<union> S')"
using `finite S` `finite S'` by simp
then obtain b where "b \<notin> S \<union> S'" and "sort_of b = sort_of a"
by (rule obtain_atom)
then have "b \<notin> S" and "b \<notin> S'" and "sort_of a = sort_of b"
by simp_all
then have "(a \<rightleftharpoons> b) \<bullet> x = x"
using `a \<notin> S'` `S' supports x` by (simp add: supports_def)
moreover have "(a \<rightleftharpoons> b) \<bullet> x \<noteq> x"
using `a \<in> S` `b \<notin> S` `sort_of a = sort_of b`
by (rule a3)
ultimately show "False" by simp
qed
qed
section {* Support w.r.t. relations *}
text {*
This definition is used for unquotient types, where
alpha-equivalence does not coincide with equality.
*}
definition
"supp_rel R x = {a. infinite {b. \<not>(R ((a \<rightleftharpoons> b) \<bullet> x) x)}}"
section {* Finitely-supported types *}
class fs = pt +
assumes finite_supp: "finite (supp x)"
lemma pure_supp:
fixes x::"'a::pure"
shows "supp x = {}"
unfolding supp_def by (simp add: permute_pure)
lemma pure_fresh:
fixes x::"'a::pure"
shows "a \<sharp> x"
unfolding fresh_def by (simp add: pure_supp)
instance pure < fs
by standard (simp add: pure_supp)
subsection {* Type @{typ atom} is finitely-supported. *}
lemma supp_atom:
shows "supp a = {a}"
apply (rule finite_supp_unique)
apply (clarsimp simp add: supports_def)
apply simp
apply simp
done
lemma fresh_atom:
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> b"
unfolding fresh_def supp_atom by simp
instance atom :: fs
by standard (simp add: supp_atom)
section {* Type @{typ perm} is finitely-supported. *}
lemma perm_swap_eq:
shows "(a \<rightleftharpoons> b) \<bullet> p = p \<longleftrightarrow> (p \<bullet> (a \<rightleftharpoons> b)) = (a \<rightleftharpoons> b)"
unfolding permute_perm_def
by (metis add_diff_cancel minus_perm_def)
lemma supports_perm:
shows "{a. p \<bullet> a \<noteq> a} supports p"
unfolding supports_def
unfolding perm_swap_eq
by (simp add: swap_eqvt)
lemma finite_perm_lemma:
shows "finite {a::atom. p \<bullet> a \<noteq> a}"
using finite_Rep_perm [of p]
unfolding permute_atom_def .
lemma supp_perm:
shows "supp p = {a. p \<bullet> a \<noteq> a}"
apply (rule finite_supp_unique)
apply (rule supports_perm)
apply (rule finite_perm_lemma)
apply (simp add: perm_swap_eq swap_eqvt)
apply (auto simp: perm_eq_iff swap_atom)
done
lemma fresh_perm:
shows "a \<sharp> p \<longleftrightarrow> p \<bullet> a = a"
unfolding fresh_def
by (simp add: supp_perm)
lemma supp_swap:
shows "supp (a \<rightleftharpoons> b) = (if a = b \<or> sort_of a \<noteq> sort_of b then {} else {a, b})"
by (auto simp: supp_perm swap_atom)
lemma fresh_swap:
shows "a \<sharp> (b \<rightleftharpoons> c) \<longleftrightarrow> (sort_of b \<noteq> sort_of c) \<or> b = c \<or> (a \<sharp> b \<and> a \<sharp> c)"
by (simp add: fresh_def supp_swap supp_atom)
lemma fresh_zero_perm:
shows "a \<sharp> (0::perm)"
unfolding fresh_perm by simp
lemma supp_zero_perm:
shows "supp (0::perm) = {}"
unfolding supp_perm by simp
lemma fresh_plus_perm:
fixes p q::perm
assumes "a \<sharp> p" "a \<sharp> q"
shows "a \<sharp> (p + q)"
using assms
unfolding fresh_def
by (auto simp: supp_perm)
lemma supp_plus_perm:
fixes p q::perm
shows "supp (p + q) \<subseteq> supp p \<union> supp q"
by (auto simp: supp_perm)
lemma fresh_minus_perm:
fixes p::perm
shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p"
unfolding fresh_def
unfolding supp_perm
apply(simp)
apply(metis permute_minus_cancel)
done
lemma supp_minus_perm:
fixes p::perm
shows "supp (- p) = supp p"
unfolding supp_conv_fresh
by (simp add: fresh_minus_perm)
lemma plus_perm_eq:
fixes p q::"perm"
assumes asm: "supp p \<inter> supp q = {}"
shows "p + q = q + p"
unfolding perm_eq_iff
proof
fix a::"atom"
show "(p + q) \<bullet> a = (q + p) \<bullet> a"
proof -
{ assume "a \<notin> supp p" "a \<notin> supp q"
then have "(p + q) \<bullet> a = (q + p) \<bullet> a"
by (simp add: supp_perm)
}
moreover
{ assume a: "a \<in> supp p" "a \<notin> supp q"
then have "p \<bullet> a \<in> supp p" by (simp add: supp_perm)
then have "p \<bullet> a \<notin> supp q" using asm by auto
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a"
by (simp add: supp_perm)
}
moreover
{ assume a: "a \<notin> supp p" "a \<in> supp q"
then have "q \<bullet> a \<in> supp q" by (simp add: supp_perm)
then have "q \<bullet> a \<notin> supp p" using asm by auto
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a"
by (simp add: supp_perm)
}
ultimately show "(p + q) \<bullet> a = (q + p) \<bullet> a"
using asm by blast
qed
qed
lemma supp_plus_perm_eq:
fixes p q::perm
assumes asm: "supp p \<inter> supp q = {}"
shows "supp (p + q) = supp p \<union> supp q"
proof -
{ fix a::"atom"
assume "a \<in> supp p"
then have "a \<notin> supp q" using asm by auto
then have "a \<in> supp (p + q)" using `a \<in> supp p`
by (simp add: supp_perm)
}
moreover
{ fix a::"atom"
assume "a \<in> supp q"
then have "a \<notin> supp p" using asm by auto
then have "a \<in> supp (q + p)" using `a \<in> supp q`
by (simp add: supp_perm)
then have "a \<in> supp (p + q)" using asm plus_perm_eq
by metis
}
ultimately have "supp p \<union> supp q \<subseteq> supp (p + q)"
by blast
then show "supp (p + q) = supp p \<union> supp q" using supp_plus_perm
by blast
qed
lemma perm_eq_iff2:
fixes p q :: "perm"
shows "p = q \<longleftrightarrow> (\<forall>a::atom \<in> supp p \<union> supp q. p \<bullet> a = q \<bullet> a)"
unfolding perm_eq_iff
apply(auto)
apply(case_tac "a \<sharp> p \<and> a \<sharp> q")
apply(simp add: fresh_perm)
apply(simp add: fresh_def)
done
instance perm :: fs
by standard (simp add: supp_perm finite_perm_lemma)
section {* Finite Support instances for other types *}
subsection {* Type @{typ "'a \<times> 'b"} is finitely-supported. *}
lemma supp_Pair:
shows "supp (x, y) = supp x \<union> supp y"
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
lemma fresh_Pair:
shows "a \<sharp> (x, y) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> y"
by (simp add: fresh_def supp_Pair)
lemma supp_Unit:
shows "supp () = {}"
by (simp add: supp_def)
lemma fresh_Unit:
shows "a \<sharp> ()"
by (simp add: fresh_def supp_Unit)
instance prod :: (fs, fs) fs
apply standard
apply (case_tac x)
apply (simp add: supp_Pair finite_supp)
done
subsection {* Type @{typ "'a + 'b"} is finitely supported *}
lemma supp_Inl:
shows "supp (Inl x) = supp x"
by (simp add: supp_def)
lemma supp_Inr:
shows "supp (Inr x) = supp x"
by (simp add: supp_def)
lemma fresh_Inl:
shows "a \<sharp> Inl x \<longleftrightarrow> a \<sharp> x"
by (simp add: fresh_def supp_Inl)
lemma fresh_Inr:
shows "a \<sharp> Inr y \<longleftrightarrow> a \<sharp> y"
by (simp add: fresh_def supp_Inr)
instance sum :: (fs, fs) fs
apply standard
apply (case_tac x)
apply (simp_all add: supp_Inl supp_Inr finite_supp)
done
subsection {* Type @{typ "'a option"} is finitely supported *}
lemma supp_None:
shows "supp None = {}"
by (simp add: supp_def)
lemma supp_Some:
shows "supp (Some x) = supp x"
by (simp add: supp_def)
lemma fresh_None:
shows "a \<sharp> None"
by (simp add: fresh_def supp_None)
lemma fresh_Some:
shows "a \<sharp> Some x \<longleftrightarrow> a \<sharp> x"
by (simp add: fresh_def supp_Some)
instance option :: (fs) fs
apply standard
apply (induct_tac x)
apply (simp_all add: supp_None supp_Some finite_supp)
done
subsubsection {* Type @{typ "'a list"} is finitely supported *}
lemma supp_Nil:
shows "supp [] = {}"
by (simp add: supp_def)
lemma fresh_Nil:
shows "a \<sharp> []"
by (simp add: fresh_def supp_Nil)
lemma supp_Cons:
shows "supp (x # xs) = supp x \<union> supp xs"
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
lemma fresh_Cons:
shows "a \<sharp> (x # xs) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> xs"
by (simp add: fresh_def supp_Cons)
lemma supp_append:
shows "supp (xs @ ys) = supp xs \<union> supp ys"
by (induct xs) (auto simp: supp_Nil supp_Cons)
lemma fresh_append:
shows "a \<sharp> (xs @ ys) \<longleftrightarrow> a \<sharp> xs \<and> a \<sharp> ys"
by (induct xs) (simp_all add: fresh_Nil fresh_Cons)
lemma supp_rev:
shows "supp (rev xs) = supp xs"
by (induct xs) (auto simp: supp_append supp_Cons supp_Nil)
lemma fresh_rev:
shows "a \<sharp> rev xs \<longleftrightarrow> a \<sharp> xs"
by (induct xs) (auto simp: fresh_append fresh_Cons fresh_Nil)
lemma supp_removeAll:
fixes x::"atom"
shows "supp (removeAll x xs) = supp xs - {x}"
by (induct xs)
(auto simp: supp_Nil supp_Cons supp_atom)
lemma supp_of_atom_list:
fixes as::"atom list"
shows "supp as = set as"
by (induct as)
(simp_all add: supp_Nil supp_Cons supp_atom)
instance list :: (fs) fs
apply standard
apply (induct_tac x)
apply (simp_all add: supp_Nil supp_Cons finite_supp)
done
section {* Support and Freshness for Applications *}
lemma fresh_conv_MOST:
shows "a \<sharp> x \<longleftrightarrow> (MOST b. (a \<rightleftharpoons> b) \<bullet> x = x)"
unfolding fresh_def supp_def
unfolding MOST_iff_cofinite by simp
lemma fresh_fun_app:
assumes "a \<sharp> f" and "a \<sharp> x"
shows "a \<sharp> f x"
using assms
unfolding fresh_conv_MOST
unfolding permute_fun_app_eq
by (elim MOST_rev_mp) (simp)
lemma supp_fun_app:
shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)"
using fresh_fun_app
unfolding fresh_def
by auto
subsection {* Equivariance Predicate @{text eqvt} and @{text eqvt_at}*}
definition
"eqvt f \<equiv> \<forall>p. p \<bullet> f = f"
lemma eqvt_boolI:
fixes f::"bool"
shows "eqvt f"
unfolding eqvt_def by (simp add: permute_bool_def)
text {* equivariance of a function at a given argument *}
definition
"eqvt_at f x \<equiv> \<forall>p. p \<bullet> (f x) = f (p \<bullet> x)"
lemma eqvtI:
shows "(\<And>p. p \<bullet> f \<equiv> f) \<Longrightarrow> eqvt f"
unfolding eqvt_def
by simp
lemma eqvt_at_perm:
assumes "eqvt_at f x"
shows "eqvt_at f (q \<bullet> x)"
proof -
{ fix p::"perm"
have "p \<bullet> (f (q \<bullet> x)) = p \<bullet> q \<bullet> (f x)"
using assms by (simp add: eqvt_at_def)
also have "\<dots> = (p + q) \<bullet> (f x)" by simp
also have "\<dots> = f ((p + q) \<bullet> x)"
using assms by (simp only: eqvt_at_def)
finally have "p \<bullet> (f (q \<bullet> x)) = f (p \<bullet> q \<bullet> x)" by simp }
then show "eqvt_at f (q \<bullet> x)" unfolding eqvt_at_def
by simp
qed
lemma supp_fun_eqvt:
assumes a: "eqvt f"
shows "supp f = {}"
using a
unfolding eqvt_def
unfolding supp_def
by simp
lemma fresh_fun_eqvt:
assumes a: "eqvt f"
shows "a \<sharp> f"
using a
unfolding fresh_def
by (simp add: supp_fun_eqvt)
lemma fresh_fun_eqvt_app:
assumes a: "eqvt f"
shows "a \<sharp> x \<Longrightarrow> a \<sharp> f x"
proof -
from a have "supp f = {}" by (simp add: supp_fun_eqvt)
then show "a \<sharp> x \<Longrightarrow> a \<sharp> f x"
unfolding fresh_def
using supp_fun_app by auto
qed
lemma supp_fun_app_eqvt:
assumes a: "eqvt f"
shows "supp (f x) \<subseteq> supp x"
using fresh_fun_eqvt_app[OF a]
unfolding fresh_def
by auto
lemma supp_eqvt_at:
assumes asm: "eqvt_at f x"
and fin: "finite (supp x)"
shows "supp (f x) \<subseteq> supp x"
apply(rule supp_is_subset)
unfolding supports_def
unfolding fresh_def[symmetric]
using asm
apply(simp add: eqvt_at_def)
apply(simp add: swap_fresh_fresh)
apply(rule fin)
done
lemma finite_supp_eqvt_at:
assumes asm: "eqvt_at f x"
and fin: "finite (supp x)"
shows "finite (supp (f x))"
apply(rule finite_subset)
apply(rule supp_eqvt_at[OF asm fin])
apply(rule fin)
done
lemma fresh_eqvt_at:
assumes asm: "eqvt_at f x"
and fin: "finite (supp x)"
and fresh: "a \<sharp> x"
shows "a \<sharp> f x"
using fresh
unfolding fresh_def
using supp_eqvt_at[OF asm fin]
by auto
text {* for handling of freshness of functions *}
simproc_setup fresh_fun_simproc ("a \<sharp> (f::'a::pt \<Rightarrow>'b::pt)") = {* fn _ => fn ctxt => fn ctrm =>
let
val _ $ _ $ f = Thm.term_of ctrm
in
case (Term.add_frees f [], Term.add_vars f []) of
([], []) => SOME(@{thm fresh_fun_eqvt[simplified eqvt_def, THEN Eq_TrueI]})
| (x::_, []) =>
let
val argx = Free x
val absf = absfree x f
val cty_inst =
[SOME (Thm.ctyp_of ctxt (fastype_of argx)), SOME (Thm.ctyp_of ctxt (fastype_of f))]
val ctrm_inst = [NONE, SOME (Thm.cterm_of ctxt absf), SOME (Thm.cterm_of ctxt argx)]
val thm = Thm.instantiate' cty_inst ctrm_inst @{thm fresh_fun_app}
in
SOME(thm RS @{thm Eq_TrueI})
end
| (_, _) => NONE
end
*}
subsection {* helper functions for @{text nominal_functions} *}
lemma THE_defaultI2:
assumes "\<exists>!x. P x" "\<And>x. P x \<Longrightarrow> Q x"
shows "Q (THE_default d P)"
by (iprover intro: assms THE_defaultI')
lemma the_default_eqvt:
assumes unique: "\<exists>!x. P x"
shows "(p \<bullet> (THE_default d P)) = (THE_default (p \<bullet> d) (p \<bullet> P))"
apply(rule THE_default1_equality [symmetric])
apply(rule_tac p="-p" in permute_boolE)
apply(simp add: ex1_eqvt)
apply(rule unique)
apply(rule_tac p="-p" in permute_boolE)
apply(rule subst[OF permute_fun_app_eq])
apply(simp)
apply(rule THE_defaultI'[OF unique])
done
lemma fundef_ex1_eqvt:
fixes x::"'a::pt"
assumes f_def: "f == (\<lambda>x::'a. THE_default (d x) (G x))"
assumes eqvt: "eqvt G"
assumes ex1: "\<exists>!y. G x y"
shows "(p \<bullet> (f x)) = f (p \<bullet> x)"
apply(simp only: f_def)
apply(subst the_default_eqvt)
apply(rule ex1)
apply(rule THE_default1_equality [symmetric])
apply(rule_tac p="-p" in permute_boolE)
apply(perm_simp add: permute_minus_cancel)
using eqvt[simplified eqvt_def]
apply(simp)
apply(rule ex1)
apply(rule THE_defaultI2)
apply(rule_tac p="-p" in permute_boolE)
apply(perm_simp add: permute_minus_cancel)
apply(rule ex1)
apply(perm_simp)
using eqvt[simplified eqvt_def]
apply(simp)
done
lemma fundef_ex1_eqvt_at:
fixes x::"'a::pt"
assumes f_def: "f == (\<lambda>x::'a. THE_default (d x) (G x))"
assumes eqvt: "eqvt G"
assumes ex1: "\<exists>!y. G x y"
shows "eqvt_at f x"
unfolding eqvt_at_def
using assms
by (auto intro: fundef_ex1_eqvt)
lemma fundef_ex1_prop:
fixes x::"'a::pt"
assumes f_def: "f == (\<lambda>x::'a. THE_default (d x) (G x))"
assumes P_all: "\<And>x y. G x y \<Longrightarrow> P x y"
assumes ex1: "\<exists>!y. G x y"
shows "P x (f x)"
unfolding f_def
using ex1
apply(erule_tac ex1E)
apply(rule THE_defaultI2)
apply(blast)
apply(rule P_all)
apply(assumption)
done
section {* Support of Finite Sets of Finitely Supported Elements *}
text {* support and freshness for atom sets *}
lemma supp_finite_atom_set:
fixes S::"atom set"
assumes "finite S"
shows "supp S = S"
apply(rule finite_supp_unique)
apply(simp add: supports_def)
apply(simp add: swap_set_not_in)
apply(rule assms)
apply(simp add: swap_set_in)
done
lemma supp_cofinite_atom_set:
fixes S::"atom set"
assumes "finite (UNIV - S)"
shows "supp S = (UNIV - S)"
apply(rule finite_supp_unique)
apply(simp add: supports_def)
apply(simp add: swap_set_both_in)
apply(rule assms)
apply(subst swap_commute)
apply(simp add: swap_set_in)
done
lemma fresh_finite_atom_set:
fixes S::"atom set"
assumes "finite S"
shows "a \<sharp> S \<longleftrightarrow> a \<notin> S"
unfolding fresh_def
by (simp add: supp_finite_atom_set[OF assms])
lemma fresh_minus_atom_set:
fixes S::"atom set"
assumes "finite S"
shows "a \<sharp> S - T \<longleftrightarrow> (a \<notin> T \<longrightarrow> a \<sharp> S)"
unfolding fresh_def
by (auto simp: supp_finite_atom_set assms)
lemma Union_supports_set:
shows "(\<Union>x \<in> S. supp x) supports S"
proof -
{ fix a b
have "\<forall>x \<in> S. (a \<rightleftharpoons> b) \<bullet> x = x \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> S = S"
unfolding permute_set_def by force
}
then show "(\<Union>x \<in> S. supp x) supports S"
unfolding supports_def
by (simp add: fresh_def[symmetric] swap_fresh_fresh)
qed
lemma Union_of_finite_supp_sets:
fixes S::"('a::fs set)"
assumes fin: "finite S"
shows "finite (\<Union>x\<in>S. supp x)"
using fin by (induct) (auto simp: finite_supp)
lemma Union_included_in_supp:
fixes S::"('a::fs set)"
assumes fin: "finite S"
shows "(\<Union>x\<in>S. supp x) \<subseteq> supp S"
proof -
have eqvt: "eqvt (\<lambda>S. \<Union>x \<in> S. supp x)"
unfolding eqvt_def by simp
have "(\<Union>x\<in>S. supp x) = supp (\<Union>x\<in>S. supp x)"
by (rule supp_finite_atom_set[symmetric]) (rule Union_of_finite_supp_sets[OF fin])
also have "\<dots> \<subseteq> supp S" using eqvt
by (rule supp_fun_app_eqvt)
finally show "(\<Union>x\<in>S. supp x) \<subseteq> supp S" .
qed
lemma supp_of_finite_sets:
fixes S::"('a::fs set)"
assumes fin: "finite S"
shows "(supp S) = (\<Union>x\<in>S. supp x)"
apply(rule subset_antisym)
apply(rule supp_is_subset)
apply(rule Union_supports_set)
apply(rule Union_of_finite_supp_sets[OF fin])
apply(rule Union_included_in_supp[OF fin])
done
lemma finite_sets_supp:
fixes S::"('a::fs set)"
assumes "finite S"
shows "finite (supp S)"
using assms
by (simp only: supp_of_finite_sets Union_of_finite_supp_sets)
lemma supp_of_finite_union:
fixes S T::"('a::fs) set"
assumes fin1: "finite S"
and fin2: "finite T"
shows "supp (S \<union> T) = supp S \<union> supp T"
using fin1 fin2
by (simp add: supp_of_finite_sets)
lemma fresh_finite_union:
fixes S T::"('a::fs) set"
assumes fin1: "finite S"
and fin2: "finite T"
shows "a \<sharp> (S \<union> T) \<longleftrightarrow> a \<sharp> S \<and> a \<sharp> T"
unfolding fresh_def
by (simp add: supp_of_finite_union[OF fin1 fin2])
lemma supp_of_finite_insert:
fixes S::"('a::fs) set"
assumes fin: "finite S"
shows "supp (insert x S) = supp x \<union> supp S"
using fin
by (simp add: supp_of_finite_sets)
lemma fresh_finite_insert:
fixes S::"('a::fs) set"
assumes fin: "finite S"
shows "a \<sharp> (insert x S) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> S"
using fin unfolding fresh_def
by (simp add: supp_of_finite_insert)
lemma supp_set_empty:
shows "supp {} = {}"
unfolding supp_def
by (simp add: empty_eqvt)
lemma fresh_set_empty:
shows "a \<sharp> {}"
by (simp add: fresh_def supp_set_empty)
lemma supp_set:
fixes xs :: "('a::fs) list"
shows "supp (set xs) = supp xs"
apply(induct xs)
apply(simp add: supp_set_empty supp_Nil)
apply(simp add: supp_Cons supp_of_finite_insert)
done
lemma fresh_set:
fixes xs :: "('a::fs) list"
shows "a \<sharp> (set xs) \<longleftrightarrow> a \<sharp> xs"
unfolding fresh_def
by (simp add: supp_set)
subsection {* Type @{typ "'a multiset"} is finitely supported *}
lemma set_mset_eqvt [eqvt]:
shows "p \<bullet> (set_mset M) = set_mset (p \<bullet> M)"
by (induct M) (simp_all add: insert_eqvt empty_eqvt)
lemma supp_set_mset:
shows "supp (set_mset M) \<subseteq> supp M"
apply (rule supp_fun_app_eqvt)
unfolding eqvt_def
apply(perm_simp)
apply(simp)
done
lemma Union_finite_multiset:
fixes M::"'a::fs multiset"
shows "finite (\<Union>{supp x | x. x \<in># M})"
proof -
have "finite (\<Union>(supp ` {x. x \<in># M}))"
by (induct M) (simp_all add: Collect_imp_eq Collect_neg_eq finite_supp)
then show "finite (\<Union>{supp x | x. x \<in># M})"
by (simp only: image_Collect)
qed
lemma Union_supports_multiset:
shows "\<Union>{supp x | x. x \<in># M} supports M"
proof -
have sw: "\<And>a b. ((\<And>x. x \<in># M \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x) \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> M = M)"
unfolding permute_multiset_def by (induct M) simp_all
have "(\<Union>x\<in>set_mset M. supp x) supports M"
by (auto intro!: sw swap_fresh_fresh simp add: fresh_def supports_def)
also have "(\<Union>x\<in>set_mset M. supp x) = (\<Union>{supp x | x. x \<in># M})"
by auto
finally show "(\<Union>{supp x | x. x \<in># M}) supports M" .
qed
lemma Union_included_multiset:
fixes M::"('a::fs multiset)"
shows "(\<Union>{supp x | x. x \<in># M}) \<subseteq> supp M"
proof -
have "(\<Union>{supp x | x. x \<in># M}) = (\<Union>x \<in> set_mset M. supp x)" by auto
also have "... = supp (set_mset M)"
by (simp add: supp_of_finite_sets)
also have " ... \<subseteq> supp M" by (rule supp_set_mset)
finally show "(\<Union>{supp x | x. x \<in># M}) \<subseteq> supp M" .
qed
lemma supp_of_multisets:
fixes M::"('a::fs multiset)"
shows "(supp M) = (\<Union>{supp x | x. x \<in># M})"
apply(rule subset_antisym)
apply(rule supp_is_subset)
apply(rule Union_supports_multiset)
apply(rule Union_finite_multiset)
apply(rule Union_included_multiset)
done
lemma multisets_supp_finite:
fixes M::"('a::fs multiset)"
shows "finite (supp M)"
by (simp only: supp_of_multisets Union_finite_multiset)
lemma supp_of_multiset_union:
fixes M N::"('a::fs) multiset"
shows "supp (M + N) = supp M \<union> supp N"
by (auto simp: supp_of_multisets)
lemma supp_empty_mset [simp]:
shows "supp {#} = {}"
unfolding supp_def
by simp
instance multiset :: (fs) fs
by standard (rule multisets_supp_finite)
subsection {* Type @{typ "'a fset"} is finitely supported *}
lemma supp_fset [simp]:
shows "supp (fset S) = supp S"
unfolding supp_def
by (simp add: fset_eqvt fset_cong)
lemma supp_empty_fset [simp]:
shows "supp {||} = {}"
unfolding supp_def
by simp
lemma fresh_empty_fset:
shows "a \<sharp> {||}"
unfolding fresh_def
by (simp)
lemma supp_finsert [simp]:
fixes x::"'a::fs"
and S::"'a fset"
shows "supp (finsert x S) = supp x \<union> supp S"
apply(subst supp_fset[symmetric])
apply(simp add: supp_of_finite_insert)
done
lemma fresh_finsert:
fixes x::"'a::fs"
and S::"'a fset"
shows "a \<sharp> finsert x S \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> S"
unfolding fresh_def
by simp
lemma fset_finite_supp:
fixes S::"('a::fs) fset"
shows "finite (supp S)"
by (induct S) (simp_all add: finite_supp)
lemma supp_union_fset:
fixes S T::"'a::fs fset"
shows "supp (S |\<union>| T) = supp S \<union> supp T"
by (induct S) (auto)
lemma fresh_union_fset:
fixes S T::"'a::fs fset"
shows "a \<sharp> S |\<union>| T \<longleftrightarrow> a \<sharp> S \<and> a \<sharp> T"
unfolding fresh_def
by (simp add: supp_union_fset)
instance fset :: (fs) fs
by standard (rule fset_finite_supp)
subsection {* Type @{typ "('a, 'b) finfun"} is finitely supported *}
lemma fresh_finfun_const:
shows "a \<sharp> (finfun_const b) \<longleftrightarrow> a \<sharp> b"
by (simp add: fresh_def supp_def)
lemma fresh_finfun_update:
shows "\<lbrakk>a \<sharp> f; a \<sharp> x; a \<sharp> y\<rbrakk> \<Longrightarrow> a \<sharp> finfun_update f x y"
unfolding fresh_conv_MOST
unfolding finfun_update_eqvt
by (elim MOST_rev_mp) (simp)
lemma supp_finfun_const:
shows "supp (finfun_const b) = supp(b)"
by (simp add: supp_def)
lemma supp_finfun_update:
shows "supp (finfun_update f x y) \<subseteq> supp(f, x, y)"
using fresh_finfun_update
by (auto simp: fresh_def supp_Pair)
instance finfun :: (fs, fs) fs
apply standard
apply(induct_tac x rule: finfun_weak_induct)
apply(simp add: supp_finfun_const finite_supp)
apply(rule finite_subset)
apply(rule supp_finfun_update)
apply(simp add: supp_Pair finite_supp)
done
section {* Freshness and Fresh-Star *}
lemma fresh_Unit_elim:
shows "(a \<sharp> () \<Longrightarrow> PROP C) \<equiv> PROP C"
by (simp add: fresh_Unit)
lemma fresh_Pair_elim:
shows "(a \<sharp> (x, y) \<Longrightarrow> PROP C) \<equiv> (a \<sharp> x \<Longrightarrow> a \<sharp> y \<Longrightarrow> PROP C)"
by rule (simp_all add: fresh_Pair)
(* this rule needs to be added before the fresh_prodD is *)
(* added to the simplifier with mksimps *)
lemma fresh_PairD:
shows "a \<sharp> (x, y) \<Longrightarrow> a \<sharp> x"
and "a \<sharp> (x, y) \<Longrightarrow> a \<sharp> y"
by (simp_all add: fresh_Pair)
declaration {* fn _ =>
let
val mksimps_pairs = (@{const_name Nominal2_Base.fresh}, @{thms fresh_PairD}) :: mksimps_pairs
in
Simplifier.map_ss (fn ss => Simplifier.set_mksimps (mksimps mksimps_pairs) ss)
end
*}
text {* The fresh-star generalisation of fresh is used in strong
induction principles. *}
definition
fresh_star :: "atom set \<Rightarrow> 'a::pt \<Rightarrow> bool" ("_ \<sharp>* _" [80,80] 80)
where
"as \<sharp>* x \<equiv> \<forall>a \<in> as. a \<sharp> x"
lemma fresh_star_supp_conv:
shows "supp x \<sharp>* y \<Longrightarrow> supp y \<sharp>* x"
by (auto simp: fresh_star_def fresh_def)
lemma fresh_star_perm_set_conv:
fixes p::"perm"
assumes fresh: "as \<sharp>* p"
and fin: "finite as"
shows "supp p \<sharp>* as"
apply(rule fresh_star_supp_conv)
apply(simp add: supp_finite_atom_set fin fresh)
done
lemma fresh_star_atom_set_conv:
assumes fresh: "as \<sharp>* bs"
and fin: "finite as" "finite bs"
shows "bs \<sharp>* as"
using fresh
unfolding fresh_star_def fresh_def
by (auto simp: supp_finite_atom_set fin)
lemma atom_fresh_star_disjoint:
assumes fin: "finite bs"
shows "as \<sharp>* bs \<longleftrightarrow> (as \<inter> bs = {})"
unfolding fresh_star_def fresh_def
by (auto simp: supp_finite_atom_set fin)
lemma fresh_star_Pair:
shows "as \<sharp>* (x, y) = (as \<sharp>* x \<and> as \<sharp>* y)"
by (auto simp: fresh_star_def fresh_Pair)
lemma fresh_star_list:
shows "as \<sharp>* (xs @ ys) \<longleftrightarrow> as \<sharp>* xs \<and> as \<sharp>* ys"
and "as \<sharp>* (x # xs) \<longleftrightarrow> as \<sharp>* x \<and> as \<sharp>* xs"
and "as \<sharp>* []"
by (auto simp: fresh_star_def fresh_Nil fresh_Cons fresh_append)
lemma fresh_star_set:
fixes xs::"('a::fs) list"
shows "as \<sharp>* set xs \<longleftrightarrow> as \<sharp>* xs"
unfolding fresh_star_def
by (simp add: fresh_set)
lemma fresh_star_singleton:
fixes a::"atom"
shows "as \<sharp>* {a} \<longleftrightarrow> as \<sharp>* a"
by (simp add: fresh_star_def fresh_finite_insert fresh_set_empty)
lemma fresh_star_fset:
fixes xs::"('a::fs) list"
shows "as \<sharp>* fset S \<longleftrightarrow> as \<sharp>* S"
by (simp add: fresh_star_def fresh_def)
lemma fresh_star_Un:
shows "(as \<union> bs) \<sharp>* x = (as \<sharp>* x \<and> bs \<sharp>* x)"
by (auto simp: fresh_star_def)
lemma fresh_star_insert:
shows "(insert a as) \<sharp>* x = (a \<sharp> x \<and> as \<sharp>* x)"
by (auto simp: fresh_star_def)
lemma fresh_star_Un_elim:
"((as \<union> bs) \<sharp>* x \<Longrightarrow> PROP C) \<equiv> (as \<sharp>* x \<Longrightarrow> bs \<sharp>* x \<Longrightarrow> PROP C)"
unfolding fresh_star_def
apply(rule)
apply(erule meta_mp)
apply(auto)
done
lemma fresh_star_insert_elim:
"(insert a as \<sharp>* x \<Longrightarrow> PROP C) \<equiv> (a \<sharp> x \<Longrightarrow> as \<sharp>* x \<Longrightarrow> PROP C)"
unfolding fresh_star_def
by rule (simp_all add: fresh_star_def)
lemma fresh_star_empty_elim:
"({} \<sharp>* x \<Longrightarrow> PROP C) \<equiv> PROP C"
by (simp add: fresh_star_def)
lemma fresh_star_Unit_elim:
shows "(a \<sharp>* () \<Longrightarrow> PROP C) \<equiv> PROP C"
by (simp add: fresh_star_def fresh_Unit)
lemma fresh_star_Pair_elim:
shows "(a \<sharp>* (x, y) \<Longrightarrow> PROP C) \<equiv> (a \<sharp>* x \<Longrightarrow> a \<sharp>* y \<Longrightarrow> PROP C)"
by (rule, simp_all add: fresh_star_Pair)
lemma fresh_star_zero:
shows "as \<sharp>* (0::perm)"
unfolding fresh_star_def
by (simp add: fresh_zero_perm)
lemma fresh_star_plus:
fixes p q::perm
shows "\<lbrakk>a \<sharp>* p; a \<sharp>* q\<rbrakk> \<Longrightarrow> a \<sharp>* (p + q)"
unfolding fresh_star_def
by (simp add: fresh_plus_perm)
lemma fresh_star_permute_iff:
shows "(p \<bullet> a) \<sharp>* (p \<bullet> x) \<longleftrightarrow> a \<sharp>* x"
unfolding fresh_star_def
by (metis mem_permute_iff permute_minus_cancel(1) fresh_permute_iff)
lemma fresh_star_eqvt [eqvt]:
shows "p \<bullet> (as \<sharp>* x) \<longleftrightarrow> (p \<bullet> as) \<sharp>* (p \<bullet> x)"
unfolding fresh_star_def by simp
section {* Induction principle for permutations *}
lemma smaller_supp:
assumes a: "a \<in> supp p"
shows "supp ((p \<bullet> a \<rightleftharpoons> a) + p) \<subset> supp p"
proof -
have "supp ((p \<bullet> a \<rightleftharpoons> a) + p) \<subseteq> supp p"
unfolding supp_perm by (auto simp: swap_atom)
moreover
have "a \<notin> supp ((p \<bullet> a \<rightleftharpoons> a) + p)" by (simp add: supp_perm)
then have "supp ((p \<bullet> a \<rightleftharpoons> a) + p) \<noteq> supp p" using a by auto
ultimately
show "supp ((p \<bullet> a \<rightleftharpoons> a) + p) \<subset> supp p" by auto
qed
lemma perm_struct_induct[consumes 1, case_names zero swap]:
assumes S: "supp p \<subseteq> S"
and zero: "P 0"
and swap: "\<And>p a b. \<lbrakk>P p; supp p \<subseteq> S; a \<in> S; b \<in> S; a \<noteq> b; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> P ((a \<rightleftharpoons> b) + p)"
shows "P p"
proof -
have "finite (supp p)" by (simp add: finite_supp)
then show "P p" using S
proof(induct A\<equiv>"supp p" arbitrary: p rule: finite_psubset_induct)
case (psubset p)
then have ih: "\<And>q. supp q \<subset> supp p \<Longrightarrow> P q" by auto
have as: "supp p \<subseteq> S" by fact
{ assume "supp p = {}"
then have "p = 0" by (simp add: supp_perm perm_eq_iff)
then have "P p" using zero by simp
}
moreover
{ assume "supp p \<noteq> {}"
then obtain a where a0: "a \<in> supp p" by blast
then have a1: "p \<bullet> a \<in> S" "a \<in> S" "sort_of (p \<bullet> a) = sort_of a" "p \<bullet> a \<noteq> a"
using as by (auto simp: supp_atom supp_perm swap_atom)
let ?q = "(p \<bullet> a \<rightleftharpoons> a) + p"
have a2: "supp ?q \<subset> supp p" using a0 smaller_supp by simp
then have "P ?q" using ih by simp
moreover
have "supp ?q \<subseteq> S" using as a2 by simp
ultimately have "P ((p \<bullet> a \<rightleftharpoons> a) + ?q)" using as a1 swap by simp
moreover
have "p = (p \<bullet> a \<rightleftharpoons> a) + ?q" by (simp add: perm_eq_iff)
ultimately have "P p" by simp
}
ultimately show "P p" by blast
qed
qed
lemma perm_simple_struct_induct[case_names zero swap]:
assumes zero: "P 0"
and swap: "\<And>p a b. \<lbrakk>P p; a \<noteq> b; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> P ((a \<rightleftharpoons> b) + p)"
shows "P p"
by (rule_tac S="supp p" in perm_struct_induct)
(auto intro: zero swap)
lemma perm_struct_induct2[consumes 1, case_names zero swap plus]:
assumes S: "supp p \<subseteq> S"
assumes zero: "P 0"
assumes swap: "\<And>a b. \<lbrakk>sort_of a = sort_of b; a \<noteq> b; a \<in> S; b \<in> S\<rbrakk> \<Longrightarrow> P (a \<rightleftharpoons> b)"
assumes plus: "\<And>p1 p2. \<lbrakk>P p1; P p2; supp p1 \<subseteq> S; supp p2 \<subseteq> S\<rbrakk> \<Longrightarrow> P (p1 + p2)"
shows "P p"
using S
by (induct p rule: perm_struct_induct)
(auto intro: zero plus swap simp add: supp_swap)
lemma perm_simple_struct_induct2[case_names zero swap plus]:
assumes zero: "P 0"
assumes swap: "\<And>a b. \<lbrakk>sort_of a = sort_of b; a \<noteq> b\<rbrakk> \<Longrightarrow> P (a \<rightleftharpoons> b)"
assumes plus: "\<And>p1 p2. \<lbrakk>P p1; P p2\<rbrakk> \<Longrightarrow> P (p1 + p2)"
shows "P p"
by (rule_tac S="supp p" in perm_struct_induct2)
(auto intro: zero swap plus)
lemma supp_perm_singleton:
fixes p::"perm"
shows "supp p \<subseteq> {b} \<longleftrightarrow> p = 0"
proof -
{ assume "supp p \<subseteq> {b}"
then have "p = 0"
by (induct p rule: perm_struct_induct) (simp_all)
}
then show "supp p \<subseteq> {b} \<longleftrightarrow> p = 0" by (auto simp: supp_zero_perm)
qed
lemma supp_perm_pair:
fixes p::"perm"
shows "supp p \<subseteq> {a, b} \<longleftrightarrow> p = 0 \<or> p = (b \<rightleftharpoons> a)"
proof -
{ assume "supp p \<subseteq> {a, b}"
then have "p = 0 \<or> p = (b \<rightleftharpoons> a)"
apply (induct p rule: perm_struct_induct)
apply (auto simp: swap_cancel supp_zero_perm supp_swap)
apply (simp add: swap_commute)
done
}
then show "supp p \<subseteq> {a, b} \<longleftrightarrow> p = 0 \<or> p = (b \<rightleftharpoons> a)"
by (auto simp: supp_zero_perm supp_swap split: if_splits)
qed
lemma supp_perm_eq:
assumes "(supp x) \<sharp>* p"
shows "p \<bullet> x = x"
proof -
from assms have "supp p \<subseteq> {a. a \<sharp> x}"
unfolding supp_perm fresh_star_def fresh_def by auto
then show "p \<bullet> x = x"
proof (induct p rule: perm_struct_induct)
case zero
show "0 \<bullet> x = x" by simp
next
case (swap p a b)
then have "a \<sharp> x" "b \<sharp> x" "p \<bullet> x = x" by simp_all
then show "((a \<rightleftharpoons> b) + p) \<bullet> x = x" by (simp add: swap_fresh_fresh)
qed
qed
text {* same lemma as above, but proved with a different induction principle *}
lemma supp_perm_eq_test:
assumes "(supp x) \<sharp>* p"
shows "p \<bullet> x = x"
proof -
from assms have "supp p \<subseteq> {a. a \<sharp> x}"
unfolding supp_perm fresh_star_def fresh_def by auto
then show "p \<bullet> x = x"
proof (induct p rule: perm_struct_induct2)
case zero
show "0 \<bullet> x = x" by simp
next
case (swap a b)
then have "a \<sharp> x" "b \<sharp> x" by simp_all
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh)
next
case (plus p1 p2)
have "p1 \<bullet> x = x" "p2 \<bullet> x = x" by fact+
then show "(p1 + p2) \<bullet> x = x" by simp
qed
qed
lemma perm_supp_eq:
assumes a: "(supp p) \<sharp>* x"
shows "p \<bullet> x = x"
proof -
from assms have "supp p \<subseteq> {a. a \<sharp> x}"
unfolding supp_perm fresh_star_def fresh_def by auto
then show "p \<bullet> x = x"
proof (induct p rule: perm_struct_induct2)
case zero
show "0 \<bullet> x = x" by simp
next
case (swap a b)
then have "a \<sharp> x" "b \<sharp> x" by simp_all
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh)
next
case (plus p1 p2)
have "p1 \<bullet> x = x" "p2 \<bullet> x = x" by fact+
then show "(p1 + p2) \<bullet> x = x" by simp
qed
qed
lemma supp_perm_perm_eq:
assumes a: "\<forall>a \<in> supp x. p \<bullet> a = q \<bullet> a"
shows "p \<bullet> x = q \<bullet> x"
proof -
from a have "\<forall>a \<in> supp x. (-q + p) \<bullet> a = a" by simp
then have "\<forall>a \<in> supp x. a \<notin> supp (-q + p)"
unfolding supp_perm by simp
then have "supp x \<sharp>* (-q + p)"
unfolding fresh_star_def fresh_def by simp
then have "(-q + p) \<bullet> x = x" by (simp only: supp_perm_eq)
then show "p \<bullet> x = q \<bullet> x"
by (metis permute_minus_cancel permute_plus)
qed
text {* disagreement set *}
definition
dset :: "perm \<Rightarrow> perm \<Rightarrow> atom set"
where
"dset p q = {a::atom. p \<bullet> a \<noteq> q \<bullet> a}"
lemma ds_fresh:
assumes "dset p q \<sharp>* x"
shows "p \<bullet> x = q \<bullet> x"
using assms
unfolding dset_def fresh_star_def fresh_def
by (auto intro: supp_perm_perm_eq)
lemma atom_set_perm_eq:
assumes a: "as \<sharp>* p"
shows "p \<bullet> as = as"
proof -
from a have "supp p \<subseteq> {a. a \<notin> as}"
unfolding supp_perm fresh_star_def fresh_def by auto
then show "p \<bullet> as = as"
proof (induct p rule: perm_struct_induct)
case zero
show "0 \<bullet> as = as" by simp
next
case (swap p a b)
then have "a \<notin> as" "b \<notin> as" "p \<bullet> as = as" by simp_all
then show "((a \<rightleftharpoons> b) + p) \<bullet> as = as" by (simp add: swap_set_not_in)
qed
qed
section {* Avoiding of atom sets *}
text {*
For every set of atoms, there is another set of atoms
avoiding a finitely supported c and there is a permutation
which 'translates' between both sets.
*}
lemma at_set_avoiding_aux:
fixes Xs::"atom set"
and As::"atom set"
assumes b: "Xs \<subseteq> As"
and c: "finite As"
shows "\<exists>p. (p \<bullet> Xs) \<inter> As = {} \<and> (supp p) = (Xs \<union> (p \<bullet> Xs))"
proof -
from b c have "finite Xs" by (rule finite_subset)
then show ?thesis using b
proof (induct rule: finite_subset_induct)
case empty
have "0 \<bullet> {} \<inter> As = {}" by simp
moreover
have "supp (0::perm) = {} \<union> 0 \<bullet> {}" by (simp add: supp_zero_perm)
ultimately show ?case by blast
next
case (insert x Xs)
then obtain p where
p1: "(p \<bullet> Xs) \<inter> As = {}" and
p2: "supp p = (Xs \<union> (p \<bullet> Xs))" by blast
from `x \<in> As` p1 have "x \<notin> p \<bullet> Xs" by fast
with `x \<notin> Xs` p2 have "x \<notin> supp p" by fast
hence px: "p \<bullet> x = x" unfolding supp_perm by simp
have "finite (As \<union> p \<bullet> Xs \<union> supp p)"
using `finite As` `finite Xs`
by (simp add: permute_set_eq_image finite_supp)
then obtain y where "y \<notin> (As \<union> p \<bullet> Xs \<union> supp p)" "sort_of y = sort_of x"
by (rule obtain_atom)
hence y: "y \<notin> As" "y \<notin> p \<bullet> Xs" "y \<notin> supp p" "sort_of y = sort_of x"
by simp_all
hence py: "p \<bullet> y = y" "x \<noteq> y" using `x \<in> As`
by (auto simp: supp_perm)
let ?q = "(x \<rightleftharpoons> y) + p"
have q: "?q \<bullet> insert x Xs = insert y (p \<bullet> Xs)"
unfolding insert_eqvt
using `p \<bullet> x = x` `sort_of y = sort_of x`
using `x \<notin> p \<bullet> Xs` `y \<notin> p \<bullet> Xs`
by (simp add: swap_atom swap_set_not_in)
have "?q \<bullet> insert x Xs \<inter> As = {}"
using `y \<notin> As` `p \<bullet> Xs \<inter> As = {}`
unfolding q by simp
moreover
have "supp (x \<rightleftharpoons> y) \<inter> supp p = {}" using px py `sort_of y = sort_of x`
unfolding supp_swap by (simp add: supp_perm)
then have "supp ?q = (supp (x \<rightleftharpoons> y) \<union> supp p)"
by (simp add: supp_plus_perm_eq)
then have "supp ?q = insert x Xs \<union> ?q \<bullet> insert x Xs"
using p2 `sort_of y = sort_of x` `x \<noteq> y` unfolding q supp_swap
by auto
ultimately show ?case by blast
qed
qed
lemma at_set_avoiding:
assumes a: "finite Xs"
and b: "finite (supp c)"
obtains p::"perm" where "(p \<bullet> Xs)\<sharp>*c" and "(supp p) = (Xs \<union> (p \<bullet> Xs))"
using a b at_set_avoiding_aux [where Xs="Xs" and As="Xs \<union> supp c"]
unfolding fresh_star_def fresh_def by blast
lemma at_set_avoiding1:
assumes "finite xs"
and "finite (supp c)"
shows "\<exists>p. (p \<bullet> xs) \<sharp>* c"
using assms
apply(erule_tac c="c" in at_set_avoiding)
apply(auto)
done
lemma at_set_avoiding2:
assumes "finite xs"
and "finite (supp c)" "finite (supp x)"
and "xs \<sharp>* x"
shows "\<exists>p. (p \<bullet> xs) \<sharp>* c \<and> supp x \<sharp>* p"
using assms
apply(erule_tac c="(c, x)" in at_set_avoiding)
apply(simp add: supp_Pair)
apply(rule_tac x="p" in exI)
apply(simp add: fresh_star_Pair)
apply(rule fresh_star_supp_conv)
apply(auto simp: fresh_star_def)
done
lemma at_set_avoiding3:
assumes "finite xs"
and "finite (supp c)" "finite (supp x)"
and "xs \<sharp>* x"
shows "\<exists>p. (p \<bullet> xs) \<sharp>* c \<and> supp x \<sharp>* p \<and> supp p = xs \<union> (p \<bullet> xs)"
using assms
apply(erule_tac c="(c, x)" in at_set_avoiding)
apply(simp add: supp_Pair)
apply(rule_tac x="p" in exI)
apply(simp add: fresh_star_Pair)
apply(rule fresh_star_supp_conv)
apply(auto simp: fresh_star_def)
done
lemma at_set_avoiding2_atom:
assumes "finite (supp c)" "finite (supp x)"
and b: "a \<sharp> x"
shows "\<exists>p. (p \<bullet> a) \<sharp> c \<and> supp x \<sharp>* p"
proof -
have a: "{a} \<sharp>* x" unfolding fresh_star_def by (simp add: b)
obtain p where p1: "(p \<bullet> {a}) \<sharp>* c" and p2: "supp x \<sharp>* p"
using at_set_avoiding2[of "{a}" "c" "x"] assms a by blast
have c: "(p \<bullet> a) \<sharp> c" using p1
unfolding fresh_star_def Ball_def
by(erule_tac x="p \<bullet> a" in allE) (simp add: permute_set_def)
hence "p \<bullet> a \<sharp> c \<and> supp x \<sharp>* p" using p2 by blast
then show "\<exists>p. (p \<bullet> a) \<sharp> c \<and> supp x \<sharp>* p" by blast
qed
section {* Renaming permutations *}
lemma set_renaming_perm:
assumes b: "finite bs"
shows "\<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)"
using b
proof (induct)
case empty
have "(\<forall>b \<in> {}. 0 \<bullet> b = p \<bullet> b) \<and> supp (0::perm) \<subseteq> {} \<union> p \<bullet> {}"
by (simp add: permute_set_def supp_perm)
then show "\<exists>q. (\<forall>b \<in> {}. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> {} \<union> p \<bullet> {}" by blast
next
case (insert a bs)
then have " \<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> p \<bullet> bs" by simp
then obtain q where *: "\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b" and **: "supp q \<subseteq> bs \<union> p \<bullet> bs"
by (metis empty_subsetI insert(3) supp_swap)
{ assume 1: "q \<bullet> a = p \<bullet> a"
have "\<forall>b \<in> (insert a bs). q \<bullet> b = p \<bullet> b" using 1 * by simp
moreover
have "supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
using ** by (auto simp: insert_eqvt)
ultimately
have "\<exists>q. (\<forall>b \<in> insert a bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs" by blast
}
moreover
{ assume 2: "q \<bullet> a \<noteq> p \<bullet> a"
def q' \<equiv> "((q \<bullet> a) \<rightleftharpoons> (p \<bullet> a)) + q"
have "\<forall>b \<in> insert a bs. q' \<bullet> b = p \<bullet> b" using 2 * `a \<notin> bs` unfolding q'_def
by (auto simp: swap_atom)
moreover
{ have "{q \<bullet> a, p \<bullet> a} \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
using **
apply (auto simp: supp_perm insert_eqvt)
apply (subgoal_tac "q \<bullet> a \<in> bs \<union> p \<bullet> bs")
apply(auto)[1]
apply(subgoal_tac "q \<bullet> a \<in> {a. q \<bullet> a \<noteq> a}")
apply(blast)
apply(simp)
done
then have "supp (q \<bullet> a \<rightleftharpoons> p \<bullet> a) \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
unfolding supp_swap by auto
moreover
have "supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
using ** by (auto simp: insert_eqvt)
ultimately
have "supp q' \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
unfolding q'_def using supp_plus_perm by blast
}
ultimately
have "\<exists>q. (\<forall>b \<in> insert a bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs" by blast
}
ultimately show "\<exists>q. (\<forall>b \<in> insert a bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
by blast
qed
lemma set_renaming_perm2:
shows "\<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)"
proof -
have "finite (bs \<inter> supp p)" by (simp add: finite_supp)
then obtain q
where *: "\<forall>b \<in> bs \<inter> supp p. q \<bullet> b = p \<bullet> b" and **: "supp q \<subseteq> (bs \<inter> supp p) \<union> (p \<bullet> (bs \<inter> supp p))"
using set_renaming_perm by blast
from ** have "supp q \<subseteq> bs \<union> (p \<bullet> bs)" by (auto simp: inter_eqvt)
moreover
have "\<forall>b \<in> bs - supp p. q \<bullet> b = p \<bullet> b"
apply(auto)
apply(subgoal_tac "b \<notin> supp q")
apply(simp add: fresh_def[symmetric])
apply(simp add: fresh_perm)
apply(clarify)
apply(rotate_tac 2)
apply(drule subsetD[OF **])
apply(simp add: inter_eqvt supp_eqvt permute_self)
done
ultimately have "(\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)" using * by auto
then show "\<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)" by blast
qed
lemma list_renaming_perm:
shows "\<exists>q. (\<forall>b \<in> set bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set bs \<union> (p \<bullet> set bs)"
proof (induct bs)
case (Cons a bs)
then have " \<exists>q. (\<forall>b \<in> set bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set bs \<union> p \<bullet> (set bs)" by simp
then obtain q where *: "\<forall>b \<in> set bs. q \<bullet> b = p \<bullet> b" and **: "supp q \<subseteq> set bs \<union> p \<bullet> (set bs)"
by (blast)
{ assume 1: "a \<in> set bs"
have "q \<bullet> a = p \<bullet> a" using * 1 by (induct bs) (auto)
then have "\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b" using * by simp
moreover
have "supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))" using ** by (auto simp: insert_eqvt)
ultimately
have "\<exists>q. (\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))" by blast
}
moreover
{ assume 2: "a \<notin> set bs"
def q' \<equiv> "((q \<bullet> a) \<rightleftharpoons> (p \<bullet> a)) + q"
have "\<forall>b \<in> set (a # bs). q' \<bullet> b = p \<bullet> b"
unfolding q'_def using 2 * `a \<notin> set bs` by (auto simp: swap_atom)
moreover
{ have "{q \<bullet> a, p \<bullet> a} \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
using **
apply (auto simp: supp_perm insert_eqvt)
apply (subgoal_tac "q \<bullet> a \<in> set bs \<union> p \<bullet> set bs")
apply(auto)[1]
apply(subgoal_tac "q \<bullet> a \<in> {a. q \<bullet> a \<noteq> a}")
apply(blast)
apply(simp)
done
then have "supp (q \<bullet> a \<rightleftharpoons> p \<bullet> a) \<subseteq> set (a # bs) \<union> p \<bullet> set (a # bs)"
unfolding supp_swap by auto
moreover
have "supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
using ** by (auto simp: insert_eqvt)
ultimately
have "supp q' \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
unfolding q'_def using supp_plus_perm by blast
}
ultimately
have "\<exists>q. (\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))" by blast
}
ultimately show "\<exists>q. (\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
by blast
next
case Nil
have "(\<forall>b \<in> set []. 0 \<bullet> b = p \<bullet> b) \<and> supp (0::perm) \<subseteq> set [] \<union> p \<bullet> set []"
by (simp add: supp_zero_perm)
then show "\<exists>q. (\<forall>b \<in> set []. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set [] \<union> p \<bullet> (set [])" by blast
qed
section {* Concrete Atoms Types *}
text {*
Class @{text at_base} allows types containing multiple sorts of atoms.
Class @{text at} only allows types with a single sort.
*}
class at_base = pt +
fixes atom :: "'a \<Rightarrow> atom"
assumes atom_eq_iff [simp]: "atom a = atom b \<longleftrightarrow> a = b"
assumes atom_eqvt: "p \<bullet> (atom a) = atom (p \<bullet> a)"
declare atom_eqvt [eqvt]
class at = at_base +
assumes sort_of_atom_eq [simp]: "sort_of (atom a) = sort_of (atom b)"
lemma sort_ineq [simp]:
assumes "sort_of (atom a) \<noteq> sort_of (atom b)"
shows "atom a \<noteq> atom b"
using assms by metis
lemma supp_at_base:
fixes a::"'a::at_base"
shows "supp a = {atom a}"
by (simp add: supp_atom [symmetric] supp_def atom_eqvt)
lemma fresh_at_base:
shows "sort_of a \<noteq> sort_of (atom b) \<Longrightarrow> a \<sharp> b"
and "a \<sharp> b \<longleftrightarrow> a \<noteq> atom b"
unfolding fresh_def
apply(simp_all add: supp_at_base)
apply(metis)
done
(* solves the freshness only if the inequality can be shown by the
simproc below *)
lemma fresh_ineq_at_base [simp]:
shows "a \<noteq> atom b \<Longrightarrow> a \<sharp> b"
by (simp add: fresh_at_base)
lemma fresh_atom_at_base [simp]:
fixes b::"'a::at_base"
shows "a \<sharp> atom b \<longleftrightarrow> a \<sharp> b"
by (simp add: fresh_def supp_at_base supp_atom)
lemma fresh_star_atom_at_base:
fixes b::"'a::at_base"
shows "as \<sharp>* atom b \<longleftrightarrow> as \<sharp>* b"
by (simp add: fresh_star_def fresh_atom_at_base)
lemma if_fresh_at_base [simp]:
shows "atom a \<sharp> x \<Longrightarrow> P (if a = x then t else s) = P s"
and "atom a \<sharp> x \<Longrightarrow> P (if x = a then t else s) = P s"
by (simp_all add: fresh_at_base)
simproc_setup fresh_ineq ("x \<noteq> (y::'a::at_base)") = {* fn _ => fn ctxt => fn ctrm =>
case Thm.term_of ctrm of @{term "HOL.Not"} $ (Const (@{const_name HOL.eq}, _) $ lhs $ rhs) =>
let
fun first_is_neg lhs rhs [] = NONE
| first_is_neg lhs rhs (thm::thms) =
(case Thm.prop_of thm of
_ $ (@{term "HOL.Not"} $ (Const (@{const_name HOL.eq}, _) $ l $ r)) =>
(if l = lhs andalso r = rhs then SOME(thm)
else if r = lhs andalso l = rhs then SOME(thm RS @{thm not_sym})
else first_is_neg lhs rhs thms)
| _ => first_is_neg lhs rhs thms)
val simp_thms = @{thms fresh_Pair fresh_at_base atom_eq_iff}
val prems = Simplifier.prems_of ctxt
|> filter (fn thm => case Thm.prop_of thm of
_ $ (Const (@{const_name fresh}, ty) $ (_ $ a) $ b) =>
(let
val atms = a :: HOLogic.strip_tuple b
in
member (op=) atms lhs andalso member (op=) atms rhs
end)
| _ => false)
|> map (simplify (put_simpset HOL_basic_ss ctxt addsimps simp_thms))
|> map (HOLogic.conj_elims ctxt)
|> flat
in
case first_is_neg lhs rhs prems of
SOME(thm) => SOME(thm RS @{thm Eq_TrueI})
| NONE => NONE
end
| _ => NONE
*}
instance at_base < fs
proof qed (simp add: supp_at_base)
lemma at_base_infinite [simp]:
shows "infinite (UNIV :: 'a::at_base set)" (is "infinite ?U")
proof
obtain a :: 'a where "True" by auto
assume "finite ?U"
hence "finite (atom ` ?U)"
by (rule finite_imageI)
then obtain b where b: "b \<notin> atom ` ?U" "sort_of b = sort_of (atom a)"
by (rule obtain_atom)
from b(2) have "b = atom ((atom a \<rightleftharpoons> b) \<bullet> a)"
unfolding atom_eqvt [symmetric]
by (simp add: swap_atom)
hence "b \<in> atom ` ?U" by simp
with b(1) show "False" by simp
qed
lemma swap_at_base_simps [simp]:
fixes x y::"'a::at_base"
shows "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> x = y"
and "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> y = x"
and "atom x \<noteq> a \<Longrightarrow> atom x \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x"
unfolding atom_eq_iff [symmetric]
unfolding atom_eqvt [symmetric]
by simp_all
lemma obtain_at_base:
assumes X: "finite X"
obtains a::"'a::at_base" where "atom a \<notin> X"
proof -
have "inj (atom :: 'a \<Rightarrow> atom)"
by (simp add: inj_on_def)
with X have "finite (atom -` X :: 'a set)"
by (rule finite_vimageI)
with at_base_infinite have "atom -` X \<noteq> (UNIV :: 'a set)"
by auto
then obtain a :: 'a where "atom a \<notin> X"
by auto
thus ?thesis ..
qed
lemma obtain_fresh':
assumes fin: "finite (supp x)"
obtains a::"'a::at_base" where "atom a \<sharp> x"
using obtain_at_base[where X="supp x"]
by (auto simp: fresh_def fin)
lemma supp_finite_set_at_base:
assumes a: "finite S"
shows "supp S = atom ` S"
apply(simp add: supp_of_finite_sets[OF a])
apply(simp add: supp_at_base)
apply(auto)
done
(* FIXME
lemma supp_cofinite_set_at_base:
assumes a: "finite (UNIV - S)"
shows "supp S = atom ` (UNIV - S)"
apply(rule finite_supp_unique)
*)
lemma fresh_finite_set_at_base:
fixes a::"'a::at_base"
assumes a: "finite S"
shows "atom a \<sharp> S \<longleftrightarrow> a \<notin> S"
unfolding fresh_def
apply(simp add: supp_finite_set_at_base[OF a])
apply(subst inj_image_mem_iff)
apply(simp add: inj_on_def)
apply(simp)
done
lemma fresh_at_base_permute_iff [simp]:
fixes a::"'a::at_base"
shows "atom (p \<bullet> a) \<sharp> p \<bullet> x \<longleftrightarrow> atom a \<sharp> x"
unfolding atom_eqvt[symmetric]
by (simp only: fresh_permute_iff)
lemma fresh_at_base_permI:
shows "atom a \<sharp> p \<Longrightarrow> p \<bullet> a = a"
by (simp add: fresh_def supp_perm)
section {* Infrastructure for concrete atom types *}
definition
flip :: "'a::at_base \<Rightarrow> 'a \<Rightarrow> perm" ("'(_ \<leftrightarrow> _')")
where
"(a \<leftrightarrow> b) = (atom a \<rightleftharpoons> atom b)"
lemma flip_fresh_fresh:
assumes "atom a \<sharp> x" "atom b \<sharp> x"
shows "(a \<leftrightarrow> b) \<bullet> x = x"
using assms
by (simp add: flip_def swap_fresh_fresh)
lemma flip_self [simp]: "(a \<leftrightarrow> a) = 0"
unfolding flip_def by (rule swap_self)
lemma flip_commute: "(a \<leftrightarrow> b) = (b \<leftrightarrow> a)"
unfolding flip_def by (rule swap_commute)
lemma minus_flip [simp]: "- (a \<leftrightarrow> b) = (a \<leftrightarrow> b)"
unfolding flip_def by (rule minus_swap)
lemma add_flip_cancel: "(a \<leftrightarrow> b) + (a \<leftrightarrow> b) = 0"
unfolding flip_def by (rule swap_cancel)
lemma permute_flip_cancel [simp]: "(a \<leftrightarrow> b) \<bullet> (a \<leftrightarrow> b) \<bullet> x = x"
unfolding permute_plus [symmetric] add_flip_cancel by simp
lemma permute_flip_cancel2 [simp]: "(a \<leftrightarrow> b) \<bullet> (b \<leftrightarrow> a) \<bullet> x = x"
by (simp add: flip_commute)
lemma flip_eqvt [eqvt]:
shows "p \<bullet> (a \<leftrightarrow> b) = (p \<bullet> a \<leftrightarrow> p \<bullet> b)"
unfolding flip_def
by (simp add: swap_eqvt atom_eqvt)
lemma flip_at_base_simps [simp]:
shows "sort_of (atom a) = sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> a = b"
and "sort_of (atom a) = sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> b = a"
and "\<lbrakk>a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> c = c"
and "sort_of (atom a) \<noteq> sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> x = x"
unfolding flip_def
unfolding atom_eq_iff [symmetric]
unfolding atom_eqvt [symmetric]
by simp_all
text {* the following two lemmas do not hold for @{text at_base},
only for single sort atoms from at *}
lemma flip_triple:
fixes a b c::"'a::at"
assumes "a \<noteq> b" and "c \<noteq> b"
shows "(a \<leftrightarrow> c) + (b \<leftrightarrow> c) + (a \<leftrightarrow> c) = (a \<leftrightarrow> b)"
unfolding flip_def
by (rule swap_triple) (simp_all add: assms)
lemma permute_flip_at:
fixes a b c::"'a::at"
shows "(a \<leftrightarrow> b) \<bullet> c = (if c = a then b else if c = b then a else c)"
unfolding flip_def
apply (rule atom_eq_iff [THEN iffD1])
apply (subst atom_eqvt [symmetric])
apply (simp add: swap_atom)
done
lemma flip_at_simps [simp]:
fixes a b::"'a::at"
shows "(a \<leftrightarrow> b) \<bullet> a = b"
and "(a \<leftrightarrow> b) \<bullet> b = a"
unfolding permute_flip_at by simp_all
subsection {* Syntax for coercing at-elements to the atom-type *}
syntax
"_atom_constrain" :: "logic \<Rightarrow> type \<Rightarrow> logic" ("_:::_" [4, 0] 3)
translations
"_atom_constrain a t" => "CONST atom (_constrain a t)"
subsection {* A lemma for proving instances of class @{text at}. *}
setup {* Sign.add_const_constraint (@{const_name "permute"}, NONE) *}
setup {* Sign.add_const_constraint (@{const_name "atom"}, NONE) *}
text {*
New atom types are defined as subtypes of @{typ atom}.
*}
lemma exists_eq_simple_sort:
shows "\<exists>a. a \<in> {a. sort_of a = s}"
by (rule_tac x="Atom s 0" in exI, simp)
lemma exists_eq_sort:
shows "\<exists>a. a \<in> {a. sort_of a \<in> range sort_fun}"
by (rule_tac x="Atom (sort_fun x) y" in exI, simp)
lemma at_base_class:
fixes sort_fun :: "'b \<Rightarrow> atom_sort"
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
assumes type: "type_definition Rep Abs {a. sort_of a \<in> range sort_fun}"
assumes atom_def: "\<And>a. atom a = Rep a"
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)"
shows "OFCLASS('a, at_base_class)"
proof
interpret type_definition Rep Abs "{a. sort_of a \<in> range sort_fun}" by (rule type)
have sort_of_Rep: "\<And>a. sort_of (Rep a) \<in> range sort_fun" using Rep by simp
fix a b :: 'a and p p1 p2 :: perm
show "0 \<bullet> a = a"
unfolding permute_def by (simp add: Rep_inverse)
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a"
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep)
show "atom a = atom b \<longleftrightarrow> a = b"
unfolding atom_def by (simp add: Rep_inject)
show "p \<bullet> atom a = atom (p \<bullet> a)"
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep)
qed
(*
lemma at_class:
fixes s :: atom_sort
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
assumes type: "type_definition Rep Abs {a. sort_of a \<in> range (\<lambda>x::unit. s)}"
assumes atom_def: "\<And>a. atom a = Rep a"
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)"
shows "OFCLASS('a, at_class)"
proof
interpret type_definition Rep Abs "{a. sort_of a \<in> range (\<lambda>x::unit. s)}" by (rule type)
have sort_of_Rep: "\<And>a. sort_of (Rep a) = s" using Rep by (simp add: image_def)
fix a b :: 'a and p p1 p2 :: perm
show "0 \<bullet> a = a"
unfolding permute_def by (simp add: Rep_inverse)
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a"
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep)
show "sort_of (atom a) = sort_of (atom b)"
unfolding atom_def by (simp add: sort_of_Rep)
show "atom a = atom b \<longleftrightarrow> a = b"
unfolding atom_def by (simp add: Rep_inject)
show "p \<bullet> atom a = atom (p \<bullet> a)"
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep)
qed
*)
lemma at_class:
fixes s :: atom_sort
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
assumes type: "type_definition Rep Abs {a. sort_of a = s}"
assumes atom_def: "\<And>a. atom a = Rep a"
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)"
shows "OFCLASS('a, at_class)"
proof
interpret type_definition Rep Abs "{a. sort_of a = s}" by (rule type)
have sort_of_Rep: "\<And>a. sort_of (Rep a) = s" using Rep by (simp add: image_def)
fix a b :: 'a and p p1 p2 :: perm
show "0 \<bullet> a = a"
unfolding permute_def by (simp add: Rep_inverse)
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a"
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep)
show "sort_of (atom a) = sort_of (atom b)"
unfolding atom_def by (simp add: sort_of_Rep)
show "atom a = atom b \<longleftrightarrow> a = b"
unfolding atom_def by (simp add: Rep_inject)
show "p \<bullet> atom a = atom (p \<bullet> a)"
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep)
qed
lemma at_class_sort:
fixes s :: atom_sort
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
fixes a::"'a"
assumes type: "type_definition Rep Abs {a. sort_of a = s}"
assumes atom_def: "\<And>a. atom a = Rep a"
shows "sort_of (atom a) = s"
using atom_def type
unfolding type_definition_def by simp
setup {* Sign.add_const_constraint
(@{const_name "permute"}, SOME @{typ "perm \<Rightarrow> 'a::pt \<Rightarrow> 'a"}) *}
setup {* Sign.add_const_constraint
(@{const_name "atom"}, SOME @{typ "'a::at_base \<Rightarrow> atom"}) *}
section {* Library functions for the nominal infrastructure *}
ML_file "nominal_library.ML"
section {* The freshness lemma according to Andy Pitts *}
lemma freshness_lemma:
fixes h :: "'a::at \<Rightarrow> 'b::pt"
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
shows "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
proof -
from a obtain b where a1: "atom b \<sharp> h" and a2: "atom b \<sharp> h b"
by (auto simp: fresh_Pair)
show "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
proof (intro exI allI impI)
fix a :: 'a
assume a3: "atom a \<sharp> h"
show "h a = h b"
proof (cases "a = b")
assume "a = b"
thus "h a = h b" by simp
next
assume "a \<noteq> b"
hence "atom a \<sharp> b" by (simp add: fresh_at_base)
with a3 have "atom a \<sharp> h b"
by (rule fresh_fun_app)
with a2 have d1: "(atom b \<rightleftharpoons> atom a) \<bullet> (h b) = (h b)"
by (rule swap_fresh_fresh)
from a1 a3 have d2: "(atom b \<rightleftharpoons> atom a) \<bullet> h = h"
by (rule swap_fresh_fresh)
from d1 have "h b = (atom b \<rightleftharpoons> atom a) \<bullet> (h b)" by simp
also have "\<dots> = ((atom b \<rightleftharpoons> atom a) \<bullet> h) ((atom b \<rightleftharpoons> atom a) \<bullet> b)"
by (rule permute_fun_app_eq)
also have "\<dots> = h a"
using d2 by simp
finally show "h a = h b" by simp
qed
qed
qed
lemma freshness_lemma_unique:
fixes h :: "'a::at \<Rightarrow> 'b::pt"
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
shows "\<exists>!x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
proof (rule ex_ex1I)
from a show "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
by (rule freshness_lemma)
next
fix x y
assume x: "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
assume y: "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = y"
from a x y show "x = y"
by (auto simp: fresh_Pair)
qed
text {* packaging the freshness lemma into a function *}
definition
Fresh :: "('a::at \<Rightarrow> 'b::pt) \<Rightarrow> 'b"
where
"Fresh h = (THE x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x)"
lemma Fresh_apply:
fixes h :: "'a::at \<Rightarrow> 'b::pt"
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
assumes b: "atom a \<sharp> h"
shows "Fresh h = h a"
unfolding Fresh_def
proof (rule the_equality)
show "\<forall>a'. atom a' \<sharp> h \<longrightarrow> h a' = h a"
proof (intro strip)
fix a':: 'a
assume c: "atom a' \<sharp> h"
from a have "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x" by (rule freshness_lemma)
with b c show "h a' = h a" by auto
qed
next
fix fr :: 'b
assume "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = fr"
with b show "fr = h a" by auto
qed
lemma Fresh_apply':
fixes h :: "'a::at \<Rightarrow> 'b::pt"
assumes a: "atom a \<sharp> h" "atom a \<sharp> h a"
shows "Fresh h = h a"
apply (rule Fresh_apply)
apply (auto simp: fresh_Pair intro: a)
done
simproc_setup Fresh_simproc ("Fresh (h::'a::at \<Rightarrow> 'b::pt)") = {* fn _ => fn ctxt => fn ctrm =>
let
val _ $ h = Thm.term_of ctrm
val cfresh = @{const_name fresh}
val catom = @{const_name atom}
val atoms = Simplifier.prems_of ctxt
|> map_filter (fn thm => case Thm.prop_of thm of
_ $ (Const (cfresh, _) $ (Const (catom, _) $ atm) $ _) => SOME (atm) | _ => NONE)
|> distinct (op=)
fun get_thm atm =
let
val goal1 = HOLogic.mk_Trueprop (mk_fresh (mk_atom atm) h)
val goal2 = HOLogic.mk_Trueprop (mk_fresh (mk_atom atm) (h $ atm))
val thm1 = Goal.prove ctxt [] [] goal1 (K (asm_simp_tac ctxt 1))
val thm2 = Goal.prove ctxt [] [] goal2 (K (asm_simp_tac ctxt 1))
in
SOME (@{thm Fresh_apply'} OF [thm1, thm2] RS eq_reflection)
end handle ERROR _ => NONE
in
get_first get_thm atoms
end
*}
lemma Fresh_eqvt:
fixes h :: "'a::at \<Rightarrow> 'b::pt"
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
shows "p \<bullet> (Fresh h) = Fresh (p \<bullet> h)"
proof -
from a obtain a::"'a::at" where fr: "atom a \<sharp> h" "atom a \<sharp> h a"
by (metis fresh_Pair)
then have fr_p: "atom (p \<bullet> a) \<sharp> (p \<bullet> h)" "atom (p \<bullet> a) \<sharp> (p \<bullet> h) (p \<bullet> a)"
by (metis atom_eqvt fresh_permute_iff eqvt_apply)+
have "p \<bullet> (Fresh h) = p \<bullet> (h a)" using fr by simp
also have "... = (p \<bullet> h) (p \<bullet> a)" by simp
also have "... = Fresh (p \<bullet> h)" using fr_p by simp
finally show "p \<bullet> (Fresh h) = Fresh (p \<bullet> h)" .
qed
lemma Fresh_supports:
fixes h :: "'a::at \<Rightarrow> 'b::pt"
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
shows "(supp h) supports (Fresh h)"
apply (simp add: supports_def fresh_def [symmetric])
apply (simp add: Fresh_eqvt [OF a] swap_fresh_fresh)
done
notation Fresh (binder "FRESH " 10)
lemma FRESH_f_iff:
fixes P :: "'a::at \<Rightarrow> 'b::pure"
fixes f :: "'b \<Rightarrow> 'c::pure"
assumes P: "finite (supp P)"
shows "(FRESH x. f (P x)) = f (FRESH x. P x)"
proof -
obtain a::'a where "atom a \<sharp> P" using P by (rule obtain_fresh')
then show "(FRESH x. f (P x)) = f (FRESH x. P x)"
by (simp add: pure_fresh)
qed
lemma FRESH_binop_iff:
fixes P :: "'a::at \<Rightarrow> 'b::pure"
fixes Q :: "'a::at \<Rightarrow> 'c::pure"
fixes binop :: "'b \<Rightarrow> 'c \<Rightarrow> 'd::pure"
assumes P: "finite (supp P)"
and Q: "finite (supp Q)"
shows "(FRESH x. binop (P x) (Q x)) = binop (FRESH x. P x) (FRESH x. Q x)"
proof -
from assms have "finite (supp (P, Q))" by (simp add: supp_Pair)
then obtain a::'a where "atom a \<sharp> (P, Q)" by (rule obtain_fresh')
then show ?thesis
by (simp add: pure_fresh)
qed
lemma FRESH_conj_iff:
fixes P Q :: "'a::at \<Rightarrow> bool"
assumes P: "finite (supp P)" and Q: "finite (supp Q)"
shows "(FRESH x. P x \<and> Q x) \<longleftrightarrow> (FRESH x. P x) \<and> (FRESH x. Q x)"
using P Q by (rule FRESH_binop_iff)
lemma FRESH_disj_iff:
fixes P Q :: "'a::at \<Rightarrow> bool"
assumes P: "finite (supp P)" and Q: "finite (supp Q)"
shows "(FRESH x. P x \<or> Q x) \<longleftrightarrow> (FRESH x. P x) \<or> (FRESH x. Q x)"
using P Q by (rule FRESH_binop_iff)
section {* Automation for creating concrete atom types *}
text {* At the moment only single-sort concrete atoms are supported. *}
ML_file "nominal_atoms.ML"
section {* Automatic equivariance procedure for inductive definitions *}
ML_file "nominal_eqvt.ML"
end
|
Memorizing this verse was an assignment my father, the minister, gave to a class of 7-9 year olds at Piney River Church of Christ near Dickson, TN. The language of the King James version made the message was largely unaccessible to me. I understood the general gist of the verse – that scripture was written to teach us about God’s love – but not its connection to the rest of this passage.
Paul is writing to Christians in Rome encouraging unity and willingness to love and serve one another. He refers to the Old Testament which was more familiar to early Christians than it is to many of us. He wanted his audience to understand that Jesus, the root of Jesse, is the hope of all the world. God’s incredible power came into the world through Jesus and the salvation and forgiveness he offers. The joy and peace of trusting in God is available to all believers. God sends his Spirit among us to transform our lives and empower each of us to do what we can to be the change God dreams for the world.
|
using InducingPoints
using Distances
using KernelFunctions
using KernelFunctions: ColVecs
using Test
using Random: seed!
include("test_utils.jl")
@testset "InducingPoints.jl" begin
@testset "Offline" begin
for file in readdir("offline")
include(joinpath("offline", file))
end
end
@testset "Online" begin
for file in readdir("online")
include(joinpath("online", file))
end
end
end
|
The newly appointed commander of this troubled fleet was Villaret de Joyeuse ; although formerly in a junior position , he was known to possess a high degree of tactical ability ; he had trained under Admiral Pierre André de Suffren in the Indian Ocean during the American war . However , Villaret 's attempts to mould his new officer corps into an effective fighting unit were hampered by another new appointee , a deputy of the National Convention named Jean @-@ Bon Saint @-@ André . Saint @-@ André 's job was to report directly to the National Convention on the revolutionary ardour of both the fleet and its admiral . He frequently intervened in strategic planning and tactical operations . Shortly after his arrival , Saint @-@ André proposed issuing a decree ordering that any officer deemed to have shown insufficient zeal in defending his ship in action should be put to death on his return to France , although this highly controversial legislation does not appear to have ever been acted upon . Although his interference was a source of frustration for Villaret , Saint @-@ André 's dispatches to Paris were published regularly in Le Moniteur , and did much to popularise the Navy in France .
|
/-
Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
! This file was ported from Lean 3 source module combinatorics.simple_graph.clique
! leanprover-community/mathlib commit ee05e9ce1322178f0c12004eb93c00d2c8c00ed2
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Combinatorics.SimpleGraph.Basic
import Mathbin.Data.Finset.Pairwise
/-!
# Graph cliques
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines cliques in simple graphs. A clique is a set of vertices that are pairwise
adjacent.
## Main declarations
* `simple_graph.is_clique`: Predicate for a set of vertices to be a clique.
* `simple_graph.is_n_clique`: Predicate for a set of vertices to be a `n`-clique.
* `simple_graph.clique_finset`: Finset of `n`-cliques of a graph.
* `simple_graph.clique_free`: Predicate for a graph to have no `n`-cliques.
## TODO
* Clique numbers
* Do we need `clique_set`, a version of `clique_finset` for infinite graphs?
-/
open Finset Fintype
namespace SimpleGraph
variable {α : Type _} (G H : SimpleGraph α)
/-! ### Cliques -/
section Clique
variable {s t : Set α}
#print SimpleGraph.IsClique /-
/-- A clique in a graph is a set of vertices that are pairwise adjacent. -/
abbrev IsClique (s : Set α) : Prop :=
s.Pairwise G.Adj
#align simple_graph.is_clique SimpleGraph.IsClique
-/
#print SimpleGraph.isClique_iff /-
theorem isClique_iff : G.IsClique s ↔ s.Pairwise G.Adj :=
Iff.rfl
#align simple_graph.is_clique_iff SimpleGraph.isClique_iff
-/
/- warning: simple_graph.is_clique_iff_induce_eq -> SimpleGraph.isClique_iff_induce_eq is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} (G : SimpleGraph.{u1} α) {s : Set.{u1} α}, Iff (SimpleGraph.IsClique.{u1} α G s) (Eq.{succ u1} (SimpleGraph.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (SimpleGraph.induce.{u1} α s G) (Top.top.{u1} (SimpleGraph.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (CompleteLattice.toHasTop.{u1} (SimpleGraph.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (SimpleGraph.completeBooleanAlgebra.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s))))))))
but is expected to have type
forall {α : Type.{u1}} (G : SimpleGraph.{u1} α) {s : Set.{u1} α}, Iff (SimpleGraph.IsClique.{u1} α G s) (Eq.{succ u1} (SimpleGraph.{u1} (Set.Elem.{u1} α s)) (SimpleGraph.induce.{u1} α s G) (Top.top.{u1} (SimpleGraph.{u1} (Set.Elem.{u1} α s)) (CompleteLattice.toTop.{u1} (SimpleGraph.{u1} (Set.Elem.{u1} α s)) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} (Set.Elem.{u1} α s)) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} (Set.Elem.{u1} α s)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} (Set.Elem.{u1} α s)) (SimpleGraph.completeBooleanAlgebra.{u1} (Set.Elem.{u1} α s))))))))
Case conversion may be inaccurate. Consider using '#align simple_graph.is_clique_iff_induce_eq SimpleGraph.isClique_iff_induce_eqₓ'. -/
/-- A clique is a set of vertices whose induced graph is complete. -/
theorem isClique_iff_induce_eq : G.IsClique s ↔ G.induce s = ⊤ :=
by
rw [is_clique_iff]
constructor
· intro h
ext (⟨v, hv⟩⟨w, hw⟩)
simp only [comap_adj, Subtype.coe_mk, top_adj, Ne.def, Subtype.mk_eq_mk]
exact ⟨adj.ne, h hv hw⟩
· intro h v hv w hw hne
have : (G.induce s).Adj ⟨v, hv⟩ ⟨w, hw⟩ = _ := rfl
conv_lhs at this => rw [h]
simpa [hne]
#align simple_graph.is_clique_iff_induce_eq SimpleGraph.isClique_iff_induce_eq
instance [DecidableEq α] [DecidableRel G.Adj] {s : Finset α} : Decidable (G.IsClique s) :=
decidable_of_iff' _ G.isClique_iff
variable {G H}
#print SimpleGraph.IsClique.mono /-
theorem IsClique.mono (h : G ≤ H) : G.IsClique s → H.IsClique s :=
by
simp_rw [is_clique_iff]
exact Set.Pairwise.mono' h
#align simple_graph.is_clique.mono SimpleGraph.IsClique.mono
-/
#print SimpleGraph.IsClique.subset /-
theorem IsClique.subset (h : t ⊆ s) : G.IsClique s → G.IsClique t :=
by
simp_rw [is_clique_iff]
exact Set.Pairwise.mono h
#align simple_graph.is_clique.subset SimpleGraph.IsClique.subset
-/
/- warning: simple_graph.is_clique_bot_iff -> SimpleGraph.isClique_bot_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {s : Set.{u1} α}, Iff (SimpleGraph.IsClique.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toHasBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) s) (Set.Subsingleton.{u1} α s)
but is expected to have type
forall {α : Type.{u1}} {s : Set.{u1} α}, Iff (SimpleGraph.IsClique.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) s) (Set.Subsingleton.{u1} α s)
Case conversion may be inaccurate. Consider using '#align simple_graph.is_clique_bot_iff SimpleGraph.isClique_bot_iffₓ'. -/
@[simp]
theorem isClique_bot_iff : (⊥ : SimpleGraph α).IsClique s ↔ (s : Set α).Subsingleton :=
Set.pairwise_bot_iff
#align simple_graph.is_clique_bot_iff SimpleGraph.isClique_bot_iff
/- warning: simple_graph.is_clique.subsingleton -> SimpleGraph.IsClique.subsingleton is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {s : Set.{u1} α}, (SimpleGraph.IsClique.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toHasBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) s) -> (Set.Subsingleton.{u1} α s)
but is expected to have type
forall {α : Type.{u1}} {s : Set.{u1} α}, (SimpleGraph.IsClique.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) s) -> (Set.Subsingleton.{u1} α s)
Case conversion may be inaccurate. Consider using '#align simple_graph.is_clique.subsingleton SimpleGraph.IsClique.subsingletonₓ'. -/
alias is_clique_bot_iff ↔ is_clique.subsingleton _
#align simple_graph.is_clique.subsingleton SimpleGraph.IsClique.subsingleton
end Clique
/-! ### `n`-cliques -/
section NClique
variable {n : ℕ} {s : Finset α}
#print SimpleGraph.IsNClique /-
/-- A `n`-clique in a graph is a set of `n` vertices which are pairwise connected. -/
structure IsNClique (n : ℕ) (s : Finset α) : Prop where
clique : G.IsClique s
card_eq : s.card = n
#align simple_graph.is_n_clique SimpleGraph.IsNClique
-/
#print SimpleGraph.isNClique_iff /-
theorem isNClique_iff : G.IsNClique n s ↔ G.IsClique s ∧ s.card = n :=
⟨fun h => ⟨h.1, h.2⟩, fun h => ⟨h.1, h.2⟩⟩
#align simple_graph.is_n_clique_iff SimpleGraph.isNClique_iff
-/
instance [DecidableEq α] [DecidableRel G.Adj] {n : ℕ} {s : Finset α} :
Decidable (G.IsNClique n s) :=
decidable_of_iff' _ G.isNClique_iff
variable {G H}
#print SimpleGraph.IsNClique.mono /-
theorem IsNClique.mono (h : G ≤ H) : G.IsNClique n s → H.IsNClique n s :=
by
simp_rw [is_n_clique_iff]
exact And.imp_left (is_clique.mono h)
#align simple_graph.is_n_clique.mono SimpleGraph.IsNClique.mono
-/
/- warning: simple_graph.is_n_clique_bot_iff -> SimpleGraph.isNClique_bot_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {n : Nat} {s : Finset.{u1} α}, Iff (SimpleGraph.IsNClique.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toHasBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) n s) (And (LE.le.{0} Nat Nat.hasLe n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Eq.{1} Nat (Finset.card.{u1} α s) n))
but is expected to have type
forall {α : Type.{u1}} {n : Nat} {s : Finset.{u1} α}, Iff (SimpleGraph.IsNClique.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) n s) (And (LE.le.{0} Nat instLENat n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Eq.{1} Nat (Finset.card.{u1} α s) n))
Case conversion may be inaccurate. Consider using '#align simple_graph.is_n_clique_bot_iff SimpleGraph.isNClique_bot_iffₓ'. -/
@[simp]
theorem isNClique_bot_iff : (⊥ : SimpleGraph α).IsNClique n s ↔ n ≤ 1 ∧ s.card = n :=
by
rw [is_n_clique_iff, is_clique_bot_iff]
refine' and_congr_left _
rintro rfl
exact card_le_one.symm
#align simple_graph.is_n_clique_bot_iff SimpleGraph.isNClique_bot_iff
variable [DecidableEq α] {a b c : α}
#print SimpleGraph.is3Clique_triple_iff /-
theorem is3Clique_triple_iff : G.IsNClique 3 {a, b, c} ↔ G.Adj a b ∧ G.Adj a c ∧ G.Adj b c :=
by
simp only [is_n_clique_iff, is_clique_iff, Set.pairwise_insert_of_symmetric G.symm, coe_insert]
have : ¬1 + 1 = 3 := by norm_num
by_cases hab : a = b <;> by_cases hbc : b = c <;> by_cases hac : a = c <;> subst_vars <;>
simp [G.ne_of_adj, and_rotate, *]
#align simple_graph.is_3_clique_triple_iff SimpleGraph.is3Clique_triple_iff
-/
#print SimpleGraph.is3Clique_iff /-
theorem is3Clique_iff :
G.IsNClique 3 s ↔ ∃ a b c, G.Adj a b ∧ G.Adj a c ∧ G.Adj b c ∧ s = {a, b, c} :=
by
refine' ⟨fun h => _, _⟩
· obtain ⟨a, b, c, -, -, -, rfl⟩ := card_eq_three.1 h.card_eq
refine' ⟨a, b, c, _⟩
rw [is_3_clique_triple_iff] at h
tauto
· rintro ⟨a, b, c, hab, hbc, hca, rfl⟩
exact is_3_clique_triple_iff.2 ⟨hab, hbc, hca⟩
#align simple_graph.is_3_clique_iff SimpleGraph.is3Clique_iff
-/
end NClique
/-! ### Graphs without cliques -/
section CliqueFree
variable {m n : ℕ}
#print SimpleGraph.CliqueFree /-
/-- `G.clique_free n` means that `G` has no `n`-cliques. -/
def CliqueFree (n : ℕ) : Prop :=
∀ t, ¬G.IsNClique n t
#align simple_graph.clique_free SimpleGraph.CliqueFree
-/
variable {G H} {s : Finset α}
#print SimpleGraph.IsNClique.not_cliqueFree /-
theorem IsNClique.not_cliqueFree (hG : G.IsNClique n s) : ¬G.CliqueFree n := fun h => h _ hG
#align simple_graph.is_n_clique.not_clique_free SimpleGraph.IsNClique.not_cliqueFree
-/
/- warning: simple_graph.not_clique_free_of_top_embedding -> SimpleGraph.not_cliqueFree_of_top_embedding is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} {n : Nat}, (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toHasTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G) -> (Not (SimpleGraph.CliqueFree.{u1} α G n))
but is expected to have type
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} {n : Nat}, (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G) -> (Not (SimpleGraph.CliqueFree.{u1} α G n))
Case conversion may be inaccurate. Consider using '#align simple_graph.not_clique_free_of_top_embedding SimpleGraph.not_cliqueFree_of_top_embeddingₓ'. -/
theorem not_cliqueFree_of_top_embedding {n : ℕ} (f : (⊤ : SimpleGraph (Fin n)) ↪g G) :
¬G.CliqueFree n :=
by
simp only [clique_free, is_n_clique_iff, is_clique_iff_induce_eq, not_forall, Classical.not_not]
use finset.univ.map f.to_embedding
simp only [card_map, Finset.card_fin, eq_self_iff_true, and_true_iff]
ext (⟨v, hv⟩⟨w, hw⟩)
simp only [coe_map, RelEmbedding.coeFn_toEmbedding, Set.mem_image, coe_univ, Set.mem_univ,
true_and_iff] at hv hw
obtain ⟨v', rfl⟩ := hv
obtain ⟨w', rfl⟩ := hw
simp only [f.map_adj_iff, comap_adj, Function.Embedding.coe_subtype, Subtype.coe_mk, top_adj,
Ne.def, Subtype.mk_eq_mk]
exact (Function.Embedding.apply_eq_iff_eq _ _ _).symm.Not
#align simple_graph.not_clique_free_of_top_embedding SimpleGraph.not_cliqueFree_of_top_embedding
/- warning: simple_graph.top_embedding_of_not_clique_free -> SimpleGraph.topEmbeddingOfNotCliqueFree is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} {n : Nat}, (Not (SimpleGraph.CliqueFree.{u1} α G n)) -> (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toHasTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G)
but is expected to have type
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} {n : Nat}, (Not (SimpleGraph.CliqueFree.{u1} α G n)) -> (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G)
Case conversion may be inaccurate. Consider using '#align simple_graph.top_embedding_of_not_clique_free SimpleGraph.topEmbeddingOfNotCliqueFreeₓ'. -/
/-- An embedding of a complete graph that witnesses the fact that the graph is not clique-free. -/
noncomputable def topEmbeddingOfNotCliqueFree {n : ℕ} (h : ¬G.CliqueFree n) :
(⊤ : SimpleGraph (Fin n)) ↪g G :=
by
simp only [clique_free, is_n_clique_iff, is_clique_iff_induce_eq, not_forall,
Classical.not_not] at h
obtain ⟨ha, hb⟩ := h.some_spec
have : (⊤ : SimpleGraph (Fin h.some.card)) ≃g (⊤ : SimpleGraph h.some) :=
by
apply iso.complete_graph
simpa using (Fintype.equivFin h.some).symm
rw [← ha] at this
convert(embedding.induce ↑h.some).comp this.to_embedding <;> exact hb.symm
#align simple_graph.top_embedding_of_not_clique_free SimpleGraph.topEmbeddingOfNotCliqueFree
/- warning: simple_graph.not_clique_free_iff -> SimpleGraph.not_cliqueFree_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} (n : Nat), Iff (Not (SimpleGraph.CliqueFree.{u1} α G n)) (Nonempty.{succ u1} (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toHasTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G))
but is expected to have type
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} (n : Nat), Iff (Not (SimpleGraph.CliqueFree.{u1} α G n)) (Nonempty.{succ u1} (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G))
Case conversion may be inaccurate. Consider using '#align simple_graph.not_clique_free_iff SimpleGraph.not_cliqueFree_iffₓ'. -/
theorem not_cliqueFree_iff (n : ℕ) : ¬G.CliqueFree n ↔ Nonempty ((⊤ : SimpleGraph (Fin n)) ↪g G) :=
by
constructor
· exact fun h => ⟨top_embedding_of_not_clique_free h⟩
· rintro ⟨f⟩
exact not_clique_free_of_top_embedding f
#align simple_graph.not_clique_free_iff SimpleGraph.not_cliqueFree_iff
/- warning: simple_graph.clique_free_iff -> SimpleGraph.cliqueFree_iff is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} {n : Nat}, Iff (SimpleGraph.CliqueFree.{u1} α G n) (IsEmpty.{succ u1} (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toHasTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G))
but is expected to have type
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} {n : Nat}, Iff (SimpleGraph.CliqueFree.{u1} α G n) (IsEmpty.{succ u1} (SimpleGraph.Embedding.{0, u1} (Fin n) α (Top.top.{0} (SimpleGraph.{0} (Fin n)) (CompleteLattice.toTop.{0} (SimpleGraph.{0} (Fin n)) (Order.Coframe.toCompleteLattice.{0} (SimpleGraph.{0} (Fin n)) (CompleteDistribLattice.toCoframe.{0} (SimpleGraph.{0} (Fin n)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{0} (SimpleGraph.{0} (Fin n)) (SimpleGraph.completeBooleanAlgebra.{0} (Fin n))))))) G))
Case conversion may be inaccurate. Consider using '#align simple_graph.clique_free_iff SimpleGraph.cliqueFree_iffₓ'. -/
theorem cliqueFree_iff {n : ℕ} : G.CliqueFree n ↔ IsEmpty ((⊤ : SimpleGraph (Fin n)) ↪g G) := by
rw [← not_iff_not, not_clique_free_iff, not_isEmpty_iff]
#align simple_graph.clique_free_iff SimpleGraph.cliqueFree_iff
/- warning: simple_graph.not_clique_free_card_of_top_embedding -> SimpleGraph.not_cliqueFree_card_of_top_embedding is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} [_inst_1 : Fintype.{u1} α], (SimpleGraph.Embedding.{u1, u1} α α (Top.top.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toHasTop.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) G) -> (Not (SimpleGraph.CliqueFree.{u1} α G (Fintype.card.{u1} α _inst_1)))
but is expected to have type
forall {α : Type.{u1}} {G : SimpleGraph.{u1} α} [_inst_1 : Fintype.{u1} α], (SimpleGraph.Embedding.{u1, u1} α α (Top.top.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toTop.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) G) -> (Not (SimpleGraph.CliqueFree.{u1} α G (Fintype.card.{u1} α _inst_1)))
Case conversion may be inaccurate. Consider using '#align simple_graph.not_clique_free_card_of_top_embedding SimpleGraph.not_cliqueFree_card_of_top_embeddingₓ'. -/
theorem not_cliqueFree_card_of_top_embedding [Fintype α] (f : (⊤ : SimpleGraph α) ↪g G) :
¬G.CliqueFree (card α) := by
rw [not_clique_free_iff]
use (iso.complete_graph (Fintype.equivFin α)).symm.toEmbedding.trans f
#align simple_graph.not_clique_free_card_of_top_embedding SimpleGraph.not_cliqueFree_card_of_top_embedding
/- warning: simple_graph.clique_free_bot -> SimpleGraph.cliqueFree_bot is a dubious translation:
lean 3 declaration is
forall {α : Type.{u1}} {n : Nat}, (LE.le.{0} Nat Nat.hasLe (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))) n) -> (SimpleGraph.CliqueFree.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toHasBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) n)
but is expected to have type
forall {α : Type.{u1}} {n : Nat}, (LE.le.{0} Nat instLENat (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)) n) -> (SimpleGraph.CliqueFree.{u1} α (Bot.bot.{u1} (SimpleGraph.{u1} α) (CompleteLattice.toBot.{u1} (SimpleGraph.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (SimpleGraph.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (SimpleGraph.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (SimpleGraph.{u1} α) (SimpleGraph.completeBooleanAlgebra.{u1} α)))))) n)
Case conversion may be inaccurate. Consider using '#align simple_graph.clique_free_bot SimpleGraph.cliqueFree_botₓ'. -/
theorem cliqueFree_bot (h : 2 ≤ n) : (⊥ : SimpleGraph α).CliqueFree n :=
by
rintro t ht
rw [is_n_clique_bot_iff] at ht
linarith
#align simple_graph.clique_free_bot SimpleGraph.cliqueFree_bot
#print SimpleGraph.CliqueFree.mono /-
theorem CliqueFree.mono (h : m ≤ n) : G.CliqueFree m → G.CliqueFree n :=
by
rintro hG s hs
obtain ⟨t, hts, ht⟩ := s.exists_smaller_set _ (h.trans hs.card_eq.ge)
exact hG _ ⟨hs.clique.subset hts, ht⟩
#align simple_graph.clique_free.mono SimpleGraph.CliqueFree.mono
-/
#print SimpleGraph.CliqueFree.anti /-
theorem CliqueFree.anti (h : G ≤ H) : H.CliqueFree n → G.CliqueFree n :=
forall_imp fun s => mt <| IsNClique.mono h
#align simple_graph.clique_free.anti SimpleGraph.CliqueFree.anti
-/
#print SimpleGraph.cliqueFree_of_card_lt /-
/-- See `simple_graph.clique_free_chromatic_number_succ` for a tighter bound. -/
theorem cliqueFree_of_card_lt [Fintype α] (hc : card α < n) : G.CliqueFree n :=
by
by_contra h
refine' Nat.lt_le_antisymm hc _
rw [clique_free_iff, not_isEmpty_iff] at h
simpa using Fintype.card_le_of_embedding h.some.to_embedding
#align simple_graph.clique_free_of_card_lt SimpleGraph.cliqueFree_of_card_lt
-/
end CliqueFree
/-! ### Set of cliques -/
section CliqueSet
variable (G) {n : ℕ} {a b c : α} {s : Finset α}
#print SimpleGraph.cliqueSet /-
/-- The `n`-cliques in a graph as a set. -/
def cliqueSet (n : ℕ) : Set (Finset α) :=
{ s | G.IsNClique n s }
#align simple_graph.clique_set SimpleGraph.cliqueSet
-/
#print SimpleGraph.mem_cliqueSet_iff /-
theorem mem_cliqueSet_iff : s ∈ G.cliqueSet n ↔ G.IsNClique n s :=
Iff.rfl
#align simple_graph.mem_clique_set_iff SimpleGraph.mem_cliqueSet_iff
-/
#print SimpleGraph.cliqueSet_eq_empty_iff /-
@[simp]
theorem cliqueSet_eq_empty_iff : G.cliqueSet n = ∅ ↔ G.CliqueFree n := by
simp_rw [clique_free, Set.eq_empty_iff_forall_not_mem, mem_clique_set_iff]
#align simple_graph.clique_set_eq_empty_iff SimpleGraph.cliqueSet_eq_empty_iff
-/
alias clique_set_eq_empty_iff ↔ _ clique_free.clique_set
#align simple_graph.clique_free.clique_set SimpleGraph.CliqueFree.cliqueSet
attribute [protected] clique_free.clique_set
variable {G H}
#print SimpleGraph.cliqueSet_mono /-
@[mono]
theorem cliqueSet_mono (h : G ≤ H) : G.cliqueSet n ⊆ H.cliqueSet n := fun _ => IsNClique.mono h
#align simple_graph.clique_set_mono SimpleGraph.cliqueSet_mono
-/
#print SimpleGraph.cliqueSet_mono' /-
theorem cliqueSet_mono' (h : G ≤ H) : G.cliqueSet ≤ H.cliqueSet := fun _ => cliqueSet_mono h
#align simple_graph.clique_set_mono' SimpleGraph.cliqueSet_mono'
-/
end CliqueSet
/-! ### Finset of cliques -/
section CliqueFinset
variable (G) [Fintype α] [DecidableEq α] [DecidableRel G.Adj] {n : ℕ} {a b c : α} {s : Finset α}
#print SimpleGraph.cliqueFinset /-
/-- The `n`-cliques in a graph as a finset. -/
def cliqueFinset (n : ℕ) : Finset (Finset α) :=
univ.filterₓ <| G.IsNClique n
#align simple_graph.clique_finset SimpleGraph.cliqueFinset
-/
#print SimpleGraph.mem_cliqueFinset_iff /-
theorem mem_cliqueFinset_iff : s ∈ G.cliqueFinset n ↔ G.IsNClique n s :=
mem_filter.trans <| and_iff_right <| mem_univ _
#align simple_graph.mem_clique_finset_iff SimpleGraph.mem_cliqueFinset_iff
-/
#print SimpleGraph.coe_cliqueFinset /-
@[simp]
theorem coe_cliqueFinset (n : ℕ) : (G.cliqueFinset n : Set (Finset α)) = G.cliqueSet n :=
Set.ext fun _ => mem_cliqueFinset_iff _
#align simple_graph.coe_clique_finset SimpleGraph.coe_cliqueFinset
-/
#print SimpleGraph.cliqueFinset_eq_empty_iff /-
@[simp]
theorem cliqueFinset_eq_empty_iff : G.cliqueFinset n = ∅ ↔ G.CliqueFree n := by
simp_rw [clique_free, eq_empty_iff_forall_not_mem, mem_clique_finset_iff]
#align simple_graph.clique_finset_eq_empty_iff SimpleGraph.cliqueFinset_eq_empty_iff
-/
alias clique_finset_eq_empty_iff ↔ _ _root_.simple_graph.clique_free.clique_finset
#align simple_graph.clique_free.clique_finset SimpleGraph.CliqueFree.cliqueFinset
attribute [protected] clique_free.clique_finset
variable {G} [DecidableRel H.Adj]
#print SimpleGraph.cliqueFinset_mono /-
@[mono]
theorem cliqueFinset_mono (h : G ≤ H) : G.cliqueFinset n ⊆ H.cliqueFinset n :=
monotone_filter_right _ fun _ => IsNClique.mono h
#align simple_graph.clique_finset_mono SimpleGraph.cliqueFinset_mono
-/
end CliqueFinset
end SimpleGraph
|
theory Wiring
imports RubyType
begin
definition Id :: "i \<Rightarrow> i" where
"Id(A) == spread({xy:A*A. EX x. xy = <x, x>})"
definition lwir :: "[i, i] \<Rightarrow> i" where
"lwir(A, C) == spread({ab:A*(A*(C*C)). EX a c. ab = <a, <a, <c, c>>>})"
definition rwir :: "[i, i] \<Rightarrow> i" where
"rwir(A, C) == spread({ab:(A*(A*C))*C. EX b c. ab = <<c, <c, b>>, b>})"
definition reorg :: "[i, i, i] \<Rightarrow> i" where
"reorg(A, B, C) == spread({ab:((A*B)*C)*(A*(B*C)).
EX a b c. ab = <<<a,b>,c>,<a, <b, c>>>})"
definition cross :: "[i, i] \<Rightarrow> i" where
"cross(A, B) == spread({ab:((A*B)*(B*A)). EX a b. ab = <<a,b>, <b,a>>})"
definition p1 :: "[i, i] \<Rightarrow> i" where
"p1(A, B) == spread({ab:(A*B)*A. EX a b. ab = <<a,b>, a>})"
definition p2 :: "[i, i] \<Rightarrow> i" where
"p2(A, B) == spread({ab:(A*B)*B. EX a b. ab = <<a,b>, b>})"
definition dub :: "i \<Rightarrow> i" where
"dub(A) == spread({ab:A*(A*A). EX a. ab = <a, <a,a>>})"
definition pzip :: "[i, i, i, i] \<Rightarrow> i" where
"pzip(A, B, C, E) ==
spread({ab: (((A*B)*(C*E))*((A*C)*(B*E))).
EX a b c d. ab = <<<a, b>, <c, d>>, <<a, c>, <b, d>>>})"
definition NNIL :: "i" where
"NNIL == spread({<nnil, nnil>})"
definition apl :: "[i, i] \<Rightarrow> i" where
"apl(A, n) == spread({ab:(A*nlist[n]A)*nlist[succ(n)]A.
EX a1 a2. ab = <<a1, a2>, ncons(n, a1, a2)>})"
definition apr :: "[i, i] \<Rightarrow> i" where
"apr(A, n) == spread({ab:(nlist[n]A*A)*nlist[succ(n)]A.
EX a1 a2. ab = <<a1, a2>, nsnoc(n, a1, a2)>})"
definition rapp :: "[i, i, i] \<Rightarrow> i" where
"rapp(A, n, m) == spread({ab:(nlist[n]A*nlist[m]A)*nlist[n #+ m]A.
EX a1 a2. ab = <<a1, a2>, napp(n, m, a1, a2)>})"
theorem reorg_type: "reorg(A,B,C): (A*B)*C <~>A*B*C"
apply(unfold reorg_def)
apply(rule spread_type, blast)
done
theorem reorgR: "\<lbrakk> A:ChTy; B:ChTy; C:ChTy \<rbrakk> \<Longrightarrow> reorg(A,B,C):(A*B)*C<R>A*B*C"
apply(unfold reorg_def)
apply(rule spreadR)
apply((intro prod_in_chty, simp+)+, blast)
done
lemma spair_apply_time: "t:int \<Longrightarrow> <a#b>`t = <a`t, b`t>"
apply(simp add: spair_def)
done
lemma sig_apply_time: "\<lbrakk> a:sig(A); t:int \<rbrakk> \<Longrightarrow> a`t:A"
apply(simp)
done
theorem reorgI:
"\<lbrakk> a:sig(A); b:sig(B); c:sig(C) \<rbrakk> \<Longrightarrow> <<<a#b>#c>,<a#<b#c>>>:reorg(A,B,C)"
apply(unfold reorg_def)
apply(rule spreadI)
apply(rule, rule)
apply((subst spair_apply_time, simp)+)
apply((drule sig_apply_time, simp)+)
apply(simp)
apply((subst spair_apply_time, simp)+)
apply(simp)
apply(blast)
apply((intro spair_type, simp+)+)
done
theorem reorgE:
"\<lbrakk> <<<a#b>#c>,<d#<e#f>>>:reorg(A,B,C);
\<lbrakk> a=d; b=e; c=f \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(B'); c:sig(C');
d:sig(A''); e:sig(B''); f:sig(C'') \<rbrakk> \<Longrightarrow> P"
apply(unfold reorg_def)
apply(erule spreadE)
apply(subgoal_tac "a=d & b=e & c=f", simp)
apply(intro conjI)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem cross_type: "cross(A,B):A*B<~>B*A"
apply(unfold cross_def)
apply(rule spread_type, blast)
done
theorem crossR: "\<lbrakk> A:ChTy; B:ChTy \<rbrakk> \<Longrightarrow> cross(A,B):A*B<R>B*A"
apply(unfold cross_def)
apply(rule spreadR)
apply((intro prod_in_chty, simp+)+, blast)
done
theorem crossI: "\<lbrakk> a:sig(A); b:sig(B) \<rbrakk> \<Longrightarrow> <<a#b>, <b#a>>:cross(A,B)"
apply(unfold cross_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast)
apply((intro spair_type, simp+)+)
done
theorem crossE:
"\<lbrakk> <<a#b>, <c#d>>:cross(A,B); \<lbrakk> a=d; b=c \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(B'); c:sig(B''); d:sig(A'') \<rbrakk> \<Longrightarrow> P"
apply(unfold cross_def, erule spreadE)
apply(subgoal_tac "a=d & b=c", simp)
apply(rule)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem Id_type: "Id(A):A<~>A"
apply(unfold Id_def)
apply(rule spread_type, blast)
done
theorem IdR: "A:ChTy \<Longrightarrow> Id(A):A<R>A"
apply(unfold Id_def, rule spreadR)
apply((simp | blast)+)
done
theorem IdI: "a:sig(A) \<Longrightarrow> <a,a>:Id(A)"
apply(unfold Id_def, rule spreadI, rule)
apply((simp | blast)+)
done
theorem IdI2: "\<lbrakk> a:sig(A); b:sig(B); a=b \<rbrakk> \<Longrightarrow> <a, b>:Id(A)"
apply(simp, rule IdI, simp)
done
theorem IdE: "\<lbrakk> <x,y>:Id(A); \<lbrakk> x=y \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply(unfold Id_def)
apply(subgoal_tac "x:sig(A) & y:sig(A)")
apply(erule spreadE)
apply(subgoal_tac "x=y", simp)
apply(rule fun_extension, auto)
apply(unfold spread_def, auto)
apply(subgoal_tac "domain({xy \<in> A \<times> A . \<exists>x. xy = \<langle>x, x\<rangle>}) \<subseteq> A")
apply(drule sig_mono, rule subsetD, simp+, blast)
apply(subgoal_tac "range({xy \<in> A \<times> A . \<exists>x. xy = \<langle>x, x\<rangle>}) \<subseteq> A")
apply(drule sig_mono, rule subsetD, simp+, blast)
done
theorem lwir_type: "lwir(A,B):A<~>A*B*B"
apply(unfold lwir_def, rule spread_type, blast)
done
theorem lwirR: "\<lbrakk> A:ChTy; B:ChTy \<rbrakk> \<Longrightarrow> lwir(A,B):A<R>A*B*B"
apply(unfold lwir_def, rule spreadR)
apply(((intro prod_in_chty)?, simp)+)
apply(blast)
done
theorem lwirI: "\<lbrakk> a:sig(A); b:sig(B) \<rbrakk> \<Longrightarrow> <a, <a#<b#b>>>:lwir(A,B)"
apply(unfold lwir_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
done
theorem lwirE:
"\<lbrakk> <a, <b#<c#d>>>:lwir(A,B);
a:sig(C1); b:sig(C2); c:sig(C3); d:sig(C4);
\<lbrakk> a=b; c=d \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply(unfold lwir_def, erule spreadE)
apply(subgoal_tac "a=b & c=d", simp)
apply(rule)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem rwir_type: "rwir(A,B):A*A*B<~>B"
apply(unfold rwir_def, rule spread_type, blast)
done
theorem rwirR: "\<lbrakk> A:ChTy; B:ChTy \<rbrakk> \<Longrightarrow> rwir(A,B):A*A*B<R>B"
apply(unfold rwir_def, rule spreadR)
apply(((intro prod_in_chty)?, simp)+)
apply(blast)
done
theorem rwirI: "\<lbrakk> a:sig(A); b:sig(B) \<rbrakk> \<Longrightarrow> <<a#<a#b>>,b>:rwir(A,B)"
apply(unfold rwir_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
done
theorem rwirE:
"\<lbrakk> <<a#<b#c>>,d>:rwir(A,B); \<lbrakk> a=b; c=d \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(A''); c:sig(B'); d:sig(B'') \<rbrakk> \<Longrightarrow> P"
apply(unfold rwir_def, erule spreadE)
apply(subgoal_tac "a=b & c=d", simp)
apply(rule)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem p1_type: "p1(A,B):A*B<~>A"
apply(unfold p1_def, rule spread_type, blast)
done
theorem p1R: "\<lbrakk> A:ChTy; B:ChTy \<rbrakk> \<Longrightarrow> p1(A,B):A*B<R>A"
apply(unfold p1_def, rule spreadR)
apply(((intro prod_in_chty)?, simp)+)
apply(blast)
done
theorem p1I: "\<lbrakk> a:sig(A); b:sig(B) \<rbrakk> \<Longrightarrow> <<a#b>, a>:p1(A,B)"
apply(unfold p1_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
done
theorem p1E:
"\<lbrakk> <<a#b>,c>:p1(A,B); \<lbrakk> a=c \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(B'); c:sig(A'') \<rbrakk> \<Longrightarrow> P"
apply(unfold p1_def, erule spreadE)
apply(subgoal_tac "a=c", simp)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem p2_type: "p2(A,B):A*B<~>B"
apply(unfold p2_def, rule spread_type, blast)
done
theorem p2R: "\<lbrakk> A:ChTy; B:ChTy \<rbrakk> \<Longrightarrow> p2(A,B):A*B<R>B"
apply(unfold p2_def, rule spreadR)
apply(((intro prod_in_chty)?, simp)+)
apply(blast)
done
theorem p2I: "\<lbrakk> a:sig(A); b:sig(B) \<rbrakk> \<Longrightarrow> <<a#b>, b>:p2(A,B)"
apply(unfold p2_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
done
theorem p2E:
"\<lbrakk> <<a#b>,c>:p2(A,B); \<lbrakk> b=c \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(B'); c:sig(A'') \<rbrakk> \<Longrightarrow> P"
apply(unfold p2_def, erule spreadE)
apply(subgoal_tac "b=c", simp)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem dub_type: "dub(A):A<~>A*A"
apply(unfold dub_def, rule spread_type, blast)
done
theorem dubR: "A:ChTy \<Longrightarrow> dub(A):A<R>A*A"
apply(unfold dub_def, rule spreadR)
apply(((intro prod_in_chty)?, simp)+)
apply(blast)
done
theorem dubI: "a:sig(A) \<Longrightarrow> <a, <a#a>>:dub(A)"
apply(unfold dub_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
done
theorem dubE:
"\<lbrakk> <a, <b#c>>:dub(A); \<lbrakk> a=b;a=c \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(A''); c:sig(A''') \<rbrakk> \<Longrightarrow> P"
apply(unfold dub_def, erule spreadE)
apply(subgoal_tac "a=b & a=c", simp, rule conjI)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem pzip_type: "pzip(A,B,C,E):(A*B)*C*E<~>(A*C)*B*E"
apply(unfold pzip_def, rule spread_type, blast)
done
theorem pzipR:
"\<lbrakk> A:ChTy; B:ChTy; C:ChTy; E:ChTy \<rbrakk>
\<Longrightarrow> pzip(A,B,C,E):(A*B)*C*E<R>(A*C)*B*E"
apply(unfold pzip_def, rule spreadR)
apply(((intro prod_in_chty)?, simp)+)
apply(blast)
done
theorem pzipI:
"\<lbrakk> a:sig(A); b:sig(B); c:sig(C); d:sig(E) \<rbrakk>
\<Longrightarrow> <<<a#b>#<c#d>>,<<a#c>#<b#d>>>:pzip(A,B,C,E)"
apply(unfold pzip_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
done
theorem pzipE:
"\<lbrakk> <<<a#b>#<c#d>>,<<e#f>#<g#h>>>:pzip(A,B,C,E);
\<lbrakk> a=e; b=g; c=f; d=h \<rbrakk> \<Longrightarrow> P;
a:sig(A'); b:sig(B'); c:sig(C'); d:sig(E');
e:sig(A''); f:sig(C''); g:sig(B''); h:sig(E'') \<rbrakk> \<Longrightarrow> P"
apply(unfold pzip_def, erule spreadE)
apply(subgoal_tac "a=e & b=g & c=f & d=h", simp, intro conjI)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp)+)
done
theorem NNIL_type: "NNIL:nlist[0]A<~>nlist[0]B"
apply(unfold NNIL_def, rule spread_type)
apply(subgoal_tac "nnil:nlist[0]A & nnil:nlist[0]B", simp)
apply(intro conjI nnil_type)
done
theorem NNILR: "\<lbrakk> A:ChTy; B:ChTy \<rbrakk> \<Longrightarrow> NNIL:nlist[0]A<R>nlist[0]B"
apply(unfold NNIL_def, rule spreadR)
apply((intro nlist_in_chty, simp)+)
apply(subgoal_tac "nnil:nlist[0]A & nnil:nlist[0]B", simp)
apply(intro conjI nnil_type)
done
theorem NNILI: "<snil, snil>:NNIL"
apply(unfold NNIL_def, rule spreadI)
apply(rule, simp add: snil_def)
defer
apply(rule snil_type[of A])
apply(rule snil_type[of B])
apply(subgoal_tac "nnil:nlist[0]A & nnil:nlist[0]B", simp)
apply(intro conjI nnil_type)
done
theorem NNILE:
"\<lbrakk> <x,y>:NNIL; x:sig(nlist[0]A'); y:sig(nlist[0]B');
\<lbrakk> x=snil; y=snil \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply(unfold NNIL_def, erule spreadE)
apply(subgoal_tac "x = snil & y = snil", simp, rule conjI)
apply((simp add: snil_def, rule fun_extension, simp+)+)
done
theorem apl_type: "apl(A,n):A*nlist[n]A<~>nlist[succ(n)]A"
apply(unfold apl_def, rule spread_type, blast)
done
theorem aplR: "A:ChTy \<Longrightarrow> apl(A,n):A*nlist[n]A<R>nlist[succ(n)]A"
apply(unfold apl_def, rule spreadR)
apply(((intro prod_in_chty nlist_in_chty)?, simp)+)
apply(blast)
done
theorem aplI: "\<lbrakk> a:sig(A); l:sig(nlist[n]A) \<rbrakk> \<Longrightarrow> <<a#l>, [a@>l|n]>:apl(A,n)"
apply(unfold apl_def scons_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
apply(insert scons_type, simp add: scons_def)
done
theorem aplE:
"\<lbrakk> <<a#la>,[b@>lb|n]>:apl(A,n);
a:sig(A1); b:sig(A2); la:sig(nlist[n]A3); lb:sig(nlist[n]A4);
\<lbrakk> a=b; la=lb \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply(unfold apl_def scons_def, erule spreadE)
apply(subgoal_tac "a=b & la=lb", simp, intro conjI)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp,
elim conjE ncons_inject, simp+)+)
done
theorem apr_type: "apr(A,n):nlist[n]A*A<~>nlist[succ(n)]A"
apply(unfold apr_def, rule spread_type, blast)
done
theorem aprR: "A:ChTy \<Longrightarrow> apr(A,n):nlist[n]A*A<R>nlist[succ(n)]A"
apply(unfold apr_def, rule spreadR)
apply(((intro prod_in_chty nlist_in_chty)?, simp)+)
apply(blast)
done
theorem aprI: "\<lbrakk> a:sig(A); l:sig(nlist[n]A) \<rbrakk> \<Longrightarrow> <<l#a>, [l<@a|n]>:apr(A,n)"
apply(unfold apr_def ssnoc_def)
apply(rule spreadI, rule+)
apply((intro sig_apply_time spair_type, simp+)+)
apply((subst spair_apply_time, simp)+, simp)
apply(blast+)
apply((intro sig_apply_time spair_type, simp+)+)
apply(insert ssnoc_type2, simp add: ssnoc_def)
done
theorem aprE:
"\<lbrakk> <<la#a>,[lb<@b|n]>:apr(A,n);
a:sig(A1); b:sig(A2); la:sig(nlist[n]A3); lb:sig(nlist[n]A4);
\<lbrakk> a=b; la=lb \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply(unfold apr_def ssnoc_def, erule spreadE)
apply(subgoal_tac "a=b & la=lb", simp, intro conjI)
apply((rule fun_extension, simp+,
drule bspec, simp,
(subst (asm) spair_apply_time, simp)+, simp,
elim conjE nsnoc_inject, simp+)+)
done
lemmas Ruby_type = Ruby_type
reorg_type cross_type Id_type
lwir_type rwir_type p1_type p2_type
dub_type pzip_type NNIL_type
apl_type apr_type
lemmas RubyR = RubyR
reorgR crossR IdR lwirR rwirR
p1R p2R dubR pzipR NNILR
aplR aprR
lemmas RubyI = RubyI
reorgI crossI IdI lwirI rwirI
p1I p2I dubI pzipI NNILI
aplI aprI
lemmas RubyE = RubyE
reorgE crossE IdE lwirE rwirE
p1E p2E dubE pzipE NNILE
aplE aprE
declare Ruby_type [TC]
end
|
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage[margin=1in]{geometry}
\usepackage[divipsnames]{xcolor}
\usepackage{float}
\usepackage{minted}
\usepackage{algorithm}
\usepackage{setspace}
\usepackage{etoolbox}
\usepackage{mathtools}
\usepackage{sourcecodepro}
\usepackage{algpseudocode}
\usepackage{mdframed}
\usepackage{pgfplots}
\usepackage{changepage}
\mdfsetup{skipabove=0pt,skipbelow=0pt}
\spaceskip=1mm
\makeatletter
\renewcommand{\ALG@name}{Pseudocode}
\bibliography{ref}
\setlength\parindent{0pt}
\setlength\parskip{0.5em}
\BeforeBeginEnvironment{minted}{\smallskip}
\AfterEndEnvironment{minted}{\smallskip}
\AtBeginEnvironment{minted}{\setstretch{1.2}}
\definecolor{palegreen}{RGB}{248, 255, 248}
\definecolor{graymetal}{RGB}{208, 226, 234}
\definecolor{navyblue}{RGB}{24, 64, 146}
\definecolor{matteblue}{RGB}{72, 114, 195}
\hypersetup{
colorlinks = true,
urlcolor = matteblue,
filecolor = navyblue
linkcolor = matteblue,
citecolor = navyblue
}
\begin{document}
\begin{titlepage}
\pagecolor{palegreen}
\centering
\vspace*{0.3cm}
\Huge
\begin{mdframed}[
backgroundcolor=graymetal,
linecolor=black,
rightline=false,
leftline=false,
linewidth=4pt,
innertopmargin=1.75cm,
innerbottommargin=1.75cm
]
\centering
\textbf{2D \ \ Procedural \ \ Map \ \ Generation}
\huge
\vfill
\
\textbf{With Pascal \& SwinGame}
\end{mdframed}
\vfill
\begin{tikzpicture}
\begin{axis}[
width=0.8\textwidth,
height=0.8\textwidth,
xlabel=$x$,
ylabel=$y$,
hide axis]
\addplot3[surf,
colormap/cool,
domain=0:1]
{sin(deg(8*pi*x))* exp(-20*(y-0.5)^2)
+ exp(-(x-0.5)^2*30
- (y-0.25)^2 - (x-0.5)*(y-0.25))};
\end{axis}
\end{tikzpicture}
\vfill
\large
\textbf{Jacob Milligan \\ \small Student ID - 100660682}
\end{titlepage}
\clearpage
\nopagecolor
\hypersetup{linkcolor=navyblue}
\tableofcontents
\hypersetup{linkcolor=blue}
\clearpage
\section{Procedural Generation}
\subsection{Procedural over Manual}
Very broadly speaking, in game development there are two primary ways to generate content for a project. The most common and controllable way is to produce each piece of content by hand. The consequences, in the case of this article, would be the production of a large 2D tile map by a manual process.
For smaller content sizes this isn't a problem; it's a relatively straight-forward process to declare each tile as an element of a statically-sized 2D array and just draw those tiles to the screen in a single pass alongside, perhaps, the drawing of different sprites layered on top of each tile to represent NPC's or the player. But what happens as a map grows in size? As it increases from a $32 \times 32$ map to a $256 \times 256$ sized map, or even larger? Even if the programmer had created a time-saving, high-level system for creating maps as text files to be read in by the program, it can very quickly become time-consuming and tedious. Although this is a valid way of generating content, in fact the developers on CD Projekt Red's The Witcher 3: Wild Hunt did just that \parencite{witcher}, most programmers don't possess the resources or manpower of a AAA game studio and therefore often must create a better solution. So what's the appropriate solution?
\paragraph{Procedural Generation algorithms are the solution}\mbox{}
Indie game title such as Minecraft, Dwarf Fortress, and the upcoming No Mans Sky all make use of procedural content generation to build enormous, beautiful, but seemingly random and unique worlds. We say \emph{seemingly} random for two reasons:
\begin{enumerate}
\item
Computers can only produce \emph{pseudo}-random numbers as the only truly random processes are analog, physically occurring phenomena, such as the measurement of cosmic radiation or noise signals in hardware circuits \parencite{guneysu}.
\item
These procedural generation algorithms are designed so that, with the same starting point, it will produce the same result.
\end{enumerate}
\paragraph{What is the starting point for this process?}\mbox{}
The answer to that question is wide and varied and many games, such as in indie title Dwarf Corp., begin by simulating tectonic plate activity \parencite{dwarfcorp}, erosion, or river formation to carve out their terrain - in a similar fashion to how terrain forms in the real world \parencite[pp. 46]{huggett}. However, this article will be taking a different route and begin by generating a realistic height map stored in a 2D array of elements that each hold a generated elevation value which will be used to base the remaining generation procedures off. We will use this initial information to procedurally generate a $512 \times 512$ sized 2D continent-like map that can be navigated by a player character. Furthermore, we will make heavy use of the SwinGame API to handle all graphics-related functionality and briefly touch on other interesting concepts such as basic collision detection and drawing algorithms, all of which will be coded using the Pascal programming language.
\subsection{Diamonds \& Squares}
To generate a heightmap, it would be possible to design an algorithm from scratch, however that would take a long time, would need to be rigorously tested, and the result probably wouldn't be very effective, so the core of our program will be based off a very well-known and well-tested one named \textbf{Random Midpoint Displacement} \parencite{fournier}, also known as \textbf{the Diamond-Square Algorithm}. At its core, the purpose of this algorithm is to generate pseudo-random noise in a desirable pattern, i.e. one that resembles a realistic spread of terrain height values. Each point of noise is stored in a data structure, in our case a 2D array, and holds a single value - a number representing its elevation. The resulting map will look something like this:
\begin{figure}[H]
\centering
\includegraphics{map.jpg}
\renewcommand{\figurename}{Example}
\caption{A map generated using Diamond-Square}
\end{figure}
\paragraph{The basic concept behind Diamond-Square can be summed up like so:}
\begin{itemize}
\item
Take an empty grid, which must be of size \(2^{n}+1\) in order for the following steps to function correctly. Then assign the corners a \emph{seed} value, a number that all other calculations are based off. This will mean that with the same seed, the same result should be produced. Then iterate the following two steps:
\begin{itemize}
\item
\textbf{The Sqaure Step} - Take the grids four corners, average their total, find their mid point and assign that point the average plus a random value up to the maximum defined height of the map.
\item
\textbf{The Diamond Step} - Given the previous step, we now have a diamond shape of four points surrounding a new mid point. Take the average of all points in the diamond and assign the new midpoint that value plus a random amount up to the maximum defined height value.
\end{itemize}
\item
Use a \mintinline{Pascal}{nextStep} variable to determine which point in each diamond and square step to calculate.
\item
Iterate until \mintinline{Pascal}{nextStep} is less than zero.
\end{itemize}
This process can be best visualized using graphs, seen in the example pictured below.
\begin{figure}[H]
\centering
\includegraphics[width=0.9\linewidth,trim=4 4 4 4,clip]{diamondsquare.eps}
\renewcommand{\figurename}{Example}
\caption{Summary of the Diamond-Square algorithm}\label{fig:graph}
\end{figure}
\paragraph{Using this algorithm provides the ability to generate a starting point.}
However, before beginning an implementation, as with all software development, it would be wise to define the requirements for the final program - the functions, procedures, data structures, and features that should be included:
\begin{itemize}
\item
First, we'll need a \mintinline{pascal}{Tile record} to hold data related to each tile in the map such as collision value, its associated bitmap, it's terrain type, and elevation. We'll also need a \mintinline{pascal}{MapData record} to contain our tile grid, the players sprite and location data, and its total size.
\item
We'll need two primary terrain generation procedures - \mintinline{pascal}{DiamondSquare()} \& \mintinline[breaklines]{pascal}{GenerateTerrain()}. \mintinline{pascal}{DiamondSquare()} will be responsible for creating a new heightmap for a given \mintinline{pascal}{MapData()} parameter, whereas \mintinline{pascal}{GenerateTerrain()} will be responsible for deciding how each tile should be rendered based off the heightmap, alongside generating trees on the new \mintinline{pascal}{MapData's} tile grid.
\item
Now that the terrain generation functions and data structures are defined, we'll also need a \mintinline{pascal}{CreateMap()} function to call both of the above procedures and to search for an appropriate place on the map to spawn the player.
\item
Finally, we'll need both a \mintinline{pascal}{HandleInput()} procedure and a \mintinline{pascal}{DrawMap()} procedure to move the player around while detecting collision tiles and to draw the tile grid to the screen respectively.
\end{itemize}
There will also be several functions and resources referenced later on that we won't be building as they aren't directly related to procedural generation and are just utilities for allowing our map to render properly. This code sits in the \mintinline{pascal}{MapUtils.pas} file and can be downloaded from \href{https://github.com/jacobmilligan/intro_hd_report}{github}, as part of the source for the finished project, alongside the bitmap resources we'll be using (if you don't have git installed you can just click the 'clone or download' link and download as a zip file). These extra files are important for loading bitmaps, updating the camera position relative to the edge of the map, and drawing a map overview to the screen.
\section{Coding Terrain Generation}
\subsection{Setting Up}
\paragraph{The primary goal of this article is to implement Diamond-Square and must be done prior to any other terrain generation.}\mbox{}
First, download and install the \href{http://www.freepascal.org/download.var}{latest version of FPC} (Free Pascal Compiler) and a Pascal SwinGame template from the \href{http://swingame.com/index.php/downloads.html}{SwinGame Website} (see each websites installation section for instructions on how to do this). Once this is complete, copy your downloaded SwinGame template to wherever you normally store your code, i.e. \mintinline{bash}{/Users/Jacob/Dev/Repos/}. All of the programming will take place in the \mintinline{bash}{/src/} folder and whenever the game needs to be built and run, type the command \mintinline{bash}{./build.sh && ./run.sh} (drop the \mintinline{bash}{./} on Windows machines). Rename the \mintinline{pascal}{GameMain.pas} file to something a bit more descriptive, such as \mintinline[breaklines]{pascal}{ProceduralGeneration.pas} and open it up in your favourite text editor.
The first thing we need to do is to replace the code in the stock \mintinline{pascal}{Main()} procedure with the following:
\begin{minted}[bgcolor=darkgray,style=native]{pascal}
procedure Main();
var
map: MapData;
begin
DiamondSquare(map, 100, 20);
PrintMapToConsole(map);
end;
\end{minted}
Before we render anything to a graphics window, we should first implement our algorithm and ensure that it functions correctly by printing it to the console, both procedures that will be called from \mintinline{pascal}{Main()}. We've also declared a new \mintinline{pascal}{MapData} variable which we'll be creating soon.
\vspace{1mm}
Next, create a new file in the \mintinline{bash}{/src/} directory called \mintinline{pascal}{Terrain.pas}, open it up and write a new Unit file skeleton:
\begin{mdframed}[topline=false,bottomline=false,backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2,breaklines]{pascal}
unit Terrain;
interface
uses SwinGame;
type
// Valid tile types for building maps with. Used as a terrain flag for different logic.
TileType = (Water, Sand, Dirt, Grass, MediumGrass, HighGrass, SnowyGrass, Mountain);
// Represents a feature on top of a tile that can have a bitmap, collision, and be interactive
FeatureType = (NoFeature, Tree);
// Represents a tile on the map - has a terrain flag, elevation and bitmap
Tile = record
flag: TileType; // Terrain type
feature: FeatureType; // Type of feature if any
collidable: Boolean; // Tile uses collision detection
elevation: Integer; // The tiles elevation - zero represents sealevel.
bmp: Bitmap; // Tiles base bitmap
featureBmp: Bitmap; // If has feature, its bitmap
hasBmp: Boolean;
end;
// Array used to hold a tilemap
TileGrid = array of array of Tile;
// Main representation of the current map. Holds a tile grid, alongside data related to size, smoothness, seed values.
MapData = record
tiles: TileGrid; // All of the tiles on a map
player: Sprite;
playerX, playerY: Integer; // Tile-based coordinates
size, seed, tilesize, playerIndicator: Integer; // Map settings
end;
// Fills a MapData's TileGrid with generated heightmap data using the Diamond-Square fractal generation algorithm
// This heightmap data gets used later on to generate terrain realistically
procedure DiamondSquare(var map: MapData; maxHeight, smoothness: Integer);
// Uses elevation values generated by DiamondSquare to assign appropriate bitmaps and randomly generate trees
procedure GenerateTerrain(var map: MapData);
implementation
procedure DiamondSquare(var map: MapData; maxHeight, smoothness: Integer);
begin
//code
end;
procedure GenerateTerrain(var map: MapData);
begin
//code
end;
end.
\end{minted}
\end{mdframed}
\paragraph{That's a lot of code, so let's step through it.}\mbox{}
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
unit Terrain;
interface
uses SwinGame;
type
//
// Valid tile types for building maps with.
// Used as a terrain flag for different logic.
//
TileType = (Water, Sand, Dirt, Grass, MediumGrass, HighGrass, SnowyGrass, Mountain);
//
// Represents a feature on top of a tile that can have a bitmap,
// collision, and be interactive
//
FeatureType = (NoFeature, Tree);
\end{minted}
First, we create a new \mintinline{pascal}{unit} file named \mintinline{pascal}{Terrain}. A \mintinline{pascal}{unit} file has two sections of code:
\begin{itemize}
\item
The \mintinline{pascal}{interface} where all types are declared alongside \textbf{forward-declared} functions and procedures. This is the part of the \mintinline{pascal}{unit} file that other units and the main program will actually see.
\item
The \mintinline{pascal}{implementation} section where the body of each function and procedure is actually defined.
\end{itemize}
Each unit and program can make use of the data structures, functions, and procedures created in other units via the \mintinline{pascal}{uses <UnitName>} syntax.
In the \mintinline{pascal}{type} section of the unit, we declare two enumeration types.- \mintinline{pascal}{TileType} \& \mintinline{pascal}{FeatureType}. These will be used by our \mintinline{pascal}{GenerateTerrain()} procedure and the \mintinline{pascal}{MapUtils.pas unit} file to determine how to treat different tiles. Of note is the \mintinline{pascal}{FeatureType enumeration} which at the moment can only be either a Tree or nothing. Generally speaking, If we only wanted to represent Trees in the game world, we would be better off using a \mintinline{pascal}{hasTree Boolean} variable but the reason we've used an \mintinline{pascal}{enumeration} is to future-proof our program; if we wanted to later on add logs or rocks to the game we would only need to add a new element to \mintinline{pascal}{FeatureType} and alter the terrain generation code.
\vspace{5mm}
\begin{mdframed}[backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2]{pascal}
//
// Represents a tile on the map - has a terrain flag,
// elevation and bitmap
//
Tile = record
// terrain type
flag: TileType;
// type of feature if any
feature: FeatureType;
// uses collision detection
collidable: Boolean;
//
// Represents the tiles elevation - zero represents sea
// level.
//
elevation: Integer;
// tiles base bitmap
bmp: Bitmap;
hasBmp: Boolean;
// bitmap for whatever feature is on top of the tiles
featureBmp: Bitmap;
end;
//
// Array used to hold a tilemap
//
TileGrid = array of array of Tile;
//
// Main representation of the current map. Holds a tile grid, alongside
// data related to size, smoothness, seed values.
//
MapData = record
tiles: TileGrid;
player: Sprite;
playerX, playerY: Integer;
size, seed, tilesize, playerIndicator: Integer;
end;
\end{minted}
\end{mdframed}
\paragraph{Here, we declare our most important records and types.} The \mintinline{pascal}{Tile record} is what represents a single element of our tile grid and contains a \mintinline{pascal}{TileType} \mintinline{pascal}{flag}, a \mintinline{pascal}{FeatureType}, a \mintinline{pascal}{Boolean} variable \mintinline{pascal}{collidable} to communicate that the particular tile is subject to collision detection, the tiles \mintinline{pascal}{elevation Integer} value, its attached base tile \mintinline{pascal}{Bitmap} and its feature \mintinline{pascal}{Bitmap} (in this case either a Tree or an invisible bitmap) to render alongside a \mintinline{pascal}{hasBmp Boolean} value used to stop our drawing procedures from trying to draw a non-existent bitmap and crash the game. We've also declared a new \mintinline{pascal}{open array of dynamic Tile arrays} to function as our tile grid. As 2D arrays are essentially just an array in which each of its elements is just another array of elements of a specified type, we've used the syntax \mintinline{pascal}{array of array of Tile} to declare this type.
\paragraph{Finally, we declare our \mintinline{pascal}{MapData} type.} This \mintinline{pascal}{record} will hold our tile grid, the players \mintinline{pascal}{Sprite} variable (A data type from the SwinGame library), the size of the map, the size of each tile, it's seed or starting value, and an indicator used by the \mintinline{pascal}{MapUtils.pas DrawMapCartography() procedure} to locate where the player is relative to the drawn tile map. Important to note is the \mintinline{pascal}{playerX} \& \mintinline{pascal}{playerY} variables as these aren't the players position in pixel coordinates (there will be a total of $275952697344$ pixels on the final map, way too large a number to even fit in a \mintinline{pascal}{LongWord} type), they are the players current pixel position translated to 2D array index equivalents - these variables will be used to calculate simple collision detection later on. Lastly, we forward declare our two terrain generation procedures.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2]{pascal}
//
// Fills a MapData's TileGrid with generated heightmap data
// using the Diamond-Square fractal generation algorithm
// This heightmap data gets used later on to generate terrain realistically
//
procedure DiamondSquare(var map: MapData; maxHeight, smoothness: Integer);
//
// Uses elevation values generated by DiamondSquare to assign appropriate
// bitmaps and randomly generate trees
//
procedure GenerateTerrain(var map: MapData);
\end{minted}
\pagebreak
\subsection{Implementing Diamond-Square}
\paragraph{Moving onto the \mintinline{pascal}{implementation} section, we can now build our terrain generation algorithms.} Starting with \mintinline{pascal}{DiamondSquare}. The basic pseudocode for the algorithm looks something like this:
\begin{algorithm}[H]
\setstretch{1.35}
\caption{The Diamond-Square algorithm}
\begin{algorithmic}
\Procedure{DiamondSquare}{$map,\ maxHeight,\ smoothness$}
\State Initialize the four corners of the map with a seed value
\State $nextStep \gets \frac{Length(tileGrid)}{2}$
\While{$nextStep > 0$}
\ForAll{$midPoints$ of each square in the grid} \Comment{Do square step}
\State $midPoint \gets$ Average four corners $+ \ (Random(maxHeight) \times smoothness)$
\EndFor
\ForAll{Diamonds in the map} \Comment{We now have diamonds, do diamond step}
\State $pointCount \gets 0$
\ForAll{$point$ in a diamond}
\If{Within boundaries of the tile grid}
\State $midPoint \gets midPoint \ + \ point$
\State $pointCount\gets pointCount+1$
\EndIf
\EndFor
\State $midPoint \gets \frac{midPoint}{pointCount} + (Random(maxHeight) \times smoothness$)
\EndFor
\State $nextStep \gets \frac{nextStep}{2}$ \Comment{Smaller diamonds and squares}
\State $smoothness \gets \frac{smoothness}{2}$ \Comment{Higher elevations have less radical difference in height}
\EndWhile
\EndProcedure
\end{algorithmic}
\end{algorithm}
Writing pseudocode can often be a good idea for breaking down a complex problem, making the underlying process seem a lot simpler. Consequentially, we now have a good abstraction to reference when implementing the algorithm, so let's start on building it into our source code.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2]{pascal}
implementation
procedure DiamondSquare(var map: MapData; maxHeight, smoothness: Integer);
var
x, y: Integer;
midpointVal: Double;
nextStep, cornerCount: Integer;
begin
x := 0;
y := 0;
midpointVal := 0;
nextStep := Round(Length(map.tiles) / 2 ); // Center of the tile grid
// Seed upper-left corner extremely low elevation to force it to
// start with water
map.tiles[x, y].elevation := -1500;
\end{minted}
Initially, we declare the x \& y variables to track our iterations through the heightmap generation process, then the \mintinline{pascal}{midpointVal Double} which we will use to calculate the current midpoint value (average plus a random value) at both the diamond and square steps. The \mintinline{pascal}{nextStep} variable is an important one and will control which tile in the grid we're analysing at any given moment and will be made smaller at each iteration until it equals 0, at which point the algorithm is finished. This is initially assigned the centre point of each axis in the tile grid, at first being multiplied by two to get the four corners of the map, and at each iteration will be used to determine the location of a given point in a diamond or a square. Finally, we 'seed' the top-left corner of the map with an elevation of $-1500$ to ensure that the map will always have some ocean as its starting point which will help achieve our goal of producing a continent-like map.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2]{pascal}
// Initialize four corners of map with the same value as above
while x < Length(map.tiles) do
begin
while y < Length(map.tiles) do
begin
map.tiles[x, y].elevation := map.tiles[0, 0].elevation;
y += 2 * nextStep;
end;
x += 2 * nextStep;
y := 0;
end;
\end{minted}
We then iterate all four corners of the map, stepping the entire length of the map at a time, and assign each corner the same elevation value as the top-left corner. Something that you may notice is that we aren't using the more obvious \mintinline{pascal}{for..do loop} to iterate the 2D tile grid. This is due to a quirk that's relatively unique to Pascal and some Pascal-derived languages in that a \mintinline{pascal}{for..do loop} can only increment the control variable by $1$ at a time. However we need to increment $2 \cdot nextStep$ (currently half the size of the map) at each iteration to get to the next corner of the map, therefore we'll be using \mintinline{pascal}{while..do loops}.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2]{pascal}
x := 0;
y := 0;
while nextStep > 0 do
begin
midpointVal := 0;
\end{minted}
Here begins the core of the generation process, essentially we want to continue to iterate the process into smaller and smaller sizes until \mintinline{pascal}{nextStep} is smaller than the size of the tile grid. Inside this loop we start with the \textbf{square step}:
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
x := nextStep;
while x < Length(map.tiles) do
begin
y := nextStep;
while y < Length(map.tiles) do
begin
//
// Sum surrounding points equidistant from the midpoint
// in a square shape
//
midpointVal := map.tiles[x - nextStep, y - nextStep].elevation
+ map.tiles[x - nextStep, y + nextStep].elevation
+ map.tiles[x + nextStep, y - nextStep].elevation
+ map.tiles[x + nextStep, y + nextStep].elevation;
// Set midpoint to the average + Random value and multiply by smoothing factor
map.tiles[x, y].elevation := Round( (midpointVal / 4) + (Random(maxHeight) * smoothness) );
y += 2 * nextStep;
end;
x += 2 * nextStep;
y := 0;
end;
\end{minted}
Here, we're scanning the tile grid for squares and their corners of the current iteration size, as in \hyperref[fig:graph]{Example 2, step 5}. \mintinline{pascal}{midpointVal} is assigned the sum of the four corners in a square surrounding the current midpoint, \mintinline[breaklines]{pascal}{map.tiles[x, y]}, then we assign the midpoints elevation value the average of the points plus a random value with a maximum possible height of our passed-in \mintinline{pascal}{maxHeight} variable \mintinline[breaklines]{pascal}{Random(maxHeight)}. Each time we complete the elevation assignment statement, also seen in a similar fashion the diamond step, we ensure we multiply the random value by the given \mintinline[breaklines]{pascal}{smoothness} parameter to allow the terrain to smooth out as the elevations become higher and the calculated map spaces become smaller to allow for less radical and unrealistic changes. \textbf{Very importantly, because we aren't using \ \mintinline{pascal}{for..do loops}, note that we're manually resetting both \mintinline{pascal}{x} \& \mintinline{pascal}{y}}, if you forget to do this before each iteration you may lose your mind. Let's move onto the diamond step.
\newgeometry{margin=0.5in}
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Diamond step. Points in a diamond shape around a given midpoint. Checks if they're within the bounds of the map
x := 0;
while x < Length(map.tiles) do
begin
y := nextStep * ( 1 - Round(x / nextStep) mod 2);
while y < Length(map.tiles) do
begin
midpointVal := 0;
cornerCount := 0;
// Sum the surrounding points equidistant from the current midpoint in a diamond shape. Ensures that each point is within the bounds of the map
if ( y - nextStep >= 0 ) then
begin
midpointVal += map.tiles[x, y - nextStep].elevation;
cornerCount += 1;
end;
if ( x + nextStep < Length(map.tiles) ) then
begin
midpointVal += map.tiles[x + nextStep, y].elevation;
cornerCount += 1;
end;
if ( y + nextStep < Length(map.tiles) ) then
begin
midpointVal += map.tiles[x, y + nextStep].elevation;
cornerCount += 1;
end;
if ( x - nextStep >= 0 ) then
begin
midpointVal += map.tiles[x - nextStep, y].elevation;
cornerCount += 1;
end;
// If at least one corner is within the map bounds, calculate average plus a random amount less than the map height.
if cornerCount > 0 then
begin
// Set midpoint to the average of corner amt + Random value and multiply by smoothing factor
map.tiles[x, y].elevation := Round( (midpointVal / cornerCount) + Random(maxHeight) * smoothness );
end;
y += 2 * nextStep;
end;
x += nextStep;
end;
\end{minted}
\restoregeometry
\paragraph{The diamond step is a little more complicated.} The reason for this is that we need to do extra checking to ensure that a given point in the diamond is within the maps boundary to avoid both calculation errors and a \mintinline{pascal}{EAccessViolation} error for accessing a non-existent memory address.
Once again we have two, nested \mintinline{pascal}{while..do loops} with their control variables manually reset and incremented at the before and at the end of each iteration. Before entering each inner loop, rather than assigning \mintinline[breaklines]{pascal}{y := nextStep} as in the square step, we assign \mintinline{pascal}{y} a seemingly confusing new value which will be equal to the next point in the diamond. Why is this the case? Well, given the formula, where $s=$ \mintinline{pascal}{nextStep}:
\begin{equation}
y=s \cdot (1 - \left[\frac{x}{s} \ mod \ 2\right]
\end{equation}
If, at the current iteration in the process, $x=0$ \& $s=3$ which is coincidentally where $x$ will be at the beginning of the diamond step and what \mintinline{pascal}{nextStep} will be assigned in the first iteration of a $5 \times 5$ grid, we would get:
\begin{equation}
\begin{split}
y&=3 \cdot (1 - \left[\frac{0}{3} \ mod \ 2\right]) \\
&=3 \cdot (1 - \left[0 \ mod \ 2\right]) \\
&=3 \cdot (1 - [0]) \\
&=3
\end{split}
\end{equation}
\mintinline{pascal}{y} is now the two elements from the right point of the diamond and will be skipped this iteration then, given
\\ \mintinline{pascal}{x += nextStep} in the next iteration, \mintinline{pascal}{x} will now be $3$, so if we plug that into the formula again, we get:
\begin{equation}
\begin{split}
y&=3 \cdot (1 - \left[\frac{3}{3} \ mod \ 2\right]) \\
&=3 \cdot (1 - \left[1 \ mod \ 2\right]) \\
&=3 \cdot (1 - [1]) \\
&=3 \cdot 0 \\
&=0
\end{split}
\end{equation}
So now \mintinline{pascal}{y} is set to the top point of the left-most diamond and so on. This simple formula allows us to iterate four points of a diamond without having to resort to using numerous \mintinline{pascal}{if} statements.
In the body of the inner loop, we then check each point surrounding the mid-point to see if it's inside the bounds of the map. If it is, we increment \mintinline{pascal}{cornerCount} once. Then, after checking all points we assign the mid-point the average of all surrounding points within the bounds of the map plus a random value limited to our \mintinline{pascal}{maxHeight} variable multiplied by the current smoothness factor. Finally, we increase the value of \mintinline{pascal}{y} in the inner loop by the length of the current diamond to get the lower point and iterate until all diamonds in the current loop are calculated.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
nextStep := Round(nextStep / 2); // Make the next space smaller
//
// Increase smoothness for every iteration, allowing
// less difference in height the more iterations that are completed
//
smoothness := Round(smoothness / 2);
end;
end;
\end{minted}
\paragraph{We're almost done.} At the end of the current diamond-square iteration, we make the size of our diamonds and squares smaller by halving \mintinline{pascal}{nextStep} alongside halving \mintinline{pascal}{smoothness} so that higher elevations have a less radical difference in height. Changing our smoothness value is what creates a realistic gradient in heights and a more visually pleasing result.
\subsection{Testing}
\paragraph{The most complex and difficult part is out of the way.}But before we do anything else, it must be tested. If we were to wait until we had all of our drawing, collision, and update procedures built, we would be well into finishing our program before we'd even made sure the core algorithm behind it works. To do this, we can go back to our main program file, \mintinline{pascal}{ProceduralGeneration.pas}, and implement the \mintinline[breaklines]{pascal}{PrintMapToConsole()} and \mintinline[breaklines]{pascal}{CreateMap()} procedures/functions we wrote in \mintinline{pascal}{Main()}.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Prints all of the elevation data in a tilemap to the console.
// Don't use for maps larger than 16 x 16 or it will be bigger than the console window
procedure PrintMapToConsole(constref map: MapData);
var
x, y: Integer;
begin
for x := 0 to High(map.tiles) do
begin
for y := 0 to High(map.tiles) do
begin
Write(map.tiles[x, y].elevation, ' ');
end;
WriteLn();
end;
end;
\end{minted}
The code for this procedure is fairly self-explanatory - we iterate the 2D array and write all \mintinline[breaklines]{pascal}{y} values without appending a newline to simulate a row, then at the end of each \mintinline[breaklines]{pascal}{x} iteration, write a newline to the console to simulate a column. Then, we move onto \mintinline[breaklines]{pascal}{CreateMap()}.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
//
// Initializes a new tile grid and then generates a new map using DiamondSquare().
// The new map can be random or based off a given seed
//
function CreateMap(size: Integer; random: Boolean; seed: Integer = 0): MapData;
var
i, j: Integer;
begin
result.tilesize := 32;
result.size := size;
result.player := CreateSprite('player', BitmapNamed('player')); // We'll use this later
// Setup seed
if random then
begin
Randomize;
end
else
begin
RandSeed := seed;
end;
// Initialize Tile Grid
SetGridLength(result.tiles, size);
// Generate Heightmap
DiamondSquare(result, 100, 20);
end;
\end{minted}
\mintinline[breaklines]{pascal}{CreateMap()} takes three parameters - a value to determine the map size, a \mintinline[breaklines]{pascal}{Boolean} variable to determine if we should generate a random map or one from a pre-determined seed value, and the actual seed value if any exist, using the \mintinline[breaklines]{pascal}{<variable>: <type> = <value>} syntax to declare a default parameter that doesn't have to necessarily be passed as an argument when calling the procedure. We first assign a tilesize, size, and player sprite for our \mintinline[breaklines]{pascal}{MapData result} variable. Then, if \mintinline[breaklines]{pascal}{random} is true we call the \mintinline[breaklines]{pascal}{Randomize procedure} which initializes Pascals internal random number generator with a new, unique seed to base all random generation off. Much like our \emph{seed} value used to base all of our Diamond-Square calculations off, the Pascal \mintinline[breaklines]{pascal}{Random()} function, a deterministic \emph{pseudo-random} number generation algorithm, itself requires a seed value, generated by the exact time on the computers system clock down to nanoseconds, to base its calculations off. If \mintinline[breaklines]{pascal}{random} is false, we then assign our seed value to the Pascal \mintinline[breaklines]{pascal}{RandSeed} variable, which sets \mintinline[breaklines]{pascal}{Random()}'s seed value manually rather than using the system clock via \mintinline[breaklines]{pascal}{Randomize}. We then call \mintinline[breaklines]{pascal}{SetGridLength()} (listed below) to initialize our 2D array and pass our map into \mintinline[breaklines]{pascal}{DiamondSquare()} to get assigned a heightmap.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Initializes the 2D map grid with the given size and sets the default
// values for each tile
procedure SetGridLength(var tiles: TileGrid; size: Integer);
var
column: Integer;
x, y: Integer;
begin
// Set all of the column sizes to the right length
for column := 0 to size do
begin
SetLength(tiles, column, size);
end;
// Iterate map and setup default values for all tiles
for x := 0 to High(tiles) do
begin
for y := 0 to High(tiles) do
begin
// Setup default values
tiles[x, y].elevation := 0;
tiles[x, y].collidable := false;
tiles[x, y].feature := NoFeature;
tiles[x, y].hasBmp := false;
end;
end;
end;
\end{minted}
Now all of our core procedures and functions are defined, we can test out our \mintinline[breaklines]{pascal}{DiamondSquare() procedure} by calling \mintinline[breaklines]{pascal}{CreateMap(9, 100, 20)} from \mintinline[breaklines]{pascal}{Main()}; we want to pass in a very small size value to \mintinline[breaklines]{pascal}{CreateMap()} otherwise we won't be able to see all of the printed elevation numbers in the console. Note that we're passing in a size of $9$ rather than $8$; this is because, as previously discussed, \mintinline[breaklines]{pascal}{DiamondSquare()} only works for maps of size $2^{n}+1$ and 9 is $2^{3}+1$. Run \mintinline[breaklines]{bash}{./build.sh && ./run.sh} in the console from the root project folder and we can see the result:
\begin{figure}[H]
\centering
\renewcommand{\figurename}{Example}
\includegraphics[width=0.9\linewidth,trim=4 4 4 4,clip]{printtoconsole.png}
\caption{The heightmap printed to the console}
\end{figure}
Although it may look fairly unimpressive now, we can at least verify that our algorithm works and produces pseudo-random values distributed across nice, smooth gradients. Let's move onto our \mintinline[breaklines]{pascal}{GenerateTerrain()} procedure to actually begin implementing a graphical representation of our map.
\subsection{Generating Terrain and Features}
\paragraph{In order to graphically represent terrain, we need to assign Bitmaps and \mintinline[breaklines]{pascal}{FeatureTypes}.} This will be defined in our \mintinline[breaklines]{pascal}{GenerateTerrain() procedure}. This step in terrain generation is less complex than \mintinline[breaklines]{pascal}{DiamondSquare()} \emph{at the present}; it's possible, and encouraged, to extend this this procedure after finishing the program and, for many procedurally generated games, \mintinline[breaklines]{pascal}{DiamondSquare()} is just the beginning with the most complex algorithms belonging to the terrain generation procedures and functions. However, our focus is on generating a base map to get started with procedural generation. If you are interested, a visit to the Procedural Content Generation Wiki \parencite{pcg} is highly recommend and browsing the many articles listed there will give a good jumping off point for many varied procedural processes.
Before we begin building the \mintinline[breaklines]{pascal}{GenerateTerrain() procedure} lets outline exactly how we want it to work by using pseudocode to abstract the algorithmic problem.
\begin{algorithm}[H]
\setstretch{1.35}
\caption{Procedure to Generate Terrain}
\begin{algorithmic}
\Procedure{GenerateTerrain}{$map$}
\For{$x \gets 0$ \ To \ $High(tiles)$} \Comment{Generate tile Bitmaps}
\For{$y \gets 0$ \ To \ $High(tiles)$}
\State Assign a different Bitmap to $tiles[x, y]$ for different $elevation$ ranges
\If{$tiles[x,y]$ $elevation$ value is $< 0$}
\State $tiles[x, y] \gets$ Dark Water Bitmap
\Else
\State $tiles[x, y] \gets$ Mountain Bitmap \Comment{$elevation > 1499$}
\EndIf
\If{$Random() > 0.9$ \textbf{and} $tiles[x,y]$ is not a Water tile}
\State $tiles[x, y]'s \ FeatureType \gets$ A tree appropriate for the current tile type
\EndIf
\EndFor
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
Essentially all we need to do is iterate over our previously generated 2D heightmap and assign each tile a Bitmap based on its elevation value. At certain elevations we may choose to apply different processes later on for more complex generation, but all we're doing at the moment is assigning the right tile Bitmap to the right elevation value. The second part of the process is generating appropriate tree Bitmaps based on a very random process; it's highly encouraged to extend this and explore \label{forestalgo}forest generation algorithms that work by creating seeds, sunlight, and maturation processes (see \cite{forests}) but for the moment we're going to apply a process to achieve a semi-procedural result.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Generates the terrain type for each tile based off its elevation value
procedure GenerateTerrain(var map: MapData);
var
x, y: Integer;
begin
// Iterate all tiles and change their bitmap and data depending on their
// pre-generated altitude
for x := 0 to High(map.tiles) do
begin
for y := 0 to High(map.tiles) do
begin
// Setup the tiles
case map.tiles[x, y].elevation of
0..199: SetTile(map.tiles[x, y], Water, 'water', true);
200..299: SetTile(map.tiles[x, y], Sand, 'sand', false);
300..399: SetTile(map.tiles[x, y], Grass, 'grass', false);
400..599: SetTile(map.tiles[x, y], MediumGrass, 'dark grass', false);
600..799: SetTile(map.tiles[x, y], HighGrass, 'darkest grass', false);
800..999: if Random(10) > 6 then
// Generate patchy snow at mid-to-high elevations
SetTile(map.tiles[x, y], SnowyGrass, 'snowy grass', false)
else
SetTile(map.tiles[x, y], HighGrass, 'darkest grass', false);
1000..1499: SetTile(map.tiles[x, y], SnowyGrass, 'snowy grass', false);
\end{minted}
First, we delare our \mintinline[breaklines]{pascal}{GenerateTerrain()} procedure and begin iterating the 2D tile grid. We then define several elevation ranges inside a \mintinline[breaklines]{pascal}{case} statement for which we assign the current tiles Bitmap using \mintinline[breaklines]{pascal}{SetTile()} (which we'll implement soon) - lower elevations get water, while higher elevations get snowy grass. At elevation ranges of $800-999$ we randomly assign either snow or grass to simulate patchy snow as the terrain transitions to higher altitudes.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
else
// Only generate dark water if elevation is low enough
// otherwise, every other value, which will be higher than 1499, should
// become mountains
if map.tiles[x, y].elevation < 0 then
SetTile(map.tiles[x, y], Water, 'dark water', true)
else
SetTile(map.tiles[x, y], Mountain, 'mountain', true)
end;
// Generates trees randomly. Feel free to extend this by making your own
// procedural tree generation algorithm to make beautiful forests!
if ( Random() > 0.9 ) and ( map.tiles[x, y].flag <> Water ) then
begin
SetFeature(map.tiles[x, y], Tree, true);
end;
end;
end;
end;
\end{minted}
If the current tiles elevation value is outside the specified ranges we fall to the \mintinline[breaklines]{pascal}{else} block and assign elevations lower than $0$ deep water tiles and anything not less than $0$ will be higher than $1499$ so we assign it a mountain tile. Finally, we randomly set the tiles' \mintinline[breaklines]{pascal}{featureBmp} to either a tree or nothing depending on both a random value and as long as the current tile isn't a water tile as trees don't generally grow in the ocean.
\paragraph{You will have noticed both \mintinline[breaklines]{pascal}{SetTile()} \& \mintinline[breaklines]{pascal}{SetFeature()} procedures.} These handle assigning default values to tiles and assigning the right tree for the right \mintinline[breaklines]{pascal}{TileType} respectively. Let's quickly code them up:
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Sets a tiles values to specified. Anything with collidable set to true
// won't be able to be walked over by the player
procedure SetTile(var newTile: Tile; flag: TileType; bmp: String; collidable: Boolean);
begin
newTile.flag := flag;
newTile.bmp := BitmapNamed(bmp);
newTile.collidable := collidable;
newTile.hasBmp := true;
end;
\end{minted}
\mintinline[breaklines]{pascal}{SetTile()} assigns all of the specified values alongside any required default values for a given tile which saves us the hassle of rewriting this code each time we want to setup a tile.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
//
// Sets up a new feature on a given tile. At the moment we only have trees
// as valid features but it's really easy for you to add more features!
// Why not try adding rocks, logs or even treasure?
//
procedure SetFeature(var tile: Tile; feature: FeatureType; collidable: Boolean);
begin
tile.feature := feature;
tile.collidable := collidable;
if feature = Tree then
begin
case tile.flag of
Water: tile.featureBmp := BitmapNamed('hidden');
Sand: tile.featureBmp := BitmapNamed('palm tree');
Dirt: tile.featureBmp := BitmapNamed('tree');
Grass: tile.featureBmp := BitmapNamed('tree');
MediumGrass: tile.featureBmp := BitmapNamed('pine tree');
HighGrass: tile.featureBmp := BitmapNamed('pine tree');
SnowyGrass: tile.featureBmp := BitmapNamed('snowy tree');
Mountain: tile.featureBmp := BitmapNamed('hidden');
end;
end;
end;
\end{minted}
\mintinline[breaklines]{pascal}{SetFeature()} is fairly self explanatory - it uses a \mintinline[breaklines]{pascal}{case} statement on the tile parameter's \mintinline[breaklines]{pascal}{TileType} to determine which tree bitmap to load up. Notice, a feature can also be collidable (you shouldn't be able to walk through trees) and, using the syntax \mintinline[breaklines]{pascal}{if feature = <FeatureType> then}, we can specify different logic for different types of features, such as \mintinline[breaklines]{pascal}{if feature = Rock then //rock logic}, once again future-proofing our program for extensibility.
Return to \mintinline[breaklines]{pascal}{CreateMap()} and add in a call to \mintinline[breaklines]{pascal}{GenerateTerrain(result)}. However, if you run the program now, it won't work. In order to draw the map to the screen, we need to both load our resources up and implement a \mintinline[breaklines]{pascal}{DrawMap()} procedure.
\section{Drawing, Input, and Collision}
\subsection{Drawing the map}
Before we can draw anything to the screen we need to open a SwinGame graphics window and define a main game loop, so let's go to our \mintinline[breaklines]{pascal}{Main()} procedure and edit it to look like this:
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
procedure Main();
var
map: MapData;
begin
LoadResources();
// Open a SwinGame graphics window for drawing to
OpenGraphicsWindow('Procedural Map Generation', 800, 600);
map := CreateMap(513, true);
repeat
ProcessEvents();
ClearScreen(ColorBlack);
UpdateCamera(map);
DrawMap(map);
DrawSprite(map.player);
RefreshScreen(60);
until WindowCloseRequested();
end;
\end{minted}
We define our main game loop to \mintinline[breaklines]{pascal}{repeat..until WindowCloseRequested()}, which happens when the user clicks to exit the window. Both \mintinline[breaklines]{pascal}{LoadResources()} \& \mintinline[breaklines]{pascal}{UpdateCamera()} are from the \mintinline[breaklines]{pascal}{MapUtils.pas unit} file and do exactly what the say they do, loading resources and making sure the camera is always centred on our player. We call \mintinline[breaklines]{pascal}{DrawMap()} to draw our map to the screen which is the procedure we'll be implementing soon, and the SwinGame API's \mintinline[breaklines]{pascal}{DrawSprite()} procedure to draw the player to the screen. More SwinGame procedures, \mintinline[breaklines]{pascal}{ClearScreen()} \& \mintinline[breaklines]{pascal}{RefreshScreen()} are called every iteration alongside \mintinline[breaklines]{pascal}{ProcessEvents()} for input handling.
\paragraph{Before we implement \mintinline[breaklines]{pascal}{DrawMap()}, we need to create a function to check if a particular element is inside the bounds of the tile grid.} \
\begin{mdframed}[backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2,breaklines]{pascal}
//
// Determines whether a given point is inside the tilemap or not
//
function IsInMap(constref map: MapData; x, y: Integer): Boolean;
begin
result := false;
// Check map bounds. As every map is (2^n)+1 in size, the bounds
// stop at High()-1 which will be a number equal to 2^n.
if (x > 0) and (x < High(map.tiles) - 1) and (y > 0) and (y < High(map.tiles) - 1) then
begin
result := true;
end;
end;
\end{minted}
\end{mdframed}
\paragraph{Once we've implemented \mintinline[breaklines]{pascal}{IsInMap()} we can move onto \mintinline[breaklines]{pascal}{DrawMap()}:}
\
\vspace{0.5cm}
\begin{mdframed}[backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2,breaklines]{pascal}
//
// Draws the current map data to the screen but only within the bounds of
// the current Camera view.
//
procedure DrawMap(constref map: MapData);
var
x, y: Integer;
newView: TileView;
begin
// Get a new tile view to see what should be drawn
newView := CreateTileView(map);
// Iterate only tiles in the tile map that correspond to a
// visible tile
for x := newView.x to newView.right do
begin
for y := newView.y to newView.bottom do
begin
if IsInMap(map, x, y) and map.tiles[x, y].hasBmp then
begin
// Draw the tile
DrawBitmap(map.tiles[x, y].bmp, x * map.tilesize, y * map.tilesize);
// Draw a tree or no feature
DrawBitmap(map.tiles[x, y].featureBmp, x * map.tilesize, y * map.tilesize);
end;
end;
end;
end;
\end{minted}
\end{mdframed}
\
In our \mintinline[breaklines]{pascal}{DrawMap()} procedure we create a new \mintinline[breaklines]{pascal}{TileView} record, this is from the \mintinline[breaklines]{bash}{MapUtils.pas} unit file and is used to translate the current camera view in pixels ($800 \times 600$ in the case of our game) into tile grid coordiantes ($25 \times 19$). We then make use of the \mintinline[breaklines]{pascal}{x, right, y, bottom record} members it returns to draw whatever tiles are currently within the cameras view to the screen through a nested \mintinline[breaklines]{pascal}{for..do} loop, also checking that the tile is inside the map bounds and has an assigned bitmap before drawing it. The reason we use a \mintinline[breaklines]{pascal}{TileView} record to only draw what's visible rather than the entire map is that, if we were drawing $512 \cdot 512 = 262,144$ tiles to the screen at each game loop, the program would run extremely slow.
\subsection{Handling Input \& Collision}
\paragraph{Now that we've implemented our drawing procedure, we can move onto input and collision detection:}\mbox{}
\vspace{0.2cm}
\
\begin{mdframed}[backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2,breaklines]{pascal}
procedure HandleInput(var map: MapData);
var
newX, newY: Integer;
begin
// Used to determine if they should be allowed to move in a given direction
newX := map.playerX;
newY := map.playerY;
// Change values depending on direction
if KeyDown(UpKey) then
begin
newY -= 1;
end;
if KeyDown(RightKey) then
begin
newX += 1;
end;
if KeyDown(DownKey) then
begin
newY += 1;
end;
if KeyDown(LeftKey) then
begin
newX -= 1;
end;
\end{minted}
\end{mdframed}
\
Here, we pass in our \mintinline[breaklines]{pascal}{MapData} variable and save the players current tile-based (as against pixel-based) $x$ and $y$ values into the \mintinline[breaklines]{pascal}{newX} \& \mintinline[breaklines]{pascal}{newY} variables as we'll be altering this data later. Next we use the SwinGame procedure \mintinline[breaklines]{pascal}{KeyDown()} to move the players $x$ \& $y$ values in the correct direction. Here, we are essentially \emph{predicting} what the players' coordinates will be on the next iteration of the game loop before we \emph{actually} move the player, which is why we aren't assigning these new coordinates to the player directly, rather saving the predicted coordinates in order to do some collision detection:
\begin{mdframed}[backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2,breaklines]{pascal}
// If either newX or newY are outside the map bounds or are a collidable tile, reset
// the players position and don't move them
if (newX <= 0) or (newX >= High(map.tiles) - 1) or (map.tiles[newX, newY].collidable) then
begin
newX := map.playerX;
end;
if (newY <= 0) or (newY >= High(map.tiles) - 1) or (map.tiles[newX, newY].collidable) then
begin
newY := map.playerY;
end;
// Assign the new values to the player
map.playerY := newY;
map.playerX := newX;
// Move the player according to world coordinates rather than tile
// coordinates by multiplying their tile coordinates by the tilesize
SpriteSetY(map.player, map.playerY * map.tilesize);
SpriteSetX(map.player, map.playerX * map.tilesize);
end;
\end{minted}
\end{mdframed}
\
In the above \mintinline[breaklines]{pascal}{if..then} statements we check to see if the players \emph{predicted} $x$ or $y$ values are outside the maps boundary or are on top of a collidable tile. If either of these conditions are true, then we reset either one or both axis' by assigning \mintinline[breaklines]{pascal}{newX or newY} the players original coordinate values. Finally, we assign the new tile-based coordinates, whether they've changed or not, to the player directly and call the SwinGame \mintinline[breaklines]{pascal}{SpriteSetX()} \& \mintinline[breaklines]{pascal}{SpriteSetY()} procedures to actually change the players in-game pixel-based coordinates by multiplying the tile values by the maps \mintinline[breaklines]{pascal}{tilesize} value.
\clearpage
\subsection{Finishing Up}
\paragraph{We're almost done.} However, first we need to append our \mintinline[breaklines]{pascal}{Main()} \& \mintinline[breaklines]{pascal}{CreateMap()} procedures with some new code to allow our player to spawn in a correct location and to handle input.
\
Edit \mintinline[breaklines]{pascal}{CreateMap()} with the following code:
\
\vspace{0.5cm}
\begin{adjustwidth}{-1cm}{-1cm}
\begin{mdframed}[backgroundcolor=darkgray]
\begin{minted}[style=native,tabsize=2,breaklines]{pascal}
// Initializes a new tile grid and then generates a new map using DiamondSquare().
// The new map can be random or based off a given seed
function CreateMap(size: Integer; random: Boolean; seed: Integer = 0): MapData;
var
i, j: Integer;
spawnFound: Boolean;
begin
result.tilesize := 32;
result.size := size;
result.player := CreateSprite('player', BitmapNamed('player'));
// Setup seed
if random then
begin
Randomize;
end
else
begin
RandSeed := seed;
end;
// Initialize Tile Grid
SetGridLength(result.tiles, size);
// Generate Heightmap
DiamondSquare(result, 100, 20);
GenerateTerrain(result);
// Search for the first sand tile without a feature on it, thus spawning the player on a beach
spawnFound := false;
for i := 0 to High(result.tiles) do
begin
if spawnFound then
break;
for j := 0 to High(result.tiles) do
begin
if spawnFound then
break;
// Search for a sand tile to spawn the player on
if (i > 1) and (result.tiles[i, j].flag = Sand) and (result.tiles[i, j].feature = NoFeature) then
begin
SpriteSetX(result.player, i * 32);
SpriteSetY(result.player, j * 32);
result.playerX := i;
result.playerY := j;
spawnFound := true;
end;
end;
end;
// Recursively call self with new random value if spawn not found
if not spawnFound then
begin
CreateMap(size, true, seed);
end;
end;
\end{minted}
\end{mdframed}
\end{adjustwidth}
\paragraph{The primary addition here, is to search for the players spawn point.} We create a nested \mintinline[breaklines]{pascal}{for..do} loop to iterate the tile grid and search for the first sand tile, then assign the players position accordingly; a very simple way to find a spawn point but effective enough for our program. The most interesting section of code in this procedure is also the shortest:
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Recursively call self with new random value if spawn not found
if not spawnFound then
begin
CreateMap(size, true, seed);
end;
\end{minted}
If the specified seed or random seed value produces a map with only water tiles then we use \textbf{recursion} to call \mintinline[breaklines]{pascal}{CreateMap()} itself again but with a new random seed. Recursion is an interesting concept in programming and occurs when part of a procedure or function calls itself and runs the same block of code again, but often with new parameters; the return value of which follows the chain of recursion back to the start, itself being recursive by definition \parencite{recursion}. Recursive procedures for the most part are interchangeable with loops, and are often more easily followed that way, but some procedures such as \mintinline[breaklines]{pascal}{CreateMap()}, lend themselves so naturally to the concept of recursion that it only makes real sense to define them as such. This means that the \mintinline[breaklines]{pascal}{CreateMap()} procedure will keep calling itself until it produces a valid map with a valid spawn point.
\paragraph{Finally, edit \mintinline[breaklines]{pascal}{Main()} so that it calls the new procedures.} We'll also add a little bit of code to delay the players movement so that \mintinline[breaklines]{pascal}{HandleInput()} is only called once every 3 frames rather than every frame, otherwise the movement speed of the player would be too fast.
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
procedure Main();
const
MOVE_INTERVAL = 4;
var
map: MapData;
moveDelay: Integer;
begin
LoadResources();
OpenGraphicsWindow('Procedural Map Generation', 800, 600);
map := CreateMap(513, true);
moveDelay := 0;
repeat
ProcessEvents();
ClearScreen(ColorBlack);
// Only moves the player at specific intervals so as to
// limit from running super fast
moveDelay += 1;
if moveDelay > MOVE_INTERVAL then
begin
HandleInput(map);
moveDelay := 0;
end;
UpdateCamera(map);
DrawMap(map);
DrawSprite(map.player);
\end{minted}
Furthermore, we'll also check if the player has typed escape and then draw a small map overview to the screen until escape is typed again. This way the player is able to find their position on the map at any given moment:
\begin{minted}[bgcolor=darkgray,style=native,tabsize=2,breaklines]{pascal}
// Create map drawing loop to show player where they are
if KeyTyped(EscapeKey) then
begin
ProcessEvents();
repeat
ProcessEvents();
DrawMapCartography(map); // Draw the map to screen
until KeyTyped(EscapeKey) or WindowCloseRequested();
end;
RefreshScreen(60);
until WindowCloseRequested();
end;
\end{minted}
Note, that we've also called \mintinline[breaklines]{pascal}{CreateMap()} with a size value of $2^{9}+1 = 513$ in order to generate our map without hitting any errors. If you want to generate maps of different sizes, just remember they must be of size
\\
$2^{n}+1$.
\paragraph{Finally, build and run the game and you should have a fully procedurally generated world able to be navigated by the player.}\mbox{}
\begin{figure}[H]
\centering
\includegraphics[width=0.9\linewidth,trim=4 4 4 4,clip]{finalresult.png}
\renewcommand{\figurename}{Example}
\caption{The final in-game result}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.9\linewidth,trim=4 4 4 4,clip]{finalmap.png}
\renewcommand{\figurename}{Example}
\caption{The accompanying map overview}
\end{figure}
\clearpage
\section{Extending \& Investigating Deeper}
Our goal at the beginning of this article was to implement a realistic heightmap generation algorithm and use it to procedurally create terrain representations and features on a 2D tile-based map. Ultimately, this goal has been reached while also touching on other complex problems such as collision detection and efficient drawing procedures alongside making use of an external API in the form of SwinGame.
\par
However, the resulting program is just a starting point and has been built in such a way that it can be extended as needed. This is highly encouraged and there a plethora of algorithms and processes to be discovered and implemented in your program:
\begin{itemize}
\item
Carving out rivers using a combination of Hart, Nilsson, and Raphaels A* Pathfinding algorithm \parencite{astar} to find the shortest path to the ocean or a lake using elevation as the path cost, in combination with Diamond-Square to distort the river paths realistically.
\item
Producing dense forests via a combination of procedures previously mentioned \hyperref[forestalgo]{here} and various cellular automata processes
\item
Generating flora and fauna such as flowers and rabbits by simulating seeds, growth, breeding, and lifespan factors. The possibilities here, in particular, are truly enormous and are where many of the most interesting problems lie.
\item
Finally, as in the previously mentioned Dwarf Fortress, it's possible to apply narrative generation algorithms to carve out of entire centuries of history and culture, literally creating entire databases of generated lore for a game.
\end{itemize}
As demonstrated in this article, it's completely within the grasp of the reader to create realistic terrain that's unique and interesting without having to create all of the content manually. The possibilities are endless and only limited by your imagination.
\printbibliography
\appendix
\setcounter{secnumdepth}{0}
\section{Source Code \& Repository}
The complete finished project directory and all source code files referenced in this article can be downloaded from the repository listed on \href{https://github.com/jacobmilligan/intro_hd_report}{github.com} by cloning or forking the project via git, or simple navigating to the 'clone or download' button and downloading as a .zip file. The repository includes all resource files alongside \\ \mintinline[breaklines]{pascal}{MapUtils.pas}. If you have find any issues or bugs in the code provided, feel free to open a new issue on the repository page or fork and contribute any fixes or additions.
\end{document}
|
import Maps
using Test
@testset "earth globe" begin
scene = (Maps.globe())
end
@testset "mars globe" begin
display(Maps.globe(Maps.mars_img()))
end
@testset "usa small" begin
display(Maps.usa(0.001))
end
@testset "usa default" begin
display(Maps.usa())
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.