text
stringlengths 0
3.34M
|
---|
/-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.topology.category.Top.adjunctions
import Mathlib.category_theory.epi_mono
import Mathlib.PostPort
universes u
namespace Mathlib
namespace Top
theorem epi_iff_surjective {X : Top} {Y : Top} (f : X ⟶ Y) : category_theory.epi f ↔ function.surjective ⇑f := sorry
theorem mono_iff_injective {X : Top} {Y : Top} (f : X ⟶ Y) : category_theory.mono f ↔ function.injective ⇑f := sorry
|
Exact figures are not available on the budget and box office earnings of Sholay , but film trade websites provide estimates of its success . According to Box Office India , Sholay earned about ₹ 150 million nett gross ( valued at about US $ 16 @,@ 778 @,@ 000 in 1975 ) in India during its first run , which was many times its ₹ 30 million ( valued at about US $ 3 @,@ 355 @,@ 000 in 1975 ) budget . Those earnings were a record that remained unbroken for nineteen years , which is also the longest amount of time that a film has held the record . Its original gross was increased further with re @-@ releases during the late 1970s , 1980s , 1990s , and early 2000s . It is often cited that after adjusting the figures for inflation , Sholay is one of the highest grossing films in the history of Indian cinema , although such figures are not known with certainty . In 2012 , Box Office India gave ₹ 1 @.@ 63 billion ( US $ 24 million ) as Sholay 's adjusted net gross , whereas Times of India , in a 2009 report of business of Indian films , reported over ₹ 3 billion ( US $ 45 million ) as the adjusted gross .
|
------------------------------------------------------------------------
-- Representation-independent results for non-dependent lenses
------------------------------------------------------------------------
import Equality.Path as P
module Lens.Non-dependent
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection equality-with-J as Bij using (module _↔_)
open import Equality.Decision-procedures equality-with-J
open import Equivalence equality-with-J using (_≃_)
open import Erased.Cubical eq
open import Function-universe equality-with-J as F hiding (_∘_)
open import H-level equality-with-J as H-level
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional eq as T using (∥_∥)
open import Surjection equality-with-J using (_↠_)
private
variable
a b c c₁ c₂ c₃ l : Level
A B : Type a
Lens₁ Lens₂ Lens₃ : Type a → Type b → Type c
------------------------------------------------------------------------
-- Some existence results
-- There is, in general, no lens for the first projection from a
-- Σ-type, assuming that lenses with contractible domains have
-- contractible codomains.
no-first-projection-lens :
(Lens : Type → Type → Type a) →
@0 (∀ {A B} → Lens A B → Contractible A → Contractible B) →
¬ Lens (∃ λ (b : Bool) → b ≡ true) Bool
no-first-projection-lens _ contractible-to-contractible l =
_↔_.to Erased-⊥↔⊥
[ $⟨ singleton-contractible _ ⟩
Contractible (Singleton true) ↝⟨ contractible-to-contractible l ⟩
Contractible Bool ↝⟨ mono₁ 0 ⟩
Is-proposition Bool ↝⟨ ¬-Bool-propositional ⟩□
⊥ □
]
-- A variant of the previous result: If A is merely inhabited, and one
-- can "project" out a boolean from a value of type A, but this
-- boolean is necessarily true, then there is no lens corresponding to
-- this projection (if the get-set law holds).
no-singleton-projection-lens :
{Lens : Type l}
(get : Lens → A → Bool)
(set : Lens → A → Bool → A)
(get-set : ∀ l a b → get l (set l a b) ≡ b) →
∥ A ∥ →
(bool : A → Bool) →
(∀ x → bool x ≡ true) →
¬ ∃ λ (l : Lens) →
∀ x → get l x ≡ bool x
no-singleton-projection-lens
get set get-set x bool is-true (l , get≡bool) =
_↔_.to Erased-⊥↔⊥
[ (flip (T.rec ⊥-propositional) x λ x →
Bool.true≢false
(true ≡⟨ sym $ is-true _ ⟩
bool (set l x false) ≡⟨ sym $ get≡bool _ ⟩
get l (set l x false) ≡⟨ get-set _ _ _ ⟩∎
false ∎))
]
------------------------------------------------------------------------
-- Statements of preservation results, and some related lemmas
-- Lens-like things with getters and setters.
record Has-getter-and-setter
(Lens : Type a → Type b → Type c) :
Type (lsuc (a ⊔ b ⊔ c)) where
field
-- Getter.
get : {A : Type a} {B : Type b} → Lens A B → A → B
-- Typeter.
set : {A : Type a} {B : Type b} → Lens A B → A → B → A
-- A statement of what it means for two lenses to have the same getter
-- and setter.
Same-getter-and-setter :
{Lens₁ : Type a → Type b → Type c₁}
{Lens₂ : Type a → Type b → Type c₂}
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
{A : Type a} {B : Type b} →
Lens₁ A B → Lens₂ A B → Type (a ⊔ b)
Same-getter-and-setter ⦃ L₁ = L₁ ⦄ ⦃ L₂ = L₂ ⦄ l₁ l₂ =
get L₁ l₁ ≡ get L₂ l₂ ×
set L₁ l₁ ≡ set L₂ l₂
where
open Has-getter-and-setter
-- A statement of what it means for a function to preserve getters and
-- setters for all inputs.
Preserves-getters-and-setters-→ :
{Lens₁ : Type a → Type b → Type c₁}
{Lens₂ : Type a → Type b → Type c₂}
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
(A : Type a) (B : Type b) →
(Lens₁ A B → Lens₂ A B) →
Type (a ⊔ b ⊔ c₁)
Preserves-getters-and-setters-→ {Lens₁ = Lens₁} A B f =
(l : Lens₁ A B) → Same-getter-and-setter (f l) l
-- A statement of what it means for a logical equivalence to preserve
-- getters and setters.
Preserves-getters-and-setters-⇔ :
{Lens₁ : Type a → Type b → Type c₁}
{Lens₂ : Type a → Type b → Type c₂}
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
(A : Type a) (B : Type b) →
(Lens₁ A B ⇔ Lens₂ A B) →
Type (a ⊔ b ⊔ c₁ ⊔ c₂)
Preserves-getters-and-setters-⇔ A B eq =
Preserves-getters-and-setters-→ A B (_⇔_.to eq) ×
Preserves-getters-and-setters-→ A B (_⇔_.from eq)
-- Composition preserves Preserves-getters-and-setters-→.
Preserves-getters-and-setters-→-∘ :
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
⦃ L₃ : Has-getter-and-setter Lens₃ ⦄
{f : Lens₂ A B → Lens₃ A B}
{g : Lens₁ A B → Lens₂ A B} →
Preserves-getters-and-setters-→ A B f →
Preserves-getters-and-setters-→ A B g →
Preserves-getters-and-setters-→ A B (f ∘ g)
Preserves-getters-and-setters-→-∘ p-f p-g _ =
trans (proj₁ (p-f _)) (proj₁ (p-g _))
, trans (proj₂ (p-f _)) (proj₂ (p-g _))
-- Composition preserves Preserves-getters-and-setters-⇔.
Preserves-getters-and-setters-⇔-∘ :
{Lens₁ : Type a → Type b → Type c₁}
{Lens₂ : Type a → Type b → Type c₂}
{Lens₃ : Type a → Type b → Type c₃}
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
⦃ L₃ : Has-getter-and-setter Lens₃ ⦄
{f : Lens₂ A B ⇔ Lens₃ A B}
{g : Lens₁ A B ⇔ Lens₂ A B} →
Preserves-getters-and-setters-⇔ A B f →
Preserves-getters-and-setters-⇔ A B g →
Preserves-getters-and-setters-⇔ A B (f F.∘ g)
Preserves-getters-and-setters-⇔-∘ p-f p-g =
Preserves-getters-and-setters-→-∘ (proj₁ p-f) (proj₁ p-g)
, Preserves-getters-and-setters-→-∘ (proj₂ p-g) (proj₂ p-f)
-- The function inverse preserves Preserves-getters-and-setters-⇔.
Preserves-getters-and-setters-⇔-inverse :
{Lens₁ : Type a → Type b → Type c₁}
{Lens₂ : Type a → Type b → Type c₂}
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
{f : Lens₁ A B ⇔ Lens₂ A B} →
Preserves-getters-and-setters-⇔ A B f →
Preserves-getters-and-setters-⇔ A B (inverse f)
Preserves-getters-and-setters-⇔-inverse = swap
-- If the forward direction of a split surjection preserves getters
-- and setters, then both directions do.
Preserves-getters-and-setters-→-↠-⇔ :
{Lens₁ : Type a → Type b → Type c₁}
{Lens₂ : Type a → Type b → Type c₂}
⦃ L₁ : Has-getter-and-setter Lens₁ ⦄
⦃ L₂ : Has-getter-and-setter Lens₂ ⦄
(f : Lens₁ A B ↠ Lens₂ A B) →
Preserves-getters-and-setters-→ A B (_↠_.to f) →
Preserves-getters-and-setters-⇔ A B (_↠_.logical-equivalence f)
Preserves-getters-and-setters-→-↠-⇔ ⦃ L₁ = L₁ ⦄ ⦃ L₂ = L₂ ⦄ f p =
p
, λ l →
(get L₁ (_↠_.from f l) ≡⟨ sym $ proj₁ $ p (_↠_.from f l) ⟩
get L₂ (_↠_.to f (_↠_.from f l)) ≡⟨ cong (get L₂) $ _↠_.right-inverse-of f _ ⟩∎
get L₂ l ∎)
, (set L₁ (_↠_.from f l) ≡⟨ sym $ proj₂ $ p (_↠_.from f l) ⟩
set L₂ (_↠_.to f (_↠_.from f l)) ≡⟨ cong (set L₂) $ _↠_.right-inverse-of f _ ⟩∎
set L₂ l ∎)
where
open Has-getter-and-setter
|
import pygame as pg
from pygame import sprite
from itertools import cycle
from pygame.locals import *
import imutils
import math, random, sys
import cv2 as cv
import numpy as np
from settings import *
from ImageProcessing import *
from glob import glob
def delta(t, x0, x): #experimento para ver como funciona el posc de las sombras
if x == x0:
return t
else:
return t*(math.sin(x)+math.cos(x))
class circle(pg.sprite.Sprite): #no es realmente necesario
def __init__(self, xy, radius, id, surface):
super().__init__()
self.xy = xy
self.radius = radius
self.id = id
self.surface = surface
self.color = (random.randint(128, 255), random.randint(128, 255),
random.randint(128, 255), 255) if id != 5 else (255,255,0)
def hasOverlapped(self, xy, radius):
minDistance = 0.0 + radius + self.radius
distance = math.hypot(xy[0] - self.xy[0], xy[1] - self.xy[1])
if distance >= minDistance: return False
radians = math.atan2(xy[1] - self.xy[1], xy[0] - self.xy[0])
overlap = 1 + (minDistance - distance)
return (math.cos(radians) * overlap, math.sin(radians) * overlap, overlap)
def setXY(self, xy):
self.xy = xy
def draw(self):
pg.draw.circle(self.surface, self.color, (int(self.xy[0]), int(self.xy[1])), self.radius, 0)
class fuenteLuz(pg.sprite.Sprite): #clase base para las fuentes de luz
def __init__(self, imgPath, lightRadius, lightable):
super().__init__() #sí, son sprites
self.center = (0,0) #inútil
self.x = 300
self.y = 500
self.lightable = lightable
self.lightRadius = lightRadius
self.animations = cycle(self.get_animations(imgPath)) #obtención de imagenes
self.animation_counter = 0
self.__image = next(self.animations)
array = pg.surfarray.array3d(self.__image)
self.circ = circle(self.__image.get_rect().center, lightRadius, 5, self.__image)
self.rect = pg.rect.Rect(self.x, self.y, self.x+lightRadius, self.y+ lightRadius) #se centra la figura
self.radius = self.circ.radius
def get_animations(self, imgPath): #se consiguen animaciones y se agrandan para poder hacer un cubo de detección de luz
self.preAnimation = [pg.image.load(img) for img in glob("animations/{}**".format(imgPath))]
for a in self.preAnimation:
a.convert()
self.postAnimation = [pg.surfarray.make_surface(
cv.copyMakeBorder(pg.surfarray.array3d(surface),
round(self.lightRadius-sizes[1]/2),
round(self.lightRadius-sizes[1]/2),
round(self.lightRadius-sizes[0]/2),
round(self.lightRadius-sizes[0]/2),
cv.BORDER_ISOLATED)
)
for sizes, surface in zip([pg.surfarray.array3d(surf).shape for surf in self.preAnimation],
self.preAnimation)]
for a in self.postAnimation:
a.set_colorkey((0,0,0))
return self.postAnimation
@property
def image(self): #bastante estandar
if self.animation_counter > 4:
self.animation_counter = 0
self.__image = next(self.animations)
return self.__image
def update(self, x, y): #método que ocupa el grupo
self.set_position(x,y)
self.check_area()
self.animation_counter += 1
def set_position(self, CAMERA_X, CAMERA_Y): #mover la fuente de luz
self.rect.x, self.rect.y = self.x-CAMERA_X, self.y-CAMERA_Y
def check_area(self): #función que por ahora contiene la creación de sombras
obj = pg.sprite.spritecollideany(self, self.lightable) #se buscavcolisiones entre el sprite de la luz y cualquier otro que este en el grupo de los colisionables
if obj != None: #pulir si se puede (se puede)
objX = obj.rect.centerx+obj.corrections[0] #se aplican correciones
objY = obj.rect.centery+obj.corrections[1]
Vect = np.array([self.rect.centerx-objX, #vextor móvil, este va del centor del jugador al de la luz
self.rect.centery-objY
])
E_1 = np.array([1,0]) #vector canónico para comparar
norm = np.linalg.norm(Vect)
angle = math.acos(np.vdot(E_1, Vect/norm)) if objY < self.rect.centery else -math.acos(np.vdot(E_1, Vect/norm))
rnorm = int(round(norm))^2 #transparencia 1/x^2
angleShadow = angle - np.radians(90)
angle -= np.radians(180)
angle = -angle #comportamientos raros
print(np.degrees(angle), delta(-30, math.pi/4, angle))
if norm <= self.radius:
alpha = 50/rnorm*255 if norm != 0 else 0
shadow = Shadow(obj, alpha, angleShadow)
xOffset, yOffset = 0, 0
if angle >= 0 and angle < math.pi/2:
xOffset = math.cos(angle)*shadow.corrections[0]+delta(-15, math.pi/4, angle)
yOffset = math.cos(angle)*shadow.corrections[1]+delta(-15, math.pi/4, angle)
d = pg.display.get_surface()
d.blit(shadow.image, (obj.rect.x + xOffset , obj.rect.y + yOffset))
d.blit(obj.image, (obj.rect.x, obj.rect.y))
del shadow
def draw(self, surface, point):
x, y = point
surface.blit(self, (x+self.w/2, y+h/2))
if __name__ == "__main__":
clock = pg.time.Clock()
fire = fuenteLuz("fire/frame", 3)
pg.init()
g = pg.sprite.Group()
g.add(fire)
screen = pg.display.set_mode((500,400))
screen.fill((255,255,255))
while True:
for event in pg.event.get():
if event.type is pg.QUIT:
pg.quit() # quit the screen
break
screen.fill((255,255,255))
g.update()
g.draw(screen)
pg.display.update()
clock.tick(60)
|
[STATEMENT]
lemma wlp_Loop:
assumes wd: "well_def body"
and uI: "unitary I"
and inv: "wlp_inv G body I"
shows "I \<le> wlp do G \<longrightarrow> body od (\<lambda>s. \<guillemotleft>\<N> G\<guillemotright> s * I s)"
(is "I \<le> wlp do G \<longrightarrow> body od ?P")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
let "?f Q s" = "\<guillemotleft>G\<guillemotright> s * wlp body Q s + \<guillemotleft>\<N> G\<guillemotright> s * ?P s"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
have "I \<tturnstile> gfp_exp ?f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. I \<tturnstile> gfp_exp (\<lambda>a b. \<guillemotleft> G \<guillemotright> b * wlp body a b + \<guillemotleft> \<N> G \<guillemotright> b * (\<guillemotleft> \<N> G \<guillemotright> b * I b))
[PROOF STEP]
proof(rule gfp_exp_upperbound[OF _ uI])
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
have "I = (\<lambda>s. (\<guillemotleft>G\<guillemotright> s + \<guillemotleft>\<N> G\<guillemotright> s) * I s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. I = (\<lambda>s. (\<guillemotleft> G \<guillemotright> s + \<guillemotleft> \<N> G \<guillemotright> s) * I s)
[PROOF STEP]
by(simp add:negate_embed)
[PROOF STATE]
proof (state)
this:
I = (\<lambda>s. (\<guillemotleft> G \<guillemotright> s + \<guillemotleft> \<N> G \<guillemotright> s) * I s)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
I = (\<lambda>s. (\<guillemotleft> G \<guillemotright> s + \<guillemotleft> \<N> G \<guillemotright> s) * I s)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
have "... = (\<lambda>s. \<guillemotleft>G\<guillemotright> s * I s + \<guillemotleft>\<N> G\<guillemotright> s * I s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<lambda>s. (\<guillemotleft> G \<guillemotright> s + \<guillemotleft> \<N> G \<guillemotright> s) * I s) = (\<lambda>s. \<guillemotleft> G \<guillemotright> s * I s + \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
by(simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>s. (\<guillemotleft> G \<guillemotright> s + \<guillemotleft> \<N> G \<guillemotright> s) * I s) = (\<lambda>s. \<guillemotleft> G \<guillemotright> s * I s + \<guillemotleft> \<N> G \<guillemotright> s * I s)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>s. (\<guillemotleft> G \<guillemotright> s + \<guillemotleft> \<N> G \<guillemotright> s) * I s) = (\<lambda>s. \<guillemotleft> G \<guillemotright> s * I s + \<guillemotleft> \<N> G \<guillemotright> s * I s)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
have "... = (\<lambda>s. \<guillemotleft>G\<guillemotright> s * (\<guillemotleft>G\<guillemotright> s * I s) + \<guillemotleft>\<N> G\<guillemotright> s * (\<guillemotleft>\<N> G\<guillemotright> s * I s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<lambda>s. \<guillemotleft> G \<guillemotright> s * I s + \<guillemotleft> \<N> G \<guillemotright> s * I s) = (\<lambda>s. \<guillemotleft> G \<guillemotright> s * (\<guillemotleft> G \<guillemotright> s * I s) + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s))
[PROOF STEP]
by(simp add:embed_bool_idem algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>s. \<guillemotleft> G \<guillemotright> s * I s + \<guillemotleft> \<N> G \<guillemotright> s * I s) = (\<lambda>s. \<guillemotleft> G \<guillemotright> s * (\<guillemotleft> G \<guillemotright> s * I s) + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s))
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>s. \<guillemotleft> G \<guillemotright> s * I s + \<guillemotleft> \<N> G \<guillemotright> s * I s) = (\<lambda>s. \<guillemotleft> G \<guillemotright> s * (\<guillemotleft> G \<guillemotright> s * I s) + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s))
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
have "... \<tturnstile> (\<lambda>s. \<guillemotleft>G\<guillemotright> s * wlp body I s + \<guillemotleft>\<N> G\<guillemotright> s * (\<guillemotleft>\<N> G\<guillemotright> s * I s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lambda>s. \<guillemotleft> G \<guillemotright> s * (\<guillemotleft> G \<guillemotright> s * I s) + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s) \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
using inv
[PROOF STATE]
proof (prove)
using this:
wlp_inv G body I
goal (1 subgoal):
1. \<lambda>s. \<guillemotleft> G \<guillemotright> s * (\<guillemotleft> G \<guillemotright> s * I s) + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s) \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
by(auto dest:wlp_invD intro:add_mono mult_left_mono)
[PROOF STATE]
proof (state)
this:
\<lambda>s. \<guillemotleft> G \<guillemotright> s * (\<guillemotleft> G \<guillemotright> s * I s) + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s) \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>a. \<guillemotleft> G \<guillemotright> a * wlp body I a + \<guillemotleft> \<N> G \<guillemotright> a * (\<guillemotleft> \<N> G \<guillemotright> a * I a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
I \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
show "I \<tturnstile> (\<lambda>s. \<guillemotleft>G\<guillemotright> s * wlp body I s + \<guillemotleft>\<N> G\<guillemotright> s * (\<guillemotleft>\<N> G\<guillemotright> s * I s))"
[PROOF STATE]
proof (prove)
using this:
I \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
goal (1 subgoal):
1. I \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
I \<tturnstile> \<lambda>s. \<guillemotleft> G \<guillemotright> s * wlp body I s + \<guillemotleft> \<N> G \<guillemotright> s * (\<guillemotleft> \<N> G \<guillemotright> s * I s)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
I \<tturnstile> gfp_exp (\<lambda>a b. \<guillemotleft> G \<guillemotright> b * wlp body a b + \<guillemotleft> \<N> G \<guillemotright> b * (\<guillemotleft> \<N> G \<guillemotright> b * I b))
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
I \<tturnstile> gfp_exp (\<lambda>a b. \<guillemotleft> G \<guillemotright> b * wlp body a b + \<guillemotleft> \<N> G \<guillemotright> b * (\<guillemotleft> \<N> G \<guillemotright> b * I b))
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
from uI well_def_wlp_nearly_healthy[OF wd]
[PROOF STATE]
proof (chain)
picking this:
unitary I
nearly_healthy (wlp body)
[PROOF STEP]
have "... = wlp do G \<longrightarrow> body od ?P"
[PROOF STATE]
proof (prove)
using this:
unitary I
nearly_healthy (wlp body)
goal (1 subgoal):
1. gfp_exp (\<lambda>a b. \<guillemotleft> G \<guillemotright> b * wlp body a b + \<guillemotleft> \<N> G \<guillemotright> b * (\<guillemotleft> \<N> G \<guillemotright> b * I b)) = wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
by(auto intro!:wlp_Loop1[symmetric] unitary_intros)
[PROOF STATE]
proof (state)
this:
gfp_exp (\<lambda>a b. \<guillemotleft> G \<guillemotright> b * wlp body a b + \<guillemotleft> \<N> G \<guillemotright> b * (\<guillemotleft> \<N> G \<guillemotright> b * I b)) = wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
goal (1 subgoal):
1. I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
I \<tturnstile> wlp (\<mu>x. body ;; x \<^bsub>\<guillemotleft> G \<guillemotright>\<^esub>\<oplus> Skip) (\<lambda>s. \<guillemotleft> \<N> G \<guillemotright> s * I s)
goal:
No subgoals!
[PROOF STEP]
qed |
Spring Break camp is just around the corner! April 22-26 Call to reserve your spot!
Where Every Child Is a Star!!
Flips For Kids Gymnastics Center strives to offer the highest quality gymnastics classes in a safe, enriching and most of all, FUN environment. With staff that includes some of the area's finest gymnastics instructors, Flips For Kids offers classes for children ages walking through teen.
Copyright © 2018 Flips for Kids - All Rights Reserved. |
import basic
section
parameters (α : Type*) (F : Type*)
structure is_clone (C : set (op F α)) :=
(proj_closed : ∀ k, (λ (x : F → α), x k) ∈ C)
(comp_closed : ∀ f (g : F → op F α), f ∈ C → (∀ i, g i ∈ C) → (λ x, f (λ i, g i x)) ∈ C)
parameter (X : set (op F α))
-- The smallest clone containing X
inductive clo : set (op F α)
| proj (k) : clo (π k)
-- there are like two different ways to make this SEGFAULT lmao
| comp {f} {g : F → op F α} :
f ∈ X → (∀ i, clo (g i)) → clo (λ x, f (λ i, g i x))
theorem clo_contains : X ⊆ clo :=
begin
intros _ h,
apply clo.comp h,
apply clo.proj
end
theorem clo_is_clone : is_clone clo :=
{ proj_closed := clo.proj,
comp_closed := begin
intros _ _ fc gc,
induction fc with _ f _ _ _ ih,
{ apply gc },
{ apply @clo.comp f,
assumption,
apply ih }
end }
theorem clo_is_smallest (Y : set (op F α)) :
is_clone Y → X ⊆ Y → clo ⊆ Y :=
begin
intros hY hX f hf,
induction hf,
{ apply hY.proj_closed },
{ apply hY.comp_closed,
apply hX,
repeat { assumption } }
end
end
section
parameters {S : signature} (A : algebra S)
-- TODO: relate clone of term operations to term algebra
end |
import tactic
import group_theory.coset
import group_theory.quotient_group
import group_theory.index
import group_theory.finiteness
import data.setoid.partition
namespace chapter2.section2
variables {G : Type*} [group G]
-- 定义 2-1
-- #check subgroup.one_mem'
-- #check subgroup.mul_mem'
-- #check subgroup.inv_mem'
-- #check subgroup.one_mem
-- #check subgroup.mul_mem
-- #check subgroup.inv_mem
-- variables (H : subgroup G)
def subgroup_trans_2_1 (H : subgroup G) (K : subgroup H) := subgroup.map H.subtype K
namespace lemma_2_1
-- (H_sub_G: H ⊆ set.univ)
def lemma_2_1_1 (H: set G) (H_n_empty: H.nonempty) (h1 : ∀ a b, a ∈ H → b ∈ H → (a * b ∈ H)) (h2 : ∀ a, a ∈ H → a⁻¹ ∈ H) : subgroup G :=
{
carrier := H,
one_mem' := begin
induction H_n_empty with a a_in_H,
have a_inv_in_H := h2 a a_in_H,
have := h1 _ _ a_in_H a_inv_in_H,
rw mul_inv_self at this,
exact this,
end,
mul_mem' := h1,
inv_mem' := h2,
}
def lemma_2_1_2 (H: set G) (H_n_empty: H.nonempty) (h : ∀ a b, a ∈ H → b ∈ H → (a * b⁻¹ ∈ H)) : subgroup G :=
begin
have one_mem: (1 : G) ∈ H := begin
cases H_n_empty with a a_in_H,
have := h a a a_in_H a_in_H,
rw mul_inv_self at this,
exact this
end,
exact {
carrier := H,
one_mem' := one_mem,
mul_mem' := begin
intros a b ha hb,
replace hb := h _ _ one_mem hb,
rw one_mul at hb,
have := h _ _ ha hb,
rw inv_inv at this,
exact this,
end,
inv_mem' := begin
intros a ha,
have := h _ _ one_mem ha,
rw one_mul at this,
exact this,
end,
},
end
def lemma_2_1_3 (H: finset G) (s_nonempty: H.nonempty) (h1 : ∀ a b, a ∈ H → b ∈ H → (a * b ∈ H)) : subgroup G := lemma_2_1_1 H (finset.coe_nonempty.mpr s_nonempty) h1 (λ x h_x, begin
have my_set_map: set.maps_to (λ (n : ℕ), x ^ (n + 1)) set.univ H := begin
intros n hn,
simp,
induction n,
{ simp, assumption },
{
specialize n_ih (set.mem_univ n_n),
specialize h1 _ _ n_ih h_x,
rw pow_add, rw pow_one,
exact h1,
}
end,
obtain ⟨r, -, s, -, H_r_neq_s, H4⟩ := set.infinite.exists_ne_map_eq_of_maps_to set.infinite_univ my_set_map (finset.finite_to_set H),
clear my_set_map,
simp at H4,
wlog H_r_s : s < r, { exact (ne.symm H_r_neq_s).lt_or_lt }, clear H_r_neq_s,
have h:= pow_mul_pow_sub x (nat.succ_le_succ (le_of_lt H_r_s)),
rw H4 at h,
clear H4,
simp at h,
have h1: r - s > 0 := tsub_pos_of_lt H_r_s,
have h2: ∀ x , x > 0 → ∃ (t : ℕ), t + 1 = x := begin intros x hx, induction x, linarith, use x_n, end,
replace h2 := h2 _ h1,
obtain ⟨t, h2⟩ := h2,
clear h1,
rw ← h2 at h,
clear h2 H_r_s r s,
have h3: ∀ u, x ^ (u + 1) ∈ H := begin
intro u,
induction u,
{ simpa using h_x },
{
have := h1 _ _ u_ih h_x,
rw [pow_add, pow_one],
exact this,
},
end,
convert_to x ^ t ∈ ↑H,
{
rw [pow_add, pow_one] at h,
rw mul_eq_one_iff_eq_inv at h,
exact eq.symm h,
},
have h4 := h3 (t + t),
rw [add_assoc,pow_add] at h4,
rw h at h4,
rw mul_one at h4,
exact h4,
end)
end lemma_2_1
-- #check quotient_group.subgroup.has_quotient
-- #check set.center
-- #check subgroup.center
-- 命题2-2
def lemma_2_2 : subgroup G :=
{
carrier := set.center G,
one_mem' := begin
dunfold set.center,
dunfold has_mem.mem set.mem set_of,
simp,
end,
mul_mem' := begin
dunfold set.center,
dunfold has_mem.mem set.mem set_of,
intros a b ha hb g,
exact by calc
g * (a * b) = (g * a) * b : by group
... = (a * g) * b : by rw ha
... = a * (g * b) : by group
... = a * (b * g) : by rw hb
... = a * b * g : by group
end,
inv_mem' := begin
dunfold set.center,
dunfold has_mem.mem set.mem set_of,
intros g h a,
specialize h a,
rw ← eq_mul_inv_iff_mul_eq at h,
rw mul_assoc at h,
rw ← inv_mul_eq_iff_eq_mul at h,
rw h,
end,
}
-- 定义2-3
-- #check subgroup.mem_closure
-- Schreier's lemma
-- https://leanprover-community.github.io/mathlib_docs/group_theory/schreier.html#subgroup.closure_mul_image_eq
-- #check subgroup.closure_mul_image_eq
-- 命题2-3
-- lemma lemma_2_3 (S : set G) : ∃ (S': subgroup G), subgroup.closure S = S' ∧ S'.carrier = { |}
-- TODO: 做不来
-- 定义2-4
-- #check is_of_fin_order
-- #check order_of
-- lemma lemma_2_4 (a : G) (h : is_of_fin_order a) : subgroup.closure ({ a } : set G) = subgroup.closure ({ a } : set G) := begin
-- induction h,
-- end
-- 定义2-5
-- #check @left_coset
lemma xz_2_1_1_r (H : subgroup G) (a b: G) : (right_coset ↑H a = right_coset ↑H b) ↔ a * b⁻¹ ∈ H :=
begin
dunfold right_coset set.image,
rw set.ext_iff,
simp,
split,
{
intro h,
replace h := (h a).mp,
replace h := h ⟨1, one_mem H, by group⟩,
rcases h with ⟨g, hg, hg_eq⟩,
rw ← eq_mul_inv_iff_mul_eq at hg_eq,
rw hg_eq at *,
assumption,
},
{
intros h1 g,
split,
{
rintros ⟨h, hh, hh_eq⟩,
replace hh_eq := eq_mul_inv_of_mul_eq hh_eq,
rw hh_eq at *, clear hh_eq h,
use g * b⁻¹,
have := mul_mem hh h1,
simpa [mul_assoc] using this,
},
{
rintros ⟨h, hh, hh_eq⟩,
replace hh_eq := eq_mul_inv_of_mul_eq hh_eq,
rw hh_eq at *, clear hh_eq h,
use g * a⁻¹,
replace h1 := inv_mem h1,
simp at h1,
have := mul_mem hh h1,
simpa [mul_assoc] using this,
}
}
end
-- 性质 _2_1_1_l
-- #check left_coset_eq_iff
lemma my_left_coset_eq_iff (H : subgroup G) {a b: G} : (left_coset a H = left_coset b H) ↔ a⁻¹ * b ∈ H :=
begin
dunfold left_coset,
dunfold set.image,
-- have := left_coset_equivalence_rel ↑H,
-- unfold equivalence left_coset_equivalence reflexive symmetric transitive at this,
split,
{
rw set.ext_iff,
simp,
intro h,
replace h := (h a).mp,
replace h := h ⟨1, one_mem H, by group⟩,
rcases h with ⟨g, hg, hg_eq⟩,
rw ← eq_inv_mul_iff_mul_eq at hg_eq,
rw hg_eq at hg, clear hg_eq,
simpa using inv_mem hg,
},
{
intro h1,
ext g,
split;simp,
{
rintros h hh rfl,
use b⁻¹ * a * h,
refine ⟨_, by group⟩,
replace h1 := inv_mem h1,
simp at h1,
exact mul_mem h1 hh,
},
{
rintros h hh rfl,
use a⁻¹ * b * h,
refine ⟨_, by group⟩,
exact mul_mem h1 hh,
}
}
end
def xz_2 (H : subgroup G) (a b: G) : (right_coset ↑H a ≃ right_coset ↑H b) :=
{
to_fun := begin
rintro ⟨c, hc⟩,
use c * a⁻¹ * b,
rcases hc with ⟨d,hd,rfl⟩,
use d,
exact ⟨hd, by group⟩,
end,
inv_fun := begin
-- dunfold right_coset set.image,
rintro ⟨c, hc⟩,
-- simp at *,
use c * b⁻¹ * a,
rcases hc with ⟨d,hd,rfl⟩,
use d,
exact ⟨hd, by group⟩,
end,
left_inv := begin
rw function.left_inverse,
simp,
end,
right_inv :=begin
rw function.right_inverse,
rw function.left_inverse,
simp,
end,
}
lemma xz_2_1_3_r (H : subgroup G) (a b: G) : (right_coset ↑H a ≠ right_coset ↑H b) → right_coset ↑H a ∩ right_coset ↑H b = ∅ :=
begin
rw ne,
rw xz_2_1_1_r,
intro h,
contrapose! h,
rw [set.ne_empty_iff_nonempty, set.nonempty_def] at h,
rcases h with ⟨g, ⟨h1, hg1, hg1'⟩, ⟨h2, hg2, hg2'⟩⟩, simp at *,
obtain rfl := eq_mul_inv_of_mul_eq hg1', clear hg1',
obtain rfl := eq_mul_inv_of_mul_eq hg2', clear hg2',
have := mul_mem (inv_mem hg1) hg2,
simpa [mul_assoc] using this,
end
-- #check left_coset_equivalence
-- #check left_coset_equivalence_rel
-- #check quotient_group.left_rel
-- #check quotient_group.right_rel
def my_quotient_group_left_rel (H : subgroup G) : setoid G := {
r := λ x y, x⁻¹ * y ∈ H,
iseqv:= begin
simp_rw ←left_coset_eq_iff,
refine ⟨_,_,_⟩,
{
intro x,
reflexivity,
},
{
intros x y H,
exact H.symm,
},
{
intros x y z hxy hyz,
rw hxy,
rw hyz,
}
end,
}
-- variable (H : subgroup G)
-- #check quotient (quotient_group.left_rel H)
-- #check ⟦ quotient_group.left_rel H ⟧
-- #check quotient1
-- #check (quotient_group.left_rel H)
-- #check quot.mk (quotient_group.left_rel H).r
-- #check quotient.mk (1: set H)
-- #check quotient.exists_rep (quot.mk (quotient_group.left_rel H).r)
example (H : subgroup G) : quotient (quotient_group.left_rel H) = (G ⧸ H) :=
begin
unfold quotient,
unfold has_quotient.quotient,
unfold has_quotient.quotient',
unfold quotient_group.left_rel,
unfold quotient,
have := quot.mk (quotient_group.left_rel H).r,
change quot setoid.r = (G ⧸ H),
refl,
end
-- #check subgroup.index_mul_card
-- #check finset
-- lemma index_mul_card [fintype G] (H : subgroup G) [hH : fintype H] :
-- H.index * fintype.card H = fintype.card G :=
-- begin
-- unfold subgroup.index,
-- -- convert_to nat.card (G ⧸ H) * fintype.card ↥H = fintype.card G,
-- have := @nat.card_eq_fintype_card (G ⧸ H),
-- -- unfold subgroup.index has_quotient.quotient has_quotient.quotient' quotient_group.left_rel coe_sort coe_sort has_coe_to_sort.coe nat.card,
-- -- unfold coe_fn has_coe_to_sort.coe cardinal.to_nat,
-- -- simp,
-- sorry,
-- end
#check subgroup.card_eq_card_quotient_mul_card_subgroup
lemma my_subgroup_card_eq_card_quotient_mul_card_subgroup
[fintype G] (H : subgroup G) [fintype H] [decidable_pred (λ a, a ∈ H)] :
fintype.card G = fintype.card (G ⧸ H) * fintype.card H :=
begin
rw ←fintype.card_prod,
apply fintype.card_congr,
sorry
end
end chapter2.section2
|
#!/usr/bin/env python
# coding: utf-8
import numpy as np
import pandas as pd
import glob
sample_idx = 0
for filename in glob.glob('/media/garner1/hdd2/tcga.detection/*.gz'):
if sample_idx == 0:
df = pd.read_csv(filename,sep='\t')
features = df.columns[np.r_[0, 7:18]]
df_pool = df[features].describe().reset_index()
df_pool['Image'] = [df[df.columns[0]].iloc[0]]*df_pool.shape[0]
else:
df = pd.read_csv(filename,sep='\t')
df_summary = df[features].describe().reset_index()
df_summary['Image'] = [df[df.columns[0]].iloc[0]]*df_summary.shape[0]
df_pool = pd.concat([df_pool, df_summary], ignore_index=True)
print(sample_idx,df_pool.shape)
sample_idx += 1
df_pool.to_pickle("/media/garner1/hdd2/pooled_measurements_min-25-50-75-max.pkl")
|
using Plots
using ColorSchemes
using Combinatorics: combinations
"""
This file calculates exact burden and fake burden.
"""
"""
grey_next_flip(n)
A Grey code is a map from a binary number to a different binary number.
The magic is that if you call this `n=2^i` times, you will see every binary
number between `0` and `n-1`, but each one will be only one digit off from
the last. This function, in particular, tells you which bit will flip next.
"""
function grey_next_flip(n)
for i in 1:1:64
if n & 1 == 1
return i
else
n >>= 1
end
end
65
end
"""
Calculates (b_j /sum(b_i))(1 - prod(1-b_i)) (prod(p_i) prod(1 - p_j)).
"""
function exact_burden_term(weights, prevalences, which)
w = weights[which]
yes = prevalences[which]
no = prevalences[.!which]
results = zeros(Float64, length(which))
results[which] += w * ((1 - prod(1 .- w)) * prod(yes) * prod(1 .- no) / sum(w))
results
end
"""
Calculates (b_j /sum(b_i))(1 - prod(1-b_i)) (prod(p_i) prod(1 - p_j))
and adds it to the given running sum.
"""
function exact_burden_term!(weights, prevalences, which, running_sum)
w = weights[which]
yes = prevalences[which]
no = prevalences[.!which]
running_sum[which] += w * ((1 - prod(1 .- w)) * prod(yes) * prod(1 .- no) / sum(w))
end
function exact_burden(weights, prevalences)
n = length(prevalences)
which = zeros(Bool, n)
b = zeros(Float64, n)
for i in 1:(1<<n - 1)
to_flip = grey_next_flip(i)
which[to_flip] = !which[to_flip]
exact_burden_term!(weights, prevalences, which, b)
end
b
end
"""
The burden if we allow up to `n` comorbidities. `n=1` means you can have
one disease at a time.
"""
function order_n_burden(weights, prevalences, n)
cnt = length(weights)
burden = similar(prevalences)
fill!(burden, 0)
which = zeros(Bool, cnt)
for depth in 1:n
for como_idx in combinations(1:cnt, depth)
fill!(which, false)
which[como_idx] .= true
exact_burden_term!(weights, prevalences, which, burden)
end
end
burden
end
"""
A term-by-term gradient calculation with respect to index i
"""
function partial_term!(weights, prevalences, which, running_sum, i)
w = weights[which]
p = copy(prevalences)
p[i] = which[i] ? 1 : 2 # 1 - no = -1, which is the derivative.
yes = p[which]
no = p[.!which]
running_sum[which] += w * ((1 - prod(1 .- w)) * prod(yes) * prod(1 .- no) / sum(w))
end
function order_n_partial(weights, prevalences, n)
cnt = length(weights)
partial = zeros(Float64, cnt, cnt)
which = zeros(Bool, cnt)
for partial_wrt_j in 1:cnt
burden = zeros(Float64, cnt)
fill!(burden, 0)
# Loop over how many comorbidities a subpopulation has.
for depth in 1:n
# Loop over different choices of comorbidities for each subpopulation.
for como_idx in combinations(1:cnt, depth - 1)
fill!(which, false)
which[como_idx] .= true
partial_term!(weights, prevalences, which, burden, partial_wrt_j)
end
end
partial[:, partial_wrt_j] .= burden
end
partial
end
"""
Make random prevalences and burdens to calculate.
"""
function exact_burden_random(cnt)
weights = rand(cnt)
prevalences = rand(cnt)
burden = exact_burden(weights, prevalences)
weights, prevalences, burden
end
"""
This is the super simple, exact total burden for a population. Given how simple it is,
it's surprising that we don't have a closed form for individual contributions to burden.
"""
function total_burden(weights, prevalences)
1 - prod(1 .- weights .* prevalences)
end
"""
Partial derivative of total comorbidity with respect to prevalence.
Writes into the `partials` buffer.
"""
function partial_wrt_prevalence!(partials, weights, prevalences)
for i in 1:length(partials)
save_p = prevalences[i]
prevalences[i] = zero(eltype(prevalences))
partials[i] = weights[i] * prod(1 .- weights .* prevalences)
prevalences[i] = save_p
end
end
"""
Maybe we can divide the total burden by some fraction in order to get
individual cause's burden. Nah.
"""
function fake_burden(weights, prevalences)
total = total_burden(weights, prevalences)
w = weights .* prevalences
w * total / sum(w)
end
function fake3_burden(weights, prevalences)
total = total_burden(weights, prevalences)
w = weights .* prevalences
rho = w .* (1 - total)
rho * total / sum(rho)
end
"""
Another try at weighting the fake burden. Try calculating burden for n-1
and using those values as weights.
"""
function fake2_burden(weights, prevalences)
total = total_burden(weights, prevalences)
reduced = similar(weights)
reduced_p = similar(prevalences)
for ridx in 1:length(prevalences)
reduced_p .= prevalences
reduced_p[ridx] = 0.99 * prevalences[ridx]
reduced[ridx] = 1 .- total_burden(weights, reduced_p)
end
reduced_product = weights .* prevalences .* reduced
reduced_product * total / sum(reduced_product)
end
relerr(observed, expected) = (observed .- expected) ./ observed
function total_burden_random(cnt)
w = rand(cnt)
p = rand(cnt)
exact = exact_burden(w, p)
[total_burden(w, p), sum(exact)]
end
"""
Error in the fake burden is above 10%, even for 20 causes.
"""
function fake_burden_random(cnt)
w = rand(cnt)
p = rand(cnt)
exact = exact_burden(w, p)
fake = fake_burden(w, p)
[sum(fake), sum(exact), maximum(abs.((fake .- exact) ./ exact))]
end
function plot_compare(weight, prevalence, burden)
total = sum(burden)
estimated = (weight .* prevalence) * total / sum(weight .* prevalence)
rel = relerr(estimated, burden)
normalized = (rel .- minimum(rel)) / (maximum(rel) - minimum(rel))
colors = get(ColorSchemes.buda, normalized)
scatter(weight, prevalence, markercolor = colors)
end
"""
Error in the fake burden is above 10%, even for `cnt` causes.
"""
function fake_burden_basic_plot(fake_func, cnt)
plotter = scatter
plot_cnt = 5
for i in 1:plot_cnt
w = rand(cnt)
p = rand(cnt)
exact = exact_burden(w, p)
fake = fake_func(w, p)
rplot = plotter(
exact,
fake,
markercolor = get(ColorSchemes.tab20b, (i-1)/(plot_cnt - 1)),
legend = false
)
plotter = scatter!
if i == plot_cnt
display(rplot)
end
end
end
function fake_gen(weight, prevalence)
total = total_burden(weight, prevalence)
estimated = (weight .* prevalence) * total / sum(weight .* prevalence)
end
function generate_prevalences(burden_gen, cause_cnt, trial_cnt)
weight = rand(cause_cnt)
relerr_and_prevalence = zeros(Float64, cause_cnt, 2, trial_cnt)
for t in 1:trial_cnt
prevalence = rand(cause_cnt)
burden = exact_burden(weight, prevalence)
estimated = burden_gen(weight, prevalence)
rel = relerr(estimated, burden)
relerr_and_prevalence[:, 1, t] = rel
relerr_and_prevalence[:, 2, t] = prevalence
end
weight, relerr_and_prevalence
end
"""
This plot asks how the error of a single cause depends on its
prevalence. It plots relative error by prevalence. It shows that
larger prevalence is estimated below what it should be. There is scatter in
this plot. I'll bet that scatter is a function of the total prevalence for
all causes for each trial. Either as a sum or as it appears in the total burden
calculation.
"""
function plot_by_cause(weight, relerr_and_prevalence)
cause_cnt = length(weight)
trial_cnt = size(relerr_and_prevalence, 3)
callit = scatter
for cidx in 1:5:cause_cnt
color = get(ColorSchemes.tab20b, (cidx - 1) / (cause_cnt - 1))
rel = reshape(relerr_and_prevalence[cidx, 1, :], trial_cnt)
prev = reshape(relerr_and_prevalence[cidx, 2, :], trial_cnt)
display(callit(prev, rel, markercolor = color))
callit = scatter!
end
end
"""
This plots prevalence by weight. It colors by relative error. We see that
larger weights tend to skew towards positive relative error.
"""
function plot_trials(weight, relerr_and_prevalence)
cause_cnt = length(weight)
trial_cnt = size(relerr_and_prevalence, 3)
w = repeat(weight, trial_cnt)
rel = reshape(relerr_and_prevalence[:, 1, :], cause_cnt * trial_cnt)
normrel = (rel .- minimum(rel)) / (maximum(rel) - minimum(rel))
p = reshape(relerr_and_prevalence[:, 2, :], cause_cnt * trial_cnt)
colors = get(ColorSchemes.viridis, normrel)
@show length(w)
@show length(rel)
@show length(p)
display(scatter(w, p, markercolor = colors))
end
|
/*
* A rng module implementation which can return a sample as an array.
* Author : Pierre Schnizer <[email protected]>
* Date : 1. July. 2003
*
*/
#include <pygsl/error_helpers.h>
#include <pygsl/block_helpers.h>
#include <pygsl/utils.h>
#ifdef PyGSL_NO_IMPORT_API
#undef PyGSL_NO_IMPORT_API
#endif
#include <pygsl/rng_helpers.h>
#include <pygsl/rng.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
/*
* All doc strings
*/
static PyObject *module = NULL;
#include "rng_helpers.c"
#include "rngmodule_docs.h"
static void rng_delete(PyGSL_rng *self);
static PyObject * rng_call(PyGSL_rng *self, PyObject *args);
#undef PyGSL_RNG_Check
#define PyGSL_RNG_Check(op) ((op)->ob_type == &PyGSL_rng_pytype)
static PyObject * /* on "instance.attr" */
rng_getattr (PyGSL_rng *self, char *name);
PyTypeObject PyGSL_rng_pytype = {
PyObject_HEAD_INIT(NULL) /* fix up the type slot in initcrng */
0, /* ob_size */
"PyGSL_rng", /* tp_name */
sizeof(PyGSL_rng), /* tp_basicsize */
0, /* tp_itemsize */
/* standard methods */
(destructor) rng_delete, /* tp_dealloc ref-count==0 */
(printfunc) 0, /* tp_print "print x" */
(getattrfunc) rng_getattr, /* tp_getattr "x.attr" */
(setattrfunc) 0, /* tp_setattr "x.attr=v" */
(cmpfunc) 0, /* tp_compare "x > y" */
(reprfunc) 0, /* tp_repr `x`, print x */
/* type categories */
0, /* tp_as_number +,-,*,/,%,&,>>,pow...*/
0, /* tp_as_sequence +,[i],[i:j],len, ...*/
0, /* tp_as_mapping [key], len, ...*/
/* more methods */
(hashfunc) 0, /* tp_hash "dict[x]" */
(ternaryfunc) rng_call, /* tp_call "x()" */
(reprfunc) 0, /* tp_str "str(x)" */
(getattrofunc) 0, /* tp_getattro */
(setattrofunc) 0, /* tp_setattro */
0, /* tp_as_buffer */
0L, /* tp_flags */
rng_type_doc /* tp_doc */
};
static PyObject *
PyGSL_rng_init(PyObject *self, PyObject *args, const gsl_rng_type * rng_type)
{
PyGSL_rng *rng = NULL;
FUNC_MESS_BEGIN();
rng = (PyGSL_rng *) PyObject_NEW(PyGSL_rng, &PyGSL_rng_pytype);
if(rng == NULL){
return NULL;
}
if(rng_type == NULL){
rng->rng = gsl_rng_alloc(gsl_rng_default);
gsl_rng_set(rng->rng, gsl_rng_default_seed);
}else{
rng->rng = gsl_rng_alloc(rng_type);
}
FUNC_MESS_END();
return (PyObject *) rng;
}
#define RNG_ARNG(name) \
static PyObject* PyGSL_rng_init_ ## name (PyObject *self, PyObject *args) \
{ \
PyObject *tmp = NULL; \
FUNC_MESS_BEGIN(); \
tmp = PyGSL_rng_init(self, args, gsl_rng_ ## name); \
if (tmp == NULL){ \
PyGSL_add_traceback(module, __FILE__, __FUNCTION__, __LINE__); \
} \
FUNC_MESS_END(); \
return tmp; \
}
#include "rng_list.h"
static PyObject *
PyGSL_rng_init_default(PyObject *self, PyObject *args)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
tmp = PyGSL_rng_init(self, args, NULL);
if (tmp == NULL){
PyGSL_add_traceback(module, __FILE__, __FUNCTION__, __LINE__ - 1);
}
FUNC_MESS_END();
return tmp;
}
static void
rng_delete(PyGSL_rng *self)
{
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
if(self->rng != NULL){
DEBUG_MESS(5, "Freeing gsl_rng @ %p", self->rng);
gsl_rng_free(self->rng);
self->rng = NULL;
}
DEBUG_MESS(1, " self %p\n",(void *) self);
PyObject_Del(self);
self = NULL;
FUNC_MESS_END();
}
static PyObject * /* on "instance.uniform()" and "instance()" */
rng_call (PyGSL_rng *self, PyObject *args)
{
PyObject *tmp;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
tmp = PyGSL_rng_to_double(self, args, gsl_rng_uniform);
if(!tmp)
PyGSL_add_traceback(module, __FILE__, "rng.__call__", __LINE__ - 2);
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_uniform_pos (PyGSL_rng *self, PyObject *args)
{
PyObject *tmp;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
tmp = PyGSL_rng_to_double(self, args, gsl_rng_uniform_pos);
if(!tmp)
PyGSL_add_traceback(module, __FILE__, "rng.uniform_pos", __LINE__-2);
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_uniform_int (PyGSL_rng *self, PyObject *args)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
tmp = PyGSL_rng_ul_to_ulong(self, args, gsl_rng_uniform_int);
if(!tmp)
PyGSL_add_traceback(module, __FILE__, "rng.uniform_int", __LINE__-2);
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_get(PyGSL_rng *self, PyObject *args)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
tmp = PyGSL_rng_to_ulong(self, args, gsl_rng_get);
if(!tmp)
PyGSL_add_traceback(module, __FILE__, "rng.get", __LINE__ - 2);
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_set(PyGSL_rng *self, PyObject *args)
{
PyObject *tmp = NULL, *seed = NULL;
unsigned long int useed;
int lineno;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
if(0 == PyArg_ParseTuple(args, "O", &tmp)){
lineno = __LINE__; goto fail;
}
assert(tmp != NULL);
seed = PyNumber_Long(tmp);
if(!seed){lineno = __LINE__ - 1; goto fail;}
useed = PyLong_AsUnsignedLong(seed);
gsl_rng_set(self->rng, useed);
Py_INCREF(Py_None);
FUNC_MESS_END();
return Py_None;
fail:
FUNC_MESS("FAIL");
PyGSL_add_traceback(module, __FILE__, "rng.set", lineno);
return NULL;
}
static PyObject *
rng_name(PyGSL_rng *self, PyObject *args)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
if(0 == PyArg_ParseTuple(args, ":name"))
return NULL;
tmp = PyString_FromString(gsl_rng_name(self->rng));
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_max(PyGSL_rng *self, PyObject *args)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
if(0 == PyArg_ParseTuple(args, ":max"))
return NULL;
tmp = PyLong_FromUnsignedLong(gsl_rng_max(self->rng));
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_min(PyGSL_rng *self, PyObject *args)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
if(0 == PyArg_ParseTuple(args, ":min"))
return NULL;
tmp = PyLong_FromUnsignedLong(gsl_rng_min(self->rng));
FUNC_MESS_END();
return tmp;
}
static PyObject *
rng_clone(PyGSL_rng *self, PyObject *args)
{
PyGSL_rng * rng = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
if(0 == PyArg_ParseTuple(args, ":clone"))
return NULL;
rng = (PyGSL_rng *) PyObject_NEW(PyGSL_rng, &PyGSL_rng_pytype);
rng->rng = gsl_rng_clone(self->rng);
FUNC_MESS_END();
return (PyObject *) rng;
}
/*
* Is #name a standard macro definition?
*/
#define RNG_DISTRIBUTION(name, function) \
static PyObject* rng_ ## name (PyGSL_rng *self, PyObject *args) \
{ \
PyObject *tmp = NULL; \
FUNC_MESS_BEGIN(); \
tmp = PyGSL_rng_ ## function (self, args, gsl_ran_ ## name); \
if (tmp == NULL){ \
/* PyGSL_add_traceback(module, __FILE__, "rng." #name, __LINE__); */ \
PyGSL_add_traceback(module, __FILE__, __FUNCTION__, __LINE__); \
} \
FUNC_MESS_END(); \
return tmp; \
}
#include "rng_distributions.h"
/* Redefine to trigger emacs into correct coloring */
/*
* This list is not optimized. I guess... Do you know how to optimize it?
*/
static struct PyMethodDef rng_methods[] = {
{"get", (PyCFunction) rng_get, METH_VARARGS, rng_get_doc},
{"set", (PyCFunction) rng_set, METH_VARARGS, rng_set_doc},
{"uniform", (PyCFunction) rng_call, METH_VARARGS, rng_uniform_doc},
{"uniform_pos", (PyCFunction) rng_uniform_pos, METH_VARARGS, rng_uniform_pos_doc},
{"uniform_int", (PyCFunction) rng_uniform_int, METH_VARARGS, rng_uniform_int_doc},
{"name", (PyCFunction) rng_name, METH_VARARGS, NULL},
{"max", (PyCFunction) rng_max, METH_VARARGS, rng_max_doc},
{"min", (PyCFunction) rng_min, METH_VARARGS, rng_min_doc},
{"clone", (PyCFunction) rng_clone, METH_VARARGS, rng_clone_doc},
#if (PY_MAJOR_VERSION == 2) && (PY_MINOR_VERSION == 3)
/* RNG clone can not be used to copy a rng type in python 2.3 No idea how to do that correctly */
#else
{"__copy__", (PyCFunction) rng_clone, METH_VARARGS, rng_clone_doc},
#endif
/* distributions */
{"gaussian", (PyCFunction) rng_gaussian,METH_VARARGS, rng_gaussian_doc},
{"gaussian_ratio_method", (PyCFunction) rng_gaussian_ratio_method,METH_VARARGS, rng_gaussian_ratio_doc},
{"ugaussian", (PyCFunction) rng_ugaussian,METH_VARARGS, rng_ugaussian_doc},
{"ugaussian_ratio_method",(PyCFunction) rng_ugaussian_ratio_method,METH_VARARGS, rng_ugaussian_ratio_doc},
{"gaussian_tail", (PyCFunction) rng_gaussian_tail,METH_VARARGS, rng_gaussian_tail_doc},
{"ugaussian_tail",(PyCFunction) rng_ugaussian_tail,METH_VARARGS, rng_ugaussian_tail_doc},
{"bivariate_gaussian", (PyCFunction) rng_bivariate_gaussian,METH_VARARGS, rng_bivariate_gaussian_doc},
{"exponential",(PyCFunction)rng_exponential,METH_VARARGS, rng_exponential_doc},
{"laplace",(PyCFunction)rng_laplace,METH_VARARGS, rng_laplace_doc},
{"exppow",(PyCFunction)rng_exppow,METH_VARARGS, rng_exppow_doc},
{"cauchy",(PyCFunction)rng_cauchy,METH_VARARGS, rng_cauchy_doc},
{"rayleigh",(PyCFunction)rng_rayleigh,METH_VARARGS, rng_rayleigh_doc},
{"rayleigh_tail",(PyCFunction)rng_rayleigh_tail,METH_VARARGS, rng_rayleigh_tail_doc},
{"levy",(PyCFunction)rng_levy,METH_VARARGS, rng_levy_doc},
{"levy_skew",(PyCFunction)rng_levy_skew,METH_VARARGS, rng_levy_skew_doc},
{"gamma",(PyCFunction)rng_gamma,METH_VARARGS, rng_gamma_doc},
{"gamma_int",(PyCFunction)rng_gamma_int,METH_VARARGS, NULL},
{"flat",(PyCFunction)rng_flat,METH_VARARGS, rng_flat_doc},
{"lognormal",(PyCFunction)rng_lognormal,METH_VARARGS, rng_lognormal_doc},
{"chisq",(PyCFunction)rng_chisq,METH_VARARGS, rng_chisq_doc},
{"fdist",(PyCFunction)rng_fdist,METH_VARARGS, rng_fdist_doc},
{"tdist",(PyCFunction)rng_tdist,METH_VARARGS, rng_tdist_doc},
{"beta",(PyCFunction)rng_beta,METH_VARARGS, rng_beta_doc},
{"logistic",(PyCFunction)rng_logistic,METH_VARARGS, rng_logistic_doc},
{"pareto",(PyCFunction)rng_pareto,METH_VARARGS, rng_pareto_doc},
{"dir_2d",(PyCFunction)rng_dir_2d,METH_VARARGS, rng_dir_2d_doc},
{"dir_2d_trig_method",(PyCFunction)rng_dir_2d_trig_method,METH_VARARGS, rng_dir_2d_trig_method_doc},
{"dir_3d",(PyCFunction)rng_dir_3d,METH_VARARGS, rng_dir_3d_doc},
{"dir_nd",(PyCFunction)rng_dir_nd,METH_VARARGS, rng_dir_nd_doc},
{"weibull",(PyCFunction)rng_weibull,METH_VARARGS, rng_weibull_doc},
{"gumbel1",(PyCFunction)rng_gumbel1,METH_VARARGS, rng_gumbel1_doc},
{"gumbel2",(PyCFunction)rng_gumbel2,METH_VARARGS, rng_gumbel2_doc},
{"poisson",(PyCFunction)rng_poisson,METH_VARARGS, rng_poisson_doc},
{"bernoulli",(PyCFunction)rng_bernoulli,METH_VARARGS, rng_bernoulli_doc},
{"binomial",(PyCFunction)rng_binomial,METH_VARARGS, rng_binomial_doc},
{"negative_binomial",(PyCFunction)rng_negative_binomial,METH_VARARGS, rng_negative_binomial_doc},
{"pascal",(PyCFunction)rng_pascal,METH_VARARGS, rng_pascal_doc},
{"geometric",(PyCFunction)rng_geometric,METH_VARARGS, rng_geometric_doc},
{"hypergeometric",(PyCFunction)rng_hypergeometric,METH_VARARGS, rng_hypergeometric_doc},
{"logarithmic",(PyCFunction)rng_logarithmic,METH_VARARGS, rng_logarithmic_doc},
{"landau",(PyCFunction)rng_landau,METH_VARARGS, rng_landau_doc},
{"erlang",(PyCFunction)rng_erlang,METH_VARARGS, NULL},
{"multinomial",(PyCFunction)rng_multinomial,METH_VARARGS, multinomial_doc},
{"dirichlet",(PyCFunction)rng_dirichlet,METH_VARARGS, rng_dirichlet_doc},
{NULL, NULL,}
};
static PyObject *
rng_getattr(PyGSL_rng *self, char *name)
{
PyObject *tmp = NULL;
FUNC_MESS_BEGIN();
assert(PyGSL_RNG_Check(self));
tmp = Py_FindMethod(rng_methods, (PyObject *) self, name);
if(NULL == tmp){
PyGSL_add_traceback(module, __FILE__, "rng.__attr__", __LINE__ - 1);
return NULL;
}
return tmp;
}
static PyObject *
rng_create_list(PyObject *self, PyObject *args)
{
const gsl_rng_type** thisRNGType=gsl_rng_types_setup();
PyObject* list = NULL, *item=NULL;
FUNC_MESS_BEGIN();
/* provide other rng types as subclasses of rng */
list = PyList_New(0);
while ((*thisRNGType)!=NULL) {
item = PyString_FromString((*thisRNGType)->name);
Py_INCREF(item);
assert(item);
PyGSL_clear_name(PyString_AsString(item), PyString_Size(item));
if(PyList_Append(list, item) != 0)
goto fail;
thisRNGType++;
}
FUNC_MESS_END();
return list;
fail:
Py_XDECREF(list);
Py_XDECREF(item);
return NULL;
}
/*---------------------------------------------------------------------------*/
/* Module set up */
#define RNG_GENERATE_PDF
#undef RNG_DISTRIBUTION
#define RNG_DISTRIBUTION(name, function) \
static PyObject* rng_ ## name ## _pdf (PyObject *self, PyObject *args) \
{ \
PyObject * tmp; \
FUNC_MESS_BEGIN(); \
tmp = PyGSL_pdf_ ## function (self, args, gsl_ran_ ## name ## _pdf); \
if (tmp == NULL){ \
PyGSL_add_traceback(module, __FILE__, #name "_pdf", __LINE__); \
} \
FUNC_MESS_END(); \
return tmp; \
}
#include "rng_distributions.h"
static PyObject* rng_dirichlet_lnpdf (PyObject *self, PyObject *args)
{
PyObject *tmp;
FUNC_MESS_BEGIN();
tmp = PyGSL_pdf_dA_to_dA(self, args, gsl_ran_dirichlet_lnpdf);
FUNC_MESS_END();
return tmp;
}
static PyObject* rng_multinomial_lnpdf (PyObject *self, PyObject *args)
{
PyObject *tmp;
FUNC_MESS_BEGIN();
tmp = PyGSL_pdf_uidA_to_uiA(self, args, gsl_ran_multinomial_lnpdf);
FUNC_MESS_END();
return tmp;
}
static const char rng_env_setup_doc[] =
"This function reads the environment variables `GSL_RNG_TYPE' and\n\
`GSL_RNG_SEED'.\n\
The environment variable `GSL_RNG_TYPE' should be the name of a\n\
generator, such as `taus' or `mt19937'. The environment variable\n\
`GSL_RNG_SEED' should contain the desired seed value. It is\n\
converted to an `unsigned long int' using the C library function\n\
`strtoul'.\n";
static PyObject *
PyGSL_rng_env_setup(PyObject *self, PyObject *args)
{
gsl_rng_env_setup();
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef PyGSL_rng_module_functions[] = {
{"borosh13" , PyGSL_rng_init_borosh13 , METH_NOARGS, NULL},
{"cmrg" , PyGSL_rng_init_cmrg , METH_NOARGS, NULL},
{"coveyou" , PyGSL_rng_init_coveyou , METH_NOARGS, NULL},
{"fishman18" , PyGSL_rng_init_fishman18 , METH_NOARGS, NULL},
{"fishman20" , PyGSL_rng_init_fishman20 , METH_NOARGS, NULL},
{"fishman2x" , PyGSL_rng_init_fishman2x , METH_NOARGS, NULL},
{"gfsr4" , PyGSL_rng_init_gfsr4 , METH_NOARGS, NULL},
{"knuthran" , PyGSL_rng_init_knuthran , METH_NOARGS, NULL},
{"knuthran2" , PyGSL_rng_init_knuthran2 , METH_NOARGS, NULL},
#ifdef _PYGSL_GSL_HAS_RNG_KNUTHRAN2002
{"knuthran2002" , PyGSL_rng_init_knuthran2002 , METH_NOARGS, NULL},
#endif
{"lecuyer21" , PyGSL_rng_init_lecuyer21 , METH_NOARGS, NULL},
{"minstd" , PyGSL_rng_init_minstd , METH_NOARGS, NULL},
{"mrg" , PyGSL_rng_init_mrg , METH_NOARGS, NULL},
{"mt19937" , PyGSL_rng_init_mt19937 , METH_NOARGS, NULL},
{"mt19937_1999" , PyGSL_rng_init_mt19937_1999 , METH_NOARGS, NULL},
{"mt19937_1998" , PyGSL_rng_init_mt19937_1998 , METH_NOARGS, NULL},
{"r250" , PyGSL_rng_init_r250 , METH_NOARGS, NULL},
{"ran0" , PyGSL_rng_init_ran0 , METH_NOARGS, NULL},
{"ran1" , PyGSL_rng_init_ran1 , METH_NOARGS, NULL},
{"ran2" , PyGSL_rng_init_ran2 , METH_NOARGS, NULL},
{"ran3" , PyGSL_rng_init_ran3 , METH_NOARGS, NULL},
{"rand" , PyGSL_rng_init_rand , METH_NOARGS, NULL},
{"rand48" , PyGSL_rng_init_rand48 , METH_NOARGS, NULL},
{"random128_bsd" , PyGSL_rng_init_random128_bsd , METH_NOARGS, NULL},
{"random128_glibc2", PyGSL_rng_init_random128_glibc2, METH_NOARGS, NULL},
{"random128_libc5" , PyGSL_rng_init_random128_libc5 , METH_NOARGS, NULL},
{"random256_bsd" , PyGSL_rng_init_random256_bsd , METH_NOARGS, NULL},
{"random256_glibc2", PyGSL_rng_init_random256_glibc2, METH_NOARGS, NULL},
{"random256_libc5" , PyGSL_rng_init_random256_libc5 , METH_NOARGS, NULL},
{"random32_bsd" , PyGSL_rng_init_random32_bsd , METH_NOARGS, NULL},
{"random32_glibc2" , PyGSL_rng_init_random32_glibc2 , METH_NOARGS, NULL},
{"random32_libc5" , PyGSL_rng_init_random32_libc5 , METH_NOARGS, NULL},
{"random64_bsd" , PyGSL_rng_init_random64_bsd , METH_NOARGS, NULL},
{"random64_glibc2" , PyGSL_rng_init_random64_glibc2 , METH_NOARGS, NULL},
{"random64_libc5" , PyGSL_rng_init_random64_libc5 , METH_NOARGS, NULL},
{"random8_bsd" , PyGSL_rng_init_random8_bsd , METH_NOARGS, NULL},
{"random8_glibc2" , PyGSL_rng_init_random8_glibc2 , METH_NOARGS, NULL},
{"random8_libc5" , PyGSL_rng_init_random8_libc5 , METH_NOARGS, NULL},
{"random_bsd" , PyGSL_rng_init_random_bsd , METH_NOARGS, NULL},
{"random_glibc2" , PyGSL_rng_init_random_glibc2 , METH_NOARGS, NULL},
{"random_libc5" , PyGSL_rng_init_random_libc5 , METH_NOARGS, NULL},
{"randu" , PyGSL_rng_init_randu , METH_NOARGS, NULL},
{"ranf" , PyGSL_rng_init_ranf , METH_NOARGS, NULL},
{"ranlux" , PyGSL_rng_init_ranlux , METH_NOARGS, NULL},
{"ranlux389" , PyGSL_rng_init_ranlux389 , METH_NOARGS, NULL},
{"ranlxd1" , PyGSL_rng_init_ranlxd1 , METH_NOARGS, NULL},
{"ranlxd2" , PyGSL_rng_init_ranlxd2 , METH_NOARGS, NULL},
{"ranlxs0" , PyGSL_rng_init_ranlxs0 , METH_NOARGS, NULL},
{"ranlxs1" , PyGSL_rng_init_ranlxs1 , METH_NOARGS, NULL},
{"ranlxs2" , PyGSL_rng_init_ranlxs2 , METH_NOARGS, NULL},
{"ranmar" , PyGSL_rng_init_ranmar , METH_NOARGS, NULL},
{"slatec" , PyGSL_rng_init_slatec , METH_NOARGS, NULL},
{"taus" , PyGSL_rng_init_taus , METH_NOARGS, NULL},
{"taus2" , PyGSL_rng_init_taus2 , METH_NOARGS, NULL},
{"taus113" , PyGSL_rng_init_taus113 , METH_NOARGS, NULL},
{"transputer" , PyGSL_rng_init_transputer , METH_NOARGS, NULL},
{"tt800" , PyGSL_rng_init_tt800 , METH_NOARGS, NULL},
{"uni" , PyGSL_rng_init_uni , METH_NOARGS, NULL},
{"uni32" , PyGSL_rng_init_uni32 , METH_NOARGS, NULL},
{"vax" , PyGSL_rng_init_vax , METH_NOARGS, NULL},
{"waterman14" , PyGSL_rng_init_waterman14 , METH_NOARGS, NULL},
{"zuf" , PyGSL_rng_init_zuf , METH_NOARGS, NULL},
{"rng", PyGSL_rng_init_default, METH_NOARGS, rng_doc},
{"list_available_rngs", rng_create_list, METH_VARARGS},
/*densities*/
{"gaussian_pdf",rng_gaussian_pdf,METH_VARARGS, rng_gaussian_pdf_doc},
{"ugaussian_pdf",rng_ugaussian_pdf,METH_VARARGS, rng_ugaussian_pdf_doc},
{"gaussian_tail_pdf",rng_gaussian_tail_pdf,METH_VARARGS, rng_gaussian_tail_pdf_doc},
{"ugaussian_tail_pdf",rng_ugaussian_tail_pdf,METH_VARARGS, rng_ugaussian_tail_pdf_doc},
{"bivariate_gaussian_pdf",rng_bivariate_gaussian_pdf,METH_VARARGS, rng_bivariate_gaussian_pdf_doc},
{"exponential_pdf",rng_exponential_pdf,METH_VARARGS, rng_exponential_pdf_doc},
{"laplace_pdf",rng_laplace_pdf,METH_VARARGS, rng_laplace_pdf_doc},
{"exppow_pdf",rng_exppow_pdf,METH_VARARGS, rng_exppow_pdf_doc},
{"cauchy_pdf",rng_cauchy_pdf,METH_VARARGS, rng_cauchy_pdf_doc},
{"rayleigh_pdf",rng_rayleigh_pdf,METH_VARARGS, rng_rayleigh_pdf_doc},
{"rayleigh_tail_pdf",rng_rayleigh_tail_pdf,METH_VARARGS, rng_rayleigh_tail_pdf_doc},
{"gamma_pdf",rng_gamma_pdf,METH_VARARGS, rng_gamma_pdf_doc},
{"flat_pdf",rng_flat_pdf,METH_VARARGS, rng_flat_pdf_doc},
{"lognormal_pdf",rng_lognormal_pdf,METH_VARARGS, rng_lognormal_pdf_doc},
{"chisq_pdf",rng_chisq_pdf,METH_VARARGS, rng_chisq_pdf_doc},
{"fdist_pdf",rng_fdist_pdf,METH_VARARGS, rng_fdist_pdf_doc},
{"tdist_pdf",rng_tdist_pdf,METH_VARARGS, rng_tdist_pdf_doc},
{"beta_pdf",rng_beta_pdf,METH_VARARGS, rng_beta_pdf_doc},
{"logistic_pdf",rng_logistic_pdf,METH_VARARGS, rng_logistic_pdf_doc},
{"pareto_pdf",rng_pareto_pdf,METH_VARARGS, rng_pareto_pdf_doc},
{"weibull_pdf",rng_weibull_pdf,METH_VARARGS, rng_weibull_pdf_doc},
{"gumbel1_pdf",rng_gumbel1_pdf,METH_VARARGS, rng_gumbel1_pdf_doc},
{"gumbel2_pdf",rng_gumbel2_pdf,METH_VARARGS, rng_gumbel2_pdf_doc},
{"poisson_pdf",rng_poisson_pdf,METH_VARARGS, rng_poisson_pdf_doc},
{"bernoulli_pdf",rng_bernoulli_pdf,METH_VARARGS, rng_bernoulli_pdf_doc},
{"binomial_pdf",rng_binomial_pdf,METH_VARARGS, rng_binomial_pdf_doc},
{"negative_binomial_pdf",rng_negative_binomial_pdf,METH_VARARGS, rng_negative_binomial_pdf_doc},
{"pascal_pdf",rng_pascal_pdf,METH_VARARGS, rng_pascal_pdf_doc},
{"geometric_pdf",rng_geometric_pdf,METH_VARARGS, rng_geometric_pdf_doc},
{"hypergeometric_pdf",rng_hypergeometric_pdf,METH_VARARGS, rng_hypergeometric_pdf_doc},
{"logarithmic_pdf",rng_logarithmic_pdf,METH_VARARGS, rng_logarithmic_pdf_doc},
{"landau_pdf",rng_landau_pdf,METH_VARARGS, rng_landau_pdf_doc},
{"erlang_pdf",rng_erlang_pdf,METH_VARARGS, NULL},
{"multinomial_pdf",rng_multinomial_pdf,METH_VARARGS,multinomial_pdf_doc},
{"dirichlet_pdf",rng_dirichlet_pdf,METH_VARARGS, rng_dirichlet_pdf_doc},
{"multinomial_lnpdf",rng_multinomial_lnpdf,METH_VARARGS, NULL},
{"dirichlet_lnpdf",rng_dirichlet_lnpdf,METH_VARARGS, rng_dirichlet_lnpdf_doc},
{"env_setup",PyGSL_rng_env_setup,METH_NOARGS, (char*) rng_env_setup_doc},
{NULL, NULL, 0} /* Sentinel */
};
static void
set_api_pointer(void)
{
FUNC_MESS_BEGIN();
PyGSL_API[PyGSL_RNG_ObjectType_NUM] = (void *) &PyGSL_rng_pytype;
DEBUG_MESS(2, "__PyGSL_RNG_API @ %p, ", (void *) PyGSL_API);
DEBUG_MESS(2, "PyGSL_rng_pytype @ %p, ", (void *) &PyGSL_rng_pytype);
/* fprintf(stderr, "__PyGSL_RNG_API @ %p\n", (void *) __PyGSL_RNG_API); */
FUNC_MESS_END();
}
void
initrng(void)
{
PyObject *m=NULL, *item=NULL, *dict=NULL;
PyObject *api=NULL;
m = Py_InitModule("rng", PyGSL_rng_module_functions);
assert(m);
/* import_array(); */
init_pygsl();
/* create_rng_types(m); */
module = m;
dict = PyModule_GetDict(m);
if(!dict)
goto fail;
if (!(item = PyString_FromString(rng_module_doc))){
PyErr_SetString(PyExc_ImportError,
"I could not generate module doc string!");
goto fail;
}
if (PyDict_SetItemString(dict, "__doc__", item) != 0){
PyErr_SetString(PyExc_ImportError,
"I could not init doc string!");
goto fail;
}
PyGSL_rng_pytype.ob_type = &PyType_Type;
set_api_pointer();
api = PyCObject_FromVoidPtr((void *) PyGSL_API, NULL);
assert(api);
if (PyDict_SetItemString(dict, "_PYGSL_RNG_API", api) != 0){
PyErr_SetString(PyExc_ImportError,
"I could not add _PYGSL_RNG_API!");
goto fail;
}
return;
fail:
if(!PyErr_Occurred()){
PyErr_SetString(PyExc_ImportError, "I could not init rng module!");
}
}
|
/-
Copyright (c) 2021 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/
import algebra.gcd_monoid.finset
import number_theory.padics.padic_norm
/-!
# Basic results about setwise gcds on ℕ
This file proves some basic results about `finset.gcd` on `ℕ`.
## Main results
* `finset.coprime_of_div_gcd`: The elements of a set divided through by their gcd are coprime.
-/
instance : is_idempotent ℕ gcd_monoid.gcd := ⟨nat.gcd_self⟩
namespace finset
theorem coprime_of_div_gcd (s : finset ℕ) {x : ℕ} (hx : x ∈ s) (hnz : x ≠ 0) :
s.gcd (/ (s.gcd id)) = 1 :=
begin
rw nat.eq_one_iff_not_exists_prime_dvd,
intros p hp hdvd,
haveI : fact p.prime := ⟨hp⟩,
rw dvd_gcd_iff at hdvd,
replace hdvd : ∀ b ∈ s, s.gcd id * p ∣ b,
{ intros b hb,
specialize hdvd b hb,
rwa nat.dvd_div_iff at hdvd,
apply gcd_dvd hb },
have : s.gcd id ≠ 0 := (not_iff_not.mpr gcd_eq_zero_iff).mpr (λ h, hnz $ h x hx),
apply @pow_succ_padic_val_nat_not_dvd p _ _ this.bot_lt,
apply dvd_gcd,
intros b hb,
obtain ⟨k, rfl⟩ := hdvd b hb,
rw [id, mul_right_comm, pow_succ', mul_dvd_mul_iff_right hp.ne_zero],
apply dvd_mul_of_dvd_left,
exact pow_padic_val_nat_dvd
end
end finset
|
------------------------------------------------------------------------------
-- Proving properties without using pattern matching on refl
------------------------------------------------------------------------------
{-# OPTIONS --no-pattern-matching #-}
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
module FOT.DistributiveLaws.NoPatternMatchingOnRefl where
open import DistributiveLaws.Base
------------------------------------------------------------------------------
-- From DistributiveLaws.PropertiesI
-- Congruence properties
·-leftCong : ∀ {a b c} → a ≡ b → a · c ≡ b · c
·-leftCong {a} {c = c} h = subst (λ t → a · c ≡ t · c) h refl
·-rightCong : ∀ {a b c} → b ≡ c → a · b ≡ a · c
·-rightCong {a} {b} h = subst (λ t → a · b ≡ a · t) h refl
|
function [fx,dfdx,dfdp] = f_gen(Xt,Theta,ut,inF)
% Generic evolution function (up to quadratic terms)
% [fx,dfdx,dfdp] = f_gen(Xt,Theta,ut,inF)
deltat = inF.deltat;
n = size(Xt,1);
nc = factorial(n)./(factorial(2)*factorial(n-2));
A = reshape(Theta(1:n^2),n,n);
B = reshape(Theta(n^2+1:n*(2*n+nc)),n,n+nc);
xij = zeros(n+nc,1);
ind = cell(n,1);
ind2 = zeros(n,1);
k = 0;
for i=1:n
for j=1:n
if j >= i
k = k+1;
xij(k) = Xt(i).*Xt(j);
if i == j
ind2(i) = k;
else
ind{i} = [ind{i},k];
ind{j} = [ind{j},k];
end
end
end
end
dbxdx = zeros(n,n);
for i=1:n
for j=1:n
dbxdx(i,j) = 2*B(i,ind2(j)).*Xt(j) ...
+ B(i,ind{j})*Xt(setdiff(1:n,j));
end
end
f = A*Xt + B*xij;
fx = Xt + deltat.*f;
dfdx = eye(n) + deltat*(A + dbxdx)';
dfdp = zeros(n,n*(2*n+nc));
dfdp(:,1:n^2) = kron(Xt',eye(n));
dfdp(:,n^2+1:n*(2*n+nc)) = kron(xij',eye(n));
dfdp = deltat*dfdp';
|
function plot_varN2(params,nMode,const)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example: plot_parvar1(params, 2,200,[],100)
%
% This function plots z, beta, and the probability of them as a function of
% input parameter like sampling size, window length and bin size. For each
% plot the other two parameters are kept fixed.
% The plot shows the distribution of values over all the grid point, the
% mean and the error as a standard deviation.
%
% Input
% params structural array from
% nMode parameter to plot z, beta, prob's against. Choose
% 1 : Sampling Volume, N
% 2 : Window Length, Tw
% 3 : Bin Size, Tbin
% vN Vector with range of sample sizes
% vTw Vector with range of window length
% vTbin Vector with range of bin size
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Author:
% van Stiphout, Thomas, [email protected]
%
% Created on 16.08.2007
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% prepare x-labels and ...
% sXLabel='Sampling Volume, N';
switch nMode
case 1
%prepare calculation
nPos1=1;
vVariable2=params.vTw; nPos2=2;
vVariable3=params.vTbin(const); nPos3=3;
% perform calculation
calc_plotval
% prepare plotting
sXLabel='Sampling Volume, N';
sName=sprintf('z(N,Tw) - const. Tbin=%4.1f',vVariable3);
sPrint=sprintf('RatesfN_Tw_const_Tbin-%03.0f.png',vVariable3);
plot_values
case 2
%prepare calculation
nPos1=1;
vVariable2=params.vTbin;nPos2=3;
vVariable3=params.vTw(const); nPos3=2;
% perform calculation
calc_plotval;
% prepare plotting
sXLabel='Sampling Volume, N';
sName=sprintf('z(N,Tbin) - const. Tw=%4.1f',vVariable3);
sPrint=sprintf('RatesfN_Tbin_const_Tw-%03.0f.png',vVariable3);
plot_values;
case 3
%prepare calculation
nPos1=2;
vVariable2=params.vN;nPos2=1;
vVariable3=params.vTbin(const); nPos3=3;
% perform calculation
calc_plotval;
% prepare plotting
sXLabel='Sampling Volume, Tw';
sName=sprintf('z(Tw,N) - const. Tbin=%4.1f',vVariable3);
sPrint=sprintf('RatesfTw_N_const_Tbin-%03.0f.png',vVariable3);
plot_values;
case 4
%prepare calculation
nPos1=2;
vVariable2=params.vTbin;nPos2=3;
vVariable3=params.vN(const); nPos3=1;
% perform calculation
calc_plotval;
% prepare plotting
sXLabel='Sampling Volume, Tw';
sName=sprintf('z(Tw,Tbin) - const. N=%4.1f',vVariable3);
sPrint=sprintf('RatesfTw_Tbin_const_N-%03.0f.png',vVariable3);
plot_values;
case 5
%prepare calculation
nPos1=3;
vVariable2=params.vN; nPos2=1;
vVariable3=params.vTw(const); nPos3=2;
% perform calculation
calc_plotval;
% prepare plotting
sXLabel='Sampling Volume, Tbin';
sName=sprintf('z(Tbin,N) - const. Tw=%4.1f',vVariable3);
sPrint=sprintf('RatesfTbin_N_const_Tw-%03.0f.png',vVariable3);
plot_values;
case 6
%prepare calculation
nPos1=3;
vVariable2=params.vTw; nPos2=2;
vVariable3=params.vN(const); nPos3=1;
% perform calculation
calc_plotval;
% prepare plotting
sXLabel='Sampling Volume, Tbin';
sName=sprintf('z(Tbin,Tw) - const. N=%4.1f',vVariable3);
sPrint=sprintf('RatesfTbin_Tw_const_N-%03.0f.png',vVariable3);
plot_values;
end % end switch
function calc_plotval
for ii=1:size(vVariable2,1)
vSel=logical((params.mVar(:,nPos2) == vVariable2(ii)).*(params.mVar(:,nPos3)==vVariable3));
params.mVar(vSel,:);
mN.V1=params.mVar(vSel,nPos1);
for i=1:size(params.mResult_,1)
mN.V2.Z{ii}(:,i)=squeeze(params.mResult_(i,1,vSel));
mN.V2.B{ii}(:,i)=squeeze(params.mResult_(i,2,vSel));
mN.V2.pZ{ii}(:,i)=squeeze(params.mResult_(i,3,vSel));
mN.V2.pB{ii}(:,i)=squeeze(params.mResult_(i,4,vSel));
end % end for i
mN.V2.Z_mean(:,ii)=mean(mN.V2.Z{ii},2);
mN.V2.B_mean(:,ii)=mean(mN.V2.B{ii},2);
mN.V2.pZ_mean(:,ii)=mean(mN.V2.pZ{ii},2);
mN.V2.pB_mean(:,ii)=mean(mN.V2.pB{ii},2);
mN.V2.Z_std(:,ii)=std(mN.V2.Z{ii},0,2);
mN.V2.B_std(:,ii)=std(mN.V2.B{ii},0,2);
mN.V2.pZ_std(:,ii)=std(mN.V2.pZ{ii},0,2);
mN.V2.pB_std(:,ii)=std(mN.V2.pB{ii},0,2);
end % end for ii
end % end function calc_plotval
function plot_values
figure_w_normalized_uicontrolunits('Position',[100 25 400 600],'Name',sName);
mPlot{1}.X1=mN.V1
mPlot{1}.Y1=mN.V2.Z_mean;
mPlot{1}.Y2=mN.V2.Z_mean-mN.V2.Z_std;
mPlot{1}.Y3=mN.V2.Z_mean+mN.V2.Z_std;
mPlot{2}.X1=mN.V1;
mPlot{2}.Y1=mN.V2.B_mean;
mPlot{2}.Y2=mN.V2.B_mean-mN.V2.B_std;
mPlot{2}.Y3=mN.V2.B_mean+mN.V2.B_std;
mPlot{3}.X1=mN.V1;
mPlot{3}.Y1=mN.V2.pZ_mean;
mPlot{3}.Y2=mN.V2.pZ_mean-mN.V2.pZ_std;
mPlot{3}.Y3=mN.V2.pZ_mean+mN.V2.pZ_std;
mPlot{4}.X1=mN.V1;
mPlot{4}.Y1=mN.V2.pB_mean;
mPlot{4}.Y2=mN.V2.pB_mean-mN.V2.pB_std;
mPlot{4}.Y3=mN.V2.pB_mean+mN.V2.pB_std;
sTitle=[cellstr(char('z(lta)-variation')), cellstr(char('p(Z)-variation')),...
cellstr(char('\beta-variation')), cellstr(char('p(\beta)-variation'))];
sYLabel=[cellstr(char('z(lta)')),cellstr(char('p(Z)')),cellstr(char('\beta')), cellstr(char('p(\beta)'))];
for pp=1:4
subplot(2,2,pp);
hold on;plot(mPlot{pp}.X1,mPlot{pp}.Y1,'x--','LineWidth',2,'MarkerSize',12)
if pp==1 legend(num2str(vVariable2)); end
hold on;plot(mPlot{pp}.X1,mPlot{pp}.Y2 ,'+:','LineWidth',1)
% hold on;plot(mPlot{pp}.X1,mPlot{pp}.Y2,'+')
hold on;plot(mPlot{pp}.X1,mPlot{pp}.Y3,':+','LineWidth',1)
% hold on;plot(mPlot{pp}.X1,mPlot{pp}.Y3,'+')
title(sTitle(pp));
ylabel(sYLabel(pp));
xlabel(sXLabel);
end % end for pp
end % end plot_values
mN;
sPrint=sprintf('print -dpng %s',sPrint);
eval(sPrint)
end % end function
%
% xlabel(sXLabel);
% switch nSubplot
% case 1
% title('z(lta)-variation');
% ylabel('z(lta)');
% case 2
% title('p(z)-variation');
% ylabel('p(z)');
% case 3
% title('\beta-variation');
% ylabel('\beta');
% case 4
% title('p(\beta)-variation');
% ylabel('p(\beta)');
% end
% subplot(2,2,nSubplot);
% Y=mean(squeeze(params.mResult_(:,nSubplot,vSel)));
% E=std(squeeze(params.mResult_(:,nSubplot,vSel)));
% errorbar(params.mVar(vSel,nMode),Y,E,'xr','MarkerSize',10,'LineWidth',1);
% end
|
[STATEMENT]
lemma subbdt_ex:
"\<And> bdt1. \<lbrakk> (Node lst stp rst) <= t; bdt t var = Some bdt1\<rbrakk>
\<Longrightarrow> \<exists> bdt2. bdt (Node lst stp rst) var = Some bdt2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t; bdt t var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
proof (induct t)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>bdt1. \<lbrakk>Node lst stp rst \<le> Tip; bdt Tip var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<And>t1 x2 t2 bdt1. \<lbrakk>\<And>bdt1. \<lbrakk>Node lst stp rst \<le> t1; bdt t1 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t2; bdt t2 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; Node lst stp rst \<le> Node t1 x2 t2; bdt (Node t1 x2 t2) var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
case Tip
[PROOF STATE]
proof (state)
this:
Node lst stp rst \<le> Tip
bdt Tip var = Some bdt1
goal (2 subgoals):
1. \<And>bdt1. \<lbrakk>Node lst stp rst \<le> Tip; bdt Tip var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<And>t1 x2 t2 bdt1. \<lbrakk>\<And>bdt1. \<lbrakk>Node lst stp rst \<le> t1; bdt t1 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t2; bdt t2 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; Node lst stp rst \<le> Node t1 x2 t2; bdt (Node t1 x2 t2) var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Tip
bdt Tip var = Some bdt1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Tip
bdt Tip var = Some bdt1
goal (1 subgoal):
1. \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
by (simp add: le_dag_def)
[PROOF STATE]
proof (state)
this:
\<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal (1 subgoal):
1. \<And>t1 x2 t2 bdt1. \<lbrakk>\<And>bdt1. \<lbrakk>Node lst stp rst \<le> t1; bdt t1 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t2; bdt t2 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; Node lst stp rst \<le> Node t1 x2 t2; bdt (Node t1 x2 t2) var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>t1 x2 t2 bdt1. \<lbrakk>\<And>bdt1. \<lbrakk>Node lst stp rst \<le> t1; bdt t1 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t2; bdt t2 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; Node lst stp rst \<le> Node t1 x2 t2; bdt (Node t1 x2 t2) var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
case (Node lt p rt)
[PROOF STATE]
proof (state)
this:
\<lbrakk>Node lst stp rst \<le> lt; bdt lt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
\<lbrakk>Node lst stp rst \<le> rt; bdt rt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
goal (1 subgoal):
1. \<And>t1 x2 t2 bdt1. \<lbrakk>\<And>bdt1. \<lbrakk>Node lst stp rst \<le> t1; bdt t1 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t2; bdt t2 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; Node lst stp rst \<le> Node t1 x2 t2; bdt (Node t1 x2 t2) var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
note pNode=this
[PROOF STATE]
proof (state)
this:
\<lbrakk>Node lst stp rst \<le> lt; bdt lt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
\<lbrakk>Node lst stp rst \<le> rt; bdt rt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
goal (1 subgoal):
1. \<And>t1 x2 t2 bdt1. \<lbrakk>\<And>bdt1. \<lbrakk>Node lst stp rst \<le> t1; bdt t1 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; \<And>bdt1. \<lbrakk>Node lst stp rst \<le> t2; bdt t2 var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2; Node lst stp rst \<le> Node t1 x2 t2; bdt (Node t1 x2 t2) var = Some bdt1\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
proof (cases "Node lst stp rst = Node lt p rt")
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. Node lst stp rst = Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Node lst stp rst = Node lt p rt
goal (2 subgoals):
1. Node lst stp rst = Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
with Node.prems
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst = Node lt p rt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst = Node lt p rt
goal (1 subgoal):
1. \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal (1 subgoal):
1. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
assume " Node lst stp rst \<noteq> Node lt p rt"
[PROOF STATE]
proof (state)
this:
Node lst stp rst \<noteq> Node lt p rt
goal (1 subgoal):
1. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
with Node.prems
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<noteq> Node lt p rt
[PROOF STEP]
have "Node lst stp rst < Node lt p rt"
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<noteq> Node lt p rt
goal (1 subgoal):
1. Node lst stp rst < Node lt p rt
[PROOF STEP]
apply (simp add: le_dag_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>lst = lt \<and> stp = p \<and> rst = rt \<or> Node lst stp rst < Node lt p rt; bdt (Node lt p rt) var = Some bdt1; stp = p \<longrightarrow> lst = lt \<longrightarrow> rst \<noteq> rt\<rbrakk> \<Longrightarrow> Node lst stp rst < Node lt p rt
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
Node lst stp rst < Node lt p rt
goal (1 subgoal):
1. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst < Node lt p rt
[PROOF STEP]
have in_ltrt: "Node lst stp rst <= lt \<or> Node lst stp rst <= rt"
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst < Node lt p rt
goal (1 subgoal):
1. Node lst stp rst \<le> lt \<or> Node lst stp rst \<le> rt
[PROOF STEP]
by (simp add: less_dag_Node)
[PROOF STATE]
proof (state)
this:
Node lst stp rst \<le> lt \<or> Node lst stp rst \<le> rt
goal (1 subgoal):
1. Node lst stp rst \<noteq> Node lt p rt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
proof (cases "Node lst stp rst <= lt")
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Node lst stp rst \<le> lt
goal (2 subgoals):
1. Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
note in_lt=this
[PROOF STATE]
proof (state)
this:
Node lst stp rst \<le> lt
goal (2 subgoals):
1. Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
from Node.prems
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
[PROOF STEP]
have lbdt_def: "\<exists> lbdt. bdt lt var = Some lbdt"
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
goal (1 subgoal):
1. \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
proof (cases lt)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Tip\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
2. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
case Tip
[PROOF STATE]
proof (state)
this:
lt = Tip
goal (2 subgoals):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Tip\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
2. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
with Node.prems in_lt
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> lt
lt = Tip
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> lt
lt = Tip
goal (1 subgoal):
1. \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
by (simp add: le_dag_def)
[PROOF STATE]
proof (state)
this:
\<exists>lbdt. bdt lt var = Some lbdt
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
case (Node llt l rlt)
[PROOF STATE]
proof (state)
this:
lt = Node llt l rlt
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
note lNode=this
[PROOF STATE]
proof (state)
this:
lt = Node llt l rlt
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; lt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
proof (cases rt)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. rt = Tip \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
2. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
case Tip
[PROOF STATE]
proof (state)
this:
rt = Tip
goal (2 subgoals):
1. rt = Tip \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
2. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
note rNode=this
[PROOF STATE]
proof (state)
this:
rt = Tip
goal (2 subgoals):
1. rt = Tip \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
2. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
with lNode Node.prems
[PROOF STATE]
proof (chain)
picking this:
lt = Node llt l rlt
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
rt = Tip
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lt = Node llt l rlt
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
rt = Tip
goal (1 subgoal):
1. \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>lbdt. bdt lt var = Some lbdt
goal (1 subgoal):
1. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
case (Node lrt r rrt)
[PROOF STATE]
proof (state)
this:
rt = Node lrt r rrt
goal (1 subgoal):
1. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
note rNode=this
[PROOF STATE]
proof (state)
this:
rt = Node lrt r rrt
goal (1 subgoal):
1. \<And>x21 x22 x23. rt = Node x21 x22 x23 \<Longrightarrow> \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
with lNode Node.prems
[PROOF STATE]
proof (chain)
picking this:
lt = Node llt l rlt
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
rt = Node lrt r rrt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lt = Node llt l rlt
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
rt = Node lrt r rrt
goal (1 subgoal):
1. \<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
by (simp split: option.splits)
[PROOF STATE]
proof (state)
this:
\<exists>lbdt. bdt lt var = Some lbdt
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>lbdt. bdt lt var = Some lbdt
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>lbdt. bdt lt var = Some lbdt
goal (2 subgoals):
1. Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>lbdt. bdt lt var = Some lbdt
[PROOF STEP]
obtain lbdt where "bdt lt var = Some lbdt"
[PROOF STATE]
proof (prove)
using this:
\<exists>lbdt. bdt lt var = Some lbdt
goal (1 subgoal):
1. (\<And>lbdt. bdt lt var = Some lbdt \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
bdt lt var = Some lbdt
goal (2 subgoals):
1. Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
2. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
with Node.prems in_lt
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> lt
bdt lt var = Some lbdt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> lt
bdt lt var = Some lbdt
goal (1 subgoal):
1. \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; Node lst stp rst \<le> lt; bdt lt var = Some lbdt\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
apply (rule Node.hyps)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; Node lst stp rst \<le> lt; bdt lt var = Some lbdt\<rbrakk> \<Longrightarrow> Node lst stp rst \<le> lt
2. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; Node lst stp rst \<le> lt; bdt lt var = Some lbdt\<rbrakk> \<Longrightarrow> bdt lt var = Some ?bdt1.4
[PROOF STEP]
apply assumption+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
assume " \<not> Node lst stp rst \<le> lt"
[PROOF STATE]
proof (state)
this:
\<not> Node lst stp rst \<le> lt
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
with in_ltrt
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> lt \<or> Node lst stp rst \<le> rt
\<not> Node lst stp rst \<le> lt
[PROOF STEP]
have in_rt: "Node lst stp rst <= rt"
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> lt \<or> Node lst stp rst \<le> rt
\<not> Node lst stp rst \<le> lt
goal (1 subgoal):
1. Node lst stp rst \<le> rt
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Node lst stp rst \<le> rt
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
from Node.hyps
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>Node lst stp rst \<le> lt; bdt lt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
\<lbrakk>Node lst stp rst \<le> rt; bdt rt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
have hyp2: "\<And> rbdt. \<lbrakk>Node lst stp rst <= rt; bdt rt var = Some rbdt\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Node lst stp rst \<le> lt; bdt lt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
\<lbrakk>Node lst stp rst \<le> rt; bdt rt var = Some ?bdt1.0\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal (1 subgoal):
1. \<And>rbdt. \<lbrakk>Node lst stp rst \<le> rt; bdt rt var = Some rbdt\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lbrakk>Node lst stp rst \<le> rt; bdt rt var = Some ?rbdt\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
from Node.prems
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
[PROOF STEP]
have rbdt_def: "\<exists> rbdt. bdt rt var = Some rbdt"
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
goal (1 subgoal):
1. \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
proof (cases rt)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Tip\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
2. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
case Tip
[PROOF STATE]
proof (state)
this:
rt = Tip
goal (2 subgoals):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Tip\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
2. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
with Node.prems in_rt
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> rt
rt = Tip
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> rt
rt = Tip
goal (1 subgoal):
1. \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
by (simp add: le_dag_def)
[PROOF STATE]
proof (state)
this:
\<exists>rbdt. bdt rt var = Some rbdt
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
case (Node lrt l rrt)
[PROOF STATE]
proof (state)
this:
rt = Node lrt l rrt
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
note rNode=this
[PROOF STATE]
proof (state)
this:
rt = Node lrt l rrt
goal (1 subgoal):
1. \<And>x21 x22 x23. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; rt = Node x21 x22 x23\<rbrakk> \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
proof (cases lt)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. lt = Tip \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
2. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
case Tip
[PROOF STATE]
proof (state)
this:
lt = Tip
goal (2 subgoals):
1. lt = Tip \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
2. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
note lNode=this
[PROOF STATE]
proof (state)
this:
lt = Tip
goal (2 subgoals):
1. lt = Tip \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
2. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
with rNode Node.prems
[PROOF STATE]
proof (chain)
picking this:
rt = Node lrt l rrt
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
lt = Tip
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rt = Node lrt l rrt
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
lt = Tip
goal (1 subgoal):
1. \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>rbdt. bdt rt var = Some rbdt
goal (1 subgoal):
1. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
case (Node lrt r rrt)
[PROOF STATE]
proof (state)
this:
lt = Node lrt r rrt
goal (1 subgoal):
1. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
note lNode=this
[PROOF STATE]
proof (state)
this:
lt = Node lrt r rrt
goal (1 subgoal):
1. \<And>x21 x22 x23. lt = Node x21 x22 x23 \<Longrightarrow> \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
with rNode Node.prems
[PROOF STATE]
proof (chain)
picking this:
rt = Node lrt__ l rrt__
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
lt = Node lrt r rrt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rt = Node lrt__ l rrt__
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
lt = Node lrt r rrt
goal (1 subgoal):
1. \<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
by (simp split: option.splits)
[PROOF STATE]
proof (state)
this:
\<exists>rbdt. bdt rt var = Some rbdt
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>rbdt. bdt rt var = Some rbdt
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>rbdt. bdt rt var = Some rbdt
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>rbdt. bdt rt var = Some rbdt
[PROOF STEP]
obtain rbdt where "bdt rt var = Some rbdt"
[PROOF STATE]
proof (prove)
using this:
\<exists>rbdt. bdt rt var = Some rbdt
goal (1 subgoal):
1. (\<And>rbdt. bdt rt var = Some rbdt \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
bdt rt var = Some rbdt
goal (1 subgoal):
1. \<not> Node lst stp rst \<le> lt \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
with Node.prems in_rt
[PROOF STATE]
proof (chain)
picking this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> rt
bdt rt var = Some rbdt
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Node lst stp rst \<le> Node lt p rt
bdt (Node lt p rt) var = Some bdt1
Node lst stp rst \<le> rt
bdt rt var = Some rbdt
goal (1 subgoal):
1. \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; Node lst stp rst \<le> rt; bdt rt var = Some rbdt\<rbrakk> \<Longrightarrow> \<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
[PROOF STEP]
apply (rule hyp2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; Node lst stp rst \<le> rt; bdt rt var = Some rbdt\<rbrakk> \<Longrightarrow> Node lst stp rst \<le> rt
2. \<lbrakk>Node lst stp rst \<le> Node lt p rt; bdt (Node lt p rt) var = Some bdt1; Node lst stp rst \<le> rt; bdt rt var = Some rbdt\<rbrakk> \<Longrightarrow> bdt rt var = Some ?rbdt4
[PROOF STEP]
apply assumption+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>bdt2. bdt (Node lst stp rst) var = Some bdt2
goal:
No subgoals!
[PROOF STEP]
qed |
It is the characteristic of mind to be capable of improvement. An individual surrenders the best attribute of man, the moment he resolves to adhere to certain fixed principles, for reasons not now present to his mind, but which formerly were.1 The instant in which he shuts upon himself the career of enquiry is the instant of his intellectual decease. He is no longer a man; he is the ghost of departed man. 'There can be no scheme more egregiously stamped with folly than that of separating a tenet from the evidence upon which its validity depends. If I cease from the habit of being able to recall this evidence, my belief is no longer a perception, but a prejudice: it may influence me like a prejudice; but cannot animate me like a real apprehension of truth. The difference between the man thus guided and the man that keeps his mind perpetually alive is the difference between cowardice and fortitude. The man who is, in the best sense, an intellectual being delights to recollect the reasons that have convinced him, to repeat them to others, that they may produce conviction in them, and stand more distinct and explicit in his own mind; and, he adds to this a willingness to examine objections, because he takes no pride in consistent error. The man who is not capable of this salutary exercise, to what valuable purpose can he be employed? Hence it appears that no vice can be more destructive than that which teaches us to regard any judgement as final, and not open to review. The same principle that applies to individuals applies to communities, There is no proposition at present apprehended to be true so valuable as to justify the introduction of an establishment for the purpose of inculcating it on mankind. Refer them to reading, to conversation, to meditation; but teach them neither creeds nor catechisms, either moral or political.
1Book 1, Chap. V, p. 127.
To Book VI, Chapter IX. |
lemma (in normalization_semidom) associatedE2: assumes "normalize a = normalize b" obtains u where "is_unit u" "b = u * a" |
theory Ex1_6
imports Main
begin
primrec sum :: "nat list \<Rightarrow> nat" where
"sum [] = 0"|
"sum (x#xs) = x + sum xs"
primrec flatten :: "'a list list \<Rightarrow> 'a list" where
"flatten [] = []"|
"flatten (x#xs) = x @ flatten xs"
lemma "sum [2::nat ,4,8] = 14" by simp
lemma "flatten [[2::nat, 3], [4,5], [7,9]] = [2,3,4,5,7,9]" by simp
lemma "length (flatten xs) = sum (map length xs)" by (induct xs; simp)
lemma sum_append : "sum (xs @ ys) = sum xs + sum ys" by (induct xs; simp)
lemma flatten_append : "flatten (xs @ ys) = flatten xs @ flatten ys" by (induct xs; simp)
lemma "flatten (map rev (rev xs)) = rev (flatten xs)" by (induct xs; simp add : flatten_append)
lemma "flatten (rev (map rev xs)) = rev (flatten xs)" by (induct xs; simp add : flatten_append)
lemma "list_all (list_all P) xs = list_all P (flatten xs)" by (induct xs; simp)
(*lemma "flatten (rev xs) = flatten xs" quickcheck *)
lemma "flatten (rev [[1::nat,2],[3::nat,4]]) = flatten [[1::nat,2],[3::nat,4]] \<Longrightarrow> False" by simp
lemma "sum (rev xs) = sum xs" by (induct xs; simp add : sum_append)
lemma "list_all (op \<le> 1) xs \<longrightarrow> length xs \<le> sum xs" by (induct xs; auto)
primrec list_exists :: "('a \<Rightarrow> bool) \<Rightarrow> ('a list \<Rightarrow> bool)" where
"list_exists _ [] = False"|
"list_exists P (x#xs) = (P x \<or> list_exists P xs)"
lemma "list_exists (\<lambda>n . n < 3 ) [4::nat , 3, 7] = False" by simp
lemma "list_exists (\<lambda>n . n < 4 ) [4::nat , 3, 7] = True" by simp
lemma list_exists_append : "list_exists P (xs @ ys) = (list_exists P xs \<or> list_exists P ys)" by (induct xs; simp)
lemma "list_exists (list_exists P) xs = list_exists P (flatten xs)" by (induct xs; simp add : list_exists_append)
definition "list_exists2 P ls = (\<not> (list_all (\<lambda>x . \<not>(P x))) ls)"
lemma "list_exists P xs = list_exists2 P xs" by (induct xs; simp add : list_exists2_def) |
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Aaron Anderson
! This file was ported from Lean 3 source module data.finsupp.order
! leanprover-community/mathlib commit fac369018417f980cec5fcdafc766a69f88d8cfe
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Data.Finsupp.Defs
/-!
# Pointwise order on finitely supported functions
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file lifts order structures on `α` to `ι →₀ α`.
## Main declarations
* `finsupp.order_embedding_to_fun`: The order embedding from finitely supported functions to
functions.
* `finsupp.order_iso_multiset`: The order isomorphism between `ℕ`-valued finitely supported
functions and multisets.
-/
noncomputable section
open BigOperators
open Finset
variable {ι α : Type _}
namespace Finsupp
/-! ### Order structures -/
section Zero
variable [Zero α]
section LE
variable [LE α]
instance : LE (ι →₀ α) :=
⟨fun f g => ∀ i, f i ≤ g i⟩
/- warning: finsupp.le_def -> Finsupp.le_def is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : LE.{u2} α] {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2) f g) (forall (i : ι), LE.le.{u2} α _inst_2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) g i))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : LE.{u1} α] {f : Finsupp.{u2, u1} ι α _inst_1} {g : Finsupp.{u2, u1} ι α _inst_1}, Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α _inst_1) (Finsupp.instLEFinsupp.{u2, u1} ι α _inst_1 _inst_2) f g) (forall (i : ι), LE.le.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) _inst_2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α _inst_1) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α _inst_1) g i))
Case conversion may be inaccurate. Consider using '#align finsupp.le_def Finsupp.le_defₓ'. -/
theorem le_def {f g : ι →₀ α} : f ≤ g ↔ ∀ i, f i ≤ g i :=
Iff.rfl
#align finsupp.le_def Finsupp.le_def
#print Finsupp.orderEmbeddingToFun /-
/-- The order on `finsupp`s over a partial order embeds into the order on functions -/
def orderEmbeddingToFun : (ι →₀ α) ↪o (ι → α)
where
toFun f := f
inj' f g h :=
Finsupp.ext fun i => by
dsimp at h
rw [h]
map_rel_iff' a b := (@le_def _ _ _ _ a b).symm
#align finsupp.order_embedding_to_fun Finsupp.orderEmbeddingToFun
-/
/- warning: finsupp.order_embedding_to_fun_apply -> Finsupp.orderEmbeddingToFun_apply is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : LE.{u2} α] {f : Finsupp.{u1, u2} ι α _inst_1} {i : ι}, Eq.{succ u2} α (coeFn.{succ (max u1 u2), succ (max u1 u2)} (OrderEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2) (Pi.hasLe.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2))) (fun (_x : RelEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2)) (LE.le.{max u1 u2} (ι -> α) (Pi.hasLe.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)))) => (Finsupp.{u1, u2} ι α _inst_1) -> ι -> α) (RelEmbedding.hasCoeToFun.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2)) (LE.le.{max u1 u2} (ι -> α) (Pi.hasLe.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)))) (Finsupp.orderEmbeddingToFun.{u1, u2} ι α _inst_1 _inst_2) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i)
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : LE.{u1} α] {f : Finsupp.{u2, u1} ι α _inst_1} {i : ι}, Eq.{succ u1} α (FunLike.coe.{succ (max u1 u2), succ (max u1 u2), succ (max u1 u2)} (Function.Embedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α)) (Finsupp.{u2, u1} ι α _inst_1) (fun (_x : Finsupp.{u2, u1} ι α _inst_1) => (fun ([email protected]._hyg.19 : Finsupp.{u2, u1} ι α _inst_1) => ι -> α) _x) (EmbeddingLike.toFunLike.{succ (max u1 u2), succ (max u1 u2), succ (max u1 u2)} (Function.Embedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α)) (Finsupp.{u2, u1} ι α _inst_1) (ι -> α) (Function.instEmbeddingLikeEmbedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α))) (RelEmbedding.toEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α) (fun ([email protected]._hyg.680 : Finsupp.{u2, u1} ι α _inst_1) ([email protected]._hyg.682 : Finsupp.{u2, u1} ι α _inst_1) => LE.le.{max u1 u2} (Finsupp.{u2, u1} ι α _inst_1) (Finsupp.instLEFinsupp.{u2, u1} ι α _inst_1 _inst_2) [email protected]._hyg.680 [email protected]._hyg.682) (fun ([email protected]._hyg.695 : ι -> α) ([email protected]._hyg.697 : ι -> α) => LE.le.{max u2 u1} (ι -> α) (Pi.hasLe.{u2, u1} ι (fun ([email protected]._hyg.129 : ι) => α) (fun (i : ι) => _inst_2)) [email protected]._hyg.695 [email protected]._hyg.697) (Finsupp.orderEmbeddingToFun.{u2, u1} ι α _inst_1 _inst_2)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α _inst_1) f i)
Case conversion may be inaccurate. Consider using '#align finsupp.order_embedding_to_fun_apply Finsupp.orderEmbeddingToFun_applyₓ'. -/
@[simp]
theorem orderEmbeddingToFun_apply {f : ι →₀ α} {i : ι} : orderEmbeddingToFun f i = f i :=
rfl
#align finsupp.order_embedding_to_fun_apply Finsupp.orderEmbeddingToFun_apply
end LE
section Preorder
variable [Preorder α]
instance : Preorder (ι →₀ α) :=
{ Finsupp.hasLe with
le_refl := fun f i => le_rfl
le_trans := fun f g h hfg hgh i => (hfg i).trans (hgh i) }
/- warning: finsupp.monotone_to_fun -> Finsupp.monotone_toFun is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : Preorder.{u2} α], Monotone.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (Finsupp.preorder.{u1, u2} ι α _inst_1 _inst_2) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)) (Finsupp.toFun.{u1, u2} ι α _inst_1)
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : Preorder.{u1} α], Monotone.{max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α) (Finsupp.preorder.{u2, u1} ι α _inst_1 _inst_2) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)) (Finsupp.toFun.{u2, u1} ι α _inst_1)
Case conversion may be inaccurate. Consider using '#align finsupp.monotone_to_fun Finsupp.monotone_toFunₓ'. -/
theorem monotone_toFun : Monotone (Finsupp.toFun : (ι →₀ α) → ι → α) := fun f g h a => le_def.1 h a
#align finsupp.monotone_to_fun Finsupp.monotone_toFun
end Preorder
instance [PartialOrder α] : PartialOrder (ι →₀ α) :=
{ Finsupp.preorder with le_antisymm := fun f g hfg hgf => ext fun i => (hfg i).antisymm (hgf i) }
instance [SemilatticeInf α] : SemilatticeInf (ι →₀ α) :=
{ Finsupp.partialOrder with
inf := zipWith (· ⊓ ·) inf_idem
inf_le_left := fun f g i => inf_le_left
inf_le_right := fun f g i => inf_le_right
le_inf := fun f g i h1 h2 s => le_inf (h1 s) (h2 s) }
/- warning: finsupp.inf_apply -> Finsupp.inf_apply is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeInf.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeInf.toHasInf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeInf.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Inf.inf.{u2} α (SemilatticeInf.toHasInf.{u2} α _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) g i))
but is expected to have type
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeInf.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} ((fun ([email protected]._hyg.779 : ι) => α) i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeInf.toInf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeInf.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Inf.inf.{u2} ((fun ([email protected]._hyg.779 : ι) => α) i) (SemilatticeInf.toInf.{u2} ((fun ([email protected]._hyg.779 : ι) => α) i) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) f i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) g i))
Case conversion may be inaccurate. Consider using '#align finsupp.inf_apply Finsupp.inf_applyₓ'. -/
@[simp]
theorem inf_apply [SemilatticeInf α] {i : ι} {f g : ι →₀ α} : (f ⊓ g) i = f i ⊓ g i :=
rfl
#align finsupp.inf_apply Finsupp.inf_apply
instance [SemilatticeSup α] : SemilatticeSup (ι →₀ α) :=
{ Finsupp.partialOrder with
sup := zipWith (· ⊔ ·) sup_idem
le_sup_left := fun f g i => le_sup_left
le_sup_right := fun f g i => le_sup_right
sup_le := fun f g h hf hg i => sup_le (hf i) (hg i) }
/- warning: finsupp.sup_apply -> Finsupp.sup_apply is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeSup.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeSup.toHasSup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeSup.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Sup.sup.{u2} α (SemilatticeSup.toHasSup.{u2} α _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) g i))
but is expected to have type
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeSup.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} ((fun ([email protected]._hyg.779 : ι) => α) i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeSup.toSup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeSup.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Sup.sup.{u2} ((fun ([email protected]._hyg.779 : ι) => α) i) (SemilatticeSup.toSup.{u2} ((fun ([email protected]._hyg.779 : ι) => α) i) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) f i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) g i))
Case conversion may be inaccurate. Consider using '#align finsupp.sup_apply Finsupp.sup_applyₓ'. -/
@[simp]
theorem sup_apply [SemilatticeSup α] {i : ι} {f g : ι →₀ α} : (f ⊔ g) i = f i ⊔ g i :=
rfl
#align finsupp.sup_apply Finsupp.sup_apply
#print Finsupp.lattice /-
instance lattice [Lattice α] : Lattice (ι →₀ α) :=
{ Finsupp.semilatticeInf, Finsupp.semilatticeSup with }
#align finsupp.lattice Finsupp.lattice
-/
end Zero
/-! ### Algebraic order structures -/
instance [OrderedAddCommMonoid α] : OrderedAddCommMonoid (ι →₀ α) :=
{ Finsupp.addCommMonoid, Finsupp.partialOrder with
add_le_add_left := fun a b h c s => add_le_add_left (h s) (c s) }
instance [OrderedCancelAddCommMonoid α] : OrderedCancelAddCommMonoid (ι →₀ α) :=
{ Finsupp.orderedAddCommMonoid with
le_of_add_le_add_left := fun f g i h s => le_of_add_le_add_left (h s) }
instance [OrderedAddCommMonoid α] [ContravariantClass α α (· + ·) (· ≤ ·)] :
ContravariantClass (ι →₀ α) (ι →₀ α) (· + ·) (· ≤ ·) :=
⟨fun f g h H x => le_of_add_le_add_left <| H x⟩
section CanonicallyOrderedAddMonoid
variable [CanonicallyOrderedAddMonoid α]
instance : OrderBot (ι →₀ α) where
bot := 0
bot_le := by simp only [le_def, coe_zero, Pi.zero_apply, imp_true_iff, zero_le]
/- warning: finsupp.bot_eq_zero -> Finsupp.bot_eq_zero is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α], Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Bot.bot.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (OrderBot.toHasBot.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Finsupp.orderBot.{u1, u2} ι α _inst_1))) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α], Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Bot.bot.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (OrderBot.toBot.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.orderBot.{u2, u1} ι α _inst_1))) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))
Case conversion may be inaccurate. Consider using '#align finsupp.bot_eq_zero Finsupp.bot_eq_zeroₓ'. -/
protected theorem bot_eq_zero : (⊥ : ι →₀ α) = 0 :=
rfl
#align finsupp.bot_eq_zero Finsupp.bot_eq_zero
/- warning: finsupp.add_eq_zero_iff -> Finsupp.add_eq_zero_iff is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))), Iff (Eq.{succ (max u1 u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (HAdd.hAdd.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHAdd.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.add.{u1, u2} ι α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f g) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))) (And (Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))) (Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))), Iff (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHAdd.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.add.{u2, u1} ι α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))) f g) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))) (And (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))) (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))))
Case conversion may be inaccurate. Consider using '#align finsupp.add_eq_zero_iff Finsupp.add_eq_zero_iffₓ'. -/
@[simp]
theorem add_eq_zero_iff (f g : ι →₀ α) : f + g = 0 ↔ f = 0 ∧ g = 0 := by simp [ext_iff, forall_and]
#align finsupp.add_eq_zero_iff Finsupp.add_eq_zero_iff
/- warning: finsupp.le_iff' -> Finsupp.le_iff' is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) {s : Finset.{u1} ι}, (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f) s) -> (Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f g) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g i))))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) {s : Finset.{u2} ι}, (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f) s) -> (Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f g) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (Preorder.toLE.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (PartialOrder.toPreorder.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g i))))
Case conversion may be inaccurate. Consider using '#align finsupp.le_iff' Finsupp.le_iff'ₓ'. -/
theorem le_iff' (f g : ι →₀ α) {s : Finset ι} (hf : f.support ⊆ s) : f ≤ g ↔ ∀ i ∈ s, f i ≤ g i :=
⟨fun h s hs => h s, fun h s => by
classical exact
if H : s ∈ f.support then h s (hf H) else (not_mem_support_iff.1 H).symm ▸ zero_le (g s)⟩
#align finsupp.le_iff' Finsupp.le_iff'
/- warning: finsupp.le_iff -> Finsupp.le_iff is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))), Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f g) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f)) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g i)))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))), Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f g) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f)) -> (LE.le.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (Preorder.toLE.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (PartialOrder.toPreorder.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun ([email protected]._hyg.779 : ι) => α) i) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g i)))
Case conversion may be inaccurate. Consider using '#align finsupp.le_iff Finsupp.le_iffₓ'. -/
theorem le_iff (f g : ι →₀ α) : f ≤ g ↔ ∀ i ∈ f.support, f i ≤ g i :=
le_iff' f g <| Subset.refl _
#align finsupp.le_iff Finsupp.le_iff
/- warning: finsupp.decidable_le -> Finsupp.decidableLE is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : DecidableRel.{succ u2} α (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))], DecidableRel.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))))
but is expected to have type
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : DecidableRel.{succ u2} α (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))], DecidableRel.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (LE.le.{max u2 u1} (Finsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Finsupp.instLEFinsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))))
Case conversion may be inaccurate. Consider using '#align finsupp.decidable_le Finsupp.decidableLEₓ'. -/
instance decidableLE [DecidableRel (@LE.le α _)] : DecidableRel (@LE.le (ι →₀ α) _) := fun f g =>
decidable_of_iff _ (le_iff f g).symm
#align finsupp.decidable_le Finsupp.decidableLE
/- warning: finsupp.single_le_iff -> Finsupp.single_le_iff is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] {i : ι} {x : α} {f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))}, Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i x) f) (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) x (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f i))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] {i : ι} {x : α} {f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))}, Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i x) f) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) x (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f i))
Case conversion may be inaccurate. Consider using '#align finsupp.single_le_iff Finsupp.single_le_iffₓ'. -/
@[simp]
theorem single_le_iff {i : ι} {x : α} {f : ι →₀ α} : single i x ≤ f ↔ x ≤ f i :=
(le_iff' _ _ support_single_subset).trans <| by simp
#align finsupp.single_le_iff Finsupp.single_le_iff
variable [Sub α] [OrderedSub α] {f g : ι →₀ α} {i : ι} {a b : α}
/- warning: finsupp.tsub -> Finsupp.tsub is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2], Sub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))))
but is expected to have type
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2], Sub.{max u2 u1} (Finsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))
Case conversion may be inaccurate. Consider using '#align finsupp.tsub Finsupp.tsubₓ'. -/
/-- This is called `tsub` for truncated subtraction, to distinguish it with subtraction in an
additive group. -/
instance tsub : Sub (ι →₀ α) :=
⟨zipWith (fun m n => m - n) (tsub_self 0)⟩
#align finsupp.tsub Finsupp.tsub
instance : OrderedSub (ι →₀ α) :=
⟨fun n m k => forall_congr' fun x => tsub_le_iff_right⟩
instance : CanonicallyOrderedAddMonoid (ι →₀ α) :=
{ Finsupp.orderBot,
Finsupp.orderedAddCommMonoid with
exists_add_of_le := fun f g h => ⟨g - f, ext fun x => (add_tsub_cancel_of_le <| h x).symm⟩
le_self_add := fun f g x => le_self_add }
/- warning: finsupp.coe_tsub -> Finsupp.coe_tsub is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))), Eq.{succ (max u1 u2)} (ι -> α) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f g)) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (ι -> α) (ι -> α) (ι -> α) (instHSub.{max u1 u2} (ι -> α) (Pi.instSub.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : ι), (fun ([email protected]._hyg.779 : ι) => α) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f g)) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (forall (ᾰ : ι), (fun ([email protected]._hyg.779 : ι) => α) ᾰ) (forall (ᾰ : ι), (fun ([email protected]._hyg.779 : ι) => α) ᾰ) (forall (ᾰ : ι), (fun ([email protected]._hyg.779 : ι) => α) ᾰ) (instHSub.{max u2 u1} (forall (ᾰ : ι), (fun ([email protected]._hyg.779 : ι) => α) ᾰ) (Pi.instSub.{u2, u1} ι (fun (ᾰ : ι) => (fun ([email protected]._hyg.779 : ι) => α) ᾰ) (fun (i : ι) => _inst_2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g))
Case conversion may be inaccurate. Consider using '#align finsupp.coe_tsub Finsupp.coe_tsubₓ'. -/
@[simp]
theorem coe_tsub (f g : ι →₀ α) : ⇑(f - g) = f - g :=
rfl
#align finsupp.coe_tsub Finsupp.coe_tsub
/- warning: finsupp.tsub_apply -> Finsupp.tsub_apply is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (a : ι), Eq.{succ u2} α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f g) a) (HSub.hSub.{u2, u2, u2} α α α (instHSub.{u2} α _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g a))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (a : ι), Eq.{succ u1} ((fun ([email protected]._hyg.779 : ι) => α) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f g) a) (HSub.hSub.{u1, u1, u1} ((fun ([email protected]._hyg.779 : ι) => α) a) ((fun ([email protected]._hyg.779 : ι) => α) a) ((fun ([email protected]._hyg.779 : ι) => α) a) (instHSub.{u1} ((fun ([email protected]._hyg.779 : ι) => α) a) _inst_2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun ([email protected]._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g a))
Case conversion may be inaccurate. Consider using '#align finsupp.tsub_apply Finsupp.tsub_applyₓ'. -/
theorem tsub_apply (f g : ι →₀ α) (a : ι) : (f - g) a = f a - g a :=
rfl
#align finsupp.tsub_apply Finsupp.tsub_apply
/- warning: finsupp.single_tsub -> Finsupp.single_tsub is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] {i : ι} {a : α} {b : α}, Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i (HSub.hSub.{u2, u2, u2} α α α (instHSub.{u2} α _inst_2) a b)) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i a) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i b))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] {i : ι} {a : α} {b : α}, Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) a b)) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i a) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i b))
Case conversion may be inaccurate. Consider using '#align finsupp.single_tsub Finsupp.single_tsubₓ'. -/
@[simp]
theorem single_tsub : single i (a - b) = single i a - single i b :=
by
ext j
obtain rfl | h := eq_or_ne i j
· rw [tsub_apply, single_eq_same, single_eq_same, single_eq_same]
· rw [tsub_apply, single_eq_of_ne h, single_eq_of_ne h, single_eq_of_ne h, tsub_self]
#align finsupp.single_tsub Finsupp.single_tsub
/- warning: finsupp.support_tsub -> Finsupp.support_tsub is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] {f1 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))} {f2 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))}, HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f1 f2)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f1)
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] {f1 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))} {f2 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))}, HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f1 f2)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f1)
Case conversion may be inaccurate. Consider using '#align finsupp.support_tsub Finsupp.support_tsubₓ'. -/
theorem support_tsub {f1 f2 : ι →₀ α} : (f1 - f2).support ⊆ f1.support := by
simp (config := { contextual := true }) only [subset_iff, tsub_eq_zero_iff_le, mem_support_iff,
Ne.def, coe_tsub, Pi.sub_apply, not_imp_not, zero_le, imp_true_iff]
#align finsupp.support_tsub Finsupp.support_tsub
/- warning: finsupp.subset_support_tsub -> Finsupp.subset_support_tsub is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] [_inst_4 : DecidableEq.{succ u1} ι] {f1 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))} {f2 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))}, HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (SDiff.sdiff.{u1} (Finset.{u1} ι) (Finset.hasSdiff.{u1} ι (fun (a : ι) (b : ι) => _inst_4 a b)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f1) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f2)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f1 f2))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] [_inst_4 : DecidableEq.{succ u2} ι] {f1 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))} {f2 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))}, HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (SDiff.sdiff.{u2} (Finset.{u2} ι) (Finset.instSDiffFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_4 a b)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f1) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f2)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f1 f2))
Case conversion may be inaccurate. Consider using '#align finsupp.subset_support_tsub Finsupp.subset_support_tsubₓ'. -/
theorem subset_support_tsub [DecidableEq ι] {f1 f2 : ι →₀ α} :
f1.support \ f2.support ⊆ (f1 - f2).support := by
simp (config := { contextual := true }) [subset_iff]
#align finsupp.subset_support_tsub Finsupp.subset_support_tsub
end CanonicallyOrderedAddMonoid
section CanonicallyLinearOrderedAddMonoid
variable [CanonicallyLinearOrderedAddMonoid α]
/- warning: finsupp.support_inf -> Finsupp.support_inf is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} α] [_inst_2 : DecidableEq.{succ u1} ι] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))), Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (SemilatticeInf.toHasInf.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (Finsupp.semilatticeInf.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (Lattice.toSemilatticeInf.{u2} α (LinearOrder.toLattice.{u2} α (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u2} α _inst_1))))) f g)) (Inter.inter.{u1} (Finset.{u1} ι) (Finset.hasInter.{u1} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) f) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) g))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} α] [_inst_2 : DecidableEq.{succ u2} ι] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))), Eq.{succ u2} (Finset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (Inf.inf.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Lattice.toInf.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Finsupp.lattice.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u1} α _inst_1))))) f g)) (Inter.inter.{u2} (Finset.{u2} ι) (Finset.instInterFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) f) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) g))
Case conversion may be inaccurate. Consider using '#align finsupp.support_inf Finsupp.support_infₓ'. -/
@[simp]
theorem support_inf [DecidableEq ι] (f g : ι →₀ α) : (f ⊓ g).support = f.support ∩ g.support :=
by
ext
simp only [inf_apply, mem_support_iff, Ne.def, Finset.mem_union, Finset.mem_filter,
Finset.mem_inter]
simp only [inf_eq_min, ← nonpos_iff_eq_zero, min_le_iff, not_or]
#align finsupp.support_inf Finsupp.support_inf
/- warning: finsupp.support_sup -> Finsupp.support_sup is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} α] [_inst_2 : DecidableEq.{succ u1} ι] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))), Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (SemilatticeSup.toHasSup.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (Finsupp.semilatticeSup.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (CanonicallyLinearOrderedAddMonoid.semilatticeSup.{u2} α _inst_1))) f g)) (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) f) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) g))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} α] [_inst_2 : DecidableEq.{succ u2} ι] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))), Eq.{succ u2} (Finset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (Sup.sup.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (SemilatticeSup.toSup.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Finsupp.semilatticeSup.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u1} α _inst_1)))))) f g)) (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) f) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) g))
Case conversion may be inaccurate. Consider using '#align finsupp.support_sup Finsupp.support_supₓ'. -/
@[simp]
theorem support_sup [DecidableEq ι] (f g : ι →₀ α) : (f ⊔ g).support = f.support ∪ g.support :=
by
ext
simp only [Finset.mem_union, mem_support_iff, sup_apply, Ne.def, ← bot_eq_zero]
rw [_root_.sup_eq_bot_iff, not_and_or]
#align finsupp.support_sup Finsupp.support_sup
/- warning: finsupp.disjoint_iff -> Finsupp.disjoint_iff is a dubious translation:
lean 3 declaration is
forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} α] {f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))} {g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))}, Iff (Disjoint.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (Finsupp.partialOrder.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))) (Finsupp.orderBot.{u1, u2} ι α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)) f g) (Disjoint.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι) (Finset.orderBot.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) f) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) g))
but is expected to have type
forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} α] {f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))} {g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))}, Iff (Disjoint.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Finsupp.partialorder.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))) (Finsupp.orderBot.{u2, u1} ι α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)) f g) (Disjoint.{u2} (Finset.{u2} ι) (Finset.partialOrder.{u2} ι) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) f) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) g))
Case conversion may be inaccurate. Consider using '#align finsupp.disjoint_iff Finsupp.disjoint_iffₓ'. -/
theorem disjoint_iff {f g : ι →₀ α} : Disjoint f g ↔ Disjoint f.support g.support := by
classical
rw [disjoint_iff, disjoint_iff, Finsupp.bot_eq_zero, ← Finsupp.support_eq_empty,
Finsupp.support_inf]
rfl
#align finsupp.disjoint_iff Finsupp.disjoint_iff
end CanonicallyLinearOrderedAddMonoid
/-! ### Some lemmas about `ℕ` -/
section Nat
#print Finsupp.sub_single_one_add /-
theorem sub_single_one_add {a : ι} {u u' : ι →₀ ℕ} (h : u a ≠ 0) :
u - single a 1 + u' = u + u' - single a 1 :=
tsub_add_eq_add_tsub <| single_le_iff.mpr <| Nat.one_le_iff_ne_zero.mpr h
#align finsupp.sub_single_one_add Finsupp.sub_single_one_add
-/
#print Finsupp.add_sub_single_one /-
theorem add_sub_single_one {a : ι} {u u' : ι →₀ ℕ} (h : u' a ≠ 0) :
u + (u' - single a 1) = u + u' - single a 1 :=
(add_tsub_assoc_of_le (single_le_iff.mpr <| Nat.one_le_iff_ne_zero.mpr h) _).symm
#align finsupp.add_sub_single_one Finsupp.add_sub_single_one
-/
end Nat
end Finsupp
|
/*****************************************************************************
* Licensed to Qualys, Inc. (QUALYS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* QUALYS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
****************************************************************************/
/**
* @file
* @brief Predicate --- Standard Template Implementation
*
* @author Christopher Alfeld <[email protected]>
*/
#include <ironbee/predicate/standard_template.hpp>
#include <ironbee/predicate/bfs.hpp>
#include <ironbee/predicate/call_helpers.hpp>
#include <ironbee/predicate/merge_graph.hpp>
#include <ironbee/predicate/tree_copy.hpp>
#include <ironbee/predicate/validate.hpp>
#ifdef __clang__
#pragma clang diagnostic push
#if __has_warning("-Wunused-local-typedef")
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
#endif
#include <boost/bind.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
using namespace std;
namespace IronBee {
namespace Predicate {
namespace Standard {
namespace {
const string CALL_NAME_REF("ref");
/**
* Reference to something else, see Template.
*
* Ref nodes exist only to reference something else. They do not transform
* and throw exceptions if calculated. They are replaced by
* Template::transform() when they appear in a template body.
**/
class Ref :
public Call
{
public:
//! See Call::name()
virtual const std::string& name() const;
//! See Node::validate().
virtual bool validate(NodeReporter reporter) const;
//! See Node::post_transform().
void post_transform(NodeReporter reporter) const;
//! See Node::eval_calculate()
virtual void eval_calculate(GraphEvalState&, EvalContext) const;
};
/**
* Call that transforms based on an expression and ref substitution.
*
* A template call is initialized with a body expression tree and an argument
* list. At transformation, the body is traversed and any ref nodes are
* replaced by replacing a ref node whose name is at position @c i in the
* argument list with the @c ith child.
**/
class Template :
public Call
{
public:
/**
* Constructor.
*
* @param[in] name Name of template.
* @param[in] args List of arguments. All ref nodes in @a body must
* use one of these.
* @param[in] body Body. Any ref nodes in body will be replaced by
* children of this node according to @a args.
* @param[in] origin_prefix Prefix to add to all origins for body nodes.
**/
Template(
const std::string& name,
const template_arg_list_t& args,
const node_cp& body,
const string& origin_prefix
);
//! See Call::name()
virtual const std::string& name() const;
/**
* See Node::transform().
*
* Will replace self with tree copy of body with ref nodes replace
* according to children and @a args.
**/
virtual bool transform(
MergeGraph& merge_graph,
const CallFactory& call_factory,
Environment environment,
NodeReporter reporter
);
//! See Node::validate().
virtual bool validate(NodeReporter reporter) const;
//! See Node::post_transform().
void post_transform(NodeReporter reporter) const;
//! See Node::eval_calculate()
virtual void eval_calculate(GraphEvalState&, EvalContext) const;
private:
//! Name.
const std::string m_name;
//! Arguments.
const template_arg_list_t m_args;
//! Body expression.
const node_cp m_body;
//! Prefix for all body origin information.
const string m_origin_prefix;
};
const string& Ref::name() const
{
return CALL_NAME_REF;
}
void Ref::eval_calculate(GraphEvalState&, EvalContext) const
{
BOOST_THROW_EXCEPTION(
einval() << errinfo_what(
"Ref node calculated. "
"Maybe transform skipped; or used outside of template body."
)
);
}
void Ref::post_transform(NodeReporter reporter) const
{
reporter.error(
"Ref node should not exist post-transform. "
"Maybe used outside of template body."
);
}
bool Ref::validate(NodeReporter reporter) const
{
bool result =
Validate::n_children(reporter, 1) &&
Validate::nth_child_is_string(reporter, 0)
;
if (result) {
string ref_param =
literal_value(children().front())
.as_string()
.to_s()
;
if (
ref_param.empty() ||
ref_param.find_first_not_of(
"_0123456789"
"abcdefghijklmnoprstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
) != string::npos
) {
reporter.error(
"Reference parameter \"" + ref_param +
"\" is not legal."
);
result = false;
}
}
return result;
}
Template::Template(
const string& name,
const template_arg_list_t& args,
const node_cp& body,
const string& origin_prefix
) :
m_name(name),
m_args(args),
m_body(body),
m_origin_prefix(origin_prefix)
{
// nop
}
const string& Template::name() const
{
return m_name;
}
void Template::eval_calculate(GraphEvalState&, EvalContext) const
{
BOOST_THROW_EXCEPTION(
einval() << errinfo_what(
"Template node calculated. "
"Must have skipped transform."
)
);
}
void Template::post_transform(NodeReporter reporter) const
{
reporter.error(
"Template node should not exist post-transform."
);
}
bool Template::validate(NodeReporter reporter) const
{
return
Validate::n_children(reporter, m_args.size())
;
}
namespace {
string template_ref(const node_cp& node)
{
const Ref* as_ref = dynamic_cast<const Ref*>(node.get());
if (! as_ref) {
return string();
}
return literal_value(as_ref->children().front())
.as_string()
.to_s()
;
}
}
bool Template::transform(
MergeGraph& merge_graph,
const CallFactory& call_factory,
Environment environment,
NodeReporter reporter
)
{
node_p me = shared_from_this();
// Construct map of argument name to children.
typedef map<string, node_p> arg_map_t;
arg_map_t arg_map;
{
template_arg_list_t::const_iterator arg_i = m_args.begin();
node_list_t::const_iterator children_i = children().begin();
while (arg_i != m_args.end() && children_i != children().end()) {
arg_map.insert(make_pair(*arg_i, tree_copy(*children_i, call_factory)));
++arg_i;
++children_i;
}
if (arg_i != m_args.end() || children_i != children().end()) {
reporter.error(
"Number of children not equal to number of arguments. "
"Should have been caught in validation."
);
return false;
}
}
// Construct copy of body to replace me with.
node_p replacement = tree_copy(m_body, call_factory);
// Special case. Body might be itself a ref node.
{
string top_ref = template_ref(m_body);
if (! top_ref.empty()) {
arg_map_t::const_iterator arg_i = arg_map.find(top_ref);
if (arg_i == arg_map.end()) {
reporter.error(
"Reference to \"" + top_ref + "\" but not such "
"argument to template " + name() = "."
);
return false;
}
node_p replacement = arg_i->second;
merge_graph.replace(me, replacement);
merge_graph.add_origin(
replacement,
m_origin_prefix + m_body->to_s()
);
return true;
}
}
// Replace arguments.
typedef map<node_p, string> origin_info_t;
origin_info_t origin_info;
{
node_list_t todo;
todo.push_back(replacement);
while (! todo.empty()) {
node_p n = todo.front();
todo.pop_front();
// Enforce that we are working on a tree, not a dag.
assert(n->parents().size() <= 1);
string ref_param = template_ref(n);
if (! ref_param.empty()) {
arg_map_t::const_iterator arg_i = arg_map.find(ref_param);
if (arg_i == arg_map.end()) {
reporter.error(
"Reference to \"" + ref_param + "\" but not such "
"argument to template " + name() = "."
);
continue;
}
node_p arg = arg_i->second;
n->parents().front().lock()->replace_child(n, arg);
origin_info[arg] = m_origin_prefix + n->to_s();
}
else {
copy(
n->children().begin(), n->children().end(),
back_inserter(todo)
);
origin_info[n] = m_origin_prefix + n->to_s();
}
}
}
// Replace with body.
merge_graph.replace(me, replacement);
BOOST_FOREACH(origin_info_t::const_reference v, origin_info) {
merge_graph.add_origin(v.first, v.second);
}
return true;
}
call_p define_template_creator(
const std::string& name,
const template_arg_list_t args,
const node_cp body,
const std::string origin_prefix
)
{
return call_p(new Template(name, args, body, origin_prefix));
}
} // Anonymous
CallFactory::generator_t define_template(
const template_arg_list_t& args,
const node_cp& body,
const string& origin_prefix
)
{
return bind(define_template_creator, _1, args, body, origin_prefix);
}
void load_template(CallFactory& to)
{
to
.add<Ref>()
;
}
} // Standard
} // Predicate
} // IronBee
|
State Before: p : ℕ
hp : Fact (Nat.Prime p)
q : ℚ_[p]
h : q = 0
⊢ ‖q‖ = ↑0 State After: no goals Tactic: simp [h] |
[GOAL]
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
y : ℝ
⊢ P ⊥ ↑y
[PROOFSTEP]
rcases lt_trichotomy y 0 with (hy | rfl | hy)
[GOAL]
case inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
y : ℝ
hy : y < 0
⊢ P ⊥ ↑y
case inr.inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
⊢ P ⊥ ↑0
case inr.inr
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
y : ℝ
hy : 0 < y
⊢ P ⊥ ↑y
[PROOFSTEP]
exacts [bot_neg y hy, bot_zero, bot_pos y hy]
[GOAL]
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
x : ℝ
⊢ P ↑x ⊥
[PROOFSTEP]
rcases lt_trichotomy x 0 with (hx | rfl | hx)
[GOAL]
case inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
x : ℝ
hx : x < 0
⊢ P ↑x ⊥
case inr.inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
⊢ P ↑0 ⊥
case inr.inr
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
x : ℝ
hx : 0 < x
⊢ P ↑x ⊥
[PROOFSTEP]
exacts [neg_bot x hx, zero_bot, pos_bot x hx]
[GOAL]
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
x : ℝ
⊢ P ↑x ⊤
[PROOFSTEP]
rcases lt_trichotomy x 0 with (hx | rfl | hx)
[GOAL]
case inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
x : ℝ
hx : x < 0
⊢ P ↑x ⊤
case inr.inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
⊢ P ↑0 ⊤
case inr.inr
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
x : ℝ
hx : 0 < x
⊢ P ↑x ⊤
[PROOFSTEP]
exacts [neg_top x hx, zero_top, pos_top x hx]
[GOAL]
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
y : ℝ
⊢ P ⊤ ↑y
[PROOFSTEP]
rcases lt_trichotomy y 0 with (hy | rfl | hy)
[GOAL]
case inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
y : ℝ
hy : y < 0
⊢ P ⊤ ↑y
case inr.inl
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
⊢ P ⊤ ↑0
case inr.inr
P : EReal → EReal → Prop
top_top : P ⊤ ⊤
top_pos : ∀ (x : ℝ), 0 < x → P ⊤ ↑x
top_zero : P ⊤ 0
top_neg : ∀ (x : ℝ), x < 0 → P ⊤ ↑x
top_bot : P ⊤ ⊥
pos_top : ∀ (x : ℝ), 0 < x → P ↑x ⊤
pos_bot : ∀ (x : ℝ), 0 < x → P ↑x ⊥
zero_top : P 0 ⊤
coe_coe : ∀ (x y : ℝ), P ↑x ↑y
zero_bot : P 0 ⊥
neg_top : ∀ (x : ℝ), x < 0 → P ↑x ⊤
neg_bot : ∀ (x : ℝ), x < 0 → P ↑x ⊥
bot_top : P ⊥ ⊤
bot_pos : ∀ (x : ℝ), 0 < x → P ⊥ ↑x
bot_zero : P ⊥ 0
bot_neg : ∀ (x : ℝ), x < 0 → P ⊥ ↑x
bot_bot : P ⊥ ⊥
y : ℝ
hy : 0 < y
⊢ P ⊤ ↑y
[PROOFSTEP]
exacts [top_neg y hy, top_zero, top_pos y hy]
[GOAL]
x y : EReal
⊢ x * y = y * x
[PROOFSTEP]
induction' x using EReal.rec with x
[GOAL]
case h_bot
y : EReal
⊢ ⊥ * y = y * ⊥
[PROOFSTEP]
induction' y using EReal.rec with y
[GOAL]
case h_real
y : EReal
x : ℝ
⊢ ↑x * y = y * ↑x
[PROOFSTEP]
induction' y using EReal.rec with y
[GOAL]
case h_top
y : EReal
⊢ ⊤ * y = y * ⊤
[PROOFSTEP]
induction' y using EReal.rec with y
[GOAL]
case h_bot.h_bot
⊢ ⊥ * ⊥ = ⊥ * ⊥
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_bot.h_bot
⊢ ⊥ * ⊥ = ⊥ * ⊥
[PROOFSTEP]
{rfl
}
[GOAL]
case h_bot.h_bot
⊢ ⊥ * ⊥ = ⊥ * ⊥
[PROOFSTEP]
rfl
[GOAL]
case h_bot.h_real
y : ℝ
⊢ ⊥ * ↑y = ↑y * ⊥
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_bot.h_real
y : ℝ
⊢ ⊥ * ↑y = ↑y * ⊥
[PROOFSTEP]
{rfl
}
[GOAL]
case h_bot.h_real
y : ℝ
⊢ ⊥ * ↑y = ↑y * ⊥
[PROOFSTEP]
rfl
[GOAL]
case h_bot.h_top
⊢ ⊥ * ⊤ = ⊤ * ⊥
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_bot.h_top
⊢ ⊥ * ⊤ = ⊤ * ⊥
[PROOFSTEP]
{rfl
}
[GOAL]
case h_bot.h_top
⊢ ⊥ * ⊤ = ⊤ * ⊥
[PROOFSTEP]
rfl
[GOAL]
case h_real.h_bot
x : ℝ
⊢ ↑x * ⊥ = ⊥ * ↑x
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_real.h_bot
x : ℝ
⊢ ↑x * ⊥ = ⊥ * ↑x
[PROOFSTEP]
{rfl
}
[GOAL]
case h_real.h_bot
x : ℝ
⊢ ↑x * ⊥ = ⊥ * ↑x
[PROOFSTEP]
rfl
[GOAL]
case h_real.h_real
x y : ℝ
⊢ ↑x * ↑y = ↑y * ↑x
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_real.h_real
x y : ℝ
⊢ ↑x * ↑y = ↑y * ↑x
[PROOFSTEP]
{rfl
}
[GOAL]
case h_real.h_real
x y : ℝ
⊢ ↑x * ↑y = ↑y * ↑x
[PROOFSTEP]
rfl
[GOAL]
case h_real.h_top
x : ℝ
⊢ ↑x * ⊤ = ⊤ * ↑x
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_real.h_top
x : ℝ
⊢ ↑x * ⊤ = ⊤ * ↑x
[PROOFSTEP]
{rfl
}
[GOAL]
case h_real.h_top
x : ℝ
⊢ ↑x * ⊤ = ⊤ * ↑x
[PROOFSTEP]
rfl
[GOAL]
case h_top.h_bot
⊢ ⊤ * ⊥ = ⊥ * ⊤
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_top.h_bot
⊢ ⊤ * ⊥ = ⊥ * ⊤
[PROOFSTEP]
{rfl
}
[GOAL]
case h_top.h_bot
⊢ ⊤ * ⊥ = ⊥ * ⊤
[PROOFSTEP]
rfl
[GOAL]
case h_top.h_real
y : ℝ
⊢ ⊤ * ↑y = ↑y * ⊤
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_top.h_real
y : ℝ
⊢ ⊤ * ↑y = ↑y * ⊤
[PROOFSTEP]
{rfl
}
[GOAL]
case h_top.h_real
y : ℝ
⊢ ⊤ * ↑y = ↑y * ⊤
[PROOFSTEP]
rfl
[GOAL]
case h_top.h_top
⊢ ⊤ * ⊤ = ⊤ * ⊤
[PROOFSTEP]
try {rfl
}
[GOAL]
case h_top.h_top
⊢ ⊤ * ⊤ = ⊤ * ⊤
[PROOFSTEP]
{rfl
}
[GOAL]
case h_top.h_top
⊢ ⊤ * ⊤ = ⊤ * ⊤
[PROOFSTEP]
rfl
[GOAL]
case h_real.h_real
x y : ℝ
⊢ ↑x * ↑y = ↑y * ↑x
[PROOFSTEP]
rw [← coe_mul, ← coe_mul, mul_comm]
[GOAL]
x : EReal
⊢ x * 1 = x
[PROOFSTEP]
rw [EReal.mul_comm, EReal.one_mul]
[GOAL]
x : EReal
⊢ x * 0 = 0
[PROOFSTEP]
rw [EReal.mul_comm, EReal.zero_mul]
[GOAL]
x : EReal
hx : x ≠ ⊤ ∧ x ≠ ⊥
⊢ ∃ y, ↑y = x
[PROOFSTEP]
induction x using EReal.rec
[GOAL]
case h_bot
hx : ⊥ ≠ ⊤ ∧ ⊥ ≠ ⊥
⊢ ∃ y, ↑y = ⊥
[PROOFSTEP]
simp at hx
[GOAL]
case h_real
a✝ : ℝ
hx : ↑a✝ ≠ ⊤ ∧ ↑a✝ ≠ ⊥
⊢ ∃ y, ↑y = ↑a✝
[PROOFSTEP]
simp
[GOAL]
case h_top
hx : ⊤ ≠ ⊤ ∧ ⊤ ≠ ⊥
⊢ ∃ y, ↑y = ⊤
[PROOFSTEP]
simp at hx
[GOAL]
⊢ range Real.toEReal = {⊥, ⊤}ᶜ
[PROOFSTEP]
ext x
[GOAL]
case h
x : EReal
⊢ x ∈ range Real.toEReal ↔ x ∈ {⊥, ⊤}ᶜ
[PROOFSTEP]
induction x using EReal.rec
[GOAL]
case h.h_bot
⊢ ⊥ ∈ range Real.toEReal ↔ ⊥ ∈ {⊥, ⊤}ᶜ
[PROOFSTEP]
simp
[GOAL]
case h.h_real
a✝ : ℝ
⊢ ↑a✝ ∈ range Real.toEReal ↔ ↑a✝ ∈ {⊥, ⊤}ᶜ
[PROOFSTEP]
simp
[GOAL]
case h.h_top
⊢ ⊤ ∈ range Real.toEReal ↔ ⊤ ∈ {⊥, ⊤}ᶜ
[PROOFSTEP]
simp
[GOAL]
⊢ range Real.toEReal = Ioo ⊥ ⊤
[PROOFSTEP]
ext x
[GOAL]
case h
x : EReal
⊢ x ∈ range Real.toEReal ↔ x ∈ Ioo ⊥ ⊤
[PROOFSTEP]
induction x using EReal.rec
[GOAL]
case h.h_bot
⊢ ⊥ ∈ range Real.toEReal ↔ ⊥ ∈ Ioo ⊥ ⊤
[PROOFSTEP]
simp
[GOAL]
case h.h_real
a✝ : ℝ
⊢ ↑a✝ ∈ range Real.toEReal ↔ ↑a✝ ∈ Ioo ⊥ ⊤
[PROOFSTEP]
simp
[GOAL]
case h.h_top
⊢ ⊤ ∈ range Real.toEReal ↔ ⊤ ∈ Ioo ⊥ ⊤
[PROOFSTEP]
simp
[GOAL]
x y : EReal
h : x ≤ y
hx : x ≠ ⊥
hy : y ≠ ⊤
⊢ toReal x ≤ toReal y
[PROOFSTEP]
lift x to ℝ using ⟨ne_top_of_le_ne_top hy h, hx⟩
[GOAL]
case intro
y : EReal
hy : y ≠ ⊤
x : ℝ
h : ↑x ≤ y
hx : ↑x ≠ ⊥
⊢ toReal ↑x ≤ toReal y
[PROOFSTEP]
lift y to ℝ using ⟨hy, ne_bot_of_le_ne_bot hx h⟩
[GOAL]
case intro.intro
x : ℝ
hx : ↑x ≠ ⊥
y : ℝ
hy : ↑y ≠ ⊤
h : ↑x ≤ ↑y
⊢ toReal ↑x ≤ toReal ↑y
[PROOFSTEP]
simpa using h
[GOAL]
x : EReal
hx : x ≠ ⊤
h'x : x ≠ ⊥
⊢ ↑(toReal x) = x
[PROOFSTEP]
lift x to ℝ using ⟨hx, h'x⟩
[GOAL]
case intro
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
⊢ ↑(toReal ↑x) = ↑x
[PROOFSTEP]
rfl
[GOAL]
x : EReal
h : x ≠ ⊤
⊢ x ≤ ↑(toReal x)
[PROOFSTEP]
by_cases h' : x = ⊥
[GOAL]
case pos
x : EReal
h : x ≠ ⊤
h' : x = ⊥
⊢ x ≤ ↑(toReal x)
[PROOFSTEP]
simp only [h', bot_le]
[GOAL]
case neg
x : EReal
h : x ≠ ⊤
h' : ¬x = ⊥
⊢ x ≤ ↑(toReal x)
[PROOFSTEP]
simp only [le_refl, coe_toReal h h']
[GOAL]
x : EReal
h : x ≠ ⊥
⊢ ↑(toReal x) ≤ x
[PROOFSTEP]
by_cases h' : x = ⊤
[GOAL]
case pos
x : EReal
h : x ≠ ⊥
h' : x = ⊤
⊢ ↑(toReal x) ≤ x
[PROOFSTEP]
simp only [h', le_top]
[GOAL]
case neg
x : EReal
h : x ≠ ⊥
h' : ¬x = ⊤
⊢ ↑(toReal x) ≤ x
[PROOFSTEP]
simp only [le_refl, coe_toReal h' h]
[GOAL]
x : EReal
⊢ x = ⊤ ↔ ∀ (y : ℝ), ↑y < x
[PROOFSTEP]
constructor
[GOAL]
case mp
x : EReal
⊢ x = ⊤ → ∀ (y : ℝ), ↑y < x
[PROOFSTEP]
rintro rfl
[GOAL]
case mp
⊢ ∀ (y : ℝ), ↑y < ⊤
[PROOFSTEP]
exact EReal.coe_lt_top
[GOAL]
case mpr
x : EReal
⊢ (∀ (y : ℝ), ↑y < x) → x = ⊤
[PROOFSTEP]
contrapose!
[GOAL]
case mpr
x : EReal
⊢ x ≠ ⊤ → ∃ y, x ≤ ↑y
[PROOFSTEP]
intro h
[GOAL]
case mpr
x : EReal
h : x ≠ ⊤
⊢ ∃ y, x ≤ ↑y
[PROOFSTEP]
exact ⟨x.toReal, le_coe_toReal h⟩
[GOAL]
x : EReal
⊢ x = ⊥ ↔ ∀ (y : ℝ), x < ↑y
[PROOFSTEP]
constructor
[GOAL]
case mp
x : EReal
⊢ x = ⊥ → ∀ (y : ℝ), x < ↑y
[PROOFSTEP]
rintro rfl
[GOAL]
case mp
⊢ ∀ (y : ℝ), ⊥ < ↑y
[PROOFSTEP]
exact bot_lt_coe
[GOAL]
case mpr
x : EReal
⊢ (∀ (y : ℝ), x < ↑y) → x = ⊥
[PROOFSTEP]
contrapose!
[GOAL]
case mpr
x : EReal
⊢ x ≠ ⊥ → ∃ y, ↑y ≤ x
[PROOFSTEP]
intro h
[GOAL]
case mpr
x : EReal
h : x ≠ ⊥
⊢ ∃ y, ↑y ≤ x
[PROOFSTEP]
exact ⟨x.toReal, coe_toReal_le h⟩
[GOAL]
x : ℝ≥0∞
⊢ ↑x = 0 ↔ x = 0
[PROOFSTEP]
rw [← coe_ennreal_eq_coe_ennreal_iff, coe_ennreal_zero]
[GOAL]
x : ℝ≥0∞
⊢ ↑x = 1 ↔ x = 1
[PROOFSTEP]
rw [← coe_ennreal_eq_coe_ennreal_iff, coe_ennreal_one]
[GOAL]
x : ℝ≥0∞
⊢ 0 < ↑x ↔ 0 < x
[PROOFSTEP]
rw [← coe_ennreal_zero, coe_ennreal_lt_coe_ennreal_iff]
[GOAL]
x y : ℝ≥0∞
⊢ ↑(x + y) = ↑x + ↑y
[PROOFSTEP]
cases x
[GOAL]
case none
y : ℝ≥0∞
⊢ ↑(none + y) = ↑none + ↑y
[PROOFSTEP]
cases y
[GOAL]
case some
y : ℝ≥0∞
val✝ : ℝ≥0
⊢ ↑(Option.some val✝ + y) = ↑(Option.some val✝) + ↑y
[PROOFSTEP]
cases y
[GOAL]
case none.none
⊢ ↑(none + none) = ↑none + ↑none
[PROOFSTEP]
rfl
[GOAL]
case none.some
val✝ : ℝ≥0
⊢ ↑(none + Option.some val✝) = ↑none + ↑(Option.some val✝)
[PROOFSTEP]
rfl
[GOAL]
case some.none
val✝ : ℝ≥0
⊢ ↑(Option.some val✝ + none) = ↑(Option.some val✝) + ↑none
[PROOFSTEP]
rfl
[GOAL]
case some.some
val✝¹ val✝ : ℝ≥0
⊢ ↑(Option.some val✝¹ + Option.some val✝) = ↑(Option.some val✝¹) + ↑(Option.some val✝)
[PROOFSTEP]
rfl
[GOAL]
x : ℝ≥0
⊢ ↑(⊤ * ↑x) = ⊤ * ↑↑x
[PROOFSTEP]
rcases eq_or_ne x 0 with (rfl | h0)
[GOAL]
case inl
⊢ ↑(⊤ * ↑0) = ⊤ * ↑↑0
[PROOFSTEP]
simp
[GOAL]
case inr
x : ℝ≥0
h0 : x ≠ 0
⊢ ↑(⊤ * ↑x) = ⊤ * ↑↑x
[PROOFSTEP]
rw [ENNReal.top_mul (ENNReal.coe_ne_zero.2 h0)]
[GOAL]
case inr
x : ℝ≥0
h0 : x ≠ 0
⊢ ↑⊤ = ⊤ * ↑↑x
[PROOFSTEP]
exact Eq.symm <| if_pos <| NNReal.coe_pos.2 h0.bot_lt
[GOAL]
x : ℝ≥0
⊢ ↑(↑x * ⊤) = ↑↑x * ↑⊤
[PROOFSTEP]
rw [mul_comm, coe_ennreal_top_mul, EReal.mul_comm, coe_ennreal_top]
[GOAL]
x y : ℝ≥0
⊢ ↑(↑x * ↑y) = ↑↑x * ↑↑y
[PROOFSTEP]
simp only [← ENNReal.coe_mul, coe_nnreal_eq_coe_real, NNReal.coe_mul, EReal.coe_mul]
[GOAL]
a b : ℝ
h : ↑a < ↑b
⊢ ∃ x, ↑a < ↑↑x ∧ ↑↑x < ↑b
[PROOFSTEP]
simp [exists_rat_btwn (EReal.coe_lt_coe_iff.1 h)]
[GOAL]
a : ℝ
x✝ : ↑a < ⊤
b : ℚ
hab : a < ↑b
⊢ ↑a < ↑↑b
[PROOFSTEP]
simpa using hab
[GOAL]
a : ℝ
x✝ : ⊥ < ↑a
b : ℚ
hab : ↑b < a
⊢ ↑↑b < ↑a
[PROOFSTEP]
simpa using hab
[GOAL]
x : ℝ
⊢ ↑x ∈ {⊥, ⊤}ᶜ
[PROOFSTEP]
simp
[GOAL]
x✝ : ↑{⊥, ⊤}ᶜ
x : EReal
hx : x ∈ {⊥, ⊤}ᶜ
⊢ (fun x => { val := ↑x, property := (_ : ↑x ∈ {⊥, ⊤}ᶜ) }) ((fun x => toReal ↑x) { val := x, property := hx }) =
{ val := x, property := hx }
[PROOFSTEP]
lift x to ℝ
[GOAL]
x✝ : ↑{⊥, ⊤}ᶜ
x : EReal
hx : x ∈ {⊥, ⊤}ᶜ
⊢ x ≠ ⊤ ∧ x ≠ ⊥
[PROOFSTEP]
simpa [not_or, and_comm] using hx
[GOAL]
case intro
x✝ : ↑{⊥, ⊤}ᶜ
x : ℝ
hx : ↑x ∈ {⊥, ⊤}ᶜ
⊢ (fun x => { val := ↑x, property := (_ : ↑x ∈ {⊥, ⊤}ᶜ) }) ((fun x => toReal ↑x) { val := ↑x, property := hx }) =
{ val := ↑x, property := hx }
[PROOFSTEP]
simp
[GOAL]
x : ℝ
⊢ (fun x => toReal ↑x) ((fun x => { val := ↑x, property := (_ : ↑x ∈ {⊥, ⊤}ᶜ) }) x) = x
[PROOFSTEP]
simp
[GOAL]
x y : EReal
⊢ ⊥ < x + y ↔ ⊥ < x ∧ ⊥ < y
[PROOFSTEP]
simp [bot_lt_iff_ne_bot, not_or]
[GOAL]
x y : EReal
hx : x ≠ ⊤
h'x : x ≠ ⊥
hy : y ≠ ⊤
h'y : y ≠ ⊥
⊢ toReal (x + y) = toReal x + toReal y
[PROOFSTEP]
lift x to ℝ using ⟨hx, h'x⟩
[GOAL]
case intro
y : EReal
hy : y ≠ ⊤
h'y : y ≠ ⊥
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
⊢ toReal (↑x + y) = toReal ↑x + toReal y
[PROOFSTEP]
lift y to ℝ using ⟨hy, h'y⟩
[GOAL]
case intro.intro
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
y : ℝ
hy : ↑y ≠ ⊤
h'y : ↑y ≠ ⊥
⊢ toReal (↑x + ↑y) = toReal ↑x + toReal ↑y
[PROOFSTEP]
rfl
[GOAL]
x z : ℝ
h : ↑x + ⊤ ≤ ↑x + ↑z
⊢ ⊤ ≤ ↑z
[PROOFSTEP]
simp only [coe_add_top, ← coe_add, top_le_iff, coe_ne_top] at h
[GOAL]
x : ℝ
x✝ : EReal
h : ↑x + x✝ ≤ ↑x + ⊥
⊢ x✝ ≤ ⊥
[PROOFSTEP]
simpa using h
[GOAL]
x y z : ℝ
h : ↑x + ↑y ≤ ↑x + ↑z
⊢ ↑y ≤ ↑z
[PROOFSTEP]
simpa only [← coe_add, EReal.coe_le_coe_iff, add_le_add_iff_left] using h
[GOAL]
x y : EReal
h : x < y
z : ℝ
⊢ ↑z + x < ↑z + y
[PROOFSTEP]
simpa [add_comm] using add_lt_add_right_coe h z
[GOAL]
x y z t : EReal
h1 : x < y
h2 : z < t
⊢ x + z < y + t
[PROOFSTEP]
rcases eq_or_ne x ⊥ with (rfl | hx)
[GOAL]
case inl
y z t : EReal
h2 : z < t
h1 : ⊥ < y
⊢ ⊥ + z < y + t
[PROOFSTEP]
simp [h1, bot_le.trans_lt h2]
[GOAL]
case inr
x y z t : EReal
h1 : x < y
h2 : z < t
hx : x ≠ ⊥
⊢ x + z < y + t
[PROOFSTEP]
lift x to ℝ using ⟨h1.ne_top, hx⟩
[GOAL]
case inr.intro
y z t : EReal
h2 : z < t
x : ℝ
h1 : ↑x < y
hx : ↑x ≠ ⊥
⊢ ↑x + z < y + t
[PROOFSTEP]
calc
(x : EReal) + z < x + t := add_lt_add_left_coe h2 _
_ ≤ y + t := add_le_add_right h1.le _
[GOAL]
x y z t : EReal
h : x < y
h' : z ≤ t
hbot : t ≠ ⊥
htop : t = ⊤ → z = ⊤ → x = ⊥
⊢ x + z < y + t
[PROOFSTEP]
rcases h'.eq_or_lt with (rfl | hlt)
[GOAL]
case inl
x y z : EReal
h : x < y
h' : z ≤ z
hbot : z ≠ ⊥
htop : z = ⊤ → z = ⊤ → x = ⊥
⊢ x + z < y + z
[PROOFSTEP]
rcases eq_or_ne z ⊤ with (rfl | hz)
[GOAL]
case inl.inl
x y : EReal
h : x < y
h' : ⊤ ≤ ⊤
hbot : ⊤ ≠ ⊥
htop : ⊤ = ⊤ → ⊤ = ⊤ → x = ⊥
⊢ x + ⊤ < y + ⊤
[PROOFSTEP]
obtain rfl := htop rfl rfl
[GOAL]
case inl.inl
y : EReal
h' : ⊤ ≤ ⊤
hbot : ⊤ ≠ ⊥
h : ⊥ < y
htop : ⊤ = ⊤ → ⊤ = ⊤ → ⊥ = ⊥
⊢ ⊥ + ⊤ < y + ⊤
[PROOFSTEP]
simpa
[GOAL]
case inl.inr
x y z : EReal
h : x < y
h' : z ≤ z
hbot : z ≠ ⊥
htop : z = ⊤ → z = ⊤ → x = ⊥
hz : z ≠ ⊤
⊢ x + z < y + z
[PROOFSTEP]
lift z to ℝ using ⟨hz, hbot⟩
[GOAL]
case inl.inr.intro
x y : EReal
h : x < y
z : ℝ
h' : ↑z ≤ ↑z
hbot : ↑z ≠ ⊥
htop : ↑z = ⊤ → ↑z = ⊤ → x = ⊥
hz : ↑z ≠ ⊤
⊢ x + ↑z < y + ↑z
[PROOFSTEP]
exact add_lt_add_right_coe h z
[GOAL]
case inr
x y z t : EReal
h : x < y
h' : z ≤ t
hbot : t ≠ ⊥
htop : t = ⊤ → z = ⊤ → x = ⊥
hlt : z < t
⊢ x + z < y + t
[PROOFSTEP]
exact add_lt_add h hlt
[GOAL]
x y : EReal
hx : x ≠ ⊤
hy : y ≠ ⊤
⊢ x + y < ⊤
[PROOFSTEP]
rw [← EReal.top_add_top]
[GOAL]
x y : EReal
hx : x ≠ ⊤
hy : y ≠ ⊤
⊢ x + y < ⊤ + ⊤
[PROOFSTEP]
exact EReal.add_lt_add hx.lt_top hy.lt_top
[GOAL]
⊢ toReal (-⊤) = -toReal ⊤
[PROOFSTEP]
simp
[GOAL]
⊢ toReal (-⊥) = -toReal ⊥
[PROOFSTEP]
simp
[GOAL]
a b : EReal
⊢ -a ≤ b ↔ -b ≤ a
[PROOFSTEP]
rw [← neg_le_neg_iff, neg_neg]
[GOAL]
a b : EReal
h : a ≤ -b
⊢ b ≤ -a
[PROOFSTEP]
rwa [← neg_neg b, EReal.neg_le, neg_neg]
[GOAL]
a b : EReal
⊢ -a < b ↔ -b < a
[PROOFSTEP]
rw [← neg_lt_neg_iff, neg_neg]
[GOAL]
x y z t : EReal
h : x < y
h' : z ≤ t
hz : z ≠ ⊥
ht : t ≠ ⊤
⊢ -t ≠ ⊥
[PROOFSTEP]
simp [ht]
[GOAL]
x y z t : EReal
h : x < y
h' : z ≤ t
hz : z ≠ ⊥
ht : t ≠ ⊤
⊢ -z ≠ ⊤
[PROOFSTEP]
simp [hz]
[GOAL]
x : ℝ
⊢ ↑x = ↑↑(Real.toNNReal x) - ↑↑(Real.toNNReal (-x))
[PROOFSTEP]
rcases le_total 0 x with (h | h)
[GOAL]
case inl
x : ℝ
h : 0 ≤ x
⊢ ↑x = ↑↑(Real.toNNReal x) - ↑↑(Real.toNNReal (-x))
[PROOFSTEP]
lift x to ℝ≥0 using h
[GOAL]
case inl.intro
x : ℝ≥0
⊢ ↑↑x = ↑↑(Real.toNNReal ↑x) - ↑↑(Real.toNNReal (-↑x))
[PROOFSTEP]
rw [Real.toNNReal_of_nonpos (neg_nonpos.mpr x.coe_nonneg), Real.toNNReal_coe, ENNReal.coe_zero, coe_ennreal_zero,
sub_zero]
[GOAL]
case inl.intro
x : ℝ≥0
⊢ ↑↑x = ↑↑x
[PROOFSTEP]
rfl
[GOAL]
case inr
x : ℝ
h : x ≤ 0
⊢ ↑x = ↑↑(Real.toNNReal x) - ↑↑(Real.toNNReal (-x))
[PROOFSTEP]
rw [Real.toNNReal_of_nonpos h, ENNReal.coe_zero, coe_ennreal_zero, coe_nnreal_eq_coe_real, Real.coe_toNNReal, zero_sub,
coe_neg, neg_neg]
[GOAL]
case inr.hr
x : ℝ
h : x ≤ 0
⊢ 0 ≤ -x
[PROOFSTEP]
exact neg_nonneg.2 h
[GOAL]
x y : EReal
hx : x ≠ ⊤
h'x : x ≠ ⊥
hy : y ≠ ⊤
h'y : y ≠ ⊥
⊢ toReal (x - y) = toReal x - toReal y
[PROOFSTEP]
lift x to ℝ using ⟨hx, h'x⟩
[GOAL]
case intro
y : EReal
hy : y ≠ ⊤
h'y : y ≠ ⊥
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
⊢ toReal (↑x - y) = toReal ↑x - toReal y
[PROOFSTEP]
lift y to ℝ using ⟨hy, h'y⟩
[GOAL]
case intro.intro
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
y : ℝ
hy : ↑y ≠ ⊤
h'y : ↑y ≠ ⊥
⊢ toReal (↑x - ↑y) = toReal ↑x - toReal ↑y
[PROOFSTEP]
rfl
[GOAL]
x : EReal
h : 0 < x
⊢ ⊤ * x = ⊤
[PROOFSTEP]
rw [EReal.mul_comm]
[GOAL]
x : EReal
h : 0 < x
⊢ x * ⊤ = ⊤
[PROOFSTEP]
exact mul_top_of_pos h
[GOAL]
x : EReal
h : x < 0
⊢ ⊤ * x = ⊥
[PROOFSTEP]
rw [EReal.mul_comm]
[GOAL]
x : EReal
h : x < 0
⊢ x * ⊤ = ⊥
[PROOFSTEP]
exact mul_top_of_neg h
[GOAL]
x : EReal
h : 0 < x
⊢ ⊥ * x = ⊥
[PROOFSTEP]
rw [EReal.mul_comm]
[GOAL]
x : EReal
h : 0 < x
⊢ x * ⊥ = ⊥
[PROOFSTEP]
exact mul_bot_of_pos h
[GOAL]
x : EReal
h : x < 0
⊢ ⊥ * x = ⊤
[PROOFSTEP]
rw [EReal.mul_comm]
[GOAL]
x : EReal
h : x < 0
⊢ x * ⊥ = ⊤
[PROOFSTEP]
exact mul_bot_of_neg h
[GOAL]
x y : EReal
⊢ toReal (x * y) = toReal x * toReal y
[PROOFSTEP]
induction x, y using induction₂_symm with
| top_zero| zero_bot| top_top| top_bot| bot_bot => simp
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => norm_cast
| top_pos _ h => simp [top_mul_coe_of_pos h]
| top_neg _ h => simp [top_mul_coe_of_neg h]
| pos_bot _ h => simp [coe_mul_bot_of_pos h]
| neg_bot _ h => simp [coe_mul_bot_of_neg h]
[GOAL]
x y : EReal
⊢ toReal (x * y) = toReal x * toReal y
[PROOFSTEP]
induction x, y using induction₂_symm with
| top_zero => simp
| zero_bot => simp
| top_top => simp
| top_bot => simp
| bot_bot => simp
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => norm_cast
| top_pos _ h => simp [top_mul_coe_of_pos h]
| top_neg _ h => simp [top_mul_coe_of_neg h]
| pos_bot _ h => simp [coe_mul_bot_of_pos h]
| neg_bot _ h => simp [coe_mul_bot_of_neg h]
[GOAL]
x y : EReal
⊢ toReal (x * y) = toReal x * toReal y
[PROOFSTEP]
induction x, y using induction₂_symm with
| top_zero => simp
| zero_bot => simp
| top_top => simp
| top_bot => simp
| bot_bot => simp
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => norm_cast
| top_pos _ h => simp [top_mul_coe_of_pos h]
| top_neg _ h => simp [top_mul_coe_of_neg h]
| pos_bot _ h => simp [coe_mul_bot_of_pos h]
| neg_bot _ h => simp [coe_mul_bot_of_neg h]
[GOAL]
case top_zero
⊢ toReal (⊤ * 0) = toReal ⊤ * toReal 0
[PROOFSTEP]
| top_zero => simp
[GOAL]
case top_zero
⊢ toReal (⊤ * 0) = toReal ⊤ * toReal 0
[PROOFSTEP]
simp
[GOAL]
case zero_bot
⊢ toReal (0 * ⊥) = toReal 0 * toReal ⊥
[PROOFSTEP]
| zero_bot => simp
[GOAL]
case zero_bot
⊢ toReal (0 * ⊥) = toReal 0 * toReal ⊥
[PROOFSTEP]
simp
[GOAL]
case top_top
⊢ toReal (⊤ * ⊤) = toReal ⊤ * toReal ⊤
[PROOFSTEP]
| top_top => simp
[GOAL]
case top_top
⊢ toReal (⊤ * ⊤) = toReal ⊤ * toReal ⊤
[PROOFSTEP]
simp
[GOAL]
case top_bot
⊢ toReal (⊤ * ⊥) = toReal ⊤ * toReal ⊥
[PROOFSTEP]
| top_bot => simp
[GOAL]
case top_bot
⊢ toReal (⊤ * ⊥) = toReal ⊤ * toReal ⊥
[PROOFSTEP]
simp
[GOAL]
case bot_bot
⊢ toReal (⊥ * ⊥) = toReal ⊥ * toReal ⊥
[PROOFSTEP]
| bot_bot => simp
[GOAL]
case bot_bot
⊢ toReal (⊥ * ⊥) = toReal ⊥ * toReal ⊥
[PROOFSTEP]
simp
[GOAL]
case symm
x✝ y✝ : EReal
h : toReal (x✝ * y✝) = toReal x✝ * toReal y✝
⊢ toReal (y✝ * x✝) = toReal y✝ * toReal x✝
[PROOFSTEP]
| symm h => rwa [mul_comm, EReal.mul_comm]
[GOAL]
case symm
x✝ y✝ : EReal
h : toReal (x✝ * y✝) = toReal x✝ * toReal y✝
⊢ toReal (y✝ * x✝) = toReal y✝ * toReal x✝
[PROOFSTEP]
rwa [mul_comm, EReal.mul_comm]
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ toReal (↑x✝ * ↑y✝) = toReal ↑x✝ * toReal ↑y✝
[PROOFSTEP]
| coe_coe => norm_cast
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ toReal (↑x✝ * ↑y✝) = toReal ↑x✝ * toReal ↑y✝
[PROOFSTEP]
norm_cast
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ toReal (⊤ * ↑x✝) = toReal ⊤ * toReal ↑x✝
[PROOFSTEP]
| top_pos _ h => simp [top_mul_coe_of_pos h]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ toReal (⊤ * ↑x✝) = toReal ⊤ * toReal ↑x✝
[PROOFSTEP]
simp [top_mul_coe_of_pos h]
[GOAL]
case top_neg
x✝ : ℝ
h : x✝ < 0
⊢ toReal (⊤ * ↑x✝) = toReal ⊤ * toReal ↑x✝
[PROOFSTEP]
| top_neg _ h => simp [top_mul_coe_of_neg h]
[GOAL]
case top_neg
x✝ : ℝ
h : x✝ < 0
⊢ toReal (⊤ * ↑x✝) = toReal ⊤ * toReal ↑x✝
[PROOFSTEP]
simp [top_mul_coe_of_neg h]
[GOAL]
case pos_bot
x✝ : ℝ
h : 0 < x✝
⊢ toReal (↑x✝ * ⊥) = toReal ↑x✝ * toReal ⊥
[PROOFSTEP]
| pos_bot _ h => simp [coe_mul_bot_of_pos h]
[GOAL]
case pos_bot
x✝ : ℝ
h : 0 < x✝
⊢ toReal (↑x✝ * ⊥) = toReal ↑x✝ * toReal ⊥
[PROOFSTEP]
simp [coe_mul_bot_of_pos h]
[GOAL]
case neg_bot
x✝ : ℝ
h : x✝ < 0
⊢ toReal (↑x✝ * ⊥) = toReal ↑x✝ * toReal ⊥
[PROOFSTEP]
| neg_bot _ h => simp [coe_mul_bot_of_neg h]
[GOAL]
case neg_bot
x✝ : ℝ
h : x✝ < 0
⊢ toReal (↑x✝ * ⊥) = toReal ↑x✝ * toReal ⊥
[PROOFSTEP]
simp [coe_mul_bot_of_neg h]
[GOAL]
x y : EReal
⊢ -x * y = -(x * y)
[PROOFSTEP]
induction x, y using induction₂_neg_left with
| top_zero| zero_top| zero_bot => simp only [zero_mul, mul_zero, neg_zero]
| top_top| top_bot => rfl
| neg_left h => rw [h, neg_neg, neg_neg]
| coe_coe => norm_cast; exact neg_mul _ _
| top_pos _ h => rw [top_mul_coe_of_pos h, neg_top, bot_mul_coe_of_pos h]
| pos_top _ h => rw [coe_mul_top_of_pos h, neg_top, ← coe_neg, coe_mul_top_of_neg (neg_neg_of_pos h)]
| top_neg _ h => rw [top_mul_coe_of_neg h, neg_top, bot_mul_coe_of_neg h, neg_bot]
| pos_bot _ h => rw [coe_mul_bot_of_pos h, neg_bot, ← coe_neg, coe_mul_bot_of_neg (neg_neg_of_pos h)]
[GOAL]
x y : EReal
⊢ -x * y = -(x * y)
[PROOFSTEP]
induction x, y using induction₂_neg_left with
| top_zero => simp only [zero_mul, mul_zero, neg_zero]
| zero_top => simp only [zero_mul, mul_zero, neg_zero]
| zero_bot => simp only [zero_mul, mul_zero, neg_zero]
| top_top => rfl
| top_bot => rfl
| neg_left h => rw [h, neg_neg, neg_neg]
| coe_coe => norm_cast; exact neg_mul _ _
| top_pos _ h => rw [top_mul_coe_of_pos h, neg_top, bot_mul_coe_of_pos h]
| pos_top _ h => rw [coe_mul_top_of_pos h, neg_top, ← coe_neg, coe_mul_top_of_neg (neg_neg_of_pos h)]
| top_neg _ h => rw [top_mul_coe_of_neg h, neg_top, bot_mul_coe_of_neg h, neg_bot]
| pos_bot _ h => rw [coe_mul_bot_of_pos h, neg_bot, ← coe_neg, coe_mul_bot_of_neg (neg_neg_of_pos h)]
[GOAL]
x y : EReal
⊢ -x * y = -(x * y)
[PROOFSTEP]
induction x, y using induction₂_neg_left with
| top_zero => simp only [zero_mul, mul_zero, neg_zero]
| zero_top => simp only [zero_mul, mul_zero, neg_zero]
| zero_bot => simp only [zero_mul, mul_zero, neg_zero]
| top_top => rfl
| top_bot => rfl
| neg_left h => rw [h, neg_neg, neg_neg]
| coe_coe => norm_cast; exact neg_mul _ _
| top_pos _ h => rw [top_mul_coe_of_pos h, neg_top, bot_mul_coe_of_pos h]
| pos_top _ h => rw [coe_mul_top_of_pos h, neg_top, ← coe_neg, coe_mul_top_of_neg (neg_neg_of_pos h)]
| top_neg _ h => rw [top_mul_coe_of_neg h, neg_top, bot_mul_coe_of_neg h, neg_bot]
| pos_bot _ h => rw [coe_mul_bot_of_pos h, neg_bot, ← coe_neg, coe_mul_bot_of_neg (neg_neg_of_pos h)]
[GOAL]
case top_zero
⊢ -⊤ * 0 = -(⊤ * 0)
[PROOFSTEP]
| top_zero => simp only [zero_mul, mul_zero, neg_zero]
[GOAL]
case top_zero
⊢ -⊤ * 0 = -(⊤ * 0)
[PROOFSTEP]
simp only [zero_mul, mul_zero, neg_zero]
[GOAL]
case zero_top
⊢ -0 * ⊤ = -(0 * ⊤)
[PROOFSTEP]
| zero_top => simp only [zero_mul, mul_zero, neg_zero]
[GOAL]
case zero_top
⊢ -0 * ⊤ = -(0 * ⊤)
[PROOFSTEP]
simp only [zero_mul, mul_zero, neg_zero]
[GOAL]
case zero_bot
⊢ -0 * ⊥ = -(0 * ⊥)
[PROOFSTEP]
| zero_bot => simp only [zero_mul, mul_zero, neg_zero]
[GOAL]
case zero_bot
⊢ -0 * ⊥ = -(0 * ⊥)
[PROOFSTEP]
simp only [zero_mul, mul_zero, neg_zero]
[GOAL]
case top_top
⊢ -⊤ * ⊤ = -(⊤ * ⊤)
[PROOFSTEP]
| top_top => rfl
[GOAL]
case top_top
⊢ -⊤ * ⊤ = -(⊤ * ⊤)
[PROOFSTEP]
rfl
[GOAL]
case top_bot
⊢ -⊤ * ⊥ = -(⊤ * ⊥)
[PROOFSTEP]
| top_bot => rfl
[GOAL]
case top_bot
⊢ -⊤ * ⊥ = -(⊤ * ⊥)
[PROOFSTEP]
rfl
[GOAL]
case neg_left
x✝ y✝ : EReal
h : -x✝ * y✝ = -(x✝ * y✝)
⊢ - -x✝ * y✝ = -(-x✝ * y✝)
[PROOFSTEP]
| neg_left h => rw [h, neg_neg, neg_neg]
[GOAL]
case neg_left
x✝ y✝ : EReal
h : -x✝ * y✝ = -(x✝ * y✝)
⊢ - -x✝ * y✝ = -(-x✝ * y✝)
[PROOFSTEP]
rw [h, neg_neg, neg_neg]
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ -↑x✝ * ↑y✝ = -(↑x✝ * ↑y✝)
[PROOFSTEP]
| coe_coe => norm_cast; exact neg_mul _ _
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ -↑x✝ * ↑y✝ = -(↑x✝ * ↑y✝)
[PROOFSTEP]
norm_cast
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ -x✝ * y✝ = -(x✝ * y✝)
[PROOFSTEP]
exact neg_mul _ _
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ -⊤ * ↑x✝ = -(⊤ * ↑x✝)
[PROOFSTEP]
| top_pos _ h => rw [top_mul_coe_of_pos h, neg_top, bot_mul_coe_of_pos h]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ -⊤ * ↑x✝ = -(⊤ * ↑x✝)
[PROOFSTEP]
rw [top_mul_coe_of_pos h, neg_top, bot_mul_coe_of_pos h]
[GOAL]
case pos_top
x✝ : ℝ
h : 0 < x✝
⊢ -↑x✝ * ⊤ = -(↑x✝ * ⊤)
[PROOFSTEP]
| pos_top _ h => rw [coe_mul_top_of_pos h, neg_top, ← coe_neg, coe_mul_top_of_neg (neg_neg_of_pos h)]
[GOAL]
case pos_top
x✝ : ℝ
h : 0 < x✝
⊢ -↑x✝ * ⊤ = -(↑x✝ * ⊤)
[PROOFSTEP]
rw [coe_mul_top_of_pos h, neg_top, ← coe_neg, coe_mul_top_of_neg (neg_neg_of_pos h)]
[GOAL]
case top_neg
x✝ : ℝ
h : x✝ < 0
⊢ -⊤ * ↑x✝ = -(⊤ * ↑x✝)
[PROOFSTEP]
| top_neg _ h => rw [top_mul_coe_of_neg h, neg_top, bot_mul_coe_of_neg h, neg_bot]
[GOAL]
case top_neg
x✝ : ℝ
h : x✝ < 0
⊢ -⊤ * ↑x✝ = -(⊤ * ↑x✝)
[PROOFSTEP]
rw [top_mul_coe_of_neg h, neg_top, bot_mul_coe_of_neg h, neg_bot]
[GOAL]
case pos_bot
x✝ : ℝ
h : 0 < x✝
⊢ -↑x✝ * ⊥ = -(↑x✝ * ⊥)
[PROOFSTEP]
| pos_bot _ h => rw [coe_mul_bot_of_pos h, neg_bot, ← coe_neg, coe_mul_bot_of_neg (neg_neg_of_pos h)]
[GOAL]
case pos_bot
x✝ : ℝ
h : 0 < x✝
⊢ -↑x✝ * ⊥ = -(↑x✝ * ⊥)
[PROOFSTEP]
rw [coe_mul_bot_of_pos h, neg_bot, ← coe_neg, coe_mul_bot_of_neg (neg_neg_of_pos h)]
[GOAL]
x y : EReal
⊢ x * -y = -(x * y)
[PROOFSTEP]
rw [x.mul_comm, x.mul_comm]
[GOAL]
x y : EReal
⊢ -y * x = -(y * x)
[PROOFSTEP]
exact y.neg_mul x
[GOAL]
x : EReal
⊢ EReal.abs x = 0 ↔ x = 0
[PROOFSTEP]
induction x using EReal.rec
[GOAL]
case h_bot
⊢ EReal.abs ⊥ = 0 ↔ ⊥ = 0
[PROOFSTEP]
simp only [abs_bot, ENNReal.top_ne_zero, bot_ne_zero]
[GOAL]
case h_real
a✝ : ℝ
⊢ EReal.abs ↑a✝ = 0 ↔ ↑a✝ = 0
[PROOFSTEP]
simp only [abs_def, coe_eq_zero, ENNReal.ofReal_eq_zero, abs_nonpos_iff]
[GOAL]
case h_top
⊢ EReal.abs ⊤ = 0 ↔ ⊤ = 0
[PROOFSTEP]
simp only [abs_top, ENNReal.top_ne_zero, top_ne_zero]
[GOAL]
⊢ EReal.abs 0 = 0
[PROOFSTEP]
rw [abs_eq_zero_iff]
[GOAL]
x : ℝ
⊢ ↑(EReal.abs ↑x) = ↑|x|
[PROOFSTEP]
rw [abs_def, ← Real.coe_nnabs, ENNReal.ofReal_coe_nnreal]
[GOAL]
x : ℝ
⊢ ↑↑(↑Real.nnabs x) = ↑↑(↑Real.nnabs x)
[PROOFSTEP]
rfl
[GOAL]
x : ℝ
⊢ EReal.abs (-↑x) = EReal.abs ↑x
[PROOFSTEP]
rw [abs_def, ← coe_neg, abs_def, abs_neg]
[GOAL]
x y : EReal
⊢ EReal.abs (x * y) = EReal.abs x * EReal.abs y
[PROOFSTEP]
induction x, y using induction₂_symm_neg with
| top_zero => simp only [zero_mul, mul_zero, abs_zero]
| top_top => rfl
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => simp only [← coe_mul, abs_def, _root_.abs_mul, ENNReal.ofReal_mul (abs_nonneg _)]
| top_pos _ h =>
rw [top_mul_coe_of_pos h, abs_top, ENNReal.top_mul]
rw [Ne.def, abs_eq_zero_iff, coe_eq_zero]
exact h.ne'
| neg_left h => rwa [neg_mul, EReal.abs_neg, EReal.abs_neg]
[GOAL]
x y : EReal
⊢ EReal.abs (x * y) = EReal.abs x * EReal.abs y
[PROOFSTEP]
induction x, y using induction₂_symm_neg with
| top_zero => simp only [zero_mul, mul_zero, abs_zero]
| top_top => rfl
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => simp only [← coe_mul, abs_def, _root_.abs_mul, ENNReal.ofReal_mul (abs_nonneg _)]
| top_pos _ h =>
rw [top_mul_coe_of_pos h, abs_top, ENNReal.top_mul]
rw [Ne.def, abs_eq_zero_iff, coe_eq_zero]
exact h.ne'
| neg_left h => rwa [neg_mul, EReal.abs_neg, EReal.abs_neg]
[GOAL]
case top_zero
⊢ EReal.abs (⊤ * 0) = EReal.abs ⊤ * EReal.abs 0
[PROOFSTEP]
| top_zero => simp only [zero_mul, mul_zero, abs_zero]
[GOAL]
case top_zero
⊢ EReal.abs (⊤ * 0) = EReal.abs ⊤ * EReal.abs 0
[PROOFSTEP]
simp only [zero_mul, mul_zero, abs_zero]
[GOAL]
case top_top
⊢ EReal.abs (⊤ * ⊤) = EReal.abs ⊤ * EReal.abs ⊤
[PROOFSTEP]
| top_top => rfl
[GOAL]
case top_top
⊢ EReal.abs (⊤ * ⊤) = EReal.abs ⊤ * EReal.abs ⊤
[PROOFSTEP]
rfl
[GOAL]
case symm
x✝ y✝ : EReal
h : EReal.abs (x✝ * y✝) = EReal.abs x✝ * EReal.abs y✝
⊢ EReal.abs (y✝ * x✝) = EReal.abs y✝ * EReal.abs x✝
[PROOFSTEP]
| symm h => rwa [mul_comm, EReal.mul_comm]
[GOAL]
case symm
x✝ y✝ : EReal
h : EReal.abs (x✝ * y✝) = EReal.abs x✝ * EReal.abs y✝
⊢ EReal.abs (y✝ * x✝) = EReal.abs y✝ * EReal.abs x✝
[PROOFSTEP]
rwa [mul_comm, EReal.mul_comm]
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ EReal.abs (↑x✝ * ↑y✝) = EReal.abs ↑x✝ * EReal.abs ↑y✝
[PROOFSTEP]
| coe_coe => simp only [← coe_mul, abs_def, _root_.abs_mul, ENNReal.ofReal_mul (abs_nonneg _)]
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ EReal.abs (↑x✝ * ↑y✝) = EReal.abs ↑x✝ * EReal.abs ↑y✝
[PROOFSTEP]
simp only [← coe_mul, abs_def, _root_.abs_mul, ENNReal.ofReal_mul (abs_nonneg _)]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ EReal.abs (⊤ * ↑x✝) = EReal.abs ⊤ * EReal.abs ↑x✝
[PROOFSTEP]
| top_pos _ h =>
rw [top_mul_coe_of_pos h, abs_top, ENNReal.top_mul]
rw [Ne.def, abs_eq_zero_iff, coe_eq_zero]
exact h.ne'
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ EReal.abs (⊤ * ↑x✝) = EReal.abs ⊤ * EReal.abs ↑x✝
[PROOFSTEP]
rw [top_mul_coe_of_pos h, abs_top, ENNReal.top_mul]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ EReal.abs ↑x✝ ≠ 0
[PROOFSTEP]
rw [Ne.def, abs_eq_zero_iff, coe_eq_zero]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ ¬x✝ = 0
[PROOFSTEP]
exact h.ne'
[GOAL]
case neg_left
x✝ y✝ : EReal
h : EReal.abs (x✝ * y✝) = EReal.abs x✝ * EReal.abs y✝
⊢ EReal.abs (-x✝ * y✝) = EReal.abs (-x✝) * EReal.abs y✝
[PROOFSTEP]
| neg_left h => rwa [neg_mul, EReal.abs_neg, EReal.abs_neg]
[GOAL]
case neg_left
x✝ y✝ : EReal
h : EReal.abs (x✝ * y✝) = EReal.abs x✝ * EReal.abs y✝
⊢ EReal.abs (-x✝ * y✝) = EReal.abs (-x✝) * EReal.abs y✝
[PROOFSTEP]
rwa [neg_mul, EReal.abs_neg, EReal.abs_neg]
[GOAL]
x : ℝ
⊢ ↑sign ↑x = ↑sign x
[PROOFSTEP]
simp only [sign, OrderHom.coe_mk, EReal.coe_pos, EReal.coe_neg']
[GOAL]
x : SignType
⊢ ↑↑x = ↑x
[PROOFSTEP]
cases x
[GOAL]
case zero
⊢ ↑↑SignType.zero = ↑SignType.zero
[PROOFSTEP]
rfl
[GOAL]
case neg
⊢ ↑↑SignType.neg = ↑SignType.neg
[PROOFSTEP]
rfl
[GOAL]
case pos
⊢ ↑↑SignType.pos = ↑SignType.pos
[PROOFSTEP]
rfl
[GOAL]
x : ℝ
⊢ ↑sign (-↑x) = -↑sign ↑x
[PROOFSTEP]
rw [← coe_neg, sign_coe, sign_coe, Left.sign_neg]
[GOAL]
x y : EReal
⊢ ↑sign (x * y) = ↑sign x * ↑sign y
[PROOFSTEP]
induction x, y using induction₂_symm_neg with
| top_zero => simp only [zero_mul, mul_zero, sign_zero]
| top_top => rfl
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => simp only [← coe_mul, sign_coe, _root_.sign_mul, ENNReal.ofReal_mul (abs_nonneg _)]
| top_pos _ h => rw [top_mul_coe_of_pos h, sign_top, one_mul, sign_pos (EReal.coe_pos.2 h)]
| neg_left h => rw [neg_mul, sign_neg, sign_neg, h, neg_mul]
[GOAL]
x y : EReal
⊢ ↑sign (x * y) = ↑sign x * ↑sign y
[PROOFSTEP]
induction x, y using induction₂_symm_neg with
| top_zero => simp only [zero_mul, mul_zero, sign_zero]
| top_top => rfl
| symm h => rwa [mul_comm, EReal.mul_comm]
| coe_coe => simp only [← coe_mul, sign_coe, _root_.sign_mul, ENNReal.ofReal_mul (abs_nonneg _)]
| top_pos _ h => rw [top_mul_coe_of_pos h, sign_top, one_mul, sign_pos (EReal.coe_pos.2 h)]
| neg_left h => rw [neg_mul, sign_neg, sign_neg, h, neg_mul]
[GOAL]
case top_zero
⊢ ↑sign (⊤ * 0) = ↑sign ⊤ * ↑sign 0
[PROOFSTEP]
| top_zero => simp only [zero_mul, mul_zero, sign_zero]
[GOAL]
case top_zero
⊢ ↑sign (⊤ * 0) = ↑sign ⊤ * ↑sign 0
[PROOFSTEP]
simp only [zero_mul, mul_zero, sign_zero]
[GOAL]
case top_top
⊢ ↑sign (⊤ * ⊤) = ↑sign ⊤ * ↑sign ⊤
[PROOFSTEP]
| top_top => rfl
[GOAL]
case top_top
⊢ ↑sign (⊤ * ⊤) = ↑sign ⊤ * ↑sign ⊤
[PROOFSTEP]
rfl
[GOAL]
case symm
x✝ y✝ : EReal
h : ↑sign (x✝ * y✝) = ↑sign x✝ * ↑sign y✝
⊢ ↑sign (y✝ * x✝) = ↑sign y✝ * ↑sign x✝
[PROOFSTEP]
| symm h => rwa [mul_comm, EReal.mul_comm]
[GOAL]
case symm
x✝ y✝ : EReal
h : ↑sign (x✝ * y✝) = ↑sign x✝ * ↑sign y✝
⊢ ↑sign (y✝ * x✝) = ↑sign y✝ * ↑sign x✝
[PROOFSTEP]
rwa [mul_comm, EReal.mul_comm]
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ ↑sign (↑x✝ * ↑y✝) = ↑sign ↑x✝ * ↑sign ↑y✝
[PROOFSTEP]
| coe_coe => simp only [← coe_mul, sign_coe, _root_.sign_mul, ENNReal.ofReal_mul (abs_nonneg _)]
[GOAL]
case coe_coe
x✝ y✝ : ℝ
⊢ ↑sign (↑x✝ * ↑y✝) = ↑sign ↑x✝ * ↑sign ↑y✝
[PROOFSTEP]
simp only [← coe_mul, sign_coe, _root_.sign_mul, ENNReal.ofReal_mul (abs_nonneg _)]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ ↑sign (⊤ * ↑x✝) = ↑sign ⊤ * ↑sign ↑x✝
[PROOFSTEP]
| top_pos _ h => rw [top_mul_coe_of_pos h, sign_top, one_mul, sign_pos (EReal.coe_pos.2 h)]
[GOAL]
case top_pos
x✝ : ℝ
h : 0 < x✝
⊢ ↑sign (⊤ * ↑x✝) = ↑sign ⊤ * ↑sign ↑x✝
[PROOFSTEP]
rw [top_mul_coe_of_pos h, sign_top, one_mul, sign_pos (EReal.coe_pos.2 h)]
[GOAL]
case neg_left
x✝ y✝ : EReal
h : ↑sign (x✝ * y✝) = ↑sign x✝ * ↑sign y✝
⊢ ↑sign (-x✝ * y✝) = ↑sign (-x✝) * ↑sign y✝
[PROOFSTEP]
| neg_left h => rw [neg_mul, sign_neg, sign_neg, h, neg_mul]
[GOAL]
case neg_left
x✝ y✝ : EReal
h : ↑sign (x✝ * y✝) = ↑sign x✝ * ↑sign y✝
⊢ ↑sign (-x✝ * y✝) = ↑sign (-x✝) * ↑sign y✝
[PROOFSTEP]
rw [neg_mul, sign_neg, sign_neg, h, neg_mul]
[GOAL]
⊢ ↑(↑sign ⊥) * ↑(EReal.abs ⊥) = ⊥
[PROOFSTEP]
simp
[GOAL]
⊢ ↑(↑sign ⊤) * ↑(EReal.abs ⊤) = ⊤
[PROOFSTEP]
simp
[GOAL]
x : ℝ
⊢ ↑(↑sign ↑x) * ↑(EReal.abs ↑x) = ↑x
[PROOFSTEP]
rw [sign_coe, coe_abs, ← coe_coe_sign, ← coe_mul, sign_mul_abs]
[GOAL]
x : EReal
⊢ ↑(EReal.abs x) * ↑(↑sign x) = x
[PROOFSTEP]
rw [EReal.mul_comm, EReal.sign_mul_abs]
[GOAL]
x y : EReal
⊢ EReal.abs x = EReal.abs y ∧ ↑sign x = ↑sign y ↔ x = y
[PROOFSTEP]
constructor
[GOAL]
case mp
x y : EReal
⊢ EReal.abs x = EReal.abs y ∧ ↑sign x = ↑sign y → x = y
[PROOFSTEP]
rintro ⟨habs, hsign⟩
[GOAL]
case mp.intro
x y : EReal
habs : EReal.abs x = EReal.abs y
hsign : ↑sign x = ↑sign y
⊢ x = y
[PROOFSTEP]
rw [← x.sign_mul_abs, ← y.sign_mul_abs, habs, hsign]
[GOAL]
case mpr
x y : EReal
⊢ x = y → EReal.abs x = EReal.abs y ∧ ↑sign x = ↑sign y
[PROOFSTEP]
rintro rfl
[GOAL]
case mpr
x : EReal
⊢ EReal.abs x = EReal.abs x ∧ ↑sign x = ↑sign x
[PROOFSTEP]
exact ⟨rfl, rfl⟩
[GOAL]
x y : EReal
⊢ x ≤ y ↔
↑sign x < ↑sign y ∨
↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ ↑sign y = SignType.zero ∨
↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
constructor
[GOAL]
case mp
x y : EReal
⊢ x ≤ y →
↑sign x < ↑sign y ∨
↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ ↑sign y = SignType.zero ∨
↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
intro h
[GOAL]
case mp
x y : EReal
h : x ≤ y
⊢ ↑sign x < ↑sign y ∨
↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ ↑sign y = SignType.zero ∨
↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
refine (sign.monotone h).lt_or_eq.imp_right (fun hs => ?_)
[GOAL]
case mp
x y : EReal
h : x ≤ y
hs : ↑sign x = ↑sign y
⊢ ↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ ↑sign y = SignType.zero ∨
↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
rw [← x.sign_mul_abs, ← y.sign_mul_abs] at h
[GOAL]
case mp
x y : EReal
h : ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
⊢ ↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ ↑sign y = SignType.zero ∨
↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
cases hy : sign y
[GOAL]
case mp.zero
x y : EReal
h : ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.zero
⊢ ↑sign x = SignType.neg ∧ SignType.zero = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ SignType.zero = SignType.zero ∨
↑sign x = SignType.pos ∧ SignType.zero = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
rw [hs, hy] at h ⊢
[GOAL]
case mp.neg
x y : EReal
h : ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.neg
⊢ ↑sign x = SignType.neg ∧ SignType.neg = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ SignType.neg = SignType.zero ∨
↑sign x = SignType.pos ∧ SignType.neg = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
rw [hs, hy] at h ⊢
[GOAL]
case mp.pos
x y : EReal
h : ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.pos
⊢ ↑sign x = SignType.neg ∧ SignType.pos = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ SignType.pos = SignType.zero ∨
↑sign x = SignType.pos ∧ SignType.pos = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
rw [hs, hy] at h ⊢
[GOAL]
case mp.zero
x y : EReal
h : ↑SignType.zero * ↑(EReal.abs x) ≤ ↑SignType.zero * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.zero
⊢ SignType.zero = SignType.neg ∧ SignType.zero = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
SignType.zero = SignType.zero ∧ SignType.zero = SignType.zero ∨
SignType.zero = SignType.pos ∧ SignType.zero = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
simp
[GOAL]
case mp.neg
x y : EReal
h : ↑SignType.neg * ↑(EReal.abs x) ≤ ↑SignType.neg * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.neg
⊢ SignType.neg = SignType.neg ∧ SignType.neg = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
SignType.neg = SignType.zero ∧ SignType.neg = SignType.zero ∨
SignType.neg = SignType.pos ∧ SignType.neg = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
left
[GOAL]
case mp.neg.h
x y : EReal
h : ↑SignType.neg * ↑(EReal.abs x) ≤ ↑SignType.neg * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.neg
⊢ SignType.neg = SignType.neg ∧ SignType.neg = SignType.neg ∧ EReal.abs y ≤ EReal.abs x
[PROOFSTEP]
simpa using h
[GOAL]
case mp.pos
x y : EReal
h : ↑SignType.pos * ↑(EReal.abs x) ≤ ↑SignType.pos * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.pos
⊢ SignType.pos = SignType.neg ∧ SignType.pos = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
SignType.pos = SignType.zero ∧ SignType.pos = SignType.zero ∨
SignType.pos = SignType.pos ∧ SignType.pos = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
right
[GOAL]
case mp.pos.h
x y : EReal
h : ↑SignType.pos * ↑(EReal.abs x) ≤ ↑SignType.pos * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.pos
⊢ SignType.pos = SignType.zero ∧ SignType.pos = SignType.zero ∨
SignType.pos = SignType.pos ∧ SignType.pos = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
right
[GOAL]
case mp.pos.h.h
x y : EReal
h : ↑SignType.pos * ↑(EReal.abs x) ≤ ↑SignType.pos * ↑(EReal.abs y)
hs : ↑sign x = ↑sign y
hy : ↑sign y = SignType.pos
⊢ SignType.pos = SignType.pos ∧ SignType.pos = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
[PROOFSTEP]
simpa using h
[GOAL]
case mpr
x y : EReal
⊢ ↑sign x < ↑sign y ∨
↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x ∨
↑sign x = SignType.zero ∧ ↑sign y = SignType.zero ∨
↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y →
x ≤ y
[PROOFSTEP]
rintro (h | h | h | h)
[GOAL]
case mpr.inl
x y : EReal
h : ↑sign x < ↑sign y
⊢ x ≤ y
[PROOFSTEP]
exact (sign.monotone.reflect_lt h).le
[GOAL]
case mpr.inr.inl
x y : EReal
h : ↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x
⊢ x ≤ y
case mpr.inr.inr.inl
x y : EReal
h : ↑sign x = SignType.zero ∧ ↑sign y = SignType.zero
⊢ x ≤ y
case mpr.inr.inr.inr x y : EReal h : ↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y ⊢ x ≤ y
[PROOFSTEP]
all_goals rw [← x.sign_mul_abs, ← y.sign_mul_abs]; simp [h]
[GOAL]
case mpr.inr.inl
x y : EReal
h : ↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x
⊢ x ≤ y
[PROOFSTEP]
rw [← x.sign_mul_abs, ← y.sign_mul_abs]
[GOAL]
case mpr.inr.inl
x y : EReal
h : ↑sign x = SignType.neg ∧ ↑sign y = SignType.neg ∧ EReal.abs y ≤ EReal.abs x
⊢ ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
[PROOFSTEP]
simp [h]
[GOAL]
case mpr.inr.inr.inl
x y : EReal
h : ↑sign x = SignType.zero ∧ ↑sign y = SignType.zero
⊢ x ≤ y
[PROOFSTEP]
rw [← x.sign_mul_abs, ← y.sign_mul_abs]
[GOAL]
case mpr.inr.inr.inl
x y : EReal
h : ↑sign x = SignType.zero ∧ ↑sign y = SignType.zero
⊢ ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
[PROOFSTEP]
simp [h]
[GOAL]
case mpr.inr.inr.inr
x y : EReal
h : ↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
⊢ x ≤ y
[PROOFSTEP]
rw [← x.sign_mul_abs, ← y.sign_mul_abs]
[GOAL]
case mpr.inr.inr.inr
x y : EReal
h : ↑sign x = SignType.pos ∧ ↑sign y = SignType.pos ∧ EReal.abs x ≤ EReal.abs y
⊢ ↑(↑sign x) * ↑(EReal.abs x) ≤ ↑(↑sign y) * ↑(EReal.abs y)
[PROOFSTEP]
simp [h]
[GOAL]
src✝ : MulZeroOneClass EReal := inferInstanceAs (MulZeroOneClass EReal)
x y z : EReal
⊢ x * y * z = x * (y * z)
[PROOFSTEP]
rw [← sign_eq_and_abs_eq_iff_eq]
[GOAL]
src✝ : MulZeroOneClass EReal := inferInstanceAs (MulZeroOneClass EReal)
x y z : EReal
⊢ EReal.abs (x * y * z) = EReal.abs (x * (y * z)) ∧ ↑sign (x * y * z) = ↑sign (x * (y * z))
[PROOFSTEP]
simp only [mul_assoc, abs_mul, eq_self_iff_true, sign_mul, and_self_iff]
[GOAL]
⊢ Covariant { x // 0 < x } EReal (fun x y => ↑x * y) fun x x_1 => x ≤ x_1
[PROOFSTEP]
rintro ⟨x, x0⟩ a b h
[GOAL]
case mk
x : EReal
x0 : 0 < x
a b : EReal
h : a ≤ b
⊢ (fun x y => ↑x * y) { val := x, property := x0 } a ≤ (fun x y => ↑x * y) { val := x, property := x0 } b
[PROOFSTEP]
simp only [le_iff_sign, EReal.sign_mul, sign_pos x0, one_mul, EReal.abs_mul] at h ⊢
[GOAL]
case mk
x : EReal
x0 : 0 < x
a b : EReal
h :
↑sign a < ↑sign b ∨
↑sign a = SignType.neg ∧ ↑sign b = SignType.neg ∧ EReal.abs b ≤ EReal.abs a ∨
↑sign a = SignType.zero ∧ ↑sign b = SignType.zero ∨
↑sign a = SignType.pos ∧ ↑sign b = SignType.pos ∧ EReal.abs a ≤ EReal.abs b
⊢ ↑sign a < ↑sign b ∨
↑sign a = SignType.neg ∧ ↑sign b = SignType.neg ∧ EReal.abs x * EReal.abs b ≤ EReal.abs x * EReal.abs a ∨
↑sign a = SignType.zero ∧ ↑sign b = SignType.zero ∨
↑sign a = SignType.pos ∧ ↑sign b = SignType.pos ∧ EReal.abs x * EReal.abs a ≤ EReal.abs x * EReal.abs b
[PROOFSTEP]
exact
h.imp_right <|
Or.imp (And.imp_right <| And.imp_right (mul_le_mul_left' · _)) <|
Or.imp_right <| And.imp_right <| And.imp_right (mul_le_mul_left' · _)
|
lemma holomorphic_on_balls_imp_entire': assumes "\<And>r. r > 0 \<Longrightarrow> f holomorphic_on ball c r" shows "f holomorphic_on B" |
% INVWISHIRND - Inverse Wishart Random Matrix
% Copyright (c) 1998, Harvard University. Full copyright in the file Copyright
%
% [IW] = invwishirnd(S,d)
%
% S = p x p symmetric, postitive definite "scale" matrix
% d = "degrees of freedom" parameter
% = "precision" parameter
% (d must be an integer for this routine, see INVWISHRND)
%
% IW = random matrix from the inverse Wishart distribution
%
% Note:
% different sources use different parameterizations w.r.t. nu
% this routine uses that of Press and Shigemasu (1989):
% density(IW) is proportional to
% exp[-.5*trace(S*inv(IW))] / [det(IW) ^ (d/2)].
%
% With this density definition:
% mean(IW) = S/(d-2p-2) when d>2p+2,
% mode(IW) = S/d.
%
% See also: INVWISHRND, WISHRND
function [IW] = invwishirnd(S,d)
[p,p2] = size(S) ;
W = wishirnd(inv(S),d-p-1) ;
IW = inv(W) ;
|
lemma has_complex_derivative_locally_injective: assumes holf: "f holomorphic_on S" and S: "\<xi> \<in> S" "open S" and dnz: "deriv f \<xi> \<noteq> 0" obtains r where "r > 0" "ball \<xi> r \<subseteq> S" "inj_on f (ball \<xi> r)" |
import geometry.manifold.smooth_manifold_with_corners
open_locale topology
open metric (hiding mem_nhds_iff ball) set
section
variables {𝕜 E M H : Type*} [nontrivially_normed_field 𝕜]
variables [topological_space H] [topological_space M] [charted_space H M]
variables [normed_add_comm_group E] [normed_space 𝕜 E]
variables (I : model_with_corners 𝕜 E H)
lemma map_ext_chart_at_nhds_of_boundaryless [I.boundaryless] {x : M} :
filter.map (ext_chart_at I x) (𝓝 x) = 𝓝 (ext_chart_at I x x) :=
by rw [map_ext_chart_at_nhds I x, model_with_corners.boundaryless.range_eq_univ, nhds_within_univ]
lemma ext_chart_at_image_nhd_mem_nhds_of_boundaryless [I.boundaryless]
{x : M} {s : set M} (h : s ∈ 𝓝 x) :
(ext_chart_at I x) '' s ∈ 𝓝 (ext_chart_at I x x) :=
begin
rw [← map_ext_chart_at_nhds_of_boundaryless, filter.mem_map],
filter_upwards [h] using subset_preimage_image (ext_chart_at I x) s,
end
namespace charted_space
/-- If `M` is a `charted_space` we can use the preferred chart at any point to transfer a
ball in coordinate space into a set in `M`. These can be a useful neighbourhood basis. -/
def ball (x : M) (r : ℝ) := (ext_chart_at I x).symm '' metric.ball (ext_chart_at I x x) r
lemma nhds_has_basis_balls_of_open_cov [I.boundaryless] (x : M)
{ι : Type*} {s : ι → set M} (s_op : ∀ j, is_open $ s j) (cov : (⋃ j, s j) = univ) :
(𝓝 x).has_basis (λ r, 0 < r ∧
metric.ball (ext_chart_at I x x) r ⊆ (ext_chart_at I x).target ∧
∃ j, charted_space.ball I x r ⊆ s j)
(charted_space.ball I x) :=
begin
-- TODO golf etc
obtain ⟨j, hj⟩ : ∃ j, x ∈ s j, by { simpa only [mem_Union, ← cov] using mem_univ x, },
replace hj : s j ∈ 𝓝 x := mem_nhds_iff.mpr ⟨s j, subset.rfl, s_op j, hj⟩,
have hx : (ext_chart_at I x).source ∈ 𝓝 x := ext_chart_at_source_mem_nhds I x,
refine filter.has_basis_iff.mpr (λ n, ⟨λ hn, _, _⟩),
{ let m := s j ∩ n ∩ (ext_chart_at I x).source,
have hm : m ∈ 𝓝 x := filter.inter_mem (filter.inter_mem hj hn) hx,
replace hm : (ext_chart_at I x) '' m ∈ 𝓝 (ext_chart_at I x x) :=
ext_chart_at_image_nhd_mem_nhds_of_boundaryless I hm,
obtain ⟨r, hr₀, hr₁⟩ :=
(filter.has_basis_iff.mp (@nhds_basis_ball E _ (ext_chart_at I x x)) _).mp hm,
refine ⟨r, ⟨hr₀, hr₁.trans _, ⟨j, _⟩⟩, _⟩,
{ exact ((ext_chart_at I x).maps_to.mono (inter_subset_right _ _) subset.rfl).image_subset },
{ suffices : m ⊆ s j,
{ refine subset.trans _ this,
convert monotone_image hr₁,
exact (local_equiv.symm_image_image_of_subset_source _
(set.inter_subset_right _ _)).symm, },
exact (set.inter_subset_left _ _).trans (set.inter_subset_left _ _), },
{ suffices : m ⊆ n,
{ refine subset.trans _ this,
convert monotone_image hr₁,
exact (local_equiv.symm_image_image_of_subset_source _
(set.inter_subset_right _ _)).symm, },
exact (set.inter_subset_left _ _).trans (set.inter_subset_right _ _), }, },
{ rintros ⟨r, ⟨hr₀, hr₁, -⟩, hr₂⟩,
replace hr₀ : metric.ball (ext_chart_at I x x) r ∈ 𝓝 (ext_chart_at I x x) := ball_mem_nhds _ hr₀,
rw [← map_ext_chart_at_nhds_of_boundaryless, filter.mem_map] at hr₀,
replace hr₀ := filter.inter_mem hx hr₀,
rw ← (ext_chart_at I x).symm_image_eq_source_inter_preimage hr₁ at hr₀,
filter_upwards [hr₀] using hr₂, },
end
end charted_space
end
section
variables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E] [finite_dimensional ℝ E]
{H : Type*} [topological_space H] (I : model_with_corners ℝ E H) (M : Type*)
[topological_space M] [charted_space H M]
lemma locally_compact_manifold :
locally_compact_space M :=
@charted_space.locally_compact H M _ _ _ I.locally_compact
end
|
{-# OPTIONS --cubical --safe #-}
module FreeReader where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Function.Base using (id; _$_)
open import Class
open Functor
variable
A B C : Set
-- The Reader monad, as a free monad
data FreeReader (R : Set) : Set → Set₁ where
Pure : A → FreeReader R A
Bind : FreeReader R A → (A → FreeReader R B) → FreeReader R B
Ask : FreeReader R R
-- Monad laws
LeftId : ∀ {A B}
→ (a : A)
→ (f : A → FreeReader R B)
→ Bind (Pure a) f ≡ f a
RightId : ∀ {A}
→ (m : FreeReader R A)
→ Bind m Pure ≡ m
Assoc : ∀ {A B C}
→ (m : FreeReader R A)
→ (f : A → FreeReader R B)
→ (g : B → FreeReader R C)
→ Bind (Bind m f) g ≡ Bind m (λ x → Bind (f x) g)
freereader-functor : ∀ {R} → Functor (FreeReader R)
freereader-functor .fmap f m = Bind m (Pure ∘ f)
freereader-functor .fmap-id-legit m i = RightId m i
freereader-functor .fmap-compose-legit m f g i
= hcomp (λ j → λ { (i = i0) → Bind m (Pure ∘ f ∘ g)
; (i = i1) → Assoc m (Pure ∘ g) (Pure ∘ f) (~ j)
})
(Bind m (λ x → LeftId (g x) (Pure ∘ f) (~ i)))
freereader-ap : ∀ {R} → Applicative (FreeReader R)
freereader-ap .Applicative.functor = freereader-functor
freereader-ap .Applicative.pure = Pure
freereader-ap .Applicative._<*>_ mf m = Bind mf (λ f → Bind m (Pure ∘ f))
freereader-ap .Applicative.app-identity v i
= hcomp (λ j → λ { (i = i0) → LeftId id (λ f → Bind v (Pure ∘ f)) (~ j)
; (i = i1) → v
})
(RightId v i)
freereader-ap .Applicative.app-compose u v w
-- For some reason, Agda doesn't like wildcards in cubical proofs. Oh well.
= Pure _∘_ <*> u <*> v <*> w
≡[ i ]⟨ LeftId _∘_ (λ f → Bind u (Pure ∘ f)) i <*> v <*> w ⟩
Bind u (λ u' → Pure (u' ∘_)) <*> v <*> w
≡[ i ]⟨ Assoc u (λ u' → Pure (u' ∘_)) (λ f → Bind v (Pure ∘ f)) i <*> w ⟩
Bind u (λ u' → Bind (Pure (u' ∘_)) (λ c → Bind v (Pure ∘ c))) <*> w
≡[ i ]⟨ Bind u (λ u' → LeftId (u' ∘_) (λ c → Bind v (Pure ∘ c)) i) <*> w ⟩
Bind u (λ u' → Bind v (λ v' → Pure (u' ∘ v'))) <*> w
≡[ i ]⟨ Assoc u (λ u' → Bind v (λ v' → Pure (u' ∘ v'))) (λ f → Bind w (Pure ∘ f)) i ⟩
Bind u (λ u' → Bind (Bind v (λ v' → Pure (u' ∘ v'))) (λ f → Bind w (Pure ∘ f)))
≡[ i ]⟨ Bind u (λ u' → Assoc v (λ v' → Pure (u' ∘ v')) (λ f → Bind w (Pure ∘ f)) i) ⟩
Bind u (λ u' → Bind v (λ v' → Bind (Pure (u' ∘ v')) (λ f → Bind w (Pure ∘ f))))
≡[ i ]⟨ Bind u (λ u' → Bind v (λ v' → LeftId (u' ∘ v') (λ f → Bind w (Pure ∘ f)) i)) ⟩
Bind u (λ u' → Bind v (λ v' → Bind w (Pure ∘ u' ∘ v')))
≡[ i ]⟨ Bind u (λ u' → Bind v (λ v' → Bind w (λ w' → LeftId (v' w') (Pure ∘ u') (~ i)))) ⟩
Bind u (λ u' → Bind v (λ v' → Bind w (λ w' → Bind (Pure (v' w')) (Pure ∘ u'))))
≡[ i ]⟨ Bind u (λ u' → Bind v (λ v' → Assoc w (Pure ∘ v') (Pure ∘ u') (~ i))) ⟩
Bind u (λ u' → Bind v (λ v' → Bind (Bind w (Pure ∘ v')) (Pure ∘ u')))
≡[ i ]⟨ Bind u (λ u' → Assoc v (λ f → Bind w (Pure ∘ f)) (Pure ∘ u') (~ i)) ⟩
Bind u (λ u' → Bind (Bind v (λ v' → Bind w (Pure ∘ v'))) (Pure ∘ u'))
∎
where open Applicative freereader-ap
freereader-ap .Applicative.app-homo f x
= LeftId f (λ f' → Bind (Pure x) (λ x' → Pure (f' x')))
∙ LeftId x (λ x' → Pure (f x'))
freereader-ap .Applicative.app-intchg u y
-- u <*> pure y
= Bind u (λ u' → Bind (Pure y) (Pure ∘ u'))
≡[ i ]⟨ Bind u (λ u' → LeftId y (Pure ∘ u') i) ⟩
Bind u (λ u' → Pure (u' y))
≡[ i ]⟨ LeftId (_$ y) (λ f → Bind u (Pure ∘ f)) (~ i) ⟩
Bind (Pure (_$ y)) (λ _y' → Bind u (λ u' → Pure (u' y')))
-- pure (_$ y) <*> u
∎
freereader-monad : ∀ {R} → Monad (FreeReader R)
freereader-monad .Monad.applicative = freereader-ap
freereader-monad .Monad._>>=_ = Bind
freereader-monad .Monad.monad-left-id = LeftId
freereader-monad .Monad.monad-right-id = RightId
freereader-monad .Monad.monad-assoc = Assoc
|
```python
%run ../../common/import_all.py
from common.setup_notebook import set_css_style, setup_matplotlib, config_ipython
config_ipython()
setup_matplotlib()
set_css_style()
```
<style>
/* DOWNLOAD COMPUTER MODERN FONT JUST IN CASE */
@font-face {
font-family: "Computer Modern";
src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunss.otf');
}
@font-face {
font-family: "Computer Modern";
font-weight: bold;
src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunsx.otf');
}
@font-face {
font-family: "Computer Modern";
font-style: oblique;
src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunsi.otf');
}
@font-face {
font-family: "Computer Modern";
font-weight: bold;
font-style: oblique;
src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunso.otf');
}
/* GLOBAL TEXT FONT */
div#notebook,
div.output_area pre,
div.output_wrapper,
div.prompt {
font-family: Times new Roman, monospace !important;
}
/* CENTER FIGURE */
.output_png {
display: table-cell;
text-align: center;
vertical-align: middle;
}
/* LINK */
a {
color: #FF8000;
}
/* H1 */
h1 {
font-size: 42px !important;
text-align: center;
color: #FF8000;
}
/* H2 */
h2 {
font-size: 32px !important;
}
/* H2 */
h3 {
font-size: 24px !important;
}
/* H2 */
h4 {
font-size: 20px !important;
}
/* PARAGRAPH */
p {
font-size: 16px !important;
text-align: center;
}
/* LIST ITEM */
li {
font-size: 16px !important;
}
</style>
# Independence; joint/marginal/conditional probability; covariance and correlation
## Statistical independence
Two random variables $X$ and $Y$ are said to be *independent* when their joint probability is equal to the product of the probabilities of each:
$$
P(X, Y) = P(X) P(Y) \ .
$$
This means, in terms of conditional probabilities,
$$
P(X | Y) = \frac{P(X, Y)}{P(Y)} = \frac{P(X)P(Y)}{P(Y)} = P(X) \ ,
$$
that is, the probability of $X$ occurring is not affected by the occurring of $Y$. This is typically how independence is defined, in word terms: the occurrence of one event does not influence the occurrence of the other.
### IID variables
I.I.D. stands for *independent* and *identically distributed*, it's a shortening used all over in statistics. IID variables are [independent](independence.ipynb) but also distributed in the same way.
The concept is the basic assumptions of many foundational results in statistics.
## The joint probability
The joint probability of one or more events is the probability that they happen together. If $X$, $Y$, $Z$, ... are the random variables, their joint probability is written as
$$
P(X, Y, Z, \ldots)
$$
or as
$$
P(X \cap Y \cap Z \ldots)
$$
### The case of independent variables
If the variables are independent, their joint probability reduces to the product of their probabilities: $P(X_1, X_2, \ldots, X_n) = \Pi_{i=1}^n P(X_i)$.
## The marginal probability
<figure style="float:left;">
<figcaption>Image by IkamusumeFan (Own work) [<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY-SA 3.0</a>], <a href="https://commons.wikimedia.org/wiki/File%3AMultivariate_normal_sample.svg">via Wikimedia Commons</a></figcaption>
</figure>
If we have the joint probability of two or more random variables, the marginal probability of each is the probability related to that variable and to its own space of events; it expresses the probability of the variable when the value of the other one is not known. It calculated by summing the joint probability over the space of events of the other variable. More specifically, given $P(X, Y) = P(X=x, Y=y)$,
$$
P(X=x) = \sum_y P(X=x, Y=y) \ .
$$
The illustration here shows points extracted from a joint probability (the black dots) and the marginal probabilities as well.
## The conditional probability
The conditional probability expresses the probability that an event occurrs given that another one has occurred. With $Y$ being the (variable related to the) event that has occurred and $X$ the (variable related to the) event whose probability of occurrence we are interested in, it is defined as
$$
P(X | Y) = \frac{P(X, Y)}{P(Y)} \ ,
$$
that is, as the ratio of the joint probability of the two to the probability of $Y$.
In the case of more than two variables we can write the joint probability as
$$
P(X_1, X_2, \ldots, X_n) = P(X_1 | X_2, \ldots, X_n) P(X_2, \ldots, X_n)
$$
and can repeat the process to isolate them one by one, obtaining
$$
P(\cap_{i=1}^n X_i) = \Pi_{i=1}^n P(X_i | \cap_{j=i+1}^{n} X_j) \ ,
$$
which is known as the [chain rule](https://en.wikipedia.org/wiki/Chain_rule_(probability).
### In the case of independence
This is easy, we would have
$$
P(X | Y) = \frac{P(X, Y)}{P(Y)} = \frac{P(X) P(Y)}{P(Y)} = P(X) \ ,
$$
which indicates what is suggested by the definition itself: independent variables mean that the happening of one does not influence the happening of the other.
## Covariance and correlation
### Covariance
Given the random variables $X$ and $Y$ with respective means $\mu_x$ and $\mu_y$, their *covariance* is defined as
$$
\text{cov}(X, Y) = \mathbb{E}[(X - \mu_x)((Y - \mu_y)]
$$
It is a measure of how jointly the two variables vary: a positive covariance means that when $X$ grows, $Y$ grows as well and a negative covariance means that when $X$ grows, $Y$ decreases.
### Correlation
The word *correlation* is measured by a *correlation coefficient* which exists in several definitions depending on what is exactly measured; it is always a sort of normalised covariance.
The correspondent of the covariance itself is Pearson's definition, which defines the correlation coefficient as the covariance normalised by the product of the standard deviations of the two variables:
$$
\rho_{xy} = \frac{\text{cov}(x, y)}{\sigma_x \sigma_y} = \frac{\mathbb{E}[(x - \mu_x)(y - \mu_y)]}{\sigma_x \sigma_y} \ ,
$$
and it can also be written as
$$
\begin{align}
\rho_{xy} &= \frac{\mathbb{E}[(xy - x \mu_y - \mu_x y + \mu_x \mu_y)]}{\sigma_x \sigma_y} \\
&= \frac{\mathbb{E}[xy] - \mu_x\mu_y - \mu_y\mu_x + \mu_x\mu_y}{\sigma_x \sigma_y} \\
&= \frac{\mathbb{E}[xy] - \mu_x\mu_y}{\sigma_x \sigma_y} \ .
\end{align}
$$
The correlation coefficient has these properties:
* $-1 \leq \rho_{xy} \leq 1$
* It is symmetric: $\rho_{xy} = \rho_{yx}$
* If the variables are independent, then $\rho_{xy} = 0$ (but the reverse is not true)
### Independence and correlation
Let's expand on the last point there really. We said that if two random variables are independent, then the correlation coefficient is zero. This is easy to prove as it follows directly from the definition above (also bear in mind [Fubini's theorem](https://en.wikipedia.org/wiki/Fubini's_theorem)):
$$
\mathbb{E}[XY] = \int_{\Omega_X } \int_{\Omega_Y} \text{d} x \text{d} y \ xy P(x,y) = \int_{\Omega_X } \int_{\Omega_Y} \text{d} x \text{d} y \ xy P(x) P(y) = \mu_x \mu_y \ .
$$
The reverse is not true. Look at this amazing Q&A on [Cross Validated](https://stats.stackexchange.com/questions/12842/covariance-and-independence#) for a well explained counter-example.
### Correlation and the relation between variables
Correlation says "how much" it happens that when $x$ grows, $y$ grows as well. It is not a measure of the slope of the linear relation between $x$ and $y$. This is greatly illustrated in the figure above (from Wikipedia's [page](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient)), which reports sets of data points with $x$ and $y$ and their correlation coefficient.
In the center figure, because the variance of $y$ is 0, then the correlation is undefined. In the bottom row, the relation between variables is not linear, the correlation does not capture that.
```python
```
|
module ParticleTrackingEngineModule
use TrackPathResultModule,only : TrackPathResultType
use ParticleLocationModule,only : ParticleLocationType
use ParticleLocationListModule,only : ParticleLocationListType
use ParticleCoordinateModule,only : ParticleCoordinateType
use TrackCellModule,only : TrackCellType
use TrackCellResultModule,only : TrackCellResultType
use BudgetReaderModule,only : BudgetReaderType
use HeadReaderModule,only : HeadReaderType
use BudgetListItemModule,only : BudgetListItemType
use ModflowRectangularGridModule,only : ModflowRectangularGridType
use ModpathCellDataModule,only : ModpathCellDataType
use ModpathSubCellDataModule,only : ModpathSubCellDataType
use ParticleTrackingOptionsModule,only : ParticleTrackingOptionsType
use BudgetRecordHeaderModule,only : BudgetRecordHeaderType
use UtilMiscModule,only : TrimAll
! use ModpathUnstructuredBasicDataModule,only : ModpathUnstructuredBasicDataType
implicit none
! Set default access status to private
private
type,public :: ParticleTrackingEngineType
! doubleprecision :: ReferenceTime = 0d0
! doubleprecision :: StoppingTime = 0d0
doubleprecision :: HDry = 0d0
doubleprecision :: HNoFlow = 0d0
type(ParticleTrackingOptionsType) :: TrackingOptions
type(ModpathCellDataType) :: CellDataBuffer
logical :: Initialized = .false.
logical :: SteadyState = .true.
integer :: DefaultIfaceCount
character(len=16),dimension(20) :: DefaultIfaceLabels
integer,dimension(20) :: DefaultIfaceValues
integer,allocatable,dimension(:) :: IBoundTS
doubleprecision,allocatable,dimension(:) :: Heads
doubleprecision,allocatable,dimension(:) :: FlowsJA
doubleprecision,allocatable,dimension(:) :: FlowsRightFace
doubleprecision,allocatable,dimension(:) :: FlowsFrontFace
doubleprecision,allocatable,dimension(:) :: FlowsLowerFace
doubleprecision,allocatable,dimension(:) :: SourceFlows
doubleprecision,allocatable,dimension(:) :: SinkFlows
doubleprecision,allocatable,dimension(:) :: StorageFlows
doubleprecision,allocatable,dimension(:) :: BoundaryFlows
doubleprecision,allocatable,dimension(:) :: SubFaceFlows
doubleprecision,allocatable,dimension(:) :: ArrayBufferDbl
! Externally assigned arrays
!integer,dimension(:),pointer :: LayerTypes
integer,dimension(:),pointer :: IBound
integer,dimension(:),pointer :: Zones
doubleprecision,dimension(:),pointer :: Porosity
doubleprecision,dimension(:),pointer :: Retardation
! Private variables
type(HeadReadertype),pointer :: HeadReader => null()
type(BudgetReaderType),pointer :: BudgetReader => null()
class(ModflowRectangularGridType),pointer :: Grid => null()
type(TrackCellType),private :: TrackCell
type(TrackCellResultType),private :: TrackCellResult
integer,private :: CurrentStressPeriod = 0
integer,private :: CurrentTimeStep = 0
integer,private :: MaxReducedCellConnectionsCount = 17
doubleprecision,dimension(17),private :: CellFlowsBuffer
integer,dimension(17),private :: ReducedCellConnectionsBuffer
type(BudgetListItemType),allocatable,dimension(:) :: ListItemBuffer
logical,allocatable,dimension(:),private :: SubFaceFlowsComputed
type(ParticleLocationListType) :: LocBuffP
type(ParticleLocationListType) :: LocBuffTS
contains
procedure :: Initialize=>pr_Initialize
procedure :: Reset=>pr_Reset
procedure :: ClearTimeStepBudgetData=>pr_ClearTimeStepBudgetData
procedure :: TrackPath=>pr_TrackPath
procedure :: FillCellBuffer=>pr_FillCellBuffer
procedure :: LoadTimeStep=>pr_LoadTimeStep
procedure :: FillFaceFlowsBuffer=>pr_FillFaceFlowsBuffer
procedure :: GetCurrentStressPeriod=>pr_GetCurrentStressPeriod
procedure :: GetCurrentTimeStep=>pr_GetCurrentTimeStep
procedure :: FillCellFlowsBuffer=>pr_FillCellFlowsBuffer
procedure :: SetIBound=>pr_SetIBound
procedure :: SetZones=>pr_SetZones
procedure :: SetPorosity=>pr_SetPorosity
procedure :: SetRetardation=>pr_SetRetardation
!procedure :: SetLayerTypes=>pr_SetLayerTypes
procedure :: SetDefaultIface=>pr_SetDefaultIface
procedure :: CheckForDefaultIface=>pr_CheckForDefaultIface
procedure :: GetVolumetricBalanceSummary=>pr_GetVolumetricBalanceSummary
procedure :: WriteCellBuffer=>pr_WriteCellBuffer
procedure :: GetTopMostActiveCell=>pr_GetTopMostActiveCell
end type
contains
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
! implicit none
!---------------------------------------------------------------------------------------------------------------
function pr_GetTopMostActiveCell(this, cellNumber) result(n)
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: cellNumber
integer :: n
n = cellNumber
do while(.true.)
if(n .eq. 0) return
if(this%IboundTS(n) .ne. 0) return
n = this%Grid%GetFaceConnection(n, 5, 1)
end do
end function pr_GetTopMostActiveCell
subroutine pr_WriteCellBuffer(this, unit, cellData, backwardTracking)
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: unit
logical,intent(in) :: backwardTracking
type(ModpathCellDataType),intent(in) :: cellData
!---------------------------------------------------------------------------------------------------------------
write(unit, '(1X,A)') '-------------------------------------'
write(unit, '(1X,A,I10)') ' Cell', cellData%CellNumber
write(unit, '(1X,A)') '-------------------------------------'
call WriteCellData(unit, cellData, backwardTracking)
end subroutine pr_WriteCellBuffer
subroutine WriteCellData(unit, cellData, backwardTracking)
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
integer,intent(in) :: unit
logical,intent(in) :: backwardTracking
type(ModpathCellDataType),intent(in) :: cellData
type(ModpathSubCellDataType) :: subCellData
integer :: m, n, count, row, column, subRowCount, subColumnCount
doubleprecision :: balance, totalFaceInflow, totalFaceOutflow, sourceInflow, &
sinkOutflow, storageInflow, storageOutflow, netFaceInflow
doubleprecision :: totalInflow, totalOutflow, netInflow
!---------------------------------------------------------------------------------------------------------------
write(unit, '(1X,A,5I10)') 'Layer, Ibound, IboundTS, Zone, LayerType: ', &
cellData%Layer, cellData%Ibound, cellData%IboundTS, cellData%Zone, &
cellData%LayerType
write(unit, '(1X,A,4E15.7)') 'DX, DY, MinX, MinY: ', cellData%DX, &
cellData%DY, cellData%MinX, cellData%MinY
write(unit, '(1X,A,3E15.7)') 'Bottom, Top, Head: ', cellData%Bottom, &
cellData%Top, cellData%Head
write(unit, '(1x,A,2E15.7)') 'Porosity, Retardation: ', cellData%Porosity, &
cellData%Retardation
write(unit, *)
write(unit, '(1X,A)') 'Volumetric Face Flows (L**3/T):'
write(unit, '(17X,4(15X,A))') 'sub-face 1', 'sub-face 2', 'sub-face 3', 'sub-face 4'
write(unit, '(1X,A,4E25.15)') 'Left (face 1):',(cellData%GetFaceFlow(1,n), n = 1, cellData%GetSubFaceCount(1))
write(unit, '(1X,A,4E25.15)') 'Right (face 2):',(cellData%GetFaceFlow(2,n), n = 1, cellData%GetSubFaceCount(2))
write(unit, '(1X,A,4E25.15)') 'Front (face 3):',(cellData%GetFaceFlow(3,n), n = 1, cellData%GetSubFaceCount(3))
write(unit, '(1X,A,4E25.15)') 'Back (face 4):',(cellData%GetFaceFlow(4,n), n = 1, cellData%GetSubFaceCount(4))
write(unit, '(1X,A,4E25.15)') 'Bottom (face 5):',(cellData%GetFaceFlow(5,n), n = 1, cellData%GetSubFaceCount(5))
write(unit, '(1X,A,4E25.15)') 'Top (face 6):',(cellData%GetFaceFlow(6,n), n = 1, cellData%GetSubFaceCount(6))
call cellData%GetVolumetricBalanceComponents(totalFaceInflow, &
totalFaceOutflow, sourceInflow, sinkOutflow, storageInflow, storageOutflow, balance)
totalInflow = totalFaceInflow + sourceInflow + storageInflow
totalOutflow = totalFaceOutflow + sinkOutflow + storageOutflow
netInflow = totalInflow - totalOutflow
write(unit, *)
write(unit, '(1X,A)') 'Water balance components:'
write(unit, '(1X,A)') 'Inflow (L**3/T)'
write(unit, '(1X,A,E25.15)') ' Total face inflow =', totalFaceInflow
write(unit, '(1X,A,E25.15)') ' Source inflow =', sourceInflow
write(unit, '(1X,A,E25.15)') ' Storage inflow =', storageInflow
write(unit, '(27X,A)') '-----------------------'
write(unit, '(1X,A,E25.15)') ' Inflow =', totalInflow
write(unit, *)
write(unit, '(1X,A)') 'Outflow (L**3/T)'
write(unit, '(1X,A,E25.15)') ' Total face outflow =', totalFaceOutflow
write(unit, '(1X,A,E25.15)') ' Sink outflow =', sinkOutflow
write(unit, '(1X,A,E25.15)') ' Storage outflow =', storageOutflow
write(unit, '(27X,A)') '-----------------------'
write(unit, '(1X,A,E25.15)') ' Ouflow =', totalOutflow
write(unit, *)
write(unit, '(1X,A,E25.15)') ' Inflow - Outflow =', netInflow
write(unit, *)
write(unit, '(1X,A,E25.15)') ' Percent discrepancy =', balance
write(unit, *)
if(backwardTracking) then
write(unit, '(1X,A)') &
'Face velocities (Backward tracking. Velocity components has been reversed to represent backward tracking.)'
else
write(unit, '(1X,A)') 'Face velocities (Forward tracking)'
end if
subRowCount = cellData%GetSubCellRowCount()
subColumnCount = cellData%GetSubCellColumnCount()
do row = 1, subRowCount
do column = 1, subColumnCount
call cellData%FillSubCellDataBuffer(subCellData, row, column, backwardTracking)
write(unit, '(1X,A,I2,A,I2,A)') 'SubCell (', row, ', ', column, ')'
write(unit, '(1X,A,3E15.7)') 'DX, DY, DZ: ', subCellData%DX, subCellData%DY, subCellData%DZ
write(unit, '(23X,A,5X,A)') 'Face Velocity (L/T)', 'Connection'
write(unit, '(1X,A,E25.15,I15)') 'Left (face 1):', subCellData%VX1, subCellData%Connection(1)
write(unit, '(1X,A,E25.15,I15)') 'Right (face 2):', subCellData%VX2, subCellData%Connection(2)
write(unit, '(1X,A,E25.15,I15)') 'Front (face 3):', subCellData%VY1, subCellData%Connection(3)
write(unit, '(1X,A,E25.15,I15)') 'Back (face 4):', subCellData%VY2, subCellData%Connection(4)
write(unit, '(1X,A,E25.15,I15)') 'Bottom (face 5):', subCellData%VZ1, subCellData%Connection(5)
write(unit, '(1X,A,E25.15,I15)') 'Top (face 6):', subCellData%VZ2, subCellData%Connection(6)
write(unit, *)
end do
end do
end subroutine WriteCellData
subroutine WriteTraceData(unit, trackCell, tcResult, stressPeriod, timeStep)
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
type(TrackCellType),intent(in),target :: trackCell
type(TrackCellResultType),intent(in),target :: tcResult
type(ModpathCellDataType),pointer :: cellData
type(ModpathSubCellDataType) :: subCellData
integer,intent(in) :: unit, stressPeriod, timeStep
integer :: m, n, count, row, column, subRowCount, subColumnCount
character(len=28) :: statusText
!---------------------------------------------------------------------------------------------------------------
cellData => trackCell%CellData
count = tcResult%TrackingPoints%GetItemCount()
write(unit, *)
write(unit, '(1X,A,I10,A,I6,A,I6)') '----- Call TrackCell: Cell', &
cellData%CellNumber, ', Stress period',stressPeriod, &
', Time step', timeStep
select case (tcResult%Status)
case (1)
statusText = ' (Reached stopping time)'
case (2)
statusText = ' (Exit at cell face)'
case (3)
statusText = ' (Stop at weak sink)'
case (4)
statusText = ' (Stop at weak source)'
case (5)
statusText = ' (No exit possible)'
case (6)
statusText = ' (Stop zone cell)'
case (7)
statusText = ' (Inactive cell)'
case (8)
statusText = ' (Inactive cell)'
case default
statusText = ' (Undefined)'
end select
write(unit, '(1X,A,I3,A)') 'Exit status =', tcResult%Status, statusText
write(unit, '(1X,A)') 'Particle locations: Local X, Local Y, Local Z, Tracking time'
do n = 1, count
write(unit, '(1X,I10,4E25.15,I10)') &
tcResult%TrackingPoints%Items(n)%CellNumber, &
tcResult%TrackingPoints%Items(n)%LocalX, &
tcResult%TrackingPoints%Items(n)%LocalY, &
tcResult%TrackingPoints%Items(n)%LocalZ, &
tcResult%TrackingPoints%Items(n)%TrackingTime, &
tcResult%TrackingPoints%Items(n)%Layer
end do
write(unit, *)
call WriteCellData(unit, cellData, trackCell%TrackingOptions%BackwardTracking)
end subroutine WriteTraceData
subroutine pr_GetVolumetricBalanceSummary(this, intervalCount, intervalBreaks, &
balanceCounts, maxError, maxErrorCell)
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer, intent(in) :: intervalCount
doubleprecision, dimension(intervalCount), intent(in) :: intervalBreaks
integer, dimension(intervalCount + 1), intent(inout) :: balanceCounts
integer, intent(inout) :: maxErrorCell
doubleprecision, intent(inout) :: maxError
type(ModpathCellDataType) :: cellBuffer
integer :: cellCount, n, m
doubleprecision :: balance, absBalance
cellCount = this%Grid%CellCount
maxErrorCell = 0
maxError = 0.0d0
do m = 1, intervalCount + 1
balanceCounts(m) = 0
end do
do n = 1, cellCount
call this%FillCellBuffer(n, cellBuffer)
if(cellBuffer%IboundTS .gt. 0) then
balance = cellBuffer%GetVolumetricBalance()
absBalance = dabs(balance)
if((maxErrorCell .eq. 0) .or. (absBalance .gt. maxError) ) then
maxError = absBalance
maxErrorCell = n
end if
do m = 1, intervalCount
if(absBalance .le. intervalBreaks(m)) then
balanceCounts(m) = balanceCounts(m) + 1
exit
end if
if(m .eq. intervalCount) balanceCounts(intervalCount + 1) = &
balanceCounts(intervalCount + 1) + 1
end do
end if
end do
end subroutine pr_GetVolumetricBalanceSummary
subroutine pr_SetDefaultIface(this, defaultIfaceLabels, defaultIfaceValues, &
arraySize)
!***************************************************************************************************************
! Description goes here
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
use UtilMiscModule,only : utrimall
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: arraySize
integer,dimension(arraySize),intent(in) :: defaultIfaceValues
character(len=16),dimension(arraySize),intent(in) :: defaultIfaceLabels
integer :: n, firstNonBlank, lastNonBlank, trimmedLength
character(len=16) :: label
!---------------------------------------------------------------------------------------------------------------
this%DefaultIfaceCount = 0
do n = 1, 20
this%DefaultIfaceValues(n) = 0
this%DefaultIfaceLabels(n) = ' '
end do
do n = 1, arraySize
this%DefaultIfaceValues(n) = defaultIfaceValues(n)
label = defaultIfaceLabels(n)
call utrimall(label)
this%DefaultIfaceLabels(n) = label
end do
this%DefaultIfaceCount = arraySize
end subroutine pr_SetDefaultIface
!subroutine pr_SetLayerTypes(this, layerTypes, arraySize)
!!***************************************************************************************************************
!!
!!***************************************************************************************************************
!!
!! Specifications
!!---------------------------------------------------------------------------------------------------------------
! implicit none
! class(ParticleTrackingEngineType) :: this
! integer,intent(in) :: arraySize
! integer,dimension(arraySize),intent(in),target :: layerTypes
!
! if(arraySize .ne. this%Grid%LayerCount) then
! write(*,*) "ParticleTrackingEngine: The LayerTypes array size does not match the layer count for the grid. stop"
! stop
! end if
!
! this%LayerTypes => layerTypes
!
!end subroutine pr_SetLayerTypes
subroutine pr_SetIbound(this, ibound, arraySize)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: arraySize
integer :: n
integer,dimension(arraySize),intent(in),target :: ibound
if(arraySize .ne. this%Grid%CellCount) then
write(*,*) "ParticleTrackingEngine: The IBound array size does not match the cell count for the grid. stop"
stop
end if
this%IBound => ibound
! Initialize the IBoundTS array to the same values as IBound whenever the IBound array is set.
! The values of IBoundTS will be updated for dry cells every time that data for a time step is loaded.
do n = 1, arraySize
this%IBoundTS(n) = this%IBound(n)
end do
end subroutine pr_SetIbound
subroutine pr_SetZones(this, zones, arraySize)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: arraySize
integer,dimension(arraySize),intent(in),target :: zones
if(arraySize .ne. this%Grid%CellCount) then
write(*,*) "ParticleTrackingEngine: The Zones array size does not match the cell count for the grid. stop"
stop
end if
this%Zones => zones
end subroutine pr_SetZones
subroutine pr_SetPorosity(this, porosity, arraySize)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: arraySize
doubleprecision,dimension(arraySize),intent(in),target :: porosity
if(arraySize .ne. this%Grid%CellCount) then
write(*,*) "ParticleTrackingEngine: The Porosity array size does not match the cell count for the grid. stop"
stop
end if
this%Porosity => porosity
end subroutine pr_SetPorosity
subroutine pr_SetRetardation(this, retardation, arraySize)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: arraySize
doubleprecision,dimension(arraySize),intent(in),target :: retardation
if(arraySize .ne. this%Grid%CellCount) then
write(*,*) "ParticleTrackingEngine: The Retardation array size does not match the cell count for the grid. stop"
stop
end if
this%Retardation => retardation
end subroutine pr_SetRetardation
function pr_FindTimeIndex(timeSeriesPoints, currentTime, maximumTime, timePointsCount) result(index)
!***************************************************************************************************************
! Find the index in the timeSeriesPoints array of the next stopping time after the currentTime value.
! Return -1 if none is found or if maximumTime is less than the stopping time found in the timeSeriesPoints
! array.
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
integer,intent(in) :: timePointsCount
doubleprecision,dimension(timePointsCount),intent(in) :: timeSeriesPoints
doubleprecision,intent(in) :: currentTime, maximumTime
integer :: index, n
doubleprecision :: t
!---------------------------------------------------------------------------------------------------------------
index = -1
if(timePointsCount .lt. 1) return
do n = 1, timePointsCount
if((timeSeriesPoints(n) .gt. currentTime) .and. (timeSeriesPoints(n) .le. maximumTime)) then
index = n
return
end if
end do
end function pr_FindTimeIndex
subroutine pr_Initialize(this,headReader, budgetReader, grid, hNoFlow, hDry, trackingOptions)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
type(BudgetReaderType),intent(inout),target :: budgetReader
type(HeadReaderType),intent(inout),target :: headReader
class(ModflowRectangularGridType),intent(inout),pointer :: grid
type(ParticleTrackingOptionsType),intent(in) :: trackingOptions
integer :: cellCount,gridType
integer :: n, flowArraySize
doubleprecision :: hNoFlow, hDry
!---------------------------------------------------------------------------------------------------------------
this%Initialized = .false.
! Call Reset to make sure that all arrays are initially unallocated
call this%Reset()
! Return if the grid cell count equals 0
cellCount = grid%CellCount
if(cellCount .le. 0) return
! Check budget reader and grid data for compatibility and allocate appropriate cell-by-cell flow arrays
gridType = grid%GridType
select case (gridType)
case (1)
if((budgetReader%GetBudgetType() .ne. 1)) return
if((headReader%GridStyle .ne. 1) .or. (headReader%CellCount .ne. cellCount)) return
flowArraySize = budgetReader%GetFlowArraySize()
if(flowArraySize .ne. cellCount) return
allocate(this%FlowsRightFace(flowArraySize))
allocate(this%FlowsFrontFace(flowArraySize))
allocate(this%FlowsLowerFace(flowArraySize))
allocate(this%FlowsJA(0))
case (2)
if((budgetReader%GetBudgetType() .ne. 2)) return
if((headReader%GridStyle .ne. 2) .or. (headReader%CellCount .ne. cellCount)) return
flowArraySize = budgetReader%GetFlowArraySize()
if(flowArraySize .ne. grid%JaCount) return
allocate(this%FlowsJA(flowArraySize))
allocate(this%FlowsRightFace(0))
allocate(this%FlowsFrontFace(0))
allocate(this%FlowsLowerFace(0))
case (3, 4)
if((budgetReader%GetBudgetType() .ne. 2)) return
if((headReader%GridStyle .ne. 1) .or. (headReader%CellCount .ne. cellCount)) return
flowArraySize = budgetReader%GetFlowArraySize()
if(flowArraySize .ne. grid%JaCount) return
allocate(this%FlowsJA(flowArraySize))
allocate(this%FlowsRightFace(0))
allocate(this%FlowsFrontFace(0))
allocate(this%FlowsLowerFace(0))
!case (4)
! ! Not implemented
! return
case default
return
end select
! Set pointers to budgetReader and grid. Assign tracking options.
this%HeadReader => headReader
this%BudgetReader => budgetReader
this%Grid => grid
this%TrackingOptions = trackingOptions
this%HNoFlow = hNoFlow
this%HDry = hDry
! Allocate the rest of the arrays
allocate(this%IBoundTS(cellCount))
allocate(this%Heads(cellCount))
allocate(this%SourceFlows(cellCount))
allocate(this%SinkFlows(cellCount))
allocate(this%StorageFlows(cellCount))
allocate(this%SubFaceFlowsComputed(cellCount))
allocate(this%BoundaryFlows(cellCount * 6))
allocate(this%SubFaceFlows(cellCount * 4))
! Allocate buffers for reading array and list data
allocate(this%ListItemBuffer(this%BudgetReader%GetMaximumListItemCount()))
allocate(this%ArrayBufferDbl(this%BudgetReader%GetMaximumArrayItemCount()))
this%Initialized = .true.
end subroutine pr_Initialize
subroutine pr_FillFaceFlowsBuffer(this,buffer,bufferSize,count)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: bufferSize
doubleprecision,intent(inout),dimension(bufferSize) :: buffer
integer,intent(inout) :: count
integer :: n,offset
!---------------------------------------------------------------------------------------------------------------
do n = 1, bufferSize
buffer(n) = 0.0d0
end do
count = size(this%FlowsJA)
do n = 1, count
buffer(n) = this%FlowsJA(n)
end do
end subroutine pr_FillFaceFlowsBuffer
subroutine pr_FillCellFlowsBuffer(this,cellNumber,buffer,bufferSize,count)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: cellNumber,bufferSize
doubleprecision,intent(inout),dimension(bufferSize) :: buffer
integer,intent(inout) :: count
integer :: n,offset
!---------------------------------------------------------------------------------------------------------------
do n = 1, bufferSize
buffer(n) = 0.0d0
end do
!offset = this%Grid%GetOffsetJa(cellNumber)
!count = this%Grid%GetOffsetJa(cellNumber + 1) - offset
offset = this%Grid%JaOffsets(cellNumber)
count = this%Grid%JaOffsets(cellNumber + 1) - offset
do n = 1, count
buffer(n) = this%FlowsJA(offset + n)
end do
end subroutine pr_FillCellFlowsBuffer
function pr_GetCurrentStressPeriod(this) result(stressPeriod)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer :: stressPeriod
!---------------------------------------------------------------------------------------------------------------
stressPeriod = this%CurrentStressPeriod
end function pr_GetCurrentStressPeriod
function pr_GetCurrentTimeStep(this) result(timeStep)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer :: timeStep
!---------------------------------------------------------------------------------------------------------------
timeStep = this%CurrentTimeStep
end function pr_GetCurrentTimeStep
subroutine pr_LoadTimeStep(this, stressPeriod, timeStep)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: stressPeriod, timeStep
integer :: firstRecord, lastRecord, n, m, firstNonBlank, lastNonBlank, &
trimmedLength
integer :: spaceAssigned, status,cellCount, iface, index, &
boundaryFlowsOffset, listItemBufferSize, cellNumber, layer
type(BudgetRecordHeaderType) :: header
character(len=16) :: textLabel
doubleprecision :: top
!---------------------------------------------------------------------------------------------------------------
call this%ClearTimeStepBudgetData()
call this%BudgetReader%GetRecordHeaderRange(stressPeriod, timeStep, firstRecord, lastRecord)
if(firstRecord .eq. 0) return
cellCount = this%Grid%CellCount
listItemBufferSize = size(this%ListItemBuffer)
! Set steady state = true, then change it if the budget file contains storage
this%SteadyState = .true.
! Load heads for this time step
call this%HeadReader%FillTimeStepHeadBuffer(stressPeriod, timeStep, &
this%Heads, cellCount, spaceAssigned)
! Fill IBoundTS array and set the SaturatedTop array for the Grid.
! The saturated top is set equal to the top for confined cells and water table cells
! where the head is above the top or below the bottom.
if(this%Grid%GridType .gt. 2) then
do n = 1, cellCount
this%Grid%SaturatedTop(n) = this%Grid%Top(n)
this%StorageFlows(n) = 0.0
this%IBoundTS(n) = this%IBound(n)
layer = this%Grid%GetLayer(n)
if(this%Grid%CellType(n) .eq. 1) then
if(this%Heads(n) .eq. this%HDry) then
this%IBoundTS(n) = 0
else
if(this%Heads(n) .lt. this%Grid%Bottom(n)) then
this%IBoundTS(n) = 0
this%Grid%SaturatedTop(n) = this%Grid%Bottom(n)
end if
end if
if(this%IBoundTS(n) .ne. 0) then
if((this%Heads(n) .le. this%Grid%Top(n)) .and. &
(this%Heads(n) .ge. this%Grid%Bottom(n))) then
this%Grid%SaturatedTop(n) = this%Heads(n)
end if
end if
end if
end do
else
do n = 1, cellCount
this%Grid%SaturatedTop(n) = this%Grid%Top(n)
this%StorageFlows(n) = 0.0
this%IBoundTS(n) = this%IBound(n)
layer = this%Grid%GetLayer(n)
if(this%Grid%CellType(n) .eq. 1) then
if((this%Heads(n) .eq. this%HDry) .or. (this%Heads(n) .gt. 1.0d+6)) then
this%IBoundTS(n) = 0
end if
if(this%IBoundTS(n) .ne. 0) then
if((this%Heads(n) .le. this%Grid%Top(n)) .and. &
(this%Heads(n) .ge. this%Grid%Bottom(n))) then
this%Grid%SaturatedTop(n) = this%Heads(n)
end if
end if
end if
end do
end if
! Loop through record headers
do n = firstRecord, lastRecord
header = this%BudgetReader%GetRecordHeader(n)
textLabel = header%TextLabel
call TrimAll(textLabel, firstNonBlank, lastNonBlank, trimmedLength)
select case(textLabel(firstNonBlank:lastNonBlank))
case('CONSTANT HEAD', 'CHD')
! Read constant head flows into the sinkFlows and sourceFlows arrays.
! For a standard budget file, Method = 0. For a compact budget file,
! Method = 2.
if(header%Method .eq. 0) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ArrayBufferDbl, cellCount, spaceAssigned, status)
if(cellCount .eq. spaceAssigned) then
do m = 1, spaceAssigned
if(this%ArrayBufferDbl(m) .gt. 0.0d0) then
this%SourceFlows(m) = this%SourceFlows(m) + &
this%ArrayBufferDbl(m)
else if(this%ArrayBufferDbl(m) .lt. 0.0d0) then
this%SinkFlows(m) = this%SinkFlows(m) + &
this%ArrayBufferDbl(m)
end if
end do
end if
else if(header%Method .eq. 2) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ListItemBuffer, listItemBufferSize, spaceAssigned, status)
if(spaceAssigned .gt. 0) then
do m = 1, spaceAssigned
cellNumber = this%ListItemBuffer(m)%CellNumber
if(this%ListItemBuffer(m)%BudgetValue .gt. 0.0d0) then
this%SourceFlows(cellNumber) = &
this%SourceFlows(cellNumber) + this%ListItemBuffer(m)%BudgetValue
else if(this%ListItemBuffer(m)%BudgetValue .lt. 0.0d0) then
this%SinkFlows(cellNumber) = &
this%SinkFlows(cellNumber) + this%ListItemBuffer(m)%BudgetValue
end if
end do
end if
else if((header%Method .eq. 5) .or. (header%Method .eq. 6)) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ListItemBuffer, listItemBufferSize, spaceAssigned, &
status)
if(spaceAssigned .gt. 0) then
do m = 1, spaceAssigned
call this%CheckForDefaultIface(header%TextLabel, iface)
index = header%FindAuxiliaryNameIndex('IFACE')
if(index .gt. 0) then
iface = int(this%ListItemBuffer(m)%AuxiliaryValues(index))
end if
cellNumber = this%ListItemBuffer(m)%CellNumber
if(iface .gt. 0) then
boundaryFlowsOffset = 6 * (cellNumber - 1)
this%BoundaryFlows(boundaryFlowsOffset + iface) = &
this%BoundaryFlows(boundaryFlowsOffset + iface) + &
this%ListItemBuffer(m)%BudgetValue
else
if(this%ListItemBuffer(m)%BudgetValue .gt. 0.0d0) then
this%SourceFlows(cellNumber) = &
this%SourceFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
else if(this%ListItemBuffer(m)%BudgetValue .lt. 0.0d0) then
this%SinkFlows(cellNumber) = &
this%SinkFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
end if
end if
end do
end if
end if
case('STORAGE', 'STO-SS', 'STO-SY')
! Read storage for all cells into the StorageFlows array.
! Method should always be 0 or 1, but check anyway to be sure.
if((header%Method .eq. 0) .or. (header%Method .eq. 1)) then
if(header%ArrayItemCount .eq. cellCount) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ArrayBufferDbl, cellCount, spaceAssigned, status)
if(cellCount .eq. spaceAssigned) then
do m = 1, spaceAssigned
this%StorageFlows(m) = this%StorageFlows(m) + this%ArrayBufferDbl(m)
if(this%StorageFlows(m) .ne. 0.0) this%SteadyState = .false.
end do
end if
end if
end if
case('FLOW JA FACE', 'FLOW-JA-FACE')
! Read connected face flows into the FlowsJA array for unstructured grids.
if((header%Method .eq. 0) .or. (header%Method .eq. 1)) then
! Method should always be 0 or 1 for flow between grid cells.
if(header%ArrayItemCount .eq. this%BudgetReader%GetFlowArraySize()) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%FlowsJA, header%ArrayItemCount, spaceAssigned, &
status)
end if
else if(header%Method .eq. 6) then
! Method code 6 indicates flow to or from cells in the current model grid
! and another connected model grid in a multi-model MODFLOW-6 simulation.
! Treat flows to or from connected model grids as distributed source/sink flows
! for the current grid.
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ListItemBuffer, listItemBufferSize, spaceAssigned, &
status)
if(spaceAssigned .gt. 0) then
do m = 1, spaceAssigned
cellNumber = this%ListItemBuffer(m)%CellNumber
if(this%ListItemBuffer(m)%BudgetValue .gt. 0.0d0) then
this%SourceFlows(cellNumber) = &
this%SourceFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
else if(this%ListItemBuffer(m)%BudgetValue .lt. 0.0d0) then
this%SinkFlows(cellNumber) = &
this%SinkFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
end if
end do
end if
end if
case('FLOW RIGHT FACE')
! Read flows across the right face for structured grids.
! Method should always be 0 or 1, but check anyway to be sure.
if((header%Method .eq. 0) .or. (header%Method .eq. 1)) then
if(header%ArrayItemCount .eq. this%BudgetReader%GetFlowArraySize()) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%FlowsRightFace, header%ArrayItemCount, spaceAssigned,&
status)
end if
end if
case('FLOW FRONT FACE')
! Read flows across the front face for structured grids.
! Method should always be 0 or 1, but check anyway to be sure.
if((header%Method .eq. 0) .or. (header%Method .eq. 1)) then
if(header%ArrayItemCount .eq. this%BudgetReader%GetFlowArraySize()) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%FlowsFrontFace, header%ArrayItemCount, spaceAssigned,&
status)
end if
end if
case('FLOW LOWER FACE')
! Read flows across the lower face for structured grids.
! Method should always be 0 or 1, but check anyway to be sure.
if((header%Method .eq. 0) .or. (header%Method .eq. 1)) then
if(header%ArrayItemCount .eq. this%BudgetReader%GetFlowArraySize()) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%FlowsLowerFace, header%ArrayItemCount, spaceAssigned,&
status)
end if
end if
case default
! Now handle any other records in the budget file.
if((header%Method .eq. 0) .or. (header%Method .eq. 1)) then
if(header%ArrayItemCount .eq. cellCount) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ArrayBufferDbl, cellCount, spaceAssigned, status)
if(cellCount .eq. spaceAssigned) then
call this%CheckForDefaultIface(header%TextLabel, iface)
if(iface .gt. 0) then
do m = 1, spaceAssigned
boundaryFlowsOffset = 6 * (m - 1)
this%BoundaryFlows(boundaryFlowsOffset + iface) = &
this%BoundaryFlows(boundaryFlowsOffset + iface) + &
this%ArrayBufferDbl(m)
end do
else
do m = 1, spaceAssigned
if(this%ArrayBufferDbl(m) .gt. 0.0d0) then
this%SourceFlows(m) = this%SourceFlows(m) + &
this%ArrayBufferDbl(m)
else if(this%ArrayBufferDbl(m) .lt. 0.0d0) then
this%SinkFlows(m) = this%SinkFlows(m) + &
this%ArrayBufferDbl(m)
end if
end do
end if
end if
end if
else if(header%Method .eq. 3) then
! Not yet supported
else if(header%Method .eq. 4) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ArrayBufferDbl, header%ArrayItemCount, spaceAssigned, &
status)
if(header%ArrayItemCount .eq. spaceAssigned) then
call this%CheckForDefaultIface(header%TextLabel, iface)
if(iface .gt. 0) then
do m = 1, spaceAssigned
boundaryFlowsOffset = 6 * (m - 1)
this%BoundaryFlows(boundaryFlowsOffset + iface) = &
this%BoundaryFlows(boundaryFlowsOffset + iface) + &
this%ArrayBufferDbl(m)
end do
else
do m = 1, spaceAssigned
if(this%ArrayBufferDbl(m) .gt. 0.0d0) then
this%SourceFlows(m) = this%SourceFlows(m) + &
this%ArrayBufferDbl(m)
else if(this%ArrayBufferDbl(m) .lt. 0.0d0) then
this%SinkFlows(m) = this%SinkFlows(m) + &
this%ArrayBufferDbl(m)
end if
end do
end if
end if
else if(header%Method .eq. 2) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ListItemBuffer, listItemBufferSize, spaceAssigned, &
status)
if(spaceAssigned .gt. 0) then
call this%CheckForDefaultIface(header%TextLabel, iface)
if(iface .gt. 0) then
do m = 1, spaceAssigned
cellNumber = this%ListItemBuffer(m)%CellNumber
boundaryFlowsOffset = 6 * (cellNumber - 1)
this%BoundaryFlows(boundaryFlowsOffset + iface) = &
this%BoundaryFlows(boundaryFlowsOffset + iface) + &
this%ListItemBuffer(m)%BudgetValue
end do
else
do m = 1, spaceAssigned
cellNumber = this%ListItemBuffer(m)%CellNumber
if(this%ListItemBuffer(m)%BudgetValue .gt. 0.0d0) then
this%SourceFlows(cellNumber) = &
this%SourceFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
else if(this%ListItemBuffer(m)%BudgetValue .lt. 0.0d0) then
this%SinkFlows(cellNumber) = &
this%SinkFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
end if
end do
end if
end if
else if((header%Method .eq. 5) .or. (header%Method .eq. 6)) then
call this%BudgetReader%FillRecordDataBuffer(header, &
this%ListItemBuffer, listItemBufferSize, spaceAssigned, &
status)
if(spaceAssigned .gt. 0) then
do m = 1, spaceAssigned
call this%CheckForDefaultIface(header%TextLabel, iface)
index = header%FindAuxiliaryNameIndex('IFACE')
if(index .gt. 0) then
iface = int(this%ListItemBuffer(m)%AuxiliaryValues(index))
end if
cellNumber = this%ListItemBuffer(m)%CellNumber
if(iface .gt. 0) then
boundaryFlowsOffset = 6 * (cellNumber - 1)
this%BoundaryFlows(boundaryFlowsOffset + iface) = &
this%BoundaryFlows(boundaryFlowsOffset + iface) + &
this%ListItemBuffer(m)%BudgetValue
else
if(this%ListItemBuffer(m)%BudgetValue .gt. 0.0d0) then
this%SourceFlows(cellNumber) = &
this%SourceFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
else if(this%ListItemBuffer(m)%BudgetValue .lt. 0.0d0) then
this%SinkFlows(cellNumber) = &
this%SinkFlows(cellNumber) + &
this%ListItemBuffer(m)%BudgetValue
end if
end if
end do
end if
end if
end select
end do
this%CurrentStressPeriod = stressPeriod
this%CurrentTimeStep = timeStep
end subroutine pr_LoadTimeStep
subroutine pr_CheckForDefaultIface(this, textLabel, iface)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
use UtilMiscModule,only : utrimall
implicit none
class(ParticleTrackingEngineType) :: this
character*(*), intent(in) :: textLabel
integer,intent(inout) :: iface
integer :: n
character(len=16) :: label
!---------------------------------------------------------------------------------------------------------------
iface = 0
label = textLabel
call utrimall(label)
do n = 1, this%DefaultIfaceCount
if(label .eq. this%DefaultIfaceLabels(n)) then
iface = this%DefaultIfaceValues(n)
return
end if
end do
end subroutine pr_CheckForDefaultIface
subroutine pr_ClearTimeStepBudgetData(this)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer :: cellCount, n, arraySize
!---------------------------------------------------------------------------------------------------------------
this%CurrentStressPeriod = 0
this%CurrentTimeStep = 0
if(allocated(this%SinkFlows)) then
cellCount = this%Grid%CellCount
do n = 1, cellCount
this%IBoundTS(n) = this%IBound(n)
this%Heads(n) = 0.0d0
this%SourceFlows(n) = 0.0d0
this%SinkFlows(n) = 0.0d0
this%StorageFlows(n) = 0.0d0
this%SubFaceFlowsComputed(n) = .false.
end do
arraySize = cellCount * 6
do n = 1, arraySize
this%BoundaryFlows(n) = 0.0d0
end do
arraySize = cellCount * 4
do n = 1, arraySize
this%SubFaceFlows(n) = 0.0d0
end do
arraySize = this%BudgetReader%GetFlowArraySize()
if(this%Grid%GridType .eq. 1) then
do n = 1, arraySize
this%FlowsRightFace(n) = 0.0d0
this%FlowsFrontFace(n) = 0.0d0
this%FlowsLowerFace(n) = 0.0d0
end do
else if(this%Grid%GridType .eq. 2) then
do n = 1, arraySize
this%FlowsJA(n) = 0.0d0
end do
end if
end if
end subroutine pr_ClearTimeStepBudgetData
subroutine pr_FillCellBuffer(this, cellNumber, cellBuffer)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType) :: this
integer,intent(in) :: cellNumber
type(ModpathCellDataType),intent(inout) :: cellBuffer
doubleprecision,dimension(6) :: boundaryFlows
integer :: n, layer, boundaryFlowsOffset, gridType, cellType
!---------------------------------------------------------------------------------------------------------------
boundaryFlowsOffset = 6 * (cellNumber - 1)
do n = 1, 6
boundaryFlows(n) = this%BoundaryFlows(boundaryFlowsOffset + n)
end do
layer = this%Grid%GetLayer(cellNumber)
gridType = this%Grid%GridType
cellType = this%Grid%CellType(cellNumber)
select case (gridType)
case (1)
! Set cell buffer data for a structured grid
call cellBuffer%SetDataStructured(cellNumber,this%Grid%CellCount, &
this%Grid,this%IBound,this%IBoundTS(cellNumber), &
this%Porosity(cellNumber),this%Retardation(cellNumber), &
this%StorageFlows(cellNumber),this%SourceFlows(cellNumber), &
this%SinkFlows(cellNumber), this%FlowsRightFace, &
this%FlowsFrontFace, this%FlowsLowerFace, boundaryFlows, &
this%Heads(cellNumber), cellType, &
this%Zones(cellNumber))
case (2)
! Set cell buffer data for a MODFLOW-USG unstructured grid
call cellBuffer%SetDataUnstructured(cellNumber,this%Grid%CellCount, &
this%Grid%JaCount,this%Grid, &
this%IBound,this%IBoundTS(cellNumber), &
this%Porosity(cellNumber),this%Retardation(cellNumber), &
this%StorageFlows(cellNumber),this%SourceFlows(cellNumber), &
this%SinkFlows(cellNumber), this%FlowsJA, boundaryFlows, &
this%Heads(cellNumber), cellType, &
this%Zones(cellNumber))
! Compute internal sub-cell face flows for cells with multiple sub-cells
if(cellBuffer%GetSubCellCount() .gt. 1) then
call cellBuffer%ComputeSubCellFlows()
end if
case (3)
! Set cell buffer data for a MODFLOW-6 structured grid (DIS)
call cellBuffer%SetDataUnstructured(cellNumber,this%Grid%CellCount, &
this%Grid%JaCount,this%Grid, &
this%IBound,this%IBoundTS(cellNumber), &
this%Porosity(cellNumber),this%Retardation(cellNumber), &
this%StorageFlows(cellNumber),this%SourceFlows(cellNumber), &
this%SinkFlows(cellNumber), this%FlowsJA, boundaryFlows, &
this%Heads(cellNumber), cellType, &
this%Zones(cellNumber))
case (4)
! Set cell buffer data for a MODFLOW-6 unstructured grid (DISV)
call cellBuffer%SetDataUnstructured(cellNumber,this%Grid%CellCount, &
this%Grid%JaCount,this%Grid, &
this%IBound,this%IBoundTS(cellNumber), &
this%Porosity(cellNumber),this%Retardation(cellNumber), &
this%StorageFlows(cellNumber),this%SourceFlows(cellNumber), &
this%SinkFlows(cellNumber), this%FlowsJA, boundaryFlows, &
this%Heads(cellNumber), cellType, &
this%Zones(cellNumber))
! Compute internal sub-cell face flows for cells with multiple sub-cells
if(cellBuffer%GetSubCellCount() .gt. 1) then
call cellBuffer%ComputeSubCellFlows()
end if
case default
! Write error message and stop
end select
end subroutine pr_FillCellBuffer
subroutine pr_Reset(this)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
!---------------------------------------------------------------------------------------------------------------
class(ParticleTrackingEngineType) :: this
! this%ReferenceTime = 0.0d0
! this%StoppingTime = 0.0d0
this%CurrentStressPeriod = 0
this%CurrentTimeStep = 0
this%BudgetReader => null()
this%Grid => null()
if(allocated(this%IBoundTS)) deallocate(this%IBoundTS)
if(allocated(this%Heads)) deallocate(this%Heads)
if(allocated(this%FlowsJA)) deallocate(this%FlowsJA)
if(allocated(this%FlowsRightFace)) deallocate(this%FlowsRightFace)
if(allocated(this%FlowsFrontFace)) deallocate(this%FlowsFrontFace)
if(allocated(this%FlowsLowerFace)) deallocate(this%FlowsLowerFace)
if(allocated(this%SourceFlows)) deallocate(this%SourceFlows)
if(allocated(this%SinkFlows)) deallocate(this%SinkFlows)
if(allocated(this%StorageFlows)) deallocate(this%StorageFlows)
if(allocated(this%BoundaryFlows)) deallocate(this%BoundaryFlows)
if(allocated(this%SubFaceFlows)) deallocate(this%SubFaceFlows)
if(allocated(this%ArrayBufferDbl)) deallocate(this%ArrayBufferDbl)
if(allocated(this%ListItemBuffer)) deallocate(this%ListItemBuffer)
if(allocated(this%SubFaceFlowsComputed)) deallocate(this%SubFaceFlowsComputed)
this%IBound => null()
this%Porosity => null()
this%Retardation => null()
this%Zones => null()
end subroutine pr_Reset
subroutine pr_TrackPath(this, trackPathResult, traceModeOn, traceModeUnit, &
group, particleID, seqNumber, location, maximumTrackingTime, timeseriesPoints,&
timeseriesPointCount)
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
implicit none
class(ParticleTrackingEngineType),target :: this
type(TrackPathResultType),target,intent(out) :: trackPathResult
type(ParticleLocationType),intent(in) :: location
integer,intent(in) :: group, particleID, seqNumber, timeseriesPointCount, &
traceModeUnit
logical,intent(in) :: traceModeOn
type(ParticleLocationType) :: loc
type(ParticleCoordinateType) :: pCoord
type(ModpathCellDataType),pointer :: cellData
type(TrackCellResultType),pointer :: tcResult
doubleprecision,intent(in) :: maximumTrackingTime
doubleprecision,dimension(timeseriesPointCount),intent(in) :: timeseriesPoints
doubleprecision :: stopTime, fromLocalX, fromLocalY, fromLocalZ, globalX, &
globalY, globalZ
integer :: timeIndex, n, count, nextCell
logical :: continueLoop, isTimeSeriesPoint, isMaximumTime
!---------------------------------------------------------------------------------------------------------------
! Reset trackPathResult and initialize particleID
call trackPathResult%Reset()
trackPathResult%ParticleID = particleID
trackPathResult%Group = group
trackPathResult%SequenceNumber = seqNumber
! Reset LocBuffP and LocBuffTS and initialize location data
call this%LocBuffP%Clear()
call this%LocBuffTS%Clear()
call loc%SetData(location)
call this%LocBuffP%AddItem(loc)
! Initialize loc
call loc%SetData(location)
! Initialize TrackCell
this%TrackCell%SteadyState = this%SteadyState
this%TrackCell%TrackingOptions = this%TrackingOptions
call this%FillCellBuffer(loc%CellNumber, this%TrackCell%CellData)
continueLoop = .true.
isTimeSeriesPoint = .false.
isMaximumTime = .false.
do while(continueLoop)
! Check to see if the particle has moved to another cell. If so, load the new cell data
if(loc%CellNumber .ne. this%TrackCell%CellData%CellNumber) then
call this%FillCellBuffer(loc%CellNumber, this%TrackCell%CellData)
end if
! Find the next stopping time value (tmax), then track the particle through the cell starting at location loc.
timeIndex = -1
if(timeseriesPointCount .gt. 0) then
timeIndex = pr_FindTimeIndex(timeseriesPoints, loc%TrackingTime, &
maximumTrackingTime, timeseriesPointCount)
end if
stopTime = maximumTrackingTime
isTimeSeriesPoint = .false.
if(timeIndex .ne. -1) then
stopTime = timeseriesPoints(timeIndex)
isTimeSeriesPoint = .true.
end if
isMaximumTime = .false.
if(stopTime .eq. maximumTrackingTime) isMaximumTime = .true.
! Start with the particle loacion loc and track it through the cell until it reaches
! an exit face or the tracking time reaches the value specified by stopTime
call this%TrackCell%ExecuteTracking(loc, stopTime, this%TrackCellResult)
! Check the status flag of the result to find out what to do next
if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_Undefined()) then
continueLoop = .false.
trackPathResult%Status = this%TrackCellResult%Status
else if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_ExitAtCellFace()) then
count = this%TrackCellResult%TrackingPoints%GetItemCount()
if(count .gt. 1) then
do n = 2, count
call this%LocBuffP%AddItem(this%TrackCellResult%TrackingPoints%Items(n))
end do
end if
! If NextCellNumber is > 0, it means the particle has moved to another cell.
! If so, convert loc from the current cell coordinates to the equivalent location in the new cell.
nextCell = this%TrackCellResult%NextCellNumber
if(nextCell .gt. 0) then
if(this%IBoundTS(nextCell) .ne. 0) then
! The next cell is active
fromLocalX = this%TrackCellResult%TrackingPoints%Items(count)%LocalX
fromLocalY = this%TrackCellResult%TrackingPoints%Items(count)%LocalY
fromLocalZ = this%TrackCellResult%TrackingPoints%Items(count)%LocalZ
call this%Grid%ConvertFromNeighbor( &
this%TrackCellResult%NextCellNumber, &
this%TrackCellResult%CellNumber, fromLocalX, fromLocalY, &
fromLocalZ, loc)
loc%TrackingTime = this%TrackCellResult%TrackingPoints%Items(count)%TrackingTime
else
! If next cell is inactive, it implies that a boundary face has been reached.
! Set status and return.
continueLoop = .false.
trackPathResult%Status = trackPathResult%Status_ReachedBoundaryFace()
end if
else
! If next cell number = 0, the boundary of the grid has been reached.
! Set status and return.
continueLoop = .false.
trackPathResult%Status = trackPathResult%Status_ReachedBoundaryFace()
end if
else if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_ReachedStoppingTime()) then
count = this%TrackCellResult%TrackingPoints%GetItemCount()
if(count .gt. 1) then
do n = 2, count
call this%LocBuffP%AddItem(this%TrackCellResult%TrackingPoints%Items(n))
end do
if(isTimeSeriesPoint) then
call this%LocBuffTS%AddItem(this%TrackCellResult%TrackingPoints%Items(count))
end if
end if
call loc%SetData(this%TrackCellResult%TrackingPoints%Items(count))
if(isMaximumTime) then
continueLoop = .false.
trackPathResult%Status = trackPathResult%Status_ReachedStoppingTime()
end if
else
continueLoop = .false.
if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_NoExitPossible()) then
trackPathResult%Status = this%TrackCellResult%Status_NoExitPossible()
else if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_StopZoneCell()) then
trackPathResult%Status = this%TrackCellResult%Status_StopZoneCell()
else if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_StopAtWeakSink()) then
trackPathResult%Status = this%TrackCellResult%Status_StopAtWeakSink()
else if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_StopAtWeakSource()) then
trackPathResult%Status = this%TrackCellResult%Status_StopAtWeakSource()
else if(this%TrackCellResult%Status .eq. this%TrackCellResult%Status_InactiveCell()) then
trackPathResult%Status = this%TrackCellResult%Status_InactiveCell()
else
trackPathResult%Status = this%TrackCellResult%Status_Undefined()
end if
! If the trackPathResult status is anything except Undefined, add the last tracking point to
! the trackPathResult tracking points
if(trackPathResult%Status .ne. this%TrackCellResult%Status_Undefined()) then
call this%LocBuffP%AddItem(this%TrackCellResult%TrackingPoints%Items(1))
end if
end if
! Write trace mode data if the trace mode is on for this particle
if(traceModeOn) then
call WriteTraceData(traceModeUnit, this%TrackCell, &
this%TrackCellResult, this%GetCurrentStressPeriod(), &
this%GetCurrentTimeStep())
end if
! If continueLoop is still set to true, go through the loop again. If set to false, exit the loop now.
end do
! Generate global coordinates and finish initializing the result data
count = this%LocBuffP%GetItemCount()
do n = 1, count
pCoord%CellNumber = this%LocBuffP%Items(n)%CellNumber
pCoord%Layer = this%LocBuffP%Items(n)%Layer
pCoord%LocalX = this%LocBuffP%Items(n)%LocalX
pCoord%LocalY = this%LocBuffP%Items(n)%LocalY
pCoord%LocalZ = this%LocBuffP%Items(n)%LocalZ
pCoord%TrackingTime = this%LocBuffP%Items(n)%TrackingTime
call this%Grid%ConvertToModelXYZ(pCoord%CellNumber, pCoord%LocalX, &
pCoord%LocalY, pCoord%LocalZ, pCoord%GlobalX, pCoord%GlobalY, &
pCoord%GlobalZ)
call trackPathResult%ParticlePath%Pathline%AddItem(pCoord)
end do
do n = 1, this%LocBuffTS%GetItemCount()
pCoord%CellNumber = this%LocBuffTS%Items(n)%CellNumber
pCoord%Layer = this%LocBuffTS%Items(n)%Layer
pCoord%LocalX = this%LocBuffTS%Items(n)%LocalX
pCoord%LocalY = this%LocBuffTS%Items(n)%LocalY
pCoord%LocalZ = this%LocBuffTS%Items(n)%LocalZ
pCoord%TrackingTime = this%LocBuffTS%Items(n)%TrackingTime
call this%Grid%ConvertToModelXYZ(pCoord%CellNumber, pCoord%LocalX, &
pCoord%LocalY, pCoord%LocalZ, pCoord%GlobalX, pCoord%GlobalY, &
pCoord%GlobalZ)
call trackPathResult%ParticlePath%Timeseries%AddItem(pCoord)
end do
end subroutine pr_TrackPath
end module ParticleTrackingEngineModule
!***************************************************************************************************************
!
!***************************************************************************************************************
!
! Specifications
!---------------------------------------------------------------------------------------------------------------
! implicit none
!---------------------------------------------------------------------------------------------------------------
|
[STATEMENT]
lemma mod_mod_nat[simp]: "a mod b mod (b * c :: nat) = a mod b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. a mod b mod (b * c) = a mod b
[PROOF STEP]
by (simp add: Divides.mod_mult2_eq) |
did_you_mean <- function(name, lastcall, problem, msg, call_stack)
{
name <- sub(x=name, pattern="\\n", replacement="")
if (problem == "function") {
#make the basic objects list:
objs <- lapply(search(), objects)
objs <- unique(c(ls(), do.call(c, objs)))
closest <- find_closest_word(name, objs)
word <- closest$word
}
else if (problem=="package")
{
objs <- installed.packages()[,"Package"]
closest <- find_closest_word(name, objs)
word <- closest$word
# in order to make suggested code, take a risk and get lastcall
# from history:
lastcall <- get_lastcall(call_stack=1,msg)
}
else if (problem == "not_exported")
{
# use the last call to recover package name and alleged function name
pkg <- as.character(as.list(lastcall)[[2]]) # gets the package
name <- as.character(as.list(lastcall)[[3]]) # gets the alleged function
package_title <- paste0("package:",pkg)
if (package_title %in% search()) {
objs <- objects(paste0("package:", pkg))
} else { #package not attached
objs <- objects(getNamespace(pkg))
#this won't give you all the objects, but
#at least you get the ones exported from the
#package
}
closest <- find_closest_word(name, objs)
word <- closest$word
# in order to make suggested code, take a risk and get lastcall
# from history:
lastcall <- get_lastcall(call_stack=1,msg)
}
else if (problem == "object")
{
objs <- lapply(search(), objects)
objs <- unique(c(ls(), do.call(c, objs)))
possible_containers <- cull_calls(call_stack)
#add on the objects contained in the valid containers:
add_on <- function(x) {
tryCatch(suppressWarnings(objects(eval(parse(text=x)))),
error=function(e){
return(NULL)
})
}
new_objs <- lapply(possible_containers,add_on)
objs <- unique(c(do.call(c,new_objs),objs))
closest <- find_closest_word(name, objs)
word <- closest$word
}
else if (problem == "unused_arguments") {
### find the call that gnerated the error:
cs_length <- length(call_stack)
topcall <- call_stack[[cs_length - 1]]
# stop_dym is the last call in call_stack
# recover the unused argument(s) from the error message:
unused_args <- find_unused_args(msg)
#see if a namespace is involved in the topcall:
top_func_call <- as.character(topcall)[[1]]
with_namespace <- length(grep(top_func_call,pattern="::")) > 0
# for each unused argument, find a suggested replacement:
replacements <- sapply(unused_args,find_replacement,topcall=topcall,
with_namespace=with_namespace)
rep_length <- length(replacements)
suggested_args <- character()
if (rep_length > 1) {
for (i in 1:(rep_length-1)) {
suggested_args <- paste0(suggested_args,replacements[i],", ")
}
}
suggested_args <- paste0(suggested_args,replacements[rep_length])
# perform console output (sorry, cannot use procedure common to the
# other errors)
lang <- get_language()
dym_local <- dym_translate(lang=lang)
cat(paste0("\n", dym_local, suggested_args, " ?\n"))
if (!is.null(lastcall) && topcall==lastcall) { # should not be empty, but just in case
# ... we'll attempt this only if there is no nesting
# get the wrong parameter names
wrong_params <- character()
for (i in 1:length(unused_args)) {
wrong_params[i] <- gsub(unused_args[i],pattern=" = .*",replacement="")
}
#get the suggested parameter names
right_params <- character()
for (i in 1:length(unused_args)) {
right_params[i] <- gsub(replacements[i],pattern=" = .*",replacement="")
}
#get new names for the list that is our call
lc_names <- names(lastcall)
for (i in 1:length(lastcall)) {
if (lc_names[i] %in% wrong_params) {
lc_names[i] <-right_params[which(wrong_params == lc_names[i])]
}
}
suggested_call <- lastcall
names(suggested_call) <- lc_names
print(suggested_call)
cat("\n")
}
return(invisible())
}
#the following applies to errors other than unused arguments:
lang <- get_language()
dym_local <- dym_translate(lang=lang)
cat(paste0("\n", dym_local, word, " ?\n"))
if (!is.null(lastcall))
{
if (class(lastcall) == "call") {
call_text <- capture.output(print(lastcall))
cat(paste0(sub(x=call_text, pattern=name, replacement=word), "\n"))
} else cat(paste0(sub(x=lastcall, pattern=name, replacement=word), "\n"))
}
return(invisible())
} # end handling unused arguments
|
#include "[!output PROJECT_NAME]ID.h"
#define PIPL_PLUGIN_NAME k[!output PROJECT_NAME]PluginName
#include "Plugin.r"
#include "Types.r"
|
module Prob
-- http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf
data Dist : Type -> Type where
Return : a -> Dist a
Bind : Dist b -> (b -> Dist a) -> Dist a
-- Primitive : Sampleable d => d a -> Dist a
-- Conditional : (a -> Prob) -> Dist a -> Dist a
Functor Dist where
map f (Return x) = Return (f x)
map f (Bind x g) = Bind x (\b=>map f $ g b)
Applicative Dist where
pure x = Return x
(<*>) (Return x) (Return y) = Return (x y)
(<*>) (Return x) (Bind y f) = Return (x ?Applicative_rhs_7)
(<*>) (Bind x f) (Return y) = Return ?Applicative_rhs_2
(<*>) (Bind x f) (Bind y g) = Return ?Applicative_rhs_6
Monad Dist where
(>>=) = Bind
join x = ?Monad_rhs_2
|
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ Function.Bijective (primeSpectrumProdOfSum R S)
[PROOFSTEP]
constructor
[GOAL]
case left
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ Function.Injective (primeSpectrumProdOfSum R S)
[PROOFSTEP]
rintro (⟨I, hI⟩ | ⟨J, hJ⟩) (⟨I', hI'⟩ | ⟨J', hJ'⟩) h
[GOAL]
case left.inl.mk.inl.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsPrime I
I' : Ideal R
hI' : Ideal.IsPrime I'
h :
primeSpectrumProdOfSum R S (Sum.inl { asIdeal := I, IsPrime := hI }) =
primeSpectrumProdOfSum R S (Sum.inl { asIdeal := I', IsPrime := hI' })
⊢ Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inl { asIdeal := I', IsPrime := hI' }
[PROOFSTEP]
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
[GOAL]
case left.inl.mk.inr.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsPrime I
J' : Ideal S
hJ' : Ideal.IsPrime J'
h :
primeSpectrumProdOfSum R S (Sum.inl { asIdeal := I, IsPrime := hI }) =
primeSpectrumProdOfSum R S (Sum.inr { asIdeal := J', IsPrime := hJ' })
⊢ Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inr { asIdeal := J', IsPrime := hJ' }
[PROOFSTEP]
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
[GOAL]
case left.inr.mk.inl.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
J : Ideal S
hJ : Ideal.IsPrime J
I' : Ideal R
hI' : Ideal.IsPrime I'
h :
primeSpectrumProdOfSum R S (Sum.inr { asIdeal := J, IsPrime := hJ }) =
primeSpectrumProdOfSum R S (Sum.inl { asIdeal := I', IsPrime := hI' })
⊢ Sum.inr { asIdeal := J, IsPrime := hJ } = Sum.inl { asIdeal := I', IsPrime := hI' }
[PROOFSTEP]
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
[GOAL]
case left.inr.mk.inr.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
J : Ideal S
hJ : Ideal.IsPrime J
J' : Ideal S
hJ' : Ideal.IsPrime J'
h :
primeSpectrumProdOfSum R S (Sum.inr { asIdeal := J, IsPrime := hJ }) =
primeSpectrumProdOfSum R S (Sum.inr { asIdeal := J', IsPrime := hJ' })
⊢ Sum.inr { asIdeal := J, IsPrime := hJ } = Sum.inr { asIdeal := J', IsPrime := hJ' }
[PROOFSTEP]
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
[GOAL]
case left.inl.mk.inl.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsPrime I
I' : Ideal R
hI' : Ideal.IsPrime I'
h : I = I' ∧ True
⊢ Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inl { asIdeal := I', IsPrime := hI' }
[PROOFSTEP]
simp only [h]
[GOAL]
case left.inl.mk.inr.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsPrime I
J' : Ideal S
hJ' : Ideal.IsPrime J'
h : I = ⊤ ∧ ⊤ = J'
⊢ Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inr { asIdeal := J', IsPrime := hJ' }
[PROOFSTEP]
exact False.elim (hI.ne_top h.left)
[GOAL]
case left.inr.mk.inl.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
J : Ideal S
hJ : Ideal.IsPrime J
I' : Ideal R
hI' : Ideal.IsPrime I'
h : ⊤ = I' ∧ J = ⊤
⊢ Sum.inr { asIdeal := J, IsPrime := hJ } = Sum.inl { asIdeal := I', IsPrime := hI' }
[PROOFSTEP]
exact False.elim (hJ.ne_top h.right)
[GOAL]
case left.inr.mk.inr.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
J : Ideal S
hJ : Ideal.IsPrime J
J' : Ideal S
hJ' : Ideal.IsPrime J'
h : True ∧ J = J'
⊢ Sum.inr { asIdeal := J, IsPrime := hJ } = Sum.inr { asIdeal := J', IsPrime := hJ' }
[PROOFSTEP]
simp only [h]
[GOAL]
case right
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ Function.Surjective (primeSpectrumProdOfSum R S)
[PROOFSTEP]
rintro ⟨I, hI⟩
[GOAL]
case right.mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal (R × S)
hI : Ideal.IsPrime I
⊢ ∃ a, primeSpectrumProdOfSum R S a = { asIdeal := I, IsPrime := hI }
[PROOFSTEP]
rcases(Ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩ | ⟨p, ⟨hp, rfl⟩⟩)
[GOAL]
case right.mk.inl.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : Ideal R
hp : Ideal.IsPrime p
hI : Ideal.IsPrime (Ideal.prod p ⊤)
⊢ ∃ a, primeSpectrumProdOfSum R S a = { asIdeal := Ideal.prod p ⊤, IsPrime := hI }
[PROOFSTEP]
exact ⟨Sum.inl ⟨p, hp⟩, rfl⟩
[GOAL]
case right.mk.inr.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : Ideal S
hp : Ideal.IsPrime p
hI : Ideal.IsPrime (Ideal.prod ⊤ p)
⊢ ∃ a, primeSpectrumProdOfSum R S a = { asIdeal := Ideal.prod ⊤ p, IsPrime := hI }
[PROOFSTEP]
exact ⟨Sum.inr ⟨p, hp⟩, rfl⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
⊢ (↑(primeSpectrumProd R S).symm (Sum.inl x)).asIdeal = Ideal.prod x.asIdeal ⊤
[PROOFSTEP]
cases x
[GOAL]
case mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
asIdeal✝ : Ideal R
IsPrime✝ : Ideal.IsPrime asIdeal✝
⊢ (↑(primeSpectrumProd R S).symm (Sum.inl { asIdeal := asIdeal✝, IsPrime := IsPrime✝ })).asIdeal =
Ideal.prod { asIdeal := asIdeal✝, IsPrime := IsPrime✝ }.asIdeal ⊤
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum S
⊢ (↑(primeSpectrumProd R S).symm (Sum.inr x)).asIdeal = Ideal.prod ⊤ x.asIdeal
[PROOFSTEP]
cases x
[GOAL]
case mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
asIdeal✝ : Ideal S
IsPrime✝ : Ideal.IsPrime asIdeal✝
⊢ (↑(primeSpectrumProd R S).symm (Sum.inr { asIdeal := asIdeal✝, IsPrime := IsPrime✝ })).asIdeal =
Ideal.prod ⊤ { asIdeal := asIdeal✝, IsPrime := IsPrime✝ }.asIdeal
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
⊢ zeroLocus ↑(Ideal.span s) = zeroLocus s
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
x : PrimeSpectrum R
⊢ x ∈ zeroLocus ↑(Ideal.span s) ↔ x ∈ zeroLocus s
[PROOFSTEP]
exact (Submodule.gi R R).gc s x.asIdeal
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
⊢ ↑(vanishingIdeal t) = {f | ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal}
[PROOFSTEP]
ext f
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
f : R
⊢ f ∈ ↑(vanishingIdeal t) ↔ f ∈ {f | ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal}
[PROOFSTEP]
rw [vanishingIdeal, SetLike.mem_coe, Submodule.mem_iInf]
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
f : R
⊢ (∀ (i : PrimeSpectrum R), f ∈ ⨅ (_ : i ∈ t), i.asIdeal) ↔ f ∈ {f | ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal}
[PROOFSTEP]
apply forall_congr'
[GOAL]
case h.h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
f : R
⊢ ∀ (a : PrimeSpectrum R), f ∈ ⨅ (_ : a ∈ t), a.asIdeal ↔ a ∈ t → f ∈ a.asIdeal
[PROOFSTEP]
intro x
[GOAL]
case h.h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
f : R
x : PrimeSpectrum R
⊢ f ∈ ⨅ (_ : x ∈ t), x.asIdeal ↔ x ∈ t → f ∈ x.asIdeal
[PROOFSTEP]
rw [Submodule.mem_iInf]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
f : R
⊢ f ∈ vanishingIdeal t ↔ ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal
[PROOFSTEP]
rw [← SetLike.mem_coe, coe_vanishingIdeal, Set.mem_setOf_eq]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
⊢ vanishingIdeal {x} = x.asIdeal
[PROOFSTEP]
simp [vanishingIdeal]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ GaloisConnection (fun s => zeroLocus s) fun t => ↑(vanishingIdeal t)
[PROOFSTEP]
have ideal_gc : GaloisConnection Ideal.span _ := (Submodule.gi R R).gc
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
ideal_gc : GaloisConnection Ideal.span SetLike.coe
⊢ GaloisConnection (fun s => zeroLocus s) fun t => ↑(vanishingIdeal t)
[PROOFSTEP]
simpa [zeroLocus_span, Function.comp] using ideal_gc.compose (gc R)
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
f : R
⊢ f ∈ vanishingIdeal (zeroLocus ↑I) ↔ f ∈ Ideal.radical I
[PROOFSTEP]
rw [mem_vanishingIdeal, Ideal.radical_eq_sInf, Submodule.mem_sInf]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
f : R
⊢ (∀ (x : PrimeSpectrum R), x ∈ zeroLocus ↑I → f ∈ x.asIdeal) ↔
∀ (p : Submodule R R), p ∈ {J | I ≤ J ∧ Ideal.IsPrime J} → f ∈ p
[PROOFSTEP]
exact ⟨fun h x hx => h ⟨x, hx.2⟩ hx.1, fun h x hx => h x.1 ⟨hx, x.2⟩⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ zeroLocus {f} ⊆ zeroLocus {g} ↔ g ∈ Ideal.radical (Ideal.span {f})
[PROOFSTEP]
rw [← zeroLocus_span { f }, ← zeroLocus_span { g }, zeroLocus_subset_zeroLocus_iff, Ideal.span_le,
Set.singleton_subset_iff, SetLike.mem_coe]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ vanishingIdeal ∅ = ⊤
[PROOFSTEP]
simpa using (gc R).u_top
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
⊢ zeroLocus s = ∅
[PROOFSTEP]
rw [Set.eq_empty_iff_forall_not_mem]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
⊢ ∀ (x : PrimeSpectrum R), ¬x ∈ zeroLocus s
[PROOFSTEP]
intro x hx
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : x ∈ zeroLocus s
⊢ False
[PROOFSTEP]
rw [mem_zeroLocus] at hx
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : s ⊆ ↑x.asIdeal
⊢ False
[PROOFSTEP]
have x_prime : x.asIdeal.IsPrime := by infer_instance
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : s ⊆ ↑x.asIdeal
⊢ Ideal.IsPrime x.asIdeal
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : s ⊆ ↑x.asIdeal
x_prime : Ideal.IsPrime x.asIdeal
⊢ False
[PROOFSTEP]
have eq_top : x.asIdeal = ⊤ := by
rw [Ideal.eq_top_iff_one]
exact hx h
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : s ⊆ ↑x.asIdeal
x_prime : Ideal.IsPrime x.asIdeal
⊢ x.asIdeal = ⊤
[PROOFSTEP]
rw [Ideal.eq_top_iff_one]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : s ⊆ ↑x.asIdeal
x_prime : Ideal.IsPrime x.asIdeal
⊢ 1 ∈ x.asIdeal
[PROOFSTEP]
exact hx h
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
h : 1 ∈ s
x : PrimeSpectrum R
hx : s ⊆ ↑x.asIdeal
x_prime : Ideal.IsPrime x.asIdeal
eq_top : x.asIdeal = ⊤
⊢ False
[PROOFSTEP]
apply x_prime.ne_top eq_top
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
⊢ zeroLocus ↑I = ∅ ↔ I = ⊤
[PROOFSTEP]
constructor
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
⊢ zeroLocus ↑I = ∅ → I = ⊤
[PROOFSTEP]
contrapose!
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
⊢ I ≠ ⊤ → zeroLocus ↑I ≠ ∅
[PROOFSTEP]
intro h
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
h : I ≠ ⊤
⊢ zeroLocus ↑I ≠ ∅
[PROOFSTEP]
rcases Ideal.exists_le_maximal I h with ⟨M, hM, hIM⟩
[GOAL]
case mp.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
h : I ≠ ⊤
M : Ideal R
hM : Ideal.IsMaximal M
hIM : I ≤ M
⊢ zeroLocus ↑I ≠ ∅
[PROOFSTEP]
exact Set.Nonempty.ne_empty ⟨⟨M, hM.isPrime⟩, hIM⟩
[GOAL]
case mpr
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
⊢ I = ⊤ → zeroLocus ↑I = ∅
[PROOFSTEP]
rintro rfl
[GOAL]
case mpr
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ zeroLocus ↑⊤ = ∅
[PROOFSTEP]
apply zeroLocus_empty_of_one_mem
[GOAL]
case mpr.h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ 1 ∈ ↑⊤
[PROOFSTEP]
trivial
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set (PrimeSpectrum R)
⊢ vanishingIdeal s = ⊤ ↔ s = ∅
[PROOFSTEP]
rw [← top_le_iff, ← subset_zeroLocus_iff_le_vanishingIdeal, Submodule.top_coe, zeroLocus_univ, Set.subset_empty_iff]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set (Set R)
⊢ zeroLocus (⋃ (s' : Set R) (_ : s' ∈ s), s') = ⋂ (s' : Set R) (_ : s' ∈ s), zeroLocus s'
[PROOFSTEP]
simp only [zeroLocus_iUnion]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s s' : Set R
⊢ zeroLocus s ∪ zeroLocus s' = zeroLocus ↑(Ideal.span s ⊓ Ideal.span s')
[PROOFSTEP]
rw [zeroLocus_inf]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s s' : Set R
⊢ zeroLocus s ∪ zeroLocus s' = zeroLocus ↑(Ideal.span s) ∪ zeroLocus ↑(Ideal.span s')
[PROOFSTEP]
simp
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
x : PrimeSpectrum R
⊢ x ∈ zeroLocus {f * g} ↔ x ∈ zeroLocus {f} ∪ zeroLocus {g}
[PROOFSTEP]
simpa using x.2.mul_mem_iff_mem_or_mem
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
n : ℕ
hn : 0 < n
x : PrimeSpectrum R
⊢ x ∈ zeroLocus {f ^ n} ↔ x ∈ zeroLocus {f}
[PROOFSTEP]
simpa using x.2.pow_mem_iff_mem n hn
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
⊢ vanishingIdeal t ⊔ vanishingIdeal t' ≤ vanishingIdeal (t ∩ t')
[PROOFSTEP]
intro r
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
r : R
⊢ r ∈ vanishingIdeal t ⊔ vanishingIdeal t' → r ∈ vanishingIdeal (t ∩ t')
[PROOFSTEP]
rw [Submodule.mem_sup, mem_vanishingIdeal]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
r : R
⊢ (∃ y, y ∈ vanishingIdeal t ∧ ∃ z, z ∈ vanishingIdeal t' ∧ y + z = r) →
∀ (x : PrimeSpectrum R), x ∈ t ∩ t' → r ∈ x.asIdeal
[PROOFSTEP]
rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩
[GOAL]
case intro.intro.intro.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
f : R
hf : f ∈ vanishingIdeal t
g : R
hg : g ∈ vanishingIdeal t'
x : PrimeSpectrum R
hxt : x ∈ t
hxt' : x ∈ t'
⊢ f + g ∈ x.asIdeal
[PROOFSTEP]
rw [mem_vanishingIdeal] at hf hg
[GOAL]
case intro.intro.intro.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
f : R
hf : ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal
g : R
hg : ∀ (x : PrimeSpectrum R), x ∈ t' → g ∈ x.asIdeal
x : PrimeSpectrum R
hxt : x ∈ t
hxt' : x ∈ t'
⊢ f + g ∈ x.asIdeal
[PROOFSTEP]
apply Submodule.add_mem
[GOAL]
case intro.intro.intro.intro.intro.h₁
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
f : R
hf : ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal
g : R
hg : ∀ (x : PrimeSpectrum R), x ∈ t' → g ∈ x.asIdeal
x : PrimeSpectrum R
hxt : x ∈ t
hxt' : x ∈ t'
⊢ f ∈ x.asIdeal
[PROOFSTEP]
solve_by_elim
[GOAL]
case intro.intro.intro.intro.intro.h₂
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t t' : Set (PrimeSpectrum R)
f : R
hf : ∀ (x : PrimeSpectrum R), x ∈ t → f ∈ x.asIdeal
g : R
hg : ∀ (x : PrimeSpectrum R), x ∈ t' → g ∈ x.asIdeal
x : PrimeSpectrum R
hxt : x ∈ t
hxt' : x ∈ t'
⊢ g ∈ x.asIdeal
[PROOFSTEP]
solve_by_elim
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
I : PrimeSpectrum R
⊢ I ∈ (zeroLocus {f})ᶜ ↔ ¬f ∈ I.asIdeal
[PROOFSTEP]
rw [Set.mem_compl_iff, mem_zeroLocus, Set.singleton_subset_iff]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
I : PrimeSpectrum R
⊢ ¬f ∈ ↑I.asIdeal ↔ ¬f ∈ I.asIdeal
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ zeroLocus Set.univ = ∅
[PROOFSTEP]
simp
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (A : Set (Set (PrimeSpectrum R))), A ⊆ Set.range zeroLocus → ⋂₀ A ∈ Set.range zeroLocus
[PROOFSTEP]
intro Zs h
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
Zs : Set (Set (PrimeSpectrum R))
h : Zs ⊆ Set.range zeroLocus
⊢ ⋂₀ Zs ∈ Set.range zeroLocus
[PROOFSTEP]
rw [Set.sInter_eq_iInter]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
Zs : Set (Set (PrimeSpectrum R))
h : Zs ⊆ Set.range zeroLocus
⊢ ⋂ (i : ↑Zs), ↑i ∈ Set.range zeroLocus
[PROOFSTEP]
choose f hf using fun i : Zs => h i.prop
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
Zs : Set (Set (PrimeSpectrum R))
h : Zs ⊆ Set.range zeroLocus
f : ↑Zs → Set R
hf : ∀ (i : ↑Zs), zeroLocus (f i) = ↑i
⊢ ⋂ (i : ↑Zs), ↑i ∈ Set.range zeroLocus
[PROOFSTEP]
simp only [← hf]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
Zs : Set (Set (PrimeSpectrum R))
h : Zs ⊆ Set.range zeroLocus
f : ↑Zs → Set R
hf : ∀ (i : ↑Zs), zeroLocus (f i) = ↑i
⊢ ⋂ (i : ↑Zs), zeroLocus (f i) ∈ Set.range zeroLocus
[PROOFSTEP]
exact ⟨_, zeroLocus_iUnion _⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (A : Set (PrimeSpectrum R)),
A ∈ Set.range zeroLocus → ∀ (B : Set (PrimeSpectrum R)), B ∈ Set.range zeroLocus → A ∪ B ∈ Set.range zeroLocus
[PROOFSTEP]
rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩
[GOAL]
case intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s t : Set R
⊢ zeroLocus s ∪ zeroLocus t ∈ Set.range zeroLocus
[PROOFSTEP]
exact ⟨_, (union_zeroLocus s t).symm⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
U : Set (PrimeSpectrum R)
⊢ IsOpen U ↔ ∃ s, Uᶜ = zeroLocus s
[PROOFSTEP]
simp only [@eq_comm _ Uᶜ]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
U : Set (PrimeSpectrum R)
⊢ IsOpen U ↔ ∃ s, zeroLocus s = Uᶜ
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
Z : Set (PrimeSpectrum R)
⊢ IsClosed Z ↔ ∃ s, Z = zeroLocus s
[PROOFSTEP]
rw [← isOpen_compl_iff, isOpen_iff, compl_compl]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
⊢ IsClosed (zeroLocus s)
[PROOFSTEP]
rw [isClosed_iff_zeroLocus]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set R
⊢ ∃ s_1, zeroLocus s = zeroLocus s_1
[PROOFSTEP]
exact ⟨s, rfl⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
⊢ IsClosed {x} ↔ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
refine' (isClosed_iff_zeroLocus _).trans ⟨fun h => _, fun h => _⟩
[GOAL]
case refine'_1
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
h : ∃ s, {x} = zeroLocus s
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
obtain ⟨s, hs⟩ := h
[GOAL]
case refine'_1.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
s : Set R
hs : {x} = zeroLocus s
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
rw [eq_comm, Set.eq_singleton_iff_unique_mem] at hs
[GOAL]
case refine'_1.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
s : Set R
hs : x ∈ zeroLocus s ∧ ∀ (x_1 : PrimeSpectrum R), x_1 ∈ zeroLocus s → x_1 = x
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
refine'
⟨⟨x.2.1, fun I hI =>
Classical.not_not.1 (mt (Ideal.exists_le_maximal I) <| not_exists.2 fun J => not_and.2 fun hJ hIJ => _)⟩⟩
[GOAL]
case refine'_1.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
s : Set R
hs : x ∈ zeroLocus s ∧ ∀ (x_1 : PrimeSpectrum R), x_1 ∈ zeroLocus s → x_1 = x
I : Ideal R
hI : x.asIdeal < I
J : Ideal R
hJ : Ideal.IsMaximal J
hIJ : I ≤ J
⊢ False
[PROOFSTEP]
exact
ne_of_lt (lt_of_lt_of_le hI hIJ)
(symm <| congr_arg PrimeSpectrum.asIdeal (hs.2 ⟨J, hJ.isPrime⟩ fun r hr => hIJ (le_of_lt hI <| hs.1 hr)))
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
h : Ideal.IsMaximal x.asIdeal
⊢ ∃ s, {x} = zeroLocus s
[PROOFSTEP]
refine' ⟨x.asIdeal.1, _⟩
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
h : Ideal.IsMaximal x.asIdeal
⊢ {x} = zeroLocus ↑x.asIdeal.toAddSubmonoid
[PROOFSTEP]
rw [eq_comm, Set.eq_singleton_iff_unique_mem]
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
h : Ideal.IsMaximal x.asIdeal
⊢ x ∈ zeroLocus ↑x.asIdeal.toAddSubmonoid ∧
∀ (x_1 : PrimeSpectrum R), x_1 ∈ zeroLocus ↑x.asIdeal.toAddSubmonoid → x_1 = x
[PROOFSTEP]
refine' ⟨fun _ h => h, fun y hy => PrimeSpectrum.ext _ _ (h.eq_of_le y.2.ne_top hy).symm⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
⊢ zeroLocus ↑(vanishingIdeal t) = closure t
[PROOFSTEP]
apply Set.Subset.antisymm
[GOAL]
case h₁
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
⊢ zeroLocus ↑(vanishingIdeal t) ⊆ closure t
[PROOFSTEP]
rintro x hx t' ⟨ht', ht⟩
[GOAL]
case h₁.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
x : PrimeSpectrum R
hx : x ∈ zeroLocus ↑(vanishingIdeal t)
t' : Set (PrimeSpectrum R)
ht' : IsClosed t'
ht : t ⊆ t'
⊢ x ∈ t'
[PROOFSTEP]
obtain ⟨fs, rfl⟩ : ∃ s, t' = zeroLocus s := by rwa [isClosed_iff_zeroLocus] at ht'
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
x : PrimeSpectrum R
hx : x ∈ zeroLocus ↑(vanishingIdeal t)
t' : Set (PrimeSpectrum R)
ht' : IsClosed t'
ht : t ⊆ t'
⊢ ∃ s, t' = zeroLocus s
[PROOFSTEP]
rwa [isClosed_iff_zeroLocus] at ht'
[GOAL]
case h₁.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
x : PrimeSpectrum R
hx : x ∈ zeroLocus ↑(vanishingIdeal t)
fs : Set R
ht' : IsClosed (zeroLocus fs)
ht : t ⊆ zeroLocus fs
⊢ x ∈ zeroLocus fs
[PROOFSTEP]
rw [subset_zeroLocus_iff_subset_vanishingIdeal] at ht
[GOAL]
case h₁.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
x : PrimeSpectrum R
hx : x ∈ zeroLocus ↑(vanishingIdeal t)
fs : Set R
ht' : IsClosed (zeroLocus fs)
ht : fs ⊆ ↑(vanishingIdeal t)
⊢ x ∈ zeroLocus fs
[PROOFSTEP]
exact Set.Subset.trans ht hx
[GOAL]
case h₂
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
⊢ closure t ⊆ zeroLocus ↑(vanishingIdeal t)
[PROOFSTEP]
rw [(isClosed_zeroLocus _).closure_subset_iff]
[GOAL]
case h₂
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
t : Set (PrimeSpectrum R)
⊢ t ⊆ zeroLocus ↑(vanishingIdeal t)
[PROOFSTEP]
exact subset_zeroLocus_vanishingIdeal t
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x : PrimeSpectrum R
⊢ closure {x} = zeroLocus ↑x.asIdeal
[PROOFSTEP]
rw [← zeroLocus_vanishingIdeal_eq_closure, vanishingIdeal_singleton]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set (PrimeSpectrum R)
⊢ Ideal.IsRadical (vanishingIdeal s)
[PROOFSTEP]
rw [← vanishingIdeal_closure, ← zeroLocus_vanishingIdeal_eq_closure, vanishingIdeal_zeroLocus_eq_radical]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set (PrimeSpectrum R)
⊢ Ideal.IsRadical (Ideal.radical (vanishingIdeal s))
[PROOFSTEP]
apply Ideal.radical_isRadical
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s t : Set (PrimeSpectrum R)
ht : IsClosed t
h : vanishingIdeal t ≤ vanishingIdeal s
⊢ s ⊆ t
[PROOFSTEP]
rw [← ht.closure_subset_iff, ← ht.closure_eq]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s t : Set (PrimeSpectrum R)
ht : IsClosed t
h : vanishingIdeal t ≤ vanishingIdeal s
⊢ closure s ⊆ closure t
[PROOFSTEP]
convert ← zeroLocus_anti_mono_ideal h
[GOAL]
case h.e'_3
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s t : Set (PrimeSpectrum R)
ht : IsClosed t
h : vanishingIdeal t ≤ vanishingIdeal s
⊢ zeroLocus ↑(vanishingIdeal s) = closure s
[PROOFSTEP]
apply zeroLocus_vanishingIdeal_eq_closure
[GOAL]
case h.e'_4
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s t : Set (PrimeSpectrum R)
ht : IsClosed t
h : vanishingIdeal t ≤ vanishingIdeal s
⊢ zeroLocus ↑(vanishingIdeal t) = closure t
[PROOFSTEP]
apply zeroLocus_vanishingIdeal_eq_closure
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s t : Set (PrimeSpectrum R)
hs : IsClosed s
ht : IsClosed t
⊢ s ⊂ t ↔ vanishingIdeal t < vanishingIdeal s
[PROOFSTEP]
rw [Set.ssubset_def, vanishingIdeal_anti_mono_iff hs, vanishingIdeal_anti_mono_iff ht, lt_iff_le_not_le]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
⊢ T1Space (PrimeSpectrum R) ↔ IsField R
[PROOFSTEP]
refine' ⟨_, fun h => _⟩
[GOAL]
case refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
⊢ T1Space (PrimeSpectrum R) → IsField R
[PROOFSTEP]
intro h
[GOAL]
case refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : T1Space (PrimeSpectrum R)
⊢ IsField R
[PROOFSTEP]
have hbot : Ideal.IsPrime (⊥ : Ideal R) := Ideal.bot_prime
[GOAL]
case refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : T1Space (PrimeSpectrum R)
hbot : Ideal.IsPrime ⊥
⊢ IsField R
[PROOFSTEP]
exact
Classical.not_not.1
(mt (Ring.ne_bot_of_isMaximal_of_not_isField <| (isClosed_singleton_iff_isMaximal _).1 (T1Space.t1 ⟨⊥, hbot⟩))
(by aesop))
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : T1Space (PrimeSpectrum R)
hbot : Ideal.IsPrime ⊥
⊢ ¬{ asIdeal := ⊥, IsPrime := hbot }.asIdeal ≠ ⊥
[PROOFSTEP]
aesop
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : IsField R
⊢ T1Space (PrimeSpectrum R)
[PROOFSTEP]
refine' ⟨fun x => (isClosed_singleton_iff_isMaximal x).2 _⟩
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : IsField R
x : PrimeSpectrum R
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
by_cases hx : x.asIdeal = ⊥
[GOAL]
case pos
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : IsField R
x : PrimeSpectrum R
hx : x.asIdeal = ⊥
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
letI := h.toField
[GOAL]
case pos
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : IsField R
x : PrimeSpectrum R
hx : x.asIdeal = ⊥
this : Field R := IsField.toField h
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
exact hx.symm ▸ Ideal.bot_isMaximal
[GOAL]
case neg
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
h : IsField R
x : PrimeSpectrum R
hx : ¬x.asIdeal = ⊥
⊢ Ideal.IsMaximal x.asIdeal
[PROOFSTEP]
exact absurd h (Ring.not_isField_iff_exists_prime.2 ⟨x.asIdeal, ⟨hx, x.2⟩⟩)
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ IsIrreducible (zeroLocus ↑I) ↔ Ideal.IsPrime I
[PROOFSTEP]
rw [Ideal.isPrime_iff, IsIrreducible]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ Set.Nonempty (zeroLocus ↑I) ∧ IsPreirreducible (zeroLocus ↑I) ↔ I ≠ ⊤ ∧ ∀ {x y : R}, x * y ∈ I → x ∈ I ∨ y ∈ I
[PROOFSTEP]
apply and_congr
[GOAL]
case h₁
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ Set.Nonempty (zeroLocus ↑I) ↔ I ≠ ⊤
[PROOFSTEP]
rw [Set.nonempty_iff_ne_empty, Ne.def, zeroLocus_empty_iff_eq_top]
[GOAL]
case h₂
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ IsPreirreducible (zeroLocus ↑I) ↔ ∀ {x y : R}, x * y ∈ I → x ∈ I ∨ y ∈ I
[PROOFSTEP]
trans ∀ x y : Ideal R, Z(I) ⊆ Z(x) ∪ Z(y) → Z(I) ⊆ Z(x) ∨ Z(I) ⊆ Z(y)
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ IsPreirreducible (zeroLocus ↑I) ↔
∀ (x y : Ideal R),
zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y
[PROOFSTEP]
simp_rw [isPreirreducible_iff_closed_union_closed, isClosed_iff_zeroLocus_ideal]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (z₁ z₂ : Set (PrimeSpectrum R)),
(∃ I, z₁ = zeroLocus ↑I) →
(∃ I, z₂ = zeroLocus ↑I) → zeroLocus ↑I ⊆ z₁ ∪ z₂ → zeroLocus ↑I ⊆ z₁ ∨ zeroLocus ↑I ⊆ z₂) ↔
∀ (x y : Ideal R),
zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y
[PROOFSTEP]
constructor
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (z₁ z₂ : Set (PrimeSpectrum R)),
(∃ I, z₁ = zeroLocus ↑I) →
(∃ I, z₂ = zeroLocus ↑I) → zeroLocus ↑I ⊆ z₁ ∪ z₂ → zeroLocus ↑I ⊆ z₁ ∨ zeroLocus ↑I ⊆ z₂) →
∀ (x y : Ideal R),
zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y
[PROOFSTEP]
rintro h x y
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
h :
∀ (z₁ z₂ : Set (PrimeSpectrum R)),
(∃ I, z₁ = zeroLocus ↑I) → (∃ I, z₂ = zeroLocus ↑I) → zeroLocus ↑I ⊆ z₁ ∪ z₂ → zeroLocus ↑I ⊆ z₁ ∨ zeroLocus ↑I ⊆ z₂
x y : Ideal R
⊢ zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y
[PROOFSTEP]
exact h _ _ ⟨x, rfl⟩ ⟨y, rfl⟩
[GOAL]
case mpr
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (x y : Ideal R),
zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y) →
∀ (z₁ z₂ : Set (PrimeSpectrum R)),
(∃ I, z₁ = zeroLocus ↑I) →
(∃ I, z₂ = zeroLocus ↑I) → zeroLocus ↑I ⊆ z₁ ∪ z₂ → zeroLocus ↑I ⊆ z₁ ∨ zeroLocus ↑I ⊆ z₂
[PROOFSTEP]
rintro h _ _ ⟨x, rfl⟩ ⟨y, rfl⟩
[GOAL]
case mpr.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
h :
∀ (x y : Ideal R),
zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y
x y : Ideal R
⊢ zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y
[PROOFSTEP]
exact h x y
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (x y : Ideal R),
zeroLocus ↑I ⊆ zeroLocus ↑x ∪ zeroLocus ↑y → zeroLocus ↑I ⊆ zeroLocus ↑x ∨ zeroLocus ↑I ⊆ zeroLocus ↑y) ↔
∀ {x y : R}, x * y ∈ I → x ∈ I ∨ y ∈ I
[PROOFSTEP]
simp_rw [← zeroLocus_inf, subset_zeroLocus_iff_le_vanishingIdeal, vanishingIdeal_zeroLocus_eq_radical, hI.radical]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (x y : Ideal R), x ⊓ y ≤ I → x ≤ I ∨ y ≤ I) ↔ ∀ {x y : R}, x * y ∈ I → x ∈ I ∨ y ∈ I
[PROOFSTEP]
constructor
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (x y : Ideal R), x ⊓ y ≤ I → x ≤ I ∨ y ≤ I) → ∀ {x y : R}, x * y ∈ I → x ∈ I ∨ y ∈ I
[PROOFSTEP]
simp_rw [← SetLike.mem_coe, ← Set.singleton_subset_iff, ← Ideal.span_le, ← Ideal.span_singleton_mul_span_singleton]
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ (x y : Ideal R), x ⊓ y ≤ I → x ≤ I ∨ y ≤ I) →
∀ {x y : R}, Ideal.span {x} * Ideal.span {y} ≤ I → Ideal.span {x} ≤ I ∨ Ideal.span {y} ≤ I
[PROOFSTEP]
refine' fun h x y h' => h _ _ _
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
h : ∀ (x y : Ideal R), x ⊓ y ≤ I → x ≤ I ∨ y ≤ I
x y : R
h' : Ideal.span {x} * Ideal.span {y} ≤ I
⊢ Ideal.span {x} ⊓ Ideal.span {y} ≤ I
[PROOFSTEP]
rw [← hI.radical_le_iff] at h' ⊢
[GOAL]
case mp
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
h : ∀ (x y : Ideal R), x ⊓ y ≤ I → x ≤ I ∨ y ≤ I
x y : R
h' : Ideal.radical (Ideal.span {x} * Ideal.span {y}) ≤ I
⊢ Ideal.radical (Ideal.span {x} ⊓ Ideal.span {y}) ≤ I
[PROOFSTEP]
simpa only [Ideal.radical_inf, Ideal.radical_mul] using h'
[GOAL]
case mpr
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ {x y : R}, x * y ∈ I → x ∈ I ∨ y ∈ I) → ∀ (x y : Ideal R), x ⊓ y ≤ I → x ≤ I ∨ y ≤ I
[PROOFSTEP]
simp_rw [or_iff_not_imp_left, SetLike.not_le_iff_exists]
[GOAL]
case mpr
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
⊢ (∀ {x y : R}, x * y ∈ I → ¬x ∈ I → y ∈ I) → ∀ (x y : Ideal R), x ⊓ y ≤ I → (∃ x_1, x_1 ∈ x ∧ ¬x_1 ∈ I) → y ≤ I
[PROOFSTEP]
rintro h s t h' ⟨x, hx, hx'⟩ y hy
[GOAL]
case mpr.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
I : Ideal R
hI : Ideal.IsRadical I
h : ∀ {x y : R}, x * y ∈ I → ¬x ∈ I → y ∈ I
s t : Ideal R
h' : s ⊓ t ≤ I
x : R
hx : x ∈ s
hx' : ¬x ∈ I
y : R
hy : y ∈ t
⊢ y ∈ I
[PROOFSTEP]
exact h (h' ⟨Ideal.mul_mem_right _ _ hx, Ideal.mul_mem_left _ _ hy⟩) hx'
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
s : Set (PrimeSpectrum R)
⊢ IsIrreducible s ↔ Ideal.IsPrime (vanishingIdeal s)
[PROOFSTEP]
rw [← isIrreducible_iff_closure, ← zeroLocus_vanishingIdeal_eq_closure,
isIrreducible_zeroLocus_iff_of_radical _ (isRadical_vanishingIdeal s)]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
⊢ IrreducibleSpace (PrimeSpectrum R)
[PROOFSTEP]
rw [irreducibleSpace_def, Set.top_eq_univ, ← zeroLocus_bot, isIrreducible_zeroLocus_iff]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : IsDomain R
⊢ Ideal.IsPrime (Ideal.radical ⊥)
[PROOFSTEP]
simpa using Ideal.bot_prime
[GOAL]
R : Type u
S✝ : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S✝
S : Set (PrimeSpectrum R)
h₁ : IsIrreducible S
h₂ : IsClosed S
⊢ IsGenericPoint { asIdeal := vanishingIdeal S, IsPrime := (_ : Ideal.IsPrime (vanishingIdeal S)) } S
[PROOFSTEP]
rw [IsGenericPoint, closure_singleton, zeroLocus_vanishingIdeal_eq_closure, h₂.closure_eq]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
s : Set R
⊢ (fun y => { asIdeal := Ideal.comap f y.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.comap f y.asIdeal)) }) ⁻¹'
zeroLocus s =
zeroLocus (↑f '' s)
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
s : Set R
x : PrimeSpectrum S
⊢ x ∈
(fun y => { asIdeal := Ideal.comap f y.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.comap f y.asIdeal)) }) ⁻¹'
zeroLocus s ↔
x ∈ zeroLocus (↑f '' s)
[PROOFSTEP]
simp only [mem_zeroLocus, Set.image_subset_iff]
[GOAL]
case h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
s : Set R
x : PrimeSpectrum S
⊢ x ∈
(fun y => { asIdeal := Ideal.comap f y.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.comap f y.asIdeal)) }) ⁻¹'
zeroLocus s ↔
s ⊆ (fun a => ↑f a) ⁻¹' ↑x.asIdeal
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
⊢ Continuous fun y => { asIdeal := Ideal.comap f y.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.comap f y.asIdeal)) }
[PROOFSTEP]
simp only [continuous_iff_isClosed, isClosed_iff_zeroLocus]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
⊢ ∀ (s : Set (PrimeSpectrum R)),
(∃ s_1, s = zeroLocus s_1) →
∃ s_1,
(fun y => { asIdeal := Ideal.comap f y.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.comap f y.asIdeal)) }) ⁻¹'
s =
zeroLocus s_1
[PROOFSTEP]
rintro _ ⟨s, rfl⟩
[GOAL]
case intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
s : Set R
⊢ ∃ s_1,
(fun y => { asIdeal := Ideal.comap f y.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.comap f y.asIdeal)) }) ⁻¹'
zeroLocus s =
zeroLocus s_1
[PROOFSTEP]
exact ⟨_, preimage_comap_zeroLocus_aux f s⟩
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
⊢ comap (RingHom.id R) = ContinuousMap.id (PrimeSpectrum R)
[PROOFSTEP]
ext
[GOAL]
case h.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
a✝ : PrimeSpectrum R
x✝ : R
⊢ x✝ ∈ (↑(comap (RingHom.id R)) a✝).asIdeal ↔ x✝ ∈ (↑(ContinuousMap.id (PrimeSpectrum R)) a✝).asIdeal
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
⊢ Inducing ↑(comap (algebraMap R S))
[PROOFSTEP]
constructor
[GOAL]
case induced
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
⊢ zariskiTopology = TopologicalSpace.induced (↑(comap (algebraMap R S))) zariskiTopology
[PROOFSTEP]
rw [topologicalSpace_eq_iff]
[GOAL]
case induced
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
⊢ ∀ (s : Set (PrimeSpectrum S)), IsOpen s ↔ IsOpen s
[PROOFSTEP]
intro U
[GOAL]
case induced
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
⊢ IsOpen U ↔ IsOpen U
[PROOFSTEP]
rw [← isClosed_compl_iff, ← @isClosed_compl_iff (α := PrimeSpectrum S) (s := U)]
[GOAL]
case induced
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
⊢ IsClosed Uᶜ ↔ IsClosed Uᶜ
[PROOFSTEP]
generalize Uᶜ = Z
[GOAL]
case induced
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U Z : Set (PrimeSpectrum S)
⊢ IsClosed Z ↔ IsClosed Z
[PROOFSTEP]
simp_rw [isClosed_induced_iff, isClosed_iff_zeroLocus]
[GOAL]
case induced
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U Z : Set (PrimeSpectrum S)
⊢ (∃ s, Z = zeroLocus s) ↔ ∃ t, (∃ s, t = zeroLocus s) ∧ ↑(comap (algebraMap R S)) ⁻¹' t = Z
[PROOFSTEP]
constructor
[GOAL]
case induced.mp
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U Z : Set (PrimeSpectrum S)
⊢ (∃ s, Z = zeroLocus s) → ∃ t, (∃ s, t = zeroLocus s) ∧ ↑(comap (algebraMap R S)) ⁻¹' t = Z
[PROOFSTEP]
rintro ⟨s, rfl⟩
[GOAL]
case induced.mp.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
s : Set S
⊢ ∃ t, (∃ s, t = zeroLocus s) ∧ ↑(comap (algebraMap R S)) ⁻¹' t = zeroLocus s
[PROOFSTEP]
refine ⟨_, ⟨algebraMap R S ⁻¹' Ideal.span s, rfl⟩, ?_⟩
[GOAL]
case induced.mp.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
s : Set S
⊢ ↑(comap (algebraMap R S)) ⁻¹' zeroLocus (↑(algebraMap R S) ⁻¹' ↑(Ideal.span s)) = zeroLocus s
[PROOFSTEP]
rw [preimage_comap_zeroLocus, ← zeroLocus_span, ← zeroLocus_span s]
[GOAL]
case induced.mp.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
s : Set S
⊢ zeroLocus ↑(Ideal.span (↑(algebraMap R S) '' (↑(algebraMap R S) ⁻¹' ↑(Ideal.span s)))) = zeroLocus ↑(Ideal.span s)
[PROOFSTEP]
congr 2
[GOAL]
case induced.mp.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
s : Set S
⊢ zeroLocus ↑(Ideal.span (↑(algebraMap R S) '' (↑(algebraMap R S) ⁻¹' ↑(Ideal.span s)))) = zeroLocus ↑(Ideal.span s)
[PROOFSTEP]
exact congr_arg (zeroLocus ·) <| Submodule.carrier_inj.mpr (IsLocalization.map_comap M S (Ideal.span s))
[GOAL]
case induced.mpr
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U Z : Set (PrimeSpectrum S)
⊢ (∃ t, (∃ s, t = zeroLocus s) ∧ ↑(comap (algebraMap R S)) ⁻¹' t = Z) → ∃ s, Z = zeroLocus s
[PROOFSTEP]
rintro ⟨_, ⟨t, rfl⟩, rfl⟩
[GOAL]
case induced.mpr.intro.intro.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
t : Set R
⊢ ∃ s, ↑(comap (algebraMap R S)) ⁻¹' zeroLocus t = zeroLocus s
[PROOFSTEP]
rw [preimage_comap_zeroLocus]
[GOAL]
case induced.mpr.intro.intro.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
U : Set (PrimeSpectrum S)
t : Set R
⊢ ∃ s, zeroLocus (↑(algebraMap R S) '' t) = zeroLocus s
[PROOFSTEP]
exact ⟨_, rfl⟩
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
⊢ Function.Injective ↑(comap (algebraMap R S))
[PROOFSTEP]
intro p q h
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
p q : PrimeSpectrum S
h : ↑(comap (algebraMap R S)) p = ↑(comap (algebraMap R S)) q
⊢ p = q
[PROOFSTEP]
replace h := congr_arg (fun x : PrimeSpectrum R => Ideal.map (algebraMap R S) x.asIdeal) h
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
p q : PrimeSpectrum S
h :
(fun x => Ideal.map (algebraMap R S) x.asIdeal) (↑(comap (algebraMap R S)) p) =
(fun x => Ideal.map (algebraMap R S) x.asIdeal) (↑(comap (algebraMap R S)) q)
⊢ p = q
[PROOFSTEP]
dsimp only [comap, ContinuousMap.coe_mk] at h
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
p q : PrimeSpectrum S
h :
Ideal.map (algebraMap R S) (Ideal.comap (algebraMap R S) p.asIdeal) =
Ideal.map (algebraMap R S) (Ideal.comap (algebraMap R S) q.asIdeal)
⊢ p = q
[PROOFSTEP]
rw [IsLocalization.map_comap M S, IsLocalization.map_comap M S] at h
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
p q : PrimeSpectrum S
h : p.asIdeal = q.asIdeal
⊢ p = q
[PROOFSTEP]
ext1
[GOAL]
case asIdeal
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
p q : PrimeSpectrum S
h : p.asIdeal = q.asIdeal
⊢ p.asIdeal = q.asIdeal
[PROOFSTEP]
exact h
[GOAL]
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
⊢ Set.range ↑(comap (algebraMap R S)) = {p | Disjoint ↑M ↑p.asIdeal}
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
⊢ x ∈ Set.range ↑(comap (algebraMap R S)) ↔ x ∈ {p | Disjoint ↑M ↑p.asIdeal}
[PROOFSTEP]
constructor
[GOAL]
case h.mp
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
⊢ x ∈ Set.range ↑(comap (algebraMap R S)) → x ∈ {p | Disjoint ↑M ↑p.asIdeal}
[PROOFSTEP]
simp_rw [disjoint_iff_inf_le]
[GOAL]
case h.mp
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
⊢ x ∈ Set.range ↑(comap (algebraMap R S)) → x ∈ {p | ↑M ⊓ ↑p.asIdeal ≤ ⊥}
[PROOFSTEP]
rintro ⟨p, rfl⟩ x ⟨hx₁, hx₂⟩
[GOAL]
case h.mp.intro.intro
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
p : PrimeSpectrum S
x : R
hx₁ : x ∈ ↑M
hx₂ : x ∈ ↑(↑(comap (algebraMap R S)) p).asIdeal
⊢ x ∈ ⊥
[PROOFSTEP]
exact (p.2.1 : ¬_) (p.asIdeal.eq_top_of_isUnit_mem hx₂ (IsLocalization.map_units S ⟨x, hx₁⟩))
[GOAL]
case h.mpr
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
⊢ x ∈ {p | Disjoint ↑M ↑p.asIdeal} → x ∈ Set.range ↑(comap (algebraMap R S))
[PROOFSTEP]
intro h
[GOAL]
case h.mpr
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
h : x ∈ {p | Disjoint ↑M ↑p.asIdeal}
⊢ x ∈ Set.range ↑(comap (algebraMap R S))
[PROOFSTEP]
use⟨x.asIdeal.map (algebraMap R S), IsLocalization.isPrime_of_isPrime_disjoint M S _ x.2 h⟩
[GOAL]
case h
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
h : x ∈ {p | Disjoint ↑M ↑p.asIdeal}
⊢ ↑(comap (algebraMap R S))
{ asIdeal := Ideal.map (algebraMap R S) x.asIdeal,
IsPrime := (_ : Ideal.IsPrime (Ideal.map (algebraMap R S) x.asIdeal)) } =
x
[PROOFSTEP]
ext1
[GOAL]
case h.asIdeal
R : Type u
S : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S
S' : Type u_1
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R S
M : Submonoid R
inst✝ : IsLocalization M S
x : PrimeSpectrum R
h : x ∈ {p | Disjoint ↑M ↑p.asIdeal}
⊢ (↑(comap (algebraMap R S))
{ asIdeal := Ideal.map (algebraMap R S) x.asIdeal,
IsPrime := (_ : Ideal.IsPrime (Ideal.map (algebraMap R S) x.asIdeal)) }).asIdeal =
x.asIdeal
[PROOFSTEP]
exact IsLocalization.comap_map_of_isPrime_disjoint M S _ x.2 h
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ zariskiTopology = TopologicalSpace.induced (↑(comap f)) zariskiTopology
[PROOFSTEP]
simp_rw [topologicalSpace_eq_iff, ← isClosed_compl_iff, ←
@isClosed_compl_iff (PrimeSpectrum S) ((TopologicalSpace.induced (comap f) zariskiTopology)), isClosed_induced_iff,
isClosed_iff_zeroLocus]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ ∀ (s : Set (PrimeSpectrum S)), (∃ s_1, sᶜ = zeroLocus s_1) ↔ ∃ t, (∃ s, t = zeroLocus s) ∧ ↑(comap f) ⁻¹' t = sᶜ
[PROOFSTEP]
refine' fun s =>
⟨fun ⟨F, hF⟩ =>
⟨zeroLocus (f ⁻¹' F), ⟨f ⁻¹' F, rfl⟩, by rw [preimage_comap_zeroLocus, Function.Surjective.image_preimage hf, hF]⟩,
_⟩
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
s : Set (PrimeSpectrum S)
x✝ : ∃ s_1, sᶜ = zeroLocus s_1
F : Set S
hF : sᶜ = zeroLocus F
⊢ ↑(comap f) ⁻¹' zeroLocus (↑f ⁻¹' F) = sᶜ
[PROOFSTEP]
rw [preimage_comap_zeroLocus, Function.Surjective.image_preimage hf, hF]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
s : Set (PrimeSpectrum S)
⊢ (∃ t, (∃ s, t = zeroLocus s) ∧ ↑(comap f) ⁻¹' t = sᶜ) → ∃ s_1, sᶜ = zeroLocus s_1
[PROOFSTEP]
rintro ⟨-, ⟨F, rfl⟩, hF⟩
[GOAL]
case intro.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
s : Set (PrimeSpectrum S)
F : Set R
hF : ↑(comap f) ⁻¹' zeroLocus F = sᶜ
⊢ ∃ s_1, sᶜ = zeroLocus s_1
[PROOFSTEP]
exact ⟨f '' F, hF.symm.trans (preimage_comap_zeroLocus f F)⟩
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
⊢ ↑(comap f) '' zeroLocus ↑I = zeroLocus ↑(Ideal.comap f I)
[PROOFSTEP]
simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
⊢ ∀ (x : PrimeSpectrum R), (∃ x_1, I ≤ x_1.asIdeal ∧ ↑(comap f) x_1 = x) ↔ Ideal.comap f I ≤ x.asIdeal
[PROOFSTEP]
refine' fun p => ⟨_, fun h_I_p => _⟩
[GOAL]
case refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
⊢ (∃ x, I ≤ x.asIdeal ∧ ↑(comap f) x = p) → Ideal.comap f I ≤ p.asIdeal
[PROOFSTEP]
rintro ⟨p, hp, rfl⟩ a ha
[GOAL]
case refine'_1.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum S
hp : I ≤ p.asIdeal
a : R
ha : a ∈ Ideal.comap f I
⊢ a ∈ (↑(comap f) p).asIdeal
[PROOFSTEP]
exact hp ha
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
⊢ ∃ x, I ≤ x.asIdeal ∧ ↑(comap f) x = p
[PROOFSTEP]
have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
[GOAL]
case refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
⊢ ∃ x, I ≤ x.asIdeal ∧ ↑(comap f) x = p
[PROOFSTEP]
refine' ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => _, _⟩
[GOAL]
case refine'_2.refine'_1
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : S
hx : x ∈ I
⊢ x ∈ { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) }.asIdeal
[PROOFSTEP]
obtain ⟨x', rfl⟩ := hf x
[GOAL]
case refine'_2.refine'_1.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x' : R
hx : ↑f x' ∈ I
⊢ ↑f x' ∈ { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) }.asIdeal
[PROOFSTEP]
exact Ideal.mem_map_of_mem f (h_I_p hx)
[GOAL]
case refine'_2.refine'_2
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
⊢ ↑(comap f) { asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) } = p
[PROOFSTEP]
ext x
[GOAL]
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ x ∈
(↑(comap f)
{ asIdeal := Ideal.map f p.asIdeal, IsPrime := (_ : Ideal.IsPrime (Ideal.map f p.asIdeal)) }).asIdeal ↔
x ∈ p.asIdeal
[PROOFSTEP]
change f x ∈ p.asIdeal.map f ↔ _
[GOAL]
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ ↑f x ∈ Ideal.map f p.asIdeal ↔ x ∈ p.asIdeal
[PROOFSTEP]
rw [Ideal.mem_map_iff_of_surjective f hf]
[GOAL]
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ (∃ x_1, x_1 ∈ p.asIdeal ∧ ↑f x_1 = ↑f x) ↔ x ∈ p.asIdeal
[PROOFSTEP]
refine' ⟨_, fun hx => ⟨x, hx, rfl⟩⟩
[GOAL]
case refine'_2.refine'_2.asIdeal.h
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x : R
⊢ (∃ x_1, x_1 ∈ p.asIdeal ∧ ↑f x_1 = ↑f x) → x ∈ p.asIdeal
[PROOFSTEP]
rintro ⟨x', hx', heq⟩
[GOAL]
case refine'_2.refine'_2.asIdeal.h.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x x' : R
hx' : x' ∈ p.asIdeal
heq : ↑f x' = ↑f x
⊢ x ∈ p.asIdeal
[PROOFSTEP]
rw [← sub_sub_cancel x' x]
[GOAL]
case refine'_2.refine'_2.asIdeal.h.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x x' : R
hx' : x' ∈ p.asIdeal
heq : ↑f x' = ↑f x
⊢ x' - (x' - x) ∈ p.asIdeal
[PROOFSTEP]
refine' p.asIdeal.sub_mem hx' (hp _)
[GOAL]
case refine'_2.refine'_2.asIdeal.h.intro.intro
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
I : Ideal S
p : PrimeSpectrum R
h_I_p : Ideal.comap f I ≤ p.asIdeal
hp : ker f ≤ p.asIdeal
x x' : R
hx' : x' ∈ p.asIdeal
heq : ↑f x' = ↑f x
⊢ x' - x ∈ ker f
[PROOFSTEP]
rwa [mem_ker, map_sub, sub_eq_zero]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ Set.range ↑(comap f) = zeroLocus ↑(ker f)
[PROOFSTEP]
rw [← Set.image_univ]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ ↑(comap f) '' Set.univ = zeroLocus ↑(ker f)
[PROOFSTEP]
convert image_comap_zeroLocus_eq_zeroLocus_comap _ _ hf _
[GOAL]
case h.e'_2.h.e'_4
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ Set.univ = zeroLocus ↑⊥
[PROOFSTEP]
rw [zeroLocus_bot]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ IsClosed (Set.range ↑(comap f))
[PROOFSTEP]
rw [range_comap_of_surjective _ f hf]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
S' : Type u_1
inst✝ : CommRing S'
f : R →+* S
hf : Surjective ↑f
⊢ IsClosed (zeroLocus ↑(ker f))
[PROOFSTEP]
exact isClosed_zeroLocus _
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
r : R
x : PrimeSpectrum R
⊢ x ∈ ↑(basicOpen r) ↔ x ∈ (zeroLocus {r})ᶜ
[PROOFSTEP]
simp only [SetLike.mem_coe, mem_basicOpen, Set.mem_compl_iff, mem_zeroLocus, Set.singleton_subset_iff]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ↑(basicOpen 1) = ↑⊤
[PROOFSTEP]
simp
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ↑(basicOpen 0) = ↑⊥
[PROOFSTEP]
simp
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen f ≤ basicOpen g ↔ f ∈ Ideal.radical (Ideal.span {g})
[PROOFSTEP]
rw [← SetLike.coe_subset_coe, basicOpen_eq_zeroLocus_compl, basicOpen_eq_zeroLocus_compl, Set.compl_subset_compl,
zeroLocus_subset_zeroLocus_singleton_iff]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ ↑(basicOpen (f * g)) = ↑(basicOpen f ⊓ basicOpen g)
[PROOFSTEP]
simp [zeroLocus_singleton_mul]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen (f * g) ≤ basicOpen f
[PROOFSTEP]
rw [basicOpen_mul f g]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen f ⊓ basicOpen g ≤ basicOpen f
[PROOFSTEP]
exact inf_le_left
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen (f * g) ≤ basicOpen g
[PROOFSTEP]
rw [basicOpen_mul f g]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f g : R
⊢ basicOpen f ⊓ basicOpen g ≤ basicOpen g
[PROOFSTEP]
exact inf_le_right
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
n : ℕ
hn : 0 < n
⊢ ↑(basicOpen (f ^ n)) = ↑(basicOpen f)
[PROOFSTEP]
simpa using zeroLocus_singleton_pow f n hn
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ TopologicalSpace.IsTopologicalBasis (Set.range fun r => ↑(basicOpen r))
[PROOFSTEP]
apply TopologicalSpace.isTopologicalBasis_of_open_of_nhds
[GOAL]
case h_open
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (u : Set (PrimeSpectrum R)), (u ∈ Set.range fun r => ↑(basicOpen r)) → IsOpen u
[PROOFSTEP]
rintro _ ⟨r, rfl⟩
[GOAL]
case h_open.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
r : R
⊢ IsOpen ((fun r => ↑(basicOpen r)) r)
[PROOFSTEP]
exact isOpen_basicOpen
[GOAL]
case h_nhds
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (a : PrimeSpectrum R) (u : Set (PrimeSpectrum R)),
a ∈ u → IsOpen u → ∃ v, (v ∈ Set.range fun r => ↑(basicOpen r)) ∧ a ∈ v ∧ v ⊆ u
[PROOFSTEP]
rintro p U hp ⟨s, hs⟩
[GOAL]
case h_nhds.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
hp : p ∈ U
s : Set R
hs : zeroLocus s = Uᶜ
⊢ ∃ v, (v ∈ Set.range fun r => ↑(basicOpen r)) ∧ p ∈ v ∧ v ⊆ U
[PROOFSTEP]
rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
[GOAL]
case h_nhds.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
s : Set R
hp : ∃ a, a ∈ s ∧ ¬a ∈ ↑p.asIdeal
hs : zeroLocus s = Uᶜ
⊢ ∃ v, (v ∈ Set.range fun r => ↑(basicOpen r)) ∧ p ∈ v ∧ v ⊆ U
[PROOFSTEP]
obtain ⟨f, hfs, hfp⟩ := hp
[GOAL]
case h_nhds.intro.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
s : Set R
hs : zeroLocus s = Uᶜ
f : R
hfs : f ∈ s
hfp : ¬f ∈ ↑p.asIdeal
⊢ ∃ v, (v ∈ Set.range fun r => ↑(basicOpen r)) ∧ p ∈ v ∧ v ⊆ U
[PROOFSTEP]
refine' ⟨basicOpen f, ⟨f, rfl⟩, hfp, _⟩
[GOAL]
case h_nhds.intro.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
s : Set R
hs : zeroLocus s = Uᶜ
f : R
hfs : f ∈ s
hfp : ¬f ∈ ↑p.asIdeal
⊢ ↑(basicOpen f) ⊆ U
[PROOFSTEP]
rw [← Set.compl_subset_compl, ← hs, basicOpen_eq_zeroLocus_compl, compl_compl]
[GOAL]
case h_nhds.intro.intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
p : PrimeSpectrum R
U : Set (PrimeSpectrum R)
s : Set R
hs : zeroLocus s = Uᶜ
f : R
hfs : f ∈ s
hfp : ¬f ∈ ↑p.asIdeal
⊢ zeroLocus s ⊆ zeroLocus {f}
[PROOFSTEP]
exact zeroLocus_anti_mono (Set.singleton_subset_iff.mpr hfs)
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ TopologicalSpace.Opens.IsBasis (Set.range basicOpen)
[PROOFSTEP]
unfold TopologicalSpace.Opens.IsBasis
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ TopologicalSpace.IsTopologicalBasis (SetLike.coe '' Set.range basicOpen)
[PROOFSTEP]
convert isTopologicalBasis_basic_opens (R := R)
[GOAL]
case h.e'_3
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ SetLike.coe '' Set.range basicOpen = Set.range fun r => ↑(basicOpen r)
[PROOFSTEP]
rw [← Set.range_comp]
[GOAL]
case h.e'_3
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ Set.range (SetLike.coe ∘ basicOpen) = Set.range fun r => ↑(basicOpen r)
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
hZ : ↑(basicOpen f) ∩ ⋂ (i : ι), Z i = ∅
⊢ ∃ t, ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ t), Z i = ∅
[PROOFSTEP]
let I : ι → Ideal R := fun i => vanishingIdeal (Z i)
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
hZ : ↑(basicOpen f) ∩ ⋂ (i : ι), Z i = ∅
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
⊢ ∃ t, ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ t), Z i = ∅
[PROOFSTEP]
have hI : ∀ i, Z i = zeroLocus (I i) := fun i => by
simpa only [zeroLocus_vanishingIdeal_eq_closure] using (hZc i).closure_eq.symm
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
hZ : ↑(basicOpen f) ∩ ⋂ (i : ι), Z i = ∅
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
i : ι
⊢ Z i = zeroLocus ↑(I i)
[PROOFSTEP]
simpa only [zeroLocus_vanishingIdeal_eq_closure] using (hZc i).closure_eq.symm
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
hZ : ↑(basicOpen f) ∩ ⋂ (i : ι), Z i = ∅
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
⊢ ∃ t, ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ t), Z i = ∅
[PROOFSTEP]
rw [basicOpen_eq_zeroLocus_compl f, Set.inter_comm, ← Set.diff_eq, Set.diff_eq_empty, funext hI, ← zeroLocus_iSup] at hZ
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
⊢ ∃ t, ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ t), Z i = ∅
[PROOFSTEP]
obtain ⟨n, hn⟩ : f ∈ (⨆ i : ι, I i).radical :=
by
rw [← vanishingIdeal_zeroLocus_eq_radical]
apply vanishingIdeal_anti_mono hZ
exact subset_vanishingIdeal_zeroLocus { f } (Set.mem_singleton f)
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
⊢ f ∈ Ideal.radical (⨆ (i : ι), I i)
[PROOFSTEP]
rw [← vanishingIdeal_zeroLocus_eq_radical]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
⊢ f ∈ vanishingIdeal (zeroLocus ↑(⨆ (i : ι), I i))
[PROOFSTEP]
apply vanishingIdeal_anti_mono hZ
[GOAL]
case a
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
⊢ f ∈ vanishingIdeal (zeroLocus {f})
[PROOFSTEP]
exact subset_vanishingIdeal_zeroLocus { f } (Set.mem_singleton f)
[GOAL]
case intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
⊢ ∃ t, ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ t), Z i = ∅
[PROOFSTEP]
rcases Submodule.exists_finset_of_mem_iSup I hn with ⟨s, hs⟩
[GOAL]
case intro.intro
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ ∃ t, ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ t), Z i = ∅
[PROOFSTEP]
use s
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ ↑(basicOpen f) ∩ ⋂ (i : ι) (_ : i ∈ s), Z i = ∅
[PROOFSTEP]
simp_rw [basicOpen_eq_zeroLocus_compl f, Set.inter_comm (zeroLocus { f })ᶜ, ← Set.diff_eq, Set.diff_eq_empty]
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ ⋂ (i : ι) (_ : i ∈ s), Z i ⊆ zeroLocus {f}
[PROOFSTEP]
rw [show
(Set.iInter fun i => Set.iInter fun (_ : i ∈ s) => Z i) =
Set.iInter fun i => Set.iInter fun (_ : i ∈ s) => zeroLocus (I i)
from congr_arg _ (funext fun i => congr_arg _ (funext fun _ => hI i))]
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ ⋂ (i : ι) (_ : i ∈ s), zeroLocus ↑(I i) ⊆ zeroLocus {f}
[PROOFSTEP]
simp_rw [← zeroLocus_iSup]
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ zeroLocus ↑(⨆ (i : ι) (_ : i ∈ s), vanishingIdeal (Z i)) ⊆ zeroLocus {f}
[PROOFSTEP]
rw [← zeroLocus_radical]
-- this one can't be in `simp_rw` because it would loop
[GOAL]
case h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ zeroLocus ↑(Ideal.radical (⨆ (i : ι) (_ : i ∈ s), vanishingIdeal (Z i))) ⊆ zeroLocus {f}
[PROOFSTEP]
apply zeroLocus_anti_mono
[GOAL]
case h.h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ {f} ⊆ ↑(Ideal.radical (⨆ (i : ι) (_ : i ∈ s), vanishingIdeal (Z i)))
[PROOFSTEP]
rw [Set.singleton_subset_iff]
[GOAL]
case h.h
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
ι : Type u
Z : ι → Set (PrimeSpectrum R)
hZc : ∀ (i : ι), IsClosed (Z i)
I : ι → Ideal R := fun i => vanishingIdeal (Z i)
hZ : zeroLocus ↑(⨆ (i : ι), I i) ⊆ zeroLocus {f}
hI : ∀ (i : ι), Z i = zeroLocus ↑(I i)
n : ℕ
hn : f ^ n ∈ ⨆ (i : ι), I i
s : Finset ι
hs : f ^ n ∈ ⨆ (i : ι) (_ : i ∈ s), I i
⊢ f ∈ ↑(Ideal.radical (⨆ (i : ι) (_ : i ∈ s), vanishingIdeal (Z i)))
[PROOFSTEP]
exact ⟨n, hs⟩
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
⊢ basicOpen f = ⊥ ↔ IsNilpotent f
[PROOFSTEP]
rw [← TopologicalSpace.Opens.coe_inj, basicOpen_eq_zeroLocus_compl]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
⊢ (zeroLocus {f})ᶜ = ↑⊥ ↔ IsNilpotent f
[PROOFSTEP]
simp only [Set.eq_univ_iff_forall, Set.singleton_subset_iff, TopologicalSpace.Opens.coe_bot, nilpotent_iff_mem_prime,
Set.compl_empty_iff, mem_zeroLocus, SetLike.mem_coe]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R
⊢ (∀ (x : PrimeSpectrum R), f ∈ x.asIdeal) ↔ ∀ (J : Ideal R), Ideal.IsPrime J → f ∈ J
[PROOFSTEP]
exact ⟨fun h I hI => h ⟨I, hI⟩, fun h ⟨I, hI⟩ => h I hI⟩
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
⊢ Set.range ↑(comap (algebraMap R S)) = ↑(basicOpen r)
[PROOFSTEP]
rw [localization_comap_range S (Submonoid.powers r)]
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
⊢ {p | Disjoint ↑(Submonoid.powers r) ↑p.asIdeal} = ↑(basicOpen r)
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
x : PrimeSpectrum R
⊢ x ∈ {p | Disjoint ↑(Submonoid.powers r) ↑p.asIdeal} ↔ x ∈ ↑(basicOpen r)
[PROOFSTEP]
simp only [mem_zeroLocus, basicOpen_eq_zeroLocus_compl, SetLike.mem_coe, Set.mem_setOf_eq, Set.singleton_subset_iff,
Set.mem_compl_iff, disjoint_iff_inf_le]
[GOAL]
case h
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
x : PrimeSpectrum R
⊢ ↑(Submonoid.powers r) ⊓ ↑x.asIdeal ≤ ⊥ ↔ ¬r ∈ x.asIdeal
[PROOFSTEP]
constructor
[GOAL]
case h.mp
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
x : PrimeSpectrum R
⊢ ↑(Submonoid.powers r) ⊓ ↑x.asIdeal ≤ ⊥ → ¬r ∈ x.asIdeal
[PROOFSTEP]
intro h₁ h₂
[GOAL]
case h.mp
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
x : PrimeSpectrum R
h₁ : ↑(Submonoid.powers r) ⊓ ↑x.asIdeal ≤ ⊥
h₂ : r ∈ x.asIdeal
⊢ False
[PROOFSTEP]
exact h₁ ⟨Submonoid.mem_powers r, h₂⟩
[GOAL]
case h.mpr
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
x : PrimeSpectrum R
⊢ ¬r ∈ x.asIdeal → ↑(Submonoid.powers r) ⊓ ↑x.asIdeal ≤ ⊥
[PROOFSTEP]
rintro h₁ _ ⟨⟨n, rfl⟩, h₃⟩
[GOAL]
case h.mpr.intro.intro
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
x : PrimeSpectrum R
h₁ : ¬r ∈ x.asIdeal
n : ℕ
h₃ : (fun x x_1 => x ^ x_1) r n ∈ ↑x.asIdeal
⊢ (fun x x_1 => x ^ x_1) r n ∈ ⊥
[PROOFSTEP]
exact h₁ (x.2.mem_of_pow_mem _ h₃)
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
⊢ IsOpen (Set.range ↑(comap (algebraMap R S)))
[PROOFSTEP]
rw [localization_away_comap_range S r]
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
S : Type v
inst✝² : CommRing S
inst✝¹ : Algebra R S
r : R
inst✝ : IsLocalization.Away r S
⊢ IsOpen ↑(basicOpen r)
[PROOFSTEP]
exact isOpen_basicOpen
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ IsCompact Set.univ
[PROOFSTEP]
convert isCompact_basicOpen (1 : R)
[GOAL]
case h.e'_3
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ Set.univ = ↑(basicOpen 1)
[PROOFSTEP]
rw [basicOpen_one]
[GOAL]
case h.e'_3
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ Set.univ = ↑⊤
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x y : PrimeSpectrum R
⊢ x ≤ y ↔ y ∈ closure {x}
[PROOFSTEP]
rw [← asIdeal_le_asIdeal, ← zeroLocus_vanishingIdeal_eq_closure, mem_zeroLocus, vanishingIdeal_singleton,
SetLike.coe_subset_coe]
[GOAL]
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x y : PrimeSpectrum R
h : x ⤳ y
⊢ ∀ (y_1 : { x // x ∈ Ideal.primeCompl y.asIdeal }), IsUnit (↑(algebraMap R (Localization.AtPrime x.asIdeal)) ↑y_1)
[PROOFSTEP]
rintro ⟨a, ha⟩
[GOAL]
case mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x y : PrimeSpectrum R
h : x ⤳ y
a : R
ha : a ∈ Ideal.primeCompl y.asIdeal
⊢ IsUnit (↑(algebraMap R (Localization.AtPrime x.asIdeal)) ↑{ val := a, property := ha })
[PROOFSTEP]
rw [← PrimeSpectrum.le_iff_specializes, ← asIdeal_le_asIdeal, ← SetLike.coe_subset_coe, ← Set.compl_subset_compl] at h
[GOAL]
case mk
R : Type u
S : Type v
inst✝¹ : CommRing R
inst✝ : CommRing S
x y : PrimeSpectrum R
h : (↑y.asIdeal)ᶜ ⊆ (↑x.asIdeal)ᶜ
a : R
ha : a ∈ Ideal.primeCompl y.asIdeal
⊢ IsUnit (↑(algebraMap R (Localization.AtPrime x.asIdeal)) ↑{ val := a, property := ha })
[PROOFSTEP]
exact (IsLocalization.map_units (Localization.AtPrime x.asIdeal) ⟨a, show a ∈ x.asIdeal.primeCompl from h ha⟩ : _)
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
inst✝² : LocalRing R
S : Type v
inst✝¹ : CommRing S
inst✝ : LocalRing S
f : R →+* S
⊢ IsLocalRingHom f ↔ ↑(PrimeSpectrum.comap f) (closedPoint S) = closedPoint R
[PROOFSTEP]
have := (local_hom_TFAE f).out 0 4
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
inst✝² : LocalRing R
S : Type v
inst✝¹ : CommRing S
inst✝ : LocalRing S
f : R →+* S
this : IsLocalRingHom f ↔ Ideal.comap f (maximalIdeal S) = maximalIdeal R
⊢ IsLocalRingHom f ↔ ↑(PrimeSpectrum.comap f) (closedPoint S) = closedPoint R
[PROOFSTEP]
rw [this, PrimeSpectrum.ext_iff]
[GOAL]
R : Type u
S✝ : Type v
inst✝⁴ : CommRing R
inst✝³ : CommRing S✝
inst✝² : LocalRing R
S : Type v
inst✝¹ : CommRing S
inst✝ : LocalRing S
f : R →+* S
this : IsLocalRingHom f ↔ Ideal.comap f (maximalIdeal S) = maximalIdeal R
⊢ Ideal.comap f (maximalIdeal S) = maximalIdeal R ↔
(↑(PrimeSpectrum.comap f) (closedPoint S)).asIdeal = (closedPoint R).asIdeal
[PROOFSTEP]
rfl
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
U : TopologicalSpace.Opens (PrimeSpectrum R)
⊢ closedPoint R ∈ U ↔ U = ⊤
[PROOFSTEP]
constructor
[GOAL]
case mp
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
U : TopologicalSpace.Opens (PrimeSpectrum R)
⊢ closedPoint R ∈ U → U = ⊤
[PROOFSTEP]
rw [eq_top_iff]
[GOAL]
case mp
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
U : TopologicalSpace.Opens (PrimeSpectrum R)
⊢ closedPoint R ∈ U → ⊤ ≤ U
[PROOFSTEP]
exact fun h x _ => (specializes_closedPoint x).mem_open U.2 h
[GOAL]
case mpr
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
U : TopologicalSpace.Opens (PrimeSpectrum R)
⊢ U = ⊤ → closedPoint R ∈ U
[PROOFSTEP]
rintro rfl
[GOAL]
case mpr
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
⊢ closedPoint R ∈ ⊤
[PROOFSTEP]
trivial
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
x : PrimeSpectrum (ResidueField R)
⊢ ↑(PrimeSpectrum.comap (residue R)) x = closedPoint R
[PROOFSTEP]
rw [Subsingleton.elim x ⊥]
[GOAL]
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
x : PrimeSpectrum (ResidueField R)
⊢ ↑(PrimeSpectrum.comap (residue R)) ⊥ = closedPoint R
[PROOFSTEP]
ext1
[GOAL]
case asIdeal
R : Type u
S : Type v
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : LocalRing R
x : PrimeSpectrum (ResidueField R)
⊢ (↑(PrimeSpectrum.comap (residue R)) ⊥).asIdeal = (closedPoint R).asIdeal
[PROOFSTEP]
exact Ideal.mk_ker
|
/*
Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <boost/variant.hpp>
#include <boost/scoped_array.hpp>
#include <cppconn/exception.h>
#include "mysql_util.h"
#include "mysql_connection.h"
#include "mysql_statement.h"
#include "mysql_prepared_statement.h"
#include "mysql_ps_resultset.h"
#include "mysql_ps_resultset_metadata.h"
#include "mysql_parameter_metadata.h"
#include "mysql_warning.h"
#include "mysql_resultbind.h"
#include "nativeapi/native_statement_wrapper.h"
#include "mysql_debug.h"
namespace sql
{
namespace mysql
{
static const unsigned int MAX_SEND_LONGDATA_BUFFER= 1 << 18; //1<<18=256k (for istream)
static const unsigned int MAX_SEND_LONGDATA_CHUNK= 1 << 18; //1<<19=512k (for string)
// Visitor class to send long data contained in blob_bind
class LongDataSender : public boost::static_visitor<bool>
{
unsigned position;
boost::shared_ptr< NativeAPI::NativeStatementWrapper > proxy;
boost::shared_ptr<MySQL_DebugLogger> logger;
LongDataSender()
{}
public:
LongDataSender(unsigned int i, boost::shared_ptr< NativeAPI::NativeStatementWrapper > & _proxy,
boost::shared_ptr<MySQL_DebugLogger> _logger)
: position ( i )
, proxy ( _proxy )
, logger ( _logger )
{
}
bool operator()(std::istream * my_blob) const
{
CPP_ENTER("LongDataSender::operator()(std::istream *)");
if (my_blob == NULL)
return false;
//char buf[MAX_SEND_LONGDATA_BUFFER];
boost::scoped_array<char> buf(new char[MAX_SEND_LONGDATA_BUFFER]);
do {
if (my_blob->eof()) {
break;
}
my_blob->read(buf.get(), MAX_SEND_LONGDATA_BUFFER);
if (my_blob->bad()) {
throw SQLException("Error while reading from blob (bad)");
} else if (my_blob->fail()) {
if (!my_blob->eof()) {
throw SQLException("Error while reading from blob (fail)");
}
}
if (proxy->send_long_data(position, buf.get(), static_cast<unsigned long>(my_blob->gcount()))) {
CPP_ERR_FMT("Couldn't send long data : %d:(%s) %s", proxy->errNo(), proxy->sqlstate().c_str(), proxy->error().c_str());
switch (proxy->errNo()) {
case CR_OUT_OF_MEMORY:
throw std::bad_alloc();
case CR_INVALID_BUFFER_USE:
throw InvalidArgumentException("MySQL_Prepared_Statement::setBlob: can't set blob value on that column");
case CR_SERVER_GONE_ERROR:
case CR_COMMANDS_OUT_OF_SYNC:
default:
sql::mysql::util::throwSQLException(*proxy.get());
}
}
} while (1);
return true;
}
bool operator()(sql::SQLString * str) const
{
CPP_ENTER("LongDataSender::operator()(sql::SQLString *)");
if ( str == NULL )
return false;
unsigned int sent= 0, chunkSize;
while (sent < str->length())
{
chunkSize= (sent + MAX_SEND_LONGDATA_CHUNK > str->length()
? str->length() - sent
: MAX_SEND_LONGDATA_CHUNK);
if (proxy->send_long_data(position, str->c_str() + sent, chunkSize)) {
CPP_ERR_FMT("Couldn't send long data : %d:(%s) %s", proxy->errNo(), proxy->sqlstate().c_str(), proxy->error().c_str());
switch (proxy->errNo()) {
case CR_OUT_OF_MEMORY:
throw std::bad_alloc();
case CR_INVALID_BUFFER_USE:
throw InvalidArgumentException("MySQL_Prepared_Statement::setBlob: can't set blob value on that column");
case CR_SERVER_GONE_ERROR:
case CR_COMMANDS_OUT_OF_SYNC:
default:
sql::mysql::util::throwSQLException(*proxy.get());
}
}
sent+= chunkSize;
}
return true;
}
};
class BlobBindDeleter : public boost::static_visitor<>
{
public:
void operator()(sql::SQLString *& str) const
{
if (str != NULL) {
delete str;
str= NULL;
}
}
void operator()(std::istream *& my_blob) const
{
if (my_blob!= NULL) {
delete my_blob;
my_blob= NULL;
}
}
};
class BlobIsNull : public boost::static_visitor<bool>
{
public:
bool operator()(sql::SQLString *& str) const
{
return str == NULL;
}
bool operator()(std::istream *& my_blob) const
{
return my_blob == NULL;
}
};
void resetBlobBind(MYSQL_BIND & param)
{
delete [] static_cast<char *>(param.buffer);
param.buffer_type= MYSQL_TYPE_LONG_BLOB;
param.buffer= NULL;
param.buffer_length= 0;
param.is_null_value= 0;
delete param.length;
param.length= new unsigned long(0);
}
class MySQL_ParamBind
{
public:
typedef boost::variant< std::istream *, sql::SQLString *> Blob_t;
private:
unsigned int param_count;
boost::scoped_array< MYSQL_BIND > bind;
boost::scoped_array< bool > value_set;
boost::scoped_array< bool > delete_blob_after_execute;
typedef std::map<unsigned int, Blob_t > Blobs;
Blobs blob_bind;
public:
MySQL_ParamBind(unsigned int paramCount)
: param_count(paramCount), bind(NULL), value_set(NULL),
delete_blob_after_execute(NULL)
{
if (param_count) {
bind.reset(new MYSQL_BIND[paramCount]);
memset(bind.get(), 0, sizeof(MYSQL_BIND) * paramCount);
value_set.reset(new bool[paramCount]);
delete_blob_after_execute.reset(new bool[paramCount]);
for (unsigned int i = 0; i < paramCount; ++i) {
bind[i].is_null_value = 1;
value_set[i] = false;
delete_blob_after_execute[i] = false;
}
}
}
virtual ~MySQL_ParamBind()
{
clearParameters();
for (Blobs::iterator it= blob_bind.begin();
it != blob_bind.end(); ++it) {
if (delete_blob_after_execute[it->first]) {
delete_blob_after_execute[it->first] = false;
boost::apply_visitor(::sql::mysql::BlobBindDeleter(), it->second);
}
}
}
void set(unsigned int position)
{
value_set[position] = true;
}
void unset(unsigned int position)
{
value_set[position] = false;
if (delete_blob_after_execute[position]) {
delete_blob_after_execute[position] = false;
boost::apply_visitor(::sql::mysql::BlobBindDeleter(),blob_bind[position]);
blob_bind.erase(position);
}
}
void setBlob(unsigned int position, Blob_t & blob, bool delete_after_execute)
{
set(position);
resetBlobBind(bind[position]);
Blobs::iterator it = blob_bind.find(position);
if (it != blob_bind.end() && delete_blob_after_execute[position]) {
boost::apply_visitor(::sql::mysql::BlobBindDeleter(), it->second);
}
if (boost::apply_visitor(::sql::mysql::BlobIsNull(), blob))
{
if (it != blob_bind.end())
blob_bind.erase(it);
delete_blob_after_execute[position] = false;
}
else
{
blob_bind[position] = blob;
delete_blob_after_execute[position] = delete_after_execute;
}
}
bool isAllSet()
{
for (unsigned int i = 0; i < param_count; ++i) {
if (!value_set[i]) {
return false;
}
}
return true;
}
void clearParameters()
{
for (unsigned int i = 0; i < param_count; ++i) {
delete (char*) bind[i].length;
bind[i].length = NULL;
delete[] (char*) bind[i].buffer;
bind[i].buffer = NULL;
if (value_set[i]) {
Blobs::iterator it= blob_bind.find(i);
if (it != blob_bind.end() && delete_blob_after_execute[i]) {
boost::apply_visitor(::sql::mysql::BlobBindDeleter(), it->second);
blob_bind.erase(it);
}
blob_bind[i] = Blob_t();
value_set[i] = false;
}
}
}
// Name get() was too confusing, since class objects are used with smart pointers
MYSQL_BIND * getBindObject()
{
return bind.get();
}
boost::variant< std::istream *, SQLString *> getBlobObject(unsigned int position)
{
Blobs::iterator it= blob_bind.find( position );
if (it != blob_bind.end())
return it->second;
return Blob_t();
}
};
/* {{{ MySQL_Prepared_Statement::MySQL_Prepared_Statement() -I- */
MySQL_Prepared_Statement::MySQL_Prepared_Statement(
boost::shared_ptr< NativeAPI::NativeStatementWrapper > & s, sql::Connection * conn,
sql::ResultSet::enum_type rset_type, boost::shared_ptr< MySQL_DebugLogger > & log
)
:connection(conn), proxy(s), isClosed(false), warningsHaveBeenLoaded(true), logger(log),
resultset_type(rset_type), result_bind(new MySQL_ResultBind(proxy, logger)),
warningsCount(0)
{
CPP_ENTER("MySQL_Prepared_Statement::MySQL_Prepared_Statement");
CPP_INFO_FMT("this=%p", this);
param_count = proxy->param_count();
param_bind.reset(new MySQL_ParamBind(param_count));
res_meta.reset(new MySQL_PreparedResultSetMetaData(proxy, logger));
param_meta.reset(new MySQL_ParameterMetaData(proxy));
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::~MySQL_Prepared_Statement() -I- */
MySQL_Prepared_Statement::~MySQL_Prepared_Statement()
{
CPP_ENTER("MySQL_Prepared_Statement::~MySQL_Prepared_Statement");
/*
This will free param_bind.
We should not do it or there will be double free.
*/
if (!isClosed) {
closeIntern();
}
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::sendLongDataBeforeParamBind() -I- */
bool
MySQL_Prepared_Statement::sendLongDataBeforeParamBind()
{
CPP_ENTER("MySQL_Prepared_Statement::sendLongDataBeforeParamBind");
MYSQL_BIND * bind= param_bind->getBindObject();
for (unsigned int i = 0; i < param_count; ++i) {
if (bind[i].buffer_type == MYSQL_TYPE_LONG_BLOB) {
::sql::mysql::LongDataSender lv(i, proxy, logger);
MySQL_ParamBind::Blob_t dummy(param_bind->getBlobObject(i));
boost::apply_visitor(lv, dummy);
}
}
return true;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::do_query() -I- */
void
MySQL_Prepared_Statement::do_query()
{
CPP_ENTER("MySQL_Prepared_Statement::do_query");
if (param_count && !param_bind->isAllSet()) {
CPP_ERR("Value not set for all parameters");
throw sql::SQLException("Value not set for all parameters");
}
if (proxy->bind_param(param_bind->getBindObject())) {
CPP_ERR_FMT("Couldn't bind : %d:(%s) %s", proxy->errNo(), proxy->sqlstate().c_str(), proxy->error().c_str());
sql::mysql::util::throwSQLException(*proxy.get());
}
if (!sendLongDataBeforeParamBind() || proxy->execute()) {
CPP_ERR_FMT("Couldn't execute : %d:(%s) %s", proxy->errNo(), proxy->sqlstate().c_str(), proxy->error().c_str());
sql::mysql::util::throwSQLException(*proxy.get());
}
warningsCount= proxy->warning_count();
warningsHaveBeenLoaded= false;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::clearParameters() -I- */
void
MySQL_Prepared_Statement::clearParameters()
{
CPP_ENTER("MySQL_Prepared_Statement::clearParameters");
CPP_INFO_FMT("this=%p", this);
checkClosed();
param_bind->clearParameters();
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getConnection() -I- */
sql::Connection *
MySQL_Prepared_Statement::getConnection()
{
CPP_ENTER("MySQL_Prepared_Statement::getConnection");
CPP_INFO_FMT("this=%p", this);
checkClosed();
return connection;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::execute() -I- */
bool
MySQL_Prepared_Statement::execute()
{
CPP_ENTER("MySQL_Prepared_Statement::execute");
CPP_INFO_FMT("this=%p", this);
checkClosed();
do_query();
return (proxy->field_count() > 0);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::execute() -U- */
bool
MySQL_Prepared_Statement::execute(const sql::SQLString&)
{
CPP_ENTER("MySQL_Prepared_Statement::execute(const sql::SQLString& sql)");
throw sql::MethodNotImplementedException("MySQL_Prepared_Statement::execute");
return false; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::executeQuery() -I- */
sql::ResultSet *
MySQL_Prepared_Statement::executeQuery()
{
CPP_ENTER("MySQL_Prepared_Statement::executeQuery");
CPP_INFO_FMT("this=%p", this);
checkClosed();
do_query();
my_bool bool_tmp=1;
proxy->attr_set( STMT_ATTR_UPDATE_MAX_LENGTH, &bool_tmp);
sql::ResultSet::enum_type tmp_type;
if (resultset_type == sql::ResultSet::TYPE_SCROLL_INSENSITIVE) {
if (proxy->store_result()) {
sql::mysql::util::throwSQLException(*proxy.get());
}
tmp_type = sql::ResultSet::TYPE_SCROLL_INSENSITIVE;
} else if (resultset_type == sql::ResultSet::TYPE_FORWARD_ONLY) {
tmp_type = sql::ResultSet::TYPE_FORWARD_ONLY;
} else {
throw SQLException("Invalid value for result set type");
}
sql::ResultSet * tmp = new MySQL_Prepared_ResultSet(proxy, result_bind, tmp_type, this, logger);
CPP_INFO_FMT("rset=%p", tmp);
return tmp;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::executeQuery() -U- */
sql::ResultSet *
MySQL_Prepared_Statement::executeQuery(const sql::SQLString&)
{
throw sql::MethodNotImplementedException("MySQL_Prepared_Statement::executeQuery"); /* TODO - what to do? Comes from Statement */
return NULL; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::executeUpdate() -I- */
int
MySQL_Prepared_Statement::executeUpdate()
{
CPP_ENTER("MySQL_Prepared_Statement::executeUpdate");
CPP_INFO_FMT("this=%p", this);
checkClosed();
do_query();
return static_cast<int>(proxy->affected_rows());
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::executeUpdate() -U- */
int
MySQL_Prepared_Statement::executeUpdate(const sql::SQLString&)
{
throw sql::MethodNotImplementedException("MySQL_Prepared_Statement::executeUpdate"); /* TODO - what to do? Comes from Statement */
return 0; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setBigInt() -I- */
void
MySQL_Prepared_Statement::setBigInt(unsigned int parameterIndex, const sql::SQLString& value)
{
CPP_ENTER("MySQL_Prepared_Statement::setBigInt");
setString(parameterIndex, value);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setBlob_intern() -I- */
/*
void
setBlob_intern(unsigned int parameterIndex
, / *boost::variant< std::istream *, sql::SQLString *>* /MySQL_ParamBind::Blob_t & blob
, bool deleteBlobAfterExecute)
{
CPP_ENTER("MySQL_Prepared_Statement::setBlob_intern");
CPP_INFO_FMT("this=%p", this);
checkClosed();
--parameterIndex; / * DBC counts from 1 * /
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
delete [] static_cast<char *>(param->buffer);
param->buffer_type = MYSQL_TYPE_LONG_BLOB;
param->buffer = NULL;
param->buffer_length= 0;
param->is_null_value= 0;
delete param->length;
param->length = new unsigned long(0);
param_bind->setBlob(parameterIndex, blob, deleteBlobAfterExecute);
}*/
/* }}} */
/* {{{ MySQL_Prepared_Statement::setBlob() -I- */
void
MySQL_Prepared_Statement::setBlob(unsigned int parameterIndex, std::istream * blob)
{
CPP_ENTER("MySQL_Prepared_Statement::setBlob");
CPP_INFO_FMT("this=%p", this);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setBlob: invalid 'parameterIndex'");
}
MySQL_ParamBind::Blob_t dummy(blob);
param_bind->setBlob(--parameterIndex, dummy, false);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setBoolean() -I- */
void
MySQL_Prepared_Statement::setBoolean(unsigned int parameterIndex, bool value)
{
CPP_ENTER("MySQL_Prepared_Statement::setBoolean");
setInt(parameterIndex, value);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setDateTime() -I- */
void
MySQL_Prepared_Statement::setDateTime(unsigned int parameterIndex, const sql::SQLString& value)
{
CPP_ENTER("MySQL_Prepared_Statement::setDateTime");
setString(parameterIndex, value);
}
/* }}} */
typedef std::pair<char *, size_t> BufferSizePair;
static BufferSizePair
allocate_buffer_for_type(enum_field_types t)
{
switch (t) {
#if A1
// We don't use these now. When we have setXXX, we can enable them
case MYSQL_TYPE_TINY:
return BufferSizePair(new char[1], 1);
case MYSQL_TYPE_SHORT:
return BufferSizePair(new char[2], 2);
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_FLOAT:
#endif
case MYSQL_TYPE_LONG:
return BufferSizePair(new char[4], 4);
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_LONGLONG:
return BufferSizePair(new char[8], 8);
#if A1
// We don't use these now. When we have setXXX, we can enable them
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
return BufferSizePair(new char[sizeof(MYSQL_TIME)], sizeof(MYSQL_TIME));
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING:
#endif
case MYSQL_TYPE_STRING:
return BufferSizePair(NULLCSTR, 0);
#if A1
// We don't use these now. When we have setXXX, we can enable them
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
return BufferSizePair(new char[64], 64);
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_YEAR:
return BufferSizePair(new char[10], 10);
#endif
#if A0
// There two are not sent over the wire
case MYSQL_TYPE_SET:
case MYSQL_TYPE_ENUM:
#endif
#if A1
// We don't use these now. When we have setXXX, we can enable them
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_BIT:
#endif
case MYSQL_TYPE_NULL:
return BufferSizePair(NULLCSTR, 0);
default:
throw sql::InvalidArgumentException("allocate_buffer_for_type: invalid result_bind data type");
}
}
/* {{{ MySQL_Prepared_Statement::setDouble() -I- */
void
MySQL_Prepared_Statement::setDouble(unsigned int parameterIndex, double value)
{
CPP_ENTER("MySQL_Prepared_Statement::setDouble");
CPP_INFO_FMT("this=%p %f", this, value);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setDouble: invalid 'parameterIndex'");
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_DOUBLE;
BufferSizePair p = allocate_buffer_for_type(t);
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
param->buffer_type = t;
delete [] static_cast<char *>(param->buffer);
param->buffer = p.first;
param->buffer_length = 0;
param->is_null_value = 0;
delete param->length;
param->length = NULL;
memcpy(param->buffer, &value, p.second);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setInt() -I- */
void
MySQL_Prepared_Statement::setInt(unsigned int parameterIndex, int32_t value)
{
CPP_ENTER("MySQL_Prepared_Statement::setInt");
CPP_INFO_FMT("this=%p", this);
CPP_INFO_FMT("column=%u value=%d", parameterIndex, value);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setInt: invalid 'parameterIndex'");
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_LONG;
BufferSizePair p = allocate_buffer_for_type(t);
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
param->buffer_type = t;
delete [] static_cast<char *>(param->buffer);
param->buffer = p.first;
param->buffer_length = 0;
param->is_null_value = 0;
delete param->length;
param->length = NULL;
memcpy(param->buffer, &value, p.second);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setUInt() -I- */
void
MySQL_Prepared_Statement::setUInt(unsigned int parameterIndex, uint32_t value)
{
CPP_ENTER("MySQL_Prepared_Statement::setUInt");
CPP_INFO_FMT("this=%p", this);
CPP_INFO_FMT("column=%u value=%u", parameterIndex, value);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setInt: invalid 'parameterIndex'");
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_LONG;
BufferSizePair p = allocate_buffer_for_type(t);
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
param->buffer_type = t;
delete [] static_cast<char *>(param->buffer);
param->buffer = p.first;
param->buffer_length = 0;
param->is_null_value = 0;
param->is_unsigned = 1;
delete param->length;
param->length = NULL;
memcpy(param->buffer, &value, p.second);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setInt64() -I- */
void
MySQL_Prepared_Statement::setInt64(unsigned int parameterIndex, int64_t value)
{
CPP_ENTER("MySQL_Prepared_Statement::setInt64");
CPP_INFO_FMT("this=%p", this);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setInt64: invalid 'parameterIndex'");
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_LONGLONG;
BufferSizePair p = allocate_buffer_for_type(t);
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
param->buffer_type = t;
delete [] static_cast<char *>(param->buffer);
param->buffer = p.first;
param->buffer_length = 0;
param->is_null_value = 0;
delete param->length;
param->length = NULL;
memcpy(param->buffer, &value, p.second);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setUInt64() -I- */
void
MySQL_Prepared_Statement::setUInt64(unsigned int parameterIndex, uint64_t value)
{
CPP_ENTER("MySQL_Prepared_Statement::setUInt64");
CPP_INFO_FMT("this=%p", this);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setUInt64: invalid 'parameterIndex'");
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_LONGLONG;
BufferSizePair p = allocate_buffer_for_type(t);
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
param->buffer_type = t;
delete [] static_cast<char *>(param->buffer);
param->buffer = p.first;
param->buffer_length = 0;
param->is_null_value = 0;
param->is_unsigned = 1;
delete param->length;
param->length = NULL;
memcpy(param->buffer, &value, p.second);
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setNull() -I- */
void
MySQL_Prepared_Statement::setNull(unsigned int parameterIndex, int /* sqlType */)
{
CPP_ENTER("MySQL_Prepared_Statement::setNull");
CPP_INFO_FMT("this=%p", this);
CPP_INFO_FMT("column=%u", parameterIndex);
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
throw InvalidArgumentException("MySQL_Prepared_Statement::setNull: invalid 'parameterIndex'");
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_NULL;
BufferSizePair p = allocate_buffer_for_type(t);
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
param->buffer_type = t;
delete [] static_cast<char *>(param->buffer);
param->buffer = NULL;
delete param->length;
param->length = NULL;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setString() -I- */
void
MySQL_Prepared_Statement::setString(unsigned int parameterIndex, const sql::SQLString& value)
{
CPP_ENTER("MySQL_Prepared_Statement::setString");
CPP_INFO_FMT("this=%p", this);
CPP_INFO_FMT("column=%u value_len=%d value=%s ", parameterIndex, value.length(), value.c_str());
checkClosed();
if (parameterIndex == 0 || parameterIndex > param_count) {
CPP_ERR("Invalid parameterIndex");
throw InvalidArgumentException("MySQL_Prepared_Statement::setString: invalid 'parameterIndex'");
}
if (value.length() > 256*1024) {
MySQL_ParamBind::Blob_t dummy(const_cast<sql::SQLString*>(&value));
return param_bind->setBlob(--parameterIndex, dummy, false);
}
--parameterIndex; /* DBC counts from 1 */
{
MySQL_ParamBind::Blob_t dummy;
param_bind->setBlob(parameterIndex, dummy, false);
param_bind->unset(parameterIndex);
}
enum_field_types t = MYSQL_TYPE_STRING;
param_bind->set(parameterIndex);
MYSQL_BIND * param = ¶m_bind->getBindObject()[parameterIndex];
delete [] static_cast<char *>(param->buffer);
param->buffer_type = t;
param->buffer = memcpy(new char[value.length() + 1], value.c_str(), value.length() + 1);
param->buffer_length= static_cast<unsigned long>(value.length()) + 1;
param->is_null_value= 0;
delete param->length;
param->length = new unsigned long(static_cast<unsigned long>(value.length()));
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::cancel() -U- */
void
MySQL_Prepared_Statement::cancel()
{
CPP_ENTER("MySQL_Prepared_Statement::cancel");
CPP_INFO_FMT("this=%p", this);
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::cancel");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getFetchSize() -U- */
size_t
MySQL_Prepared_Statement::getFetchSize()
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::getFetchSize");
return 0; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getMetaData() -I- */
sql::ResultSetMetaData *
MySQL_Prepared_Statement::getMetaData()
{
CPP_ENTER("MySQL_Prepared_Statement::getMetaData");
CPP_INFO_FMT("this=%p", this);
checkClosed();
return res_meta.get();
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getParameterMetaData() -I- */
sql::ParameterMetaData *
MySQL_Prepared_Statement::getParameterMetaData()
{
CPP_ENTER("MySQL_Prepared_Statement::getParameterMetaData");
CPP_INFO_FMT("this=%p", this);
checkClosed();
return param_meta.get();
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getResultSet() -I- */
sql::ResultSet *
MySQL_Prepared_Statement::getResultSet()
{
CPP_ENTER("MySQL_Prepared_Statement::getResultSet");
CPP_INFO_FMT("this=%p", this);
checkClosed();
if (proxy->more_results() && proxy->next_result()) {
sql::mysql::util::throwSQLException(*proxy.get());
}
my_bool bool_tmp = 1;
proxy->attr_set(STMT_ATTR_UPDATE_MAX_LENGTH, &bool_tmp);
sql::ResultSet::enum_type tmp_type;
if (resultset_type == sql::ResultSet::TYPE_SCROLL_INSENSITIVE) {
if (proxy->store_result()) {
sql::mysql::util::throwSQLException(*proxy.get());
}
tmp_type = sql::ResultSet::TYPE_SCROLL_INSENSITIVE;
} else if (resultset_type == sql::ResultSet::TYPE_FORWARD_ONLY) {
tmp_type = sql::ResultSet::TYPE_FORWARD_ONLY;
} else {
throw SQLException("Invalid value for result set type");
}
sql::ResultSet * tmp = new MySQL_Prepared_ResultSet(proxy, result_bind, tmp_type, this, logger);
CPP_INFO_FMT("rset=%p", tmp);
return tmp;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setFetchSize() -U- */
void
MySQL_Prepared_Statement::setFetchSize(size_t /* size */)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setFetchSize");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setQueryTimeout() -U- */
void
MySQL_Prepared_Statement::setQueryTimeout(unsigned int)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setQueryTimeout");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::clearWarnings() -I- */
void
MySQL_Prepared_Statement::clearWarnings()
{
CPP_ENTER("MySQL_Prepared_Statement::clearWarnings");
CPP_INFO_FMT("this=%p", this);
checkClosed();
if (warnings)
{
warnings.reset();
}
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::close() -I- */
void
MySQL_Prepared_Statement::close()
{
CPP_ENTER("MySQL_Prepared_Statement::close");
CPP_INFO_FMT("this=%p", this);
checkClosed();
closeIntern();
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getMaxFieldSize() -U- */
unsigned int
MySQL_Prepared_Statement::getMaxFieldSize()
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::getMaxFieldSize");
return 0; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getMaxRows() -U- */
uint64_t
MySQL_Prepared_Statement::getMaxRows()
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::getMaxRows");
return 0; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getMoreResults() -U- */
bool
MySQL_Prepared_Statement::getMoreResults()
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::getMoreResults");
return false; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getQueryTimeout() -U- */
unsigned int
MySQL_Prepared_Statement::getQueryTimeout()
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::getQueryTimeout");
return 0; // fool compilers
}
/* }}} */
/* {{{ MySQL_Statement::getResultSetType() -I- */
sql::ResultSet::enum_type
MySQL_Prepared_Statement::getResultSetType()
{
CPP_ENTER("MySQL_Statement::getResultSetType");
checkClosed();
return resultset_type;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getUpdateCount() -U- */
uint64_t
MySQL_Prepared_Statement::getUpdateCount()
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::getUpdateCount");
return 0; // fool compilers
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::getWarnings() -I- */
const SQLWarning *
MySQL_Prepared_Statement::getWarnings()
{
CPP_ENTER("MySQL_Prepared_Statement::getWarnings");
CPP_INFO_FMT("this=%p", this);
checkClosed();
if (!warningsHaveBeenLoaded)
{
if (warningsCount)
warnings.reset( loadMysqlWarnings(connection, warningsCount) );
warningsHaveBeenLoaded= true;
}
return warnings.get();
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setCursorName() -U- */
void
MySQL_Prepared_Statement::setCursorName(const sql::SQLString &)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setCursorName");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setEscapeProcessing() -U- */
void
MySQL_Prepared_Statement::setEscapeProcessing(bool)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setEscapeProcessing");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setMaxFieldSize() -U- */
void
MySQL_Prepared_Statement::setMaxFieldSize(unsigned int)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setMaxFieldSize");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setMaxRows() -U- */
void
MySQL_Prepared_Statement::setMaxRows(unsigned int)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setMaxRows");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setResultSetConcurrency() -U- */
void
MySQL_Prepared_Statement::setResultSetConcurrency(int)
{
checkClosed();
throw MethodNotImplementedException("MySQL_Prepared_Statement::setResultSetConcurrency");
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::setResultSetType() -U- */
sql::PreparedStatement *
MySQL_Prepared_Statement::setResultSetType(sql::ResultSet::enum_type /* type */)
{
checkClosed();
#if WE_SUPPORT_USE_RESULT_WITH_PS
/* The connector is not ready for unbuffered as we need to refetch */
resultset_type = type;
#else
throw MethodNotImplementedException("MySQL_Prepared_Statement::setResultSetType");
#endif
return this;
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::checkClosed() -I- */
void
MySQL_Prepared_Statement::checkClosed()
{
CPP_ENTER("MySQL_Prepared_Statement::checkClosed");
if (isClosed) {
CPP_ERR("Statement has already been closed");
throw sql::InvalidInstanceException("Statement has been closed");
}
}
/* }}} */
/* {{{ MySQL_Prepared_Statement::closeIntern() -I- */
void
MySQL_Prepared_Statement::closeIntern()
{
CPP_ENTER("MySQL_Prepared_Statement::closeIntern");
proxy.reset();
clearParameters();
clearWarnings();
isClosed = true;
}
/* }}} */
} /* namespace mysql */
} /* namespace sql */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
|
function svm = svmRemove(svm, indices)
% svm = svmRemove(svm, indices)
% SUPPORT VECTOR MACHINE - REMOVE
% ---------------------------------------------------------
% Removes the specified condition from the SVM structure, patching up any
% holes it leaves in the order of the condition numbers.
%
% INPUTS
% svm - Structure generated by svmInit.
% indices - Vector of indices to remove from SVM structure.
%
% OUTPUTS
% svm - Structure with specified indices removed.
%
% USAGE
% After generating an SVM structure, removing conditions 2 and 3.
% svm = svmInit(...);
% svm = svmRemove(svm, [2 3]);
%
% See also SVMINIT, SVMRUN, SVMEXPORTMAP, SVMBOOTSTRAP, SVMRELABEL,
% SVMRUNOPTIONS, SLINIT.
%
% [email protected] [2010]
%
keepIndices = ~ismember(svm.group, indices);
svm.run = svm.run(keepIndices, :);
svm.group = svm.group(keepIndices, :);
svm.trial = svm.trial(keepIndices, :);
svm.data = svm.data(keepIndices, :);
combineInto = min(svm.group);
svm = svmRelabel(svm, [combineInto indices], svm.grouplabel{combineInto});
end |
/**
* @copyright (c) 2017 King Abdullah University of Science and Technology (KAUST).
* All rights reserved.
**/
/**
* @file codelet_zhagdm.c
*
* Codelet for generating dense matrix from a problem determined according to current global setting of HiCMA library.
*
* HiCMA is a software package provided by King Abdullah University of Science and Technology (KAUST)
*
* @version 0.1.1
* @author Kadir Akbudak
* @date 2018-11-08
**/
#include "morse.h"
#include "runtime/starpu/chameleon_starpu.h"
#include "runtime/starpu/runtime_codelets.h"
ZCODELETS_HEADER(hagdm)
#include <assert.h>
#include <stdio.h>
#include <sys/time.h>//FIXME for gettimeofday
#include "hicma.h"
#include "starsh.h"
#include "starsh-spatial.h"
#include "starsh-randtlr.h"
#ifdef MKL
#include <mkl.h>
#include <mkl_lapack.h>
//#pragma message("MKL is used")
#else
#ifdef ARMPL
#include <armpl.h>
#else
#include <cblas.h>
#endif
#ifdef LAPACKE_UTILS
#include <lapacke_utils.h>
#endif
#include <lapacke.h>
//#pragma message("MKL is NOT used")
#endif
//#warning "An experimental feature is enabled!!!"
extern int steal_lrtile;
extern void _printmat(double * A, int m, int n, int ld);
void zhagdm(
int nrows_Dense,
int ncols_Dense,
double *Dense,
int ld_Dense,
int tile_row_index,
int tile_col_index,
int A_mt
)
{
if(steal_lrtile == 1 && tile_row_index == tile_col_index){
if(tile_row_index == A_mt-1) { // steal tile above
tile_row_index -= 1;
} else { // still tile below
tile_row_index += 1;
}
}
struct timeval tvalBefore, tvalAfter;
gettimeofday (&tvalBefore, NULL);
STARSH_cluster *RC = HICMA_get_starsh_format()->row_cluster, *CC = RC;
void *RD = RC->data, *CD = RD;
HICMA_get_starsh_format()->problem->kernel(nrows_Dense, ncols_Dense,
RC->pivot+RC->start[tile_row_index],
CC->pivot+CC->start[tile_col_index],
RD, CD, Dense, ld_Dense);
}
/**
* HICMA_TASK_zhagdm - Generate dense matrix from a problem determined according to current global setting of HiCMA library
*/
void HICMA_TASK_zhagdm( const MORSE_option_t *options,
int nrows_Dense, int ncols_Dense,
const MORSE_desc_t *Dense,
int ld_Dense,
int tile_row_index,
int tile_col_index,
int A_mt
)
{
struct starpu_codelet *codelet = &cl_zhagdm;
void (*callback)(void*) = NULL;
MORSE_BEGIN_ACCESS_DECLARATION;
MORSE_ACCESS_W(Dense, tile_row_index, tile_col_index);
MORSE_END_ACCESS_DECLARATION;
starpu_insert_task(
starpu_mpi_codelet(codelet),
STARPU_VALUE, &nrows_Dense, sizeof(int),
STARPU_VALUE, &ncols_Dense, sizeof(int),
STARPU_W, RTBLKADDR(Dense, double, tile_row_index, tile_col_index),
STARPU_VALUE, &ld_Dense, sizeof(int),
STARPU_VALUE, &tile_row_index, sizeof(int),
STARPU_VALUE, &tile_col_index, sizeof(int),
STARPU_VALUE, &A_mt, sizeof(int),
STARPU_PRIORITY, options->priority,
STARPU_CALLBACK, callback,
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
STARPU_NAME, "zhagdm",
#endif
0);
}
/**
* cl_zhagdm_cpu_func - Generate a tile for random matrix.
*/
#if !defined(CHAMELEON_SIMULATION)
static void cl_zhagdm_cpu_func(void *descr[], void *cl_arg)
{
int nrows_Dense;
int ncols_Dense;
int ld_Dense;
int tile_row_index;
int tile_col_index;
int A_mt;
int maxrank;
double *Dense;
Dense = (double *)STARPU_MATRIX_GET_PTR(descr[0]);
starpu_codelet_unpack_args(cl_arg, &nrows_Dense, &ncols_Dense, &ld_Dense, &tile_row_index, &tile_col_index, &A_mt);
zhagdm(
nrows_Dense,
ncols_Dense,
Dense,
ld_Dense,
tile_row_index,
tile_col_index,
A_mt
);
}
#endif /* !defined(CHAMELEON_SIMULATION) */
/*
* Codelet definition
*/
CODELETS_CPU(zhagdm, 1, cl_zhagdm_cpu_func)
ZCODELETS_HEADER(hagdmi)
/**
* HICMA_TASK_zhagdmi - Generate dense matrix from a problem determined according to current global setting of HiCMA library
* This function takes indices of tiles of problem.
*/
void HICMA_TASK_zhagdmi( const MORSE_option_t *options,
int nrows_Dense, int ncols_Dense,
const MORSE_desc_t *Dense,
int ld_Dense,
int tile_row_index,
int tile_col_index,
int problem_row_index,
int problem_col_index
)
{
struct starpu_codelet *codelet = &cl_zhagdmi;
void (*callback)(void*) = NULL;
MORSE_BEGIN_ACCESS_DECLARATION;
MORSE_ACCESS_W(Dense, tile_row_index, tile_col_index);
MORSE_END_ACCESS_DECLARATION;
starpu_insert_task(
starpu_mpi_codelet(codelet),
STARPU_VALUE, &nrows_Dense, sizeof(int),
STARPU_VALUE, &ncols_Dense, sizeof(int),
STARPU_W, RTBLKADDR(Dense, double, tile_row_index, tile_col_index),
STARPU_VALUE, &ld_Dense, sizeof(int),
STARPU_VALUE, &tile_row_index, sizeof(int),
STARPU_VALUE, &tile_col_index, sizeof(int),
STARPU_VALUE, &problem_row_index, sizeof(int),
STARPU_VALUE, &problem_col_index, sizeof(int),
STARPU_PRIORITY, options->priority,
STARPU_CALLBACK, callback,
#if defined(CHAMELEON_CODELETS_HAVE_NAME)
STARPU_NAME, "zhagdm",
#endif
0);
}
/** cl_zhagdm_cpu_func - Generate a tile for random matrix.
* This function takes indices of tiles of problem.
*/
#if !defined(CHAMELEON_SIMULATION)
static void cl_zhagdmi_cpu_func(void *descr[], void *cl_arg)
{
int nrows_Dense;
int ncols_Dense;
int ld_Dense;
int tile_row_index;
int tile_col_index;
int maxrank;
double *Dense;
int problem_row_index;
int problem_col_index;
Dense = (double *)STARPU_MATRIX_GET_PTR(descr[0]);
starpu_codelet_unpack_args(cl_arg, &nrows_Dense, &ncols_Dense, &ld_Dense, &tile_row_index, &tile_col_index, &problem_row_index, &problem_col_index);
zhagdm(
nrows_Dense,
ncols_Dense,
Dense,
ld_Dense,
problem_row_index,
problem_col_index, -1
);
}
#endif /* !defined(CHAMELEON_SIMULATION) */
/*
* Codelet definition
*/
CODELETS_CPU(zhagdmi, 1, cl_zhagdmi_cpu_func)
|
classdef CorrelateCross < dagnn.Filter
properties
opts = {'cuDNN'}
ImageArea = [];
BatchSize = [];
end
methods
function outputs = forward(obj, inputs, params)
% Assume the same size
obj.BatchSize = size(inputs{1});
obj.ImageArea = obj.BatchSize(1) * obj.BatchSize(2);
InputsAll = gpuArray.zeros(obj.ImageArea * obj.BatchSize(end), 1, obj.BatchSize(3), 1, 'single');
for i = 1:obj.BatchSize(end)
Start = (i - 1) * obj.ImageArea + 1;
End = i * obj.ImageArea;
InputsAll(Start:End,:,:) = reshape(inputs{1}(:,:,:,i), [obj.ImageArea 1 obj.BatchSize(3)]);
end
outputs = obj.CorrelateFoward({InputsAll});
end
function outputs = CorrelateFoward(obj, inputs)
[h,w,d,batchsize]= size(inputs{1});
inputsfilter = reshape(permute(inputs{1},[3,1,2,4]),1,1,d,h*w,[]);
outputs{1} = gpuArray.zeros(h,w,h*w,batchsize,'single');
for i=1:batchsize
outputs{1}(:,:,:,i) = vl_nnconv(inputs{1}(:,:,:,i), inputsfilter(:,:,:,:,i),[]) ;
end
end
function [derInputs, derParams] = backward(obj, inputs, params, derOutputs)
InputsAll = gpuArray.zeros(obj.ImageArea * obj.BatchSize(end), 1, obj.BatchSize(3), 1, 'single');
for i = 1:obj.BatchSize(end)
Start = (i - 1) * obj.ImageArea + 1;
End = i * obj.ImageArea;
InputsAll(Start:End,:,:) = reshape(inputs{1}(:,:,:,i), [obj.ImageArea 1 obj.BatchSize(3)]);
end
derInputsAll = obj.CorrelateBackward({InputsAll}, derOutputs);
derInputs{1} = gpuArray.zeros(obj.BatchSize, 'single');
for i = 1:obj.BatchSize(end)
Start = (i - 1) * obj.ImageArea + 1;
End = i * obj.ImageArea;
derInputs{1}(:,:,:,i) = reshape(derInputsAll(Start:End,:,:), obj.BatchSize(1:3));
end
derParams = {} ;
end
function derInputs = CorrelateBackward(obj, inputs, derOutputs)
[h,w,d,batchsize]= size(inputs{1});
inputsfilter = reshape(permute(inputs{1},[3,1,2,4]),1,1,d,h*w,[]);
derInputs1 = gpuArray.zeros(h,w,d,batchsize,'single');
derInputs2 = gpuArray.zeros(h,w,d,batchsize,'single');
for i=1:batchsize
[dI1, dI2, ~] = vl_nnconv(...
inputs{1}(:,:,:,i), inputsfilter(:,:,:,:,i), [], derOutputs{1}(:,:,:,i)) ;
derInputs1(:,:,:,i) = dI1;
derInputs2(:,:,:,i) = permute(reshape(dI2,d,h,w,[]),[2 3 1 4]);
end
derInputs = derInputs1 + derInputs2;
end
function obj = CorrelateCross(varargin)
obj.load(varargin) ;
end
end
end |
Please note, all our House Specials contain coconut.
Tandoori chicken marinated in Pakistani spices, fried in butter and served in curry.
Sliced lamb in a special minced lamb sauce with sultanas.
Indian style meatballs in a superbly spiced tomato and onion bhuna sauce.
Cooked with mint, fresh herbs and selected spices, with a sweet and tangy taste.
Prepared with potato and egg. Medium taste.
Topped with korma sauce. Medium.
Chicken tikka tossed over iron skillet with exotic herbs and spices, crushed garlic and ginger root, covered in a sauce of tomatoes, spring onions and capsicums.
Chicken or lamb in a delicious preparation of yoghurt, cream, coconut, mushrooms and spices. Very mild but rich, creamy texture.
Choice of chicken, lamb or prawn cooked in a mild sauce with apricot slices, topped with honey.
Marinated pieces of chicken, lamb, king prawn and sheek kebab, skewered and barbecued with onions and tomatoes. Medium, very tasty dish.
Chicken or lamb cooked with garlic and coriander with a cheese topping. Medium.
Chicken or lamb cooked with eggs and spices.
Chicken or lamb cooked with green chillies, garlic, onion, tomato, capsicum and lemon. Slightly hot dish.
Tender chicken or lamb cooked with minced meat and egg in a thick, spicy sauce. Fairly hot.
Freshly chopped chicken, stir-fried with chillies and tomatoes. Hot dish.
Extremely hot but flavoursome. A tasty alternative for those who live Phall dishes. |
[STATEMENT]
lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1
[PROOF STEP]
by (rule power2_le_imp_le [OF _ zero_le_one])
(simp add: power_divide divide_le_eq not_sum_power2_lt_zero) |
Require Export euclidean__axioms.
Require Export euclidean__defs.
Require Export lemma__betweennotequal.
Require Export lemma__congruencesymmetric.
Require Export lemma__congruencetransitive.
Require Export lemma__lessthancongruence.
Require Export lemma__lessthancongruence2.
Require Export logic.
Definition lemma__together : forall A B C D F G P Q a b c, (euclidean__defs.TG A a B b C c) -> ((euclidean__axioms.Cong D F A a) -> ((euclidean__axioms.Cong F G B b) -> ((euclidean__axioms.BetS D F G) -> ((euclidean__axioms.Cong P Q C c) -> ((euclidean__defs.Lt P Q D G) /\ ((euclidean__axioms.neq A a) /\ ((euclidean__axioms.neq B b) /\ (euclidean__axioms.neq C c)))))))).
Proof.
intro A.
intro B.
intro C.
intro D.
intro F.
intro G.
intro P.
intro Q.
intro a.
intro b.
intro c.
intro H.
intro H0.
intro H1.
intro H2.
intro H3.
assert (exists R, (euclidean__axioms.BetS A a R) /\ ((euclidean__axioms.Cong a R B b) /\ (euclidean__defs.Lt C c A R))) as H4 by exact H.
destruct H4 as [R H5].
destruct H5 as [H6 H7].
destruct H7 as [H8 H9].
assert (* Cut *) (euclidean__axioms.Cong A a A a) as H10.
- apply (@euclidean__axioms.cn__congruencereflexive A a).
- assert (* Cut *) (euclidean__axioms.Cong B b a R) as H11.
-- apply (@lemma__congruencesymmetric.lemma__congruencesymmetric B a R b H8).
-- assert (* Cut *) (euclidean__axioms.Cong F G a R) as H12.
--- apply (@lemma__congruencetransitive.lemma__congruencetransitive F G B b a R H1 H11).
--- assert (* Cut *) (euclidean__axioms.Cong D G A R) as H13.
---- apply (@euclidean__axioms.cn__sumofparts D F G A a R H0 H12 H2 H6).
---- assert (* Cut *) (euclidean__axioms.Cong A R D G) as H14.
----- apply (@lemma__congruencesymmetric.lemma__congruencesymmetric A D G R H13).
----- assert (* Cut *) (euclidean__axioms.Cong C c P Q) as H15.
------ apply (@lemma__congruencesymmetric.lemma__congruencesymmetric C P Q c H3).
------ assert (* Cut *) (euclidean__defs.Lt P Q A R) as H16.
------- apply (@lemma__lessthancongruence2.lemma__lessthancongruence2 C c A R P Q H9 H15).
------- assert (* Cut *) (euclidean__defs.Lt P Q D G) as H17.
-------- apply (@lemma__lessthancongruence.lemma__lessthancongruence P Q A R D G H16 H14).
-------- assert (* Cut *) (euclidean__axioms.neq A a) as H18.
--------- assert (* Cut *) ((euclidean__axioms.neq a R) /\ ((euclidean__axioms.neq A a) /\ (euclidean__axioms.neq A R))) as H18.
---------- apply (@lemma__betweennotequal.lemma__betweennotequal A a R H6).
---------- destruct H18 as [H19 H20].
destruct H20 as [H21 H22].
exact H21.
--------- assert (* Cut *) (euclidean__axioms.neq a R) as H19.
---------- assert (* Cut *) ((euclidean__axioms.neq a R) /\ ((euclidean__axioms.neq A a) /\ (euclidean__axioms.neq A R))) as H19.
----------- apply (@lemma__betweennotequal.lemma__betweennotequal A a R H6).
----------- destruct H19 as [H20 H21].
destruct H21 as [H22 H23].
exact H20.
---------- assert (* Cut *) (euclidean__axioms.neq B b) as H20.
----------- apply (@euclidean__axioms.axiom__nocollapse a R B b H19 H8).
----------- assert (exists S, (euclidean__axioms.BetS A S R) /\ (euclidean__axioms.Cong A S C c)) as H21 by exact H9.
destruct H21 as [S H22].
destruct H22 as [H23 H24].
assert (* Cut *) (euclidean__axioms.neq A S) as H25.
------------ assert (* Cut *) ((euclidean__axioms.neq S R) /\ ((euclidean__axioms.neq A S) /\ (euclidean__axioms.neq A R))) as H25.
------------- apply (@lemma__betweennotequal.lemma__betweennotequal A S R H23).
------------- destruct H25 as [H26 H27].
destruct H27 as [H28 H29].
exact H28.
------------ assert (* Cut *) (euclidean__axioms.neq C c) as H26.
------------- apply (@euclidean__axioms.axiom__nocollapse A S C c H25 H24).
------------- split.
-------------- exact H17.
-------------- split.
--------------- exact H18.
--------------- split.
---------------- exact H20.
---------------- exact H26.
Qed.
|
In the next valley @-@ glades :
|
(* Title: HOL/Library/DAList_Multiset.thy
Author: Lukas Bulwahn, TU Muenchen
*)
section \<open>Multisets partially implemented by association lists\<close>
theory DAList_Multiset
imports Multiset DAList
begin
text \<open>Delete prexisting code equations\<close>
declare [[code drop: "{#}" Multiset.is_empty add_mset
"plus :: 'a multiset \<Rightarrow> _" "minus :: 'a multiset \<Rightarrow> _"
inter_mset union_mset image_mset filter_mset count
"size :: _ multiset \<Rightarrow> nat" sum_mset prod_mset
set_mset sorted_list_of_multiset subset_mset subseteq_mset
equal_multiset_inst.equal_multiset]]
text \<open>Raw operations on lists\<close>
definition join_raw ::
"('key \<Rightarrow> 'val \<times> 'val \<Rightarrow> 'val) \<Rightarrow>
('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
where "join_raw f xs ys = foldr (\<lambda>(k, v). map_default k v (\<lambda>v'. f k (v', v))) ys xs"
lemma join_raw_Nil [simp]: "join_raw f xs [] = xs"
by (simp add: join_raw_def)
lemma join_raw_Cons [simp]:
"join_raw f xs ((k, v) # ys) = map_default k v (\<lambda>v'. f k (v', v)) (join_raw f xs ys)"
by (simp add: join_raw_def)
lemma map_of_join_raw:
assumes "distinct (map fst ys)"
shows "map_of (join_raw f xs ys) x =
(case map_of xs x of
None \<Rightarrow> map_of ys x
| Some v \<Rightarrow> (case map_of ys x of None \<Rightarrow> Some v | Some v' \<Rightarrow> Some (f x (v, v'))))"
using assms
apply (induct ys)
apply (auto simp add: map_of_map_default split: option.split)
apply (metis map_of_eq_None_iff option.simps(2) weak_map_of_SomeI)
apply (metis Some_eq_map_of_iff map_of_eq_None_iff option.simps(2))
done
lemma distinct_join_raw:
assumes "distinct (map fst xs)"
shows "distinct (map fst (join_raw f xs ys))"
using assms
proof (induct ys)
case Nil
then show ?case by simp
next
case (Cons y ys)
then show ?case by (cases y) (simp add: distinct_map_default)
qed
definition "subtract_entries_raw xs ys = foldr (\<lambda>(k, v). AList.map_entry k (\<lambda>v'. v' - v)) ys xs"
lemma map_of_subtract_entries_raw:
assumes "distinct (map fst ys)"
shows "map_of (subtract_entries_raw xs ys) x =
(case map_of xs x of
None \<Rightarrow> None
| Some v \<Rightarrow> (case map_of ys x of None \<Rightarrow> Some v | Some v' \<Rightarrow> Some (v - v')))"
using assms
unfolding subtract_entries_raw_def
apply (induct ys)
apply auto
apply (simp split: option.split)
apply (simp add: map_of_map_entry)
apply (auto split: option.split)
apply (metis map_of_eq_None_iff option.simps(3) option.simps(4))
apply (metis map_of_eq_None_iff option.simps(4) option.simps(5))
done
lemma distinct_subtract_entries_raw:
assumes "distinct (map fst xs)"
shows "distinct (map fst (subtract_entries_raw xs ys))"
using assms
unfolding subtract_entries_raw_def
by (induct ys) (auto simp add: distinct_map_entry)
text \<open>Operations on alists with distinct keys\<close>
lift_definition join :: "('a \<Rightarrow> 'b \<times> 'b \<Rightarrow> 'b) \<Rightarrow> ('a, 'b) alist \<Rightarrow> ('a, 'b) alist \<Rightarrow> ('a, 'b) alist"
is join_raw
by (simp add: distinct_join_raw)
lift_definition subtract_entries :: "('a, ('b :: minus)) alist \<Rightarrow> ('a, 'b) alist \<Rightarrow> ('a, 'b) alist"
is subtract_entries_raw
by (simp add: distinct_subtract_entries_raw)
text \<open>Implementing multisets by means of association lists\<close>
definition count_of :: "('a \<times> nat) list \<Rightarrow> 'a \<Rightarrow> nat"
where "count_of xs x = (case map_of xs x of None \<Rightarrow> 0 | Some n \<Rightarrow> n)"
lemma count_of_multiset: "finite {x. 0 < count_of xs x}"
proof -
let ?A = "{x::'a. 0 < (case map_of xs x of None \<Rightarrow> 0::nat | Some n \<Rightarrow> n)}"
have "?A \<subseteq> dom (map_of xs)"
proof
fix x
assume "x \<in> ?A"
then have "0 < (case map_of xs x of None \<Rightarrow> 0::nat | Some n \<Rightarrow> n)"
by simp
then have "map_of xs x \<noteq> None"
by (cases "map_of xs x") auto
then show "x \<in> dom (map_of xs)"
by auto
qed
with finite_dom_map_of [of xs] have "finite ?A"
by (auto intro: finite_subset)
then show ?thesis
by (simp add: count_of_def fun_eq_iff)
qed
lemma count_simps [simp]:
"count_of [] = (\<lambda>_. 0)"
"count_of ((x, n) # xs) = (\<lambda>y. if x = y then n else count_of xs y)"
by (simp_all add: count_of_def fun_eq_iff)
lemma count_of_empty: "x \<notin> fst ` set xs \<Longrightarrow> count_of xs x = 0"
by (induct xs) (simp_all add: count_of_def)
lemma count_of_filter: "count_of (List.filter (P \<circ> fst) xs) x = (if P x then count_of xs x else 0)"
by (induct xs) auto
lemma count_of_map_default [simp]:
"count_of (map_default x b (\<lambda>x. x + b) xs) y =
(if x = y then count_of xs x + b else count_of xs y)"
unfolding count_of_def by (simp add: map_of_map_default split: option.split)
lemma count_of_join_raw:
"distinct (map fst ys) \<Longrightarrow>
count_of xs x + count_of ys x = count_of (join_raw (\<lambda>x (x, y). x + y) xs ys) x"
unfolding count_of_def by (simp add: map_of_join_raw split: option.split)
lemma count_of_subtract_entries_raw:
"distinct (map fst ys) \<Longrightarrow>
count_of xs x - count_of ys x = count_of (subtract_entries_raw xs ys) x"
unfolding count_of_def by (simp add: map_of_subtract_entries_raw split: option.split)
text \<open>Code equations for multiset operations\<close>
definition Bag :: "('a, nat) alist \<Rightarrow> 'a multiset"
where "Bag xs = Abs_multiset (count_of (DAList.impl_of xs))"
code_datatype Bag
lemma count_Bag [simp, code]: "count (Bag xs) = count_of (DAList.impl_of xs)"
by (simp add: Bag_def count_of_multiset)
lemma Mempty_Bag [code]: "{#} = Bag (DAList.empty)"
by (simp add: multiset_eq_iff alist.Alist_inverse DAList.empty_def)
lift_definition is_empty_Bag_impl :: "('a, nat) alist \<Rightarrow> bool" is
"\<lambda>xs. list_all (\<lambda>x. snd x = 0) xs" .
lemma is_empty_Bag [code]: "Multiset.is_empty (Bag xs) \<longleftrightarrow> is_empty_Bag_impl xs"
proof -
have "Multiset.is_empty (Bag xs) \<longleftrightarrow> (\<forall>x. count (Bag xs) x = 0)"
unfolding Multiset.is_empty_def multiset_eq_iff by simp
also have "\<dots> \<longleftrightarrow> (\<forall>x\<in>fst ` set (alist.impl_of xs). count (Bag xs) x = 0)"
proof (intro iffI allI ballI)
fix x assume A: "\<forall>x\<in>fst ` set (alist.impl_of xs). count (Bag xs) x = 0"
thus "count (Bag xs) x = 0"
proof (cases "x \<in> fst ` set (alist.impl_of xs)")
case False
thus ?thesis by (force simp: count_of_def split: option.splits)
qed (insert A, auto)
qed simp_all
also have "\<dots> \<longleftrightarrow> list_all (\<lambda>x. snd x = 0) (alist.impl_of xs)"
by (auto simp: count_of_def list_all_def)
finally show ?thesis by (simp add: is_empty_Bag_impl.rep_eq)
qed
lemma union_Bag [code]: "Bag xs + Bag ys = Bag (join (\<lambda>x (n1, n2). n1 + n2) xs ys)"
by (rule multiset_eqI)
(simp add: count_of_join_raw alist.Alist_inverse distinct_join_raw join_def)
lemma add_mset_Bag [code]: "add_mset x (Bag xs) =
Bag (join (\<lambda>x (n1, n2). n1 + n2) (DAList.update x 1 DAList.empty) xs)"
unfolding add_mset_add_single[of x "Bag xs"] union_Bag[symmetric]
by (simp add: multiset_eq_iff update.rep_eq empty.rep_eq)
lemma minus_Bag [code]: "Bag xs - Bag ys = Bag (subtract_entries xs ys)"
by (rule multiset_eqI)
(simp add: count_of_subtract_entries_raw alist.Alist_inverse
distinct_subtract_entries_raw subtract_entries_def)
lemma filter_Bag [code]: "filter_mset P (Bag xs) = Bag (DAList.filter (P \<circ> fst) xs)"
by (rule multiset_eqI) (simp add: count_of_filter DAList.filter.rep_eq)
lemma mset_eq [code]: "HOL.equal (m1::'a::equal multiset) m2 \<longleftrightarrow> m1 \<subseteq># m2 \<and> m2 \<subseteq># m1"
by (metis equal_multiset_def subset_mset.order_eq_iff)
text \<open>By default the code for \<open><\<close> is \<^prop>\<open>xs < ys \<longleftrightarrow> xs \<le> ys \<and> \<not> xs = ys\<close>.
With equality implemented by \<open>\<le>\<close>, this leads to three calls of \<open>\<le>\<close>.
Here is a more efficient version:\<close>
lemma mset_less[code]: "xs \<subset># (ys :: 'a multiset) \<longleftrightarrow> xs \<subseteq># ys \<and> \<not> ys \<subseteq># xs"
by (rule subset_mset.less_le_not_le)
lemma mset_less_eq_Bag0:
"Bag xs \<subseteq># A \<longleftrightarrow> (\<forall>(x, n) \<in> set (DAList.impl_of xs). count_of (DAList.impl_of xs) x \<le> count A x)"
(is "?lhs \<longleftrightarrow> ?rhs")
proof
assume ?lhs
then show ?rhs by (auto simp add: subseteq_mset_def)
next
assume ?rhs
show ?lhs
proof (rule mset_subset_eqI)
fix x
from \<open>?rhs\<close> have "count_of (DAList.impl_of xs) x \<le> count A x"
by (cases "x \<in> fst ` set (DAList.impl_of xs)") (auto simp add: count_of_empty)
then show "count (Bag xs) x \<le> count A x" by (simp add: subset_mset_def)
qed
qed
lemma mset_less_eq_Bag [code]:
"Bag xs \<subseteq># (A :: 'a multiset) \<longleftrightarrow> (\<forall>(x, n) \<in> set (DAList.impl_of xs). n \<le> count A x)"
proof -
{
fix x n
assume "(x,n) \<in> set (DAList.impl_of xs)"
then have "count_of (DAList.impl_of xs) x = n"
proof transfer
fix x n
fix xs :: "('a \<times> nat) list"
show "(distinct \<circ> map fst) xs \<Longrightarrow> (x, n) \<in> set xs \<Longrightarrow> count_of xs x = n"
proof (induct xs)
case Nil
then show ?case by simp
next
case (Cons ym ys)
obtain y m where ym: "ym = (y,m)" by force
note Cons = Cons[unfolded ym]
show ?case
proof (cases "x = y")
case False
with Cons show ?thesis
unfolding ym by auto
next
case True
with Cons(2-3) have "m = n" by force
with True show ?thesis
unfolding ym by auto
qed
qed
qed
}
then show ?thesis
unfolding mset_less_eq_Bag0 by auto
qed
declare inter_mset_def [code]
declare union_mset_def [code]
declare mset.simps [code]
fun fold_impl :: "('a \<Rightarrow> nat \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> ('a \<times> nat) list \<Rightarrow> 'b"
where
"fold_impl fn e ((a,n) # ms) = (fold_impl fn ((fn a n) e) ms)"
| "fold_impl fn e [] = e"
context
begin
qualified definition fold :: "('a \<Rightarrow> nat \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> ('a, nat) alist \<Rightarrow> 'b"
where "fold f e al = fold_impl f e (DAList.impl_of al)"
end
context comp_fun_commute
begin
lemma DAList_Multiset_fold:
assumes fn: "\<And>a n x. fn a n x = (f a ^^ n) x"
shows "fold_mset f e (Bag al) = DAList_Multiset.fold fn e al"
unfolding DAList_Multiset.fold_def
proof (induct al)
fix ys
let ?inv = "{xs :: ('a \<times> nat) list. (distinct \<circ> map fst) xs}"
note cs[simp del] = count_simps
have count[simp]: "\<And>x. count (Abs_multiset (count_of x)) = count_of x"
by (rule Abs_multiset_inverse) (simp add: count_of_multiset)
assume ys: "ys \<in> ?inv"
then show "fold_mset f e (Bag (Alist ys)) = fold_impl fn e (DAList.impl_of (Alist ys))"
unfolding Bag_def unfolding Alist_inverse[OF ys]
proof (induct ys arbitrary: e rule: list.induct)
case Nil
show ?case
by (rule trans[OF arg_cong[of _ "{#}" "fold_mset f e", OF multiset_eqI]])
(auto, simp add: cs)
next
case (Cons pair ys e)
obtain a n where pair: "pair = (a,n)"
by force
from fn[of a n] have [simp]: "fn a n = (f a ^^ n)"
by auto
have inv: "ys \<in> ?inv"
using Cons(2) by auto
note IH = Cons(1)[OF inv]
define Ys where "Ys = Abs_multiset (count_of ys)"
have id: "Abs_multiset (count_of ((a, n) # ys)) = (((+) {# a #}) ^^ n) Ys"
unfolding Ys_def
proof (rule multiset_eqI, unfold count)
fix c
show "count_of ((a, n) # ys) c =
count (((+) {#a#} ^^ n) (Abs_multiset (count_of ys))) c" (is "?l = ?r")
proof (cases "c = a")
case False
then show ?thesis
unfolding cs by (induct n) auto
next
case True
then have "?l = n" by (simp add: cs)
also have "n = ?r" unfolding True
proof (induct n)
case 0
from Cons(2)[unfolded pair] have "a \<notin> fst ` set ys" by auto
then show ?case by (induct ys) (simp, auto simp: cs)
next
case Suc
then show ?case by simp
qed
finally show ?thesis .
qed
qed
show ?case
unfolding pair
apply (simp add: IH[symmetric])
unfolding id Ys_def[symmetric]
apply (induct n)
apply (auto simp: fold_mset_fun_left_comm[symmetric])
done
qed
qed
end
context
begin
private lift_definition single_alist_entry :: "'a \<Rightarrow> 'b \<Rightarrow> ('a, 'b) alist" is "\<lambda>a b. [(a, b)]"
by auto
lemma image_mset_Bag [code]:
"image_mset f (Bag ms) =
DAList_Multiset.fold (\<lambda>a n m. Bag (single_alist_entry (f a) n) + m) {#} ms"
unfolding image_mset_def
proof (rule comp_fun_commute.DAList_Multiset_fold, unfold_locales, (auto simp: ac_simps)[1])
fix a n m
show "Bag (single_alist_entry (f a) n) + m = ((add_mset \<circ> f) a ^^ n) m" (is "?l = ?r")
proof (rule multiset_eqI)
fix x
have "count ?r x = (if x = f a then n + count m x else count m x)"
by (induct n) auto
also have "\<dots> = count ?l x"
by (simp add: single_alist_entry.rep_eq)
finally show "count ?l x = count ?r x" ..
qed
qed
end
\<comment> \<open>we cannot use \<open>\<lambda>a n. (+) (a * n)\<close> for folding, since \<open>(*)\<close> is not defined in \<open>comm_monoid_add\<close>\<close>
lemma sum_mset_Bag[code]: "sum_mset (Bag ms) = DAList_Multiset.fold (\<lambda>a n. (((+) a) ^^ n)) 0 ms"
unfolding sum_mset.eq_fold
apply (rule comp_fun_commute.DAList_Multiset_fold)
apply unfold_locales
apply (auto simp: ac_simps)
done
\<comment> \<open>we cannot use \<open>\<lambda>a n. (*) (a ^ n)\<close> for folding, since \<open>(^)\<close> is not defined in \<open>comm_monoid_mult\<close>\<close>
lemma prod_mset_Bag[code]: "prod_mset (Bag ms) = DAList_Multiset.fold (\<lambda>a n. (((*) a) ^^ n)) 1 ms"
unfolding prod_mset.eq_fold
apply (rule comp_fun_commute.DAList_Multiset_fold)
apply unfold_locales
apply (auto simp: ac_simps)
done
lemma size_fold: "size A = fold_mset (\<lambda>_. Suc) 0 A" (is "_ = fold_mset ?f _ _")
proof -
interpret comp_fun_commute ?f by standard auto
show ?thesis by (induct A) auto
qed
lemma size_Bag[code]: "size (Bag ms) = DAList_Multiset.fold (\<lambda>a n. (+) n) 0 ms"
unfolding size_fold
proof (rule comp_fun_commute.DAList_Multiset_fold, unfold_locales, simp)
fix a n x
show "n + x = (Suc ^^ n) x"
by (induct n) auto
qed
lemma set_mset_fold: "set_mset A = fold_mset insert {} A" (is "_ = fold_mset ?f _ _")
proof -
interpret comp_fun_commute ?f by standard auto
show ?thesis by (induct A) auto
qed
lemma set_mset_Bag[code]:
"set_mset (Bag ms) = DAList_Multiset.fold (\<lambda>a n. (if n = 0 then (\<lambda>m. m) else insert a)) {} ms"
unfolding set_mset_fold
proof (rule comp_fun_commute.DAList_Multiset_fold, unfold_locales, (auto simp: ac_simps)[1])
fix a n x
show "(if n = 0 then \<lambda>m. m else insert a) x = (insert a ^^ n) x" (is "?l n = ?r n")
proof (cases n)
case 0
then show ?thesis by simp
next
case (Suc m)
then have "?l n = insert a x" by simp
moreover have "?r n = insert a x" unfolding Suc by (induct m) auto
ultimately show ?thesis by auto
qed
qed
instantiation multiset :: (exhaustive) exhaustive
begin
definition exhaustive_multiset ::
"('a multiset \<Rightarrow> (bool \<times> term list) option) \<Rightarrow> natural \<Rightarrow> (bool \<times> term list) option"
where "exhaustive_multiset f i = Quickcheck_Exhaustive.exhaustive (\<lambda>xs. f (Bag xs)) i"
instance ..
end
end
|
In : (x : a) -> (l : List a) -> Type
In x [] = Void
In x (x' :: xs) = (x' = x) `Either` In x xs
appendEmpty : (xs : List a) -> xs ++ [] = xs
appendEmpty [] = Refl
appendEmpty (x :: xs) = rewrite appendEmpty xs in Refl
in_app_iff : {l : List b} -> {l' : List b} -> In a (l++l') -> (In a l `Either` In a l')
in_app_iff {l = []} { l' = []} x = Left x
in_app_iff {l = []} { l' = (y :: xs)} x = Right x
in_app_iff {l = (y::xs)} { l' = []} x = rewrite sym (appendEmpty xs) in Left x
in_app_iff {l = (y::xs)} {l' = (z::ys)} (Left prf) = Left (Left prf)
in_app_iff {l = (y::xs)} {l' = (z::ys)} (Right prf) =
let induc : Either (In a xs) (Either (z = a) (In a ys))= in_app_iff {l = xs} {l' = z :: ys} prf in
case induc of
(Left l) => Left $ Right l
(Right r) => Right r
|
(** **** SNU 4190.310, 2016 Spring *)
(** Assignment 02 *)
(** Due: 2016/10/10 23:59 *)
(* Important:
- You are NOT allowed to use the [admit] tactic.
- You are NOT allowed to use the following tactics.
[tauto], [intuition], [firstorder], [omega].
- Just leave [exact FILL_IN_HERE] for those problems that you fail to prove.
*)
Require Import Basics.
Definition FILL_IN_HERE {T: Type} : T. Admitted.
(** The following function doubles its argument: *)
Fixpoint double (n:nat) :=
match n with
| O => O
| S n' => S (S (double n'))
end.
Inductive natprod : Type :=
pair : nat -> nat -> natprod.
Notation "( x , y )" := (pair x y).
Definition fst :=
fun (p : natprod) =>
match p with
| (x, y) => x
end.
Definition snd (p : natprod) : nat :=
match p with
| (x, y) => y
end.
Definition swap_pair (p : natprod) : natprod :=
match p with
| (x,y) => (y,x)
end.
(***
See the chapter "Lists" for explanations of the following.
***)
Inductive natlist : Type :=
| nil : natlist
| cons : nat -> natlist -> natlist.
Notation "x :: l" := (cons x l) (at level 60, right associativity).
Notation "[ ]" := nil.
Notation "[ x ; .. ; y ]" := (cons x .. (cons y nil) ..).
Fixpoint app (l1 l2 : natlist) : natlist :=
match l1 with
| nil => l2
| h :: t => h :: (app t l2)
end.
Notation "x ++ y" := (app x y)
(right associativity, at level 60).
Definition hd (default:nat) (l:natlist) : nat :=
match l with
| nil => default
| h :: t => h
end.
Theorem app_assoc : forall l1 l2 l3 : natlist,
(l1 ++ l2) ++ l3 = l1 ++ (l2 ++ l3).
Proof.
intros l1 l2 l3. induction l1 as [| n l1'].
- reflexivity.
- simpl. rewrite -> IHl1'. reflexivity.
Qed.
Fixpoint snoc (l:natlist) (v:nat) : natlist :=
match l with
| nil => [v]
| h :: t => h :: (snoc t v)
end.
Fixpoint rev (l:natlist) : natlist :=
match l with
| nil => nil
| h :: t => snoc (rev t) h
end.
|
\documentclass{article}
\usepackage{amssymb}
\usepackage{multicol,multienum}
\usepackage{latexsym,amssymb,amsmath}
\usepackage{indentfirst}
\usepackage{cases}
\usepackage{color}
\usepackage{graphicx}
\usepackage{mathrsfs}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{CJK}
\usepackage{url}
\usepackage[font={sf,bf},textfont=md]{caption}
\usepackage{animate}
\usepackage{hyperref}
\usepackage{multirow}
\usepackage{interval}
\usepackage[table,xcdraw]{xcolor}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{bm}
\usepackage{thmtools, thm-restate}
\usepackage{bbm}
\usepackage{verbatim}
\usepackage{wrapfig}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{algorithm}
\usepackage{enumitem}
\usepackage{natbib}
\usepackage[noend]{algpseudocode}
\usepackage{bbding}
\usepackage{booktabs}
\usepackage{titlesec}
\usepackage{bigstrut}
\usepackage[stable]{footmisc}
\usepackage{multibib}
\usepackage{pgffor}
\pdfminorversion=4
\addtolength{\oddsidemargin}{-.7in}%
\addtolength{\evensidemargin}{-.7in}%
\addtolength{\textwidth}{1.4in}%
\addtolength{\textheight}{0.8in}%
\addtolength{\topmargin}{-0.8in}%
\newcommand{\irow}[1]{% inline row vector
\big(\begin{smallmatrix}#1\end{smallmatrix}\big)%
}
\newcommand{\beginsupplement}{%
\setcounter{table}{0}
\renewcommand{\thetable}{S\arabic{table}}%
\setcounter{figure}{0}
\renewcommand{\thefigure}{S\arabic{figure}}%
\setcounter{page}{0}
\renewcommand{\theequation}{S.\arabic{equation}}%
\setcounter{equation}{0}
}
\newcommand{\pkg}[1]{{\fontseries{b}\selectfont #1}}
%\newtheorem{theorem}{Theorem}[section]
\newtheorem{theorem}{Theorem}
%\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}{Lemma}
\newtheorem*{remark}{Remark}
\newcommand{\N}{{\mathbb{N}}} % the natural numbers
\newcommand{\Z}{{\mathbb{Z}}} % the integers
\newcommand{\Q}{{\mathbb{Q}}} % the rational numbers
\newcommand{\R}{{\mathbb{R}}} % the real numbers
\newcommand{\C}{{\mathbb{C}}} % the complex numbers
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\begin{document}
\def\spacingset#1{\renewcommand{\baselinestretch}%
{#1}\small\normalsize} \spacingset{1}
\beginsupplement
\appendix
\pagenumbering{arabic}
\begin{center}
\textbf{\large Complete Simulation Results for \\
Selection of Regression Models under Linear Restrictions \\ for Fixed and Random Designs}
Sen Tian, Clifford M. Hurvich, Jeffrey S. Simonoff
\end{center}
\section{Setup}
\subsection{Variable selection}
For the variable selection problem, we consider the following configurations of the experiment.
\begin{itemize}
\item Design matrix $X$: fixed-X and random-X.
\item Sample size: $n \in \{40, 200, 1000\}$.
\item Number of predictors: $p \in \{12, n/2, n-1\}$.
\item Correlation of predictors: $\rho \in \{0,0.5,0.9\}$.
\item Signal level: low, medium and high. The average oracle $R^2$ (linear regression on the set of true predictors) corresponding to these three signal levels are roughly $20\%$, $50\%$ and $90\%$, respectively.
\item The correlation structure $\Sigma_0$ (with entries $\Sigma_{0,ij}$ where $\Sigma_{0,ii}=1$ for $i=1,\cdots,p$) and true coefficient vector $\beta_0$ include the following scenarios (VS stands for variable selection problem):
\begin{itemize}
\item VS-Ex1: \textbf{All of the predictors (both signal and noise) are correlated.} We take $\Sigma_{0,ij}=\rho^{|i-j|}$ for $i,j\in\{1,\cdots,p\}\times\{1,\cdots,p\}$. $\beta_0=[3.5,3,2.5,2,1.5,1,0_{p-6}]^T$.
\item VS-Ex2: \textbf{Signal predictors are only correlated with signal predictors, and noise predictors are only correlated with noise predictors.} We take $\Sigma_{0,ij}=\sigma_{0,ji}=\rho$ for $1\le i <j \le 6$ and $7\le i <j \le p$. Other off-diagonal elements in $\Sigma_0$ are zero. $\beta_0=[1,1,3,3,5,5,0_{p-6}]^T$.
%\item Sparse-Ex3: \textbf{Signal predictors are pairwise correlated with noise predictors.} We take $\Sigma_{0,ij}=\sigma_{0,ji}=\rho$ for $1\le i \le 6$ and $j=6+i$. Other off-diagonal elements in $\Sigma_0$ are zero. $\beta_0=[1_6,0_{p-6}]^T$.
%\item Sparse-Ex4: \textbf{Signal predictors are pairwise correlated with opposite effects.} We take $\Sigma_{0,ij}=\sigma_{0,ji}=\rho$ for $1\le i <j \le 6$. Other off-diagonal elements in $\Sigma_0$ are zero. $\beta_0=[1,-1,3,-3,5,-5,0_{p-6}]^T$.
\item VS-Ex3: \textbf{Same correlation structure as VS-Ex1, but all of the coefficients are non-zero}. The true coefficient vector has: $\beta_{0,j} = \displaystyle (-1)^j \exp(-\frac{j}{\kappa})$, $j=1,\cdots,p$, and here $\kappa=10$.
%\item Dense-Ex2: \textbf{Same setup as Dense-Ex1, but with slower decay}. Here we take $\kappa=50$.
\end{itemize}
\end{itemize}
\subsection{General restriction}
For the general restriction (GR) problem, we consider the following configurations.
\begin{itemize}
\item Design matrix $X$: fixed-X and random-X.
\item Sample size: $n \in \{10, 40\}$.
\item Number of predictors: $p=6$.
\item Correlation of predictors: $\rho \in \{0,0.5,0.9\}$.
\item Signal level: low, medium and high. The average oracle $R^2$ (linear regression on the set of true predictors) corresponding to these three signal levels are roughly $20\%$, $50\%$ and $90\%$, respectively.
\item The entries of the covariance matrix $\Sigma_0$: $\Sigma_{0,ij}=\rho^{|i-j|}$ for $i,j\in\{1,\cdots,p\}\times\{1,\cdots,p\}$.
\item The true coefficient vector:
\begin{itemize}
\item GR-Ex1: $\beta_0 = [2,2,2,1,1,1]^T$.
\item GR-Ex2: $\beta_0 = [-2,2,2,-1.5,-1.5,1]^T$.
\item GR-Ex3: $\beta_0 = [2,-2,1,-1,0.5,-0.5]^T$.
\end{itemize}
\item Restrictions:
\begin{itemize}
\item GR-Ex1:
\begin{itemize}
\item Correct: $\beta_1=\beta_2$, $\beta_2=\beta_3$, $\beta_4=\beta_5$, $\beta_5=\beta_6$
\item Incorrect: $\beta_1=\beta_4$, $\beta_1=2\beta_2$
\end{itemize}
\item GR-Ex2:
\begin{itemize}
\item Correct: $\beta_1+\beta_2=0$, $\beta_3+\beta_4+\beta_5+\beta_6=0$
\item Incorrect: $\beta_5+\beta_6=0$, $\beta_4+\beta_6=0$, $-2\beta_1+\beta_4=0$, $\beta_1-\beta_2=0$
\end{itemize}
\item GR-Ex3:
\begin{itemize}
\item Correct: $\beta_1=-\beta_2$, $\beta_3=-\beta_4$, $\beta_5=-\beta_6$
\item Incorrect: $\beta_1=-\beta_4$, $\beta_2=-\beta_5$, $\beta_1=\beta_2$
\end{itemize}
For each example, we have a total of six restrictions, where the correct ones hold for the choice of $\beta_0$. The candidate restriction set is considered by combining all the possible subsets of the six restrictions, resulting in $64$ candidate restrictions in total.
\end{itemize}
\end{itemize}
We also extend the general restriction example by including restrictions that force additional
predictors to have zero coeffcients, and we consider the following configurations.
\begin{itemize}
\item Design matrix $X$: fixed-X and random-X.
\item Sample size: $n \in \{40, 200, 1000\}$.
\item Number of predictors: $p \in \{12, n/2, n-1\}$.
\item Correlation of predictors: $\rho \in \{0,0.5,0.9\}$.
\item Signal level: low, medium and high. The average oracle $R^2$ (linear regression on the set of true predictors) corresponding to these three signal levels are roughly $20\%$, $50\%$ and $90\%$, respectively.
\item The entries of the covariance matrix $\Sigma_0$: $\Sigma_{0,ij}=\rho^{|i-j|}$ for $i,j\in\{1,\cdots,p\}\times\{1,\cdots,p\}$.
\item The true coefficient vector:
\begin{itemize}
\item GR-Ex4: $\beta_0 = [2,2,2,1,1,1,0_{p-6}]^T$.
\item GR-Ex5: $\beta_0 = [-2,2,2,-1.5,-1.5,1,0_{p-6}]^T$.
\item GR-Ex6: $\beta_0 = [2,-2,1,-1,0.5,-0.5,0_{p-6}]^T$.
\end{itemize}
\item Restrictions:
\begin{itemize}
\item GR-Ex4 (extend the set of restrictions for GR-Ex1): $\beta_1=\beta_4$, $\beta_1=2\beta_2$, $\beta_1=\beta_2$, $\beta_2=\beta_3$, $\beta_4=\beta_5$, $\beta_5=\beta_6$, $\beta_7=0$, $\beta_8=0$, $\cdots$, $\beta_p=0$.
\item GR-Ex5 (extend the set of restrictions for GR-Ex2): $\beta_5+\beta_6=0$, $\beta_4+\beta_6=0$, $-2\beta_1+\beta_4=0$, $\beta_1-\beta_2=0$, $\beta_1+\beta_2=0$, $\beta_3+\beta_4+\beta_5+\beta_6=0$, $\beta_7=0$, $\beta_8=0$, $\cdots$, $\beta_p=0$.
\item GR-Ex6 (extend the set of restrictions for GR-Ex3): $\beta_1=-\beta_4$, $\beta_2=-\beta_5$, $\beta_1=\beta_2$, $\beta_1=-\beta_2$, $\beta_3=-\beta_4$, $\beta_5=-\beta_6$, $\beta_7=0$, $\beta_8=0$, $\cdots$, $\beta_p=0$.
For each example, we have a total of $p$ restrictions. The candidate models are formulated by excluding the restrictions in a nested fashion. We start from the model including all $p$ restrictions (corresponding to the null model), and the next model includes the $p-1$ restrictions except the first one (e.g. $\beta_1=\beta_4$ for GR-Ex4). The process is repeated until all restrictions are excluded (the full model including all predictors with arbitrary slopes) resulting in $p + 1$ candidate models in total.
\end{itemize}
\end{itemize}
\subsection{Data generation and evaluation metric}
For the random-X scenario, in each replication, we generate an $X$ where the rows $x_i$ ($i=1,\cdots,n$) are drawn from a $p$-dimensional multivariate normal distribution with mean zero and covariance matrix $\Sigma_0$, and we draw the response $y$ from the conditional distribution of $y|X$ based on the true model $y=X\beta_0+\epsilon$. The entire process is repeated $1000$ times. For the fixed-X scenario, we only generate $X$ once and draw $1000$ replications of $y$ based on the same $X$. We consider the following metrics to evaluate the fit.
\begin{itemize}
\item Root Mean Squared Error:
\begin{equation*}
\begin{aligned}
\text{RMSEF} &= \sqrt{ \frac{1}{n}\lVert X\hat{\beta} - X\beta_0 \rVert_2^2 }.\\
\text{RMSER} &= \sqrt{E_{X^n} \lVert X^n\hat\beta-X^n\beta_0 \rVert_2^2} = \sqrt{(\hat{\beta}-\beta_0)^T \Sigma_0 (\hat{\beta}-\beta_0)}.
\end{aligned}
\end{equation*}
RMSEF and RMSER are the fixed-X and random-X versions of the RMSE, respectively.
\iffalse
\item Relative risk:
\begin{equation*}
\text{RR}(\hat{\beta}) = \frac{E_{X^n} \lVert X^n\hat\beta-X^n\beta_0 \rVert_2^2}{E_{X^n} \lVert X^n\beta_0 \rVert_2^2} = \frac{(\hat{\beta}-\beta_0)^T \Sigma_0 (\hat{\beta}-\beta_0)}{\beta_0^T \Sigma_0 \beta_0}.
\end{equation*}
\item Relative test error:
\begin{equation*}
\text{RTE}(\hat{\beta}) = \frac{E_{X^n,y^n} \lVert y^n - X^n\hat\beta \rVert_2^2}{\sigma_0^2}= \frac{(\hat{\beta}-\beta_0)^T \Sigma_0 (\hat{\beta}-\beta_0) + \sigma_0^2}{\sigma_0^2}.
\end{equation*}
\item Proportion of variance explained:
\begin{equation*}
\text{PVE}(\hat{\beta}) = 1 - \frac{E_{X^n,y^n} \lVert y^n- X^n\hat\beta \rVert_2^2}{\text{Tr}\left( \text{Cov}_{y^n} (y^n) \right)}= 1-\frac{(\hat{\beta}-\beta_0)^T \Sigma_0 (\hat{\beta}-\beta_0)+\sigma_0^2}{\beta_0^T \Sigma_0 \beta_0 + \sigma_0^2}.
\end{equation*}
\fi
\item KL discrepancy (on log scale): logKLF and logKLR are the fixed-X and random-X versions of the KL on the log scale, where the expressions KL are given in (8) and (13) of the manuscript, respectively.
\iffalse
\begin{equation*}
\begin{aligned}
\text{KLF} &= \text{KLF}(\hat\beta) \\
%&= \log\left( \frac{n\log(2\pi\lVert y-X\hat\beta \rVert_2^2 /n) + n\lVert X\hat{\beta} - X\beta_0 \rVert_2^2/\lVert y-X\hat\beta \rVert_2^2+n^2 \sigma_0^2 / \lVert y-X\hat\beta \rVert_2^2}{n\log(2\pi\lVert y \rVert_2^2 /n) + n\lVert X\beta_0 \rVert_2^2/\lVert y \rVert_2^2+n^2 \sigma_0^2 / \lVert y \rVert_2^2} \right).\\
\text{KLR} &= \text{KLR}(\hat\beta)
%&= \log\left(\frac{n\log(2\pi\lVert y-X\hat\beta \rVert_2^2 /n) + n^2 (\hat{\beta}-\beta_0)^T \Sigma_0 (\hat{\beta}-\beta_0)/\lVert y-X\hat\beta \rVert_2^2+n^2 \sigma_0^2 / \lVert y-X\hat\beta \rVert_2^2}{n\log(2\pi\lVert y \rVert_2^2 /n) + n^2 \beta_0^T \Sigma_0 \beta_0/\lVert y \rVert_2^2+n^2 \sigma_0^2 / \lVert y \rVert_2^2} \right).
\end{aligned}
\end{equation*}
\fi
%Note that $\widetilde{\text{ErrR}}$ is obtained ErrR, by removing the terms that do not change when we compare two models ($np\log(2\pi)$, $n\log|\hat{\Sigma}|$ and $n\text{Tr}(\hat\Sigma^{-1}\Sigma_{0})$). We find that for large $n$ and $p$, these terms dominate the values of ErrR, and make it hard to differentiate the performances of two models as they appear in the criteria of both models.
\item Size of the subset selected for the variable selection problem, and number of restrictions given by the selected model for the general restriction problem.
\end{itemize}
There are in total $486$ scenarios for the variable selection problem, and $594$ scenarios for the general restriction problem.
\clearpage
\section{Results}
\begin{itemize}
\item Variable selection
\begin{itemize}
\item VS-Ex1: Figure S1-S54
\item VS-Ex2: Figure S55-S108
\item VS-Ex3: Figure S109-S162
\end{itemize}
\item General restriction
\begin{itemize}
\item GR-Ex1: Figure S163-S174
\item GR-Ex2: Figure S175-S186
\item GR-Ex3: Figure S187-S198
\item GR-Ex4: Figure S199-S252
\item GR-Ex5: Figure S253-S306
\item GR-Ex6: Figure S307-S360
\end{itemize}
\end{itemize}
\clearpage
\input{plot_supplement.tex}
\iffalse
\clearpage
\bibliographystyle{chicago}
\bibliography{raicc.bib}
\fi
\end{document} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Heterogeneously-indexed binary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Indexed.Heterogeneous where
------------------------------------------------------------------------
-- Publicly export core definitions
open import Relation.Binary.Indexed.Heterogeneous.Core public
open import Relation.Binary.Indexed.Heterogeneous.Definitions public
open import Relation.Binary.Indexed.Heterogeneous.Structures public
open import Relation.Binary.Indexed.Heterogeneous.Bundles public
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.17
REL = IREL
{-# WARNING_ON_USAGE REL
"Warning: REL was deprecated in v0.17.
Please use IREL instead."
#-}
Rel = IRel
{-# WARNING_ON_USAGE Rel
"Warning: Rel was deprecated in v0.17.
Please use IRel instead."
#-}
Setoid = IndexedSetoid
{-# WARNING_ON_USAGE Setoid
"Warning: Setoid was deprecated in v0.17.
Please use IndexedSetoid instead."
#-}
IsEquivalence = IsIndexedEquivalence
{-# WARNING_ON_USAGE IsEquivalence
"Warning: IsEquivalence was deprecated in v0.17.
Please use IsIndexedEquivalence instead."
#-}
|
context("Load: collate")
test_that("If collate absent, load in alphabetical order", {
load_all("testCollateAbsent")
expect_equal(a, 3)
unload("testCollateAbsent")
})
test_that("Warned about files missing from collate, but they're still loaded", {
expect_message(load_all("testCollateMissing"), "a.r")
expect_equal(a, 1)
expect_equal(b, 2)
unload("testCollateMissing")
})
test_that("Extra files in collate don't error, but warn", {
expect_message(load_all("testCollateExtra"), "b.r")
expect_equal(a, 1)
unload("testCollateExtra")
})
|
navbarPage("CartoParcours", id="CartoParcours",
# tout englobé dans div pour le CSS
# onglet carte
tabPanel("Filtre",
div(class="outer",
tags$head(
# Include our custom CSS
includeCSS("style.css")
),
fluidRow(
column(3,
uiOutput("choose_dataset")),
column(6,
h2("Tableau"),
DT::dataTableOutput("tableau")
)
),
fluidRow(
column(10,
h2("Graphiques"),
uiOutput("choose_columns")
)),
fluidRow(
column(12,
uiOutput("plots"))
))
)) |
{-# LANGUAGE FlexibleContexts #-}
module GT.Algebra.Matrix
( adjacencyMatrix,
degreeMatrix,
laplacianMatrix,
)
where
import Data.Maybe (fromJust)
import Data.Sequence as Q (Seq, elemIndexL)
import Data.Tuple (swap)
import Data.Witherable (Witherable, mapMaybe)
import GT.Graph.Class
( Direction (Directed, Undirected),
Graph (degree, direction, edgeMap, nodeCount, nodeIds, nodeMap),
Unwrap (unwrap),
)
import Numeric.LinearAlgebra.Data as LA
( Konst (konst),
Matrix,
R,
accum,
diagl,
)
adjacencyMatrix :: Graph g n n' e e' d => g -> Matrix R
adjacencyMatrix g = LA.accum (konst 0 (n, n)) (+) as'
where
n = nodeCount g
as' = case direction g of
Directed -> as
Undirected -> as ++ fmap (\(rc, a) -> (swap rc, a)) as
is = nodeIds g
as =
edgeMap
( \e' ->
let (i, j) = unwrap e'
r = fromJust $ elemIndexL i is
c = fromJust $ elemIndexL j is
in ((r, c), 1)
)
g
degreeMatrix :: Graph g n n' e e' d => g -> Matrix R
degreeMatrix g = diagl $ nodeMap (\n' -> fromIntegral (fromJust $ degree (unwrap n') g)) g
laplacianMatrix :: Graph g n n' e e' d => g -> Matrix R
laplacianMatrix g = degreeMatrix g - adjacencyMatrix g
|
C05AYJ Example Program Results
Zero at x = 0.56714
|
from bagua.torch_api.distributed import BaguaModule
from bagua.torch_api.bucket import BaguaBucket
from bagua.torch_api.tensor import BaguaTensor
from bagua.torch_api.algorithms import Algorithm
from bagua.torch_api.communication import get_backend
from typing import List
import torch
import bagua_core as B
from bagua.torch_api import get_world_size, get_rank, get_local_rank, get_local_size
from bagua.torch_api import allgather_inplace, alltoall_inplace, allgather, recv, send, reduce_inplace, ReduceOp, broadcast
import torch.distributed as dist
import torch.multiprocessing as mp
# compression:
import cupy
from cupy._binary import packing
from torch.utils.dlpack import to_dlpack, from_dlpack
import math
class QSGDAlgorithm(Algorithm):
def __init__(self, quantization_bits: int = 8):
self.quantization_bits = quantization_bits
def init_operations(
self,
bagua_module: BaguaModule,
bucket: BaguaBucket,
):
bucket.clear_ops()
def qsgd_centeralized_communication(*args):
def compression_tensor(cat_tensor):
scale = torch.norm(cat_tensor)
# signs = torch.sign(cat_tensor).add(1.0).bool()
signs = torch.sign(cat_tensor).add(1.0)
normalized_tensor = cat_tensor / scale
# for performance: just round to nearest level instead of random
level = normalized_tensor * level_of_quantization
quantized = torch.round(level).abs()
quantized = torch.clamp(quantized, max=level_of_quantization)
return scale, signs, quantized.byte()
def compression_signs(signs, is_chunk):
packed_size = (chunk_size + 7) // 8
sign_padding = packed_size * 8 - chunk_size
signs_bool = torch.empty(
0, dtype=torch.uint8, device='cuda:{}'.format(torch.cuda.current_device()))
if (not is_chunk):
signs_padded = torch.empty(
0, device='cuda:{}'.format(torch.cuda.current_device()))
for i in range(n_workers):
temp = torch.cat((signs[:chunk_size], torch.zeros(
sign_padding, device='cuda:{}'.format(torch.cuda.current_device()))))
signs = signs[chunk_size:]
signs_padded = torch.cat((signs_padded, temp))
signs_bool = signs_padded.bool()
else:
signs_bool = signs.bool()
signs_dlpack = to_dlpack(signs_bool)
signs_cupy = cupy.fromDlpack(signs_dlpack)
signs = cupy.packbits(signs_cupy)
signs = signs.toDlpack()
signs = from_dlpack(signs).cuda()
return signs, sign_padding
def decompression(scale, compressed_signs, compressed_tensor):
signs_cupy = cupy.fromDlpack(to_dlpack(compressed_signs))
signs_cupy_unpacked = cupy.unpackbits(signs_cupy)
signs_unpacked = signs_cupy_unpacked.toDlpack()
signs_unpacked = from_dlpack(signs_unpacked).cuda()
signs_decompressed_pad = signs_unpacked.float().mul(2.0).sub(1.0)
signs = torch.empty(0, device='cuda:{}'.format(
torch.cuda.current_device()))
for i in range(n_workers):
signs = torch.cat(
(signs, signs_decompressed_pad[:chunk_size]))
signs_decompressed_pad = signs_decompressed_pad[chunk_size + sign_padding:]
signs = torch.reshape(signs, (n_workers, chunk_size))
return compressed_tensor / level_of_quantization * scale * signs
backend = get_backend("")
rank = get_rank()
n_nodes = get_world_size()
n_workers = n_nodes
# currently only works with 8 quantization_bits
quantization_bits = 8
level_of_quantization = (1 << quantization_bits) - 1
cat_tensor = torch.empty(
0, device='cuda:{}'.format(torch.cuda.current_device()))
# Concatenate the tensors in the bucket
for tensor in bucket.tensors:
clone_tensor = tensor.clone().detach()
cat_tensor = torch.cat(
(cat_tensor, clone_tensor.flatten()))
# compress the cat_tensor
scale, signs, compressed_tensor = compression_tensor(
cat_tensor)
del cat_tensor
# allgather the sale of own compressed_tensor and receive all the other scales
recv_scales = torch.empty(
n_workers, device='cuda:{}'.format(torch.cuda.current_device()))
allgather(scale, recv_scales)
recv_scales = torch.reshape(recv_scales, (n_workers, 1))
# prepare compressed_tensor for alltoall by adding padding if needed
chunk_size = math.ceil(compressed_tensor.numel() / n_workers)
# chunk_padding: number of elements to add to that compressed_tensor can be distributed evently to all workers
chunk_padding = 0
if (compressed_tensor.numel() % n_workers != 0):
chunk_padding = (chunk_size * n_workers) - \
compressed_tensor.numel()
compressed_tensor = torch.cat((compressed_tensor, torch.empty(
chunk_padding, dtype=torch.uint8, device='cuda:{}'.format(torch.cuda.current_device()))))
signs = torch.cat((signs, torch.zeros(
chunk_padding, dtype=torch.uint8, device='cuda:{}'.format(torch.cuda.current_device()))))
compressed_tensor = compressed_tensor.byte()
alltoall_inplace(compressed_tensor)
recv_tensor = torch.reshape(
compressed_tensor, (n_workers, chunk_size)).float()
del compressed_tensor
# compress the signs and prepare them for alltoall by adding padding
compressed_signs, sign_padding = compression_signs(
signs, is_chunk=False)
alltoall_inplace(compressed_signs)
chunk_decompressed = decompression(
recv_scales, compressed_signs, recv_tensor)
del compressed_signs
del recv_scales
del recv_tensor
chunk_avg = torch.mean(chunk_decompressed, 0)
scale, signs, compressed_tensor = compression_tensor(chunk_avg)
compressed_signs, sign_padding = compression_signs(
signs, is_chunk=True)
del chunk_avg
# communicate averaged chunks
recv_scales = torch.empty(
(scale.numel() * n_workers), device='cuda:{}'.format(torch.cuda.current_device()))
allgather(scale, recv_scales)
recv_scales = torch.reshape(recv_scales, (n_workers, 1))
del scale
recv_signs = torch.empty((compressed_signs.numel(
) * n_workers), dtype=torch.uint8, device='cuda:{}'.format(torch.cuda.current_device()))
allgather(compressed_signs, recv_signs)
del compressed_signs
recv_tensor = torch.empty((compressed_tensor.numel() * n_workers), dtype=torch.uint8,
device='cuda:{}'.format(torch.cuda.current_device()))
allgather(compressed_tensor, recv_tensor)
del compressed_tensor
# TESTING RESHAPING
recv_scales = torch.reshape(recv_scales, (n_workers, 1))
recv_tensor = torch.reshape(
recv_tensor, (n_workers, chunk_size)).float()
decompressed = decompression(
recv_scales, recv_signs, recv_tensor)
del recv_scales, recv_signs, recv_tensor
decompressed = decompressed.flatten()
padding = decompressed.numel() - chunk_padding
update_tensor = decompressed[0:padding]
for tensor in bucket.tensors:
tensor_size = tensor.numel()
tensor_shape = tensor.shape
new_tensor = update_tensor[0:tensor_size]
new_tensor = torch.reshape(new_tensor, tensor_shape)
tensor.set_(new_tensor)
update_tensor = update_tensor[tensor_size:]
del update_tensor
torch.cuda.empty_cache()
bucket.append_python_op(qsgd_centeralized_communication)
|
\chapter*{Preface to the Open Source Edition}
{\em Java, Java, Java, 3e} was previously published by Pearson
Education, Inc. The first edition (2000) and the second
edition (2003) were published by Prentice-Hall. In 2010
Pearson Education, Inc. reassigned the copyright to
the authors, and we are happy now to be able to make the
book available under an open source license.
This PDF edition of the book is available under a Creative Commons
Attribution 4.0 International License, which allows the
book to be used, modified, and shared with attribution:
\\(https://creativecommons.org/licenses/by/4.0/).
\noindent
\\-- Ralph Morelli and Ralph Walde
\noindent
\\-- Hartford, CT
\noindent
\\-- December 30, 2016
|
```python
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 20191125
@author: zhangji
test the linear relationship
U_t =?= U_sh + U_wm
U_t is the total velocity
U_sh is the velocity induced by shear flow
U_wm is the active velocity.
"""
# %pylab inline
# pylab.rcParams['figure.figsize'] = (25, 11)
# fontsize = 40
# import numpy as np
# import scipy as sp
# from scipy.optimize import leastsq, curve_fit
# from scipy import interpolate
# from scipy.interpolate import interp1d
# from scipy.io import loadmat, savemat
# # import scipy.misc
# import matplotlib
# from matplotlib import pyplot as plt
# from matplotlib import animation, rc
# import matplotlib.ticker as mtick
# from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes
# from mpl_toolkits.mplot3d import Axes3D, axes3d
# from sympy import symbols, simplify, series, exp
# from sympy.matrices import Matrix
# from sympy.solvers import solve
# from IPython.display import display, HTML
# from tqdm import tqdm_notebook as tqdm
# import pandas as pd
# import re
# from scanf import scanf
# import os
# import glob
# from codeStore import support_fun as spf
# from src.support_class import *
# from src import stokes_flow as sf
# rc('animation', html='html5')
# PWD = os.getcwd()
# font = {'size': 20}
# matplotlib.rc('font', **font)
# np.set_printoptions(linewidth=90, precision=5)
%load_ext autoreload
%autoreload 2
import os
import glob
import re
import pandas as pd
from scanf import scanf
import natsort
import numpy as np
import scipy as sp
from scipy.optimize import leastsq, curve_fit
from scipy import interpolate, spatial, sparse, optimize
# from scipy.interpolate import interp1d
from scipy.io import loadmat, savemat
# import scipy.misc
import importlib
from IPython.display import display, HTML
import pickle
import matplotlib
from matplotlib import pyplot as plt
from matplotlib import colors as mcolors
from matplotlib import animation, rc
import matplotlib.ticker as mtick
from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes
from mpl_toolkits.mplot3d import Axes3D, axes3d
from matplotlib import ticker, cm
from mpl_toolkits.axes_grid1 import make_axes_locatable
from time import time
from src import support_class as spc
from src import jeffery_model as jm
from codeStore import support_fun as spf
from codeStore import support_fun_table as spf_tb
# %matplotlib notebook
%matplotlib inline
rc('animation', html='html5')
rc('text', usetex=True)
params = {'text.latex.preamble': [r'\usepackage{bm}', r'\usepackage{amsmath}']}
plt.rcParams.update(params)
fontsize = 40
figsize = (30, 16)
PWD = os.getcwd()
```
```python
fig = plt.figure(figsize=(2, 2))
fig.patch.set_facecolor('white')
ax0 = fig.add_subplot(1, 1, 1)
```
```python
from shutil import copyfile
pickle_name = 'hlxB01_baseFlow'
mdf_pickle_name = 'hlxB01_baseFlow_mdf'
with open('%s.pickle' % pickle_name, 'rb') as handle:
pickle_dict = pickle.load(handle)
display(np.vstack(pickle_dict['uw_Base_list'])[1:6, :3])
display(np.vstack(pickle_dict['uw_Base_list'])[1:6, 3:])
t1 = pickle_dict['uw_Base_list'].copy()
for i0 in (1, 2, 3, 4, 5):
t1[i0] = np.zeros_like(t1[i0])
t1[2][3] = pickle_dict['uw_Base_list'][2][3]
t1[4][1] = pickle_dict['uw_Base_list'][4][1]
t1[5][0] = pickle_dict['uw_Base_list'][5][0]
t1[4][4] = pickle_dict['uw_Base_list'][4][4]
t1[5][3] = pickle_dict['uw_Base_list'][5][3]
display(np.vstack(t1)[1:6, :])
display(np.vstack(t1)[9, :])
pickle_dict['uw_Base_list'] = t1
tname = '%s.pickle' % mdf_pickle_name
with open(tname, 'wb') as handle:
pickle.dump(pickle_dict, handle, protocol=pickle.HIGHEST_PROTOCOL)
copyfile(tname, os.path.join(os.getcwd(), os.pardir, os.pardir, 'src', tname))
print('save table_data to %s' % tname)
```
array([[-7.76132412e-03, -5.69502967e-08, -4.66898703e-07],
[ 2.80705829e-02, 1.65351066e-06, 2.25261263e-07],
[ 6.62964540e-08, -7.04582609e-03, -8.56368581e-05],
[ 2.31596494e-07, -2.42372294e-02, -1.41701252e-02],
[ 2.32129486e-02, 4.40727001e-08, -6.61599524e-07]])
array([[ 2.88299473e-02, -1.46853323e-06, -1.03064360e-06],
[ 5.42510802e-02, -2.22381634e-06, -8.76820219e-06],
[ 1.00153773e-06, 3.19268703e-02, 5.91691688e-02],
[ 6.59827138e-07, 9.56943091e-01, -5.45242721e-02],
[-9.68509888e-01, -5.96048419e-08, 6.67837781e-07]])
array([[ 0. , 0. , 0. , 0. , 0. ,
0. ],
[ 0. , 0. , 0. , 0.05425108, 0. ,
0. ],
[ 0. , 0. , 0. , 0. , 0. ,
0. ],
[ 0. , -0.02423723, 0. , 0. , 0.95694309,
0. ],
[ 0.02321295, 0. , 0. , -0.96850989, 0. ,
0. ]])
array([0., 0., 0., 0., 0., 0.])
save table_data to hlxB01_baseFlow_mdf.pickle
```python
pickle_name = 'hlxC01_baseFlow'
with open('%s.pickle' % pickle_name, 'rb') as handle:
pickle_dict = pickle.load(handle)
display(np.vstack(pickle_dict['uw_Base_list'])[1:6, :3])
display(np.vstack(pickle_dict['uw_Base_list'])[1:6, 3:])
pickle_dict['problem_kwargs']
```
array([[-1.88711409e-02, -2.79019503e-08, 1.93690957e-07],
[ 3.78986662e-02, 4.55500239e-09, 2.11266648e-07],
[ 6.24916098e-08, -4.02988899e-03, 1.15194554e-02],
[ 4.16665587e-07, -3.23764564e-02, -1.64266651e-02],
[ 3.07251774e-02, 2.14228359e-09, 2.18574696e-08]])
array([[ 2.88844213e-02, -1.42407563e-07, 1.44794001e-07],
[ 9.19696658e-02, -1.02179777e-06, -4.29459143e-07],
[ 3.92545578e-07, 5.21519706e-02, 7.95683975e-01],
[ 7.05201088e-07, 7.28549445e-01, -5.78217355e-02],
[-9.57230642e-01, -3.33148727e-08, -2.80564695e-08]])
{'MPISIZE': 24,
'basei': 1,
'belemshandle': 'belems',
'bnodeshandle': 'bnodes',
'center': array([0, 0, 0]),
'ch': 3.0,
'eh': -1.0,
'ffweightT': 2.0,
'ffweightx': 2.0,
'ffweighty': 2.0,
'ffweightz': 2.0,
'field_range': array([[-3, -3, -3],
[ 3, 3, 3]]),
'fileHandle': 'hlxC01_baseFlow',
'getConvergenceHistory': False,
'hfct': 1.0,
'hlx_ini_rot_theta': 0,
'left_hand': False,
'matname': 'body1',
'matrix_method': 'pf',
'n_grid': array([10, 10, 10]),
'n_node_threshold': 5000,
'n_tail': 1,
'nth': 20,
'ph': 0.666667,
'pickProblem': False,
'plot_geo': False,
'precondition_method': 'none',
'rT2': 0.03,
'region_type': 'rectangle',
'rel_Uh': array([0., 0., 0., 0., 0., 0.]),
'repeat_n': 1,
'restart': False,
'rh1': 0.2,
'rh11': 0.3,
'rh12': 0.1,
'rh2': 0.03,
'rot_norm': array([1, 0, 0]),
'rot_theta': 0,
'save_vtk': False,
'solve_method': 'gmres',
'with_cover': 2,
'zoom_factor': 1.0}
```python
```
```python
figsize = np.array((16, 9)) * 0.5
figsize = np.array((9, 9)) * 0.5
dpi = 300
t1, t2 = np.meshgrid(np.linspace(-3, 3, 8), np.linspace(-3, 3, 8), indexing='ij')
# u1, u2 = t1, -t2
# title = '$\\tilde{\\bm{u}}^{E1} = (x, -y, 0)$'
# xlabel, ylabel = '$x$', '$y$'
# u1, u2 = -t1, t2
# title = '$\\tilde{\\bm{u}}^{E2} = (0, -y, z)$'
# xlabel, ylabel = '$y$', '$z$'
# u1, u2 = t2, t1
# title = '$\\tilde{\\bm{u}}^{E3} = (y, x, 0)$'
# xlabel, ylabel = '$x$', '$y$'
# u1, u2 = t2, t1
# title = '$\\tilde{\\bm{u}}^{E4} = (z, 0, x)$'
# xlabel, ylabel = '$x$', '$z$'
# u1, u2 = t2, t1
# title = '$\\tilde{\\bm{u}}^{E5} = (0, y, x)$'
# xlabel, ylabel = '$y$', '$z$'
# u1, u2 = t2, t1
# title = '$\\tilde{\\bm{u}}^{E4} = (z, 0, x)$'
# xlabel, ylabel = '$x$', '$z$'
# u1, u2 = np.ones_like(t2), np.zeros_like(t2)
# title = ''
# xlabel, ylabel = '$x$', '$z$'
# u1, u2 = -t2, -t1
# title = ''
# xlabel, ylabel = '$x$', '$z$'
# u1, u2 = t2, -t1
# title = ''
# xlabel, ylabel = '$x$', '$z$'
u1, u2 = t2, 0.25 * t1
title = '$(z, 0, 0.25x)$'
xlabel, ylabel = '$x$', '$z$'
fig, axs = plt.subplots(1, 1, figsize=figsize, dpi=dpi)
fig.patch.set_facecolor('white')
axi = axs
axi.quiver(t1, t2, u1, u2, scale=None)
axi.axis('equal')
axi.set_title(title)
axi.set_xlabel(xlabel)
axi.set_ylabel(ylabel)
plt.tight_layout()
```
```python
```
|
/-
Copyright (c) 2019 Jesse Michael Han. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author(s): Jesse Michael Han
Tests for `finish using [...]`
-/
import tactic.finish
import algebra.order.ring
section list_rev
open list
variable {α : Type*}
def append1 (a : α) : list α → list α
| nil := [a]
| (b :: l) := b :: (append1 l)
def rev : list α → list α
| nil := nil
| (a :: l) := append1 a (rev l)
lemma hd_rev (a : α) (l : list α) :
a :: rev l = rev (append1 a l) :=
begin
induction l with l_hd l_tl ih, refl,
-- finish -- fails
-- finish[rev, append1] -- fails
-- finish[rev, append1, ih] -- fails
-- finish[rev, append1, ih.symm] -- times out
finish using [rev, append1]
end
end list_rev
section barber
variables (man : Type) (barber : man)
variable (shaves : man → man → Prop)
example (h : ∀ x : man, shaves barber x ↔ ¬ shaves x x) : false :=
by finish using [h barber]
end barber
constant real : Type
@[instance] constant orreal : ordered_ring real
-- TODO(Mario): suspicious fix
@[irreducible] noncomputable instance : has_lt real := by apply_instance
constants (log exp : real → real)
constant log_exp_eq : ∀ x, log (exp x) = x
constant exp_log_eq : ∀ {x}, x > 0 → exp (log x) = x
constant exp_pos : ∀ x, exp x > 0
constant exp_add : ∀ x y, exp (x + y) = exp x * exp y
theorem log_mul' {x y : real} (hx : x > 0) (hy : y > 0) :
log (x * y) = log x + log y :=
by finish using [log_exp_eq, exp_log_eq, exp_add]
|
# SynchronySDK integration file
using SynchronySDK
using DocStringExtensions # temporary while $(SIGNATURES) is in use in this file
const Syncr = SynchronySDK
"""
SyncrSLAM
An object definition containing the require variables to leverage the server side SLAM solution per user, robot, and session.
"""
mutable struct SyncrSLAM
robotId::AbstractString
sessionId::AbstractString
syncrconf::Union{Void, SynchronySDK.SynchronyConfig}
robot
session
# Constructor
SyncrSLAM(
robotId::AbstractString,
sessionId::AbstractString,
syncrconf::Union{Void, SynchronySDK.SynchronyConfig};
robot=nothing,
session=nothing
) = new(
robotId,
sessionId,
syncrconf,
robot,
session
)
end
"""
$(SIGNATURES)
Get Synchrony configuration, default filepath location assumed as `~/Documents/synchronyConfig.json`.
"""
function loadSyncrConfig(;
filepath::AS=joinpath(ENV["HOME"],"Documents","synchronyConfig.json")
) where {AS <: AbstractString}
#
println(" - Retrieving Synchrony Configuration...")
configFile = open(filepath)
configData = JSON.parse(readstring(configFile))
close(configFile)
Unmarshal.unmarshal(SynchronyConfig, configData) # synchronyConfig =
end
"""
$(SIGNATURES)
Confirm that the robot already exists, create if it doesn't.
"""
function syncrRobot(
synchronyConfig::SynchronyConfig,
robotId::AS
) where {AS <: AbstractString}
#
println(" - Creating or retrieving robot '$robotId'...")
robot = nothing
if(SynchronySDK.isRobotExisting(synchronyConfig, robotId))
println(" -- Robot '$robotId' already exists, retrieving it...")
robot = getRobot(synchronyConfig, robotId)
else
# Create a new one
println(" -- Robot '$robotId' doesn't exist, creating it...")
newRobot = RobotRequest(robotId, "My New Bot", "Description of my neat robot", "Active")
robot = addRobot(synchronyConfig, newRobot)
end
println(robot)
robot
end
"""
$(SIGNATURES)
Get sessions, if it already exists, add to it.
"""
function syncrSession(
synchronyConfig::SynchronyConfig,
robotId::AS,
sessionId::AS
) where {AS<: AbstractString}
#
println(" - Creating or retrieving data session '$sessionId' for robot...")
session = nothing
if(SynchronySDK.isSessionExisting(synchronyConfig, robotId, sessionId))
println(" -- Session '$sessionId' already exists for robot '$robotId', retrieving it...")
session = getSession(synchronyConfig, robotId, sessionId)
else
# Create a new one
println(" -- Session '$sessionId' doesn't exist for robot '$robotId', creating it...")
newSessionRequest = SessionDetailsRequest(sessionId, "Submersible vehicle.", "Pose3", false)
session = addSession(synchronyConfig, robotId, newSessionRequest)
end
println(session)
session
end
"""
$(SIGNATURES)
Intialize the `sslaml` object using configuration file defined in `syncrconfpath`.
"""
function initialize!(sslaml::SyncrSLAM;
syncrconfpath::AS=joinpath(ENV["HOME"],"Documents","synchronyConfig.json")
) where {AS <: AbstractString}
# 1. Get a Synchrony configuration
sslaml.syncrconf = loadSyncrConfig(filepath=syncrconfpath)
# 2. Confirm that the robot already exists, create if it doesn't.
sslaml.robot = syncrRobot(sslaml.syncrconf, sslaml.robotId)
# Make sure that this session is not already populated
if isSessionExisting(slam_client.syncrconf, sslaml.robotId, sslaml.sessionId)
warn("There is already a session named '$sessionId' for robot '$robotId'. This example will fail if it tries to add duplicate nodes. We strongly recommend providing a new session name.")
print(" Should we delete it? [Y/N] - ")
if lowercase(strip(readline(STDIN))) == "y"
deleteSession(sslaml.syncrconf, sslaml.robotId, sslaml.sessionId)
println(" -- Session '$sessionId' deleted!")
else
warn("Okay, but this may break the example! Caveat Userus!")
end
end
# 3. Create or retrieve the session.
sslaml.session = syncrSession(sslaml.syncrconf, sslaml.robotId, sslaml.sessionId)
nothing
end
|
\chapter{Sequential Transport planning}
In this chapter, we describe the planning approaches we
selected, implemented, and tested for the STRIPS variant of Transport.
Throughout this, we will leverage the acquired
Transport domain knowledge as much as possible.
\section{State-space forward planning}\label{forward-planning}
One of the most straightforward approaches to automated planning
is forward search \citep[Section~4.2]{Ghallab2004}
in state space (Figure~\ref{alg:forward-search}).
Although the algorithm is defined on a classical representation,
it can be used on any planning problem, where we can:
\begin{itemize}
\item determine whether a state is a goal state or not;
\item iterate over all actions applicable to a state; and
\item compute a successor state by applying an action to the current state.
\end{itemize}
Forward search, despite its simplicity, is one of the most frequently
used approaches for domain-independent planners.
There are two key steps of the algorithm, which
cause the most problems in practice: representing
the applicable actions (step 6) and choosing the
next action to apply (step 8).
\myalg{Forward Search}%
{%
\Input a planning problem in a classical representation $\mathcal{P} = (S, O, \gamma, s_0, g)$
\Output a plan $\pi$
\Function{Forward-Search}{$\mathcal{P}$}
\State $s \gets s_0$
\State $\pi \gets $ empty plan
\Loop
\If {$s$ satisfies $g$} \Return $\pi$ \EndIf
\State $A_s \gets \{a \,|\, o \in O$, $a$ is a ground instance of $o \;\&\; \mt{precond}(a) \mt{ is true in } s\}$
\If {$A_s = \emptyset$} \Return failure \EndIf
\State (nondeterministically) choose an action $a \in A_s$
\State $s \gets \gamma(s, a)$
\State $\pi \gets$ append $a$ to $\pi$
\EndLoop
\EndFunction
}%
{A forward search planning algorithm.}{A forward search planning algorithm for Transport. Adapted from \citet[Figure~4.1]{Ghallab2004}.}{forward-search}{bt}
Representing state transitions in step 6
is a technical problem of representing successor states
in state space search \citep[Section~3.2]{Russell1995}.
Due to limited memory,
applicable actions are grounded from operators
on demand, as are the corresponding successor states
\citep[Section~3.4]{Russell1995}.
The forward search algorithm, in its specified form, is nondeterministic.
If we knew which action to choose in step 8,
we would know how to solve the planning problem.
Since we generally do not know which action (state transition) to chose in a given state, the choice is usually delegated to a suitable
search algorithm, which makes forward search deterministic.
\subsection{Deterministic search algorithms}
State space search algorithms are a heavily studied area
of computer science and any reasonable search algorithm applied
to forward search will yield results.
Examples of such algorithms are Breadth-First Search (BFS),
Depth-First Search (DFS), and many more \citep[Section~3.5]{Russell1995}.
The choice of a search algorithm greatly influences
the quality of resulting plans when applied to forward search.
As sizes of planning problems grow,
choosing a search algorithm is even more crucial.
Several well-performing algorithms on small problems (like BFS)
exceed reasonable run times and become unusable for practical application on larger problems.
An important and practically useful search algorithm
withstanding larger problem sizes is the \textit{A$^{\kern-.05em*}$ algorithm} (Figure~\ref{alg:astar})
introduced in \citet{Hart1968}.
\myalg{Forward Search with A$^{\kern-.15em*}$}%
{%
\Input a classical planning problem $\mathcal{P} = (S, O, \gamma, s_0, g)$,
a heuristic $h$
\Output a plan $\pi$
\Function{Collect-Plan}{$s, \pi$}
\State $\pi' \gets $ empty list
\While{$s \neq \emptyset$}
\State $(s', a) \gets \pi[s]$
\State $\pi' \gets$ prepend $a$ to $\pi'$
\State $s \gets s'$
\EndWhile
\State \Return $\pi'$
\EndFunction
\Function{Forward-Search-Astar}{$\mathcal{P}$}
\State $\pi \gets $ empty map, $f[*] \gets \infty$, $g[*] \gets \infty$, $o \gets \{s_0\}$, $c \gets \emptyset$
\State $\pi[s_0] \gets \emptyset$,
$g[s_0] \gets 0$, $f[s_0] \gets h(s_0)$
\While{$o \neq \emptyset$}
\State $s \gets \mt{argmin}_{s' \in o} f[s']$, $o \gets o \setminus \{s\}$, $c \gets c \cup \{s\}$
\If {$s$ satisfies $g$} \Return \Call{Collect-Plan}{$s$, $\pi$} \EndIf
\ForAll{actions $a \in$ \Call{Generate-Actions}{$s, \pi$}}
\State $s_n \gets \gamma(s, a)$ \Comment{Neighbor state}
\If{$s_n \notin c$} \Comment{Not visited yet}
\If{$s_n \notin o$} $o \gets o \cup \{s_n\}$ \Comment{Discovered a new state} \EndIf
\If{$g[s] + \mt{cost}(a) < g[s_n]$} \Comment{Found a better path}
\State $\pi[s_n] \gets (s, a)$
\State $g[s_n] \gets g[s] + \mt{cost}(a)$
\State $f[s_n] \gets g[s_n] + h(s_n)$
\EndIf
\EndIf
\EndFor
\EndWhile
\Return failure
\EndFunction
}%
{A forward search planning algorithm using A$^{\kern-.15em*}{\kern-.30em.}$}{A forward search planning algorithm using A$^{\kern-.15em*}{\kern-.30em.}$
\textsc{Generate-Actions} is a function that produces actions applicable to the state $s$. The notation $x[*] \gets y$ reprensents initialization of all values of the map $x$ to $y$.}{astar}{tb}
A$^{\kern-.15em*}$ has many important properties. We pinpoint one important to us, namely its admissibility.
A search algorithm is \textit{admissible}
if it is guaranteed to find an optimal path from a state $s$
to a goal state $s_g$ for any state space \citep{Hart1968}.
A$^{\kern-.15em*}$ is admissible and optimal given an admissible heuristic.
An \textit{admissible} heuristic never overestimates
the true value it is approximating. During planning in state space,
when examining a state $s$, we want to estimate the total cost of the best
plan that gets us to a goal state from state $s$. In other words, because we are
trying to minimize the total cost,
a planning heuristic $h: S \to \N_0$ is admissible if and only if $\forall s \in S : h(s) \leq h^*(s),$
where $h^*$ is the true total cost (i.e.\;the optimal heuristic). A similar definition is applicable for minimizing makespan in the temporal variant.
Furthermore, some heuristics have the property of being consistent. A heuristic $h$ is consistent
if and only if $\forall s \in S : h(s) \leq cost(a) + h(s_n)$
(where $a \in A : \gamma(s, a) = s_n$) and for all goal states $s_g$, it holds that $h(s_g) = 0$.
Consistent heuristics are sometimes called monotonic, because their value
does not increase along the best path to a goal state. Additionally,
it can be proven that consistent heuristics are always admissible
\citep[Section~4.1]{Russell1995}.
A slight modification of A$^{\kern-.15em*}{\kern-.30em,}$ called \textit{Weighted A$^{\kern-.05em*}$} \citep{Pohl1970},
tends to yield good quality plans in a shorter amount of time,
at the expense of
sacrificing admissibility. The only difference
when compared to A$^{\kern-.15em*}$ is that the heuristic $h(x)$
is substituted for $h_w(x) = w \cdot h(x),$
where $w \in \N_0$ is a weight constant. Choosing a weight greater
than 1 makes the heuristic inadmissible,
but guides the search towards a goal state faster.
\subsection{Heuristics for forward search in Transport}\label{seq-heuristics}
When designing a heuristic, we want to provide an estimate
of the total plan cost or makespan
that is as precise as possible, which
will help guide the search to a goal state as quickly as
possible.
We will now describe several heuristics for sequential
Transport using the state-variable representation.
In the following, the value of the $\mt{target(p)}$ function represents
the target location of a package $p$ in the set of packages $P$.
\subsubsection{Trivially admissible Transport heuristic}\label{sfa0}
The simplest domain-specific heuristic (apart from the zero heuristic $h_0 \equiv 0$) that is applicable to all variants of Transport
is one that counts the minimum number of \pickup{} and \drop{} actions
necessary to reach a goal state.
To obtain the correct count, we add 1 for each
package that is not yet at its destination (it will need to be dropped there) and another 1 for each package
that is, additionally, not in a vehicle (it will need to be picked up):
$$h'_{0}(s) = \sum_{\substack{
p \in P\\ \mt{at}(p) \neq \mt{target}(p)}} 1
+ \sum_{\substack{
p \in P\\ \mt{at}(p) \neq \mt{target}(p)\\
\mt{at}(p) \neq \mt{nil}}} 1.$$
The heuristic $h'_0$ is admissible, but it is practically unusable, as it
very poorly approximates
the cost of the optimal remaining actions to a goal state
--- recall that costs of \drive{} actions are generally much higher than the costs of \pickup{} and \drop{} actions.
\subsubsection{Package distance heuristic}\label{sfa1}
In \texttt{transport-strips}, the only thing we want is to deliver packages to their destinations. Therefore, a straightforward heuristic is one that calculates the length of a shortest
path of each package to its destination and sums the lengths for all packages.
To make the heuristic more precise, we can add the
value of $h'_0$ to it, as the \pickup{} and \drop{}
actions also have to occur in the optimal plan:
$$h_1(s) = h'_0(s) + \sum_{p \in P} \mt{spd}(location(p), target(p)),$$
where the $location: P \to L$ function,
with values in the set of all locations $L$, is defined as:
$$location(p) = \begin{cases}
\mt{at}(p), & \text{if } \mt{at}(p) \neq \mt{nil},\\
\mt{at}(\mt{in}(p)), & \text{else}.
\end{cases}$$
The location of a package is, therefore, defined
as the location it is at, or, if it is loaded in a vehicle,
the location of the vehicle.
The function $\mt{spd}: L \times L \to \N_0$ represents
the shortest path distance between the two locations.
This heuristic is definitely not optimal, meaning that there are states,
where we will need to add actions to reach a goal state with a higher total cost than the value of the heuristic in that state.
However, it is important to note, the heuristic
is not even admissible, so its value might sometimes overestimate the total cost needed.
To see why, let us consider a network with just two locations $A$ and $B$.
A vehicle of capacity 2 and two packages are located at $A$ and both packages want to be
transported to $B$. The road between $A$ and $B$ is symmetric and has length
of a 1. It is trivial to see that the optimal plan consists of two \pickup{} actions,
followed by a \drive{} and two \drop{} actions. This plan has a total cost of $2+1+2=5$,
but the heuristic would estimate that we need actions
that cost $6$.
\subsubsection{Minimum spanning tree marking heuristic}\label{sfa2}
A different extension of the $h'_0$ heuristic
is the heuristic $h_2$ defined below, based
on finding the shortest paths on a \textit{minimum spanning tree} (MST).
Using an MST calculated using the algorithm presented in \citet{Kruskal1956}, we can solve one of the largest problems with $h_1$,
namely that we count an excessive amount of \drive{} actions
for packages to their targets.
For each package, we calculate
shortest path distances only on the MST.
Also, we do not calculate any edge twice --- we mark
the edge when it is part of a used shortest path and
after marking edges of all shortest paths,
we sum the lengths of the marked edges.
In the same way as with $h_1$, we add the value of $h'_0$ to
the sum.
Do note that this heuristic is yet again inadmissible:
let the road network be a circle of $n$ locations with
roads of lengths $1, 2, \ldots, n$ assigned clockwise.
An MST on this network consists of all roads except the road
with length $n$, let us denote the road $r = (A, B) \in L^2$.
Now, assume there is a package located at $A$ with a target
location of $B$ and a vehicle also located at $A$.
The optimal plan is obviously to pick up the package at $A$,
drive along road $r$ to $B$, and drop the package there.
The plan has a cost of $n+2$. The $h_2$ heuristic's estimate
in the initial state is:
$$h_2(s_0) = 2 + \sum_{i=1}^{n-1} i = \frac{n^2}{2} - \frac{n}{2} + 2,$$
which is evidently greater than $n+2$ for $n > 3$.
\subsubsection{Package and vehicle distance heuristic}\label{sfa3}
As an extension of the package distance heuristic,
we will also add the distance of the nearest vehicle for
each package:
$$h_3(s) = h_1(s) + \sum_{p \in P} \min_{v \in V} \mt{spd}(location(p), \mt{at}(v)),$$
where $V$ is the set of all vehicles.
As follows from the inadmissibility of $h_1$, $h_3$
is also inadmissible and nonoptimal.
\subsubsection{Package or vehicle distance heuristic}\label{sfa4}
A variation on the package and distance heuristic
is one that does not sum the shortest path distances, but instead takes
the minimum.
Specifically, for each package, the minimum
is taken from the distance to its target location,
distance to the nearest vehicle,
and the distance to the nearest package:
\begin{align*}
h_4(s) = h'_0(s) + \sum_{p \in P} &\min\lbrace
\mt{spd}(location(p), target(p)),
\min_{v \in V} \mt{spd}(location(p), \mt{at}(v)),\\
&\min_{\substack{p' \in P\\p' \neq p}} \mt{spd}(location(p), location(p'))\rbrace.
\end{align*}
We will now show the admissibility of this heuristic.
\begin{thm}
The heuristic $h_4$ is admissible for sequential Transport problems.
\end{thm}
\begin{proof}
Let $s$ be a state such that $h_4(s) > h^*(s)$,
where $h^*$ is a function of the real distance to the nearest goal state.
State $s$ is not a goal state, because for all goal states $s'$
it holds that
$h_4(s') = 0 = h^*(s'),$ due to all packages being at their target locations.
Let $s_g$ be the nearest goal state to $s$.
Because $h_4(s) > h^*(s)$, there exists a finite plan $\pi$ from the initial state $s$ that ends in $s_g$,
such that the total cost of $\pi$ is equal to $h^*(s)$.
Let $h^{(p)}_4(s)$ denote the value of a package's term in the sum of $h_4(s)$,
ignoring the contribution of $h'_0$.
Let $p \in P$ be any package that is not yet at its destination,
not loaded in a vehicle, and not at a location with any other packages
(all of those have $h^{(p)}_4(s) = 0$).
In the plan $\pi$, $p$ had to be delivered.
That means a vehicle (possibly more)
had to arrive at the
package's location, pick it up, drive it somewhere else and drop it,
possibly several times.
However, any vehicle could not have arrived at $p$'s current location from a location that is closer than: $$\min\{\min_{v \in V} \mt{spd}(location(p), \mt{at}(v)),
\min_{\substack{p' \in P\\p' \neq p}} \mt{spd}(location(p), location(p'))\} \leq h^{(p)}_4(s),$$
and at least one vehicle had to arrive at the package's location.
The \pickup{} and \drop{} actions for each package have to be planned in $\pi$ as well, at least in the corresponding counts that $h'_0$ adds.
This means, that $\pi$ had to have actions that correspond at least to the costs of:
$$h'_0(s) + \sum_{p \in P} h_4^{(p)}(s) = h_4(s),$$
which implies $h_4(s) \leq cost(\pi) = h^*(s),$ and that is a contradiction.
\end{proof}
Despite its admissibility, the $h_4$ heuristic is not consistent. Let us assume the following road network (Figure~\ref{fig:heursit}):
$$\{\{A, B, 1\}, \{B, C, 2\}, \{B, D, 2\}\},$$
where $\mt{at}(v) = A$, $\mt{at}(p_1) = C,$ and $\mt{at}(p_2) = D$
hold in the initial state $s_0$.
The target of $p_1$ is $D$ and the target of $p_2$ is $C$.
The value:
$$h_4(s_0) = 3+3+4 = 10$$ is greater than the cost
of the applicable \drive{} action for vehicle $v$ from $A$ to $B$
added to the heuristic value in the updated state:
$$cost(a) + h_4(s') = 1 + (2+2+4) = 9.$$
The heuristic is also not optimal, as is evident from the same
example situation (for $s_0$, the optimal plan is of length $13$).
\begin{figure}[b]
\centering
\begin{subfigure}{0.48\textwidth}
\centering
\includegraphics[width=0.75\textwidth]{../imga/heursit}
\caption{Counterexample for $h_4$.}
\label{fig:heursit}
\end{subfigure}
\begin{subfigure}{0.48\textwidth}
\centering
\includegraphics[width=0.75\textwidth]{../imga/heursit_h5}
\caption{Counterexample for $h_5$.}
\label{fig:heursit_h5}
\end{subfigure}
\caption{Visualization of the counterexample road networks
for consistency of heuristics $h_4$ and $h_5$.}
\label{fig:heursits}
\end{figure}
\subsubsection{General marking heuristic}\label{sfa5}
The heuristic $h_5$ is a generalization of the MST marking heuristic $h_2$. We calculate $h_5$ in the exact same way by marking roads,
except for
using an MST --- instead, the whole graph is used.
We also mark roads on the shortest path from each package to the nearest
vehicle or package or target location, depending on which is nearer (similar
to the package or vehicle distance heuristic).
Shortest path ties are broken arbitrarily.
Do note that if a package is loaded in a vehicle, no roads are marked for it.
The described heuristic is not optimal, but it is admissible.
Both properties hold because $\forall s \in S : h_5(s) \leq h_4(s)$ holds
and they hold for $h_4$.
Even though $h_5$ is consistent in far more situations (combinations of states and applicable actions) than $h_4$, it is still not consistent in general.
Assume the following road network (Figure~\ref{fig:heursit_h5}):
$$\{\{A, B, 1\}, \{A, C, 1\}, \{A, D, 1\}, \{B, C, 2\}, \{B, E, 10\}, \{C, D, 2\}, \{D, E, 10\}\},$$
where $\mt{at}(v) = C$, $\mt{at}(p_1) = B,$ and $\mt{at}(p_2) = D$
hold in the initial state $s_0$.
The target of both $p_1$ and $p_2$ is $E$.
If the heuristic selects the red edges for $s_0$, the value:
$$h_5(s_0) = 2+2+4 = 8$$ is greater than the cost
of the applicable \drive{} action for vehicle $v$ from $C$ to $A$
added to the heuristic value in the updated state (assuming selection of blue edges):
$$cost(a) + h_5(s') = 1 + (1+1+4) = 7.$$
Note that the $h_5$ heuristic could have likewise selected the blue edges along
with the $\{A, C, 1\}$ edge, which would have resulted in $h_5(s_0) = 7,$
and this case would not be a counterexample. This points to the possibility that th $h_5$ heuristic will work reasonably ``consistenly'' in practice.
\subsubsection{Summary}
In our tests, we found that
the heuristics $h_0$, $h'_0$, $h_1$, and $h_2$
were too simple for practical usage.
The $h_3$ heuristic, while having no significant
theoretical properties performs surprisingly well in practice.
The $h_4$ heuristic on the other hand, while being admissible, does not
perform well empirically.
Due to its closeness to consistency, the $h_5$ heuristic has the best properties out of all the discussed heuristics and also
performs well in practice.
We will include planners utilizing the $h_3$ and $h_5$ heuristics
in our final evaluation (Chapter~\ref{experiments}).
\subsection{Sequential Forward A*}\label{sfa}
\textit{Sequential Forward A$^{\kern-.05em*}$} (SFA) is a planner for sequential Transport based on forward search using A$^{\kern-.15em*}$ (Figure~\ref{alg:astar}).
It utilizes most of the domain knowledge described
in Section~\ref{domain-info} and~\ref{datasets}
to prune the search space as much as possible
without sacrificing admissibility.
However, domain knowledge alone does not
prune away enough search space to
generate plans efficiently.
With the addition of
heuristics
from Section~\ref{seq-heuristics},
implementations of the planner become reasonably useful
on practical problems, as will be demonstrated
later during experimental evaluation.
To limit memory usage, we add an if statement to line 17 of the algorithm
(Figure~\ref{alg:astar}),
which checks if the open set is larger than a given hyperparameter.
If it is, it removes the state with the largest $f$ value in the open set,
making room for the addition of the new state. In our experiments,
the hyperparameter is always set to 800 000.
A variant of SFA,
\textit{Weighted Sequential Forward A$^{\kern-.05em*}$} (WSFA)
swaps A$^{\kern-.15em*}$ search for Weighted A$^{\kern-.15em*}$ in the SFA planner.
\subsection{Meta-heuristically weighted SFA*}\label{msfa}
\textit{Meta-heuristically weighted SFA$^{\kern-.05em*}$} (MSFA) is
a meta-planner built on top of a WSFA planner with
a given heuristic.
Given two hyperparameters $\alpha \in [0, 1]$ and $w_0 \in [1, \infty)$,
it runs the WSFA planner with the weight $w \gets w_0$,
waits for the planner to find a plan,
and then (exponentially) decays the
weight of the heuristic function
with a minimum at 1: $$w \gets \max(1, \floor*{\alpha \cdot w}).$$
Do note that this is followed up by a complete restart of the internal WSFA planner.
If only a recalculation of values in the $f$ map
of forward search with A$^{\kern-.15em*}$ was done, all successive
weight runs would almost immediately return, because we are in the vincinity of a goal state,
but not necessarily the nearest one to the initial state.
In some sense, this simulates a quick DFS run followed up
by local search around the path found by DFS.
Generally, better results are obtained by reexploring the
state space from the initial state with an updated weight.
Even though this meta-planning approach breaks
admissibility guarantees, it works very well on
practical problems, even the larger ones.
\section{Ad-hoc planning}\label{ad-hoc}
An approach that domain-independent planners by definition cannot utilize
is ad-hoc planning. We propose several
ad-hoc planners that generate decent quality plans very fast,
although they are usually suboptimal.
This becomes an advantage mainly when dealing with very large
problems or time-constrained planning,
like in the agile track of IPC.
\subsection{Randomized Restart Planning}\label{rand-restart}
We will now describe a family of planners which we will refer to as \textit{Randomized Restart} planners.
Each of these planners essentially performs the same algorithm (Figure~\ref{alg:rand-restart}),
with minor tweaks. The motivation
behind the algorithm is that the ``hardest'' part of Transport planning
is choosing where to drive with what vehicle.
\myalg{Randomized Restart planning}%
{%
\Input a Transport problem in a classical representation $\mathcal{P} = (S, O, \gamma, s_0, g)$
\Output a plan $\pi$
\Function{Randomized-Restart}{$\mathcal{P}$}
\State $\pi \gets $ empty plan, $\Pi \gets \infty$
\While{cancel not requested} \Comment{Canceled by an external request}
\State $s \gets s_0$, $\pi' \gets $ empty plan
\While{$s$ doesn't satisfy $g \And score(\pi') < \Pi$}
\State $A \gets $ \Call{Generate-Drive-Sequence}{$s$}
\ForAll{action $a \in A$} \Comment{Apply all actions to the state}
\State $s \gets \gamma(s, a)$
\EndFor
\If{$s = \emptyset$} \textbf{break} \Comment{At least one $a \in A$ was not applicable}
\EndIf
\State $\pi' \gets $ append all $a \in A$ to $\pi'$
\EndWhile
\If{$s$ satisfies $g \And score(\pi') < \Pi$}
\State $\pi \gets \pi'$, $\Pi \gets score(\pi')$ \Comment{Update the best plan}
\EndIf
\EndWhile
\State \Return $\pi$
\EndFunction
}%
{A Randomized Restart planning algorithm.}{A Randomized Restart planning algorithm. The \textsc{Generate-Drive-Sequence} function
generates a partial plan beginning in state $s$.
The exact definition of the function
depends on the specific algorithm variant as described in Section~\ref{rand-restart}.}{rand-restart}{tb}
The algorithm essentially does domain-dependent plan space planning
by iteratively adding sequences of \drive{} actions
intertwined with \pickup{} and \drop{} actions
until all packages are delivered.
To do all of this at speed, the vehicle used for the given sequence
is usually chosen randomly, as are the packages that are picked up and dropped along the driving path.
The biggest advantage, however, is gained by precomputing
a matrix of shortest paths and always using those to drive to the
selected locations.
Our randomized restart planners will generate many suboptimal plans,
but by always keeping a copy of the so far best found plan,
we can prune away the current partial plan if it becomes
worse than the best plan after adding a sequence.
Afterwards, we simply restart
from the initial state and iteratively generate a new candidate plan.
We utilize domain knowledge in all the planners,
for example by not picking up packages that are at their destination,
and using most of the other insights discussed in Section~\ref{domain-info}.
\subsubsection{Randomized Restart From Location Planner}\label{rrfl}
In each iteration of the before mentioned algorithm,
the Randomized Restart From Location planner (RRFL)
randomly chooses a vehicle and a location.
It adds \drive{} actions along the shortest path
to that location and greedily picks up as many packages as
its capacity allows.
It then calculates the optimal
path through all the picked up package target locations,
by trying the shortest paths through all possible permutations
of the locations.
Finally, it adds the appropriate \drive{} and \drop{} actions.
\subsubsection{Randomized Restart On Path Planner}\label{rrop}
The Randomized Restart On Path planner (RROP),
randomly chooses a vehicle
and a package that fits into the vehicle.
It then calculates the shortest path from the vehicle
to the package
and the shortest path from the package to its target location.
Afterwards, it finds all packages that have current and target locations on the path, taking into account the direction of driving.
It then tries all combinations of
those packages that do not make the vehicle become
overcapacitated over the whole course
of the path, in order
to find the combination that maximizes the minimum
free capacity over the course of the path.
If there are several such combinations, it minimizes the
maximum package drop location index in the path.
If there are still several combinations, it chooses one arbitrarily.
Finally, it adds the appropriate \drive{} and \drop{} actions.
\subsubsection{Randomized Restart On Path Nearby Planner}\label{rropn}
The Randomized Restart On Path Nearby planner (RROPN)
is a slight modification of RROP.
It first chooses a package randomly and then,
based on a probability $\varepsilon \in [0, 1]$,
either chooses a random vehicle that the package fits into,
or the nearest such vehicle.
The rest of the algorithm is identical to RROP.
The probability $\varepsilon$ is a hyperparameter,
which in our experiments is fixed to $0.2$,
which means that the probability of selecting the nearest vehicle is 80\%.
\subsubsection{Randomized Restart Around Path Nearby Planner}\label{rrapn}
Another randomized restart planner that is built on top of RROPN,
is the Randomized Restart Around Path Nearby planner (RRAPN).
It uses the same vehicle and package selection,
but it changes the way packages on the path are chosen to be loaded
onto the vehicle.
We still load as many packages that are completely on the path
as possible, using the same selection mechanism as in RROPN.
Additionally, for each package we precalculate
the location on the path that is closest to its target,
limited to locations after the package was picked up
in the correct driving direction.
Finally, we plan the \pickup{} and \drop{} actions of the
packages that greedily fit into the vehicle and
have the smallest precalculated distance to their target.
\subsubsection{Randomized Backtrack Around Path Nearby Planner}\label{rbapn}
We also developed a backtracking variant of RRAPN
called Randomized Backtrack Around Path Nearby (RBAPN).
Instead of choosing random vehicles and packages
it backtracks over the choices it makes,
guaranteeing to find an optimal
plan in the subspace of plans
generated by adding such action sequences as described in
the section about RRAPN. This approach is very
time-consuming and not practically usable.
\subsubsection{Randomized Restart Around Path Distribution Planner}\label{rrapd}
Another variant of RRAPN, the
Randomized Restart Around Path Distribution planner (RRAPD),
changes the vehicle choice inherited from RROPN.
Instead of using a biased coin flip based on the $\varepsilon$
hyperparameter, RRAPD samples the vehicle
from a discrete probability distribution
obtained by applying the \textit{softmax} function on the inverse distances of vehicles to the selected package:
\begin{align*}
\varphi'_i &= \frac{1}{\mt{spd}(location(p), \mt{at}(v_i)) + 1},\\
\varphi_i &= \frac{\exp(\varphi'_i/T)}{\sum_{j = 1}^{|V|} \exp(\varphi'_j/T)}.
\end{align*}
The value $\varphi_i$ is the resulting probability of each vehicle $v_i \in V = \{v_1, v_2, \ldots, v_n\}$.
The hyperparameter $T \in (0, \infty)$ is the \textit{temperature}
of the softmax. If set to higher values than 1, it
evens out the distribution --- higher probabilities shrink
and smaller probabilities become larger.
As $T$ grows large, the distribution will resemble a uniform distribution.
If $T$ is set to lower values, the distribution will prefer larger values.
In our experiments, we used a fixed $T = 0.1$, to prefer the nearest vehicles.
\subsubsection{Summary}
The implementations
of RRFL, RROP, and RROPN have empirically shown
lesser performance in our tests than RRAPN and RRAPD.
RRAPD, however, performs worse than RRAPN on
average.
As mentioned previously, RBAPN is unusable on larger
problems due to catastrophic run time in practice.
We will evaluate the Nearby planner
of the Randomized Restart Around Path
kind in our experiments in Chapter~\ref{experiments},
as they produce good quality plans in a very short time
even for larger problem instances.
All planners of the Randomized Restart family
are suboptimal, not only meaning that they sometimes produce
suboptimal plans, but also that for some problems,
even the best plan they can produce will be suboptimal.
This is easiest to prove for each planner individually,
by constructing a counterexample for a corner
case of the
greedy
choices
the planners make.
\comment{
\section{Formulating Transport as a CSP}\label{csp-approach}
When discussing related works, we mentioned the Vehicle Routing Problem (Section~\ref{vrp}) and its straightforward
formulation as a Constraint Satisfaction Problem. Utilizing CSPs has been useful
for planning in the past \citep[Section~8.7]{Ghallab2004}
and we will attempt to use domain-specific knowledge to improve upon the standard, domain-independent
formulation.
\subsection{Na{\"{i}}ve CSP formulation}
We will now formulate a sequential Transport (Section~\ref{transport-strips}) problem as a CSP (Section~\ref{csp}) using the na{\"{i}}ve encoding provided in \citet[Section~8.3]{Ghallab2004}.
TODO{explain the model + constraints}
However, using that strategy, our problems ``blow up'' in size --- as is expected due
to the different complexities of planning versus solving CSPs \citep[Section~8.3.2]{Ghallab2004}. To visualize the difference in our case, we have constructed a state space estimation table (Table~\ref{tab:csp-trivial}) for conversions of two sample sequential Transport problems.
TODO{recalculate + verify numbers}
\begin{table}[tb]
\begin{center}
\begin{tabular}{l||rr}
\textbf{Features / estimates} & \textbf{p01} & \textbf{p20} \\
\midrule
\midrule
\textbf{Best-known plan length} & 6 & 351 \\
\textbf{Vehicles} & 2 & 4 \\
\textbf{Vehicle variables} & 14 & 1 408 \\
\textbf{Packages} & 2 & 20 \\
\textbf{Package variables} & 14 & 7 040 \\
\textbf{Locations} & 5 & 60 \\
\textbf{Roads} & 12 & 256 \\
\textbf{Max capacity} & 4 & 4 \\
\midrule
\textbf{Ground Drive actions} & 168 & 360 448 \\
\textbf{Ground PickUp actions} & 140 & 1 689 600 \\
\textbf{Ground Drop actions} & 140 & 1 689 600 \\
\midrule
\textbf{Planning variables total} & 48 & 10 207 \\
\textbf{Grounded actions total} & 448 & 1 189 838 848 \\
\textbf{Search Space Estimate} & $\approx 1.1 \cdot 10^{52}$ & $\approx 1.4 \cdot 10^{27 952}$ \\ % https://www.wolframalpha.com/input/?i=(245120%5E351)+*+4%5E1408+*+60%5E1408+*+1468%5E7040
\end{tabular}
\end{center}
\caption[Search space approximations for a na{\"{i}}ve CSP encoding.]{CSP Search space approximations for the \textit{p01} and \textit{p20} problems from the \textit{seq-sat} track of IPC 2008, using the general and domain-independent encoding from \citet[Section~8.3]{Ghallab2004}.}
\label{tab:csp-trivial}
\end{table}
The first section of the table (rows 1--7) contains problem-specific constants.
The two calculated values in that section, \textit{Vehicle variables} and \textit{Package variables} are the numbers of variables generated for the respective
object by grounding it for every intermediate plan state (before and after applying an action). Therefore, the value is equal to the number of vehicles/packages of the problem
multiplied by the set plan length + 1 (each state corresponds to the state before applying an action + the last state).
In the second section (rows 8--10), we estimate the number of ground actions
Step 1 from \citet[Section~8.3.1]{Ghallab2004} will generate.
We calculate the number of \pickup{} and \drop{} actions the CSP encoding will generate
as $$(\mt{length(plan)} + 1) \cdot \mt{\#vehicles} \cdot \mt{\#locations} \cdot \mt{\#packages},$$
effectively counting all ground planning operators of the problem. Similarly,
the number of \drive{} actions is calculated as
$$(\mt{length(plan)} + 1) \cdot \mt{\#vehicles} \cdot \mt{\#roads},$$
which is more efficient than the na{\"{i}}ve way of
counting all
$$(\mt{length(plan)} + 1) \cdot \mt{\#vehicles} \cdot \mt{\#locations}^2$$
actions.
As we can see from the third section of the table, the number of variables
(planning variables and ground actions) is not extremely high
--- the problem is that the variables have very large domains,
which makes the CSP problem exponentially larger \citep[Section~8.3.2]{Ghallab2004}.
We calculated the \textit{Search Space Size Estimate} (SSE) as
\begin{align*}
\mt{SSE} =\; &\mt{\#ground\_actions}^{l-1} & \textit{\footnotesize select ground actions for the plan}\\
&\cdot \mt{\#capacities}^{l \cdot \mt{\#vehicles}} & \textit{\footnotesize select capacities for vehicle variables}\\
&\cdot \mt{\#locations}^{l \cdot \mt{\#vehicles}} & \textit{\footnotesize select locations for vehicle variables}\\
&\cdot (\mt{\#locations} + \mt{\#vehicles})^{l \cdot \mt{\#pkg}}, & \textit{\footnotesize select locations/vehicles for package variables}
\end{align*}
where we set $l := \mt{length(plan) + 1}$.
For comparison to the SSEs in the last table row,
the estimated number of atoms in the universe is generally estimated to be about $4 \cdot 10^{80}$.
\subsection{Domain-dependent CSP representation}\label{csp-custom-repr}
We will now devise a different CSP representation for sequential Transport.
While not improving upon the search space estimates of the na{\"{i}}ve formulation
in a theoretical sense, we will describe a slightly more complex
and less general
CSP model that enables us to explore fewer states.
Using OptaPlanner and its shadow variable concept \citep[Section~4.3.6]{DeSmet2017}, we will model our Transport problem without keeping explicit track of capacities,
vehicle and package locations, and ground actions, all of which will be implicitly managed by OptaPlanner, or inferred in the case of capacity and actions.
This means we will reduce the memory overhead, maintaining the same expressive power
and hopefully not enlarge the processing time too much.
TODO{Describe the specific representation after it is polished in the code}
TODO{recalculate + verify numbers}
\begin{table}[tb]
\begin{center}
\begin{tabular}{l||rr}
\textbf{Features / estimates} & \textbf{p01} & \textbf{p20} \\
\midrule
\midrule
\textbf{Best-known plan length} & 6 & 351 \\
\textbf{Vehicles} & 2 & 4 \\
\textbf{Vehicle shadow vars} & 14 & 1 408 \\
\textbf{Packages} & 2 & 20 \\
\textbf{Package shadow vars} & 14 & 7 040 \\
\textbf{Locations} & 5 & 60 \\
\textbf{Roads} & 12 & 256 \\
\textbf{Max capacity} & 4 & 4 \\
\midrule
\textbf{Ground Drive actions} & 24 & 1024 \\
\textbf{Ground PickUp actions} & 20 & 4800 \\
\textbf{Ground Drop actions} & 20 & 4800 \\
\midrule
\textbf{Planning variables total} & 48 & 10 207 \\
\textbf{Grounded actions in step} & 64 & 10 624 \\
\textbf{Action type orderings} & 2 187 & $\approx 8.8 \cdot 10^{167}$ \\
\textbf{Search Space Estimate} & $\approx 1.5 \cdot 10^{14}$ & $\approx 2.0 \cdot 10^{637}$ \\
\end{tabular}
\end{center}
\caption[Search space approximations for a domain-dependent CSP representation.]{CSP Search space approximations for the \textit{p01} and \textit{p20} problems from the \textit{seq-sat} track of IPC 2008, using a custom domain-dependent CSP representation for Transport sequential.}
\label{tab:csp-custom}
\end{table}
Using the domain-dependent representation specified, we are now able to construct
a search space estimate table for the same Transport problems (Table~\ref{tab:csp-custom}).
Do note, that this table cannot be compared directly to the previous one,
because it hides the shadow variable management overhead.
Also, while the table rows look similar, sections 2 and 3 are calculated
differently. The ground action counts in section 2 are not multiplied by $\mt{length(plan)} + 1$
as done previously, because we only represent them once, not at every plan state.
The total number of grounded actions is the same, but they are not explicitly represented as variables. The Search Space size Estimate is therefore calculated differently:
\begin{align*}
\mt{SSE} =\; &3^{\mt{length(plan)} + 1} & \textit{\footnotesize select the action type of each action}\\
&\cdot \mt{\#ground\_actions}^{l-1}. & \textit{\footnotesize select the specific ground action}
\end{align*}
For comparison to the na{\"{i}}ve encoding SSEs which going from the p01 problem to p20 grow by a logarithmic factor of approximately $538$,
whereas the domain-dependent ones only grow by approximately $46$,
which is a huge improvement.
Given the search space reduction, we will now attempt to use this representation
for constructing a CSP-based planner.
\subsection{CSP-based planner}\label{csp-planner}
TODO{try to run a CSP in OptaPlanner to solve this and compare results, using Section~\ref{csp-custom-repr}}
TODO{Advantages and shortcommings of a CSP-based planner}
} |
module Control.Comonad.Traced.Traced
import Control.Comonad
import Control.Comonad.Trans
import Control.Monad.Identity
%default total
public export
record TracedT (m : Type) (w : Type -> Type) (a : Type) where
constructor MkTracedT
runTracedT : w (m -> a)
public export
Traced : (m : Type) -> (a : Type) -> Type
Traced m = TracedT m Identity
public export %inline
traced : (m -> a) -> Traced m a
traced f = MkTracedT (Id f)
public export %inline
runTraced : Traced m a -> m -> a
runTraced (MkTracedT (Id f)) = f
--------------------------------------------------------------------------------
-- Utilities
--------------------------------------------------------------------------------
public export %inline
listen : Functor w => TracedT m w a -> TracedT m w (a, m)
listen = record { runTracedT $= map (\f,m => (f m, m)) }
public export %inline
listens : Functor w => (m -> b) -> TracedT m w a -> TracedT m w (a, b)
listens g = record { runTracedT $= map (\f,m => (f m, g m)) }
public export %inline
censor : Functor w => (m -> m) -> TracedT m w a -> TracedT m w a
censor g = record { runTracedT $= map (. g) }
--------------------------------------------------------------------------------
-- Interface Implementations
--------------------------------------------------------------------------------
appEnv : (s -> a -> b) -> (s -> a) -> s -> b
appEnv ff fa s = ff s (fa s)
public export %inline
Functor w => Functor (TracedT m w) where
map f = record { runTracedT $= map (f .) }
public export %inline
Applicative w => Applicative (TracedT m w) where
pure = MkTracedT . pure . const
MkTracedT wf <*> MkTracedT wa = MkTracedT (map appEnv wf <*> wa)
public export %inline
(Comonad w, Monoid m) => Comonad (TracedT m w) where
extract (MkTracedT wf) = extract wf neutral
extend f =
record { runTracedT $= extend (\w,m => f (MkTracedT $ map (. (<+> m)) w)) }
public export %inline
(ComonadApply w, Monoid m) => ComonadApply (TracedT m w) where
MkTracedT wf <@> MkTracedT wa = MkTracedT (map appEnv wf <@> wa)
public export %inline
Monoid m => ComonadTrans (TracedT m) where
lower = map ($ neutral) . runTracedT
|
function example2 ( )
%*****************************************************************************80
%
%% EXAMPLE2 demonstrates the use of PDEPE on a scalar PDE.
%
% Discussion:
%
% Solve the convection-diffusion equation.
%
% PDE:
% ut + (a(x)*u)x = uxx
% BC:
% u(t,-oo) = 0, u(t,+oo) = 0
% IC:
% u(0,x) = 1 / (1+(x-5)^2)
%
% Here, the quantity a(x) is a bit complicated. It is defined by
% a(x) = 3 (ubar(x))^2 + 2 * ubar(x)
% where ubar is defined implicitly by the nonlinear equation
% 1/ubar + log ( abs ( (1-ubar)/ubar ) ) = x
%
% Ubar(x) is the equilibrium solution to the conservation law
% ut + (u^3-u^2)x = uxx.
%
% Although the mathematical problem has boundary conditions at infinity,
% we approximate this by the interval [-50,+50].
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 August 2013
%
% Author:
%
% Original formulation by P Howard, 2005.
% This version by John Burkardt
%
timestamp ( );
fprintf ( 1, '\n' );
fprintf ( 1, 'EXAMPLE2:\n' );
fprintf ( 1, ' The convection-diffusion equation.\n' );
fprintf ( 1, ' ut + (a(x)*u)x = uxx\n' );
fprintf ( 1, ' u(t,-oo) = 0, u(t,+oo) = 0\n' );
fprintf ( 1, ' u(0,x) = 1 / (1+(x-5)^2)\n' );
%
% M defines the coordinate system:
% 0: cartesian
% 1: cylindrical
% 2: spherical
%
m = 0;
%
% Define the spatial mesh.
%
nx = 201;
xmesh = linspace ( -50.0, +50.0, nx );
%
% Define the time mesh.
%
nt = 101;
tspan = linspace ( 0.0, 10.0, nt );
%
% Call PDEPE() for the solution.
%
sol = pdepe ( m, @pdefun, @icfun, @bcfun, xmesh, tspan );
%
% Even though our solution is "really" a 2D array, PDEPE stores it
% in a 3D array SOL(:,:,:). The surf() command needs a 2D array to plot,
% so let's copy U out of SOL.
%
u = sol(:,:,1);
figure ( 1 )
surf ( xmesh, tspan, u, 'EdgeColor', 'None' );
title ( 'Example 2: Solution Over Time', 'Fontsize', 16 );
xlabel ( '<--- X --->' )
ylabel ( '<--- T --->' );
zlabel ( '<---U(X,T)--->' );
filename = 'example2.png';
print ( '-dpng', filename );
fprintf ( 1, '\n' );
fprintf ( 1, ' Saved solution plot in file "%s"\n', filename );
%
% Plot the initial condition, U at time 0.
%
figure ( 2 )
plot ( xmesh, u(1,:), 'LineWidth', 3 );
grid on
title ( 'Example 2: Initial Condition', 'Fontsize', 16 );
xlabel ( '<--- X --->' )
ylabel ( '<--- U(X,T0) --->' );
filename = 'example2_ic.png';
print ( '-dpng', filename );
fprintf ( 1, ' Saved initial condition plot in file "%s"\n', filename );
%
% Plot the solution U at a fixed point, with time varying.
%
figure ( 3 )
mid = 1 + floor ( 55 * ( nx - 1 ) / 100 );
plot ( tspan, u(:,mid), 'LineWidth', 3 );
grid on
title ( 'Example 2: Time evolution of solution at X=5.0', 'Fontsize', 16 );
xlabel ( '<--- T --->' )
ylabel ( '<--- U(5.0,T) --->' );
filename = 'example2_profile.png';
print ( '-dpng', filename );
fprintf ( 1, ' Saved time evolution plot in file "%s"\n', filename );
%
% Animate the profile.
% I wish I could also display the running value of time, but it
% does not seem possible.
%
figure ( 4 )
fig = plot ( xmesh, u(1,:), 'erase', 'xor' );
title ( 'Profile animation', 'Fontsize', 16 );
grid on
for k = 2 : length ( tspan )
set ( fig, 'xdata', xmesh, 'ydata', u(k,:) );
pause ( 0.4 );
end
%
% Terminate.
%
fprintf ( 1, '\n' );
fprintf ( 1, 'EXAMPLE2:\n' );
fprintf ( 1, ' Normal end of execution.\n' );
fprintf ( 1, '\n' );
timestamp ( );
return
end
function value = degwave ( x )
%*****************************************************************************80
%
%% DEGWAVE determines the value of UBAR in the equation.
%
% Discussion:
%
% MATLAB's zero finder "fzero()" must be called in order to determine
% the value of UBAR.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 August 2013
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real X, the spatial location.
%
% Output, real VALUE, the value of A(X).
%
if ( x < -35.0 )
value = 1.0;
elseif ( 2.0 < x )
guess = 1.0 / x;
value = fzero ( @f, guess, [], x );
elseif ( -2.5 < x )
guess = 0.6;
value = fzero ( @f, guess, [], x );
else
guess = 1.0 - exp ( - 2.0 ) * exp ( x );
value = fzero ( @f, guess, [], x );
end
return
end
function value = f ( u, x )
%*****************************************************************************80
%
%% F evaluates a function, which should be zero if U = UBAR.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 August 2013
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real U, the estimated solution value at X.
%
% Input, real X, the spatial location.
%
% Output, real VALUE, the function value.
%
value = ( 1.0 / u ) + log ( ( 1.0 - u ) / u ) - x;
return
end
function [ c, f, s ] = pdefun ( x, t, u, dudx )
%*****************************************************************************80
%
%% PDEFUN defines the components of the PDE.
%
% Discussion:
%
% The PDE has the form:
%
% c * du/dt = x^(-m) d/dx ( x^m f ) + s
%
% where m is 0, 1 or 2,
% c, f and s are functions of x, t, u, and dudx,
% and most typically, f = dudx.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 August 2013
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real X, the spatial location.
%
% Input, real T, the current time.
%
% Input, real U(:,1), the estimated solution at T and X.
%
% Input, real DUDX(:,1), the estimated spatial derivative of U at T and X.
%
% Output, real C(:,1), the coefficients of du/dt.
%
% Output, real F(:,1), the flux terms.
%
% Output, real S(:,1), the source terms.
%
c = 1.0;
ubar = degwave ( x );
f = dudx - ( 3.0 * ubar.^2 - 2.0 * ubar ) * u;
s = 0.0;
return
end
function u0 = icfun ( x )
%*****************************************************************************80
%
%% ICFUN defines the initial conditions.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 August 2013
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real X, the spatial location.
%
% Output, real U0(:,1), the value of the solution at the initial time,
% and location X.
%
u0 = 1.0 / ( 1.0 + ( x - 5.0 ).^2 );
return
end
function [ pl, ql, pr, qr ] = bcfun ( xl, ul, xr, ur, t )
%*****************************************************************************80
%
%% BCFUN defines the boundary conditions.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 August 2013
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real XL, the spatial coordinate of the left boundary.
%
% Input, real UL(:,1), the solution estimate at the left boundary.
%
% Input, real XR, the spatial coordinate of the right boundary.
%
% Input, real UR(:,1), the solution estimate at the right boundary.
%
% Output, real PL(:,1), the Dirichlet portion of the left boundary condition.
%
% Output, real QL(:,1), the coefficient of the flux portion of the left
% boundary condition.
%
% Output, real PR(:,1), the Dirichlet portion of the right boundary condition.
%
% Output, real QR(:,1), the coefficient of the flux portion of the right
% boundary condition.
%
pl = ul;
ql = 0.0;
pr = ur;
qr = 0.0;
return
end
function timestamp ( )
%*****************************************************************************80
%
%% TIMESTAMP prints the current YMDHMS date as a timestamp.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 14 February 2003
%
% Author:
%
% John Burkardt
%
t = now;
c = datevec ( t );
s = datestr ( c, 0 );
fprintf ( 1, '%s\n', s );
return
end
|
State Before: m✝ n : ℕ
i : Fin (n + 1)
m : Fin n
h : i ≤ ↑Fin.castSucc m
⊢ ↑(finSuccEquiv' i) (Fin.succ m) = some m State After: no goals Tactic: rw [← Fin.succAbove_above _ _ h, finSuccEquiv'_succAbove] |
"I made this randomly and it was delicious."
Meet the perfect weeknight one-pot chicken dinner.
This is a very 'basic' recipe to start out with, but it needs a lot more herbs in it, in order to make it tasty. Chop up and add in some fresh Parsley, Thyme, Rosemary and Sage.
Extremely simple and my family loved it too. I would recommend pounding the chicken flat in order to get uniform thickness for cook time.
I've been making this all week for my dinner! So good! And easy too! It has perfect flavor (not too overpowering), with a moist tender inside and a crisp garlic crust. |
lemma residue_holomorphic_over_power': assumes "open A" "0 \<in> A" "f holomorphic_on A" shows "residue (\<lambda>z. f z / z ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" |
lemmas coeff_pCons = pCons.rep_eq |
## This is wrapper around the BEA API
bea_api <- function(api_key_bea, dataname, frequency, table_ids, destfile) {
UserID <- rep(api_key_bea, length(table_ids))
Method <- rep('GetData', length(table_ids))
datasetname <- rep(dataname, length(table_ids))
Frequency <- rep(frequency, length(table_ids))
TableName <- table_ids
Year <- rep('X', length(table_ids)) # all years selected
ResultFormat<- rep("json", length(table_ids))
params <- list(
UserID = UserID,
Method = Method,
datasetname = datasetname,
Frequency = Frequency,
TableName = TableName,
Year = Year,
ResultFormat = ResultFormat
)
df <- purrr::pmap_dfr(
.l = params,
.f = ~ beaGet(list('UserID' = ..1, 'Method' = ..2, 'datasetname' = ..3,
'Frequency' = ..4, 'TableName' = ..5, 'Year' = ..6,
'ResultFormat' = ..7), asTable = TRUE, asWide = FALSE)
)
saveRDS(df, file = destfile)
}
# Simple example:
# beaGet( list('UserID' = "BC707C2A-6523-4AF8-8346-70E4AB34E9E5",
# 'Method' = 'GetData',
# 'datasetname' = 'NIPA',
# 'Frequency' = 'A',
# 'TableName' = 'T60200A',
# 'Year' = 'X',
# 'ResultFormat' = 'json'), asTable = TRUE, asWide = FALSE)
|
'''
Calculates the soil temperature profile for a 24 hour period given an average and change of
temperature and soil depth
Course: PSC 6500 - Environmental Physics of Land Ecosystems and Climate
Created: March 2017
Last edit: September 12th, 2018 (added docstrings)
@author: miksch
'''
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
class Profile(object):
'''
Creates soil temperature profile through depth and time
Inputs:
t : range of times (in hours) e.g. [0.,24.]
z : range of soil depths (in meters) e.g. [0.,0.3]
Tavg : Average temperature at surface
T0 : Amplitude of temperature change at surface
K : Thermal diffusivity of soil
p : Period of time (24 hours)
Internal functions:
create_series
temp_profile
Properties:
z_profile : profile of depths
t_profile : profile of soil temperatures
x : x-coordinates for plotting
y : y-coordinates for plotting
'''
def __init__(self,t,z,Tavg,T0,K,p):
self.ts = Profile.create_series(self,t)
self.z_profile = Profile.create_series(self,z)
self.t_profile = Profile.temp_profile(self,self.ts,self.z_profile,Tavg,T0,K,p)
self.x, self.y = np.meshgrid(self.ts,self.z_profile)
#Create np.array to calculate t profile and grid for plotting
def create_series(self,rnge):
series = np.linspace(rnge[0],rnge[1],num=500)
return series
#Calculates 2d np.array of temperatures
def temp_profile(self,ts,z_prof,Tavg,T0,K,p):
w = (2*np.pi)/(p*3600)
D = np.sqrt((2*K)/w)
#correct ts and z_prof to make proper 2d graph
ts.shape = (1,len(ts))
z_prof.shape = (len(z_prof),1)
#calculate profile
t_prof = Tavg + T0*np.exp(-z_prof/D)*np.sin(w*ts*3600-z_prof/D)
return t_prof
def subplots(ax,K_curve,K):
ax.set_xlabel('Time [hour]')
ax.set_xlim(0,24)
ax.set_ylabel('Depth [m]')
ax.set_ylim(0,.3)
ax.set_zlabel('Temperature [deg C]')
ax.set_zlim(0,25)
#manually set contour interval
cont_int_y = np.linspace(K_curve.y[0,0],K_curve.y[-1,-1],10)
#cont_int_z = np.linspace(K_curve.t_profile.min(),K_curve.t_profile.max(),10)
ax.plot_surface(K_curve.x, K_curve.y, K_curve.t_profile,
cmap=cm.coolwarm,linewidth=0,alpha=.8)
ax.contour(K_curve.x, K_curve.y, K_curve.t_profile, 10, zdir='z', offset=-.3, cmap=cm.coolwarm)
ax.contour(K_curve.x, K_curve.y, K_curve.t_profile, cont_int_y, zdir='y', offset=.3, cmap=cm.viridis_r)
ax.set_title('Temperature Profile: K='+str(K))
def main():
#CONSTANTS
#Thermal diffusivity values [m^2s^-1]
K1 = 2.0e-7
K2 = 8.0e-7
#period [Hours]
p = 24.
#Temperature values [C]
Tavg = 15.
T0 = 10.
#Time and Z profile ranges [Hours], [m]
t = [0.,24.]
z = [0.,.3]
K1_curve = Profile(t,z,Tavg,T0,K1,p)
K2_curve = Profile(t,z,Tavg,T0,K2,p)
fig = plt.figure(figsize=(10,5))
ax1 = fig.add_subplot(121,projection='3d')
subplots(ax1,K1_curve,K1)
ax2 = fig.add_subplot(122,projection='3d')
subplots(ax2,K2_curve,K2)
plt.savefig('soil_profiles.png')
if __name__ == main():
main()
|
State Before: E : Type u_1
ι : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℂ E
inst✝ : CompleteSpace E
U K : Set ℂ
z : ℂ
M r δ : ℝ
φ : Filter ι
F : ι → ℂ → E
f g : ℂ → E
hf : TendstoLocallyUniformlyOn F f φ U
hF : ∀ᶠ (n : ι) in φ, DifferentiableOn ℂ (F n) U
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
⊢ ∃ δ, δ > 0 ∧ cthickening δ K ⊆ U ∧ TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K State After: case intro.intro
E : Type u_1
ι : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℂ E
inst✝ : CompleteSpace E
U K : Set ℂ
z : ℂ
M r δ✝ : ℝ
φ : Filter ι
F : ι → ℂ → E
f g : ℂ → E
hf : TendstoLocallyUniformlyOn F f φ U
hF : ∀ᶠ (n : ι) in φ, DifferentiableOn ℂ (F n) U
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
δ : ℝ
hδ : 0 < δ
hKδ : cthickening δ K ⊆ U
⊢ ∃ δ, δ > 0 ∧ cthickening δ K ⊆ U ∧ TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K Tactic: obtain ⟨δ, hδ, hKδ⟩ := hK.exists_cthickening_subset_open hU hKU State Before: case intro.intro
E : Type u_1
ι : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℂ E
inst✝ : CompleteSpace E
U K : Set ℂ
z : ℂ
M r δ✝ : ℝ
φ : Filter ι
F : ι → ℂ → E
f g : ℂ → E
hf : TendstoLocallyUniformlyOn F f φ U
hF : ∀ᶠ (n : ι) in φ, DifferentiableOn ℂ (F n) U
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
δ : ℝ
hδ : 0 < δ
hKδ : cthickening δ K ⊆ U
⊢ ∃ δ, δ > 0 ∧ cthickening δ K ⊆ U ∧ TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K State After: no goals Tactic: exact ⟨δ, hδ, hKδ, tendstoUniformlyOn_deriv_of_cthickening_subset hf hF hδ hK hU hKδ⟩ |
/-
Copyright (c) 2022 Stuart Presnell. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stuart Presnell, Eric Wieser, Yaël Dillies, Patrick Massot, Scott Morrison
! This file was ported from Lean 3 source module data.set.intervals.instances
! leanprover-community/mathlib commit d012cd09a9b256d870751284dd6a29882b0be105
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Algebra.GroupPower.Order
import Mathlib.Algebra.Ring.Regular
/-!
# Algebraic instances for unit intervals
For suitably structured underlying type `α`, we exhibit the structure of
the unit intervals (`Set.Icc`, `Set.Ioc`, `Set.Ioc`, and `Set.Ioo`) from `0` to `1`.
Note: Instances for the interval `Ici 0` are dealt with in `Algebra/Order/Nonneg.lean`.
## Main definitions
The strongest typeclass provided on each interval is:
* `Set.Icc.cancelCommMonoidWithZero`
* `Set.Ico.commSemigroup`
* `Set.Ioc.commMonoid`
* `Set.Ioo.commSemigroup`
## TODO
* algebraic instances for intervals -1 to 1
* algebraic instances for `Ici 1`
* algebraic instances for `(Ioo (-1) 1)ᶜ`
* provide `distribNeg` instances where applicable
* prove versions of `mul_le_{left,right}` for other intervals
* prove versions of the lemmas in `Topology/UnitInterval` with `ℝ` generalized to
some arbitrary ordered semiring
-/
open Set
variable {α : Type _}
section OrderedSemiring
variable [OrderedSemiring α]
/-! ### Instances for `↥(Set.Icc 0 1)` -/
namespace Set.Icc
instance zero : Zero (Icc (0 : α) 1) where zero := ⟨0, left_mem_Icc.2 zero_le_one⟩
#align set.Icc.has_zero Set.Icc.zero
instance one : One (Icc (0 : α) 1) where one := ⟨1, right_mem_Icc.2 zero_le_one⟩
#align set.Icc.has_one Set.Icc.one
@[simp, norm_cast]
theorem coe_zero : ↑(0 : Icc (0 : α) 1) = (0 : α) :=
rfl
#align set.Icc.coe_zero Set.Icc.coe_zero
@[simp, norm_cast]
theorem coe_one : ↑(1 : Icc (0 : α) 1) = (1 : α) :=
rfl
#align set.Icc.coe_one Set.Icc.coe_one
@[simp]
theorem mk_zero (h : (0 : α) ∈ Icc (0 : α) 1) : (⟨0, h⟩ : Icc (0 : α) 1) = 0 :=
rfl
#align set.Icc.mk_zero Set.Icc.mk_zero
@[simp]
theorem mk_one (h : (1 : α) ∈ Icc (0 : α) 1) : (⟨1, h⟩ : Icc (0 : α) 1) = 1 :=
rfl
#align set.Icc.mk_one Set.Icc.mk_one
@[simp, norm_cast]
theorem coe_eq_zero {x : Icc (0 : α) 1} : (x : α) = 0 ↔ x = 0 := by
symm
exact Subtype.ext_iff
#align set.Icc.coe_eq_zero Set.Icc.coe_eq_zero
theorem coe_ne_zero {x : Icc (0 : α) 1} : (x : α) ≠ 0 ↔ x ≠ 0 :=
not_iff_not.mpr coe_eq_zero
#align set.Icc.coe_ne_zero Set.Icc.coe_ne_zero
@[simp, norm_cast]
theorem coe_eq_one {x : Icc (0 : α) 1} : (x : α) = 1 ↔ x = 1 := by
symm
exact Subtype.ext_iff
#align set.Icc.coe_eq_one Set.Icc.coe_eq_one
theorem coe_ne_one {x : Icc (0 : α) 1} : (x : α) ≠ 1 ↔ x ≠ 1 :=
not_iff_not.mpr coe_eq_one
#align set.Icc.coe_ne_one Set.Icc.coe_ne_one
theorem coe_nonneg (x : Icc (0 : α) 1) : 0 ≤ (x : α) :=
x.2.1
#align set.Icc.coe_nonneg Set.Icc.coe_nonneg
theorem coe_le_one (x : Icc (0 : α) 1) : (x : α) ≤ 1 :=
x.2.2
#align set.Icc.coe_le_one Set.Icc.coe_le_one
/-- like `coe_nonneg`, but with the inequality in `Icc (0:α) 1`. -/
theorem nonneg {t : Icc (0 : α) 1} : 0 ≤ t :=
t.2.1
#align set.Icc.nonneg Set.Icc.nonneg
/-- like `coe_le_one`, but with the inequality in `Icc (0:α) 1`. -/
theorem le_one {t : Icc (0 : α) 1} : t ≤ 1 :=
t.2.2
#align set.Icc.le_one Set.Icc.le_one
instance mul : Mul (Icc (0 : α) 1) where
mul p q := ⟨p * q, ⟨mul_nonneg p.2.1 q.2.1, mul_le_one p.2.2 q.2.1 q.2.2⟩⟩
#align set.Icc.has_mul Set.Icc.mul
instance pow : Pow (Icc (0 : α) 1) ℕ where
pow p n := ⟨p.1 ^ n, ⟨pow_nonneg p.2.1 n, pow_le_one n p.2.1 p.2.2⟩⟩
#align set.Icc.has_pow Set.Icc.pow
@[simp, norm_cast]
theorem coe_mul (x y : Icc (0 : α) 1) : ↑(x * y) = (x * y : α) :=
rfl
#align set.Icc.coe_mul Set.Icc.coe_mul
@[simp, norm_cast]
theorem coe_pow (x : Icc (0 : α) 1) (n : ℕ) : ↑(x ^ n) = ((x : α) ^ n) :=
rfl
#align set.Icc.coe_pow Set.Icc.coe_pow
theorem mul_le_left {x y : Icc (0 : α) 1} : x * y ≤ x :=
(mul_le_mul_of_nonneg_left y.2.2 x.2.1).trans_eq (mul_one _)
#align set.Icc.mul_le_left Set.Icc.mul_le_left
theorem mul_le_right {x y : Icc (0 : α) 1} : x * y ≤ y :=
(mul_le_mul_of_nonneg_right x.2.2 y.2.1).trans_eq (one_mul _)
#align set.Icc.mul_le_right Set.Icc.mul_le_right
instance monoidWithZero : MonoidWithZero (Icc (0 : α) 1) :=
Subtype.coe_injective.monoidWithZero _ coe_zero coe_one coe_mul coe_pow
#align set.Icc.monoid_with_zero Set.Icc.monoidWithZero
instance commMonoidWithZero {α : Type _} [OrderedCommSemiring α] :
CommMonoidWithZero (Icc (0 : α) 1) :=
Subtype.coe_injective.commMonoidWithZero _ coe_zero coe_one coe_mul coe_pow
#align set.Icc.comm_monoid_with_zero Set.Icc.commMonoidWithZero
instance cancelMonoidWithZero {α : Type _} [OrderedRing α] [NoZeroDivisors α] :
CancelMonoidWithZero (Icc (0 : α) 1) :=
@Function.Injective.cancelMonoidWithZero α _ NoZeroDivisors.toCancelMonoidWithZero _ _ _ _
(fun v => v.val) Subtype.coe_injective coe_zero coe_one coe_mul coe_pow
#align set.Icc.cancel_monoid_with_zero Set.Icc.cancelMonoidWithZero
instance cancelCommMonoidWithZero {α : Type _} [OrderedCommRing α] [NoZeroDivisors α] :
CancelCommMonoidWithZero (Icc (0 : α) 1) :=
@Function.Injective.cancelCommMonoidWithZero α _ NoZeroDivisors.toCancelCommMonoidWithZero _ _ _ _
(fun v => v.val) Subtype.coe_injective coe_zero coe_one coe_mul coe_pow
#align set.Icc.cancel_comm_monoid_with_zero Set.Icc.cancelCommMonoidWithZero
variable {β : Type _} [OrderedRing β]
theorem one_sub_mem {t : β} (ht : t ∈ Icc (0 : β) 1) : 1 - t ∈ Icc (0 : β) 1 := by
rw [mem_Icc] at *
exact ⟨sub_nonneg.2 ht.2, (sub_le_self_iff _).2 ht.1⟩
#align set.Icc.one_sub_mem Set.Icc.one_sub_mem
theorem mem_iff_one_sub_mem {t : β} : t ∈ Icc (0 : β) 1 ↔ 1 - t ∈ Icc (0 : β) 1 :=
⟨one_sub_mem, fun h => sub_sub_cancel 1 t ▸ one_sub_mem h⟩
#align set.Icc.mem_iff_one_sub_mem Set.Icc.mem_iff_one_sub_mem
theorem one_sub_nonneg (x : Icc (0 : β) 1) : 0 ≤ 1 - (x : β) := by simpa using x.2.2
#align set.Icc.one_sub_nonneg Set.Icc.one_sub_nonneg
theorem one_sub_le_one (x : Icc (0 : β) 1) : 1 - (x : β) ≤ 1 := by simpa using x.2.1
#align set.Icc.one_sub_le_one Set.Icc.one_sub_le_one
end Set.Icc
/-! ### Instances for `↥(Set.Ico 0 1)` -/
namespace Set.Ico
instance zero [Nontrivial α] : Zero (Ico (0 : α) 1) where zero := ⟨0, left_mem_Ico.2 zero_lt_one⟩
#align set.Ico.has_zero Set.Ico.zero
@[simp, norm_cast]
theorem coe_zero [Nontrivial α] : ↑(0 : Ico (0 : α) 1) = (0 : α) :=
rfl
#align set.Ico.coe_zero Set.Ico.coe_zero
@[simp]
theorem mk_zero [Nontrivial α] (h : (0 : α) ∈ Ico (0 : α) 1) : (⟨0, h⟩ : Ico (0 : α) 1) = 0 :=
rfl
#align set.Ico.mk_zero Set.Ico.mk_zero
@[simp, norm_cast]
theorem coe_eq_zero [Nontrivial α] {x : Ico (0 : α) 1} : (x : α) = 0 ↔ x = 0 := by
symm
exact Subtype.ext_iff
#align set.Ico.coe_eq_zero Set.Ico.coe_eq_zero
theorem coe_ne_zero [Nontrivial α] {x : Ico (0 : α) 1} : (x : α) ≠ 0 ↔ x ≠ 0 :=
not_iff_not.mpr coe_eq_zero
#align set.Ico.coe_ne_zero Set.Ico.coe_ne_zero
theorem coe_nonneg (x : Ico (0 : α) 1) : 0 ≤ (x : α) :=
x.2.1
#align set.Ico.coe_nonneg Set.Ico.coe_nonneg
theorem coe_lt_one (x : Ico (0 : α) 1) : (x : α) < 1 :=
x.2.2
#align set.Ico.coe_lt_one Set.Ico.coe_lt_one
/-- like `coe_nonneg`, but with the inequality in `Ico (0:α) 1`. -/
theorem nonneg [Nontrivial α] {t : Ico (0 : α) 1} : 0 ≤ t :=
t.2.1
#align set.Ico.nonneg Set.Ico.nonneg
instance mul : Mul (Ico (0 : α) 1) where
mul p q :=
⟨p * q, ⟨mul_nonneg p.2.1 q.2.1, mul_lt_one_of_nonneg_of_lt_one_right p.2.2.le q.2.1 q.2.2⟩⟩
#align set.Ico.has_mul Set.Ico.mul
@[simp, norm_cast]
theorem coe_mul (x y : Ico (0 : α) 1) : ↑(x * y) = (x * y : α) :=
rfl
#align set.Ico.coe_mul Set.Ico.coe_mul
instance semigroup : Semigroup (Ico (0 : α) 1) :=
Subtype.coe_injective.semigroup _ coe_mul
#align set.Ico.semigroup Set.Ico.semigroup
instance commSemigroup {α : Type _} [OrderedCommSemiring α] : CommSemigroup (Ico (0 : α) 1) :=
Subtype.coe_injective.commSemigroup _ coe_mul
#align set.Ico.comm_semigroup Set.Ico.commSemigroup
end Set.Ico
end OrderedSemiring
variable [StrictOrderedSemiring α]
/-! ### Instances for `↥(set.Ioc 0 1)` -/
namespace Set.Ioc
instance one [Nontrivial α] : One (Ioc (0 : α) 1) where one := ⟨1, ⟨zero_lt_one, le_refl 1⟩⟩
#align set.Ioc.has_one Set.Ioc.one
@[simp, norm_cast]
theorem coe_one [Nontrivial α] : ↑(1 : Ioc (0 : α) 1) = (1 : α) :=
rfl
#align set.Ioc.coe_one Set.Ioc.coe_one
@[simp]
theorem mk_one [Nontrivial α] (h : (1 : α) ∈ Ioc (0 : α) 1) : (⟨1, h⟩ : Ioc (0 : α) 1) = 1 :=
rfl
#align set.Ioc.mk_one Set.Ioc.mk_one
@[simp, norm_cast]
theorem coe_eq_one [Nontrivial α] {x : Ioc (0 : α) 1} : (x : α) = 1 ↔ x = 1 := by
symm
exact Subtype.ext_iff
#align set.Ioc.coe_eq_one Set.Ioc.coe_eq_one
theorem coe_ne_one [Nontrivial α] {x : Ioc (0 : α) 1} : (x : α) ≠ 1 ↔ x ≠ 1 :=
not_iff_not.mpr coe_eq_one
#align set.Ioc.coe_ne_one Set.Ioc.coe_ne_one
theorem coe_le_one (x : Ioc (0 : α) 1) : (x : α) ≤ 1 :=
x.2.2
#align set.Ioc.coe_le_one Set.Ioc.coe_le_one
/-- like `coe_le_one`, but with the inequality in `Ioc (0:α) 1`. -/
theorem le_one [Nontrivial α] {t : Ioc (0 : α) 1} : t ≤ 1 :=
t.2.2
#align set.Ioc.le_one Set.Ioc.le_one
instance mul : Mul (Ioc (0 : α) 1) where
mul p q := ⟨p.1 * q.1, ⟨mul_pos p.2.1 q.2.1, mul_le_one p.2.2 (le_of_lt q.2.1) q.2.2⟩⟩
#align set.Ioc.has_mul Set.Ioc.mul
instance pow : Pow (Ioc (0 : α) 1) ℕ where
pow p n := ⟨p.1 ^ n, ⟨pow_pos p.2.1 n, pow_le_one n (le_of_lt p.2.1) p.2.2⟩⟩
#align set.Ioc.has_pow Set.Ioc.pow
@[simp, norm_cast]
theorem coe_mul (x y : Ioc (0 : α) 1) : ↑(x * y) = (x * y : α) :=
rfl
#align set.Ioc.coe_mul Set.Ioc.coe_mul
@[simp, norm_cast]
theorem coe_pow (x : Ioc (0 : α) 1) (n : ℕ) : ↑(x ^ n) = ((x : α) ^ n) :=
rfl
#align set.Ioc.coe_pow Set.Ioc.coe_pow
instance semigroup : Semigroup (Ioc (0 : α) 1) :=
Subtype.coe_injective.semigroup _ coe_mul
#align set.Ioc.semigroup Set.Ioc.semigroup
instance monoid [Nontrivial α] : Monoid (Ioc (0 : α) 1) :=
Subtype.coe_injective.monoid _ coe_one coe_mul coe_pow
#align set.Ioc.monoid Set.Ioc.monoid
instance commSemigroup {α : Type _} [StrictOrderedCommSemiring α] : CommSemigroup (Ioc (0 : α) 1) :=
Subtype.coe_injective.commSemigroup _ coe_mul
#align set.Ioc.comm_semigroup Set.Ioc.commSemigroup
instance commMonoid {α : Type _} [StrictOrderedCommSemiring α] [Nontrivial α] :
CommMonoid (Ioc (0 : α) 1) :=
Subtype.coe_injective.commMonoid _ coe_one coe_mul coe_pow
#align set.Ioc.comm_monoid Set.Ioc.commMonoid
instance cancelMonoid {α : Type _} [StrictOrderedRing α] [IsDomain α] :
CancelMonoid (Ioc (0 : α) 1) :=
{ Set.Ioc.monoid with
mul_left_cancel := fun a _ _ h =>
Subtype.ext <| mul_left_cancel₀ a.prop.1.ne' <| (congr_arg Subtype.val h : _)
mul_right_cancel := fun _ b _ h =>
Subtype.ext <| mul_right_cancel₀ b.prop.1.ne' <| (congr_arg Subtype.val h : _) }
#align set.Ioc.cancel_monoid Set.Ioc.cancelMonoid
-- Porting note: This takes too long
set_option maxHeartbeats 0 in
instance cancelCommMonoid {α : Type _} [StrictOrderedCommRing α] [IsDomain α] :
CancelCommMonoid (Ioc (0 : α) 1) :=
{ Set.Ioc.cancelMonoid, Set.Ioc.commMonoid with }
#align set.Ioc.cancel_comm_monoid Set.Ioc.cancelCommMonoid
end Set.Ioc
/-! ### Instances for `↥(Set.Ioo 0 1)` -/
namespace Set.Ioo
theorem pos (x : Ioo (0 : α) 1) : 0 < (x : α) :=
x.2.1
#align set.Ioo.pos Set.Ioo.pos
theorem lt_one (x : Ioo (0 : α) 1) : (x : α) < 1 :=
x.2.2
#align set.Ioo.lt_one Set.Ioo.lt_one
instance mul : Mul (Ioo (0 : α) 1) where
mul p q :=
⟨p.1 * q.1, ⟨mul_pos p.2.1 q.2.1, mul_lt_one_of_nonneg_of_lt_one_right p.2.2.le q.2.1.le q.2.2⟩⟩
#align set.Ioo.has_mul Set.Ioo.mul
@[simp, norm_cast]
theorem coe_mul (x y : Ioo (0 : α) 1) : ↑(x * y) = (x * y : α) :=
rfl
#align set.Ioo.coe_mul Set.Ioo.coe_mul
instance semigroup : Semigroup (Ioo (0 : α) 1) :=
Subtype.coe_injective.semigroup _ coe_mul
#align set.Ioo.semigroup Set.Ioo.semigroup
instance commSemigroup {α : Type _} [StrictOrderedCommSemiring α] : CommSemigroup (Ioo (0 : α) 1) :=
Subtype.coe_injective.commSemigroup _ coe_mul
#align set.Ioo.comm_semigroup Set.Ioo.commSemigroup
variable {β : Type _} [OrderedRing β]
theorem one_sub_mem {t : β} (ht : t ∈ Ioo (0 : β) 1) : 1 - t ∈ Ioo (0 : β) 1 := by
rw [mem_Ioo] at *
refine' ⟨sub_pos.2 ht.2, _⟩
exact lt_of_le_of_ne ((sub_le_self_iff 1).2 ht.1.le) (mt sub_eq_self.mp ht.1.ne')
#align set.Ioo.one_sub_mem Set.Ioo.one_sub_mem
theorem mem_iff_one_sub_mem {t : β} : t ∈ Ioo (0 : β) 1 ↔ 1 - t ∈ Ioo (0 : β) 1 :=
⟨one_sub_mem, fun h => sub_sub_cancel 1 t ▸ one_sub_mem h⟩
#align set.Ioo.mem_iff_one_sub_mem Set.Ioo.mem_iff_one_sub_mem
theorem one_minus_pos (x : Ioo (0 : β) 1) : 0 < 1 - (x : β) := by simpa using x.2.2
#align set.Ioo.one_minus_pos Set.Ioo.one_minus_pos
theorem one_minus_lt_one (x : Ioo (0 : β) 1) : 1 - (x : β) < 1 := by simpa using x.2.1
#align set.Ioo.one_minus_lt_one Set.Ioo.one_minus_lt_one
end Set.Ioo
|
Former Lightning head coach Terry Crisp has stated publicly that Cullen was a player that stood out as something special saying “ John Cullen ... beat cancer and came back to play and helped us win . ”
|
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/scoped_ptr.hpp>
#include "EventListener.h"
#include "Keyboard.h"
#include "Pointer.h"
#include "Seat.h"
#include "TimeoutManager.h"
#include "InputFactory.h"
namespace xw = xbmc::wayland;
xbmc::InputFactory::InputFactory(IDllWaylandClient &clientLibrary,
IDllXKBCommon &xkbCommonLibrary,
struct wl_seat *seat,
IEventListener &dispatch,
ITimeoutManager &timeouts) :
m_clientLibrary(clientLibrary),
m_xkbCommonLibrary(xkbCommonLibrary),
m_pointerProcessor(dispatch, *this),
m_keyboardProcessor(dispatch, timeouts),
m_seat(new xw::Seat(clientLibrary, seat, *this))
{
}
void xbmc::InputFactory::SetXBMCSurface(struct wl_surface *s)
{
m_keyboardProcessor.SetXBMCSurface(s);
}
void xbmc::InputFactory::SetCursor(uint32_t serial,
struct wl_surface *surface,
double surfaceX,
double surfaceY)
{
m_pointer->SetCursor(serial, surface, surfaceX, surfaceY);
}
bool xbmc::InputFactory::InsertPointer(struct wl_pointer *p)
{
if (m_pointer.get())
return false;
m_pointer.reset(new xw::Pointer(m_clientLibrary,
p,
m_pointerProcessor));
return true;
}
bool xbmc::InputFactory::InsertKeyboard(struct wl_keyboard *k)
{
if (m_keyboard.get())
return false;
m_keyboard.reset(new xw::Keyboard(m_clientLibrary,
m_xkbCommonLibrary,
k,
m_keyboardProcessor));
return true;
}
void xbmc::InputFactory::RemovePointer()
{
m_pointer.reset();
}
void xbmc::InputFactory::RemoveKeyboard()
{
m_keyboard.reset();
}
|
mtcars[2:3:5, 1]
mtcars[1, 2]
mtcars[, am]
mtcars[[9]]
D$names[length(D$names)] |
pdf()
files <- dir(pattern="metrics.*csv")
s_script <- vector(mode="integer")
s_ins <- vector(mode="integer")
s_del <- vector(mode="integer")
s_up <- vector(mode="integer")
s_mov <- vector(mode="integer")
t_total <- vector(mode="integer")
for (file in files) {
d <- read.csv(file, header=T, sep=";")
length(d[[3]])
s_script <- cbind(s_script, d[[3]])
s_ins <- cbind(s_ins, d[[3]])
s_del <- cbind(s_del, d[[4]])
s_up <- cbind(s_up, d[[5]])
s_mov <- cbind(s_mov, d[[6]])
t_total <- cbind(t_total, d[[11]])
}
boxplot(s_script, main="Edit script size")
boxplot(s_ins, main="Insert actions")
boxplot(s_del, main="Delete actions")
boxplot(s_up, main="Update actions")
boxplot(s_mov, main="Move actions")
boxplot(t_total, main="Total time") |
Formal statement is: lemma csqrt_of_real_nonneg [simp]: "Im x = 0 \<Longrightarrow> Re x \<ge> 0 \<Longrightarrow> csqrt x = sqrt (Re x)" Informal statement is: If $x$ is a real number, then $\sqrt{x}$ is the square root of $x$. |
These fantastic Kiko frames are a beautiful way to display photographs and keepsakes. Their brass frames simply add to their elegance. Choose from portrait and landscape apertures or mix it up with both!
Colour: Brass (Sari tie colour varies). |
From paper and textiles to metal foil, Selvol™ Polyvinyl Alcohol is an invaluable adhesive additive or modifier.
Heat resistant, easy cleanup, and rapid setting speed, Selvol™ Polyvinyl Alcohol is an excellent emulsifying and dispersing agent.
Selvol™ Ultiloc offers high-performance flexible barrier options for a variety of packaging.
The world’s most commonly used fluid loss control additives for oil field cementing, Selvol™ Polyvinyl Alcohol and Selvol™ Premiol.
Selvol™ Polyvinyl Alcohol controls stickies, improves both dry and wet strength of paper, renders brighter paper, and improves print quality.
Better weavability, lower add-ons, decreased shed, and the best size stability, Selvol™ Polyvinyl Alcohol and Selvol™ Ultalux for textile warp sizing composition protects spun and filament yarn.
In cements, joint compounds, caulks, sealants, and so much more, Selvol™ Polyvinyl Alcohol delivers better binding power, thickening, and moisture retention to products used in construction and building.
With its unique properties, Selvol™ Polyvinyl Alcohol’s applications are endless-from detergents, seed coatings, sponges, dental adhesives, floor coatings, health and beauty, and so much more.
Selvol™ Ultalux polyvinyl alcohol cosmetic grades safely and effectively impart a range of functional attributes to hair, skin and color cosmetics formulations. |
The director 's original cut of Sholay has a different ending in which Thakur kills Gabbar , along with some additional violent scenes . Gabbar 's death scene , and the scene in which the imam 's son is killed , were cut from the film by India 's Censor Board , as was the scene in which Thakur 's family is massacred . The Censor Board was concerned about the violence , and that viewers may be influenced to violate the law by punishing people severely . Although Sippy fought to keep the scenes , eventually he had to re @-@ shoot the ending of the film , and as directed by the Censor Board , have the police arrive just before Thakur can kill Gabbar . The censored theatrical version was the only one seen by audiences for fifteen years . The original , unedited cut of the film finally came out in a British release on VHS in 1990 . Since then , Eros International has released two versions on DVD . The director 's cut of the film preserves the original full frame and is 204 minutes in length ; the censored widescreen version is 198 minutes long .
|
subsection \<open>Bottom-Up Computation\<close>
theory Bottom_Up_Computation
imports "../state_monad/Memory" "../state_monad/DP_CRelVS"
begin
fun iterate_state where
"iterate_state f [] = State_Monad.return ()" |
"iterate_state f (x # xs) = do {f x; iterate_state f xs}"
locale iterator_defs =
fixes cnt :: "'a \<Rightarrow> bool" and nxt :: "'a \<Rightarrow> 'a"
begin
definition
"iter_state f \<equiv>
wfrec
{(nxt x, x) | x. cnt x}
(\<lambda> rec x. if cnt x then do {f x; rec (nxt x)} else State_Monad.return ())"
definition
"iterator_to_list \<equiv>
wfrec {(nxt x, x) | x. cnt x} (\<lambda> rec x. if cnt x then x # rec (nxt x) else [])
"
end
locale iterator = iterator_defs +
fixes sizef :: "'a \<Rightarrow> nat"
assumes terminating:
"finite {x. cnt x}" "\<forall> x. cnt x \<longrightarrow> sizef x < sizef (nxt x)"
begin
lemma admissible:
"adm_wf
{(nxt x, x) | x. cnt x}
(\<lambda> rec x. if cnt x then do {f x; rec (nxt x)} else State_Monad.return ())"
unfolding adm_wf_def by auto
lemma wellfounded:
"wf {(nxt x, x) | x. cnt x}" (is "wf ?S")
proof -
from terminating have "acyclic ?S"
by (auto intro: acyclicI_order[where f = sizef])
moreover have "finite ?S"
using [[simproc add: finite_Collect]] terminating(1) by auto
ultimately show ?thesis
by - (rule finite_acyclic_wf)
qed
lemma iter_state_unfold:
"iter_state f x = (if cnt x then do {f x; iter_state f (nxt x)} else State_Monad.return ())"
unfolding iter_state_def by (simp add: wfrec_fixpoint[OF wellfounded admissible])
lemma iterator_to_list_unfold:
"iterator_to_list x = (if cnt x then x # iterator_to_list (nxt x) else [])"
unfolding iterator_to_list_def by (simp add: adm_wf_def wfrec_fixpoint[OF wellfounded])
lemma iter_state_iterate_state:
"iter_state f x = iterate_state f (iterator_to_list x)"
apply (induction "iterator_to_list x" arbitrary: x)
apply (simp add: iterator_to_list_unfold split: if_split_asm)
apply (simp add: iter_state_unfold)
apply (subst (asm) (3) iterator_to_list_unfold)
apply (simp split: if_split_asm)
apply (auto simp: iterator_to_list_unfold iter_state_unfold)
done
end (* Termination *)
context dp_consistency
begin
context
includes lifting_syntax
begin
lemma crel_vs_iterate_state:
"crel_vs (=) () (iterate_state f xs)" if "((=) ===>\<^sub>T R) g f"
proof (induction xs)
case Nil
then show ?case
by (simp; rule crel_vs_return_ext[unfolded Transfer.Rel_def]; simp; fail)
next
case (Cons x xs)
have unit_expand: "() = (\<lambda> a f. f a) () (\<lambda> _. ())" ..
from Cons show ?case
by simp
(rule
bind_transfer[unfolded rel_fun_def, rule_format, unfolded unit_expand]
that[unfolded rel_fun_def, rule_format] HOL.refl
)+
qed
lemma crel_vs_bind_ignore:
"crel_vs R a (do {d; b})" if "crel_vs R a b" "crel_vs S c d"
proof -
have unit_expand: "a = (\<lambda> a f. f a) () (\<lambda> _. a)" ..
show ?thesis
by (subst unit_expand)
(rule bind_transfer[unfolded rel_fun_def, rule_format, unfolded unit_expand] that)+
qed
lemma crel_vs_iterate_and_compute:
assumes "((=) ===>\<^sub>T R) g f"
shows "crel_vs R (g x) (do {iterate_state f xs; f x})"
by (rule
crel_vs_bind_ignore crel_vs_iterate_state HOL.refl
assms[unfolded rel_fun_def, rule_format] assms
)+
end (* Lifting Syntax *)
end (* DP Consistency *)
locale dp_consistency_iterator =
dp_consistency lookup update + iterator cnt nxt sizef
for lookup :: "'a \<Rightarrow> ('b, 'c option) state" and update
and cnt :: "'a \<Rightarrow> bool" and nxt and sizef
begin
lemma crel_vs_iter_and_compute:
assumes "((=) ===>\<^sub>T R) g f"
shows "crel_vs R (g x) (do {iter_state f y; f x})"
unfolding iter_state_iterate_state using crel_vs_iterate_and_compute[OF assms] .
lemma consistentDP_iter_and_compute:
assumes "consistentDP f"
shows "crel_vs (=) (dp x) (do {iter_state f y; f x})"
using assms unfolding consistentDP_def by (rule crel_vs_iter_and_compute)
end (* Consistency + Iterator *)
locale dp_consistency_iterator_empty =
dp_consistency_iterator + dp_consistency_empty
begin
lemma memoized:
"dp x = fst (run_state (do {iter_state f y; f x}) empty)" if "consistentDP f"
using consistentDP_iter_and_compute[OF that, of x y]
by (auto elim!: crel_vs_elim intro: P_empty cmem_empty)
lemma cmem_result:
"cmem (snd (run_state (do {iter_state f y; f x}) empty))" if "consistentDP f"
using consistentDP_iter_and_compute[OF that, of x y]
by (auto elim!: crel_vs_elim intro: P_empty cmem_empty)
end (* Consistency + Iterator *)
lemma dp_consistency_iterator_emptyI:
"dp_consistency_iterator_empty P lookup update cnt
nxt sizef empty"
if "dp_consistency_empty lookup update P empty"
"iterator cnt nxt sizef"
for empty
by (meson
dp_consistency_empty.axioms(1) dp_consistency_iterator_def
dp_consistency_iterator_empty_def that
)
context
fixes m :: nat \<comment> \<open>Width of a row\<close>
and n :: nat \<comment> \<open>Number of rows\<close>
begin
lemma table_iterator_up:
"iterator
(\<lambda> (x, y). x \<le> n \<and> y \<le> m)
(\<lambda> (x, y). if y < m then (x, y + 1) else (x + 1, 0))
(\<lambda> (x, y). x * (m + 1) + y)"
by standard auto
lemma table_iterator_down:
"iterator
(\<lambda> (x, y). x \<le> n \<and> y \<le> m \<and> x > 0)
(\<lambda> (x, y). if y > 0 then (x, y - 1) else (x - 1, m))
(\<lambda> (x, y). (n - x) * (m + 1) + (m - y))"
using [[simproc add: finite_Collect]] by standard (auto simp: Suc_diff_le)
end (* Table *)
end (* Theory *)
|
theory ListSet imports Main
begin
primrec member where
\<open>member _ [] = False\<close> |
\<open>member m (n # A) = (m = n \<or> member m A)\<close>
lemma member_iff [iff]: \<open>member m A \<longleftrightarrow> m \<in> set A\<close>
by (induct A) simp_all
primrec common where
\<open>common _ [] = False\<close> |
\<open>common X (y # Y) = (member y X \<or> common X Y)\<close>
lemma common_iff [iff]: \<open>common A B \<longleftrightarrow> set A \<inter> set B \<noteq> {}\<close>
by (induct B) simp_all
definition add where "
add a X \<equiv>
if member a X
then X
else a # X"
lemma add_simp [simp]: \<open>add a X = Y \<longrightarrow> (insert a (set X)) = set Y\<close>
by (metis add_def insert_absorb list.simps(15) member_iff)
(*UNION*)
primrec union (infixr \<open>U\<close> 100) where
\<open>union A [] = A\<close> |
\<open>union A (b # B) = union (add b A) B\<close>
lemma union_simp [simp]: \<open>union A B = C \<longrightarrow> set A \<union> set B = set C\<close>
apply (induct B arbitrary: A C)
apply simp
by (metis Un_insert_left Un_insert_right add_simp list.simps(15) union.simps(2))
lemma union_member: \<open>member a (A U B) \<longleftrightarrow> member a A \<or> member a B\<close>
by (metis Un_iff member_iff union_simp)
(*\UNION*)
(*REMOVE*)
primrec remove where
\<open>remove [] B = []\<close> |
\<open>remove (a # A) B = (
if member a B
then remove A B
else a # remove A B)\<close>
lemma remove_simp [simp]: \<open>remove A B = C \<longrightarrow> set A - set B = set C\<close>
apply (induct A arbitrary: B C)
apply simp
by (metis insert_Diff_if list.simps(15) member_iff remove.simps(2))
lemma remove_iff : \<open>set (remove A B) = set A - set B\<close>
by simp
lemma removent: \<open>\<not>common A B \<Longrightarrow> remove A B = A\<close>
proof (induct A)
case Nil
then show ?case by simp
next
case (Cons a A)
then have a: "\<not> common (a # A) B \<and> (\<not> common A B \<longrightarrow> remove A B = A)" by simp
then have 1:"\<not> member a B"
by (metis common_iff insert_disjoint(1) list.simps(15) member_iff)
from a have "\<not> common A B"
by (metis "1" Int_insert_left_if0 common_iff list.simps(15) member_iff)
then show ?case using 1
using Cons.hyps by fastforce
qed
lemma removent2: \<open>\<not> member b B \<Longrightarrow> member b A \<Longrightarrow> member b (remove A B)\<close>
by (metis DiffI member_iff remove_simp)
lemma remove_size: \<open>common A B \<Longrightarrow> size (remove A B) < size A\<close>
proof (induct A)
case Nil
then show ?case by simp
next
case (Cons a A)
then have a: "(common A B \<longrightarrow> length (remove A B) < length A) \<and> common (a # A) B" by simp
then show ?case
proof cases
assume "member a B"
then show ?thesis using a
by (metis dual_order.strict_trans impossible_Cons not_le_imp_less remove.simps(2) removent)
next
assume "\<not> member a B"
then have "common A B"
using Cons.prems set_ConsD by fastforce
then show ?thesis using a by simp
qed
qed
lemma member_remove: \<open>member a B \<Longrightarrow> \<not> member a (remove A B)\<close>
by (metis DiffD2 member_iff remove_simp)
(*\REMOVE*)
(*SETEQUAL*)
definition set_equal where \<open>set_equal A B \<equiv> remove A B = [] \<and> remove B A = []\<close>
lemma set_equal_iff[iff]: "set_equal A B \<longleftrightarrow> set A = set B"
apply (induct A arbitrary: B)
apply (smt (z3) Diff_empty remove_simp set_empty set_equal_def)
by (smt (verit) Diff_cancel Un_Diff_cancel Un_left_commute
remove_simp set_empty2 set_equal_def sup_bot.right_neutral)
lemma set_equal_reflexive: \<open>set_equal A A\<close>
by simp
lemma set_equal_commutative: \<open>set_equal A B \<longleftrightarrow> set_equal B A\<close>
by auto
lemma set_equal_associative: \<open>set_equal A B \<Longrightarrow> set_equal B C \<Longrightarrow> set_equal A C\<close>
by simp
lemma union_commutative: \<open>set_equal (A U B) (B U A)\<close>
apply simp
by (metis Un_commute union_simp)
lemma union_associative: \<open>set_equal (A U (B U C)) ((A U B) U C)\<close>
by (metis boolean_algebra_cancel.sup1 set_equal_iff union_simp)
lemma union_reflexive:\<open>set_equal A (A U A)\<close>
by (metis set_equal_iff sup.idem union_simp)
lemma equal_add: \<open>set_equal A B \<Longrightarrow> set_equal (add a A) (add a B)\<close>
by (metis add_simp set_equal_iff)
lemma unionadd1: \<open>set_equal (add a (A U B)) ((add a A) U B)\<close>
by (metis Un_insert_left add_simp set_equal_iff union_simp)
lemma unionadd11: \<open>set_equal (add a (add b (A U B))) ((add a (add b A)) U B)\<close>
by (metis add_simp set_equal_iff unionadd1)
lemma unionadd2: \<open>set_equal (add a (A U B)) (A U (add a B))\<close>
by (metis add_simp set_equal_iff union_commutative unionadd1)
lemma unionaddnt: \<open>set_equal ([] U B) B\<close>
proof (induct B)
case Nil
then show ?case by simp
next
case (Cons a B)
then show ?case using set_equal_def
by (smt (verit, del_insts) add_def add_simp
list.simps(15) set_equal_iff union.simps(2) unionadd1)
qed
lemma union_with_equal: \<open>set_equal A B \<Longrightarrow> set_equal (C U A) (C U B)\<close>
apply (induct C)
apply (metis set_equal_iff unionaddnt)
apply simp
by (metis union_simp)
lemma union_with_equal2: \<open>set_equal A B \<Longrightarrow> set_equal (A U C) (B U C)\<close>
by (metis set_equal_iff union_simp)
lemma set_equal_append_add: \<open>set_equal (a # A) (add a A)\<close>
by simp
lemma remove_equal: \<open>set_equal A B \<Longrightarrow> set_equal (remove A C) (remove B C)\<close>
by (metis remove_simp set_equal_iff)
lemma remove_commute: \<open>set_equal (remove (remove A B) C) (remove A (C @ B))\<close>
proof (induct A)
case Nil
then show ?case by simp
next
case (Cons a A)
consider \<open>member a B \<or> member a C\<close> | \<open>\<not>member a B \<and> \<not>member a C\<close>
by auto
then show ?case
proof cases
case 1
have \<open>member a (C @ B)\<close>
by (metis 1 UnI1 UnI2 member_iff set_append)
then have \<open>set_equal (remove (a # A) (C @ B)) (remove A (C @ B))\<close>
by simp
moreover have \<open>set_equal (remove (remove (a # A) B) C) (remove (remove A B) C)\<close>
using "1" by auto
ultimately show ?thesis
using Cons.hyps by force
next
case 2
then have \<open>\<not>member a (C @ B)\<close>
by (metis Un_iff member_iff set_append)
then have \<open>set_equal (remove (a # A) (C @ B)) (a # (remove A (C @ B)))\<close>
by simp
moreover have \<open>set_equal (remove (remove (a # A) B) C) (a # (remove (remove A B) C))\<close>
using "2" by auto
ultimately show ?thesis
using Cons.hyps by force
qed
qed
lemma set_equal_remove_commont: \<open>
\<not> common A B \<Longrightarrow> set_equal (remove (B @ A) B) A\<close>
proof (induct B)
case Nil
then show ?case
by (simp add: removent)
next
case (Cons a B)
have 0:\<open>\<not>member a A\<close>
by (meson Cons.prems common.simps(2))
have 1:\<open>set_equal A (remove (B @ A) B)\<close>
by (meson Cons.hyps Cons.prems common.simps(2) set_equal_commutative)
then have 2:\<open>\<not> member a (remove (B @ A) B)\<close>
by (metis Cons.prems ListSet.member.simps(1) common.simps(2) removent2 set_equal_def)
have \<open>set_equal A (remove (B @ A) B)\<close>
using "1" by auto
moreover have \<open>set_equal ... (remove (remove (B @ A) B) [a])\<close>
by (metis "2" append_Nil2 common.simps(1) common.simps(2) remove_commute removent)
moreover have \<open>set_equal ... (remove (B @ A) (a # B))\<close>
by (metis append_Cons append_Nil remove_commute)
moreover have \<open>set_equal ... (remove (a # B @ A) (a # B))\<close>
by (metis ListSet.member.simps(2) remove.simps(2) union_with_equal union.simps(1) unionaddnt)
ultimately show ?case
by simp
qed
lemma set_equal_commont_remove: \<open>
\<not> common A C \<Longrightarrow> set_equal (C @ A) B \<Longrightarrow> set_equal A (remove B C)\<close>
proof -
assume a1:\<open>\<not> common A C\<close>
assume a2:\<open>set_equal (C @ A) B\<close>
then have \<open>set_equal (remove (C @ A) C) (remove B C)\<close>
by (meson remove_equal)
moreover have \<open>set_equal (remove (C @ A) C) A\<close> using a1
by (meson set_equal_remove_commont)
ultimately show ?thesis
by simp
qed
lemma double_union_equal: \<open>
set_equal A C \<Longrightarrow> set_equal B D \<Longrightarrow> set_equal (A U B) (C U D)\<close> (is \<open>?A1 \<Longrightarrow> ?A2 \<Longrightarrow> ?C\<close>)
proof -
assume a1:"?A1"
assume a2:\<open>?A2\<close>
have \<open>set_equal (A U B) (A U D)\<close>
by (meson a2 union_with_equal)
then show ?C
by (metis a1 set_equal_iff union_simp)
qed
lemma set_equal_add_con: \<open>set_equal (add a (b # A)) (b # (add a A))\<close>
proof-
have \<open>set_equal (add a (b # A)) (add a (add b A))\<close>
by (meson equal_add set_equal_append_add)
moreover have \<open>set_equal ... (add b (add a A))\<close>
by (metis calculation set_equal_associative set_equal_commutative union.simps(1)
union.simps(2) union_commutative unionadd2)
ultimately show ?thesis
by simp
qed
(*\SETEQUAL*)
(*SUBSET*)
definition sub_set where "sub_set A B \<equiv> remove A B = []"
lemma sub_set_iff[iff]: "sub_set A B \<longleftrightarrow> set A \<subseteq> set B"
apply (induct A)
apply (simp add: sub_set_def)
by (metis Diff_eq_empty_iff remove_simp set_empty sub_set_def)
lemma sub_set_union1: \<open>sub_set A (A U B)\<close>
by (metis sub_set_iff sup.cobounded1 union_simp)
lemma sub_set_union2: \<open>sub_set A (B U A)\<close>
by (metis UnI2 sub_set_iff subsetI union_simp)
lemma sub_set_remove: \<open>\<not> member a' A \<Longrightarrow> sub_set A B \<Longrightarrow> sub_set A (remove B [a'])\<close>
proof (induct A arbitrary: a' B)
case Nil
then show ?case by simp
next
case (Cons a A)
have 1:"a' \<noteq> a"
by (metis Cons.prems(1) member.simps(2))
have 2:"sub_set A (remove B [a'])"
by (metis Cons.hyps Cons.prems(1) Cons.prems(2) member.simps(2)
list.distinct(1) remove.simps(2) sub_set_def)
show ?case
proof cases
assume "member a B"
then have "member a (remove B [a'])"
by (metis "1" member.simps(1)
member.simps(2) removent2)
then show ?thesis
by (metis 2 remove.simps(2) sub_set_def)
next
assume "\<not>member a B"
then show ?thesis
by (metis Cons.prems(2) list.distinct(1) remove.simps(2) sub_set_def)
qed
qed
lemma sub_set_remove2: \<open>\<not> member a' A \<Longrightarrow> sub_set A (a' # B) \<Longrightarrow> sub_set A B\<close>
using set_ConsD by fastforce
lemma add_sub_set: \<open>sub_set A B \<Longrightarrow> sub_set A (add b B)\<close>
by (metis add_simp sub_set_iff subset_insertI2)
lemma sub_set_union: \<open>sub_set A C \<Longrightarrow> sub_set B C \<Longrightarrow> sub_set (A U B) C\<close>
by (metis Un_subset_iff sub_set_iff union_simp)
lemma member_sub_set: \<open>(\<forall> a. member a A \<longrightarrow> member a B) \<longleftrightarrow> sub_set A B\<close>
by auto
lemma sub_remove_set: \<open>sub_set A B \<Longrightarrow> sub_set (remove A C) B\<close>
using remove_iff by fast
lemma sub_remove_middle: \<open>A = A1 @ A2 @ A3 \<Longrightarrow> A' = A1 @ A3 \<Longrightarrow> sub_set A' A\<close>
apply (induct A1 arbitrary: A A')
apply simp
apply (meson sub_set_iff sub_set_union2)
by (metis (full_types) Cons_eq_appendI ListSet.member.simps(2) member_sub_set)
(*\SUBSET*)
(*ISSET*)
primrec is_set where
\<open>is_set [] = True\<close> |
\<open>is_set (a # A) = (\<not> member a A \<and> is_set A)\<close>
lemma is_set_size: \<open>is_set A \<longleftrightarrow> (\<forall> a. member a A \<longrightarrow> Suc (size (remove A [a])) = size A)\<close>
proof (induct A)
case Nil
then show ?case by simp
next
case (Cons a A)
assume a1: "is_set A = (\<forall>a. member a A \<longrightarrow> Suc (length (remove A [a])) = length A)"
show "is_set (a # A) \<longleftrightarrow> (\<forall>aa. member aa (a # A) \<longrightarrow> Suc (length (remove (a # A) [aa])) = length (a # A))"
proof
assume a2: "is_set (a # A)"
then have 1:"(\<forall>a. member a A \<longrightarrow> Suc (length (remove A [a])) = length A)" using a1 by simp
show "(\<forall>aa. member aa (a # A) \<longrightarrow> Suc (length (remove (a # A) [aa])) = length (a # A))"
proof
fix aa
show "member aa (a # A) \<longrightarrow> Suc (length (remove (a # A) [aa])) = length (a # A)"
proof
assume a3: "member aa (a # A)"
show "Suc (length (remove (a # A) [aa])) = length (a # A)"
proof cases
assume "member aa A"
then show ?thesis
using 1 a2 by auto
next
assume a4: "\<not> member aa A"
then have 1: \<open>remove (a # A) [aa] = remove A [aa]\<close>
by (metis member.simps(2) a3 remove.simps(2))
then have "remove A [aa] = A" using a4 removent
by force
then show ?thesis
using 1 by auto
qed
qed
qed
next
assume a2:"\<forall>aa. member aa (a # A) \<longrightarrow> Suc (length (remove (a # A) [aa])) = length (a # A)"
have "\<forall>a. member a A \<longrightarrow> Suc (length (remove A [a])) = length A"
proof
fix a'
show "member a' A \<longrightarrow> Suc (length (remove A [a'])) = length A"
proof
assume a3:"member a' A"
then have 1: "Suc (length (remove (a # A) [a'])) = length (a # A)" using a2
by (meson member.simps(2))
have "a \<noteq> a'"
proof (rule ccontr)
assume "\<not>a \<noteq> a'"
then have 2:"remove (a # A) [a'] = remove A [a']" by simp
have "length (remove A [a']) < length A" using a3
by (metis common.simps(2) remove_size)
then show "False"
using 1 2 by fastforce
qed
then show "Suc (length (remove A [a'])) = length A"
using 1 by auto
qed
qed
then show "is_set (a # A)"
using member.simps(2) a1 a2 by fastforce
qed
qed
lemma union_is_set: \<open>is_set A \<Longrightarrow> is_set (A U B)\<close>
apply (induct B arbitrary: A)
apply simp
by (metis add_def is_set.simps(2) union.simps(2))
lemma add_is_set: \<open>is_set A \<Longrightarrow> is_set (add a A)\<close>
by (simp add: add_def)
lemma remove_is_set: \<open>is_set A \<Longrightarrow> is_set (remove A B)\<close>
proof (induct A)
case Nil
then show ?case by simp
next
case (Cons a A)
then show ?case
proof cases
assume "member a B"
then show ?thesis
using Cons.hyps Cons.prems by auto
next
assume "\<not>member a B"
have "\<not> member a A"
using Cons.prems by auto
then have "\<not> member a (remove A B)"
by (metis DiffE member_iff remove_simp)
then show ?thesis
using Cons.hyps Cons.prems by auto
qed
qed
lemma set_size_equal: \<open>is_set A \<Longrightarrow> is_set B \<Longrightarrow> set_equal A B \<Longrightarrow> length A = length B\<close>
apply (induct A arbitrary: B)
apply simp
by (smt (verit, ccfv_threshold) member.simps(2) is_set.simps(2) is_set_size
length_Cons less_irrefl_nat list.distinct(1) nat.inject remove.simps(2) remove_equal
remove_is_set remove_size removent set_equal_def)
lemma sub_set_size: \<open>is_set A \<Longrightarrow> is_set B \<Longrightarrow> sub_set A B \<Longrightarrow> length A \<le> length B\<close>
proof (induct A arbitrary: B)
case Nil
then show ?case by simp
next
case (Cons a A)
then show ?case
proof cases
assume "member a A"
then show ?thesis
by (meson Cons.prems(1) is_set.simps(2))
next
assume a:"\<not> member a A"
then have "member a B"
by (metis Cons.prems(3) in_mono list.set_intros(1) member_iff sub_set_iff)
moreover have "is_set A"
using Cons.prems(1) by auto
moreover have "is_set (remove B [a])"
by (simp add: Cons.prems(2) remove_is_set)
then have "length A \<le> length (remove B [a])"
by (metis Cons.hyps Cons.prems(3) a calculation(1)
calculation(2) remove.simps(2) sub_set_def sub_set_remove)
then show ?thesis
using Cons.prems(2) calculation(1) is_set_size by fastforce
qed
qed
lemma add_size: \<open>length (add a A) \<le> length A + 1\<close>
proof cases
assume "member a A"
then show ?thesis
by (simp add: add_def)
next
assume "\<not> member a A"
then show ?thesis
by (metis One_nat_def add_def eq_imp_le list.size(4))
qed
(*\ISSET*)
end |
import tactic
import tactic.induction
import data.list.basic
import data.multiset.basic
noncomputable theory
open_locale classical
open_locale big_operators
lemma nat.pred_eq_self_iff {n : ℕ} : n.pred = n ↔ n = 0 :=
begin
cases n; simp,
exact (nat.succ_ne_self _).symm,
end
lemma list.count_erase {α : Type*} {l : list α} {x : α} :
(l.erase x).count x = l.count x - (ite (x ∈ l) 1 0) :=
begin
split_ifs with h,
{ rw list.count_erase_self, refl },
{ have h₁ : x ∉ l.erase x,
{ contrapose! h, exact list.mem_of_mem_erase h },
rw [list.count_eq_zero_of_not_mem h, list.count_eq_zero_of_not_mem h₁] },
end
lemma list.mem_diff_iff {α : Type*} {l₁ l₂ : list α} {x : α} :
x ∈ l₁ \ l₂ ↔ l₂.count x < l₁.count x :=
begin
change x ∈ list.diff _ _ ↔ _,
induction l₂ with hd l₂ ih generalizing l₁; simp,
rw [ih, list.count_cons], split_ifs,
{ subst h, split; intro h,
{ rw list.count_erase at h, split_ifs at h with h₁,
{ cases list.count x l₁,
{ cases h },
{ rwa nat.succ_lt_succ_iff } },
{ rw ←list.count_pos at h₁, push_neg at h₁,
rw nat.le_zero_iff at h₁, rw h₁ at h, cases h }},
{ rw list.count_erase, split_ifs with h₁,
{ rwa lt_tsub_iff_right },
{ rw ←list.count_pos at h₁, push_neg at h₁,
rw nat.le_zero_iff at h₁, rw h₁ at h, cases h }}},
{ rw list.count_erase_of_ne h },
end
lemma finset.sum_le_sum_of_le {α : Type*} {f g : α → ℕ} {s : finset α}
(h : ∀ (a : α), a ∈ s → f a ≤ g a) :
∑ (a : α) in s, f a ≤ ∑ (a : α) in s, g a :=
begin
revert h, apply s.induction_on; simp,
rintro a s h₁ h₂ h₃ h₄, specialize h₂ h₄,
simp_rw finset.sum_insert h₁, exact add_le_add h₃ h₂,
end
lemma list.sum_count_cons_diff_singleton {α : Type*} {l : list α} {x : α} :
∑ (a : α) in l.to_finset \ {x}, (x :: l).count a =
∑ (a : α) in l.to_finset \ {x}, l.count a :=
begin
apply finset.sum_congr rfl, rintro a h, rw [list.count_cons, if_neg],
rintro rfl, rw [finset.mem_sdiff, finset.mem_singleton] at h, exact h.2 rfl,
end
lemma list.sum_count_cons {α : Type*} {l : list α} {x : α} :
∑ (a : α) in l.to_finset, (x :: l).count a =
∑ (a : α) in l.to_finset, l.count a + ite (x ∈ l) 1 0 :=
begin
simp_rw ←list.mem_to_finset, split_ifs,
{ simp_rw finset.sum_eq_sum_diff_singleton_add h,
rw [list.sum_count_cons_diff_singleton, add_assoc],
congr, rw [list.count_cons, if_pos rfl] },
{ have h₁ : l.to_finset = l.to_finset \ {x},
{ exact (finset.sdiff_singleton_not_mem_eq_self _ h).symm },
rw h₁, exact list.sum_count_cons_diff_singleton },
end
lemma list.length_eq_sum_count {α : Type*} {l : list α} :
l.length = ∑ (x : α) in l.to_finset, l.count x :=
begin
induction l with hd l ih; simp, by_cases h : hd ∈ l.to_finset,
{ rw finset.insert_eq_of_mem h,
rw finset.sum_eq_sum_diff_singleton_add h at ih ⊢,
rw [list.sum_count_cons_diff_singleton, list.count_cons, if_pos rfl, ih],
refl },
{ have h₁ : hd ∈ insert hd l.to_finset := finset.mem_insert_self _ _,
rw finset.sum_eq_sum_diff_singleton_add h₁, have h₂ : hd ∉ l,
{ rwa list.mem_to_finset at h },
have h₃ : insert hd l.to_finset \ {hd} = l.to_finset,
{ ext x, by_cases h₃ : x = hd,
{ subst h₃, simpa [h₁] },
{ simp [h₃] }},
rw h₃, have h₃ : list.count hd (hd :: l) = 1,
{ rw [list.count_cons, if_pos rfl, list.count_eq_zero_of_not_mem h₂] },
rw h₃, congr, rw [ih, list.sum_count_cons, if_neg h₂], refl },
end
lemma list.sum_union_eq_sum {α : Type*} {l : list α} {s : finset α} :
∑ (x : α) in l.to_finset ∪ s, l.count x = ∑ (x : α) in l.to_finset, l.count x :=
begin
apply s.induction_on; simp, rintro a s h₁ ih,
by_cases h₃ : a ∈ l.to_finset ∪ s,
{ rwa finset.insert_eq_of_mem h₃ },
{ rw [finset.sum_insert h₃, ih], have h₄ : a ∉ l,
{ contrapose! h₃, apply finset.mem_union_left, rwa list.mem_to_finset },
rw [list.count_eq_zero_of_not_mem h₄, zero_add] },
end
lemma list.length_le_length_of_count_le_count {α : Type*}
{l₁ l₂ : list α} (h : ∀ (a : α), l₁.count a ≤ l₂.count a) :
l₁.length ≤ l₂.length :=
begin
simp_rw list.length_eq_sum_count,
let s := l₁.to_finset ∪ l₂.to_finset,
suffices h₁ : ∑ (x : α) in s, l₁.count x ≤ ∑ (x : α) in s, l₂.count x,
{ change s with _ ∪ _ at h₁, nth_rewrite 1 finset.union_comm at h₁,
simp_rw list.sum_union_eq_sum at h₁, exact h₁ },
replace h : ∀ (a : α), a ∈ s → l₁.count a ≤ l₂.count a,
{ rintro a h₁, apply h },
exact finset.sum_le_sum_of_le h,
end
lemma list.count_map_eq_length_filter {α β : Type*} {f : α → β}
{l : list α} {y : β} :
(l.map f).count y = (l.filter (λ (x : α), f x = y)).length :=
begin
induction l with hd l ih; simp,
rw list.count_cons, rw ih, clear ih,
split_ifs; rw list.filter,
{ rw if_pos h.symm, refl },
{ rw if_neg, tauto },
end
lemma list.count_filter_eq_ite {α : Type*} {P : α → Prop}
{l : list α} {x : α} : (l.filter P).count x = ite (P x) (l.count x) 0 :=
begin
split_ifs,
{ exact list.count_filter h },
{ apply list.count_eq_zero_of_not_mem,
contrapose! h, exact list.of_mem_filter h },
end
-----
theorem list.diff_map_subset {α β : Type*} {f : α → β} {l₁ l₂ : list α} :
l₁.map f \ l₂.map f ⊆ (l₁ \ l₂).map f :=
begin
rintro y h, rw list.mem_diff_iff at h, rw list.mem_map,
contrapose! h, simp_rw [list.mem_diff_iff, imp_not_comm, not_lt] at h,
let s₁ := l₁.filter (λ x, f x = y), let s₂ := l₂.filter (λ x, f x = y),
have hs₁ : ∀ (a : α), s₁.count a = ite (f a = y) (l₁.count a) 0,
{ exact λ _, list.count_filter_eq_ite },
have hs₂ : ∀ (a : α), s₂.count a = ite (f a = y) (l₂.count a) 0,
{ exact λ _, list.count_filter_eq_ite },
replace h : ∀ (a : α), s₁.count a ≤ s₂.count a,
{ rintro a, specialize h a, rw [hs₁, hs₂],
split_ifs with h₁,
{ exact h h₁ },
{ refl }},
have hh₁ : (l₁.map f).count y = s₁.length := list.count_map_eq_length_filter,
have hh₂ : (l₂.map f).count y = s₂.length := list.count_map_eq_length_filter,
rw [hh₁, hh₂], exact list.length_le_length_of_count_le_count h,
end |
#pragma once
#include "GradUtil.h"
#ifndef _NOGSL
#include <gsl/gsl_vector.h>
#include <gsl/gsl_blas.h>
#else
#include "CustomSolver.h"
#endif
#include <limits>
#include <math.h>
#include <vector>
#include "BasicError.h"
#include "Util.h"
using namespace std;
class ValueGrad;
class DistanceGrad {
public:
double dist;
gsl_vector* grad;
bool set; // TODO: this bit is not necessary if the default dist is 0
DistanceGrad(double d, gsl_vector* g): dist(d), grad(g), set(true) {}
~DistanceGrad(void) {
gsl_vector_free(grad);
}
string print() {
stringstream str;
if (set) {
str << "Dist: " << dist;
} else {
str << "Dist: NOT SET";
}
return str.str();
}
string printFull() {
stringstream str;
if (set) {
str << "Dist: " << dist << endl;
str << "DGrads: ";
for (int i = 0; i < grad->size; i++) {
str << gsl_vector_get(grad, i) << ", ";
}
if (dist > 1e5 || gsl_blas_dnrm2(grad) > 1e5) {
str << "LARGE VALUES" << endl;
}
} else {
str << "Dist: NOT SET";
}
return str.str();
}
static void dg_and(DistanceGrad* m, DistanceGrad* f, DistanceGrad* d);
static void dg_or(DistanceGrad* m, DistanceGrad* f, DistanceGrad* d);
static void dg_not(DistanceGrad* m, DistanceGrad* d);
static void dg_ite(DistanceGrad* b, DistanceGrad* m, DistanceGrad* f, DistanceGrad* d);
static double dg_copy(DistanceGrad* m, gsl_vector* grad);
static void dg_copy(DistanceGrad* m, DistanceGrad* o);
static double dg_times(DistanceGrad* m, DistanceGrad* f, gsl_vector* grad);
static void dg_ite(DistanceGrad* m, DistanceGrad* f, double dval, gsl_vector* dgrad, DistanceGrad* o);
static bool same(DistanceGrad* m, DistanceGrad* f);
static double dg_combine(DistanceGrad* m, DistanceGrad* f);
static void dg_combine(DistanceGrad* m, DistanceGrad* f, DistanceGrad* o);
static double dg_combine(DistanceGrad* m, DistanceGrad* f, double cval, gsl_vector* grad, int bv, gsl_vector* o);
static double dg_combine(DistanceGrad* m, DistanceGrad* f, double cval, int bv);
static void dg_combine(vector<DistanceGrad*>& cdists, DistanceGrad* vdist, vector<ValueGrad*>& cvals, int bv, DistanceGrad* o);
};
|
[STATEMENT]
lemma closest_pair_rec_eq_val_closest_pair_rec_tm:
"val (closest_pair_rec_tm xs) = closest_pair_rec xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
proof (induction rule: length_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
case (1 xs)
[PROOF STATE]
proof (state)
this:
\<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys
goal (1 subgoal):
1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
define n where "n = length xs"
[PROOF STATE]
proof (state)
this:
n = length xs
goal (1 subgoal):
1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
obtain xs\<^sub>L xs\<^sub>R where xs_def: "(xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>xs\<^sub>L xs\<^sub>R. (xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis surj_pair)
[PROOF STATE]
proof (state)
this:
(xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs
goal (1 subgoal):
1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
note defs = n_def xs_def
[PROOF STATE]
proof (state)
this:
n = length xs
(xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs
goal (1 subgoal):
1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. ?P \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
2. \<not> ?P \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
assume "n \<le> 3"
[PROOF STATE]
proof (state)
this:
n \<le> 3
goal (2 subgoals):
1. ?P \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
2. \<not> ?P \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<le> 3
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n \<le> 3
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
using defs
[PROOF STATE]
proof (prove)
using this:
n \<le> 3
n = length xs
(xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
by (auto simp: length_eq_val_length_tm mergesort_eq_val_mergesort_tm
closest_pair_bf_eq_val_closest_pair_bf_tm closest_pair_rec.simps)
[PROOF STATE]
proof (state)
this:
Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
goal (1 subgoal):
1. \<not> n \<le> 3 \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<not> n \<le> 3 \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
assume asm: "\<not> n \<le> 3"
[PROOF STATE]
proof (state)
this:
\<not> n \<le> 3
goal (1 subgoal):
1. \<not> n \<le> 3 \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
have "length xs\<^sub>L < length xs" "length xs\<^sub>R < length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. length xs\<^sub>L < length xs &&& length xs\<^sub>R < length xs
[PROOF STEP]
using asm defs
[PROOF STATE]
proof (prove)
using this:
\<not> n \<le> 3
n = length xs
(xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs
goal (1 subgoal):
1. length xs\<^sub>L < length xs &&& length xs\<^sub>R < length xs
[PROOF STEP]
by (auto simp: split_at_take_drop_conv)
[PROOF STATE]
proof (state)
this:
length xs\<^sub>L < length xs
length xs\<^sub>R < length xs
goal (1 subgoal):
1. \<not> n \<le> 3 \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
hence "val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L"
"val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R"
[PROOF STATE]
proof (prove)
using this:
length xs\<^sub>L < length xs
length xs\<^sub>R < length xs
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L &&& Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R
[PROOF STEP]
using "1.IH"
[PROOF STATE]
proof (prove)
using this:
length xs\<^sub>L < length xs
length xs\<^sub>R < length xs
\<forall>ys. length ys < length xs \<longrightarrow> Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L &&& Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L
Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R
goal (1 subgoal):
1. \<not> n \<le> 3 \<Longrightarrow> Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L
Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
using asm defs
[PROOF STATE]
proof (prove)
using this:
Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L
Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R
\<not> n \<le> 3
n = length xs
(xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs
goal (1 subgoal):
1. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
[PROOF STEP]
apply (subst closest_pair_rec.simps, subst closest_pair_rec_tm.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L; Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R; \<not> n \<le> 3; n = length xs; (xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs; Time_Monad.val (closest_pair_rec_tm xs\<^sub>L) = closest_pair_rec xs\<^sub>L; Time_Monad.val (closest_pair_rec_tm xs\<^sub>R) = closest_pair_rec xs\<^sub>R; \<not> n \<le> 3; n = length xs; (xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs\<rbrakk> \<Longrightarrow> Time_Monad.val (length_tm xs \<bind> (\<lambda>n. if n \<le> 3 then mergesort_tm snd xs \<bind> (\<lambda>ys. closest_pair_bf_tm xs \<bind> (\<lambda>p. return (ys, p))) else split_at_tm (n div 2) xs \<bind> (\<lambda>(xs\<^sub>L, xs\<^sub>R). closest_pair_rec_tm xs\<^sub>L \<bind> (\<lambda>(ys\<^sub>L, p\<^sub>0\<^sub>L, p\<^sub>1\<^sub>L). closest_pair_rec_tm xs\<^sub>R \<bind> (\<lambda>(ys\<^sub>R, p\<^sub>0\<^sub>R, p\<^sub>1\<^sub>R). merge_tm snd ys\<^sub>L ys\<^sub>R \<bind> (\<lambda>ys. combine_tm (p\<^sub>0\<^sub>L, p\<^sub>1\<^sub>L) (p\<^sub>0\<^sub>R, p\<^sub>1\<^sub>R) (fst (hd xs\<^sub>R)) ys \<bind> (\<lambda>(p\<^sub>0, p\<^sub>1). return (ys, p\<^sub>0, p\<^sub>1))))))) \<bind> tick) = (let n = length xs in if n \<le> 3 then (mergesort snd xs, closest_pair_bf xs) else let (xs\<^sub>L, xs\<^sub>R) = split_at (n div 2) xs; (ys\<^sub>L, p\<^sub>0\<^sub>L, p\<^sub>1\<^sub>L) = closest_pair_rec xs\<^sub>L; (ys\<^sub>R, p\<^sub>0\<^sub>R, p\<^sub>1\<^sub>R) = closest_pair_rec xs\<^sub>R; ys = Common.merge snd ys\<^sub>L ys\<^sub>R in (ys, combine (p\<^sub>0\<^sub>L, p\<^sub>1\<^sub>L) (p\<^sub>0\<^sub>R, p\<^sub>1\<^sub>R) (fst (hd xs\<^sub>R)) ys))
[PROOF STEP]
by (auto simp del: closest_pair_rec_tm.simps
simp add: Let_def length_eq_val_length_tm merge_eq_val_merge_tm
split_at_eq_val_split_at_tm combine_eq_val_combine_tm
split: prod.split)
[PROOF STATE]
proof (state)
this:
Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs
goal:
No subgoals!
[PROOF STEP]
qed |
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsPiSystem (C i)
⊢ IsPiSystem (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
rintro _ ⟨s₁, hs₁, rfl⟩ _ ⟨s₂, hs₂, rfl⟩ hst
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsPiSystem (C i)
s₁ : (i : ι) → Set (α i)
hs₁ : s₁ ∈ Set.pi univ C
s₂ : (i : ι) → Set (α i)
hs₂ : s₂ ∈ Set.pi univ C
hst : Set.Nonempty (Set.pi univ s₁ ∩ Set.pi univ s₂)
⊢ Set.pi univ s₁ ∩ Set.pi univ s₂ ∈ Set.pi univ '' Set.pi univ C
[PROOFSTEP]
rw [← pi_inter_distrib] at hst ⊢
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsPiSystem (C i)
s₁ : (i : ι) → Set (α i)
hs₁ : s₁ ∈ Set.pi univ C
s₂ : (i : ι) → Set (α i)
hs₂ : s₂ ∈ Set.pi univ C
hst : Set.Nonempty (Set.pi univ fun i => s₁ i ∩ s₂ i)
⊢ (Set.pi univ fun i => s₁ i ∩ s₂ i) ∈ Set.pi univ '' Set.pi univ C
[PROOFSTEP]
rw [univ_pi_nonempty_iff] at hst
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsPiSystem (C i)
s₁ : (i : ι) → Set (α i)
hs₁ : s₁ ∈ Set.pi univ C
s₂ : (i : ι) → Set (α i)
hs₂ : s₂ ∈ Set.pi univ C
hst : ∀ (i : ι), Set.Nonempty (s₁ i ∩ s₂ i)
⊢ (Set.pi univ fun i => s₁ i ∩ s₂ i) ∈ Set.pi univ '' Set.pi univ C
[PROOFSTEP]
exact mem_image_of_mem _ fun i _ => hC i _ (hs₁ i (mem_univ i)) _ (hs₂ i (mem_univ i)) (hst i)
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
⊢ IsCountablySpanning (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
choose s h1s h2s using hC
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
s : (i : ι) → ℕ → Set (α i)
h1s : ∀ (i : ι) (n : ℕ), s i n ∈ C i
h2s : ∀ (i : ι), ⋃ (n : ℕ), s i n = univ
⊢ IsCountablySpanning (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
cases nonempty_encodable (ι → ℕ)
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
s : (i : ι) → ℕ → Set (α i)
h1s : ∀ (i : ι) (n : ℕ), s i n ∈ C i
h2s : ∀ (i : ι), ⋃ (n : ℕ), s i n = univ
val✝ : Encodable (ι → ℕ)
⊢ IsCountablySpanning (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
s : (i : ι) → ℕ → Set (α i)
h1s : ∀ (i : ι) (n : ℕ), s i n ∈ C i
h2s : ∀ (i : ι), ⋃ (n : ℕ), s i n = univ
val✝ : Encodable (ι → ℕ)
e : ℕ → ι → ℕ := fun n => Option.iget (decode n)
⊢ IsCountablySpanning (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
refine' ⟨fun n => Set.pi univ fun i => s i (e n i), fun n => mem_image_of_mem _ fun i _ => h1s i _, _⟩
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
s : (i : ι) → ℕ → Set (α i)
h1s : ∀ (i : ι) (n : ℕ), s i n ∈ C i
h2s : ∀ (i : ι), ⋃ (n : ℕ), s i n = univ
val✝ : Encodable (ι → ℕ)
e : ℕ → ι → ℕ := fun n => Option.iget (decode n)
⊢ ⋃ (n : ℕ), (fun n => Set.pi univ fun i => s i (e n i)) n = univ
[PROOFSTEP]
simp_rw [(surjective_decode_iget (ι → ℕ)).iUnion_comp fun x => Set.pi univ fun i => s i (x i), iUnion_univ_pi s, h2s,
pi_univ]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
⊢ MeasurableSpace.pi = generateFrom (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
cases nonempty_encodable ι
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
⊢ MeasurableSpace.pi = generateFrom (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
apply le_antisymm
[GOAL]
case intro.a
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
⊢ MeasurableSpace.pi ≤ generateFrom (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
refine' iSup_le _
[GOAL]
case intro.a
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
⊢ ∀ (i : ι),
MeasurableSpace.comap (fun b => b i) ((fun i => generateFrom (C i)) i) ≤ generateFrom (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
intro i
[GOAL]
case intro.a
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
i : ι
⊢ MeasurableSpace.comap (fun b => b i) ((fun i => generateFrom (C i)) i) ≤ generateFrom (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
rw [comap_generateFrom]
[GOAL]
case intro.a
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
i : ι
⊢ generateFrom ((preimage fun b => b i) '' C i) ≤ generateFrom (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
apply generateFrom_le
[GOAL]
case intro.a.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
i : ι
⊢ ∀ (t : Set ((a : ι) → (fun i => α i) a)), t ∈ (preimage fun b => b i) '' C i → MeasurableSet t
[PROOFSTEP]
rintro _ ⟨s, hs, rfl⟩
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
⊢ MeasurableSet ((fun b => b i) ⁻¹' s)
[PROOFSTEP]
dsimp
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
⊢ MeasurableSet ((fun b => b i) ⁻¹' s)
[PROOFSTEP]
choose t h1t h2t using hC
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
⊢ MeasurableSet ((fun b => b i) ⁻¹' s)
[PROOFSTEP]
simp_rw [eval_preimage, ← h2t]
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
⊢ MeasurableSet (Set.pi univ (update (fun i => ⋃ (n : ℕ), t i n) i s))
[PROOFSTEP]
rw [← @iUnion_const _ ℕ _ s]
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
⊢ MeasurableSet (Set.pi univ (update (fun i => ⋃ (n : ℕ), t i n) i (⋃ (x : ℕ), s)))
[PROOFSTEP]
have :
Set.pi univ (update (fun i' : ι => iUnion (t i')) i (⋃ _ : ℕ, s)) =
Set.pi univ fun k => ⋃ j : ℕ, @update ι (fun i' => Set (α i')) _ (fun i' => t i' j) i s k :=
by
ext; simp_rw [mem_univ_pi]; apply forall_congr'; intro i'
by_cases h : i' = i
· subst h; simp
· rw [← Ne.def] at h ; simp [h]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
⊢ Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
[PROOFSTEP]
ext
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
⊢ x✝ ∈ Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) ↔
x✝ ∈ Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
[PROOFSTEP]
simp_rw [mem_univ_pi]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
⊢ (∀ (i_1 : ι), x✝ i_1 ∈ update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s) i_1) ↔
∀ (i_1 : ι), x✝ i_1 ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i s i_1
[PROOFSTEP]
apply forall_congr'
[GOAL]
case h.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
⊢ ∀ (a : ι),
x✝ a ∈ update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s) a ↔ x✝ a ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i s a
[PROOFSTEP]
intro i'
[GOAL]
case h.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
i' : ι
⊢ x✝ i' ∈ update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s) i' ↔ x✝ i' ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i s i'
[PROOFSTEP]
by_cases h : i' = i
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
i' : ι
h : i' = i
⊢ x✝ i' ∈ update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s) i' ↔ x✝ i' ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i s i'
[PROOFSTEP]
subst h
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
i' : ι
s : Set ((fun i => α i) i')
hs : s ∈ C i'
⊢ x✝ i' ∈ update (fun i' => iUnion (t i')) i' (⋃ (x : ℕ), s) i' ↔ x✝ i' ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i' s i'
[PROOFSTEP]
simp
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
i' : ι
h : ¬i' = i
⊢ x✝ i' ∈ update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s) i' ↔ x✝ i' ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i s i'
[PROOFSTEP]
rw [← Ne.def] at h
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
x✝ : (i : ι) → α i
i' : ι
h : i' ≠ i
⊢ x✝ i' ∈ update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s) i' ↔ x✝ i' ∈ ⋃ (j : ℕ), update (fun i' => t i' j) i s i'
[PROOFSTEP]
simp [h]
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
⊢ MeasurableSet (Set.pi univ (update (fun i => ⋃ (n : ℕ), t i n) i (⋃ (x : ℕ), s)))
[PROOFSTEP]
rw [this, ← iUnion_univ_pi]
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
⊢ MeasurableSet (⋃ (x : ι → ℕ), Set.pi univ fun i_1 => update (fun i' => t i' (x i_1)) i s i_1)
[PROOFSTEP]
apply MeasurableSet.iUnion
[GOAL]
case intro.a.h.intro.intro.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
⊢ ∀ (b : ι → ℕ), MeasurableSet (Set.pi univ fun i_1 => update (fun i' => t i' (b i_1)) i s i_1)
[PROOFSTEP]
intro n
[GOAL]
case intro.a.h.intro.intro.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
⊢ MeasurableSet (Set.pi univ fun i_1 => update (fun i' => t i' (n i_1)) i s i_1)
[PROOFSTEP]
apply measurableSet_generateFrom
[GOAL]
case intro.a.h.intro.intro.h.ht
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
⊢ (Set.pi univ fun i_1 => update (fun i' => t i' (n i_1)) i s i_1) ∈ Set.pi univ '' Set.pi univ C
[PROOFSTEP]
apply mem_image_of_mem
[GOAL]
case intro.a.h.intro.intro.h.ht.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
⊢ (fun i_1 => update (fun i' => t i' (n i_1)) i s i_1) ∈ Set.pi univ C
[PROOFSTEP]
intro j _
[GOAL]
case intro.a.h.intro.intro.h.ht.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
⊢ (fun i_1 => update (fun i' => t i' (n i_1)) i s i_1) j ∈ C j
[PROOFSTEP]
dsimp only
[GOAL]
case intro.a.h.intro.intro.h.ht.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
⊢ update (fun i' => t i' (n j)) i s j ∈ C j
[PROOFSTEP]
by_cases h : j = i
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
h : j = i
⊢ update (fun i' => t i' (n j)) i s j ∈ C j
case neg
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
h : ¬j = i
⊢ update (fun i' => t i' (n j)) i s j ∈ C j
[PROOFSTEP]
subst h
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
n : ι → ℕ
j : ι
a✝ : j ∈ univ
s : Set ((fun i => α i) j)
hs : s ∈ C j
this :
Set.pi univ (update (fun i' => iUnion (t i')) j (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j_1 : ℕ), update (fun i' => t i' j_1) j s k
⊢ update (fun i' => t i' (n j)) j s j ∈ C j
case neg
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
h : ¬j = i
⊢ update (fun i' => t i' (n j)) i s j ∈ C j
[PROOFSTEP]
rwa [update_same]
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
h : ¬j = i
⊢ update (fun i' => t i' (n j)) i s j ∈ C j
[PROOFSTEP]
rw [update_noteq h]
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
val✝ : Encodable ι
i : ι
s : Set ((fun i => α i) i)
hs : s ∈ C i
t : (i : ι) → ℕ → Set (α i)
h1t : ∀ (i : ι) (n : ℕ), t i n ∈ C i
h2t : ∀ (i : ι), ⋃ (n : ℕ), t i n = univ
this :
Set.pi univ (update (fun i' => iUnion (t i')) i (⋃ (x : ℕ), s)) =
Set.pi univ fun k => ⋃ (j : ℕ), update (fun i' => t i' j) i s k
n : ι → ℕ
j : ι
a✝ : j ∈ univ
h : ¬j = i
⊢ t j (n j) ∈ C j
[PROOFSTEP]
apply h1t
[GOAL]
case intro.a
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
⊢ generateFrom (Set.pi univ '' Set.pi univ C) ≤ MeasurableSpace.pi
[PROOFSTEP]
apply generateFrom_le
[GOAL]
case intro.a.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
⊢ ∀ (t : Set ((i : ι) → α i)), t ∈ Set.pi univ '' Set.pi univ C → MeasurableSet t
[PROOFSTEP]
rintro _ ⟨s, hs, rfl⟩
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
s : (i : ι) → Set (α i)
hs : s ∈ Set.pi univ C
⊢ MeasurableSet (Set.pi univ s)
[PROOFSTEP]
rw [univ_pi_eq_iInter]
[GOAL]
case intro.a.h.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
s : (i : ι) → Set (α i)
hs : s ∈ Set.pi univ C
⊢ MeasurableSet (⋂ (i : ι), eval i ⁻¹' s i)
[PROOFSTEP]
apply MeasurableSet.iInter
[GOAL]
case intro.a.h.intro.intro.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
s : (i : ι) → Set (α i)
hs : s ∈ Set.pi univ C
⊢ ∀ (b : ι), MeasurableSet (eval b ⁻¹' s b)
[PROOFSTEP]
intro i
[GOAL]
case intro.a.h.intro.intro.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
s : (i : ι) → Set (α i)
hs : s ∈ Set.pi univ C
i : ι
⊢ MeasurableSet (eval i ⁻¹' s i)
[PROOFSTEP]
apply @measurable_pi_apply _ _ (fun i => generateFrom (C i))
[GOAL]
case intro.a.h.intro.intro.h.a
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), IsCountablySpanning (C i)
val✝ : Encodable ι
s : (i : ι) → Set (α i)
hs : s ∈ Set.pi univ C
i : ι
⊢ MeasurableSet (s i)
[PROOFSTEP]
exact measurableSet_generateFrom (hs i (mem_univ i))
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Finite ι
inst✝ : Finite ι'
h : (i : ι) → MeasurableSpace (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = h i
h2C : ∀ (i : ι), IsCountablySpanning (C i)
⊢ generateFrom (Set.pi univ '' Set.pi univ C) = MeasurableSpace.pi
[PROOFSTEP]
rw [← funext hC, generateFrom_pi_eq h2C]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
hs : Set.Nonempty (Set.pi univ s)
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
simp [hs, piPremeasure]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
cases isEmpty_or_nonempty ι
[GOAL]
case inl
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : IsEmpty ι
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
simp [piPremeasure]
[GOAL]
case inr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : Nonempty ι
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
cases' (pi univ s).eq_empty_or_nonempty with h h
[GOAL]
case inr.inl
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : Nonempty ι
h : Set.pi univ s = ∅
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
rcases univ_pi_eq_empty_iff.mp h with ⟨i, hi⟩
[GOAL]
case inr.inl.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : Nonempty ι
h : Set.pi univ s = ∅
i : ι
hi : s i = ∅
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
have : ∃ i, m i (s i) = 0 := ⟨i, by simp [hi]⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : Nonempty ι
h : Set.pi univ s = ∅
i : ι
hi : s i = ∅
⊢ ↑(m i) (s i) = 0
[PROOFSTEP]
simp [hi]
[GOAL]
case inr.inl.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : Nonempty ι
h : Set.pi univ s = ∅
i : ι
hi : s i = ∅
this : ∃ i, ↑(m i) (s i) = 0
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
simpa [h, Finset.card_univ, zero_pow (Fintype.card_pos_iff.mpr ‹_›), @eq_comm _ (0 : ℝ≥0∞), Finset.prod_eq_zero_iff,
piPremeasure]
[GOAL]
case inr.inr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h✝ : Nonempty ι
h : Set.Nonempty (Set.pi univ s)
⊢ piPremeasure m (Set.pi univ s) = ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
simp [h, piPremeasure]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : Set ((i : ι) → α i)
⊢ piPremeasure m (Set.pi univ fun i => eval i '' s) = piPremeasure m s
[PROOFSTEP]
simp only [eval, piPremeasure_pi']
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
s : Set ((i : ι) → α i)
⊢ ∏ i : ι, ↑(m i) ((fun a => a i) '' s) = piPremeasure m s
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
⊢ ↑(OuterMeasure.pi m) (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
cases' (pi univ s).eq_empty_or_nonempty with h h
[GOAL]
case inl
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h : Set.pi univ s = ∅
⊢ ↑(OuterMeasure.pi m) (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
case inr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h : Set.Nonempty (Set.pi univ s)
⊢ ↑(OuterMeasure.pi m) (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
simp [h]
[GOAL]
case inr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
s : (i : ι) → Set (α i)
h : Set.Nonempty (Set.pi univ s)
⊢ ↑(OuterMeasure.pi m) (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
exact (boundedBy_le _).trans_eq (piPremeasure_pi h)
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
⊢ n ≤ OuterMeasure.pi m ↔
∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
rw [OuterMeasure.pi, le_boundedBy']
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
⊢ (∀ (s : Set ((i : ι) → α i)), Set.Nonempty s → ↑n s ≤ piPremeasure m s) ↔
∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
constructor
[GOAL]
case mp
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
⊢ (∀ (s : Set ((i : ι) → α i)), Set.Nonempty s → ↑n s ≤ piPremeasure m s) →
∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
intro h s hs
[GOAL]
case mp
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
h : ∀ (s : Set ((i : ι) → α i)), Set.Nonempty s → ↑n s ≤ piPremeasure m s
s : (i : ι) → Set (α i)
hs : Set.Nonempty (Set.pi univ s)
⊢ ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
[PROOFSTEP]
refine' (h _ hs).trans_eq (piPremeasure_pi hs)
[GOAL]
case mpr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
⊢ (∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)) →
∀ (s : Set ((i : ι) → α i)), Set.Nonempty s → ↑n s ≤ piPremeasure m s
[PROOFSTEP]
intro h s hs
[GOAL]
case mpr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
h : ∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
s : Set ((i : ι) → α i)
hs : Set.Nonempty s
⊢ ↑n s ≤ piPremeasure m s
[PROOFSTEP]
refine' le_trans (n.mono <| subset_pi_eval_image univ s) (h _ _)
[GOAL]
case mpr
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝ : Fintype ι
m✝ m : (i : ι) → OuterMeasure (α i)
n : OuterMeasure ((i : ι) → α i)
h : ∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑n (Set.pi univ s) ≤ ∏ i : ι, ↑(m i) (s i)
s : Set ((i : ι) → α i)
hs : Set.Nonempty s
⊢ Set.Nonempty (Set.pi univ fun i => eval i '' s)
[PROOFSTEP]
simp [univ_pi_nonempty_iff, hs]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝ : (x : δ) → MeasurableSpace (π x)
l : List δ
μ : (i : δ) → Measure (π i)
⊢ Measure (TProd π l)
[PROOFSTEP]
induction' l with i l ih
[GOAL]
case nil
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
⊢ Measure (TProd π [])
[PROOFSTEP]
exact dirac PUnit.unit
[GOAL]
case cons
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
i : δ
l : List δ
ih : Measure (TProd π l)
⊢ Measure (TProd π (i :: l))
[PROOFSTEP]
have := (μ i).prod (α := π i) ih
[GOAL]
case cons
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
i : δ
l : List δ
ih : Measure (TProd π l)
this : Measure (π i × TProd π l)
⊢ Measure (TProd π (i :: l))
[PROOFSTEP]
exact this
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
l : List δ
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
⊢ SigmaFinite (Measure.tprod l μ)
[PROOFSTEP]
induction l with
| nil => rw [tprod_nil]; infer_instance
| cons i l ih => rw [tprod_cons]; exact @prod.instSigmaFinite _ _ _ _ _ _ ih _
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
l : List δ
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
⊢ SigmaFinite (Measure.tprod l μ)
[PROOFSTEP]
induction l with
| nil => rw [tprod_nil]; infer_instance
| cons i l ih => rw [tprod_cons]; exact @prod.instSigmaFinite _ _ _ _ _ _ ih _
[GOAL]
case nil
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
⊢ SigmaFinite (Measure.tprod [] μ)
[PROOFSTEP]
| nil => rw [tprod_nil]; infer_instance
[GOAL]
case nil
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
⊢ SigmaFinite (Measure.tprod [] μ)
[PROOFSTEP]
rw [tprod_nil]
[GOAL]
case nil
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
⊢ SigmaFinite (dirac PUnit.unit)
[PROOFSTEP]
infer_instance
[GOAL]
case cons
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
i : δ
l : List δ
ih : SigmaFinite (Measure.tprod l μ)
⊢ SigmaFinite (Measure.tprod (i :: l) μ)
[PROOFSTEP]
| cons i l ih => rw [tprod_cons]; exact @prod.instSigmaFinite _ _ _ _ _ _ ih _
[GOAL]
case cons
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
i : δ
l : List δ
ih : SigmaFinite (Measure.tprod l μ)
⊢ SigmaFinite (Measure.tprod (i :: l) μ)
[PROOFSTEP]
rw [tprod_cons]
[GOAL]
case cons
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
i : δ
l : List δ
ih : SigmaFinite (Measure.tprod l μ)
⊢ SigmaFinite (Measure.prod (μ i) (Measure.tprod l μ))
[PROOFSTEP]
exact @prod.instSigmaFinite _ _ _ _ _ _ ih _
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
l : List δ
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
s : (i : δ) → Set (π i)
⊢ ↑↑(Measure.tprod l μ) (Set.tprod l s) = List.prod (List.map (fun i => ↑↑(μ i) (s i)) l)
[PROOFSTEP]
induction' l with i l ih
[GOAL]
case nil
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
s : (i : δ) → Set (π i)
⊢ ↑↑(Measure.tprod [] μ) (Set.tprod [] s) = List.prod (List.map (fun i => ↑↑(μ i) (s i)) [])
[PROOFSTEP]
simp
[GOAL]
case cons
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ✝ : (i : ι) → Measure (α i)
δ : Type u_4
π : δ → Type u_5
inst✝¹ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝ : ∀ (i : δ), SigmaFinite (μ i)
s : (i : δ) → Set (π i)
i : δ
l : List δ
ih : ↑↑(Measure.tprod l μ) (Set.tprod l s) = List.prod (List.map (fun i => ↑↑(μ i) (s i)) l)
⊢ ↑↑(Measure.tprod (i :: l) μ) (Set.tprod (i :: l) s) = List.prod (List.map (fun i => ↑↑(μ i) (s i)) (i :: l))
[PROOFSTEP]
rw [tprod_cons, Set.tprod, prod_prod, map_cons, prod_cons, ih]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : Encodable ι
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ ↑↑(pi' μ) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [pi']
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : Encodable ι
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ ↑↑(map (TProd.elim' (_ : ∀ (x : ι), x ∈ sortedUniv ι)) (Measure.tprod (sortedUniv ι) μ)) (Set.pi univ s) =
∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
simp only [TProd.elim']
-- Porting note: new step
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : Encodable ι
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ ↑↑(map (fun v i => TProd.elim v (_ : i ∈ sortedUniv ι)) (Measure.tprod (sortedUniv ι) μ)) (Set.pi univ s) =
∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
erw [← MeasurableEquiv.piMeasurableEquivTProd_symm_apply, MeasurableEquiv.map_apply,
MeasurableEquiv.piMeasurableEquivTProd_symm_apply, elim_preimage_pi, tprod_tprod _ μ, ← List.prod_toFinset,
sortedUniv_toFinset]
[GOAL]
case _hl
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : Encodable ι
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ Nodup (sortedUniv ι)
[PROOFSTEP]
exact sortedUniv_nodup ι
[GOAL]
case hnd
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : Encodable ι
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ Nodup (sortedUniv ι)
[PROOFSTEP]
exact sortedUniv_nodup ι
[GOAL]
case hnd
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : Encodable ι
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ Nodup (sortedUniv ι)
[PROOFSTEP]
exact sortedUniv_nodup ι
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
⊢ MeasurableSpace.pi ≤ OuterMeasure.caratheodory (OuterMeasure.pi fun i => ↑(μ i))
[PROOFSTEP]
refine' iSup_le _
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
⊢ ∀ (i : ι),
MeasurableSpace.comap (fun b => b i) ((fun a => inst✝ a) i) ≤
OuterMeasure.caratheodory (OuterMeasure.pi fun i => ↑(μ i))
[PROOFSTEP]
intro i s hs
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((a : ι) → α a)
hs : MeasurableSet s
⊢ MeasurableSet s
[PROOFSTEP]
rw [MeasurableSpace.comap] at hs
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((a : ι) → α a)
hs : MeasurableSet s
⊢ MeasurableSet s
[PROOFSTEP]
rcases hs with ⟨s, hs, rfl⟩
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
⊢ MeasurableSet ((fun b => b i) ⁻¹' s)
[PROOFSTEP]
apply boundedBy_caratheodory
[GOAL]
case intro.intro.hs
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
⊢ ∀ (t : Set ((a : ι) → α a)),
piPremeasure (fun i => ↑(μ i)) (t ∩ (fun b => b i) ⁻¹' s) +
piPremeasure (fun i => ↑(μ i)) (t \ (fun b => b i) ⁻¹' s) ≤
piPremeasure (fun i => ↑(μ i)) t
[PROOFSTEP]
intro t
[GOAL]
case intro.intro.hs
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
⊢ piPremeasure (fun i => ↑(μ i)) (t ∩ (fun b => b i) ⁻¹' s) +
piPremeasure (fun i => ↑(μ i)) (t \ (fun b => b i) ⁻¹' s) ≤
piPremeasure (fun i => ↑(μ i)) t
[PROOFSTEP]
simp_rw [piPremeasure]
[GOAL]
case intro.intro.hs
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
⊢ ∏ x : ι, ↑↑(μ x) (eval x '' (t ∩ (fun b => b i) ⁻¹' s)) + ∏ x : ι, ↑↑(μ x) (eval x '' (t \ (fun b => b i) ⁻¹' s)) ≤
∏ x : ι, ↑↑(μ x) (eval x '' t)
[PROOFSTEP]
refine' Finset.prod_add_prod_le' (Finset.mem_univ i) _ _ _
[GOAL]
case intro.intro.hs.refine'_1
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
⊢ ↑↑(μ i) (eval i '' (t ∩ (fun b => b i) ⁻¹' s)) + ↑↑(μ i) (eval i '' (t \ (fun b => b i) ⁻¹' s)) ≤
↑↑(μ i) (eval i '' t)
[PROOFSTEP]
simp [image_inter_preimage, image_diff_preimage, measure_inter_add_diff _ hs, le_refl]
[GOAL]
case intro.intro.hs.refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
⊢ ∀ (j : ι), j ∈ Finset.univ → j ≠ i → ↑↑(μ j) (eval j '' (t ∩ (fun b => b i) ⁻¹' s)) ≤ ↑↑(μ j) (eval j '' t)
[PROOFSTEP]
rintro j - _
[GOAL]
case intro.intro.hs.refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
j : ι
a✝ : j ≠ i
⊢ ↑↑(μ j) (eval j '' (t ∩ (fun b => b i) ⁻¹' s)) ≤ ↑↑(μ j) (eval j '' t)
[PROOFSTEP]
apply mono'
[GOAL]
case intro.intro.hs.refine'_2.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
j : ι
a✝ : j ≠ i
⊢ eval j '' (t ∩ (fun b => b i) ⁻¹' s) ⊆ eval j '' t
[PROOFSTEP]
apply image_subset
[GOAL]
case intro.intro.hs.refine'_2.h.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
j : ι
a✝ : j ≠ i
⊢ t ∩ (fun b => b i) ⁻¹' s ⊆ t
[PROOFSTEP]
apply inter_subset_left
[GOAL]
case intro.intro.hs.refine'_3
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
⊢ ∀ (j : ι), j ∈ Finset.univ → j ≠ i → ↑↑(μ j) (eval j '' (t \ (fun b => b i) ⁻¹' s)) ≤ ↑↑(μ j) (eval j '' t)
[PROOFSTEP]
rintro j - _
[GOAL]
case intro.intro.hs.refine'_3
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
j : ι
a✝ : j ≠ i
⊢ ↑↑(μ j) (eval j '' (t \ (fun b => b i) ⁻¹' s)) ≤ ↑↑(μ j) (eval j '' t)
[PROOFSTEP]
apply mono'
[GOAL]
case intro.intro.hs.refine'_3.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
j : ι
a✝ : j ≠ i
⊢ eval j '' (t \ (fun b => b i) ⁻¹' s) ⊆ eval j '' t
[PROOFSTEP]
apply image_subset
[GOAL]
case intro.intro.hs.refine'_3.h.h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
i : ι
s : Set ((fun i => α i) i)
hs : MeasurableSet s
t : Set ((a : ι) → α a)
j : ι
a✝ : j ≠ i
⊢ t \ (fun b => b i) ⁻¹' s ⊆ t
[PROOFSTEP]
apply diff_subset
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
refine' le_antisymm _ _
[GOAL]
case refine'_1
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) ≤ ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [Measure.pi, toMeasure_apply _ _ (MeasurableSet.pi countable_univ fun i _ => hs i)]
[GOAL]
case refine'_1
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑(OuterMeasure.pi fun i => ↑(μ i)) (Set.pi univ fun i => s i) ≤ ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
apply OuterMeasure.pi_pi_le
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ∏ i : ι, ↑↑(μ i) (s i) ≤ ↑↑(Measure.pi μ) (Set.pi univ s)
[PROOFSTEP]
haveI : Encodable ι := Fintype.toEncodable ι
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
this : Encodable ι
⊢ ∏ i : ι, ↑↑(μ i) (s i) ≤ ↑↑(Measure.pi μ) (Set.pi univ s)
[PROOFSTEP]
simp_rw [← pi'_pi μ s, Measure.pi, toMeasure_apply _ _ (MeasurableSet.pi countable_univ fun i _ => hs i)]
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
this : Encodable ι
⊢ ↑↑(pi' μ) (Set.pi univ s) ≤ ↑(OuterMeasure.pi fun i => ↑(μ i)) (Set.pi univ fun i => s i)
[PROOFSTEP]
suffices (pi' μ).toOuterMeasure ≤ OuterMeasure.pi fun i => (μ i).toOuterMeasure by exact this _
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
this✝ : Encodable ι
this : ↑(pi' μ) ≤ OuterMeasure.pi fun i => ↑(μ i)
⊢ ↑↑(pi' μ) (Set.pi univ s) ≤ ↑(OuterMeasure.pi fun i => ↑(μ i)) (Set.pi univ fun i => s i)
[PROOFSTEP]
exact this _
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
this : Encodable ι
⊢ ↑(pi' μ) ≤ OuterMeasure.pi fun i => ↑(μ i)
[PROOFSTEP]
clear hs s
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
⊢ ↑(pi' μ) ≤ OuterMeasure.pi fun i => ↑(μ i)
[PROOFSTEP]
rw [OuterMeasure.le_pi]
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
⊢ ∀ (s : (i : ι) → Set (α i)), Set.Nonempty (Set.pi univ s) → ↑↑(pi' μ) (Set.pi univ s) ≤ ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
intro s _
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
s : (i : ι) → Set (α i)
a✝ : Set.Nonempty (Set.pi univ s)
⊢ ↑↑(pi' μ) (Set.pi univ s) ≤ ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
exact (pi'_pi μ s).le
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
⊢ FiniteSpanningSetsIn (Measure.pi μ) (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
haveI := fun i => (hμ i).sigmaFinite
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this : ∀ (i : ι), SigmaFinite (μ i)
⊢ FiniteSpanningSetsIn (Measure.pi μ) (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
haveI := Fintype.toEncodable ι
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
⊢ FiniteSpanningSetsIn (Measure.pi μ) (Set.pi univ '' Set.pi univ C)
[PROOFSTEP]
refine' ⟨fun n => Set.pi univ fun i => (hμ i).set ((@decode (ι → ℕ) _ n).iget i), fun n => _, fun n => _, _⟩
[GOAL]
case refine'_1
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
n : ℕ
⊢ (fun n => Set.pi univ fun i => FiniteSpanningSetsIn.set (hμ i) (Option.iget (decode n) i)) n ∈
Set.pi univ '' Set.pi univ C
[PROOFSTEP]
let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
n : ℕ
⊢ ↑↑(Measure.pi μ) ((fun n => Set.pi univ fun i => FiniteSpanningSetsIn.set (hμ i) (Option.iget (decode n) i)) n) < ⊤
[PROOFSTEP]
let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget
[GOAL]
case refine'_3
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
⊢ ⋃ (i : ℕ), (fun n => Set.pi univ fun i => FiniteSpanningSetsIn.set (hμ i) (Option.iget (decode n) i)) i = univ
[PROOFSTEP]
let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget
[GOAL]
case refine'_1
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
n : ℕ
e : ℕ → ι → ℕ := fun n => Option.iget (decode n)
⊢ (fun n => Set.pi univ fun i => FiniteSpanningSetsIn.set (hμ i) (Option.iget (decode n) i)) n ∈
Set.pi univ '' Set.pi univ C
[PROOFSTEP]
refine' mem_image_of_mem _ fun i _ => (hμ i).set_mem _
[GOAL]
case refine'_2
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
n : ℕ
e : ℕ → ι → ℕ := fun n => Option.iget (decode n)
⊢ ↑↑(Measure.pi μ) ((fun n => Set.pi univ fun i => FiniteSpanningSetsIn.set (hμ i) (Option.iget (decode n) i)) n) < ⊤
[PROOFSTEP]
calc
Measure.pi μ (Set.pi univ fun i => (hμ i).set (e n i)) ≤
Measure.pi μ (Set.pi univ fun i => toMeasurable (μ i) ((hμ i).set (e n i))) :=
measure_mono (pi_mono fun i _ => subset_toMeasurable _ _)
_ = ∏ i, μ i (toMeasurable (μ i) ((hμ i).set (e n i))) := (pi_pi_aux μ _ fun i => measurableSet_toMeasurable _ _)
_ = ∏ i, μ i ((hμ i).set (e n i)) := by simp only [measure_toMeasurable]
_ < ∞ := ENNReal.prod_lt_top fun i _ => ((hμ i).finite _).ne
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
n : ℕ
e : ℕ → ι → ℕ := fun n => Option.iget (decode n)
⊢ ∏ i : ι, ↑↑(μ i) (toMeasurable (μ i) (FiniteSpanningSetsIn.set (hμ i) (e n i))) =
∏ i : ι, ↑↑(μ i) (FiniteSpanningSetsIn.set (hμ i) (e n i))
[PROOFSTEP]
simp only [measure_toMeasurable]
[GOAL]
case refine'_3
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hμ : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
this✝ : ∀ (i : ι), SigmaFinite (μ i)
this : Encodable ι
e : ℕ → ι → ℕ := fun n => Option.iget (decode n)
⊢ ⋃ (i : ℕ), (fun n => Set.pi univ fun i => FiniteSpanningSetsIn.set (hμ i) (Option.iget (decode n) i)) i = univ
[PROOFSTEP]
simp_rw [(surjective_decode_iget (ι → ℕ)).iUnion_comp fun x => Set.pi univ fun i => (hμ i).set (x i),
iUnion_univ_pi fun i => (hμ i).set, (hμ _).spanning, Set.pi_univ]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
i : ι
⊢ MeasurableSpace (α i)
[PROOFSTEP]
apply_assumption
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
⊢ Measure.pi μ = μν
[PROOFSTEP]
have h4C : ∀ (i) (s : Set (α i)), s ∈ C i → MeasurableSet s := by intro i s hs; rw [← hC];
exact measurableSet_generateFrom hs
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
⊢ ∀ (i : ι) (s : Set (α i)), s ∈ C i → MeasurableSet s
[PROOFSTEP]
intro i s hs
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
i : ι
s : Set (α i)
hs : s ∈ C i
⊢ MeasurableSet s
[PROOFSTEP]
rw [← hC]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
i : ι
s : Set (α i)
hs : s ∈ C i
⊢ MeasurableSet s
[PROOFSTEP]
exact measurableSet_generateFrom hs
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
h4C : ∀ (i : ι) (s : Set (α i)), s ∈ C i → MeasurableSet s
⊢ Measure.pi μ = μν
[PROOFSTEP]
refine'
(FiniteSpanningSetsIn.pi h3C).ext (generateFrom_eq_pi hC fun i => (h3C i).isCountablySpanning).symm
(IsPiSystem.pi h2C) _
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
h4C : ∀ (i : ι) (s : Set (α i)), s ∈ C i → MeasurableSet s
⊢ ∀ (s : Set ((i : ι) → α i)), (s ∈ Set.pi univ '' Set.pi univ fun i => C i) → ↑↑(Measure.pi μ) s = ↑↑μν s
[PROOFSTEP]
rintro _ ⟨s, hs, rfl⟩
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
h4C : ∀ (i : ι) (s : Set (α i)), s ∈ C i → MeasurableSet s
s : (i : ι) → Set (α i)
hs : s ∈ Set.pi univ fun i => C i
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) = ↑↑μν (Set.pi univ s)
[PROOFSTEP]
rw [mem_univ_pi] at hs
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
h4C : ∀ (i : ι) (s : Set (α i)), s ∈ C i → MeasurableSet s
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), s i ∈ C i
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) = ↑↑μν (Set.pi univ s)
[PROOFSTEP]
haveI := fun i => (h3C i).sigmaFinite
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝¹ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
C : (i : ι) → Set (Set (α i))
hC : ∀ (i : ι), generateFrom (C i) = inst✝ i
h2C : ∀ (i : ι), IsPiSystem (C i)
h3C : (i : ι) → FiniteSpanningSetsIn (μ i) (C i)
μν : Measure ((i : ι) → α i)
h₁ : ∀ (s : (i : ι) → Set (α i)), (∀ (i : ι), s i ∈ C i) → ↑↑μν (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
h4C : ∀ (i : ι) (s : Set (α i)), s ∈ C i → MeasurableSet s
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), s i ∈ C i
this : ∀ (i : ι), SigmaFinite (μ i)
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) = ↑↑μν (Set.pi univ s)
[PROOFSTEP]
simp_rw [h₁ s hs, pi_pi_aux μ s fun i => h4C i _ (hs i)]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
haveI : Encodable ι := Fintype.toEncodable ι
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
s : (i : ι) → Set (α i)
this : Encodable ι
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [← pi'_eq_pi, pi'_pi]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
⊢ ↑↑(Measure.pi μ) univ = ∏ i : ι, ↑↑(μ i) univ
[PROOFSTEP]
rw [← pi_univ, pi_pi μ]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
inst✝ : (i : ι) → MetricSpace (α i)
x : (i : ι) → α i
r : ℝ
hr : 0 < r
⊢ ↑↑(Measure.pi μ) (Metric.ball x r) = ∏ i : ι, ↑↑(μ i) (Metric.ball (x i) r)
[PROOFSTEP]
rw [ball_pi _ hr, pi_pi]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝³ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝² : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
inst✝ : (i : ι) → MetricSpace (α i)
x : (i : ι) → α i
r : ℝ
hr : 0 ≤ r
⊢ ↑↑(Measure.pi μ) (Metric.closedBall x r) = ∏ i : ι, ↑↑(μ i) (Metric.closedBall (x i) r)
[PROOFSTEP]
rw [closedBall_pi _ hr, pi_pi]
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝³ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
inst✝² : (i : ι) → MeasurableSpace (α✝ i)
μ✝ : (i : ι) → Measure (α✝ i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ✝ i)
α : Type u_4
inst✝ : IsEmpty α
β : α → Type u_5
m : (a : α) → MeasurableSpace (β a)
μ : (a : α) → Measure (β a)
x : optParam ((a : α) → β a) fun a => isEmptyElim a
⊢ Measure.pi μ = dirac x
[PROOFSTEP]
haveI : ∀ a, SigmaFinite (μ a) := isEmptyElim
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝³ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
inst✝² : (i : ι) → MeasurableSpace (α✝ i)
μ✝ : (i : ι) → Measure (α✝ i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ✝ i)
α : Type u_4
inst✝ : IsEmpty α
β : α → Type u_5
m : (a : α) → MeasurableSpace (β a)
μ : (a : α) → Measure (β a)
x : optParam ((a : α) → β a) fun a => isEmptyElim a
this : ∀ (a : α), SigmaFinite (μ a)
⊢ Measure.pi μ = dirac x
[PROOFSTEP]
refine' pi_eq fun s _ => _
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝³ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
inst✝² : (i : ι) → MeasurableSpace (α✝ i)
μ✝ : (i : ι) → Measure (α✝ i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ✝ i)
α : Type u_4
inst✝ : IsEmpty α
β : α → Type u_5
m : (a : α) → MeasurableSpace (β a)
μ : (a : α) → Measure (β a)
x : optParam ((a : α) → β a) fun a => isEmptyElim a
this : ∀ (a : α), SigmaFinite (μ a)
s : (i : α) → Set (β i)
x✝ : ∀ (i : α), MeasurableSet (s i)
⊢ ↑↑(dirac x) (Set.pi univ s) = ∏ i : α, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [Fintype.prod_empty, dirac_apply_of_mem]
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝³ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
inst✝² : (i : ι) → MeasurableSpace (α✝ i)
μ✝ : (i : ι) → Measure (α✝ i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ✝ i)
α : Type u_4
inst✝ : IsEmpty α
β : α → Type u_5
m : (a : α) → MeasurableSpace (β a)
μ : (a : α) → Measure (β a)
x : optParam ((a : α) → β a) fun a => isEmptyElim a
this : ∀ (a : α), SigmaFinite (μ a)
s : (i : α) → Set (β i)
x✝ : ∀ (i : α), MeasurableSet (s i)
⊢ x ∈ Set.pi univ s
[PROOFSTEP]
exact isEmptyElim (α := α)
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
s : Set (α i)
hs : ↑↑(μ i) s = 0
⊢ ↑↑(Measure.pi μ) (eval i ⁻¹' s) = 0
[PROOFSTEP]
rcases exists_measurable_superset_of_null hs with ⟨t, hst, _, hμt⟩
[GOAL]
case intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
s : Set (α i)
hs : ↑↑(μ i) s = 0
t : Set (α i)
hst : s ⊆ t
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
⊢ ↑↑(Measure.pi μ) (eval i ⁻¹' s) = 0
[PROOFSTEP]
suffices : Measure.pi μ (eval i ⁻¹' t) = 0
[GOAL]
case intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
s : Set (α i)
hs : ↑↑(μ i) s = 0
t : Set (α i)
hst : s ⊆ t
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
this : ↑↑(Measure.pi μ) (eval i ⁻¹' t) = 0
⊢ ↑↑(Measure.pi μ) (eval i ⁻¹' s) = 0
case this
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
s : Set (α i)
hs : ↑↑(μ i) s = 0
t : Set (α i)
hst : s ⊆ t
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
⊢ ↑↑(Measure.pi μ) (eval i ⁻¹' t) = 0
[PROOFSTEP]
exact measure_mono_null (preimage_mono hst) this
[GOAL]
case this
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
s : Set (α i)
hs : ↑↑(μ i) s = 0
t : Set (α i)
hst : s ⊆ t
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
⊢ ↑↑(Measure.pi μ) (eval i ⁻¹' t) = 0
[PROOFSTEP]
clear! s
[GOAL]
case this
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
t : Set (α i)
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
⊢ ↑↑(Measure.pi μ) (eval i ⁻¹' t) = 0
[PROOFSTEP]
rw [← univ_pi_update_univ, pi_pi]
[GOAL]
case this
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
t : Set (α i)
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
⊢ ∏ i_1 : ι, ↑↑(μ i_1) (update (fun j => univ) i t i_1) = 0
[PROOFSTEP]
apply Finset.prod_eq_zero (Finset.mem_univ i)
[GOAL]
case this
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝² : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝¹ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝ : ∀ (i : ι), SigmaFinite (μ i)
i : ι
t : Set (α i)
left✝ : MeasurableSet t
hμt : ↑↑(μ i) t = 0
⊢ ↑↑(μ i) (update (fun j => univ) i t i) = 0
[PROOFSTEP]
simp [hμt]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f : (i : ι) → α i
⊢ (Set.pi univ fun i => Iio (f i)) =ᶠ[ae (Measure.pi μ)] Iic f
[PROOFSTEP]
rw [← pi_univ_Iic]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f : (i : ι) → α i
⊢ (Set.pi univ fun i => Iio (f i)) =ᶠ[ae (Measure.pi μ)] Set.pi univ fun i => Iic (f i)
[PROOFSTEP]
exact pi_Iio_ae_eq_pi_Iic
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f : (i : ι) → α i
⊢ (Set.pi univ fun i => Ioi (f i)) =ᶠ[ae (Measure.pi μ)] Ici f
[PROOFSTEP]
rw [← pi_univ_Ici]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f : (i : ι) → α i
⊢ (Set.pi univ fun i => Ioi (f i)) =ᶠ[ae (Measure.pi μ)] Set.pi univ fun i => Ici (f i)
[PROOFSTEP]
exact pi_Ioi_ae_eq_pi_Ici
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f g : (i : ι) → α i
⊢ (Set.pi univ fun i => Ioo (f i) (g i)) =ᶠ[ae (Measure.pi μ)] Icc f g
[PROOFSTEP]
rw [← pi_univ_Icc]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f g : (i : ι) → α i
⊢ (Set.pi univ fun i => Ioo (f i) (g i)) =ᶠ[ae (Measure.pi μ)] Set.pi univ fun i => Icc (f i) (g i)
[PROOFSTEP]
exact pi_Ioo_ae_eq_pi_Icc
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f g : (i : ι) → α i
⊢ (Set.pi univ fun i => Ioc (f i) (g i)) =ᶠ[ae (Measure.pi μ)] Icc f g
[PROOFSTEP]
rw [← pi_univ_Icc]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f g : (i : ι) → α i
⊢ (Set.pi univ fun i => Ioc (f i) (g i)) =ᶠ[ae (Measure.pi μ)] Set.pi univ fun i => Icc (f i) (g i)
[PROOFSTEP]
exact pi_Ioc_ae_eq_pi_Icc
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f g : (i : ι) → α i
⊢ (Set.pi univ fun i => Ico (f i) (g i)) =ᶠ[ae (Measure.pi μ)] Icc f g
[PROOFSTEP]
rw [← pi_univ_Icc]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → PartialOrder (α i)
inst✝ : ∀ (i : ι), NoAtoms (μ i)
f g : (i : ι) → α i
⊢ (Set.pi univ fun i => Ico (f i) (g i)) =ᶠ[ae (Measure.pi μ)] Set.pi univ fun i => Icc (f i) (g i)
[PROOFSTEP]
exact pi_Ico_ae_eq_pi_Icc
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsLocallyFiniteMeasure (μ i)
⊢ IsLocallyFiniteMeasure (Measure.pi μ)
[PROOFSTEP]
refine' ⟨fun x => _⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsLocallyFiniteMeasure (μ i)
x : (i : ι) → α i
⊢ FiniteAtFilter (Measure.pi μ) (𝓝 x)
[PROOFSTEP]
choose s hxs ho hμ using fun i => (μ i).exists_isOpen_measure_lt_top (x i)
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsLocallyFiniteMeasure (μ i)
x : (i : ι) → α i
s : (i : ι) → Set (α i)
hxs : ∀ (i : ι), x i ∈ s i
ho : ∀ (i : ι), IsOpen (s i)
hμ : ∀ (i : ι), ↑↑(μ i) (s i) < ⊤
⊢ FiniteAtFilter (Measure.pi μ) (𝓝 x)
[PROOFSTEP]
refine' ⟨pi univ s, set_pi_mem_nhds finite_univ fun i _ => IsOpen.mem_nhds (ho i) (hxs i), _⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsLocallyFiniteMeasure (μ i)
x : (i : ι) → α i
s : (i : ι) → Set (α i)
hxs : ∀ (i : ι), x i ∈ s i
ho : ∀ (i : ι), IsOpen (s i)
hμ : ∀ (i : ι), ↑↑(μ i) (s i) < ⊤
⊢ ↑↑(Measure.pi μ) (Set.pi univ s) < ⊤
[PROOFSTEP]
rw [pi_pi]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsLocallyFiniteMeasure (μ i)
x : (i : ι) → α i
s : (i : ι) → Set (α i)
hxs : ∀ (i : ι), x i ∈ s i
ho : ∀ (i : ι), IsOpen (s i)
hμ : ∀ (i : ι), ↑↑(μ i) (s i) < ⊤
⊢ ∏ i : ι, ↑↑(μ i) (s i) < ⊤
[PROOFSTEP]
exact ENNReal.prod_lt_top fun i _ => (hμ i).ne
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulLeftInvariant (μ i)
⊢ IsMulLeftInvariant (Measure.pi μ)
[PROOFSTEP]
refine' ⟨fun v => (pi_eq fun s hs => _).symm⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulLeftInvariant (μ i)
v : (i : ι) → α i
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑↑(map (fun x => v * x) (Measure.pi μ)) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [map_apply (measurable_const_mul _) (MeasurableSet.univ_pi hs),
show (· * ·) v ⁻¹' univ.pi s = univ.pi fun i => (· * ·) (v i) ⁻¹' s i by rfl, pi_pi]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulLeftInvariant (μ i)
v : (i : ι) → α i
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ (fun x x_1 => x * x_1) v ⁻¹' Set.pi univ s = Set.pi univ fun i => (fun x x_1 => x * x_1) (v i) ⁻¹' s i
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulLeftInvariant (μ i)
v : (i : ι) → α i
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ∏ i : ι, ↑↑(μ i) ((fun x x_1 => x * x_1) (v i) ⁻¹' s i) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
simp_rw [measure_preimage_mul]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulRightInvariant (μ i)
⊢ IsMulRightInvariant (Measure.pi μ)
[PROOFSTEP]
refine' ⟨fun v => (pi_eq fun s hs => _).symm⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulRightInvariant (μ i)
v : (i : ι) → α i
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑↑(map (fun x => x * v) (Measure.pi μ)) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [map_apply (measurable_mul_const _) (MeasurableSet.univ_pi hs),
show (· * v) ⁻¹' univ.pi s = univ.pi fun i => (· * v i) ⁻¹' s i by rfl, pi_pi]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulRightInvariant (μ i)
v : (i : ι) → α i
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ (fun x => x * v) ⁻¹' Set.pi univ s = Set.pi univ fun i => (fun x => x * v i) ⁻¹' s i
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableMul (α i)
inst✝ : ∀ (i : ι), IsMulRightInvariant (μ i)
v : (i : ι) → α i
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ∏ i : ι, ↑↑(μ i) ((fun x => x * v i) ⁻¹' s i) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
simp_rw [measure_preimage_mul_right]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableInv (α i)
inst✝ : ∀ (i : ι), IsInvInvariant (μ i)
⊢ IsInvInvariant (Measure.pi μ)
[PROOFSTEP]
refine' ⟨(Measure.pi_eq fun s hs => _).symm⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableInv (α i)
inst✝ : ∀ (i : ι), IsInvInvariant (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑↑(Measure.inv (Measure.pi μ)) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
have A : Inv.inv ⁻¹' pi univ s = Set.pi univ fun i => Inv.inv ⁻¹' s i := by ext; simp
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableInv (α i)
inst✝ : ∀ (i : ι), IsInvInvariant (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
⊢ Inv.inv ⁻¹' Set.pi univ s = Set.pi univ fun i => Inv.inv ⁻¹' s i
[PROOFSTEP]
ext
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableInv (α i)
inst✝ : ∀ (i : ι), IsInvInvariant (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
x✝ : (i : ι) → α i
⊢ x✝ ∈ Inv.inv ⁻¹' Set.pi univ s ↔ x✝ ∈ Set.pi univ fun i => Inv.inv ⁻¹' s i
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁵ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝⁴ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝³ : ∀ (i : ι), SigmaFinite (μ i)
inst✝² : (i : ι) → Group (α i)
inst✝¹ : ∀ (i : ι), MeasurableInv (α i)
inst✝ : ∀ (i : ι), IsInvInvariant (μ i)
s : (i : ι) → Set (α i)
hs : ∀ (i : ι), MeasurableSet (s i)
A : Inv.inv ⁻¹' Set.pi univ s = Set.pi univ fun i => Inv.inv ⁻¹' s i
⊢ ↑↑(Measure.inv (Measure.pi μ)) (Set.pi univ s) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
simp_rw [Measure.inv, Measure.map_apply measurable_inv (MeasurableSet.univ_pi hs), A, pi_pi, measure_preimage_inv]
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
⊢ IsOpenPosMeasure (Measure.pi μ)
[PROOFSTEP]
constructor
[GOAL]
case open_pos
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
⊢ ∀ (U : Set ((i : ι) → α i)), IsOpen U → Set.Nonempty U → ↑↑(Measure.pi μ) U ≠ 0
[PROOFSTEP]
rintro U U_open ⟨a, ha⟩
[GOAL]
case open_pos.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
U : Set ((i : ι) → α i)
U_open : IsOpen U
a : (i : ι) → α i
ha : a ∈ U
⊢ ↑↑(Measure.pi μ) U ≠ 0
[PROOFSTEP]
obtain ⟨s, ⟨hs, hsU⟩⟩ := isOpen_pi_iff'.1 U_open a ha
[GOAL]
case open_pos.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
U : Set ((i : ι) → α i)
U_open : IsOpen U
a : (i : ι) → α i
ha : a ∈ U
s : (a : ι) → Set (α a)
hs : ∀ (a_1 : ι), IsOpen (s a_1) ∧ a a_1 ∈ s a_1
hsU : Set.pi univ s ⊆ U
⊢ ↑↑(Measure.pi μ) U ≠ 0
[PROOFSTEP]
refine' ne_of_gt (lt_of_lt_of_le _ (measure_mono hsU))
[GOAL]
case open_pos.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
U : Set ((i : ι) → α i)
U_open : IsOpen U
a : (i : ι) → α i
ha : a ∈ U
s : (a : ι) → Set (α a)
hs : ∀ (a_1 : ι), IsOpen (s a_1) ∧ a a_1 ∈ s a_1
hsU : Set.pi univ s ⊆ U
⊢ 0 < ↑↑(Measure.pi μ) (Set.pi univ s)
[PROOFSTEP]
simp only [pi_pi]
[GOAL]
case open_pos.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
U : Set ((i : ι) → α i)
U_open : IsOpen U
a : (i : ι) → α i
ha : a ∈ U
s : (a : ι) → Set (α a)
hs : ∀ (a_1 : ι), IsOpen (s a_1) ∧ a a_1 ∈ s a_1
hsU : Set.pi univ s ⊆ U
⊢ 0 < ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [CanonicallyOrderedCommSemiring.prod_pos]
[GOAL]
case open_pos.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
U : Set ((i : ι) → α i)
U_open : IsOpen U
a : (i : ι) → α i
ha : a ∈ U
s : (a : ι) → Set (α a)
hs : ∀ (a_1 : ι), IsOpen (s a_1) ∧ a a_1 ∈ s a_1
hsU : Set.pi univ s ⊆ U
⊢ ∀ (i : ι), i ∈ Finset.univ → 0 < ↑↑(μ i) (s i)
[PROOFSTEP]
intro i _
[GOAL]
case open_pos.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsOpenPosMeasure (μ i)
U : Set ((i : ι) → α i)
U_open : IsOpen U
a : (i : ι) → α i
ha : a ∈ U
s : (a : ι) → Set (α a)
hs : ∀ (a_1 : ι), IsOpen (s a_1) ∧ a a_1 ∈ s a_1
hsU : Set.pi univ s ⊆ U
i : ι
a✝ : i ∈ Finset.univ
⊢ 0 < ↑↑(μ i) (s i)
[PROOFSTEP]
apply (hs i).1.measure_pos (μ i) ⟨a i, (hs i).2⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
⊢ IsFiniteMeasureOnCompacts (Measure.pi μ)
[PROOFSTEP]
constructor
[GOAL]
case lt_top_of_isCompact
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
⊢ ∀ ⦃K : Set ((i : ι) → α i)⦄, IsCompact K → ↑↑(Measure.pi μ) K < ⊤
[PROOFSTEP]
intro K hK
[GOAL]
case lt_top_of_isCompact
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
K : Set ((i : ι) → α i)
hK : IsCompact K
⊢ ↑↑(Measure.pi μ) K < ⊤
[PROOFSTEP]
suffices Measure.pi μ (Set.univ.pi fun j => Function.eval j '' K) < ⊤ by
exact lt_of_le_of_lt (measure_mono (univ.subset_pi_eval_image K)) this
[GOAL]
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
K : Set ((i : ι) → α i)
hK : IsCompact K
this : ↑↑(Measure.pi μ) (Set.pi univ fun j => eval j '' K) < ⊤
⊢ ↑↑(Measure.pi μ) K < ⊤
[PROOFSTEP]
exact lt_of_le_of_lt (measure_mono (univ.subset_pi_eval_image K)) this
[GOAL]
case lt_top_of_isCompact
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
K : Set ((i : ι) → α i)
hK : IsCompact K
⊢ ↑↑(Measure.pi μ) (Set.pi univ fun j => eval j '' K) < ⊤
[PROOFSTEP]
rw [Measure.pi_pi]
[GOAL]
case lt_top_of_isCompact
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
K : Set ((i : ι) → α i)
hK : IsCompact K
⊢ ∏ i : ι, ↑↑(μ i) (eval i '' K) < ⊤
[PROOFSTEP]
refine' WithTop.prod_lt_top _
[GOAL]
case lt_top_of_isCompact
ι : Type u_1
ι' : Type u_2
α : ι → Type u_3
inst✝⁴ : Fintype ι
m : (i : ι) → OuterMeasure (α i)
inst✝³ : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝² : ∀ (i : ι), SigmaFinite (μ i)
inst✝¹ : (i : ι) → TopologicalSpace (α i)
inst✝ : ∀ (i : ι), IsFiniteMeasureOnCompacts (μ i)
K : Set ((i : ι) → α i)
hK : IsCompact K
⊢ ∀ (i : ι), i ∈ Finset.univ → ↑↑(μ i) (eval i '' K) ≠ ⊤
[PROOFSTEP]
exact fun i _ => ne_of_lt (IsCompact.measure_lt_top (IsCompact.image hK (continuous_apply i)))
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝³ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝² : Fintype ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
p : ι → Prop
inst✝ : DecidablePred p
⊢ MeasurePreserving ↑(MeasurableEquiv.piEquivPiSubtypeProd α p)
[PROOFSTEP]
set e := (MeasurableEquiv.piEquivPiSubtypeProd α p).symm
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝³ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝² : Fintype ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
p : ι → Prop
inst✝ : DecidablePred p
e : ((i : Subtype p) → α ↑i) × ((i : { i // ¬p i }) → α ↑i) ≃ᵐ ((i : ι) → α i) :=
MeasurableEquiv.symm (MeasurableEquiv.piEquivPiSubtypeProd α p)
⊢ MeasurePreserving ↑(MeasurableEquiv.piEquivPiSubtypeProd α p)
[PROOFSTEP]
refine' MeasurePreserving.symm e _
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝³ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝² : Fintype ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
p : ι → Prop
inst✝ : DecidablePred p
e : ((i : Subtype p) → α ↑i) × ((i : { i // ¬p i }) → α ↑i) ≃ᵐ ((i : ι) → α i) :=
MeasurableEquiv.symm (MeasurableEquiv.piEquivPiSubtypeProd α p)
⊢ MeasurePreserving ↑e
[PROOFSTEP]
refine' ⟨e.measurable, (pi_eq fun s _ => _).symm⟩
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝³ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝² : Fintype ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
p : ι → Prop
inst✝ : DecidablePred p
e : ((i : Subtype p) → α ↑i) × ((i : { i // ¬p i }) → α ↑i) ≃ᵐ ((i : ι) → α i) :=
MeasurableEquiv.symm (MeasurableEquiv.piEquivPiSubtypeProd α p)
s : (i : ι) → Set (α i)
x✝ : ∀ (i : ι), MeasurableSet (s i)
⊢ ↑↑(Measure.map (↑e) (Measure.prod (Measure.pi fun i => μ ↑i) (Measure.pi fun i => μ ↑i))) (Set.pi univ s) =
∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
have : e ⁻¹' pi univ s = (pi univ fun i : { i // p i } => s i) ×ˢ pi univ fun i : { i // ¬p i } => s i :=
Equiv.preimage_piEquivPiSubtypeProd_symm_pi p s
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝³ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝² : Fintype ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
p : ι → Prop
inst✝ : DecidablePred p
e : ((i : Subtype p) → α ↑i) × ((i : { i // ¬p i }) → α ↑i) ≃ᵐ ((i : ι) → α i) :=
MeasurableEquiv.symm (MeasurableEquiv.piEquivPiSubtypeProd α p)
s : (i : ι) → Set (α i)
x✝ : ∀ (i : ι), MeasurableSet (s i)
this : ↑e ⁻¹' Set.pi univ s = (Set.pi univ fun i => s ↑i) ×ˢ Set.pi univ fun i => s ↑i
⊢ ↑↑(Measure.map (↑e) (Measure.prod (Measure.pi fun i => μ ↑i) (Measure.pi fun i => μ ↑i))) (Set.pi univ s) =
∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
rw [e.map_apply, this, prod_prod, pi_pi, pi_pi]
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝³ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝² : Fintype ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
inst✝¹ : ∀ (i : ι), SigmaFinite (μ i)
p : ι → Prop
inst✝ : DecidablePred p
e : ((i : Subtype p) → α ↑i) × ((i : { i // ¬p i }) → α ↑i) ≃ᵐ ((i : ι) → α i) :=
MeasurableEquiv.symm (MeasurableEquiv.piEquivPiSubtypeProd α p)
s : (i : ι) → Set (α i)
x✝ : ∀ (i : ι), MeasurableSet (s i)
this : ↑e ⁻¹' Set.pi univ s = (Set.pi univ fun i => s ↑i) ×ˢ Set.pi univ fun i => s ↑i
⊢ (∏ i : Subtype p, ↑↑(μ ↑i) (s ↑i)) * ∏ i : { i // ¬p i }, ↑↑(μ ↑i) (s ↑i) = ∏ i : ι, ↑↑(μ i) (s i)
[PROOFSTEP]
exact Fintype.prod_subtype_mul_prod_subtype p fun i => μ i (s i)
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
n : ℕ
α : Fin (n + 1) → Type u
m : (i : Fin (n + 1)) → MeasurableSpace (α i)
μ : (i : Fin (n + 1)) → Measure (α i)
inst✝ : ∀ (i : Fin (n + 1)), SigmaFinite (μ i)
i : Fin (n + 1)
⊢ MeasurePreserving ↑(MeasurableEquiv.piFinSuccAboveEquiv α i)
[PROOFSTEP]
set e := (MeasurableEquiv.piFinSuccAboveEquiv α i).symm
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
n : ℕ
α : Fin (n + 1) → Type u
m : (i : Fin (n + 1)) → MeasurableSpace (α i)
μ : (i : Fin (n + 1)) → Measure (α i)
inst✝ : ∀ (i : Fin (n + 1)), SigmaFinite (μ i)
i : Fin (n + 1)
e : α i × ((j : Fin n) → α (Fin.succAbove i j)) ≃ᵐ ((j : Fin (n + 1)) → α j) :=
MeasurableEquiv.symm (MeasurableEquiv.piFinSuccAboveEquiv α i)
⊢ MeasurePreserving ↑(MeasurableEquiv.piFinSuccAboveEquiv α i)
[PROOFSTEP]
refine' MeasurePreserving.symm e _
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
n : ℕ
α : Fin (n + 1) → Type u
m : (i : Fin (n + 1)) → MeasurableSpace (α i)
μ : (i : Fin (n + 1)) → Measure (α i)
inst✝ : ∀ (i : Fin (n + 1)), SigmaFinite (μ i)
i : Fin (n + 1)
e : α i × ((j : Fin n) → α (Fin.succAbove i j)) ≃ᵐ ((j : Fin (n + 1)) → α j) :=
MeasurableEquiv.symm (MeasurableEquiv.piFinSuccAboveEquiv α i)
⊢ MeasurePreserving ↑e
[PROOFSTEP]
refine' ⟨e.measurable, (pi_eq fun s _ => _).symm⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
n : ℕ
α : Fin (n + 1) → Type u
m : (i : Fin (n + 1)) → MeasurableSpace (α i)
μ : (i : Fin (n + 1)) → Measure (α i)
inst✝ : ∀ (i : Fin (n + 1)), SigmaFinite (μ i)
i : Fin (n + 1)
e : α i × ((j : Fin n) → α (Fin.succAbove i j)) ≃ᵐ ((j : Fin (n + 1)) → α j) :=
MeasurableEquiv.symm (MeasurableEquiv.piFinSuccAboveEquiv α i)
s : (i : Fin (n + 1)) → Set (α i)
x✝ : ∀ (i : Fin (n + 1)), MeasurableSet (s i)
⊢ ↑↑(Measure.map (↑e) (Measure.prod (μ i) (Measure.pi fun j => μ (Fin.succAbove i j)))) (Set.pi univ s) =
∏ i : Fin (n + 1), ↑↑(μ i) (s i)
[PROOFSTEP]
rw [e.map_apply, i.prod_univ_succAbove _, ← pi_pi, ← prod_prod]
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
n : ℕ
α : Fin (n + 1) → Type u
m : (i : Fin (n + 1)) → MeasurableSpace (α i)
μ : (i : Fin (n + 1)) → Measure (α i)
inst✝ : ∀ (i : Fin (n + 1)), SigmaFinite (μ i)
i : Fin (n + 1)
e : α i × ((j : Fin n) → α (Fin.succAbove i j)) ≃ᵐ ((j : Fin (n + 1)) → α j) :=
MeasurableEquiv.symm (MeasurableEquiv.piFinSuccAboveEquiv α i)
s : (i : Fin (n + 1)) → Set (α i)
x✝ : ∀ (i : Fin (n + 1)), MeasurableSet (s i)
⊢ ↑↑(Measure.prod (μ i) (Measure.pi fun j => μ (Fin.succAbove i j))) (↑e ⁻¹' Set.pi univ s) =
↑↑(Measure.prod (μ i) (Measure.pi fun i_1 => μ (Fin.succAbove i i_1)))
(s i ×ˢ Set.pi univ fun i_1 => s (Fin.succAbove i i_1))
[PROOFSTEP]
congr 1 with ⟨x, f⟩
[GOAL]
case e_a.h.mk
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
n : ℕ
α : Fin (n + 1) → Type u
m : (i : Fin (n + 1)) → MeasurableSpace (α i)
μ : (i : Fin (n + 1)) → Measure (α i)
inst✝ : ∀ (i : Fin (n + 1)), SigmaFinite (μ i)
i : Fin (n + 1)
e : α i × ((j : Fin n) → α (Fin.succAbove i j)) ≃ᵐ ((j : Fin (n + 1)) → α j) :=
MeasurableEquiv.symm (MeasurableEquiv.piFinSuccAboveEquiv α i)
s : (i : Fin (n + 1)) → Set (α i)
x✝ : ∀ (i : Fin (n + 1)), MeasurableSet (s i)
x : α i
f : (j : Fin n) → α (Fin.succAbove i j)
⊢ (x, f) ∈ ↑e ⁻¹' Set.pi univ s ↔ (x, f) ∈ s i ×ˢ Set.pi univ fun i_1 => s (Fin.succAbove i i_1)
[PROOFSTEP]
simp [i.forall_iff_succAbove]
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
⊢ MeasurePreserving ↑(MeasurableEquiv.funUnique α β)
[PROOFSTEP]
set e := MeasurableEquiv.funUnique α β
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
⊢ MeasurePreserving ↑e
[PROOFSTEP]
have : (piPremeasure fun _ : α => μ.toOuterMeasure) = Measure.map e.symm μ :=
by
ext1 s
rw [piPremeasure, Fintype.prod_unique, e.symm.map_apply]
congr 1; exact e.toEquiv.image_eq_preimage s
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
⊢ (piPremeasure fun x => ↑μ) = ↑↑(Measure.map (↑(MeasurableEquiv.symm e)) μ)
[PROOFSTEP]
ext1 s
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
s : Set (α → β)
⊢ piPremeasure (fun x => ↑μ) s = ↑↑(Measure.map (↑(MeasurableEquiv.symm e)) μ) s
[PROOFSTEP]
rw [piPremeasure, Fintype.prod_unique, e.symm.map_apply]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
s : Set (α → β)
⊢ ↑↑μ (eval default '' s) = ↑↑μ (↑(MeasurableEquiv.symm e) ⁻¹' s)
[PROOFSTEP]
congr 1
[GOAL]
case h.e_a
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
s : Set (α → β)
⊢ eval default '' s = ↑(MeasurableEquiv.symm e) ⁻¹' s
[PROOFSTEP]
exact e.toEquiv.image_eq_preimage s
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
this : (piPremeasure fun x => ↑μ) = ↑↑(Measure.map (↑(MeasurableEquiv.symm e)) μ)
⊢ MeasurePreserving ↑e
[PROOFSTEP]
simp only [Measure.pi, OuterMeasure.pi, this, boundedBy_measure, toOuterMeasure_toMeasure]
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
β : Type u
m : MeasurableSpace β
μ : Measure β
α : Type v
inst✝ : Unique α
e : (α → β) ≃ᵐ β := MeasurableEquiv.funUnique α β
this : (piPremeasure fun x => ↑μ) = ↑↑(Measure.map (↑(MeasurableEquiv.symm e)) μ)
⊢ MeasurePreserving ↑(MeasurableEquiv.funUnique α β)
[PROOFSTEP]
exact (e.symm.measurable.measurePreserving _).symm e.symm
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
α : Fin 2 → Type u
m : (i : Fin 2) → MeasurableSpace (α i)
μ : (i : Fin 2) → Measure (α i)
inst✝ : ∀ (i : Fin 2), SigmaFinite (μ i)
⊢ MeasurePreserving ↑(MeasurableEquiv.piFinTwo α)
[PROOFSTEP]
refine' ⟨MeasurableEquiv.measurable _, (Measure.prod_eq fun s t _ _ => _).symm⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
α : Fin 2 → Type u
m : (i : Fin 2) → MeasurableSpace (α i)
μ : (i : Fin 2) → Measure (α i)
inst✝ : ∀ (i : Fin 2), SigmaFinite (μ i)
s : Set (α 0)
t : Set (α 1)
x✝¹ : MeasurableSet s
x✝ : MeasurableSet t
⊢ ↑↑(Measure.map (↑(MeasurableEquiv.piFinTwo α)) (Measure.pi μ)) (s ×ˢ t) = ↑↑(μ 0) s * ↑↑(μ 1) t
[PROOFSTEP]
rw [MeasurableEquiv.map_apply, MeasurableEquiv.piFinTwo_apply, Fin.preimage_apply_01_prod, Measure.pi_pi,
Fin.prod_univ_two]
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
α : Fin 2 → Type u
m : (i : Fin 2) → MeasurableSpace (α i)
μ : (i : Fin 2) → Measure (α i)
inst✝ : ∀ (i : Fin 2), SigmaFinite (μ i)
s : Set (α 0)
t : Set (α 1)
x✝¹ : MeasurableSet s
x✝ : MeasurableSet t
⊢ ↑↑(μ 0) (Fin.cons s (Fin.cons t finZeroElim) 0) * ↑↑(μ 1) (Fin.cons s (Fin.cons t finZeroElim) 1) =
↑↑(μ 0) s * ↑↑(μ 1) t
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
α✝ : ι → Type u_3
inst✝¹ : Fintype ι
m✝ : (i : ι) → OuterMeasure (α✝ i)
α : Type u
m : MeasurableSpace α
μ : Measure α
inst✝ : SigmaFinite μ
⊢ MeasurePreserving ↑MeasurableEquiv.finTwoArrow
[PROOFSTEP]
simpa only [Matrix.vec_single_eq_const, Matrix.vecCons_const] using measurePreserving_finTwoArrow_vec μ μ
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝¹ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝ : IsEmpty ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
⊢ MeasurePreserving ↑(MeasurableEquiv.ofUniqueOfUnique ((i : ι) → α i) Unit)
[PROOFSTEP]
set e := MeasurableEquiv.ofUniqueOfUnique (∀ i, α i) Unit
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝¹ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝ : IsEmpty ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
e : ((i : ι) → α i) ≃ᵐ Unit := MeasurableEquiv.ofUniqueOfUnique ((i : ι) → α i) Unit
⊢ MeasurePreserving ↑e
[PROOFSTEP]
refine' ⟨e.measurable, _⟩
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
α✝ : ι✝ → Type u_3
inst✝¹ : Fintype ι✝
m✝ : (i : ι✝) → OuterMeasure (α✝ i)
ι : Type u
α : ι → Type v
inst✝ : IsEmpty ι
m : (i : ι) → MeasurableSpace (α i)
μ : (i : ι) → Measure (α i)
e : ((i : ι) → α i) ≃ᵐ Unit := MeasurableEquiv.ofUniqueOfUnique ((i : ι) → α i) Unit
⊢ Measure.map (↑e) (Measure.pi μ) = Measure.dirac ()
[PROOFSTEP]
rw [Measure.pi_of_empty, Measure.map_dirac e.measurable]
|
theorem needs_intros (P Q R : Prop) (HR : R) : P → (Q → R) :=
begin
sorry,
end
|
------------------------------------------------------------------------
-- Application of substitutions
------------------------------------------------------------------------
open import Data.Universe.Indexed
module deBruijn.Substitution.Data.Application.Application
{i u e} {Uni : IndexedUniverse i u e} where
import deBruijn.Context; open deBruijn.Context Uni
open import deBruijn.Substitution.Data.Basics
open import deBruijn.Substitution.Data.Map
open import Level using (_⊔_)
import Relation.Binary.PropositionalEquality as P
-- Given an operation which applies substitutions to terms one can
-- define composition of substitutions.
record Application
{t₁} (T₁ : Term-like t₁)
{t₂} (T₂ : Term-like t₂) :
Set (i ⊔ u ⊔ e ⊔ t₁ ⊔ t₂) where
open Term-like T₂ renaming (_⊢_ to _⊢₂_; _≅-⊢_ to _≅-⊢₂_)
field
-- Application of substitutions to terms.
app : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub T₁ ρ̂ → [ T₂ ⟶ T₂ ] ρ̂
-- Post-application of substitutions to terms.
infixl 8 _/⊢_
_/⊢_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ⊢₂ σ → Sub T₁ ρ̂ → Δ ⊢₂ σ /̂ ρ̂
t /⊢ ρ = app ρ · t
-- Reverse composition. (Fits well with post-application.)
infixl 9 _∘_
_∘_ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} →
Sub T₂ ρ̂₁ → Sub T₁ ρ̂₂ → Sub T₂ (ρ̂₁ ∘̂ ρ̂₂)
ρ₁ ∘ ρ₂ = map (app ρ₂) ρ₁
-- Application of multiple substitutions to terms.
app⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Subs T₁ ρ̂ → [ T₂ ⟶ T₂ ] ρ̂
app⋆ = fold [ T₂ ⟶ T₂ ] [id] (λ f ρ → app ρ [∘] f)
infixl 8 _/⊢⋆_
_/⊢⋆_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ⊢₂ σ → Subs T₁ ρ̂ → Δ ⊢₂ σ /̂ ρ̂
t /⊢⋆ ρs = app⋆ ρs · t
-- Some congruence lemmas.
app-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T₁ ρ̂₁}
{Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T₁ ρ̂₂} →
ρ₁ ≅-⇨ ρ₂ → app ρ₁ ≅-⟶ app ρ₂
app-cong P.refl = [ P.refl ]
/⊢-cong :
∀ {Γ₁ Δ₁ σ₁} {t₁ : Γ₁ ⊢₂ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T₁ ρ̂₁}
{Γ₂ Δ₂ σ₂} {t₂ : Γ₂ ⊢₂ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T₁ ρ̂₂} →
t₁ ≅-⊢₂ t₂ → ρ₁ ≅-⇨ ρ₂ → t₁ /⊢ ρ₁ ≅-⊢₂ t₂ /⊢ ρ₂
/⊢-cong P.refl P.refl = P.refl
∘-cong :
∀ {Γ₁ Δ₁ Ε₁} {ρ̂₁₁ : Γ₁ ⇨̂ Δ₁} {ρ̂₂₁ : Δ₁ ⇨̂ Ε₁}
{ρ₁₁ : Sub T₂ ρ̂₁₁} {ρ₂₁ : Sub T₁ ρ̂₂₁}
{Γ₂ Δ₂ Ε₂} {ρ̂₁₂ : Γ₂ ⇨̂ Δ₂} {ρ̂₂₂ : Δ₂ ⇨̂ Ε₂}
{ρ₁₂ : Sub T₂ ρ̂₁₂} {ρ₂₂ : Sub T₁ ρ̂₂₂} →
ρ₁₁ ≅-⇨ ρ₁₂ → ρ₂₁ ≅-⇨ ρ₂₂ → ρ₁₁ ∘ ρ₂₁ ≅-⇨ ρ₁₂ ∘ ρ₂₂
∘-cong P.refl P.refl = P.refl
app⋆-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁}
{Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} →
ρs₁ ≅-⇨⋆ ρs₂ → app⋆ ρs₁ ≅-⟶ app⋆ ρs₂
app⋆-cong P.refl = [ P.refl ]
/⊢⋆-cong :
∀ {Γ₁ Δ₁ σ₁} {t₁ : Γ₁ ⊢₂ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁}
{Γ₂ Δ₂ σ₂} {t₂ : Γ₂ ⊢₂ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} →
t₁ ≅-⊢₂ t₂ → ρs₁ ≅-⇨⋆ ρs₂ → t₁ /⊢⋆ ρs₁ ≅-⊢₂ t₂ /⊢⋆ ρs₂
/⊢⋆-cong P.refl P.refl = P.refl
abstract
-- An unfolding lemma.
▻-∘ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} {σ}
(ρ₁ : Sub T₂ ρ̂₁) (t : Δ ⊢₂ σ / ρ₁) (ρ₂ : Sub T₁ ρ̂₂) →
(ρ₁ ▻⇨[ σ ] t) ∘ ρ₂ ≅-⇨ ρ₁ ∘ ρ₂ ▻⇨[ σ ] t /⊢ ρ₂
▻-∘ ρ₁ t ρ₂ = map-▻ (app ρ₂) ρ₁ t
-- Applying a composed substitution to a variable is equivalent to
-- applying one substitution and then the other.
/∋-∘ : ∀ {Γ Δ Ε σ} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε}
(x : Γ ∋ σ) (ρ₁ : Sub T₂ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) →
x /∋ ρ₁ ∘ ρ₂ ≅-⊢₂ x /∋ ρ₁ /⊢ ρ₂
/∋-∘ x ρ₁ ρ₂ = /∋-map x (app ρ₂) ρ₁
|
% CONVERT SPHERICAL TO CARTESIAN
function [p] = GetCartesianFromSpherical(r,psi,theta)
% This function calculates the relative position from a spherical
% coordinate system that assumes angles are measured from the
% agents heading vector Xref.
% INPUTS:
% range - The objects radial seperation (m)
% azimuth - The objects relative azimuth angle (rad)
% elevation - The objects relative elevation (rad)
% OUTPUTS:
% cartesianPosition - The new 3D position in local coordinates (m)
% DEFINE THE POSITION AS A VECTOR INTERVAL
p = [cos(psi)*cos(theta);...
sin(psi)*cos(theta);...
sin(theta)]*r;
end |
using Documenter, Shuffle
DocMeta.setdocmeta!(
Shuffle,
:DocTestSetup,
quote
using Shuffle
import Random
using Random: MersenneTwister
end;
recursive=true
)
makedocs(
sitename = "Shuffle.jl",
modules = [Shuffle],
pages = [
"Home" => "index.md"
"API Reference" => "reference.md"
],
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true"
)
)
deploydocs(repo = "github.com/Luapulu/Shuffle.jl.git")
|
/-
Copyright (c) 2021 Antoine Labelle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Labelle
-/
import algebra.big_operators.basic
import algebra.big_operators.order
import data.fintype.card
import data.finset.sort
import data.fin.interval
import tactic.linarith
import tactic.by_contra
/-!
# IMO 1994 Q1
Let `m` and `n` be two positive integers.
Let `a₁, a₂, ..., aₘ` be `m` different numbers from the set `{1, 2, ..., n}`
such that for any two indices `i` and `j` with `1 ≤ i ≤ j ≤ m` and `aᵢ + aⱼ ≤ n`,
there exists an index `k` such that `aᵢ + aⱼ = aₖ`.
Show that `(a₁+a₂+...+aₘ)/m ≥ (n+1)/2`
# Sketch of solution
We can order the numbers so that `a₁ ≤ a₂ ≤ ... ≤ aₘ`.
The key idea is to pair the numbers in the sum and show that `aᵢ + aₘ₊₁₋ᵢ ≥ n+1`.
Indeed, if we had `aᵢ + aₘ₊₁₋ᵢ ≤ n`, then `a₁ + aₘ₊₁₋ᵢ, a₂ + aₘ₊₁₋ᵢ, ..., aᵢ + aₘ₊₁₋ᵢ`
would be `m` elements of the set of `aᵢ`'s all larger than `aₘ₊₁₋ᵢ`, which is impossible.
-/
open_locale big_operators
open finset
lemma tedious (m : ℕ) (k : fin (m+1)) : m - (m + (m + 1 - ↑k)) % (m + 1) = ↑k :=
begin
cases k with k hk,
rw [nat.lt_succ_iff,le_iff_exists_add] at hk,
rcases hk with ⟨c, rfl⟩,
have : k + c + (k + c + 1 - k) = c + (k + c + 1),
{ simp only [add_assoc, add_tsub_cancel_left], ring_nf, },
rw [fin.coe_mk, this, nat.add_mod_right, nat.mod_eq_of_lt, nat.add_sub_cancel],
linarith
end
theorem imo1994_q1 (n : ℕ) (m : ℕ) (A : finset ℕ) (hm : A.card = m + 1)
(hrange : ∀ a ∈ A, 0 < a ∧ a ≤ n) (hadd : ∀ (a b ∈ A), a + b ≤ n → a + b ∈ A) :
(m+1)*(n+1) ≤ 2*(∑ x in A, x) :=
begin
set a := order_emb_of_fin A hm, -- We sort the elements of `A`
have ha : ∀ i, a i ∈ A := λ i, order_emb_of_fin_mem A hm i,
set rev := equiv.sub_left (fin.last m), -- `i ↦ m-i`
-- We reindex the sum by fin (m+1)
have : ∑ x in A, x = ∑ i : fin (m+1), a i,
{ convert sum_image (λ x hx y hy, (order_embedding.eq_iff_eq a).1),
rw ←coe_inj, simp },
rw this, clear this,
-- The main proof is a simple calculation by rearranging one of the two sums
suffices hpair : ∀ k ∈ univ, a k + a (rev k) ≥ n+1,
calc 2 * ∑ i : fin (m+1), a i
= ∑ i : fin (m+1), a i + ∑ i : fin (m+1), a i : two_mul _
... = ∑ i : fin (m+1), a i + ∑ i : fin (m+1), a (rev i) : by rw equiv.sum_comp rev
... = ∑ i : fin (m+1), (a i + a (rev i)) : sum_add_distrib.symm
... ≥ ∑ i : fin (m+1), (n+1) : sum_le_sum hpair
... = (m+1) * (n+1) : by simp,
-- It remains to prove the key inequality, by contradiction
rintros k -,
by_contra' h : a k + a (rev k) < n + 1,
-- We exhibit `k+1` elements of `A` greater than `a (rev k)`
set f : fin (m+1) ↪ ℕ := ⟨λ i, a i + a (rev k),
begin
apply injective_of_le_imp_le,
intros i j hij,
rwa [add_le_add_iff_right, a.map_rel_iff] at hij,
end⟩,
-- Proof that the `f i` are greater than `a (rev k)` for `i ≤ k`
have hf : map f (Icc 0 k) ⊆ map a.to_embedding (Ioc (rev k) (fin.last m)),
{ intros x hx,
simp at h hx ⊢,
rcases hx with ⟨i, ⟨hi, rfl⟩⟩,
have h1 : a i + a (fin.last m - k) ≤ n,
{ linarith only [h, a.monotone hi.2] },
have h2 : a i + a (fin.last m - k) ∈ A := hadd _ _ (ha _) (ha _) h1,
rw [←mem_coe, ←range_order_emb_of_fin A hm, set.mem_range] at h2,
cases h2 with j hj,
use j,
refine ⟨⟨_, fin.le_last j⟩, hj⟩,
rw [← a.strict_mono.lt_iff_lt, hj],
simpa using (hrange (a i) (ha i)).1 },
-- A set of size `k+1` embed in one of size `k`, which yields a contradiction
have ineq := card_le_of_subset hf,
simp [fin.coe_sub, tedious] at ineq,
contradiction ,
end
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Impl.Consensus.Types
-- This module defines the LBFT monad used by our (fake/simple,
-- for now) "implementation", along with some utility functions
-- to facilitate reasoning about it.
module LibraBFT.Impl.Util.Util where
open import Optics.All
open import LibraBFT.Impl.Util.RWST ℓ-RoundManager public
----------------
-- LBFT Monad --
----------------
-- Global 'LBFT'; works over the whole state.
LBFT : Set → Set
LBFT = RWST Unit Output RoundManager
LBFT-run : ∀ {A} → LBFT A → RoundManager → (A × RoundManager × List Output)
LBFT-run m = RWST-run m unit
LBFT-post : ∀ {A} → LBFT A → RoundManager → RoundManager
LBFT-post m rm = proj₁ (proj₂ (LBFT-run m rm))
LBFT-outs : ∀ {A} → LBFT A → RoundManager → List Output
LBFT-outs m rm = proj₂ (proj₂ (LBFT-run m rm))
-- Local 'LBFT' monad; which operates only over the part of
-- the state that /depends/ on the ec; not the part
-- of the state that /defines/ the ec.
--
-- This is very convenient to define functions that
-- do not alter the ec.
LBFT-ec : EpochConfig → Set → Set
LBFT-ec ec = RWST Unit Output (RoundManagerWithEC ec)
-- Lifting a function that does not alter the pieces that
-- define the epoch config is easy
liftEC : {A : Set}(f : ∀ ec → LBFT-ec ec A) → LBFT A
liftEC f = rwst λ _ st
→ let ec = α-EC (₋rmEC st , ₋rmEC-correct st)
res , stec' , acts = RWST-run (f ec) unit (₋rmWithEC st)
in res , record st { ₋rmWithEC = stec' } , acts
-- Type that captures a proof that a computation in the LBFT monad
-- satisfies a given contract.
LBFT-Contract : ∀{A} → LBFT A
→ (RoundManager → Set)
→ (RoundManager → Set)
→ Set
LBFT-Contract f Pre Post =
∀ rm → Pre rm × Post (proj₁ (proj₂ (RWST-run f unit rm)))
-- Because we made RWST work for different level State types, but broke use
-- and modify' because Lens does not support different levels, we define use
-- and modify' here for RoundManager. This will work as long as we can keep
-- RoundManager in Set. If we ever need to make RoundManager at some higher
-- Level, we will have to consider making Lens level-agnostic. Preliminary
-- exploration by @cwjnkins showed this to be somewhat painful in particular
-- around composition, so we are not pursuing it for now.
use : ∀ {A} → Lens RoundManager A → LBFT A
use f = RWST-bind get (RWST-return ∘ (_^∙ f))
modify' : ∀ {A} → Lens RoundManager A → A → LBFT Unit
modify' l val = modify λ x → x [ l := val ]
|
Bluehost Pricing \u2013 What to Expect from Their Plans \u0026 Prices?
Bluehost India vs Bluehost.com \u2013 Why .Com Is Still The Best in 2019?
HostGator vs Bluehost India for 2019 \u2013 Which One Should You Choose?
InMotion Hosting vs BlueHost - Which Hosting Provider is Best?
Bluehost Review 2019: Tested them for 2 years. Here\u0027s what we know.
Bluehost Review 2019 - Are They Secure? Reliable? Fast? Find out more!
Bluehost Optimized Hosting for WordPress Review: Why Use It?
Namecheap Vs Bluehost: Which Provides Better Hosting?
BlueHost Review (2019) - Really The Best Host for WordPress?
SiteGround vs Bluehost Review 2019: Who is The Winner [Hosting Race]?
Bluehost Review (2019): Is Bluehost Just Cheap, Or Good Too?
Bluehost vs GoDaddy: (April 2019) Who\u0027s the Winner? Look Inside!
BlueHost Review - Shoul You Choose BlueHost.com for Business?
Hostinger Review: Is This European Web Host Any Good? |
import SnocList
total
isSuffix : Eq a => List a -> List a -> Bool
isSuffix input1 input2 with (snocList input1)
isSuffix [] input2 | Empty = True
isSuffix (xs ++ [x]) input2 | (Snoc xs_rec) with (snocList input2)
isSuffix (xs ++ [x]) [] | (Snoc xs_rec) | Empty = False
isSuffix (xs ++ [x]) (ys ++ [y]) | (Snoc xs_rec) | (Snoc ys_rec)
= if x == y then isSuffix xs ys | xs_rec | ys_rec
else False
|
-----------------------------------------------------------
-- |
-- module: Math.Complex
-- copyright: (c) 2017 HE, Tao
-- license: MIT
-- maintainer: [email protected]
--
-- Coordinate `Data.Complex` with foundation's numeric and primitive type support.
--
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UnboxedTuples #-}
module Math.Complex
( Complex (..)
, conjugate
) where
import Foundation
import Foundation.Class.Storable
import Foundation.Primitive
import Data.Complex (Complex(..), conjugate)
import GHC.Exts
instance Additive a => Additive (Complex a) where
azero = azero :+ azero
(a :+ b) + (c :+ d) = (a + c) :+ (b + d)
instance (Subtractive a, Difference a ~ a) => Subtractive (Complex a) where
type Difference (Complex a) = (Complex a)
(a :+ b) - (c :+ d) = (a - c) :+ (b - d)
instance (Additive a, Subtractive a, Difference a ~ a, Multiplicative a) => Multiplicative (Complex a) where
midentity = midentity :+ azero
(a :+ b) * (c :+ d) = (a * c - b * d) :+ (b * c + a * d)
instance (Additive a, Subtractive a, Difference a ~ a, Divisible a) => Divisible (Complex a) where
(a :+ b) / (c :+ d) = ((a * c + b * d) / (c * c + d * d)) :+ ((b * c - a * d) / (c * c + d * d))
offsetComplex :: Offset (Complex a) -> (# Int#, Int# #)
offsetComplex !(Offset (I# i)) = (# n, n +# 1# #)
where !n = uncheckedIShiftL# i 1#
{-# INLINE offsetComplex #-}
instance PrimType (Complex Float) where
primSizeInBytes _ = primSizeInBytes (Proxy :: Proxy Float) + primSizeInBytes (Proxy :: Proxy Float)
{-# INLINE primSizeInBytes #-}
primShiftToBytes _ = 3 -- TODO may be wrong
{-# INLINE primShiftToBytes #-}
primBaUIndex ba n = F# (indexFloatArray# ba n1) :+ F# (indexFloatArray# ba n2)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primBaUIndex #-}
primMbaURead mba n = primitive $ \s1 -> let !(# s2, r1 #) = readFloatArray# mba n1 s1
!(# s3, r2 #) = readFloatArray# mba n2 s2
in (# s3, F# r1 :+ F# r2 #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primMbaURead #-}
primMbaUWrite mba n ((F# w1) :+ (F# w2)) = primitive $ \s1 -> let !s2 = writeFloatArray# mba n1 w1 s1
in (# writeFloatArray# mba n2 w2 s2, () #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primMbaUWrite #-}
primAddrIndex addr n = F# (indexFloatOffAddr# addr n1) :+ F# (indexFloatOffAddr# addr n2)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primAddrIndex #-}
primAddrRead addr n = primitive $ \s1 -> let !(# s2, r1 #) = readFloatOffAddr# addr n1 s1
!(# s3, r2 #) = readFloatOffAddr# addr n2 s2
in (# s3, F# r1 :+ F# r2 #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primAddrRead #-}
primAddrWrite addr n ((F# w1) :+ (F# w2)) = primitive $ \s1 -> let !s2 = writeFloatOffAddr# addr n1 w1 s1
in (# writeFloatOffAddr# addr n2 w2 s2, () #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primAddrWrite #-}
instance PrimType (Complex Double) where
primSizeInBytes _ = primSizeInBytes (Proxy :: Proxy Double) + primSizeInBytes (Proxy :: Proxy Double)
{-# INLINE primSizeInBytes #-}
primShiftToBytes _ = 5 -- TODO may be wrong
{-# INLINE primShiftToBytes #-}
primBaUIndex ba n = D# (indexDoubleArray# ba n1) :+ D# (indexDoubleArray# ba n2)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primBaUIndex #-}
primMbaURead mba n = primitive $ \s1 -> let !(# s2, r1 #) = readDoubleArray# mba n1 s1
!(# s3, r2 #) = readDoubleArray# mba n2 s2
in (# s3, D# r1 :+ D# r2 #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primMbaURead #-}
primMbaUWrite mba n ((D# w1) :+ (D# w2)) = primitive $ \s1 -> let !s2 = writeDoubleArray# mba n1 w1 s1
in (# writeDoubleArray# mba n2 w2 s2, () #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primMbaUWrite #-}
primAddrIndex addr n = D# (indexDoubleOffAddr# addr n1) :+ D# (indexDoubleOffAddr# addr n2)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primAddrIndex #-}
primAddrRead addr n = primitive $ \s1 -> let !(# s2, r1 #) = readDoubleOffAddr# addr n1 s1
!(# s3, r2 #) = readDoubleOffAddr# addr n2 s2
in (# s3, D# r1 :+ D# r2 #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primAddrRead #-}
primAddrWrite addr n ((D# w1) :+ (D# w2)) = primitive $ \s1 -> let !s2 = writeDoubleOffAddr# addr n1 w1 s1
in (# writeDoubleOffAddr# addr n2 w2 s2, () #)
where !(# n1, n2 #) = offsetComplex n
{-# INLINE primAddrWrite #-}
instance Storable (Complex Float) where
peek (Ptr addr) = primAddrRead addr (Offset 0)
poke (Ptr addr) = primAddrWrite addr (Offset 0)
instance Storable (Complex Double) where
peek (Ptr addr) = primAddrRead addr (Offset 0)
poke (Ptr addr) = primAddrWrite addr (Offset 0)
instance StorableFixed (Complex Float) where
size _ = size (Proxy :: Proxy Float) + size (Proxy :: Proxy Float)
alignment _ = alignment (Proxy :: Proxy Float)
instance StorableFixed (Complex Double) where
size _ = size (Proxy :: Proxy Double) + size (Proxy :: Proxy Double)
alignment _ = alignment (Proxy :: Proxy Double)
|
using Plots
using Statistics, LinearAlgebra, Random
Random.seed!(1)
using Robotlib, StaticArrays, Test
import Robotlib: Rt2T, T2R, T2t, I4
# include(joinpath(dirname(@__FILE__),"..","src","calibNAXP.jl"))
const TM = SMatrix{4,4,Float64,16}
mutable struct Plane{T1,T2,T3,T4,T5}
N::T1
N1::T2
d::T3
Pn::T4
Qn::T5
end
function generateRandomPlane(no)
if no == 1
N_RB = [1, 0, 0]
elseif no == 2
N_RB = [0, 1, 0]
elseif no == 3
N_RB = [0, 0, 1]
else
N_RB = normalize(randn(3)) # Normal of calibration plane, given in RB
end
d_RB = 1 # abs(0.001*randn);
Pn = N_RB * N_RB' # Projection matrix onto normal
Qn = I - Pn # Projection matrix onto plane
Plane(N_RB, [N_RB; 1], d_RB, Pn, Qn)
end
function generateRandomPoses(N_poses, σₙ, T_TF_S, plane)
LN_S = [0, 0, 1] # Normal of laser plane in sensor frame
N_RB = plane.N
d_RB = plane.d
T_RB_TF = Array{Float64}(undef, 4, 4, N_poses)
lines_RB = zeros(3, N_poses)
lines_S = zeros(3, N_poses)
points_RB = zeros(3, N_poses)
points_S = zeros(4, N_poses)
i = 1
while i <= N_poses
T_RB_TF[:, :, i] = Rt2T(
rpy2R(1.5 * randn(), 1.5 * randn(), 1.5 * randn()),
0.6 * randn(3) + 2 * N_RB,
)
T_RB_S = T_RB_TF[:, :, i] * T_TF_S |> TM
LN_RB = T2R(T_RB_S) * LN_S
intersection_line_RB = normalize(cross(N_RB, LN_RB))
intersection_line_S = inv(T2R(T_RB_S)) * intersection_line_RB
lines_RB[:, i] = intersection_line_RB
lines_S[:, i] = intersection_line_S
laser_orig_RB = T_RB_S[1:3, 4]
laser_y_RB = T_RB_S[1:3, 2]
λ = (d_RB - N_RB'laser_orig_RB) / (N_RB'laser_y_RB)
# λ is the distance from laser origin to plane, should be positive and small to be realistic, also, the angle with the plane normal should not be too large. In paper, the following (slightly unrealistic) condition was used
# if abs(λ) > 2
if abs(λ) > 0.2 || λ < 0 || (180 / pi .* acos(intersection_line_S[2])) > 120
continue
end
points_RB[:, i] = laser_orig_RB + λ * laser_y_RB
points_S[:, i] = inv(T_RB_S) * [points_RB[:, i]; 1]
i += 1
end
points_S = points_S[1:3, :]
points_S .+= σₙ * randn(size(points_S))
# Verify poses
ei = eigen(cov(points_RB'))
nhat_points = ei.vectors[:, 1]
V = eigen(cov(lines_RB')).vectors
nhat_lines = V[:, 1]
if 1 - abs(nhat_points'nhat_lines) > 0.001 || ei.values[1, 1] > 1e-5
@warn("Something is wrong")
@show 1 - abs(nhat_points'nhat_lines), ei.values[1, 1]
end
points = zeros(4, N_poses)
for i = 1:N_poses
T_RB_S = T_RB_TF[:, :, i] * T_TF_S |> TM
# points(:,end+1) = T_RB_S*[(points_S[:,i]);1];
points[:, i] = T_RB_S * [points_S[:, i]; 1]
# points(:,end+1) = inv(T_RB_S)*[(points_S[:,i] - 0.01*lines_S[:,i]);1];
end
if any(abs.(points[1:3, :] - points_RB) .> 1e-2)
@warn("Something is wrong 2")
end
points_S, lines_S, T_RB_TF
end
MC = 10 # In paper 100
N_planes = 3 # In paper 3
iters = 80 # In paper 30
N_poses = 20 # In paper 10
σₙ = 5e-4 # In paper: 5e-4
function run_calib(verbose = false)
SSEStart = zeros(MC)
normStart = zeros(MC)
distStart = zeros(MC)
rotStart = zeros(MC)
distEnd = zeros(MC)
rotEnd = zeros(MC)
SSEMC = zeros(MC, iters)
normMC = zeros(MC, iters)
distEnd2 = zeros(MC)
rotEnd2 = zeros(MC)
SSEMC2 = zeros(MC, iters)
normMC2 = zeros(MC, iters)
mc = 1
for mc = 1:MC
@info "MC iterations $(mc)/$(MC)"
# Simulate measurement data
T_TF_S = Rt2T(rpy2R(randn(3)), 0.5 * randn(3)) |> TM #TCP to sensor
points_Sv = Matrix{Float64}[]
lines_Sv = Matrix{Float64}[]
T_RB_TFv = Array{Float64,3}[]
plane = Plane[]
SSE = zeros(N_planes)
verbose && println("Genereating planes and poses")
for j = 1:N_planes
push!(plane, generateRandomPlane(j))
points_St, lines_St, T_RB_TFt =
generateRandomPoses(N_poses, σₙ, T_TF_S, plane[j])
push!(points_Sv, points_St)
push!(lines_Sv, lines_St)
push!(T_RB_TFv, T_RB_TFt)
SSE[j] = Robotlib.pointDiff(T_TF_S, T_RB_TFt, points_St)[1]
end
planes = repeat((1:N_planes)', N_poses)[:]
points_S = cat(points_Sv..., dims = 2)
lines_S = cat(lines_Sv..., dims = 2)
T_RB_TF = cat(T_RB_TFv..., dims = 3)
any(abs.(SSE .> 1e-3)) && @error("Points does not seem to lie on a plane")
dist = [
norm(T_RB_TF[1:4, 4, i] - T_TF_S * [points_S[:, i]; 1])
for i = 1:size(T_RB_TF, 3)
]
# hist(dist,15)
## Calibration
# display('----------------------------------------')
# Generate nominal transformation
T_TF_S_real = copy(T_TF_S)
if true
T_TF_S0 =
Rt2T(rpy2R(60π / 180 * (rand(3) .- 0.5)), 0.4 * (rand(3) .- 0.5)) *
T_TF_S_real
# T_TF_S0 = Rt2T(rpy2R(10π/180*(rand(3).-0.5)),0.1*(rand(3).-0.5))*T_TF_S_real
# T_TF_S0 = rt2tr(rpy2R(2*(rand(1,3).-0.5),'deg'),0.01*(rand(3,1).-0.5))*T_TF_S_real;
else
T_TF_S0 = copy(T_TF_S_real)
end
for j = 1:N_planes
ind = findall(planes .== j)
SSE[j] = sqrt(Robotlib.pointDiff(T_TF_S0, T_RB_TF[:, :, ind], points_S[1:3, ind])[1])
end
SSEStart[mc] = mean(SSE)
normStart[mc] = norm(vec(T_TF_S0 - T_TF_S_real))
distStart[mc] = norm(T_TF_S0[1:3, 4] - T_TF_S_real[1:3, 4])
rotStart[mc] = norm(180 / π * R2rpy(T_TF_S0 \ T_TF_S_real))
# display(T_TF_S_real)
T_TF_S, RMScalibs, ALLcalibs, norms = calibNAXP(
points_S,
lines_S,
T_RB_TF,
T_TF_S0,
planes,
iters,
trueT_TF_S = T_TF_S_real,
variance = (1, 1),
doplot = true,
)
T_TF_S2, RMScalibs2, ALLcalibs2, norms2 = T_TF_S, RMScalibs, ALLcalibs, norms#Robotlib.Calibration.calibNAXP_bootstrap(points_S, lines_S, T_RB_TF, T_TF_S0, planes, iters, trueT_TF_S=T_TF_S_real, nbootstrap=500)
SSEMC[mc, :] = RMScalibs
normMC[mc, :] = norms
if RMScalibs[end] > 1e-2
println("Bad result")
end
distEnd[mc] = norm(T_TF_S[1:3, 4] - T_TF_S_real[1:3, 4])
rotEnd[mc] = norm(180 / π * R2rpy(T_TF_S \ T_TF_S_real))
SSEMC2[mc, :] = RMScalibs2
normMC2[mc, :] = norms2
if RMScalibs2[end] > 1e-2
println("Bad result")
end
distEnd2[mc] = norm(T_TF_S2[1:3, 4] - T_TF_S_real[1:3, 4])
rotEnd2[mc] = norm(180 / π * R2rpy(T_TF_S2 \ T_TF_S_real))
end
SSEStart,
normStart,
distStart,
rotStart,
distEnd,
rotEnd,
SSEMC,
normMC,
distEnd2,
rotEnd2,
SSEMC2,
normMC2
end
# @testset "CalibNAXP" begin
@test isapprox(Robotlib.pointDiff(I4, cat(fill(I4, 5)..., dims = 3), zeros(3, 5))[], 0, atol = 1e-10)
SSEStart, normStart, distStart, rotStart, distEnd, rotEnd, SSEMC, normMC, distEnd2, rotEnd2, SSEMC2, normMC2 = run_calib()
# iters = size(SSEMC,2)
# using StatPlots
# gr(legend=false)
# plot(0:iters,copy([normStart normMC]'),yscale=:log10,c=:black, xlabel="Number of iterations", layout=2, subplot=1)
# # plot!(0:iters,copy([normStart normMC2]'),yscale=:log10,c=:green, subplot=1)
# hline!([σₙ, σₙ],l=:dash, c=:red, subplot=1)
#
# plot!(0:iters,[SSEStart SSEMC]',yscale=:log10,c=:black, xlabel="Number of iterations",title="RMS distance from points to plane [m]", subplot=2)
# # plot!(0:iters,[SSEStart SSEMC2]',c=:green, subplot=2)
# hline!([σₙ σₙ],l=:dash,c=:red, subplot=2)
#
#
# boxplot(["Before" "After" "After WTLS"],([distStart distEnd distEnd2]), title="Distance error [m]", yscale=:log10, layout=2, subplot=1)
# hline!([σₙ σₙ],c=:red)
# boxplot!(["Before" "After" "After WTLS"],([rotStart rotEnd rotEnd2]),title="Rotation error [degree]", yscale=:log10, subplot=2)
# end
|
#pragma once
#include <gsl/gsl>
#include <fmt/format.h>
#include "temple_enums.h"
// Define objHndl as a struct that contains just the handle value
#pragma pack(push, 1)
struct objHndl {
uint64_t handle;
explicit operator bool() const {
return !!handle;
}
objHndl& operator=(uint64_t handle) {
this->handle = handle;
return *this;
}
uint32_t GetHandleLower() const {
return (uint32_t)(handle & 0xffffffff);
}
uint32_t GetHandleUpper() const {
return (uint32_t)((handle >> 32) & 0xffffffff);
}
static objHndl FromUpperAndLower(uint32_t upper, uint32_t lower) {
return{
(((uint64_t) upper) << 32)
| (((uint64_t)lower) & 0xFFFFFFFF)
};
}
static const objHndl null;
};
#pragma pack(pop)
/**
* Compares two object handles for equality. They are equal if their
* handle value is equal.
*/
inline bool operator ==(const objHndl &a, const objHndl &b) {
return a.handle == b.handle;
}
inline bool operator !=(const objHndl &a, const objHndl &b) {
return a.handle != b.handle;
}
inline bool operator <(const objHndl &a, const objHndl &b) {
return a.handle < b.handle;
}
inline bool operator >(const objHndl &a, const objHndl &b) {
return a.handle > b.handle;
}
void format_arg(fmt::BasicFormatter<char> &f, const char *&format_str, const objHndl &s);
namespace std {
template <> struct hash<objHndl> {
size_t operator()(const objHndl &x) const {
return std::hash<uint64_t>()(x.handle);
}
};
}
typedef uint32_t _fieldIdx;
typedef uint32_t _fieldSubIdx;
typedef uint32_t _mapNum;
typedef uint32_t _key;
#pragma pack(push, 8)
enum class ObjectIdKind : uint16_t {
Null = 0,
Prototype = 1,
Permanent = 2,
Positional = 3,
Handle = 0xFFFE,
Blocked = 0xFFFF
};
union ObjectIdBody {
GUID guid;
uint32_t protoId;
objHndl handle;
struct {
int x;
int y;
int tempId;
int mapId;
} pos;
};
struct ObjectId {
ObjectIdKind subtype = ObjectIdKind::Null;
int unk = 0;
ObjectIdBody body;
bool IsNull() const {
return subtype == ObjectIdKind::Null;
}
bool IsPermanent() const {
return subtype == ObjectIdKind::Permanent;
}
bool IsPrototype() const {
return subtype == ObjectIdKind::Prototype;
}
bool IsPositional() const {
return subtype == ObjectIdKind::Positional;
}
bool IsHandle() const {
return subtype == ObjectIdKind::Handle;
}
bool IsBlocked() const {
return subtype == ObjectIdKind::Blocked;
}
// Can this object id be persisted and later restored to a handle?
bool IsPersistable() const {
return IsNull() || IsPermanent() || IsPrototype() || IsPositional();
}
int GetPrototypeId() const {
Expects(IsPrototype());
return body.protoId;
}
objHndl GetHandle() const {
Expects(IsHandle());
return body.handle;
}
operator bool() const {
return !IsNull();
}
bool operator ==(const ObjectId &other) const;
std::string ToString() const;
// Randomly generates a GUID and returns an object id that contains it
static ObjectId CreatePermanent();
// Creates a positional object id
static ObjectId CreatePositional(int mapId, int tileX, int tileY, int tempId);
// Creates a prototype object id
static ObjectId CreatePrototype(uint16_t prototypeId);
// Creates a null object id
static ObjectId CreateNull() {
ObjectId result;
result.subtype = ObjectIdKind::Null;
return result;
}
static ObjectId CreateHandle(objHndl handle);
};
#pragma pack(pop)
const int testSizeofObjectId = sizeof(ObjectId); // should be 24 |
[STATEMENT]
lemma (in -) find_path1_ex_rule:
assumes "finite (E\<^sup>*``{u0})"
assumes "\<exists>v\<in>E\<^sup>+``{u0}. P v"
shows "find_path1 E u0 P \<le> SPEC (\<lambda>r.
\<exists>p v. r = Some (p,v) \<and> p\<noteq>[] \<and> P v \<and> path E u0 p v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. find_path1 E u0 P \<le> SPEC (\<lambda>r. \<exists>p v. r = Some (p, v) \<and> p \<noteq> [] \<and> P v \<and> path E u0 p v)
[PROOF STEP]
unfolding find_path1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. ASSERT (finite (E\<^sup>* `` {u0})) \<bind> (\<lambda>_. SPEC (\<lambda>p. case p of None \<Rightarrow> \<forall>v\<in>E\<^sup>+ `` {u0}. \<not> P v | Some (p, v) \<Rightarrow> path E u0 p v \<and> P v \<and> p \<noteq> [])) \<le> SPEC (\<lambda>r. \<exists>p v. r = Some (p, v) \<and> p \<noteq> [] \<and> P v \<and> path E u0 p v)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite (E\<^sup>* `` {u0})
\<exists>v\<in>E\<^sup>+ `` {u0}. P v
goal (1 subgoal):
1. ASSERT (finite (E\<^sup>* `` {u0})) \<bind> (\<lambda>_. SPEC (\<lambda>p. case p of None \<Rightarrow> \<forall>v\<in>E\<^sup>+ `` {u0}. \<not> P v | Some (p, v) \<Rightarrow> path E u0 p v \<and> P v \<and> p \<noteq> [])) \<le> SPEC (\<lambda>r. \<exists>p v. r = Some (p, v) \<and> p \<noteq> [] \<and> P v \<and> path E u0 p v)
[PROOF STEP]
by (fastforce split: option.splits) |
import WinPath
@test WinPath.in()
@test WinPath.out()
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CS630: Database Management Systems
% Copyright 2014 Pejman Ghorbanzade <[email protected]>
% Creative Commons Attribution-ShareAlike 4.0 International License
% More info: https://github.com/ghorbanzade/beacon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Question 1}
A university database contains information about professors (identified by social security number \textit{SSN}) and courses (identified by \textit{courseid}).
Professors also have a name, an address and a phone number.
Courses have a name and a number of credits.
Professors teach courses.
For each of the following situations, draw an ER diagram that describes it (assuming no further constraints hold).
\begin{enumerate}[label=(\alph*)]
\item Every professor must teach some course.
\textbf{Solution:}
\begin{figure}[H]\centering
\input{\texDirectory/hw03/hw03q01f01}
\caption{ER Diagram for Question 1$\left(a\right)$ with Chen's Notation} \label{fig:ER1}
\end{figure}
\item Every professor teaches exactly one course (no more, no less).
\textbf{Solution:}
\begin{figure}[H]\centering
\input{\texDirectory/hw03/hw03q01f02}
\caption{ER Diagram for Question 1$\left(b\right)$ with Chen's Notation} \label{fig:ER2}
\end{figure}
\item Every professor teaches exactly one course (no more, no less), and every course must be taught by some professor.
\textbf{Solution:}
\begin{figure}[H]\centering
\input{\texDirectory/hw03/hw03q01f03}
\caption{ER Diagram for Question 1$\left(c\right)$ with Chen's Notation} \label{fig:ER3}
\end{figure}
\item Modify the diagram from (a) such that a professor can have a set of addresses (which are street, city and state triples) and a set of phones.
Recall that in the ER model there can be only primitive data types (no sets).
\textbf{Solution:}
\begin{figure}[H]\centering
\input{\texDirectory/hw03/hw03q01f04}
\caption{ER Diagram for Question 1$\left(d\right)$ with Chen's Notation} \label{fig:ER4}
\end{figure}
It is assumed multiple professors may live at a single address.
There might be addresses at which no professor lives.
There might be phone numbers that do not belong to any professor.
There might be professors who have not declared their addresses or phone numbers.
As each entity must have a key attribute, \texttt{Address ID} and \texttt{Phone ID} of \texttt{Address} and \texttt{Phone} entities are also indicated.
\item Modify the diagram from (d) such that professors can have a set of addresses, and at each address there is a set of phones.
\textbf{Solution:}
It is assumed multiple professors may live at a single address.
There might be addresses at which no professor lives.
There might be phone numbers that do not belong to any professor.
There might be professors who have not declared their addresses.
There might be addresses with no phone.
As each entity must have a key attribute, \texttt{Address ID} and \texttt{Phone ID} of \texttt{Address} and \texttt{Phone} entities are also indicated.
\begin{figure}[H]\centering
\input{\texDirectory/hw03/hw03q01f05}
\caption{ER Diagram for Question 1$\left(e\right)$ with Chen's Notation} \label{fig:ER5}
\end{figure}
\end{enumerate}
|
# Dynamically keep track of the eigenvalues system of a hermitian, positive
# definite matrix that is growing diagonally.
# * We need to keep track of its inverse, which is not going to be very stable numerically, but it should do the trick
# of tracking eigenvalues using the Cauchy Interlace Theorem.
# * We also want to keep track of it's eigensystem, which is going to serve for the Lanczos Algorithm with selective
# re-orthogonalizations!
# * It starts keeping track of the eigensystem when it's been asked to, and it will start doing it.
mutable struct DynamicSymTridiagonal{T<:AbstractFloat}
alphas::Vector{T} # Diaognal
betas::Vector{T} # Lower & upper Diaognal
L::Vector{T} # The lower diagonal of the unit-bidiagonal matrix L
U::Vector{T} # Lower diagonal of the upper bi-diagonal matrix U
k::Int64 # Size of the matrix.
V::Matrix{T} # Eigenvectors
thetas::Vector{T} # Eigen values.
function DynamicSymTridiagonal{T}(alpha::T) where {T<:Float64}
this = new{T}()
this.alphas = Vector{T}()
push!(this.alphas, alpha)
this.betas = Vector{T}()
this.L = Vector{T}()
this.U = Vector{T}()
push!(this.U, alpha)
this.k = 1
return this
end
function DynamicSymTridiagonal(alpha::AbstractFloat)
T = typeof(alpha)
return DynamicSymTridiagonal{T}(alpha)
end
end
"""
append an alpha and a beta (diagonal and sub & super diagonal) elemnt to the current sym diagonal matrix.
"""
function (this::DynamicSymTridiagonal{T})(alpha::T, beta::T) where {T<:AbstractFloat}
push!(this.alphas, alpha)
push!(this.betas, beta)
push!(this.U, alpha - beta^2/this.U[end])
push!(this.L, beta/this.U[end - 1])
this.k += 1
return this
end
"""
Using the Lapack library to get the eigen system of the curent T, and then after
this, it will keep track of the eigensystem as elements are added to the dynamic matrix.
"""
function InitializeEigenSystem(this::DynamicSymTridiagonal{T}, max_size::Int64) where {T<:AbstractFloat}
if max_size > 32728 || max_size < 2
error("Eigen system estimated max size can't be: $(max_size)")
end
Trid = GetT(this)
theta, V = eigen(Trid)
Vbigger = zeros(T, max_size, max_size)
Vbigger[1:this.k, 1:this.k] = V
this.V = Vbigger
Theta = zeros(T, max_size)
Theta[1:this.k] = theta
this.thetas = Theta
# Sort by absolute values.
SortedIdx = sortperm(abs.(this.thetas))
this.thetas = this.thetas[SortedIdx]
this.V = this.V[:, SortedIdx]
return this.thetas, this.V
end
"""
Update the eigensystem of the bigger matrix using the preivous eigen system. Use Power Iterations
iteratively.
"""
function UpdateEigenSystemPowItr(this::DynamicSymTridiagonal{T}) where {T <: AbstractFloat}
# if !(isdefined(Base, :this.V)) # cheks if defined first.
# error("Must initialize the eigensystem with an estimated size before calling this function. ")
# end
k = this.k
V = this.V
Θ = this.thetas
A = this
if k > size(this.V, 1)
error("Hasn't implemented this part yet, k exceed the maximal size of eigen system.")
end
Avⱼ = zeros(T, k)
for j in 1: k
vⱼ = view(V, 1:k, j)
vⱼ .+= 1e-10*rand(T, k)
if j >= 2 # Components on to previous ortho eigen vectors removed.
vⱼ .-= view(V, 1:k, 1:j - 1)*view(V, 1:k, 1:j - 1)'*vⱼ
end
for Itr in 1: k^2 + 1e3 # Power iterations
vⱼᵀvⱼ = dot(vⱼ, vⱼ)
Apply!(A, vⱼ, Avⱼ)
if j >= 2 # Components on to previous ortho eigen vectors removed.
Avⱼ .-= view(V, 1:k, 1:j - 1)*view(V, 1:k, 1:j - 1)'*Avⱼ
end
λ̃ = dot(vⱼ, Avⱼ)/vⱼᵀvⱼ # Rayleigh Quotient.
∇r = 2(Avⱼ - λ̃*vⱼ) # Gradient of Rayleigh Quotient.
if norm(∇r, Inf) <= 1e-8
V[1:k, j] .= vⱼ/sqrt(vⱼᵀvⱼ)
Θ[j] = λ̃
break # go to Next Eigenvector.
end
vⱼ .= Avⱼ/norm(Avⱼ)
end
end
return
end
"""
Get the L matrix for this instance.
"""
function GetL(this::DynamicSymTridiagonal)
return Bidiagonal(fill(1, this.k), convert(Vector{Float64}, this.L), :L)
end
"""
Get the U matrix for this instance.
"""
function GetU(this::DynamicSymTridiagonal)
return Bidiagonal(convert(Vector{Float64}, this.U), this.betas, :U)
end
"""
Get the Tridiagonal Matrix
"""
function GetT(this::DynamicSymTridiagonal)
return SymTridiagonal(this.alphas, this.betas)
end
"""
Solve this matrix against another matrix or vector.
"""
function Base.:\(
this::DynamicSymTridiagonal{T},
b::Union{Matrix{T}, Vector{T}}
) where {T<:AbstractFloat}
return
end
"""
Multiply a vector on the left hand size of this dynamically growing matrix
T.
"""
function Base.:*(this::DynamicSymTridiagonal{T}, b::AbstractArray{T}) where {T <: AbstractFloat}
@assert length(b) == this.k "Dimension of vector b does match the number of rows in k. Expect $(this.k) but get $(length(b))"
β = this.betas
α = this.alphas
v = similar(b)
v[1] = α[1]*b[1] + β[1]*b[2]
for Idx in 2: this.k - 1
v[Idx] = β[Idx - 1]*b[Idx - 1] + α[Idx]*b[Idx] + β[Idx]*b[Idx + 1]
end
v[this.k] = β[this.k - 1]*b[end - 1] + α[this.k]*b[end]
return v
end
"""
Memory friendly version of multiplications.
"""
function Apply!(this::DynamicSymTridiagonal{T}, b::AbstractArray{T}, v::Vector{T}) where {T <: AbstractFloat}
@assert length(b) == this.k "Dimension of vector b does match the number of rows in k. Expect $(this.k) but get $(length(b))"
@assert length(v) == this.k "Dimension of mutable vector v deosn't match the number of rows in k. Expect $(this.k) but get $(length(v))"
β = this.betas
α = this.alphas
v[1] = α[1]*b[1] + β[1]*b[2]
for Idx in 2: this.k - 1
v[Idx] = β[Idx - 1]*b[Idx - 1] + α[Idx]*b[Idx] + β[Idx]*b[Idx + 1]
end
v[this.k] = β[this.k - 1]*b[end - 1] + α[this.k]*b[end]
return v
end
# BASIC TESTING ----------------------------------------------------------------
using LinearAlgebra, Logging, Plots
@info "Basic Testing"
n = 64
A = SymTridiagonal(fill(-2.0, n), fill(1.0,n - 1))
T_dy = DynamicSymTridiagonal(A[1, 1])
InitializeEigenSystem(T_dy, n)
for Idx in 2: n
T_dy(A[Idx, Idx], A[Idx - 1, Idx])
@time UpdateEigenSystemPowItr(T_dy)
# display(T_dy.V)
end
@info "Dynamic T Eigen System"
display(T_dy.V)
L = GetL(T_dy)
U = GetU(T_dy)
b = rand(n)
@assert norm(GetT(T_dy) - L*U) < 1e-10
@assert norm(T_dy*b - GetT(T_dy)*b) < 1e-10
|
{-
The goal of this file is to prove the iso π₄S³≅ℤ/β
where β is a natural number (aka "the Brunerie number",
defined below).
-}
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Homotopy.Group.Pi4S3.BrunerieNumber where
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.Base
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.Group.Pi3S2
open import Cubical.Homotopy.Group.PinSn
open import Cubical.Homotopy.BlakersMassey
open import Cubical.Homotopy.Whitehead
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Group.LES
open import Cubical.Homotopy.Group.Pi4S3.S3PushoutIso2
open import Cubical.Homotopy.Group.Pi4S3.S3PushoutIso
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Data.Int
renaming (ℤ to Z ; _·_ to _·Z_ ; _+_ to _+Z_)
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Wedge
open import Cubical.HITs.Pushout
open import Cubical.HITs.PropositionalTruncation
renaming (rec to pRec ; elim to pElim ; map to pMap)
open import Cubical.HITs.SetTruncation
renaming (rec to sRec ; rec2 to sRec2
; elim to sElim ; elim2 to sElim2 ; elim3 to sElim3
; map to sMap)
open import Cubical.HITs.Truncation renaming
(rec to trRec ; elim to trElim ; elim2 to trElim2 ; map to trMap)
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Exact
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Instances.IntMod
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Unit
open import Cubical.Algebra.Group.GroupPath
open Iso
open Exact4
-- The Brunerie number (see Corollary 3.4.5 in Brunerie's PhD thesis)
Brunerie : ℕ
Brunerie =
abs (HopfInvariant-π' 0 [ ∣ idfun∙ (S₊∙ 2) ∣₂ ∣ ∣ idfun∙ (S₊∙ 2) ∣₂ ]π')
-- First we need to define the following maps.
W : S₊ 3 → (S₊∙ 2 ⋁ S₊∙ 2)
W = joinTo⋁ {A = S₊∙ 1} {B = S₊∙ 1} ∘ Iso.inv (IsoSphereJoin 1 1)
fold∘W : S₊ 3 → S₊ 2
fold∘W = fold⋁ ∘ W
{-
We will now instantiate Blakers Massey to get a square:
fold∘W
S³ --------------> S²
|\ ↗ |
| \ ↗ |
| \ ↗ |
| X | inr
| / |
| / |
| / |
v / v
1 -----------> coFib fold∘W
inl
where X is the pullback of inl and inr and the map S³ → X is
surjective on π₃. This will give us a sequence
π₃ S³ --ᶠ→ π₃ S² → π₃ (coFib fold∘W) → π₂ X ≅ 0, where f is
the function induced by fold∘W. From this, we can deduce that
π₃ (coFib fold∘W) ≅ ℤ/ f(1) where f(1) is interpreted as an
integer via the isos π₃ S³ ≅ π₃ S² ≅ ℤ
(Recall that π₃(coFib fold∘W) ≅ π₄S³)
For clarity:
X, above will have two names (via a trivial iso) below:
TotalPushoutPath× (the version the falls out of BM)
P = fiber inr (Same name as in Brunerie's prop 4.3.4.)
-}
-- Before instantiating, we need to show that
-- any map S³ → S² is 0-connected
isConnectedS3→S2 : (f : S₊ 3 → S₊ 2) → isConnectedFun 2 f
isConnectedS3→S2 f p =
trRec (isProp→isOfHLevelSuc 1 isPropIsContr)
(J (λ p _ → isConnected 2 (fiber f p))
(∣ north , refl ∣
, (trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _)
(uncurry
(sphereElim 2
(λ _ → isOfHLevelΠ 3
λ _ → isOfHLevelPath 3
(isOfHLevelSuc 2 (isOfHLevelTrunc 2)) _ _)
λ p → trRec (isOfHLevelTrunc 2 _ _)
(λ r → cong ∣_∣ₕ (ΣPathP (refl , r)))
(fun (PathIdTruncIso 1)
(isContr→isProp
(isConnectedPath 2 (sphereConnected 2)
(f north) (f north)) ∣ refl ∣ ∣ p ∣)))))))
(fun (PathIdTruncIso 2)
(isContr→isProp (sphereConnected 2) ∣ f north ∣ ∣ p ∣))
-- We get our square
module BM-inst =
BlakersMassey□
(λ _ → tt) fold∘W 3 1
(λ _ → subst (isConnected 4)
(isoToPath (invIso fiberUnitIso))
(sphereConnected 3))
(isConnectedS3→S2 fold∘W)
open BM-inst
-- The central types
coFib-fold∘W : Type
coFib-fold∘W = Pushout (λ _ → tt) fold∘W
coFib-fold∘W∙ : Pointed₀
coFib-fold∘W∙ = coFib-fold∘W , inl tt
TotalPushoutPath×∙ : Pointed ℓ-zero
fst TotalPushoutPath×∙ = Σ (Unit × S₊ 2) PushoutPath×
snd TotalPushoutPath×∙ = (tt , north) , push north
S³→TotalPushoutPath× : S₊ 3 → Σ (Unit × S₊ 2) PushoutPath×
S³→TotalPushoutPath× = toPullback
private
inr' : S₊ 2 → coFib-fold∘W
inr' = inr
inr∙ : S₊∙ 2 →∙ coFib-fold∘W∙
fst inr∙ = inr'
snd inr∙ = sym (push north)
fiberinr'Iso' : Iso (fiber inr' (inl tt))
(Σ (Unit × S₊ 2) PushoutPath×)
fiberinr'Iso' =
compIso (Σ-cong-iso-snd (λ x → symIso))
(Σ-cong-iso-fst (invIso lUnit×Iso))
fiberinr'Iso : Iso (fiber inr' (inl tt))
(Σ (Unit × S₊ 2) PushoutPath×)
fun fiberinr'Iso (x , p) = (tt , x) , (sym p)
inv fiberinr'Iso ((tt , x) , p) = x , (sym p)
rightInv fiberinr'Iso _ = refl
leftInv fiberinr'Iso _ = refl
P : Pointed₀
P = (fiber inr' (inl tt) , north , (sym (push north)))
π'P→π'TotalPath× : (n : ℕ)
→ GroupEquiv (π'Gr n TotalPushoutPath×∙) (π'Gr n P)
fst (fst (π'P→π'TotalPath× n)) =
π'eqFun n ((invEquiv (isoToEquiv fiberinr'Iso)) , refl)
snd (fst (π'P→π'TotalPath× n)) = π'eqFunIsEquiv n _
snd (π'P→π'TotalPath× n) = π'eqFunIsHom n _
-- Time to invoke the long exact sequence of homotopy groups on
-- inr : S² → coFib-fold∘W
module LESinst = πLES {A = S₊∙ 2} {B = coFib-fold∘W∙} inr∙
-- We instantiate the sequence
-- π₃ P → π₃ S² → π₃ coFib-fold∘W∙ → π₂ P
P→S²→Pushout :
Exact4 (πGr 2 P) (πGr 2 (S₊∙ 2)) (πGr 2 coFib-fold∘W∙) (πGr 1 P)
(LESinst.fib→A 2)
(LESinst.A→B 2)
(LESinst.B→fib 1)
Exact4.ImG→H⊂KerH→L P→S²→Pushout = LESinst.Im-fib→A⊂Ker-A→B 2
Exact4.KerH→L⊂ImG→H P→S²→Pushout = LESinst.Ker-A→B⊂Im-fib→A 2
Exact4.ImH→L⊂KerL→R P→S²→Pushout = LESinst.Im-A→B⊂Ker-B→fib 1
Exact4.KerL→R⊂ImH→L P→S²→Pushout = LESinst.Ker-B→fib⊂Im-A→B 1
-- The goal now is to rewrite it as
-- π₃ S³ → π₃ S² → π₃ coFib-fold∘W∙ → Unit using the
-- "functions from spheres"-definition of πₙ.
-- Here, the first map is the one induced by fold∘W. We do this by:
-- (1) showing that π₂ P is trivial
-- (2) extending the sequence by appending surjections
-- π₃ S³ → π₃ TotalPushoutPath×∙ → π₃ P on the left.
-- (3) proving that this new composition is indeed the appropriate map
-- Step 1: π₂ P is trivial
π₂P≅0 : GroupEquiv (πGr 1 P) UnitGroup₀
π₂P≅0 = compGroupEquiv (πIso (isoToEquiv fiberinr'Iso , refl) 1)
(GroupIso→GroupEquiv
(contrGroupIsoUnit
(isOfHLevelRetractFromIso 0 (invIso iso₂) isContrπ₂S³)))
where
iso₁ : Iso (hLevelTrunc 4 (S₊ 3))
(hLevelTrunc 4 (Σ (Unit × S₊ 2) PushoutPath×))
iso₁ = connectedTruncIso 4 S³→TotalPushoutPath× isConnected-toPullback
iso₂ : Iso (π 2 (hLevelTrunc∙ 4 (S₊∙ 3)))
(π 2 TotalPushoutPath×∙)
iso₂ =
(compIso (setTruncIso
(equivToIso (_ ,
(isEquivΩ^→ 2 (fun iso₁ , refl) (isoToIsEquiv iso₁)))))
(invIso (πTruncIso 2)))
isContrπ₂S³ : isContr (π 2 (hLevelTrunc∙ 4 (S₊∙ 3)))
isContrπ₂S³ =
subst (λ x → isContr (π 2 x))
(λ i → ((sym (isContr→≡Unit (sphereConnected 3))) i)
, transp (λ j → isContr→≡Unit
(sphereConnected 3) (~ i ∧ j)) i ∣ north ∣)
(∣ refl ∣₂ , sElim (λ _ → isSetPathImplicit)
λ p → cong ∣_∣₂
(isProp→isSet
(isOfHLevelPath 1 isPropUnit _ _) _ _ _ p))
-- Step 2. We transform our original sequence to one for the
-- the "maps from spheres" definition of πₙ and where π₂ P is
-- replaced by the trivial group:
-- π₃ P → π₃ S² → π₃ coFib-fold∘W∙ → 0
P→S²→Pushout→P' :
Exact4 (π'Gr 2 P) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙) UnitGroup₀
(π'∘∙Hom 2 (fst , refl))
(π'∘∙Hom 2 inr∙)
(→UnitHom _)
P→S²→Pushout→P' =
transportExact4
(sym (GroupPath _ _ .fst ((GroupIso→GroupEquiv (π'Gr≅πGr 2 P)))))
(sym (GroupPath _ _ .fst ((GroupIso→GroupEquiv (π'Gr≅πGr 2 (S₊∙ 2))))))
(sym (GroupPath _ _ .fst ((GroupIso→GroupEquiv (π'Gr≅πGr 2 coFib-fold∘W∙)))))
(sym (GroupPath _ _ .fst π₂P≅0))
_ _ _ _ _
P→S²→Pushout
(ΣPathPProp (λ _ → isPropIsGroupHom _ _)
λ i → fst (π∘∙fib→A-PathP 2 inr∙ i))
(ΣPathPProp (λ _ → isPropIsGroupHom _ _)
λ i → fst (π∘∙A→B-PathP 2 inr∙ i))
-- The two surjections in question
π₃S³→π₃P : GroupHom (π'Gr 2 (S₊∙ 3)) (π'Gr 2 TotalPushoutPath×∙)
π₃S³→π₃P = π'∘∙Hom 2 (S³→TotalPushoutPath× , refl)
TotalPushoutPath×∙→P : TotalPushoutPath×∙ →∙ P -- Surjective, and in particular on π₃
fst TotalPushoutPath×∙→P x = (snd (fst x)) , (sym (snd x))
snd TotalPushoutPath×∙→P = refl
-- This surjectivity is where Blakers-Massey is used
-- In particular, it uses isConnected-toPullback
isSurjective-π₃S³→π₃TotalPushoutPath× : isSurjective π₃S³→π₃P
isSurjective-π₃S³→π₃TotalPushoutPath× =
transport (λ i → isSurjective (transportLem i))
isSurjective-π₃S³→π₃TotalPushoutPath×'
where
π₃S³→π₃TotalPushoutPath× : GroupHom (πGr 2 (S₊∙ 3)) (πGr 2 TotalPushoutPath×∙)
π₃S³→π₃TotalPushoutPath× = πHom 2 (S³→TotalPushoutPath× , refl)
isSurjective-π₃S³→π₃TotalPushoutPath×' : isSurjective π₃S³→π₃TotalPushoutPath×
isSurjective-π₃S³→π₃TotalPushoutPath×' =
sElim (λ _ → isProp→isSet squash₁)
λ p → trRec squash₁
(λ s → ∣ ∣ fst s ∣₂ , (cong ∣_∣₂ (snd s)) ∣₁)
(((isConnectedΩ^→ 3 3 (S³→TotalPushoutPath× , refl)
isConnected-toPullback) p) .fst)
transportLem : PathP (λ i → GroupHomπ≅π'PathP (S₊∙ 3) TotalPushoutPath×∙ 2 i)
π₃S³→π₃TotalPushoutPath× π₃S³→π₃P
transportLem =
toPathP (Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(π'∘∙Hom'≡π'∘∙fun {A = S₊∙ 3} {B = TotalPushoutPath×∙}
2 (S³→TotalPushoutPath× , refl)))
-- We get a sequence on the right form π₃S³ → π₃S² → π₃ Pushout → Unit
S³→S²→Pushout→Unit'' :
Exact4 (π'Gr 2 (S₊∙ 3)) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙) UnitGroup₀
(compGroupHom π₃S³→π₃P
(compGroupHom
(π'∘∙Hom 2 TotalPushoutPath×∙→P) (π'∘∙Hom 2 (fst , refl))))
(π'∘∙Hom 2 inr∙)
(→UnitHom (π'Gr 2 coFib-fold∘W∙))
S³→S²→Pushout→Unit'' =
extendExact4Surjective _ _ _ _ _ _ _ _ _
isSurjective-π₃S³→π₃TotalPushoutPath×
(extendExact4Surjective _ _ _ _ _ _ _ _ _
((sElim (λ _ → isProp→isSet squash₁)
(λ f → ∣ ∣ (λ x → (tt , fst f x .fst) , sym (fst f x .snd))
, ΣPathP ((ΣPathP (refl , cong fst (snd f)))
, λ j i → snd f j .snd (~ i)) ∣₂
, cong ∣_∣₂ (ΣPathP (refl , sym (rUnit _))) ∣₁)))
P→S²→Pushout→P')
-- Step 3: We need to show that the map π₃S³ → π₃S² in the above sequence
-- indeed comes from fold∘W
tripleComp≡ :
(compGroupHom π₃S³→π₃P
(compGroupHom
(π'∘∙Hom 2 TotalPushoutPath×∙→P) (π'∘∙Hom 2 (fst , refl))))
≡ π'∘∙Hom 2 (fold∘W , refl)
tripleComp≡ =
Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(funExt (sElim (λ _ → isSetPathImplicit)
λ f → cong ∣_∣₂ (ΣPathP (refl , (cong (_∙ refl)
(λ j → cong fst (rUnit (cong (fst TotalPushoutPath×∙→P)
(rUnit (cong S³→TotalPushoutPath× (snd f)) (~ j))) (~ j))))))))
-- We finally get the correct sequence
S³→S²→Pushout→Unit :
Exact4 (π'Gr 2 (S₊∙ 3)) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙) UnitGroup₀
(π'∘∙Hom 2 (fold∘W , refl))
(π'∘∙Hom 2 inr∙)
(→UnitHom (π'Gr 2 coFib-fold∘W∙))
S³→S²→Pushout→Unit =
subst
(λ F → Exact4 (π'Gr 2 (S₊∙ 3)) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙) UnitGroup₀
F (π'∘∙Hom 2 inr∙)
(→UnitHom (π'Gr 2 coFib-fold∘W∙)))
tripleComp≡
S³→S²→Pushout→Unit''
-- We need to throw around some pushouts
module _ where
Pushout-coFibW-fold⋁≃coFib-fold∘W :
Pushout {B = (Pushout W (λ _ → tt))} inl fold⋁ ≃ fst coFib-fold∘W∙
Pushout-coFibW-fold⋁≃coFib-fold∘W = compEquiv
(compEquiv pushoutSwitchEquiv
(isoToEquiv (PushoutDistr.PushoutDistrIso fold⋁ W λ _ → tt)))
pushoutSwitchEquiv
coFibW≅coFibW' : Pushout W (λ _ → tt) ≃ cofibW S¹ S¹ base base
coFibW≅coFibW' = pushoutEquiv W (λ _ → tt) joinTo⋁ (λ _ → tt)
(isoToEquiv (invIso (IsoSphereJoin 1 1)))
(idEquiv _)
(idEquiv _)
refl
refl
Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁ :
Pushout {B = (Pushout W (λ _ → tt))} inl fold⋁
≃ fst (Pushout⋁↪fold⋁∙ (S₊∙ 2))
Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁ = pushoutEquiv inl _ ⋁↪ fold⋁
(idEquiv _)
(compEquiv coFibW≅coFibW'
(isoToEquiv (invIso (Iso-Susp×Susp-cofibJoinTo⋁ S¹ S¹ base base))))
(idEquiv _)
(Susp×Susp→cofibW≡ S¹ S¹ base base)
refl
Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁∙ :
(Pushout {B = (Pushout W (λ _ → tt))} inl fold⋁ , inr north)
≃∙ (Pushout⋁↪fold⋁∙ (S₊∙ 2))
fst Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁∙ =
Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁
snd Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁∙ =
sym (push (inl north))
π₄S³≅π₃coFib-fold∘W∙ : GroupEquiv (π'Gr 3 (S₊∙ 3)) (π'Gr 2 coFib-fold∘W∙)
π₄S³≅π₃coFib-fold∘W∙ =
compGroupEquiv
(GroupIso→GroupEquiv
(compGroupIso
(π'Gr≅πGr 3 (S₊∙ 3))
(compGroupIso
π₄S³≅π₃PushS²
(invGroupIso (π'Gr≅πGr 2 (Pushout⋁↪fold⋁∙ (S₊∙ 2)))))))
(compGroupEquiv
(invGroupEquiv (π'Iso 2 Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁∙))
(π'Iso 2 (Pushout-coFibW-fold⋁≃coFib-fold∘W , sym (push north))))
-- We get the iso
-- For type checking reasons, let's first prove it for the abstract
-- definition of ℤ/_
-- To get everything on the same form as in Brunerie's thesis, we
-- first need the following:
fold∘W≡Whitehead :
fst (π'∘∙Hom 2 (fold∘W , refl)) ∣ idfun∙ (S₊∙ 3) ∣₂
≡ ∣ [ idfun∙ (S₊∙ 2) ∣ idfun∙ (S₊∙ 2) ]₂ ∣₂
fold∘W≡Whitehead =
pRec (squash₂ _ _)
(cong ∣_∣₂)
(indΠ₃S₂ _ _
(funExt (λ x → funExt⁻ (sym (cong fst (id∨→∙id {A = S₊∙ 2}))) (W x))))
where
indΠ₃S₂ : ∀ {ℓ} {A : Pointed ℓ}
→ (f g : A →∙ S₊∙ 2)
→ fst f ≡ fst g → ∥ f ≡ g ∥₁
indΠ₃S₂ {A = A} f g p =
trRec squash₁
(λ r → ∣ ΣPathP (p , r) ∣₁)
(isConnectedPathP 1 {A = (λ i → p i (snd A) ≡ north)}
(isConnectedPathSⁿ 1 (fst g (pt A)) north) (snd f) (snd g) .fst )
BrunerieIsoAbstract : GroupEquiv (π'Gr 3 (S₊∙ 3)) (abstractℤGroup/ Brunerie)
BrunerieIsoAbstract =
compGroupEquiv π₄S³≅π₃coFib-fold∘W∙
(invGroupEquiv
(GroupEquiv-abstractℤ/abs-gen
(π'Gr 2 (S₊∙ 3)) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙)
(GroupIso→GroupEquiv (invGroupIso (πₙ'Sⁿ≅ℤ 2)))
(invGroupEquiv hopfInvariantEquiv)
(π'∘∙Hom 2 (fold∘W , refl))
_
S³→S²→Pushout→Unit Brunerie main))
where
mainPath :
fst (π'∘∙Hom 2 (fold∘W , refl))
(Iso.inv (fst (πₙ'Sⁿ≅ℤ 2)) 1)
≡ [ ∣ idfun∙ (S₊∙ 2) ∣₂ ∣ ∣ idfun∙ (S₊∙ 2) ∣₂ ]π'
mainPath =
cong (fst (π'∘∙Hom 2 (fold∘W , refl)))
(cong (Iso.inv (fst (πₙ'Sⁿ≅ℤ 2))) (sym (πₙ'Sⁿ≅ℤ-idfun∙ 2))
∙ (Iso.leftInv (fst (πₙ'Sⁿ≅ℤ 2)) ∣ idfun∙ (S₊∙ 3) ∣₂))
∙ fold∘W≡Whitehead
∙ cong ∣_∣₂ (sym ([]≡[]₂ (idfun∙ (S₊∙ 2)) (idfun∙ (S₊∙ 2))))
main : _ ≡ Brunerie
main i = abs (HopfInvariant-π' 0 (mainPath i))
-- And, finally, we get the actual iso
-- (as in Corollary 3.4.5 in Brunerie's thesis)
BrunerieIso : GroupEquiv (π'Gr 3 (S₊∙ 3)) (ℤGroup/ Brunerie)
BrunerieIso =
compGroupEquiv BrunerieIsoAbstract (abstractℤ/≅ℤ Brunerie)
|
(************************************************************************************)
(** *)
(** The SQLEngines Library *)
(** *)
(** LRI, CNRS & Université Paris-Sud, Université Paris-Saclay *)
(** *)
(** Copyright 2016-2019 : FormalData *)
(** *)
(** Authors: Véronique Benzaken *)
(** Évelyne Contejean *)
(** *)
(************************************************************************************)
Set Implicit Arguments.
Require Import NArith List.
Lemma app_nil : forall (A : Type) (l : list A), nil ++ l = l.
Proof.
intros A l; apply refl_equal.
Qed.
Lemma f_equal6 :
forall (A1 A2 A3 A4 A5 A6 B : Type)
(f : A1 -> A2 -> A3 -> A4 -> A5 -> A6 -> B)
(x1 y1 : A1) (x2 y2 : A2) (x3 y3 : A3) (x4 y4 : A4) (x5 y5 : A5) (x6 y6 : A6),
x1 = y1 -> x2 = y2 -> x3 = y3 -> x4 = y4 -> x5 = y5 -> x6 = y6 ->
f x1 x2 x3 x4 x5 x6 = f y1 y2 y3 y4 y5 y6.
Proof.
intros; subst; trivial.
Qed.
Lemma f_equal7 :
forall (A1 A2 A3 A4 A5 A6 A7 B : Type)
(f : A1 -> A2 -> A3 -> A4 -> A5 -> A6 -> A7 -> B)
(x1 y1 : A1) (x2 y2 : A2) (x3 y3 : A3) (x4 y4 : A4) (x5 y5 : A5) (x6 y6 : A6)
(x7 y7 : A7),
x1 = y1 -> x2 = y2 -> x3 = y3 -> x4 = y4 -> x5 = y5 -> x6 = y6 -> x7 = y7 ->
f x1 x2 x3 x4 x5 x6 x7 = f y1 y2 y3 y4 y5 y6 y7.
Proof.
intros; subst; trivial.
Qed.
Lemma f_equal8 :
forall (A1 A2 A3 A4 A5 A6 A7 A8 B : Type)
(f : A1 -> A2 -> A3 -> A4 -> A5 -> A6 -> A7 -> A8 -> B)
(x1 y1 : A1) (x2 y2 : A2) (x3 y3 : A3) (x4 y4 : A4) (x5 y5 : A5) (x6 y6 : A6)
(x7 y7 : A7) (x8 y8 : A8),
x1 = y1 -> x2 = y2 -> x3 = y3 -> x4 = y4 -> x5 = y5 -> x6 = y6 -> x7 = y7 -> x8 = y8 ->
f x1 x2 x3 x4 x5 x6 x7 x8 = f y1 y2 y3 y4 y5 y6 y7 y8.
Proof.
intros; subst; trivial.
Qed.
Lemma if_if :
forall (A : Type) (b1 b2 : bool) (x y : A),
(if b1 then if b2 then x else y else y) = if (andb b1 b2) then x else y.
Proof.
intros A b1 b2 x y; case b1; [case b2 | ]; apply refl_equal.
Qed.
Lemma eq_bool_iff :
forall b1 b2, b1 = b2 <-> (b1 = true -> b2 = true) /\ (b2 = true -> b1 = true).
Proof.
intros b1 b2; split.
- intro H; subst b2; split; exact (fun h => h).
- intros [H1 H2]; destruct b1; destruct b2; trivial.
+ apply sym_eq; apply H1; apply refl_equal.
+ apply H2; apply refl_equal.
Qed.
Lemma if_eq :
forall (A : Type) (b1 b2 : bool) (a1 a2 c1 c2 : A),
b1 = b2 -> (b1 = true -> a1 = a2) -> (b1 = false -> c1 = c2) ->
(if b1 then a1 else c1) = (if b2 then a2 else c2).
Proof.
intros A b1 b2 a1 a2 c1 c2 Hb Ha Hc; subst.
case_eq b2; assumption.
Qed.
Lemma if_eq_mul :
forall (b1 b2 : bool) (a1 a2 : N),
b1 = b2 -> (b1 = true -> a1 = a2) ->
(a1 * (if b1 then 1 else 0))%N = (if b2 then a2 else 0)%N.
Proof.
intros b1 b2 a1 a2 Hb Ha; subst.
case_eq b2.
- rewrite N.mul_1_r; apply Ha.
- intros; rewrite N.mul_0_r; apply refl_equal.
Qed.
Lemma match_bool_eq :
forall (A : Type) (b1 b2 : bool) (a1 a2 : A),
b1 = b2 ->
match b1 with true => a1 | false => a2 end = match b2 with true => a1 | false => a2 end.
Proof.
intros A b1 b2 a1 a2 H; subst b2; apply refl_equal.
Qed.
Lemma match_option_eq :
forall (A C : Type) (a1 a2 : option A) (c : C) (f : A -> C),
a1 = a2 ->
match a1 with Some b => f b | None => c end = match a2 with Some b => f b | None => c end.
Proof.
intros A C a1 a2 c f H; subst a2.
apply refl_equal.
Qed.
Lemma match_option_eq2 :
forall (A B C : Type) (a1 a2 : option A) (b1 b2 : B) (c : C) (f : A -> B -> C),
a1 = a2 -> (forall a, f a b1 = f a b2) ->
match a1 with Some a1' => f a1' b1 | None => c end = match a2 with Some a2' => f a2' b2 | None => c end.
Proof.
intros A B C a1 a2 b1 b2 c f H K; subst a2.
destruct a1 as [a1 | ]; [ | apply refl_equal].
apply K.
Qed.
Require Import List.
Lemma In_app :
forall (A : Type) (a : A) (l1 l2 : list A), In a (l1 ++ l2) <-> (In a l1 \/ In a l2).
Proof.
intros A a l1 l2; split; intro H.
- destruct (in_app_or _ _ _ H) as [H1 | H2]; [left | right]; assumption.
- apply in_or_app; assumption.
Qed.
Require Import Relations.
Lemma equivalence_eq :
forall (A : Type), equivalence _ (@eq A).
Proof.
intro A; split.
- intro; apply refl_equal.
- do 5 intro; subst; trivial.
- do 3 intro; subst; trivial.
Qed.
Require Import NArith.
Lemma N_diff_0_ge_1 :
forall n, match (n ?= 0)%N with Eq | Lt => false | Gt => true end = true <-> (n >= 1)%N.
Proof.
intro n; destruct n; simpl; split.
- intro Abs; discriminate Abs.
- intro Abs; unfold N.ge in Abs; simpl in Abs.
apply False_rec; apply Abs; apply refl_equal.
- intros _; destruct p; discriminate.
- intros _; apply refl_equal.
Qed.
(* A lemma that vanished between coq-8.4 and coq-8.6 *)
Lemma nat_iter_succ_r n {A} (f : A->A) (x : A) :
Nat.iter (S n) f x = Nat.iter n f (f x).
Proof.
induction n; intros; simpl; rewrite <- ?IHn; trivial.
Qed.
Lemma nat_iter_plus :
forall (n1 n2 : nat) (A : Type) (f : A -> A) x,
Nat.iter (n1 + n2) f x = Nat.iter n1 f (Nat.iter n2 f x).
Proof.
intro n1; induction n1 as [ | n1]; intros n2 A f x; simpl; [ | rewrite IHn1]; trivial.
Qed.
|
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
⊢ q = 0 ∨ IsPrimePow q
[PROOFSTEP]
apply or_iff_not_imp_left.2
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
⊢ ¬q = 0 → IsPrimePow q
[PROOFSTEP]
intro q_pos
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
⊢ IsPrimePow q
[PROOFSTEP]
let K := LocalRing.ResidueField R
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
⊢ IsPrimePow q
[PROOFSTEP]
haveI RM_char := ringChar.charP K
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
⊢ IsPrimePow q
[PROOFSTEP]
let r := ringChar K
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
⊢ IsPrimePow q
[PROOFSTEP]
let n := q.factorization r
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
⊢ IsPrimePow q
[PROOFSTEP]
cases' CharP.char_is_prime_or_zero K r with r_prime r_zero
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
⊢ IsPrimePow q
[PROOFSTEP]
let a := q / r ^ n
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
⊢ IsPrimePow q
[PROOFSTEP]
have q_eq_a_mul_rn : q = r ^ n * a := by rw [Nat.mul_div_cancel' (Nat.ord_proj_dvd q r)]
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
⊢ q = r ^ n * a
[PROOFSTEP]
rw [Nat.mul_div_cancel' (Nat.ord_proj_dvd q r)]
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = r ^ n * a
⊢ IsPrimePow q
[PROOFSTEP]
have r_ne_dvd_a := Nat.not_dvd_ord_compl r_prime q_pos
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = r ^ n * a
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
⊢ IsPrimePow q
[PROOFSTEP]
have rn_dvd_q : r ^ n ∣ q := ⟨a, q_eq_a_mul_rn⟩
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = r ^ n * a
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
⊢ IsPrimePow q
[PROOFSTEP]
rw [mul_comm] at q_eq_a_mul_rn
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
⊢ IsPrimePow q
[PROOFSTEP]
have a_unit : IsUnit (a : R) := by
by_contra g
rw [← mem_nonunits_iff] at g
rw [← LocalRing.mem_maximalIdeal] at g
have a_cast_zero := Ideal.Quotient.eq_zero_iff_mem.2 g
rw [map_natCast] at a_cast_zero
have r_dvd_a := (ringChar.spec K a).1 a_cast_zero
exact absurd r_dvd_a r_ne_dvd_a
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
⊢ IsUnit ↑a
[PROOFSTEP]
by_contra g
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
g : ¬IsUnit ↑a
⊢ False
[PROOFSTEP]
rw [← mem_nonunits_iff] at g
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
g : ↑a ∈ nonunits R
⊢ False
[PROOFSTEP]
rw [← LocalRing.mem_maximalIdeal] at g
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
g✝ : ↑a ∈ nonunits R
g : ↑a ∈ LocalRing.maximalIdeal R
⊢ False
[PROOFSTEP]
have a_cast_zero := Ideal.Quotient.eq_zero_iff_mem.2 g
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
g✝ : ↑a ∈ nonunits R
g : ↑a ∈ LocalRing.maximalIdeal R
a_cast_zero : ↑(Ideal.Quotient.mk (LocalRing.maximalIdeal R)) ↑a = 0
⊢ False
[PROOFSTEP]
rw [map_natCast] at a_cast_zero
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
g✝ : ↑a ∈ nonunits R
g : ↑a ∈ LocalRing.maximalIdeal R
a_cast_zero : ↑a = 0
⊢ False
[PROOFSTEP]
have r_dvd_a := (ringChar.spec K a).1 a_cast_zero
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
g✝ : ↑a ∈ nonunits R
g : ↑a ∈ LocalRing.maximalIdeal R
a_cast_zero : ↑a = 0
r_dvd_a : ringChar K ∣ a
⊢ False
[PROOFSTEP]
exact absurd r_dvd_a r_ne_dvd_a
[GOAL]
case inl
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
⊢ IsPrimePow q
[PROOFSTEP]
cases' a_unit.exists_left_inv with a_inv h_inv_mul_a
[GOAL]
case inl.intro
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
⊢ IsPrimePow q
[PROOFSTEP]
have rn_cast_zero : ↑(r ^ n) = (0 : R) :=
by
rw [← @mul_one R _ (r ^ n), mul_comm, ← Classical.choose_spec a_unit.exists_left_inv, mul_assoc, ← Nat.cast_mul, ←
q_eq_a_mul_rn, CharP.cast_eq_zero R q]
simp
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
⊢ ↑(r ^ n) = 0
[PROOFSTEP]
rw [← @mul_one R _ (r ^ n), mul_comm, ← Classical.choose_spec a_unit.exists_left_inv, mul_assoc, ← Nat.cast_mul, ←
q_eq_a_mul_rn, CharP.cast_eq_zero R q]
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
⊢ Classical.choose (_ : ∃ b, b * ↑a = 1) * 0 = 0
[PROOFSTEP]
simp
[GOAL]
case inl.intro
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
rn_cast_zero : ↑(r ^ n) = 0
⊢ IsPrimePow q
[PROOFSTEP]
have q_eq_rn := Nat.dvd_antisymm ((CharP.cast_eq_zero_iff R q (r ^ n)).mp rn_cast_zero) rn_dvd_q
[GOAL]
case inl.intro
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
rn_cast_zero : ↑(r ^ n) = 0
q_eq_rn : q = r ^ n
⊢ IsPrimePow q
[PROOFSTEP]
have n_pos : n ≠ 0 := fun n_zero =>
absurd (by simpa [n_zero] using q_eq_rn)
(CharP.char_ne_one R q)
-- Definition of prime power: `∃ r n, Prime r ∧ 0 < n ∧ r ^ n = q`.
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
rn_cast_zero : ↑(r ^ n) = 0
q_eq_rn : q = r ^ n
n_zero : n = 0
⊢ q = 1
[PROOFSTEP]
simpa [n_zero] using q_eq_rn
[GOAL]
case inl.intro
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_prime : Nat.Prime r
a : ℕ := q / r ^ n
q_eq_a_mul_rn : q = a * r ^ n
r_ne_dvd_a : ¬r ∣ q / r ^ ↑(Nat.factorization q) r
rn_dvd_q : r ^ n ∣ q
a_unit : IsUnit ↑a
a_inv : R
h_inv_mul_a : a_inv * ↑a = 1
rn_cast_zero : ↑(r ^ n) = 0
q_eq_rn : q = r ^ n
n_pos : n ≠ 0
⊢ IsPrimePow q
[PROOFSTEP]
exact ⟨r, ⟨n, ⟨r_prime.prime, ⟨pos_iff_ne_zero.mpr n_pos, q_eq_rn.symm⟩⟩⟩⟩
[GOAL]
case inr
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_zero : r = 0
⊢ IsPrimePow q
[PROOFSTEP]
haveI K_char_p_0 := ringChar.of_eq r_zero
[GOAL]
case inr
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_zero : r = 0
K_char_p_0 : CharP K 0
⊢ IsPrimePow q
[PROOFSTEP]
haveI K_char_zero : CharZero K := CharP.charP_to_charZero K
[GOAL]
case inr
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_zero : r = 0
K_char_p_0 : CharP K 0
K_char_zero : CharZero K
⊢ IsPrimePow q
[PROOFSTEP]
haveI R_char_zero :=
RingHom.charZero
(LocalRing.residue R)
-- Finally, `r = 0` would lead to a contradiction:
[GOAL]
case inr
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_zero : r = 0
K_char_p_0 : CharP K 0
K_char_zero : CharZero K
R_char_zero : CharZero R
⊢ IsPrimePow q
[PROOFSTEP]
have q_zero := CharP.eq R char_R_q (CharP.ofCharZero R)
[GOAL]
case inr
R : Type u_1
inst✝¹ : CommRing R
inst✝ : LocalRing R
q : ℕ
char_R_q : CharP R q
q_pos : ¬q = 0
K : Type u_1 := LocalRing.ResidueField R
RM_char : CharP K (ringChar K)
r : ℕ := ringChar K
n : (fun x => ℕ) r := ↑(Nat.factorization q) r
r_zero : r = 0
K_char_p_0 : CharP K 0
K_char_zero : CharZero K
R_char_zero : CharZero R
q_zero : q = 0
⊢ IsPrimePow q
[PROOFSTEP]
exact absurd q_zero q_pos
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.