Datasets:
AI4M
/

text
stringlengths
0
3.34M
= = Children = =
lemma monom_eq_0 [simp]: "monom 0 n = 0"
variables p q r s : Prop theorem and_commutative (p q : Prop) : p ∧ q → q ∧ p := assume hpq : p ∧ q, have hp : p, from and.left hpq, have hq : q, from and.right hpq, show q ∧ p, from and.intro hq hp theorem or_commutative (p q : Prop) : p ∨ q → q ∨ p := assume hpq : p ∨ q, show q ∨ p, from or.elim hpq (assume hp : p, show q ∨ p, from or.intro_right q hp) (assume hq: q, show q ∨ p, from or.intro_left p hq) theorem and_associ (h : (p ∧ q) ∧ r) : p ∧ (q ∧ r) := have hpq : p ∧ q, from and.left h, have hr : r, from and.right h, have hp : p, from and.left hpq, have hq : q, from and.right hpq, have hqr : q ∧ r, from and.intro hq hr, show p ∧ (q ∧ r), from and.intro hp hqr theorem or_associ (h : (p ∨ q) ∨ r) : p ∨ (q ∨ r) := show p ∨ (q ∨ r), from or.elim h (assume hpq : p ∨ q, show p ∨ (q ∨ r), from or.elim hpq (assume hp : p, or.inl hp) (assume hq : q, or.inr (or.inl hq)) ) (assume hr : r, show p ∨ (q ∨ r), from or.intro_right p (or.intro_right q hr)) theorem test (p q : Prop) (hp : p) (hq : q) : p ∧ q ∧ p := begin apply and.intro, exact hp, apply and.intro, exact hq, exact hp end example (p q r : Prop) : p ∧ (q ∨ r) ↔ (p ∧ q) ∨ (p ∧ r) := begin apply iff.intro, intro h, apply or.elim (and.right h), intro hq, apply or.inl, apply and.intro, exact and.left h, exact hq, intro hr, apply or.inr, apply and.intro, exact and.left h, exact hr, intro h, apply or.elim h, intro hpq, apply and.intro, exact and.left hpq, apply or.inl, exact and.right hpq, intro hpr, apply and.intro, exact and.left hpr, apply or.inr, exact and.right hpr end theorem and_associ_tac (h : (p ∧ q) ∧ r) : p ∧ (q ∧ r) := begin apply and.intro, exact and.left (and.left h), apply and.intro, exact and.right (and.left h), exact and.right h end example : ∀ a b c : ℕ, a = b → a = c → c = b := begin intros, transitivity, symmetry, assumption, assumption end
theory BDD_select imports Main BDD_basic begin definition select :: "nat \<Rightarrow> BDD \<Rightarrow> BDD \<Rightarrow> BDD" where "select a t e = (if t = e then t else Select a t e)" lemma select_noop [simp]: "norm n t \<Longrightarrow> norm n e \<Longrightarrow> t \<noteq> e \<Longrightarrow> select v t e = Select v t e" by (auto simp: select_def) theorem norm_select [simp]: "n > a \<Longrightarrow> norm a t \<Longrightarrow> norm a e \<Longrightarrow> norm n (select a t e)" by (simp add: select_def) theorem ordered_select [simp]: "n > a \<Longrightarrow> ordered a t \<Longrightarrow> ordered a e \<Longrightarrow> ordered n (select a t e)" by (simp add: select_def) theorem select_correct [simp]: "contains (select a t e) f = contains (Select a t e) f" apply (rule iffI) apply (auto simp add: select_def) apply (metis (full_types) contains_sel_e contains_sel_t) using contains.cases by auto end
dataset(iris) summary(iris) plot(iris)
[STATEMENT] lemma of_real_erf_numeral [simp]: "of_real (erf (numeral n)) = erf (numeral n)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. of_real (erf (numeral n)) = erf (numeral n) [PROOF STEP] by (simp only: erf_of_real [symmetric] of_real_numeral)
/- Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura -/ prelude import Init.Data.UInt @[inline, reducible] def isValidChar (n : UInt32) : Prop := n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000) namespace Char protected def lt (a b : Char) : Prop := a.val < b.val protected def le (a b : Char) : Prop := a.val ≤ b.val instance : LT Char := ⟨Char.lt⟩ instance : LE Char := ⟨Char.le⟩ instance (a b : Char) : Decidable (a < b) := UInt32.decLt _ _ instance (a b : Char) : Decidable (a ≤ b) := UInt32.decLe _ _ abbrev isValidCharNat (n : Nat) : Prop := n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000) theorem isValidUInt32 (n : Nat) (h : isValidCharNat n) : n < UInt32.size := by match h with | Or.inl h => apply Nat.ltTrans h decide | Or.inr ⟨h₁, h₂⟩ => apply Nat.ltTrans h₂ decide theorem isValidCharOfValidNat (n : Nat) (h : isValidCharNat n) : isValidChar (UInt32.ofNat' n (isValidUInt32 n h)) := match h with | Or.inl h => Or.inl h | Or.inr ⟨h₁, h₂⟩ => Or.inr ⟨h₁, h₂⟩ theorem isValidChar0 : isValidChar 0 := Or.inl (by decide) @[inline] def toNat (c : Char) : Nat := c.val.toNat instance : Inhabited Char where default := 'A' def isWhitespace (c : Char) : Bool := c = ' ' || c = '\t' || c = '\r' || c = '\n' def isUpper (c : Char) : Bool := c.val ≥ 65 && c.val ≤ 90 def isLower (c : Char) : Bool := c.val ≥ 97 && c.val ≤ 122 def isAlpha (c : Char) : Bool := c.isUpper || c.isLower def isDigit (c : Char) : Bool := c.val ≥ 48 && c.val ≤ 57 def isAlphanum (c : Char) : Bool := c.isAlpha || c.isDigit def toLower (c : Char) : Char := let n := toNat c; if n >= 65 ∧ n <= 90 then ofNat (n + 32) else c def toUpper (c : Char) : Char := let n := toNat c; if n >= 97 ∧ n <= 122 then ofNat (n - 32) else c end Char
lemma and_symm (P Q : Prop) : P ∧ Q → Q ∧ P := begin intro h, cases h with p q, split, exact q, exact p, end
open function #print surjective universes u v w variables {α : Type u} {β : Type v} {γ : Type w} lemma surjective_comp {g : β → γ} {f : α → β} (hg : surjective g) (hf : surjective f) : surjective (g ∘ f) := λ z, let ⟨y, iy⟩ := hg z, ⟨x, ix⟩ := hf y in ⟨x, show g(f(x)) = z, by simp *⟩ #print surjective_comp
[STATEMENT] lemma compile_consE: assumes "(name, rhs') # rest = compile rs" "is_fmap rs" obtains rhs where "rhs' = pterm_to_sterm rhs" "(name, rhs) |\<in>| rs" "rest = compile (rs - {| (name, rhs) |})" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] from assms [PROOF STATE] proof (chain) picking this: (name, rhs') # rest = Rewriting_Sterm.compile rs is_fmap rs [PROOF STEP] have "ordered_fmap (map_prod id pterm_to_sterm |`| rs) = (name, rhs') # rest" [PROOF STATE] proof (prove) using this: (name, rhs') # rest = Rewriting_Sterm.compile rs is_fmap rs goal (1 subgoal): 1. ordered_fmap (map_prod id pterm_to_sterm |`| rs) = (name, rhs') # rest [PROOF STEP] unfolding compile_def [PROOF STATE] proof (prove) using this: (name, rhs') # rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs) is_fmap rs goal (1 subgoal): 1. ordered_fmap (map_prod id pterm_to_sterm |`| rs) = (name, rhs') # rest [PROOF STEP] by simp [PROOF STATE] proof (state) this: ordered_fmap (map_prod id pterm_to_sterm |`| rs) = (name, rhs') # rest goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] hence "(name, rhs') \<in> set (ordered_fmap (map_prod id pterm_to_sterm |`| rs))" [PROOF STATE] proof (prove) using this: ordered_fmap (map_prod id pterm_to_sterm |`| rs) = (name, rhs') # rest goal (1 subgoal): 1. (name, rhs') \<in> set (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) [PROOF STEP] by simp [PROOF STATE] proof (state) this: (name, rhs') \<in> set (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] have "(name, rhs') |\<in>| map_prod id pterm_to_sterm |`| rs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (name, rhs') |\<in>| map_prod id pterm_to_sterm |`| rs [PROOF STEP] apply (rule ordered_fmap_sound) [PROOF STATE] proof (prove) goal (2 subgoals): 1. is_fmap (map_prod id pterm_to_sterm |`| rs) 2. (name, rhs') \<in> set (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. is_fmap (map_prod id pterm_to_sterm |`| rs) [PROOF STEP] unfolding map_prod_def id_apply [PROOF STATE] proof (prove) goal (1 subgoal): 1. is_fmap ((\<lambda>(x, y). (x, pterm_to_sterm y)) |`| rs) [PROOF STEP] apply (rule is_fmap_image) [PROOF STATE] proof (prove) goal (1 subgoal): 1. is_fmap rs [PROOF STEP] apply fact [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (prove) goal (1 subgoal): 1. (name, rhs') \<in> set (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. (name, rhs') \<in> set (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) [PROOF STEP] by fact [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: (name, rhs') |\<in>| map_prod id pterm_to_sterm |`| rs goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] then [PROOF STATE] proof (chain) picking this: (name, rhs') |\<in>| map_prod id pterm_to_sterm |`| rs [PROOF STEP] obtain rhs where "rhs' = pterm_to_sterm rhs" "(name, rhs) |\<in>| rs" [PROOF STATE] proof (prove) using this: (name, rhs') |\<in>| map_prod id pterm_to_sterm |`| rs goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: rhs' = pterm_to_sterm rhs (name, rhs) |\<in>| rs goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] have "rest = compile (rs - {| (name, rhs) |})" [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|}) [PROOF STEP] unfolding compile_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = ordered_fmap (map_prod id pterm_to_sterm |`| (rs |-| {|(name, rhs)|})) [PROOF STEP] apply (subst inj_on_fimage_set_diff[where C = rs]) [PROOF STATE] proof (prove) goal (4 subgoals): 1. inj_on (map_prod id pterm_to_sterm) (fset rs) 2. rs |\<subseteq>| rs 3. {|(name, rhs)|} |\<subseteq>| rs 4. rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs |-| map_prod id pterm_to_sterm |`| {|(name, rhs)|}) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. inj_on (map_prod id pterm_to_sterm) (fset rs) [PROOF STEP] apply (rule inj_onI) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>x y. \<lbrakk>x \<in> fset rs; y \<in> fset rs; map_prod id pterm_to_sterm x = map_prod id pterm_to_sterm y\<rbrakk> \<Longrightarrow> x = y [PROOF STEP] apply safe [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>a b aa ba. \<lbrakk>(a, b) \<in> fset rs; (aa, ba) \<in> fset rs; map_prod id pterm_to_sterm (a, b) = map_prod id pterm_to_sterm (aa, ba)\<rbrakk> \<Longrightarrow> a = aa 2. \<And>a b aa ba. \<lbrakk>(a, b) \<in> fset rs; (aa, ba) \<in> fset rs; map_prod id pterm_to_sterm (a, b) = map_prod id pterm_to_sterm (aa, ba)\<rbrakk> \<Longrightarrow> b = ba [PROOF STEP] apply auto [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>a b ba. \<lbrakk>(a, b) \<in> fset rs; (a, ba) \<in> fset rs; pterm_to_sterm b = pterm_to_sterm ba\<rbrakk> \<Longrightarrow> b = ba [PROOF STEP] apply (subst (asm) fmember.rep_eq[symmetric])+ [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>a b ba. \<lbrakk>(a, b) |\<in>| rs; (a, ba) |\<in>| rs; pterm_to_sterm b = pterm_to_sterm ba\<rbrakk> \<Longrightarrow> b = ba [PROOF STEP] using \<open>is_fmap rs\<close> [PROOF STATE] proof (prove) using this: is_fmap rs goal (1 subgoal): 1. \<And>a b ba. \<lbrakk>(a, b) |\<in>| rs; (a, ba) |\<in>| rs; pterm_to_sterm b = pterm_to_sterm ba\<rbrakk> \<Longrightarrow> b = ba [PROOF STEP] by (blast dest: is_fmapD) [PROOF STATE] proof (prove) goal (3 subgoals): 1. rs |\<subseteq>| rs 2. {|(name, rhs)|} |\<subseteq>| rs 3. rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs |-| map_prod id pterm_to_sterm |`| {|(name, rhs)|}) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. rs |\<subseteq>| rs [PROOF STEP] by simp [PROOF STATE] proof (prove) goal (2 subgoals): 1. {|(name, rhs)|} |\<subseteq>| rs 2. rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs |-| map_prod id pterm_to_sterm |`| {|(name, rhs)|}) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. {|(name, rhs)|} |\<subseteq>| rs [PROOF STEP] using \<open>(name, rhs) |\<in>| rs\<close> [PROOF STATE] proof (prove) using this: (name, rhs) |\<in>| rs goal (1 subgoal): 1. {|(name, rhs)|} |\<subseteq>| rs [PROOF STEP] by simp [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs |-| map_prod id pterm_to_sterm |`| {|(name, rhs)|}) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs |-| map_prod id pterm_to_sterm |`| {|(name, rhs)|}) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = ordered_fmap (map_prod id pterm_to_sterm |`| rs |-| {|(name, pterm_to_sterm rhs)|}) [PROOF STEP] apply (subst ordered_fmap_remove) [PROOF STATE] proof (prove) goal (3 subgoals): 1. is_fmap (map_prod id pterm_to_sterm |`| rs) 2. (name, pterm_to_sterm rhs) |\<in>| map_prod id pterm_to_sterm |`| rs 3. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) [PROOF STEP] apply (subst map_prod_def) [PROOF STATE] proof (prove) goal (3 subgoals): 1. is_fmap ((\<lambda>(x, y). (id x, pterm_to_sterm y)) |`| rs) 2. (name, pterm_to_sterm rhs) |\<in>| map_prod id pterm_to_sterm |`| rs 3. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod id pterm_to_sterm |`| rs)) [PROOF STEP] unfolding id_apply [PROOF STATE] proof (prove) goal (3 subgoals): 1. is_fmap ((\<lambda>(x, y). (x, pterm_to_sterm y)) |`| rs) 2. (name, pterm_to_sterm rhs) |\<in>| map_prod (\<lambda>x. x) pterm_to_sterm |`| rs 3. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod (\<lambda>x. x) pterm_to_sterm |`| rs)) [PROOF STEP] apply (rule is_fmap_image) [PROOF STATE] proof (prove) goal (3 subgoals): 1. is_fmap rs 2. (name, pterm_to_sterm rhs) |\<in>| map_prod (\<lambda>x. x) pterm_to_sterm |`| rs 3. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod (\<lambda>x. x) pterm_to_sterm |`| rs)) [PROOF STEP] apply fact [PROOF STATE] proof (prove) goal (2 subgoals): 1. (name, pterm_to_sterm rhs) |\<in>| map_prod (\<lambda>x. x) pterm_to_sterm |`| rs 2. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod (\<lambda>x. x) pterm_to_sterm |`| rs)) [PROOF STEP] using \<open>(name, rhs) |\<in>| rs\<close> [PROOF STATE] proof (prove) using this: (name, rhs) |\<in>| rs goal (2 subgoals): 1. (name, pterm_to_sterm rhs) |\<in>| map_prod (\<lambda>x. x) pterm_to_sterm |`| rs 2. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod (\<lambda>x. x) pterm_to_sterm |`| rs)) [PROOF STEP] apply force [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = remove1 (name, pterm_to_sterm rhs) (ordered_fmap (map_prod (\<lambda>x. x) pterm_to_sterm |`| rs)) [PROOF STEP] apply (subst \<open>rhs' = pterm_to_sterm rhs\<close>[symmetric]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = remove1 (name, rhs') (ordered_fmap (map_prod (\<lambda>x. x) pterm_to_sterm |`| rs)) [PROOF STEP] apply (subst \<open>ordered_fmap _ = _\<close>[unfolded id_def]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. rest = remove1 (name, rhs') ((name, rhs') # rest) [PROOF STEP] by simp [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|}) goal (1 subgoal): 1. (\<And>rhs. \<lbrakk>rhs' = pterm_to_sterm rhs; (name, rhs) |\<in>| rs; rest = Rewriting_Sterm.compile (rs |-| {|(name, rhs)|})\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] show thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. thesis [PROOF STEP] by (rule that) fact+ [PROOF STATE] proof (state) this: thesis goal: No subgoals! [PROOF STEP] qed
variable {p: Prop} axiom double_negation: ¬¬p → p theorem not_not_excluded_middle: ¬¬(p ∨ ¬p) := assume (h: ¬(p ∨ ¬p)), have hnp: ¬p, from (assume hp: p, h (or.inl hp)), h (or.inr hnp) theorem excluded_middle: p ∨ ¬p := double_negation not_not_excluded_middle #check excluded_middle
[STATEMENT] lemma enum_all [simp]: "enum_all = HOL.All" [PROOF STATE] proof (prove) goal (1 subgoal): 1. enum_all = All [PROOF STEP] by (simp add: fun_eq_iff enum_all_UNIV)
lemma prime_nat_numeral_eq [simp]: "prime (numeral m :: nat) \<longleftrightarrow> (1::nat) < numeral m \<and> (\<forall>n::nat \<in> set [2..<numeral m]. \<not> n dvd numeral m)"
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-| Module : Grenade.Layers.Dropout Description : Defines the Dropout Layer Dropout is a regularization method used to prevent overfitting of the network to the training dataset. It works by randomly "dropping out", i.e. ignoring, outputs of a percentage of neurons. This is strategy is effective in preventing overfitting as it forces a NN not to rely on a single feature for computing the output of a neural network -} module Grenade.Layers.Dropout ( Dropout (..) , randomDropout ) where import Control.DeepSeq import Control.Monad.Primitive (PrimBase, PrimState) import Data.Proxy import Data.Serialize import GHC.Generics hiding (R) import GHC.TypeLits import Numeric.LinearAlgebra.Static hiding (Seed) import System.Random.MWC import Grenade.Core -- Dropout layer help to reduce overfitting. -- Idea here is that the vector is a shape of 1s and 0s, which we multiply the input by. -- After backpropogation, we return a new matrix/vector, with different bits dropped out. -- The provided argument is the proportion to drop in each training iteration (like 1% or -- 5% would be reasonable). data Dropout (pct :: Nat) = Dropout { dropoutActive :: Bool -- ^ Add possibility to deactivate dropout , dropoutSeed :: !Int -- ^ Seed } deriving (Generic) instance NFData (Dropout pct) where rnf (Dropout a s) = rnf a `seq` rnf s instance Show (Dropout pct) where show (Dropout _ _) = "Dropout" instance Serialize (Dropout pct) where put (Dropout act seed) = put act >> put seed get = Dropout <$> get <*> get instance UpdateLayer (Dropout pct) where type Gradient (Dropout pct) = () runUpdate _ (Dropout act seed) _ = Dropout act (seed+1) runSettingsUpdate set (Dropout _ seed) = Dropout (setDropoutActive set) seed reduceGradient _ = () instance RandomLayer (Dropout pct) where createRandomWith _ = randomDropout randomDropout :: (PrimBase m) => Gen (PrimState m) -> m (Dropout pct) randomDropout gen = Dropout True <$> uniform gen instance (KnownNat pct, KnownNat i) => Layer (Dropout pct) ('D1 i) ('D1 i) where type Tape (Dropout pct) ('D1 i) ('D1 i) = R i runForwards (Dropout act seed) (S1D x) | not act = (v, S1D $ dvmap (rate *) x) -- multily with rate to normalise throughput | otherwise = (v, S1D $ v * x) where rate = (/100) $ fromIntegral $ max 0 $ min 100 $ natVal (Proxy :: Proxy pct) v = dvmap mask $ randomVector seed Uniform mask r | not act || r < rate = 1 | otherwise = 0 runBackwards (Dropout _ _) v (S1D x) = ((), S1D $ x * v)
% example_2 - inversion of a fractional F(s) clear, close all [t1,ft1]=INVLAP('1/(sqrt(s)*s)',0.01,5,200,6,40,20); [t2,ft2]=INVLAP('(20.5+3.7343*s^1.15)/(21.5+3.7343*s^1.15+0.8*s^2.2+0.5*s^0.9)/s',0.01,5,200); figure(4) set(4,'color','white') subplot(2,1,1) plot(t1,ft1), grid on, zoom on xlabel('t [s]'), ylabel('f(t)') %title(' subplot(2,1,2) plot(t2,ft2), grid on, zoom xlabel('t [s]'), ylabel('f(t)') title('step response of a fractional control system')
(** Proof the causal memory implementation w.r.t. modular specification. *) From iris.algebra Require Import agree auth excl gmap. From iris.base_logic Require Import invariants. From iris.base_logic Require Export gen_heap. From iris.proofmode Require Import tactics. From aneris.aneris_lang Require Import lang network tactics proofmode lifting. From aneris.prelude Require Import misc. From aneris.aneris_lang.lib Require Import list_proof map_proof lock_proof network_util_proof inject. From aneris.aneris_lang.program_logic Require Import lightweight_atomic. From aneris.aneris_lang.lib.vector_clock Require Import vector_clock_proof. From aneris.aneris_lang.lib.serialization Require Import serialization_proof. From aneris.examples.rcb Require Import rcb_code. From aneris.examples.rcb.spec Require Import base. From aneris.examples.rcb.model Require Import model_lst model_gst model_update_system model_update_lst model_update_gst. From aneris.examples.rcb.resources Require Import base resources_global resources_lhst resources_local_inv resources_global_inv. Section proof. Context `{!anerisG Mdl Σ, !RCB_params, !internal_RCBG Σ}. Context (γGauth γGsnap : gname) (γLs : list gname). Lemma wp_is_causally_next n (vt : val) (t : vector_clock) (i : nat) : {{{ ⌜is_vc vt t⌝ ∗ ⌜length t = length RCB_addresses⌝ }}} is_causally_next vt #i @[n] {{{(f : val), RET f; ∀ (w : global_event), {{{ True }}} f ($ w) @[n] {{{(b : bool), RET #b; if b then ⌜w.(ge_orig) ≠ i ∧ length w.(ge_time) = length t ∧ w.(ge_time) !! w.(ge_orig) = Some (S (default 0 (t !! w.(ge_orig)))) ∧ (∀ j, j < length RCB_addresses → j ≠ w.(ge_orig) → default 0 (w.(ge_time) !! j) <= default 0 (t !! j))⌝ else True }}} }}}. Proof. iIntros (Φ) "[Ht Htlen] HΦ". iDestruct "Ht" as %Ht. iDestruct "Htlen" as %Htlen. rewrite /is_causally_next. wp_pures. wp_apply wp_list_length; first done. iIntros (k Hk). wp_pures. iApply "HΦ". clear Φ. iIntros (w vw Φ) "!# HΦ". wp_pures. destruct (decide (i = w.(ge_orig))) as [->|Hioe]. { rewrite bool_decide_eq_true_2; last lia. wp_pures. iApply "HΦ"; done. } rewrite bool_decide_eq_false_2; last lia. wp_pures. destruct (decide (w.(ge_orig) < length RCB_addresses)) as [Hlt|]; last first. { rewrite bool_decide_eq_false_2; last lia. wp_pures. iApply "HΦ"; done. } rewrite bool_decide_eq_true_2; last lia. wp_pures. wp_apply (wp_vect_applicable _ _ _ w.(ge_time) t with "[]"); [by iSplit; iPureIntro; first apply vector_clock_to_val_is_vc|]. iIntros (b) "Hb". iApply ("HΦ" with "[Hb]"). destruct b; last done. iDestruct "Hb" as %(Hb1 & Hb2 & Hb3). iPureIntro. split_and!; [lia|lia| |]. - destruct (lookup_lt_is_Some_2 w.(ge_time) w.(ge_orig)) as [wto Hwto]; first lia. destruct (lookup_lt_is_Some_2 t w.(ge_orig)) as [two Htwo]; first lia. rewrite Hwto Htwo in Hb2. inversion Hb2 as [? ? ->|]; simplify_eq; simpl. rewrite Htwo Hwto /=. f_equal; lia. - intros j Hj1 Hj2. destruct (lookup_lt_is_Some_2 w.(ge_time) j) as [wj Hwj]; first lia. destruct (lookup_lt_is_Some_2 t j) as [tj Htj]; first lia. rewrite Htj Hwj /=. assert (ge_orig w ≠ j) as Hj2' by done. specialize (Hb3 j wj tj Hj2' Hwj Htj). eauto with lia. Qed. Definition internal_deliver_spec (deliver_fn : val) (i : nat) (z : socket_address) : iProp Σ := ⌜RCB_addresses !! i = Some z⌝ -∗ <<< ∀∀ (s : gset local_event), lhst_user γLs i s >>> deliver_fn #() @[ip_of_address z] ↑RCB_InvName <<<▷ ∃∃ s' vo, RET vo; lhst_user γLs i s' ∗ ((⌜s' = s⌝ ∗ ⌜vo = NONEV⌝) ∨ (∃ a , ⌜s' = s ∪ {[ a ]}⌝ ∗ ⌜a ∉ s⌝ ∗ ⌜a ∈ compute_maximals le_time s'⌝ ∗ ⌜not (a.(le_orig) = i)⌝ ∗ own_global_snap γGsnap {[ erase a ]} ∗ ∃ v, ⌜vo = SOMEV v⌝ ∗ ⌜is_lev v a⌝)) >>>. Lemma internal_deliver_spec_holds (i : nat) (z : socket_address) (T SeenLoc IQ OQ : loc) (lk : val) (γlk : gname) : {{{ Global_Inv γGauth γGsnap γLs ∗ local_invariant γGsnap γLs i T SeenLoc IQ OQ lk γlk z ∗ ⌜ip_of_address <$> RCB_addresses !! i = Some (ip_of_address z)⌝ }}} deliver #T lk #IQ #i @[ip_of_address z] {{{ (fv : val), RET fv; internal_deliver_spec fv i z }}}. Proof. rewrite /deliver /local_invariant. remember (ip_of_address z) as ip. iIntros (Φ) "(#Ginv & #Linv & %Hip) HΦ". wp_pures. iApply "HΦ"; clear Φ. iIntros "#Haddr". iIntros "!>" (Φ) "Hvs". wp_pures. rewrite Heqip. wp_apply acquire_spec; first iExact "Linv". iIntros (?) "(-> & Hlk & Hli)". rewrite /local_inv_def. iDestruct "Hli" as (vt vseen viq voq t seenv liq loq s' ip') "(%Hip'& HT & %Hvc & Hseen & %Hseen_vc & %Hseen_len & HIQ & HOQ & Hlhst & %Hlstv)". assert (ip = ip') as ->. { rewrite Hip in Hip'. inversion Hip'; done. } clear Hip'. subst. iDestruct "HIQ" as "(HIQ & %Hviq & Hliq)". wp_pures. wp_load. wp_load. wp_apply wp_is_causally_next. { iSplit; first done. rewrite (RCBM_LSTV_time_length Hlstv); done. } iIntros (f) "#Hf /=". wp_apply (wp_find_remove); [|done|]. { iIntros (? ? _) "!> HΦ". iApply "Hf"; first done. iNext. iIntros (b) "Hb". iApply "HΦ". destruct b; first iExact "Hb"; done. } iIntros (v) "[->|Hv]". { wp_pures. wp_apply (release_spec with "[$Hlk HT Hseen HOQ HIQ Hliq Hlhst]"). { eauto 20 with iFrame. } iIntros (v ->). wp_bind (Rec _ _ _). iApply (aneris_wp_atomic _ _ (↑RCB_InvName)). iMod "Hvs". iModIntro. wp_pure _. iDestruct "Hvs" as (x) "[Hu Hupd]". iMod ("Hupd" with "[$Hu]") as "HΦ". { iLeft. eauto. } iModIntro. wp_pures. iApply "HΦ". } iDestruct "Hv" as (a lv' l1 l2) "((->&->&%Hlv')&%Honi&%Hwtlen&%Hwtoa&%Hwtnoa)". wp_pures. wp_store. wp_load. assert (a.(ge_orig) < length t). { apply lookup_lt_Some in Hwtoa; lia. } destruct (lookup_lt_is_Some_2 t a.(ge_orig)); first done. wp_apply wp_vect_inc; [|done|done|]; first lia. iIntros (vt' Hvt'); simpl. wp_store. iDestruct "Hliq" as "(Hliq1 & (%Hne & #Ha) & Hliq2)". iCombine "Hliq1" "Hliq2" as "Hliq". rewrite -big_sepL_app. set (e := LocalEvent a.(ge_payload) a.(ge_time) a.(ge_orig) (S (length (elements s')))). assert (a = erase e) as Herase. { destruct a; done. } pose proof (RCBM_LSTV_at Hlstv). pose proof (RCBM_LSTV_time_length Hlstv) as Htlen; rewrite /= /RCBM_lst_time_length in Htlen. assert (e ∉ s') as Hes'. { apply (RCBM_system_local_event_fresh_lhst e i t); eauto with lia. } wp_bind (InjR _). do 2 wp_pure _. iApply (aneris_wp_atomic _ _ (↑RCB_InvName)). iMod "Hvs". iModIntro. wp_pures. iDestruct "Hvs" as (s) "[Hu Himpl]". iDestruct (lhst_user_lock_agree with "Hu Hlhst") as %->. iInv RCB_InvName as (G Ss) "(>% & >Hgsys & >Hl & >%Hvl)" "Hclos_inv". iDestruct (own_global_snap_lookup with "Hgsys Ha") as "%Hina". iDestruct (lhst_user_lookup with "Hl Hu") as %His'. iDestruct (lhst_lock_lookup with "Hl Hlhst") as %His''. assert (e ∈ compute_maximals le_time (s' ∪ {[ e ]})) as Hemax. { remember {| Lst_time := t; Lst_hst := s' |} as lst. replace s' with lst.(Lst_hst); [ | by rewrite Heqlst ]. eapply RCBM_Lst_valid_compute_maximals; [done |]. rewrite /e; simpl. replace (Lst_time lst) with t; [eauto | ]. rewrite Heqlst; done. } assert (RCBM_Lst_valid i {| Lst_time := incr_time t (ge_orig a); Lst_hst := s' ∪ {[e]} |}). { apply (RCBM_lst_update_apply i {| Lst_time := t; Lst_hst := s' |} (erase e)); rewrite /e; [done | done |]. split_and!; simpl; auto with lia. } assert (RCBM_Gst_valid {| Gst_ghst := G; Gst_hst := <[i := s' ∪ {[e]} ]>Ss |}). { rewrite /e. apply (RCBM_system_apply_update_gst i {| Gst_ghst := G |} {| Lst_time := t; Lst_hst := s' |} a ); simpl; eauto with set_solver. split_and!; simpl; eauto with lia. } iMod (lhst_update _ _ _ _ e with "Hu Hlhst Hl") as "(Hu & Hlhst & Hl)". iMod ("Hclos_inv" with "[Hgsys Hl]") as "_". { eauto 15 with iFrame. } rewrite Herase. iMod ("Himpl" with "[$Hu]") as "HΦ". { iRight. iExists e. iFrame "#". repeat iSplit; eauto. iExists $(erase e). iSplit; eauto. iPureIntro. simpl. eexists _, _, _. eauto using vector_clock_to_val_is_vc. } iModIntro. wp_pures. wp_apply (release_spec with "[$Hlk HT Hseen HOQ HIQ Hliq Hlhst]"). { iFrame "Linv". iExists _, _, _, _, _, _, _, _. iExists _, _. iSplitL ""; [by iPureIntro |]. iSplitL "HT"; [iFrame |]. iSplitL ""; [by iPureIntro|]. iFrame; iFrame "#". repeat iSplit; eauto. iPureIntro. rewrite Hseen_len. symmetry. apply incr_time_length. } iIntros (? ->). wp_seq. iApply "HΦ". Qed. End proof.
integer aa0,aa00,aa0000,aa000000, . Naa,Paa,Namax parameter(aa0=1) parameter(aa00= 2) parameter(aa0000=3) parameter(aa000000=4) parameter(Naa=4) parameter(Paa=1) parameter(Namax=10)
/- Copyright (c) 2021 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Tactic.Basic import Std.Tactic.Simpa import Mathlib.Data.Array.Basic structure UFModel (n) where parent : Fin n → Fin n rank : Nat → Nat rank_lt : ∀ i, (parent i).1 ≠ i → rank i < rank (parent i) namespace UFModel def empty : UFModel 0 where parent i := i.elim0 rank _ := 0 rank_lt i := i.elim0 def push {n} (m : UFModel n) (k) (le : n ≤ k) : UFModel k where parent i := if h : i < n then let ⟨a, h'⟩ := m.parent ⟨i, h⟩ ⟨a, lt_of_lt_of_le h' le⟩ else i rank i := if i < n then m.rank i else 0 rank_lt i := by simp; split <;> rename_i h · simp [(m.parent ⟨i, h⟩).2, h]; exact m.rank_lt _ · intro. def setParent {n} (m : UFModel n) (x y : Fin n) (h : m.rank x < m.rank y) : UFModel n where parent i := if x.1 = i then y else m.parent i rank := m.rank rank_lt i := by simp; split <;> rename_i h' · rw [← h']; exact fun _ ↦ h · exact m.rank_lt i def setParentBump {n} (m : UFModel n) (x y : Fin n) (H : m.rank x ≤ m.rank y) (hroot : (m.parent y).1 = y) : UFModel n where parent i := if x.1 = i then y else m.parent i rank i := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i rank_lt i := by simp; split <;> (rename_i h₁; simp [h₁]; split <;> rename_i h₂ <;> (intro h; simp [h] at h₂ <;> simp [h₁, h₂, h])) · simp [← h₁]; split <;> rename_i h₃ · rw [h₃]; apply Nat.lt_succ_self · exact lt_of_le_of_ne H h₃ · have := Fin.eq_of_val_eq h₂.1; subst this simp [hroot] at h · have := m.rank_lt i h split <;> rename_i h₃ · rw [h₃.1]; exact Nat.lt_succ_of_lt this · exact this end UFModel structure UFNode (α : Type _) where parent : Nat value : α rank : Nat inductive UFModel.Agrees (arr : Array α) (f : α → β) : ∀ {n}, (Fin n → β) → Prop | mk : Agrees arr f fun i ↦ f (arr.get i) namespace UFModel.Agrees theorem mk' {arr : Array α} {f : α → β} {n} {g : Fin n → β} (e : n = arr.size) (H : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = g ⟨i, h₂⟩) : Agrees arr f g := by cases e have : (fun i ↦ f (arr.get i)) = g := by funext ⟨i, h⟩; apply H cases this; constructor theorem get_eq {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = m ⟨i, h₂⟩ := by cases H; exact fun i h _ ↦ rfl theorem get_eq' {arr : Array α} {m : Fin arr.size → β} (H : Agrees arr f m) (i) : f (arr.get i) = m i := H.get_eq .. theorem empty {f : α → β} {g : Fin 0 → β} : Agrees #[] f g := mk' rfl λ. theorem push {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) (k) (hk : k = n + 1) (x) (m' : Fin k → β) (hm₁ : ∀ (i : Fin k) (h : i < n), m' i = m ⟨i, h⟩) (hm₂ : ∀ (h : n < k), f x = m' ⟨n, h⟩) : Agrees (arr.push x) f m' := by cases H have : k = (arr.push x).size := by simp [hk] refine mk' this fun i h₁ h₂ ↦ ?_ simp [Array.get_push]; split <;> (rename_i h; simp at hm₁ ⊢) · rw [← hm₁ ⟨i, h₂⟩]; assumption · cases show i = arr.size by apply le_antisymm <;> simp_all [Nat.lt_succ] rw [hm₂] theorem set {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) {i : Fin arr.size} {x} {m' : Fin n → β} (hm₁ : ∀ (j : Fin n), j.1 ≠ i → m' j = m j) (hm₂ : ∀ (h : i < n), f x = m' ⟨i, h⟩) : Agrees (arr.set i x) f m' := by cases H refine mk' (by simp) fun j hj₁ hj₂ ↦ ?_ suffices f (Array.set arr i x)[j] = m' ⟨j, hj₂⟩ by simp_all [Array.get_set] by_cases h : i = j · subst h; rw [Array.get_set_eq, ← hm₂] · rw [arr.get_set_ne _ _ _ h, hm₁ ⟨j, _⟩ (Ne.symm h)]; rfl end UFModel.Agrees def UFModel.Models (arr : Array (UFNode α)) {n} (m : UFModel n) := UFModel.Agrees arr (·.parent) (fun i ↦ m.parent i) ∧ UFModel.Agrees arr (·.rank) (fun i : Fin n ↦ m.rank i) namespace UFModel.Models theorem size_eq {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr) : n = arr.size := H.1.size_eq theorem parent_eq {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr) (i : Nat) (h₁ : i < arr.size) (h₂) : arr[i].parent = m.parent ⟨i, h₂⟩ := H.1.get_eq .. theorem parent_eq' {arr : Array (UFNode α)} {m : UFModel arr.size} (H : m.Models arr) (i : Fin arr.size) : (arr[i.1]).parent = m.parent i := H.parent_eq .. theorem rank_eq {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr) (i : Nat) (h : i < arr.size) : arr[i].rank = m.rank i := H.2.get_eq _ _ (by rw [H.size_eq]; exact h) theorem empty : UFModel.empty.Models (α := α) #[] := ⟨Agrees.empty, Agrees.empty⟩ theorem push {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr) (k) (hk : k = n + 1) (x) : (m.push k (hk ▸ Nat.le_add_right ..)).Models (arr.push ⟨n, x, 0⟩) := by apply H.imp <;> · intro H refine H.push _ hk _ _ (fun i h ↦ ?_) (fun h ↦ ?_) <;> simp [UFModel.push, h, lt_irrefl] theorem setParent {arr : Array (UFNode α)} {n} {m : UFModel n} (hm : m.Models arr) (i j H hi x) (hp : x.parent = j.1) (hrk : x.rank = arr[i].rank) : (m.setParent i j H).Models (arr.set ⟨i.1, hi⟩ x) := ⟨hm.1.set (fun k (h : (k:ℕ) ≠ i) ↦ by simp [UFModel.setParent, h.symm]) (fun h ↦ by simp [UFModel.setParent, hp]), hm.2.set (fun _ _ ↦ rfl) (fun _ ↦ hrk.trans $ hm.2.get_eq ..)⟩ end UFModel.Models structure UnionFind (α) where arr : Array (UFNode α) model : ∃ (n : _) (m : UFModel n), m.Models arr namespace UnionFind def size (self : UnionFind α) := self.arr.size theorem model' (self : UnionFind α) : ∃ (m : UFModel self.arr.size), m.Models self.arr := by let ⟨n, m, hm⟩ := self.model; cases hm.size_eq; exact ⟨m, hm⟩ def empty : UnionFind α where arr := #[] model := ⟨_, _, UFModel.Models.empty⟩ def mkEmpty (c : Nat) : UnionFind α where arr := Array.mkEmpty c model := ⟨_, _, UFModel.Models.empty⟩ def rank (self : UnionFind α) (i : Nat) : Nat := if h : i < self.size then (self.arr.get ⟨i, h⟩).rank else 0 def rankMaxAux (self : UnionFind α) : ∀ (i : Nat), {k : Nat // ∀ j < i, ∀ h, (self.arr.get ⟨j, h⟩).rank ≤ k} | 0 => ⟨0, λ.⟩ | i+1 => by let ⟨k, H⟩ := rankMaxAux self i refine ⟨max k (if h : _ then (self.arr.get ⟨i, h⟩).rank else 0), fun j hj h ↦ ?_⟩ match j, lt_or_eq_of_le (Nat.le_of_lt_succ hj) with | j, Or.inl hj => exact le_trans (H _ hj h) (le_max_left _ _) | _, Or.inr rfl => simp [h, le_max_right] def rankMax (self : UnionFind α) := (rankMaxAux self self.size).1 + 1 theorem lt_rankMax' (self : UnionFind α) (i : Fin self.size) : (self.arr.get i).rank < self.rankMax := Nat.lt_succ.2 $ (rankMaxAux self self.size).2 _ i.2 _ theorem lt_rankMax (self : UnionFind α) (i : Nat) : self.rank i < self.rankMax := by simp [rank]; split; {apply lt_rankMax'}; apply Nat.succ_pos theorem rank_eq (self : UnionFind α) {n} {m : UFModel n} (H : m.Models self.arr) {i} (h : i < self.size) : self.rank i = m.rank i := by simp [rank, h, H.rank_eq] theorem rank_lt (self : UnionFind α) {i : Nat} (h) : self.arr[i].parent ≠ i → self.rank i < self.rank self.arr[i].parent := by let ⟨m, hm⟩ := self.model' simpa [hm.parent_eq, hm.rank_eq, rank, size, h, (m.parent ⟨i, h⟩).2] using m.rank_lt ⟨i, h⟩ theorem parent_lt (self : UnionFind α) (i : Nat) (h) : self.arr[i].parent < self.size := by let ⟨m, hm⟩ := self.model' simp [hm.parent_eq, size, (m.parent ⟨i, h⟩).2, h] def push (self : UnionFind α) (x : α) : UnionFind α where arr := self.arr.push ⟨self.arr.size, x, 0⟩ model := let ⟨_, hm⟩ := self.model'; ⟨_, _, hm.push _ rfl _⟩ def findAux (self : UnionFind α) (x : Fin self.size) : (s : Array (UFNode α)) ×' (root : Fin s.size) ×' ∃ n, ∃ (m : UFModel n) (m' : UFModel n), m.Models self.arr ∧ m'.Models s ∧ m'.rank = m.rank ∧ (∃ hr, (m'.parent ⟨root, hr⟩).1 = root) ∧ m.rank x ≤ m.rank root := by let y := self.arr[x].parent refine if h : y = x then ⟨self.arr, x, ?a'⟩ else have := Nat.sub_lt_sub_left (self.lt_rankMax x) (self.rank_lt _ h) let ⟨arr₁, root, H⟩ := self.findAux ⟨y, self.parent_lt _ x.2⟩ have hx := ?hx let arr₂ := arr₁.set ⟨x, hx⟩ {arr₁.get ⟨x, hx⟩ with parent := root} ⟨arr₂, ⟨root, by simp [root.2]⟩, ?b'⟩ -- start proof case a' => -- FIXME: hygiene bug causes `case a` to fail let ⟨m, hm⟩ := self.model' exact ⟨_, m, m, hm, hm, rfl, ⟨x.2, by rwa [← hm.parent_eq]⟩, le_refl _⟩ all_goals let ⟨n, m, m', hm, hm', e, ⟨_, hr⟩, le⟩ := H case hx => exact hm'.size_eq ▸ hm.size_eq.symm ▸ x.2 case b' => let x' : Fin n := ⟨x, hm.size_eq ▸ x.2⟩ let root : Fin n := ⟨root, hm'.size_eq.symm ▸ root.2⟩ have hy : (UFModel.parent m x').1 = y := by rw [← hm.parent_eq x x.2 x'.2]; rfl have := m.rank_lt x'; rw [hy] at this have := lt_of_lt_of_le (this h) le refine ⟨n, m, _, hm, hm'.setParent x' root (by rw [e]; exact this) hx _ rfl rfl, e, ⟨root.2, ?_⟩, le_of_lt this⟩ have : x.1 ≠ root := mt (congrArg _) (ne_of_lt this); dsimp only at this simp [UFModel.setParent, this, hr] termination_by _ α self x => self.rankMax - self.rank x def find (self : UnionFind α) (x : Fin self.size) : (s : UnionFind α) × (root : Fin s.size) ×' s.size = self.size ∧ (s.arr.get root).parent = root := let ⟨s, root, H⟩ := self.findAux x have : _ ∧ s.size = self.size ∧ s[root.1].parent = root := let ⟨n, _, m', hm, hm', _, ⟨_, hr⟩, _⟩ := H ⟨⟨n, m', hm'⟩, hm'.size_eq.symm.trans hm.size_eq, by rwa [hm'.parent_eq]⟩ ⟨⟨s, this.1⟩, root, this.2⟩ def link (self : UnionFind α) (x y : Fin self.size) (yroot : (self.arr.get y).parent = y) : UnionFind α := by refine if ne : x.1 = y then self else let nx := self.arr[x] let ny := self.arr[y] if h : ny.rank < nx.rank then ⟨self.arr.set y {ny with parent := x}, ?a⟩ else let arr₁ := self.arr.set x {nx with parent := y} let arr₂ := if nx.rank = ny.rank then arr₁.set ⟨y, by simp; exact y.2⟩ {ny with rank := ny.rank + 1} else arr₁ ⟨arr₂, ?b⟩ -- start proof case a => let ⟨m, hm⟩ := self.model' exact ⟨_, _, hm.setParent y x (by simpa [hm.rank_eq] using h) _ _ rfl rfl⟩ case b => let ⟨m, hm⟩ := self.model'; let n := self.size refine ⟨_, m.setParentBump x y (by simpa [hm.rank_eq] using h) (by simpa [← hm.parent_eq'] using yroot), ?_⟩ let parent (i : Fin n) := (if x.1 = i then y else m.parent i).1 have : UFModel.Agrees arr₁ (·.parent) parent := hm.1.set (fun i h ↦ by simp; rw [if_neg h.symm]) (fun h ↦ by simp) have H1 : UFModel.Agrees arr₂ (·.parent) parent := by simp; split · exact this.set (fun i h ↦ by simp [h.symm]) (fun h ↦ by simp [ne, hm.parent_eq']) · exact this have : UFModel.Agrees arr₁ (·.rank) (fun i : Fin n ↦ m.rank i) := hm.2.set (fun i _ ↦ by simp) (fun _ ↦ by simp [hm.rank_eq]) let rank (i : Fin n) := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i have H2 : UFModel.Agrees arr₂ (·.rank) rank := by simp; split <;> (rename_i xy; simp [hm.rank_eq] at xy; simp [xy]) · exact this.set (fun i h ↦ by rw [if_neg h.symm]) (fun h ↦ by simp [hm.rank_eq]) · exact this exact ⟨H1, H2⟩ def union (self : UnionFind α) (x y : Fin self.size) : UnionFind α := let ⟨self₁, rx, e, _⟩ := self.find x let ⟨self₂, ry, e, hry⟩ := self₁.find ⟨y, by rw [e]; exact y.2⟩ self₂.link ⟨rx, by rw [e]; exact rx.2⟩ ry hry
using MeshCat using GeometryBasics using Dojo using DojoEnvironments vis = Visualizer() render(vis) include(joinpath(@__DIR__, "..", "..", "..", "DojoEnvironments/src/utilities.jl")) include(joinpath(@__DIR__, "..", "..", "..", "DojoEnvironments/src/panda/methods/initialize.jl")) mech = get_panda( timestep=0.01, gravity=0.0 * 9.81, spring=1.0, damper=100.0, # contact=true, model_type=:no_end_effector, limits=false, object_type=:box, ) nu = input_dimension(mech) function ctrl!(m, k; kp=10.0, kd=5.0) pref = [0,-0.8,0,1.6,0,-2.4]#,0.5 * π] y = get_minimal_state(m) p = y[12 .+ (1:2:12)] v = y[12 .+ (2:2:12)] u = [ 5.0 * kp * [1,1.0e-1,1.0e-1,1.0e-1,1.0e-1,1.0e-1] .* (pref - p) - kd * v; [0.0; 0.0; -1.0 * get_body(m, :box).mass * 9.81]; zeros(3); ] set_input!(m, u*m.timestep) return nothing end joint_angles = [1.3,-0.85,0.3,1.3,0.3,-2.0]#,0.5 * π] joint_velocities = [0,0,0,0,0,0]#,0] y = zeros(length(get_minimal_state(mech))) y[1:3] = [0.5; 0.5; 0.125] for i = 1:6 y[12 + (i - 1) * 2 .+ (1:2)] = [joint_angles[i]; joint_velocities[i]] end set_minimal_state!(mech, y) # set_minimal_state!(mech, copy(y_start[12 .+ (1:18)])) # set_minimal_state!(mech, copy(y_start)) box_body = get_body(mech, :box) box_body.state.q2 = RotZ(0.25 * π) storage = simulate!(mech, 5.0, ctrl!, verbose=true, opts=SolverOptions(verbose=true, rtol=1.0e-6, btol=1.0e-6)); vis, anim = visualize(mech, storage, vis=vis, show_contact=false) setobject!(vis["ee"], GeometryBasics.Sphere(Point3f0(0), convert(Float32, mech.contacts[1].model.collision.radius_sphere)), MeshPhongMaterial(color = RGBA(0.0, 1.0, 0.0, 1.0))) for t in 1:length(storage) MeshCat.atframe(anim, t) do MeshCat.settransform!(vis["ee"], MeshCat.Translation(storage.x[5][t] + vector_rotate(mech.contacts[1].model.collision.origin_sphere, storage.q[5][t]))) end end MeshCat.setanimation!(vis, anim)
(* Title: HOL/Isar_Examples/Drinker.thy Author: Makarius *) section \<open>The Drinker's Principle\<close> theory Drinker imports Main begin text \<open> Here is another example of classical reasoning: the Drinker's Principle says that for some person, if he is drunk, everybody else is drunk! We first prove a classical part of de-Morgan's law. \<close> lemma de_Morgan: assumes "\<not> (\<forall>x. P x)" shows "\<exists>x. \<not> P x" proof (rule classical) assume "\<nexists>x. \<not> P x" hence "\<forall>x. P x" by blast with assms show ?thesis by contradiction qed theorem Drinker's_Principle: "\<exists>x. drunk x \<longrightarrow> (\<forall>x. drunk x)" proof (cases "\<forall>x. drunk x") case True then show ?thesis by blast next case False then show ?thesis by blast qed end
(* week_39a_binary_trees.v *) (* dIFP 2014-2015, Q1, Week 38 *) (* Olivier Danvy <[email protected]> *) (* ********** *) Require Import Arith Bool unfold_tactic. (* ********** *) Inductive binary_tree_nat : Type := | Leaf : nat -> binary_tree_nat | Node : binary_tree_nat -> binary_tree_nat -> binary_tree_nat. Definition bt_0 := Leaf 42. Definition bt_1 := Node (Leaf 10) (Leaf 20). Definition bt_2 := Node (Node (Leaf 10) (Leaf 20)) (Leaf 30). (* Print bt_2. bt_2 = Node (Node (Leaf 10) (Leaf 20)) (Leaf 30) : binary_tree_nat *) (* ********** *) (* A unit test: *) Notation "A =n= B" := (beq_nat A B) (at level 70, right associativity). Definition unit_test_for_number_of_leaves (candidate : binary_tree_nat -> nat) := (candidate bt_0 =n= 1) && (candidate bt_1 =n= 2) && (candidate bt_2 =n= 3) && (candidate (Node bt_1 bt_2) =n= 5) . Definition specification_of_number_of_leaves (number_of_leaves : binary_tree_nat -> nat) := (forall n : nat, number_of_leaves (Leaf n) = 1) /\ (forall t1 t2 : binary_tree_nat, number_of_leaves (Node t1 t2) = (number_of_leaves t1) + (number_of_leaves t2)). Theorem there_is_only_one_number_of_leaves : forall f g : binary_tree_nat -> nat, specification_of_number_of_leaves f -> specification_of_number_of_leaves g -> forall t : binary_tree_nat, f t = g t. Proof. intros f g. unfold specification_of_number_of_leaves. intros [Hf_leaf Hf_node] [Hg_leaf Hg_node]. intro t. induction t as [n | t1 IHt1 t2 IHt2]. rewrite -> Hf_leaf. rewrite -> Hg_leaf. reflexivity. rewrite -> Hf_node. rewrite -> Hg_node. rewrite -> IHt1. rewrite -> IHt2. reflexivity. Qed. Fixpoint number_of_leaves_ds (t : binary_tree_nat) : nat := match t with | Leaf n => 1 | Node t1 t2 => (number_of_leaves_ds t1) + (number_of_leaves_ds t2) end. Lemma unfold_number_of_leaves_ds_leaf : forall n : nat, number_of_leaves_ds (Leaf n) = 1. Proof. unfold_tactic number_of_leaves_ds. Qed. Lemma unfold_number_of_leaves_ds_node : forall t1 t2 : binary_tree_nat, number_of_leaves_ds (Node t1 t2) = (number_of_leaves_ds t1) + (number_of_leaves_ds t2). Proof. unfold_tactic number_of_leaves_ds. Qed. Definition number_of_leaves_v0 (t : binary_tree_nat) : nat := number_of_leaves_ds t. Compute unit_test_for_number_of_leaves number_of_leaves_v0. (* = true : bool *) (* Homework: write a version number_of_leaves_v1 that uses an accumulator. *) (* ********** *) (* Exercise: do the same as above for computing the number of nodes of a binary tree. *) (* ********** *) (* end of week_39a_binary_trees.v *)
/** * * @file zcposv.c * * PLASMA computational routines * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Emmanuel Agullo * @date 2010-11-15 * @precisions mixed zc -> ds * **/ #include <stdlib.h> #include <math.h> #include <lapacke.h> #include "common.h" #define PLASMA_zlag2c(_descA, _descSB) \ plasma_parallel_call_4(plasma_pzlag2c, \ PLASMA_desc, (_descA), \ PLASMA_desc, (_descSB), \ PLASMA_sequence*, sequence, \ PLASMA_request*, request) #define PLASMA_clag2z(_descSA, _descB) \ plasma_parallel_call_4(plasma_pclag2z, \ PLASMA_desc, (_descSA), \ PLASMA_desc, (_descB), \ PLASMA_sequence*, sequence, \ PLASMA_request*, request) #define PLASMA_zlange(_norm, _descA, _result, _work) \ _result = 0; \ plasma_parallel_call_6(plasma_pzlange, \ PLASMA_enum, (_norm), \ PLASMA_desc, (_descA), \ double*, (_work), \ double*, &(_result), \ PLASMA_sequence*, sequence, \ PLASMA_request*, request); #define PLASMA_zlanhe(_norm, _uplo, _descA, _result, _work) \ _result = 0; \ plasma_parallel_call_7(plasma_pzlanhe, \ PLASMA_enum, (_norm), \ PLASMA_enum, (_uplo), \ PLASMA_desc, (_descA), \ double*, (_work), \ double*, &(_result), \ PLASMA_sequence*, sequence, \ PLASMA_request*, request); #define PLASMA_zlacpy(_descA, _descB) \ plasma_parallel_call_5(plasma_pzlacpy, \ PLASMA_enum, PlasmaUpperLower, \ PLASMA_desc, (_descA), \ PLASMA_desc, (_descB), \ PLASMA_sequence*, sequence, \ PLASMA_request*, request) #define PLASMA_zgeadd(_alpha, _descA, _descB) \ plasma_parallel_call_5(plasma_pzgeadd, \ PLASMA_Complex64_t, (_alpha), \ PLASMA_desc, (_descA), \ PLASMA_desc, (_descB), \ PLASMA_sequence*, sequence, \ PLASMA_request*, request) /***************************************************************************//** * * @ingroup PLASMA_Complex64_t * * PLASMA_zcposv - Computes the solution to a system of linear equations A * X = B, * where A is an N-by-N symmetric positive definite (or Hermitian positive definite * in the complex case) matrix and X and B are N-by-NRHS matrices. * The Cholesky decomposition is used to factor A as * * A = U**H * U, if uplo = PlasmaUpper, or * A = L * L**H, if uplo = PlasmaLower, * * where U is an upper triangular matrix and L is a lower triangular matrix. * The factored form of A is then used to solve the system of equations A * X = B. * * PLASMA_zcposv first attempts to factorize the matrix in COMPLEX and use this * factorization within an iterative refinement procedure to produce a * solution with COMPLEX*16 normwise backward error quality (see below). * If the approach fails the method switches to a COMPLEX*16 * factorization and solve. * * The iterative refinement is not going to be a winning strategy if * the ratio COMPLEX performance over COMPLEX*16 performance is too * small. A reasonable strategy should take the number of right-hand * sides and the size of the matrix into account. This might be done * with a call to ILAENV in the future. Up to now, we always try * iterative refinement. * * The iterative refinement process is stopped if ITER > ITERMAX or * for all the RHS we have: RNRM < N*XNRM*ANRM*EPS*BWDMAX * where: * * - ITER is the number of the current iteration in the iterative refinement process * - RNRM is the infinity-norm of the residual * - XNRM is the infinity-norm of the solution * - ANRM is the infinity-operator-norm of the matrix A * - EPS is the machine epsilon returned by DLAMCH('Epsilon'). * * Actually, in its current state (PLASMA 2.1.0), the test is slightly relaxed. * * The values ITERMAX and BWDMAX are fixed to 30 and 1.0D+00 respectively. * ******************************************************************************* * * @param[in] uplo * Specifies whether the matrix A is upper triangular or lower triangular: * = PlasmaUpper: Upper triangle of A is stored; * = PlasmaLower: Lower triangle of A is stored. * * @param[in] N * The number of linear equations, i.e., the order of the matrix A. N >= 0. * * @param[in] NRHS * The number of right hand sides, i.e., the number of columns of the matrix B. * NRHS >= 0. * * @param[in] A * The N-by-N symmetric positive definite (or Hermitian) coefficient matrix A. * If uplo = PlasmaUpper, the leading N-by-N upper triangular part of A * contains the upper triangular part of the matrix A, and the strictly lower triangular * part of A is not referenced. * If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower * triangular part of the matrix A, and the strictly upper triangular part of A is not * referenced. * This matrix is not modified. * * @param[in] LDA * The leading dimension of the array A. LDA >= max(1,N). * * @param[in] B * The N-by-NRHS matrix of right hand side matrix B. * * @param[in] LDB * The leading dimension of the array B. LDB >= max(1,N). * * @param[out] X * If return value = 0, the N-by-NRHS solution matrix X. * * @param[in] LDX * The leading dimension of the array B. LDX >= max(1,N). * * @param[out] ITER * The number of the current iteration in the iterative refinement process * ******************************************************************************* * * @return * \retval PLASMA_SUCCESS successful exit * \retval <0 if -i, the i-th argument had an illegal value * \retval >0 if i, the leading minor of order i of A is not positive definite, so the * factorization could not be completed, and the solution has not been computed. * ******************************************************************************* * * @sa PLASMA_zcposv_Tile * @sa PLASMA_zcposv_Tile_Async * @sa PLASMA_dsposv * @sa PLASMA_zposv * ******************************************************************************/ int PLASMA_zcposv(PLASMA_enum uplo, int N, int NRHS, PLASMA_Complex64_t *A, int LDA, PLASMA_Complex64_t *B, int LDB, PLASMA_Complex64_t *X, int LDX, int *ITER) { int NB; int status; PLASMA_desc descA; PLASMA_desc descB; PLASMA_desc descX; plasma_context_t *plasma; PLASMA_sequence *sequence = NULL; PLASMA_request request = PLASMA_REQUEST_INITIALIZER; plasma = plasma_context_self(); if (plasma == NULL) { plasma_fatal_error("PLASMA_zcposv", "PLASMA not initialized"); return PLASMA_ERR_NOT_INITIALIZED; } *ITER = 0; /* Check input arguments */ if (uplo != PlasmaUpper && uplo != PlasmaLower) { plasma_error("PLASMA_zcposv", "illegal value of uplo"); return -1; } if (N < 0) { plasma_error("PLASMA_zcposv", "illegal value of N"); return -2; } if (NRHS < 0) { plasma_error("PLASMA_zcposv", "illegal value of NRHS"); return -3; } if (LDA < max(1, N)) { plasma_error("PLASMA_zcposv", "illegal value of LDA"); return -5; } if (LDB < max(1, N)) { plasma_error("PLASMA_zcposv", "illegal value of LDB"); return -7; } if (LDX < max(1, N)) { plasma_error("PLASMA_zcposv", "illegal value of LDX"); return -9; } /* Quick return - currently NOT equivalent to LAPACK's * LAPACK does not have such check for ZCPOSV */ if (min(N, NRHS) == 0) return PLASMA_SUCCESS; /* Tune NB depending on M, N & NRHS; Set NBNBSIZE */ status = plasma_tune(PLASMA_FUNC_ZCPOSV, N, N, NRHS); if (status != PLASMA_SUCCESS) { plasma_error("PLASMA_zcposv", "plasma_tune() failed"); return status; } NB = PLASMA_NB; plasma_sequence_create(plasma, &sequence); /* DOUBLE PRECISION INITIALIZATION */ if ( PLASMA_TRANSLATION == PLASMA_OUTOFPLACE ) { plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N, sequence, &request, plasma_desc_mat_free(&(descA)) ); plasma_zooplap2tile( descB, B, NB, NB, LDB, NRHS, 0, 0, N, NRHS, sequence, &request, plasma_desc_mat_free(&(descA)); plasma_desc_mat_free(&(descB)) ); plasma_zdesc_alloc( descX, NB, NB, N, NRHS, 0, 0, N, NRHS, plasma_desc_mat_free(&(descA)); plasma_desc_mat_free(&(descB)); plasma_desc_mat_free(&(descX)) ); } else { plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N, sequence, &request); plasma_ziplap2tile( descB, B, NB, NB, LDB, NRHS, 0, 0, N, NRHS, sequence, &request); descX = plasma_desc_init( PlasmaComplexDouble, NB, NB, (NB*NB), LDX, NRHS, 0, 0, N, NRHS); descX.mat = X; } /* Call the native interface */ status = PLASMA_zcposv_Tile_Async(uplo, &descA, &descB, &descX, ITER, sequence, &request); if (status == PLASMA_SUCCESS) { if ( PLASMA_TRANSLATION == PLASMA_OUTOFPLACE ) { plasma_zooptile2lap( descX, X, NB, NB, LDX, NRHS, sequence, &request); plasma_dynamic_sync(); plasma_desc_mat_free(&descA); plasma_desc_mat_free(&descB); plasma_desc_mat_free(&descX); } else { plasma_ziptile2lap( descA, A, NB, NB, LDA, N, sequence, &request); plasma_ziptile2lap( descB, B, NB, NB, LDB, NRHS, sequence, &request); plasma_ziptile2lap( descX, X, NB, NB, LDX, NRHS, sequence, &request); plasma_dynamic_sync(); } } status = sequence->status; plasma_sequence_destroy(plasma, sequence); return status; } /***************************************************************************//** * * @ingroup PLASMA_Complex64_t_Tile * * PLASMA_zcposv_Tile - Solves a symmetric positive definite or Hermitian positive definite * system of linear equations using the Cholesky factorization and mixed-precision iterative refinement. * Tile equivalent of PLASMA_zcposv(). * Operates on matrices stored by tiles. * All matrices are passed through descriptors. * All dimensions are taken from the descriptors. * ******************************************************************************* * * @param[in] uplo * Specifies whether the matrix A is upper triangular or lower triangular: * = PlasmaUpper: Upper triangle of A is stored; * = PlasmaLower: Lower triangle of A is stored. * * @param[in,out] A * On entry, the N-by-N symmetric positive definite (or Hermitian) coefficient matrix A. * If uplo = PlasmaUpper, the leading N-by-N upper triangular part of A * contains the upper triangular part of the matrix A, and the strictly lower triangular * part of A is not referenced. * If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower * triangular part of the matrix A, and the strictly upper triangular part of A is not * referenced. * - If the iterative refinement converged, A is not modified; * - otherwise, it falled backed to double precision solution, * * @param[in] B * On entry, the N-by-NRHS matrix of right hand side matrix B. * * @param[out] X * On exit, if return value = 0, the N-by-NRHS solution matrix X. * * @param[out] ITER * The number of the current iteration in the iterative refinement process * ******************************************************************************* * * @return * \retval PLASMA_SUCCESS successful exit * \retval >0 if i, the leading minor of order i of A is not positive definite, so the * factorization could not be completed, and the solution has not been computed. * ******************************************************************************* * * @sa PLASMA_zcposv * @sa PLASMA_zcposv_Tile_Async * @sa PLASMA_dsposv_Tile * @sa PLASMA_zposv_Tile * ******************************************************************************/ int PLASMA_zcposv_Tile(PLASMA_enum uplo, PLASMA_desc *A, PLASMA_desc *B, PLASMA_desc *X, int *ITER) { plasma_context_t *plasma; PLASMA_sequence *sequence = NULL; PLASMA_request request = PLASMA_REQUEST_INITIALIZER; int status; plasma = plasma_context_self(); if (plasma == NULL) { plasma_fatal_error("PLASMA_zcposv_Tile", "PLASMA not initialized"); return PLASMA_ERR_NOT_INITIALIZED; } plasma_sequence_create(plasma, &sequence); status = PLASMA_zcposv_Tile_Async(uplo, A, B, X, ITER, sequence, &request); if (status != PLASMA_SUCCESS) return status; plasma_dynamic_sync(); status = sequence->status; plasma_sequence_destroy(plasma, sequence); return status; } /***************************************************************************//** * * @ingroup PLASMA_Complex64_t_Tile_Async * * PLASMA_zcposv_Tile_Async - Solves a symmetric positive definite or Hermitian * positive definite system of linear equations using the Cholesky factorization * and mixed-precision iterative refinement. * Non-blocking equivalent of PLASMA_zcposv_Tile(). * May return before the computation is finished. * Allows for pipelining of operations at runtime. * ******************************************************************************* * * @param[in] sequence * Identifies the sequence of function calls that this call belongs to * (for completion checks and exception handling purposes). * * @param[out] request * Identifies this function call (for exception handling purposes). * ******************************************************************************* * * @sa PLASMA_zcposv * @sa PLASMA_zcposv_Tile * @sa PLASMA_dsposv_Tile_Async * @sa PLASMA_zposv_Tile_Async * ******************************************************************************/ int PLASMA_zcposv_Tile_Async(PLASMA_enum uplo, PLASMA_desc *A, PLASMA_desc *B, PLASMA_desc *X, int *ITER, PLASMA_sequence *sequence, PLASMA_request *request) { int N, NB; PLASMA_desc descA; PLASMA_desc descB; PLASMA_desc descX; plasma_context_t *plasma; double *work; PLASMA_desc descR, descSA, descSX; const int itermax = 30; const double bwdmax = 1.0; const PLASMA_Complex64_t negone = -1.0; const PLASMA_Complex64_t one = 1.0; int iiter; double Anorm, cte, eps, Rnorm, Xnorm; *ITER=0; plasma = plasma_context_self(); if (plasma == NULL) { plasma_fatal_error("PLASMA_zcposv_Tile_Async", "PLASMA not initialized"); return PLASMA_ERR_NOT_INITIALIZED; } if (sequence == NULL) { plasma_fatal_error("PLASMA_zcposv_Tile_Async", "NULL sequence"); return PLASMA_ERR_UNALLOCATED; } if (request == NULL) { plasma_fatal_error("PLASMA_zcposv_Tile_Async", "NULL request"); return PLASMA_ERR_UNALLOCATED; } /* Check sequence status */ if (sequence->status == PLASMA_SUCCESS) request->status = PLASMA_SUCCESS; else return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED); /* Check descriptors for correctness */ if (plasma_desc_check(A) != PLASMA_SUCCESS) { plasma_error("PLASMA_zcposv_Tile_Async", "invalid first descriptor"); return PLASMA_ERR_ILLEGAL_VALUE; } else { descA = *A; } if (plasma_desc_check(B) != PLASMA_SUCCESS) { plasma_error("PLASMA_zcposv_Tile_Async", "invalid second descriptor"); return PLASMA_ERR_ILLEGAL_VALUE; } else { descB = *B; } if (plasma_desc_check(X) != PLASMA_SUCCESS) { plasma_error("PLASMA_zcposv_Tile_Async", "invalid third descriptor"); return PLASMA_ERR_ILLEGAL_VALUE; } else { descX = *X; } /* Check input arguments */ if (descA.nb != descA.mb || descB.nb != descB.mb || descX.nb != descX.mb) { plasma_error("PLASMA_zcposv_Tile_Async", "only square tiles supported"); return PLASMA_ERR_ILLEGAL_VALUE; } if (uplo != PlasmaUpper && uplo != PlasmaLower) { plasma_error("PLASMA_zcposv_Tile_Async", "illegal value of uplo"); return -1; } /* Quick return - currently NOT equivalent to LAPACK's * LAPACK does not have such check for DPOSV */ /* if (min(N, NRHS) == 0) return PLASMA_SUCCESS; */ /* Set N, NRHS */ N = descA.m; NB = descA.nb; work = (double *)plasma_shared_alloc(plasma, PLASMA_SIZE, PlasmaRealDouble); if (work == NULL) { plasma_error("PLASMA_zcposv_Tile_Async", "plasma_shared_alloc() failed"); plasma_shared_free(plasma, work); return PLASMA_ERR_OUT_OF_RESOURCES; } plasma_zdesc_alloc( descR, NB, NB, descB.m, descB.n, 0, 0, descB.m, descB.n, plasma_shared_free( plasma, work ); plasma_desc_mat_free(&descR) ); plasma_cdesc_alloc( descSA, NB, NB, descA.m, descA.n, 0, 0, descA.m, descA.n, plasma_shared_free( plasma, work ); plasma_desc_mat_free(&descR); plasma_desc_mat_free(&descSA) ); plasma_cdesc_alloc( descSX, NB, NB, descX.m, descX.n, 0, 0, descX.m, descX.n, plasma_shared_free( plasma, work ); plasma_desc_mat_free(&descR); plasma_desc_mat_free(&descSA); plasma_desc_mat_free(&descSX) ); /* Compute some constants */ PLASMA_zlanhe(PlasmaInfNorm, uplo, descA, Anorm, work); eps = LAPACKE_dlamch_work('e'); /* Convert B from double precision to single precision and store the result in SX. */ PLASMA_zlag2c(descB, descSX); if (sequence->status != PLASMA_SUCCESS) return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED); /* Convert A from double precision to single precision and store the result in SA. */ PLASMA_zlag2c(descA, descSA); if (sequence->status != PLASMA_SUCCESS) return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED); /* Compute the Cholesky factorization of SA */ plasma_parallel_call_4(plasma_pcpotrf, PLASMA_enum, uplo, PLASMA_desc, descSA, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Solve the system SA*SX = SB */ /* Forward substitution */ plasma_parallel_call_9(plasma_pctrsm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_enum, uplo == PlasmaUpper ? PlasmaConjTrans : PlasmaNoTrans, PLASMA_enum, PlasmaNonUnit, PLASMA_Complex32_t, 1.0, PLASMA_desc, descSA, PLASMA_desc, descSX, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Backward substitution */ plasma_parallel_call_9(plasma_pctrsm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_enum, uplo == PlasmaUpper ? PlasmaNoTrans : PlasmaConjTrans, PLASMA_enum, PlasmaNonUnit, PLASMA_Complex32_t, 1.0, PLASMA_desc, descSA, PLASMA_desc, descSX, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Convert SX back to double precision */ PLASMA_clag2z(descSX, descX); /* Compute R = B - AX. */ PLASMA_zlacpy(descB,descR); plasma_parallel_call_9(plasma_pzhemm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_Complex64_t, negone, PLASMA_desc, descA, PLASMA_desc, descX, PLASMA_Complex64_t, one, PLASMA_desc, descR, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Check whether the NRHS normwise backward error satisfies the stopping criterion. If yes return. Note that ITER=0 (already set). */ PLASMA_zlange(PlasmaInfNorm, descX, Xnorm, work); PLASMA_zlange(PlasmaInfNorm, descR, Rnorm, work); /* Wait for the end of Anorm, Xnorm and Bnorm computations */ plasma_dynamic_sync(); cte = Anorm*eps*((double) N)*bwdmax; if (Rnorm < Xnorm * cte){ /* The NRHS normwise backward errors satisfy the stopping criterion. We are good to exit. */ plasma_desc_mat_free(&descSA); plasma_desc_mat_free(&descSX); plasma_desc_mat_free(&descR); plasma_shared_free(plasma, work); return PLASMA_SUCCESS; } /* Iterative refinement */ for (iiter = 0; iiter < itermax; iiter++){ /* Convert R from double precision to single precision and store the result in SX. */ PLASMA_zlag2c(descR, descSX); /* Solve the system SA*SX = SR */ /* Forward substitution */ plasma_parallel_call_9(plasma_pctrsm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_enum, uplo == PlasmaUpper ? PlasmaConjTrans : PlasmaNoTrans, PLASMA_enum, PlasmaNonUnit, PLASMA_Complex32_t, 1.0, PLASMA_desc, descSA, PLASMA_desc, descSX, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Backward substitution */ plasma_parallel_call_9(plasma_pctrsm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_enum, uplo == PlasmaUpper ? PlasmaNoTrans : PlasmaConjTrans, PLASMA_enum, PlasmaNonUnit, PLASMA_Complex32_t, 1.0, PLASMA_desc, descSA, PLASMA_desc, descSX, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Convert SX back to double precision and update the current iterate. */ PLASMA_clag2z(descSX, descR); PLASMA_zgeadd(one, descR, descX); /* Compute R = B - AX. */ PLASMA_zlacpy(descB,descR); plasma_parallel_call_9(plasma_pzhemm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_Complex64_t, negone, PLASMA_desc, descA, PLASMA_desc, descX, PLASMA_Complex64_t, one, PLASMA_desc, descR, PLASMA_sequence*, sequence, PLASMA_request*, request); /* Check whether the NRHS normwise backward errors satisfy the stopping criterion. If yes, set ITER=IITER>0 and return. */ PLASMA_zlange(PlasmaInfNorm, descX, Xnorm, work); PLASMA_zlange(PlasmaInfNorm, descR, Rnorm, work); /* Wait for the end of Xnorm and Bnorm computations */ plasma_dynamic_sync(); if (Rnorm < Xnorm * cte){ /* The NRHS normwise backward errors satisfy the stopping criterion. We are good to exit. */ *ITER = iiter; plasma_desc_mat_free(&descSA); plasma_desc_mat_free(&descSX); plasma_desc_mat_free(&descR); plasma_shared_free(plasma, work); return PLASMA_SUCCESS; } } /* We have performed ITER=itermax iterations and never satisified the stopping criterion, set up the ITER flag accordingly and follow up on double precision routine. */ *ITER = -itermax - 1; plasma_desc_mat_free(&descSA); plasma_desc_mat_free(&descSX); plasma_desc_mat_free(&descR); plasma_shared_free(plasma, work); /* Single-precision iterative refinement failed to converge to a satisfactory solution, so we resort to double precision. */ plasma_parallel_call_4(plasma_pzpotrf, PLASMA_enum, uplo, PLASMA_desc, descA, PLASMA_sequence*, sequence, PLASMA_request*, request); PLASMA_zlacpy(descB,descX); plasma_parallel_call_9(plasma_pztrsm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_enum, uplo == PlasmaUpper ? PlasmaConjTrans : PlasmaNoTrans, PLASMA_enum, PlasmaNonUnit, PLASMA_Complex64_t, 1.0, PLASMA_desc, descA, PLASMA_desc, descX, PLASMA_sequence*, sequence, PLASMA_request*, request); plasma_parallel_call_9(plasma_pztrsm, PLASMA_enum, PlasmaLeft, PLASMA_enum, uplo, PLASMA_enum, uplo == PlasmaUpper ? PlasmaNoTrans : PlasmaConjTrans, PLASMA_enum, PlasmaNonUnit, PLASMA_Complex64_t, 1.0, PLASMA_desc, descA, PLASMA_desc, descX, PLASMA_sequence*, sequence, PLASMA_request*, request); return PLASMA_SUCCESS; }
/- Copyright (c) 2021 OpenAI. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f -/ import mathzoo.imports.miniF2F open_locale nat rat real big_operators topological_space theorem amc12a_2021_p7 (x : ℝ) (y : ℝ) : 1 ≤ ((x * y) - 1)^2 + (x + y)^2 := begin ring_nf, nlinarith, end
theory WiseMen imports Epistemic_S5 begin (* Wise Men Puzzle *) type_synonym \<alpha> = "i \<Rightarrow> i \<Rightarrow> bool" (* denoting people *) consts a::\<alpha> b::\<alpha> c::\<alpha> (* Three people *) consts fool::\<alpha> (* All people *) consts white::"\<alpha>\<Rightarrow>\<sigma>" context assumes A0a: "a \<noteq> b \<and> b \<noteq> c \<and> c \<noteq> a" and (* no two people are the same*) A0b: "fool \<noteq> a \<and> fool \<noteq> b \<and> fool \<noteq> c" and (* no person is the fool *) A1: "valid( \<^bold>\<box>fool (white a \<^bold>\<or> white b \<^bold>\<or> white c))" and (*fool knows it's one of a, b or c*) (*if white is on X then Y and Z both know*) A2_ab: "valid ( \<^bold>\<box>fool (white a \<^bold>\<rightarrow> \<^bold>\<box>b (white a)))" and A2_ac: "valid ( \<^bold>\<box>fool (white a \<^bold>\<rightarrow> \<^bold>\<box>c (white a)))" and A2_bc: "valid ( \<^bold>\<box>fool (white b \<^bold>\<rightarrow> \<^bold>\<box>c (white b)))" and A2_ba: "valid ( \<^bold>\<box>fool (white b \<^bold>\<rightarrow> \<^bold>\<box>a (white b)))" and A2_ca: "valid ( \<^bold>\<box>fool (white c \<^bold>\<rightarrow> \<^bold>\<box>a (white c)))" and A2_cb: "valid ( \<^bold>\<box>fool (white c \<^bold>\<rightarrow> \<^bold>\<box>b (white c)))" and (* if black is on X then Y and Z both know *) A3_ab: "valid ( \<^bold>\<box>fool (\<^bold>\<not>(white a) \<^bold>\<rightarrow> \<^bold>\<box>b \<^bold>\<not>(white a)))" and A3_ac: "valid ( \<^bold>\<box>fool (\<^bold>\<not>(white a) \<^bold>\<rightarrow> \<^bold>\<box>c \<^bold>\<not>(white a)))" and A3_bc: "valid ( \<^bold>\<box>fool (\<^bold>\<not>(white b) \<^bold>\<rightarrow> \<^bold>\<box>c \<^bold>\<not>(white b)))" and A3_ba: "valid ( \<^bold>\<box>fool (\<^bold>\<not>(white b) \<^bold>\<rightarrow> \<^bold>\<box>a \<^bold>\<not>(white b)))" and A3_ca: "valid ( \<^bold>\<box>fool (\<^bold>\<not>(white c) \<^bold>\<rightarrow> \<^bold>\<box>a \<^bold>\<not>(white c)))" and A3_cb: "valid ( \<^bold>\<box>fool (\<^bold>\<not>(white c) \<^bold>\<rightarrow> \<^bold>\<box>b \<^bold>\<not>(white c)))" and (* Fool knows X does't know about it's white spot*) A4_a: "valid (\<^bold>\<box>fool \<^bold>\<not>(\<^bold>\<box>a (white a)))" and A4_b: "valid (\<^bold>\<box>fool \<^bold>\<not>(\<^bold>\<box>b (white b)))" and (* If fool knows somethings, then it's true *) A5: "valid ((\<^bold>\<box>fool \<phi>) \<^bold>\<rightarrow> \<phi>)" begin theorem (* Proving C knows it has white spot*) C : "valid (\<^bold>\<box>c (white c))" sledgehammer by (metis A1 A3_ab A3_ca A3_cb A4_a A4_b A5) end
[GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R ⊢ IsJacobson R ↔ ∀ (P : Ideal R), IsPrime P → jacobson P = P [PROOFSTEP] refine' isJacobson_iff.trans ⟨fun h I hI => h I hI.isRadical, _⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R ⊢ (∀ (P : Ideal R), IsPrime P → jacobson P = P) → ∀ (I : Ideal R), IsRadical I → jacobson I = I [PROOFSTEP] refine fun h I hI ↦ le_antisymm (fun x hx ↦ ?_) (fun x hx ↦ mem_sInf.mpr fun _ hJ ↦ hJ.left hx) [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I✝ : Ideal R h : ∀ (P : Ideal R), IsPrime P → jacobson P = P I : Ideal R hI : IsRadical I x : R hx : x ∈ jacobson I ⊢ x ∈ I [PROOFSTEP] rw [← hI.radical, radical_eq_sInf I, mem_sInf] [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I✝ : Ideal R h : ∀ (P : Ideal R), IsPrime P → jacobson P = P I : Ideal R hI : IsRadical I x : R hx : x ∈ jacobson I ⊢ ∀ ⦃I_1 : Ideal R⦄, I_1 ∈ {J | I ≤ J ∧ IsPrime J} → x ∈ I_1 [PROOFSTEP] intro P hP [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I✝ : Ideal R h : ∀ (P : Ideal R), IsPrime P → jacobson P = P I : Ideal R hI : IsRadical I x : R hx : x ∈ jacobson I P : Ideal R hP : P ∈ {J | I ≤ J ∧ IsPrime J} ⊢ x ∈ P [PROOFSTEP] rw [Set.mem_setOf_eq] at hP [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I✝ : Ideal R h : ∀ (P : Ideal R), IsPrime P → jacobson P = P I : Ideal R hI : IsRadical I x : R hx : x ∈ jacobson I P : Ideal R hP : I ≤ P ∧ IsPrime P ⊢ x ∈ P [PROOFSTEP] erw [mem_sInf] at hx [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I✝ : Ideal R h : ∀ (P : Ideal R), IsPrime P → jacobson P = P I : Ideal R hI : IsRadical I x : R hx : ∀ ⦃I_1 : Ideal R⦄, I_1 ∈ {J | I ≤ J ∧ IsMaximal J} → x ∈ I_1 P : Ideal R hP : I ≤ P ∧ IsPrime P ⊢ x ∈ P [PROOFSTEP] erw [← h P hP.right, mem_sInf] [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I✝ : Ideal R h : ∀ (P : Ideal R), IsPrime P → jacobson P = P I : Ideal R hI : IsRadical I x : R hx : ∀ ⦃I_1 : Ideal R⦄, I_1 ∈ {J | I ≤ J ∧ IsMaximal J} → x ∈ I_1 P : Ideal R hP : I ≤ P ∧ IsPrime P ⊢ ∀ ⦃I : Ideal R⦄, I ∈ {J | P ≤ J ∧ IsMaximal J} → x ∈ I [PROOFSTEP] exact fun J hJ => hx ⟨le_trans hP.left hJ.left, hJ.right⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I✝ : Ideal R K : Type u_3 inst✝ : Field K I : Ideal K x✝ : IsRadical I h : I = ⊤ ⊢ jacobson I = I [PROOFSTEP] rw [h, jacobson_eq_top_iff] [GOAL] R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R ⊢ (∃ f, Function.Surjective ↑f) → IsJacobson S [PROOFSTEP] rintro ⟨f, hf⟩ [GOAL] case intro R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R f : R →+* S hf : Function.Surjective ↑f ⊢ IsJacobson S [PROOFSTEP] rw [isJacobson_iff_sInf_maximal] [GOAL] case intro R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R f : R →+* S hf : Function.Surjective ↑f ⊢ ∀ {I : Ideal S}, IsPrime I → ∃ M, (∀ (J : Ideal S), J ∈ M → IsMaximal J ∨ J = ⊤) ∧ I = sInf M [PROOFSTEP] intro p hp [GOAL] case intro R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R f : R →+* S hf : Function.Surjective ↑f p : Ideal S hp : IsPrime p ⊢ ∃ M, (∀ (J : Ideal S), J ∈ M → IsMaximal J ∨ J = ⊤) ∧ p = sInf M [PROOFSTEP] use map f '' {J : Ideal R | comap f p ≤ J ∧ J.IsMaximal} [GOAL] case h R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R f : R →+* S hf : Function.Surjective ↑f p : Ideal S hp : IsPrime p ⊢ (∀ (J : Ideal S), J ∈ map f '' {J | comap f p ≤ J ∧ IsMaximal J} → IsMaximal J ∨ J = ⊤) ∧ p = sInf (map f '' {J | comap f p ≤ J ∧ IsMaximal J}) [PROOFSTEP] use fun j ⟨J, hJ, hmap⟩ => hmap ▸ (map_eq_top_or_isMaximal_of_surjective f hf hJ.right).symm [GOAL] case right R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R f : R →+* S hf : Function.Surjective ↑f p : Ideal S hp : IsPrime p ⊢ p = sInf (map f '' {J | comap f p ≤ J ∧ IsMaximal J}) [PROOFSTEP] have : p = map f (comap f p).jacobson := (IsJacobson.out' _ <| hp.isRadical.comap f).symm ▸ (map_comap_of_surjective f hf p).symm [GOAL] case right R : Type u_1 S : Type u_2 inst✝¹ : CommRing R inst✝ : CommRing S I : Ideal R H : IsJacobson R f : R →+* S hf : Function.Surjective ↑f p : Ideal S hp : IsPrime p this : p = map f (jacobson (comap f p)) ⊢ p = sInf (map f '' {J | comap f p ≤ J ∧ IsMaximal J}) [PROOFSTEP] exact this.trans (map_sInf hf fun J ⟨hJ, _⟩ => le_trans (Ideal.ker_le_comap f) hJ) [GOAL] R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : IsJacobson R ⊢ Function.Surjective ↑(Quotient.mk I) [PROOFSTEP] rintro ⟨x⟩ [GOAL] case mk R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : IsJacobson R b✝ : R ⧸ I x : R ⊢ ∃ a, ↑(Quotient.mk I) a = Quot.mk Setoid.r x [PROOFSTEP] use x [GOAL] case h R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : IsJacobson R b✝ : R ⧸ I x : R ⊢ ↑(Quotient.mk I) x = Quot.mk Setoid.r x [PROOFSTEP] rfl [GOAL] R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R ⊢ IsJacobson S [PROOFSTEP] rw [isJacobson_iff_prime_eq] [GOAL] R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R ⊢ ∀ (P : Ideal S), IsPrime P → jacobson P = P [PROOFSTEP] intro P hP [GOAL] R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P ⊢ jacobson P = P [PROOFSTEP] by_cases hP_top : comap (algebraMap R S) P = ⊤ [GOAL] case pos R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : comap (algebraMap R S) P = ⊤ ⊢ jacobson P = P [PROOFSTEP] simp [comap_eq_top_iff.1 hP_top] [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ ⊢ jacobson P = P [PROOFSTEP] haveI : Nontrivial (R ⧸ comap (algebraMap R S) P) := Quotient.nontrivial hP_top [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) ⊢ jacobson P = P [PROOFSTEP] rw [jacobson_eq_iff_jacobson_quotient_eq_bot] [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] refine' eq_bot_of_comap_eq_bot (isIntegral_quotient_of_isIntegral hRS) _ [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) ⊢ comap (algebraMap (R ⧸ comap (algebraMap R S) P) (S ⧸ P)) (jacobson ⊥) = ⊥ [PROOFSTEP] rw [eq_bot_iff, ← jacobson_eq_iff_jacobson_quotient_eq_bot.1 ((isJacobson_iff_prime_eq.1 hR) (comap (algebraMap R S) P) (comap_isPrime _ _)), comap_jacobson] [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) ⊢ sInf (comap (algebraMap (R ⧸ comap (algebraMap R S) P) (S ⧸ P)) '' {J | ⊥ ≤ J ∧ IsMaximal J}) ≤ jacobson ⊥ [PROOFSTEP] refine' sInf_le_sInf fun J hJ => _ [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) J : Ideal (R ⧸ comap (algebraMap R S) P) hJ : J ∈ {J | ⊥ ≤ J ∧ IsMaximal J} ⊢ J ∈ comap (algebraMap (R ⧸ comap (algebraMap R S) P) (S ⧸ P)) '' {J | ⊥ ≤ J ∧ IsMaximal J} [PROOFSTEP] simp only [true_and_iff, Set.mem_image, bot_le, Set.mem_setOf_eq] [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) J : Ideal (R ⧸ comap (algebraMap R S) P) hJ : J ∈ {J | ⊥ ≤ J ∧ IsMaximal J} ⊢ ∃ x, IsMaximal x ∧ comap (algebraMap (R ⧸ comap (algebraMap R S) P) (S ⧸ P)) x = J [PROOFSTEP] have : J.IsMaximal := by simpa using hJ [GOAL] R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this : Nontrivial (R ⧸ comap (algebraMap R S) P) J : Ideal (R ⧸ comap (algebraMap R S) P) hJ : J ∈ {J | ⊥ ≤ J ∧ IsMaximal J} ⊢ IsMaximal J [PROOFSTEP] simpa using hJ [GOAL] case neg R : Type u_1 S : Type u_2 inst✝² : CommRing R inst✝¹ : CommRing S I : Ideal R inst✝ : Algebra R S hRS : Algebra.IsIntegral R S hR : IsJacobson R P : Ideal S hP : IsPrime P hP_top : ¬comap (algebraMap R S) P = ⊤ this✝ : Nontrivial (R ⧸ comap (algebraMap R S) P) J : Ideal (R ⧸ comap (algebraMap R S) P) hJ : J ∈ {J | ⊥ ≤ J ∧ IsMaximal J} this : IsMaximal J ⊢ ∃ x, IsMaximal x ∧ comap (algebraMap (R ⧸ comap (algebraMap R S) P) (S ⧸ P)) x = J [PROOFSTEP] exact exists_ideal_over_maximal_of_isIntegral (isIntegral_quotient_of_isIntegral hRS) J (comap_bot_le_of_injective _ algebraMap_quotient_injective) [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S hI : IsRadical I ⊢ Disjoint ↑(powers y) ↑I ↔ ¬y ∈ I.toAddSubmonoid [PROOFSTEP] refine' ⟨fun h => Set.disjoint_left.1 h (mem_powers _), fun h => disjoint_iff.mpr (eq_bot_iff.mpr _)⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S hI : IsRadical I h : ¬y ∈ I.toAddSubmonoid ⊢ ↑(powers y) ⊓ ↑I ≤ ⊥ [PROOFSTEP] rintro x ⟨⟨n, rfl⟩, hx'⟩ [GOAL] case intro.intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S hI : IsRadical I h : ¬y ∈ I.toAddSubmonoid n : ℕ hx' : (fun x x_1 => x ^ x_1) y n ∈ ↑I ⊢ (fun x x_1 => x ^ x_1) y n ∈ ⊥ [PROOFSTEP] exact h (hI <| mem_radical_of_pow_mem <| le_radical hx') [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S ⊢ IsMaximal J ↔ IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J [PROOFSTEP] constructor [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S ⊢ IsMaximal J → IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J [PROOFSTEP] refine' fun h => ⟨_, fun hy => h.ne_top (Ideal.eq_top_of_isUnit_mem _ hy (map_units _ ⟨y, Submonoid.mem_powers _⟩))⟩ [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] have hJ : J.IsPrime := IsMaximal.isPrime h [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime J ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] rw [isPrime_iff_isPrime_disjoint (Submonoid.powers y)] at hJ [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] have : y ∉ (comap (algebraMap R S) J).1 := Set.disjoint_left.1 hJ.right (Submonoid.mem_powers _) [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) this : ¬y ∈ (comap (algebraMap R S) J).toAddSubmonoid ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] erw [← H.out hJ.left.isRadical, mem_sInf] at this [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) this : ¬∀ ⦃I : Ideal R⦄, I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} → y ∈ I ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] push_neg at this [GOAL] case mp R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) this : Exists fun ⦃I⦄ => I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} ∧ ¬y ∈ I ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] rcases this with ⟨I, hI, hI'⟩ [GOAL] case mp.intro.intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I ⊢ IsMaximal (comap (algebraMap R S) J) [PROOFSTEP] convert hI.right [GOAL] case h.e'_3.h R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring ⊢ comap (algebraMap R S) J = I [PROOFSTEP] by_cases hJ : J = map (algebraMap R S) I [GOAL] case pos R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : J = map (algebraMap R S) I ⊢ comap (algebraMap R S) J = I [PROOFSTEP] rw [hJ, comap_map_of_isPrime_disjoint (powers y) S I (IsMaximal.isPrime hI.right)] [GOAL] case pos R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : J = map (algebraMap R S) I ⊢ Disjoint ↑(powers y) ↑I [PROOFSTEP] rwa [disjoint_powers_iff_not_mem y hI.right.isPrime.isRadical] [GOAL] case neg R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : ¬J = map (algebraMap R S) I ⊢ comap (algebraMap R S) J = I [PROOFSTEP] have hI_p : (map (algebraMap R S) I).IsPrime := by refine' isPrime_of_isPrime_disjoint (powers y) _ I hI.right.isPrime _ rwa [disjoint_powers_iff_not_mem y hI.right.isPrime.isRadical] [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : ¬J = map (algebraMap R S) I ⊢ IsPrime (map (algebraMap R S) I) [PROOFSTEP] refine' isPrime_of_isPrime_disjoint (powers y) _ I hI.right.isPrime _ [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : ¬J = map (algebraMap R S) I ⊢ Disjoint ↑(powers y) ↑I [PROOFSTEP] rwa [disjoint_powers_iff_not_mem y hI.right.isPrime.isRadical] [GOAL] case neg R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : ¬J = map (algebraMap R S) I hI_p : IsPrime (map (algebraMap R S) I) ⊢ comap (algebraMap R S) J = I [PROOFSTEP] have : J ≤ map (algebraMap R S) I := map_comap (Submonoid.powers y) S J ▸ map_mono hI.left [GOAL] case neg R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal J hJ✝ : IsPrime (comap (algebraMap R S) J) ∧ Disjoint ↑(powers y) ↑(comap (algebraMap R S) J) I : Ideal R hI : I ∈ {J_1 | comap (algebraMap R S) J ≤ J_1 ∧ IsMaximal J_1} hI' : ¬y ∈ I e_2✝ : CommSemiring.toSemiring = Ring.toSemiring hJ : ¬J = map (algebraMap R S) I hI_p : IsPrime (map (algebraMap R S) I) this : J ≤ map (algebraMap R S) I ⊢ comap (algebraMap R S) J = I [PROOFSTEP] exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1 [GOAL] case mpr R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S ⊢ IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J → IsMaximal J [PROOFSTEP] refine' fun h => ⟨⟨fun hJ => h.1.ne_top (eq_top_iff.2 _), fun I hI => _⟩⟩ [GOAL] case mpr.refine'_1 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J hJ : J = ⊤ ⊢ ⊤ ≤ comap (algebraMap R S) J [PROOFSTEP] rwa [eq_top_iff, ← (IsLocalization.orderEmbedding (powers y) S).le_iff_le] at hJ [GOAL] case mpr.refine'_2 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J I : Ideal S hI : J < I ⊢ I = ⊤ [PROOFSTEP] have := congr_arg (map (algebraMap R S)) (h.1.1.2 _ ⟨comap_mono (le_of_lt hI), ?_⟩) [GOAL] case mpr.refine'_2.refine_2 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J I : Ideal S hI : J < I this : map (algebraMap R S) (comap (algebraMap R S) I) = map (algebraMap R S) ⊤ ⊢ I = ⊤ case mpr.refine'_2.refine_1 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J I : Ideal S hI : J < I ⊢ ¬↑(comap (algebraMap R S) I) ⊆ ↑(comap (algebraMap R S) J) [PROOFSTEP] rwa [map_comap (powers y) S I, map_top] at this [GOAL] case mpr.refine'_2.refine_1 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J I : Ideal S hI : J < I ⊢ ¬↑(comap (algebraMap R S) I) ⊆ ↑(comap (algebraMap R S) J) [PROOFSTEP] refine' fun hI' => hI.right _ [GOAL] case mpr.refine'_2.refine_1 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J I : Ideal S hI : J < I hI' : ↑(comap (algebraMap R S) I) ⊆ ↑(comap (algebraMap R S) J) ⊢ ↑I ⊆ ↑J [PROOFSTEP] rw [← map_comap (powers y) S I, ← map_comap (powers y) S J] [GOAL] case mpr.refine'_2.refine_1 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R J : Ideal S h : IsMaximal (comap (algebraMap R S) J) ∧ ¬y ∈ comap (algebraMap R S) J I : Ideal S hI : J < I hI' : ↑(comap (algebraMap R S) I) ⊆ ↑(comap (algebraMap R S) J) ⊢ ↑(map (algebraMap R S) (comap (algebraMap R S) I)) ⊆ ↑(map (algebraMap R S) (comap (algebraMap R S) J)) [PROOFSTEP] exact map_mono hI' [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S I✝ : Ideal R y : R inst✝² : Algebra R S inst✝¹ : Away y S inst✝ : IsJacobson R I : Ideal R hI : IsMaximal I hy : ¬y ∈ I ⊢ IsMaximal (map (algebraMap R S) I) [PROOFSTEP] rw [isMaximal_iff_isMaximal_disjoint S y, comap_map_of_isPrime_disjoint (powers y) S I (IsMaximal.isPrime hI) ((disjoint_powers_iff_not_mem y hI.isPrime.isRadical).2 hy)] [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S I✝ : Ideal R y : R inst✝² : Algebra R S inst✝¹ : Away y S inst✝ : IsJacobson R I : Ideal R hI : IsMaximal I hy : ¬y ∈ I ⊢ IsMaximal I ∧ ¬y ∈ I [PROOFSTEP] exact ⟨hI, hy⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R ⊢ IsJacobson S [PROOFSTEP] rw [isJacobson_iff_prime_eq] [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R ⊢ ∀ (P : Ideal S), IsPrime P → jacobson P = P [PROOFSTEP] refine' fun P' hP' => le_antisymm _ le_jacobson [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP' : IsPrime P' ⊢ jacobson P' ≤ P' [PROOFSTEP] obtain ⟨hP', hPM⟩ := (IsLocalization.isPrime_iff_isPrime_disjoint (powers y) S P').mp hP' [GOAL] case intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') ⊢ jacobson P' ≤ P' [PROOFSTEP] have hP := H.out hP'.isRadical [GOAL] case intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' ⊢ jacobson P' ≤ P' [PROOFSTEP] refine' (IsLocalization.map_comap (powers y) S P'.jacobson).ge.trans ((map_mono _).trans (IsLocalization.map_comap (powers y) S P').le) [GOAL] case intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' ⊢ comap (algebraMap R S) (jacobson P') ≤ comap (algebraMap R S) P' [PROOFSTEP] have : sInf {I : Ideal R | comap (algebraMap R S) P' ≤ I ∧ I.IsMaximal ∧ y ∉ I} ≤ comap (algebraMap R S) P' := by intro x hx have hxy : x * y ∈ (comap (algebraMap R S) P').jacobson := by rw [Ideal.jacobson, mem_sInf] intro J hJ by_cases y ∈ J · exact J.mul_mem_left x h · exact J.mul_mem_right y ((mem_sInf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩) rw [hP] at hxy cases' hP'.mem_or_mem hxy with hxy hxy · exact hxy · exact (hPM.le_bot ⟨Submonoid.mem_powers _, hxy⟩).elim [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' ⊢ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ≤ comap (algebraMap R S) P' [PROOFSTEP] intro x hx [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ⊢ x ∈ comap (algebraMap R S) P' [PROOFSTEP] have hxy : x * y ∈ (comap (algebraMap R S) P').jacobson := by rw [Ideal.jacobson, mem_sInf] intro J hJ by_cases y ∈ J · exact J.mul_mem_left x h · exact J.mul_mem_right y ((mem_sInf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩) [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ⊢ x * y ∈ jacobson (comap (algebraMap R S) P') [PROOFSTEP] rw [Ideal.jacobson, mem_sInf] [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ⊢ ∀ ⦃I : Ideal R⦄, I ∈ {J | comap (algebraMap R S) P' ≤ J ∧ IsMaximal J} → x * y ∈ I [PROOFSTEP] intro J hJ [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} J : Ideal R hJ : J ∈ {J | comap (algebraMap R S) P' ≤ J ∧ IsMaximal J} ⊢ x * y ∈ J [PROOFSTEP] by_cases y ∈ J [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} J : Ideal R hJ : J ∈ {J | comap (algebraMap R S) P' ≤ J ∧ IsMaximal J} ⊢ x * y ∈ J [PROOFSTEP] by_cases y ∈ J [GOAL] case pos R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} J : Ideal R hJ : J ∈ {J | comap (algebraMap R S) P' ≤ J ∧ IsMaximal J} h : y ∈ J ⊢ x * y ∈ J [PROOFSTEP] exact J.mul_mem_left x h [GOAL] case neg R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} J : Ideal R hJ : J ∈ {J | comap (algebraMap R S) P' ≤ J ∧ IsMaximal J} h : ¬y ∈ J ⊢ x * y ∈ J [PROOFSTEP] exact J.mul_mem_right y ((mem_sInf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩) [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} hxy : x * y ∈ jacobson (comap (algebraMap R S) P') ⊢ x ∈ comap (algebraMap R S) P' [PROOFSTEP] rw [hP] at hxy [GOAL] R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} hxy : x * y ∈ comap (algebraMap R S) P' ⊢ x ∈ comap (algebraMap R S) P' [PROOFSTEP] cases' hP'.mem_or_mem hxy with hxy hxy [GOAL] case inl R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} hxy✝ : x * y ∈ comap (algebraMap R S) P' hxy : x ∈ comap (algebraMap R S) P' ⊢ x ∈ comap (algebraMap R S) P' [PROOFSTEP] exact hxy [GOAL] case inr R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' x : R hx : x ∈ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} hxy✝ : x * y ∈ comap (algebraMap R S) P' hxy : y ∈ comap (algebraMap R S) P' ⊢ x ∈ comap (algebraMap R S) P' [PROOFSTEP] exact (hPM.le_bot ⟨Submonoid.mem_powers _, hxy⟩).elim [GOAL] case intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' this : sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ≤ comap (algebraMap R S) P' ⊢ comap (algebraMap R S) (jacobson P') ≤ comap (algebraMap R S) P' [PROOFSTEP] refine' le_trans _ this [GOAL] case intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' this : sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ≤ comap (algebraMap R S) P' ⊢ comap (algebraMap R S) (jacobson P') ≤ sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} [PROOFSTEP] rw [Ideal.jacobson, comap_sInf', sInf_eq_iInf] [GOAL] case intro R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' this : sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ≤ comap (algebraMap R S) P' ⊢ ⨅ (I : Ideal R) (_ : I ∈ comap (algebraMap R S) '' {J | P' ≤ J ∧ IsMaximal J}), I ≤ ⨅ (a : Ideal R) (_ : a ∈ {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I}), a [PROOFSTEP] refine' iInf_le_iInf_of_subset fun I hI => ⟨map (algebraMap R S) I, ⟨_, _⟩⟩ [GOAL] case intro.refine'_1 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' this : sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ≤ comap (algebraMap R S) P' I : Ideal R hI : I ∈ {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ⊢ map (algebraMap R S) I ∈ {J | P' ≤ J ∧ IsMaximal J} [PROOFSTEP] exact ⟨le_trans (le_of_eq (IsLocalization.map_comap (powers y) S P').symm) (map_mono hI.1), isMaximal_of_isMaximal_disjoint y _ hI.2.1 hI.2.2⟩ [GOAL] case intro.refine'_2 R : Type u_1 S : Type u_2 inst✝³ : CommRing R inst✝² : CommRing S I✝ : Ideal R y : R inst✝¹ : Algebra R S inst✝ : Away y S H : IsJacobson R P' : Ideal S hP'✝ : IsPrime P' hP' : IsPrime (comap (algebraMap R S) P') hPM : Disjoint ↑(powers y) ↑(comap (algebraMap R S) P') hP : jacobson (comap (algebraMap R S) P') = comap (algebraMap R S) P' this : sInf {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ≤ comap (algebraMap R S) P' I : Ideal R hI : I ∈ {I | comap (algebraMap R S) P' ≤ I ∧ IsMaximal I ∧ ¬y ∈ I} ⊢ comap (algebraMap R S) (map (algebraMap R S) I) = I [PROOFSTEP] exact IsLocalization.comap_map_of_isPrime_disjoint _ S I (IsMaximal.isPrime hI.2.1) ((disjoint_powers_iff_not_mem y hI.2.1.isPrime.isRadical).2 hI.2.2) [GOAL] S : Type u_1 T : Type u_2 inst✝¹ : CommRing S inst✝ : CommRing T g : S →+* T u : Set S x : S hx : x ∈ Subring.closure u ⊢ ↑g x ∈ Subring.closure (↑g '' u) [PROOFSTEP] rw [Subring.mem_closure] at hx ⊢ [GOAL] S : Type u_1 T : Type u_2 inst✝¹ : CommRing S inst✝ : CommRing T g : S →+* T u : Set S x : S hx : ∀ (S_1 : Subring S), u ⊆ ↑S_1 → x ∈ S_1 ⊢ ∀ (S_1 : Subring ((fun x => T) x)), ↑g '' u ⊆ ↑S_1 → ↑g x ∈ S_1 [PROOFSTEP] intro T₁ h₁ [GOAL] S : Type u_1 T : Type u_2 inst✝¹ : CommRing S inst✝ : CommRing T g : S →+* T u : Set S x : S hx : ∀ (S_1 : Subring S), u ⊆ ↑S_1 → x ∈ S_1 T₁ : Subring ((fun x => T) x) h₁ : ↑g '' u ⊆ ↑T₁ ⊢ ↑g x ∈ T₁ [PROOFSTEP] rw [← Subring.mem_comap] [GOAL] S : Type u_1 T : Type u_2 inst✝¹ : CommRing S inst✝ : CommRing T g : S →+* T u : Set S x : S hx : ∀ (S_1 : Subring S), u ⊆ ↑S_1 → x ∈ S_1 T₁ : Subring ((fun x => T) x) h₁ : ↑g '' u ⊆ ↑T₁ ⊢ x ∈ Subring.comap g T₁ [PROOFSTEP] apply hx [GOAL] case a S : Type u_1 T : Type u_2 inst✝¹ : CommRing S inst✝ : CommRing T g : S →+* T u : Set S x : S hx : ∀ (S_1 : Subring S), u ⊆ ↑S_1 → x ∈ S_1 T₁ : Subring ((fun x => T) x) h₁ : ↑g '' u ⊆ ↑T₁ ⊢ u ⊆ ↑(Subring.comap g T₁) [PROOFSTEP] simp only [Subring.coe_comap, ← Set.image_subset_iff, SetLike.mem_coe] [GOAL] case a S : Type u_1 T : Type u_2 inst✝¹ : CommRing S inst✝ : CommRing T g : S →+* T u : Set S x : S hx : ∀ (S_1 : Subring S), u ⊆ ↑S_1 → x ∈ S_1 T₁ : Subring ((fun x => T) x) h₁ : ↑g '' u ⊆ ↑T₁ ⊢ ↑g '' u ⊆ ↑T₁ [PROOFSTEP] exact h₁ [GOAL] R : Type u_1 inst✝ : Ring R p : R[X] ⊢ p ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] refine' Polynomial.induction_on p _ _ _ [GOAL] case refine'_1 R : Type u_1 inst✝ : Ring R p : R[X] ⊢ ∀ (a : R), ↑C a ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] intro r [GOAL] case refine'_1 R : Type u_1 inst✝ : Ring R p : R[X] r : R ⊢ ↑C r ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] apply Subring.subset_closure [GOAL] case refine'_1.a R : Type u_1 inst✝ : Ring R p : R[X] r : R ⊢ ↑C r ∈ insert X {f | degree f ≤ 0} [PROOFSTEP] apply Set.mem_insert_of_mem [GOAL] case refine'_1.a.a R : Type u_1 inst✝ : Ring R p : R[X] r : R ⊢ ↑C r ∈ {f | degree f ≤ 0} [PROOFSTEP] exact degree_C_le [GOAL] case refine'_2 R : Type u_1 inst✝ : Ring R p : R[X] ⊢ ∀ (p q : R[X]), p ∈ Subring.closure (insert X {f | degree f ≤ 0}) → q ∈ Subring.closure (insert X {f | degree f ≤ 0}) → p + q ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] intros p1 p2 h1 h2 [GOAL] case refine'_2 R : Type u_1 inst✝ : Ring R p p1 p2 : R[X] h1 : p1 ∈ Subring.closure (insert X {f | degree f ≤ 0}) h2 : p2 ∈ Subring.closure (insert X {f | degree f ≤ 0}) ⊢ p1 + p2 ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] exact Subring.add_mem _ h1 h2 [GOAL] case refine'_3 R : Type u_1 inst✝ : Ring R p : R[X] ⊢ ∀ (n : ℕ) (a : R), ↑C a * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0}) → ↑C a * X ^ (n + 1) ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] intros n r hr [GOAL] case refine'_3 R : Type u_1 inst✝ : Ring R p : R[X] n : ℕ r : R hr : ↑C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0}) ⊢ ↑C r * X ^ (n + 1) ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] rw [pow_succ', ← mul_assoc] [GOAL] case refine'_3 R : Type u_1 inst✝ : Ring R p : R[X] n : ℕ r : R hr : ↑C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0}) ⊢ ↑C r * X ^ n * X ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] apply Subring.mul_mem _ hr [GOAL] case refine'_3 R : Type u_1 inst✝ : Ring R p : R[X] n : ℕ r : R hr : ↑C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0}) ⊢ X ∈ Subring.closure (insert X {f | degree f ≤ 0}) [PROOFSTEP] apply Subring.subset_closure [GOAL] case refine'_3.a R : Type u_1 inst✝ : Ring R p : R[X] n : ℕ r : R hr : ↑C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0}) ⊢ X ∈ insert X {f | degree f ≤ 0} [PROOFSTEP] apply Set.mem_insert [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] let P' : Ideal R := P.comap C [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] let M : Submonoid (R ⧸ P') := Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] let M' : Submonoid (R[X] ⧸ P) := (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] let φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ M.le_comap_map [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] have hφ' : φ.comp (Quotient.mk P') = (Quotient.mk P).comp C := rfl [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) [PROOFSTEP] intro p [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ ⊢ RingHom.IsIntegralElem (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) p [PROOFSTEP] obtain ⟨⟨p', ⟨q, hq⟩⟩, hp⟩ := IsLocalization.surj M' p [GOAL] case intro.mk.mk R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := q, property := hq }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := q, property := hq }).fst ⊢ RingHom.IsIntegralElem (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) p [PROOFSTEP] suffices φ'.IsIntegralElem (algebraMap (R[X] ⧸ P) Sₘ p') by obtain ⟨q', hq', rfl⟩ := hq obtain ⟨q'', hq''⟩ := isUnit_iff_exists_inv'.1 (IsLocalization.map_units Rₘ (⟨q', hq'⟩ : M)) refine' φ'.isIntegral_of_isIntegral_mul_unit p (algebraMap (R[X] ⧸ P) Sₘ (φ q')) q'' _ (hp.symm ▸ this) rw [← φ'.map_one, ← congr_arg φ' hq'', φ'.map_mul, ← φ'.comp_apply] simp only [IsLocalization.map_comp _] rw [RingHom.comp_apply] [GOAL] R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := q, property := hq }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := q, property := hq }).fst this : RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') ⊢ RingHom.IsIntegralElem (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) p [PROOFSTEP] obtain ⟨q', hq', rfl⟩ := hq [GOAL] case intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' : R[X] ⧸ P this : RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') q' : R ⧸ comap C P hq' : q' ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).fst ⊢ RingHom.IsIntegralElem (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) p [PROOFSTEP] obtain ⟨q'', hq''⟩ := isUnit_iff_exists_inv'.1 (IsLocalization.map_units Rₘ (⟨q', hq'⟩ : M)) [GOAL] case intro.intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' : R[X] ⧸ P this : RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') q' : R ⧸ comap C P hq' : q' ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).fst q'' : Rₘ hq'' : q'' * ↑(algebraMap (R ⧸ P') Rₘ) ↑{ val := q', property := hq' } = 1 ⊢ RingHom.IsIntegralElem (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))))) p [PROOFSTEP] refine' φ'.isIntegral_of_isIntegral_mul_unit p (algebraMap (R[X] ⧸ P) Sₘ (φ q')) q'' _ (hp.symm ▸ this) [GOAL] case intro.intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' : R[X] ⧸ P this : RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') q' : R ⧸ comap C P hq' : q' ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).fst q'' : Rₘ hq'' : q'' * ↑(algebraMap (R ⧸ P') Rₘ) ↑{ val := q', property := hq' } = 1 ⊢ ↑φ' q'' * ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑φ q') = 1 [PROOFSTEP] rw [← φ'.map_one, ← congr_arg φ' hq'', φ'.map_mul, ← φ'.comp_apply] [GOAL] case intro.intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' : R[X] ⧸ P this : RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') q' : R ⧸ comap C P hq' : q' ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).fst q'' : Rₘ hq'' : q'' * ↑(algebraMap (R ⧸ P') Rₘ) ↑{ val := q', property := hq' } = 1 ⊢ ↑φ' q'' * ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑φ q') = ↑φ' q'' * ↑(RingHom.comp φ' (algebraMap (R ⧸ P') Rₘ)) ↑{ val := q', property := hq' } [PROOFSTEP] simp only [IsLocalization.map_comp _] [GOAL] case intro.intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' : R[X] ⧸ P this : RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') q' : R ⧸ comap C P hq' : q' ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q', property := (_ : ∃ a, a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) ∧ ↑(quotientMap P C (_ : comap C P ≤ comap C P)) a = ↑(quotientMap P C (_ : comap C P ≤ comap C P)) q') }).fst q'' : Rₘ hq'' : q'' * ↑(algebraMap (R ⧸ P') Rₘ) ↑{ val := q', property := hq' } = 1 ⊢ ↑(IsLocalization.map Sₘ (quotientMap P C (_ : P' ≤ P')) (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) q'' * ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑(quotientMap P C (_ : P' ≤ P')) q') = ↑(IsLocalization.map Sₘ (quotientMap P C (_ : P' ≤ P')) (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) q'' * ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (quotientMap P C (_ : P' ≤ P'))) q' [PROOFSTEP] rw [RingHom.comp_apply] [GOAL] case intro.mk.mk R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) ↑(p', { val := q, property := hq }).snd = ↑(algebraMap (R[X] ⧸ P) Sₘ) (p', { val := q, property := hq }).fst ⊢ RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') [PROOFSTEP] dsimp at hp [GOAL] case intro.mk.mk R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' ⊢ RingHom.IsIntegralElem φ' (↑(algebraMap (R[X] ⧸ P) Sₘ) p') [PROOFSTEP] refine' @isIntegral_of_mem_closure'' Rₘ _ Sₘ _ φ' ((algebraMap (R[X] ⧸ P) Sₘ).comp (Quotient.mk P) '' insert X {p | p.degree ≤ 0}) _ ((algebraMap (R[X] ⧸ P) Sₘ) p') _ [GOAL] case intro.mk.mk.refine'_1 R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' ⊢ ∀ (x : Sₘ), x ∈ ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) '' insert X {p | degree p ≤ 0} → RingHom.IsIntegralElem φ' x [PROOFSTEP] rintro x ⟨p, hp, rfl⟩ [GOAL] case intro.mk.mk.refine'_1.intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp✝ : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hp : p ∈ insert X {p | degree p ≤ 0} ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) p) [PROOFSTEP] simp only [Set.mem_insert_iff] at hp [GOAL] case intro.mk.mk.refine'_1.intro.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp✝ : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hp : p = X ∨ p ∈ {p | degree p ≤ 0} ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) p) [PROOFSTEP] cases' hp with hy hy [GOAL] case intro.mk.mk.refine'_1.intro.intro.inl R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = X ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) p) [PROOFSTEP] rw [hy] [GOAL] case intro.mk.mk.refine'_1.intro.intro.inl R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = X ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) X) [PROOFSTEP] refine' φ.isIntegralElem_localization_at_leadingCoeff ((Quotient.mk P) X) (pX.map (Quotient.mk P')) _ M _ [GOAL] case intro.mk.mk.refine'_1.intro.intro.inl.refine'_1 R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = X ⊢ eval₂ φ (↑(Quotient.mk P) X) (Polynomial.map (Quotient.mk P') pX) = 0 [PROOFSTEP] rwa [eval₂_map, hφ', ← hom_eval₂, Quotient.eq_zero_iff_mem, eval₂_C_X] [GOAL] case intro.mk.mk.refine'_1.intro.intro.inl.refine'_2 R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = X ⊢ Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) ∈ M [PROOFSTEP] use 1 [GOAL] case h R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = X ⊢ (fun x x_1 => x ^ x_1) (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) 1 = Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) [PROOFSTEP] simp only [pow_one] [GOAL] case intro.mk.mk.refine'_1.intro.intro.inr R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p ∈ {p | degree p ≤ 0} ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) p) [PROOFSTEP] rw [Set.mem_setOf_eq, degree_le_zero_iff] at hy [GOAL] case intro.mk.mk.refine'_1.intro.intro.inr R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) p) [PROOFSTEP] rw [hy] [GOAL] case intro.mk.mk.refine'_1.intro.intro.inr R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ RingHom.IsIntegralElem φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) (↑C (coeff p 0))) [PROOFSTEP] use X - C (algebraMap (R ⧸ P') Rₘ ((Quotient.mk P') (p.coeff 0))) [GOAL] case h R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ Monic (X - ↑C (↑(algebraMap (R ⧸ P') Rₘ) (↑(Quotient.mk P') (coeff p 0)))) ∧ eval₂ φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) (↑C (coeff p 0))) (X - ↑C (↑(algebraMap (R ⧸ P') Rₘ) (↑(Quotient.mk P') (coeff p 0)))) = 0 [PROOFSTEP] constructor [GOAL] case h.left R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ Monic (X - ↑C (↑(algebraMap (R ⧸ P') Rₘ) (↑(Quotient.mk P') (coeff p 0)))) [PROOFSTEP] apply monic_X_sub_C [GOAL] case h.right R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ eval₂ φ' (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) (↑C (coeff p 0))) (X - ↑C (↑(algebraMap (R ⧸ P') Rₘ) (↑(Quotient.mk P') (coeff p 0)))) = 0 [PROOFSTEP] simp only [eval₂_sub, eval₂_X, eval₂_C] [GOAL] case h.right R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) (↑C (coeff p 0)) - ↑(IsLocalization.map Sₘ (quotientMap P C (_ : P' ≤ P')) (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (↑(algebraMap (R ⧸ comap C P) Rₘ) (↑(Quotient.mk (comap C P)) (coeff p 0))) = 0 [PROOFSTEP] rw [sub_eq_zero, ← φ'.comp_apply] [GOAL] case h.right R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) (↑C (coeff p 0)) = ↑(RingHom.comp φ' (algebraMap (R ⧸ comap C P) Rₘ)) (↑(Quotient.mk (comap C P)) (coeff p 0)) [PROOFSTEP] simp only [IsLocalization.map_comp _] [GOAL] case h.right R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' p : R[X] hy : p = ↑C (coeff p 0) ⊢ ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) (↑C (coeff p 0)) = ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (quotientMap P C (_ : P' ≤ P'))) (↑(Quotient.mk (comap C P)) (coeff p 0)) [PROOFSTEP] rfl [GOAL] case intro.mk.mk.refine'_2 R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p : Sₘ p' q : R[X] ⧸ P hq : q ∈ M' hp : p * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) p' ⊢ ↑(algebraMap (R[X] ⧸ P) Sₘ) p' ∈ Subring.closure (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) '' insert X {p | degree p ≤ 0}) [PROOFSTEP] obtain ⟨p, rfl⟩ := Quotient.mk_surjective p' [GOAL] case intro.mk.mk.refine'_2.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ q : R[X] ⧸ P hq : q ∈ M' p : R[X] hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑(Quotient.mk P) p) ⊢ ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑(Quotient.mk P) p) ∈ Subring.closure (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) '' insert X {p | degree p ≤ 0}) [PROOFSTEP] rw [← RingHom.comp_apply] [GOAL] case intro.mk.mk.refine'_2.intro R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ q : R[X] ⧸ P hq : q ∈ M' p : R[X] hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑(Quotient.mk P) p) ⊢ ↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) p ∈ Subring.closure (↑(RingHom.comp (algebraMap (R[X] ⧸ P) Sₘ) (Quotient.mk P)) '' insert X {p | degree p ≤ 0}) [PROOFSTEP] apply Subring.mem_closure_image_of [GOAL] case intro.mk.mk.refine'_2.intro.hx R : Type u_1 S : Type u_2 inst✝⁸ : CommRing R inst✝⁷ : CommRing S inst✝⁶ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ P : Ideal R[X] pX : R[X] hpX : pX ∈ P inst✝³ : Algebra (R ⧸ comap C P) Rₘ inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ inst✝¹ : Algebra (R[X] ⧸ P) Sₘ inst✝ : IsLocalization (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))) Sₘ P' : Ideal R := comap C P M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) M' : Submonoid (R[X] ⧸ P) := Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))) φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M)) hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C p✝ : Sₘ q : R[X] ⧸ P hq : q ∈ M' p : R[X] hp : p✝ * ↑(algebraMap (R[X] ⧸ P) Sₘ) q = ↑(algebraMap (R[X] ⧸ P) Sₘ) (↑(Quotient.mk P) p) ⊢ p ∈ Subring.closure (insert X {p | degree p ≤ 0}) [PROOFSTEP] apply Polynomial.mem_closure_X_union_C [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] have hM : ((Submonoid.powers x).map φ : Submonoid S) ≤ nonZeroDivisors S := map_le_nonZeroDivisors_of_injective φ hφ (powers_le_nonZeroDivisors_of_noZeroDivisors hx) [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] letI : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors _ hM [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let φ' : Rₘ →+* Sₘ := IsLocalization.map _ φ (Submonoid.powers x).le_comap_map [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] suffices ∀ I : Ideal Sₘ, I.IsMaximal → (I.comap (algebraMap S Sₘ)).IsMaximal by have hϕ' : comap (algebraMap S Sₘ) (⊥ : Ideal Sₘ) = (⊥ : Ideal S) := by rw [← RingHom.ker_eq_comap_bot, ← RingHom.injective_iff_ker_eq_bot] exact IsLocalization.injective Sₘ hM have hSₘ : IsJacobson Sₘ := isJacobson_of_isIntegral' φ' hφ' (isJacobson_localization x) refine' eq_bot_iff.mpr (le_trans _ (le_of_eq hϕ')) rw [← hSₘ.out isRadical_bot_of_noZeroDivisors, comap_jacobson] exact sInf_le_sInf fun j hj => ⟨bot_le, let ⟨J, hJ⟩ := hj hJ.2 ▸ this J hJ.1.2⟩ [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] have hϕ' : comap (algebraMap S Sₘ) (⊥ : Ideal Sₘ) = (⊥ : Ideal S) := by rw [← RingHom.ker_eq_comap_bot, ← RingHom.injective_iff_ker_eq_bot] exact IsLocalization.injective Sₘ hM [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) ⊢ comap (algebraMap S Sₘ) ⊥ = ⊥ [PROOFSTEP] rw [← RingHom.ker_eq_comap_bot, ← RingHom.injective_iff_ker_eq_bot] [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) ⊢ Function.Injective ↑(algebraMap S Sₘ) [PROOFSTEP] exact IsLocalization.injective Sₘ hM [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) hϕ' : comap (algebraMap S Sₘ) ⊥ = ⊥ ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] have hSₘ : IsJacobson Sₘ := isJacobson_of_isIntegral' φ' hφ' (isJacobson_localization x) [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) hϕ' : comap (algebraMap S Sₘ) ⊥ = ⊥ hSₘ : IsJacobson Sₘ ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] refine' eq_bot_iff.mpr (le_trans _ (le_of_eq hϕ')) [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) hϕ' : comap (algebraMap S Sₘ) ⊥ = ⊥ hSₘ : IsJacobson Sₘ ⊢ jacobson ⊥ ≤ comap (algebraMap S Sₘ) ⊥ [PROOFSTEP] rw [← hSₘ.out isRadical_bot_of_noZeroDivisors, comap_jacobson] [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) this : ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) hϕ' : comap (algebraMap S Sₘ) ⊥ = ⊥ hSₘ : IsJacobson Sₘ ⊢ jacobson ⊥ ≤ sInf (comap (algebraMap S Sₘ) '' {J | ⊥ ≤ J ∧ IsMaximal J}) [PROOFSTEP] exact sInf_le_sInf fun j hj => ⟨bot_le, let ⟨J, hJ⟩ := hj hJ.2 ▸ this J hJ.1.2⟩ [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) ⊢ ∀ (I : Ideal Sₘ), IsMaximal I → IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] intro I hI [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] haveI : (I.comap (algebraMap S Sₘ)).IsPrime := comap_isPrime _ I [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this : IsPrime (comap (algebraMap S Sₘ) I) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] haveI : (I.comap φ').IsPrime := comap_isPrime φ' I [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝¹ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝ : IsPrime (comap (algebraMap S Sₘ) I) this : IsPrime (comap φ' I) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] haveI : (⊥ : Ideal (S ⧸ I.comap (algebraMap S Sₘ))).IsPrime := bot_prime [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝² : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝¹ : IsPrime (comap (algebraMap S Sₘ) I) this✝ : IsPrime (comap φ' I) this : IsPrime ⊥ ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] have hcomm : φ'.comp (algebraMap R Rₘ) = (algebraMap S Sₘ).comp φ := IsLocalization.map_comp _ [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝² : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝¹ : IsPrime (comap (algebraMap S Sₘ) I) this✝ : IsPrime (comap φ' I) this : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] let f := quotientMap (I.comap (algebraMap S Sₘ)) φ le_rfl [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝² : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝¹ : IsPrime (comap (algebraMap S Sₘ) I) this✝ : IsPrime (comap φ' I) this : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] let g := quotientMap I (algebraMap S Sₘ) le_rfl [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝² : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝¹ : IsPrime (comap (algebraMap S Sₘ) I) this✝ : IsPrime (comap φ' I) this : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] have := isMaximal_comap_of_isIntegral_of_isMaximal' φ' hφ' I hI [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝³ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝² : IsPrime (comap (algebraMap S Sₘ) I) this✝¹ : IsPrime (comap φ' I) this✝ : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this : IsMaximal (comap φ' I) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] have := ((isMaximal_iff_isMaximal_disjoint Rₘ x _).1 this).left [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝⁴ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝³ : IsPrime (comap (algebraMap S Sₘ) I) this✝² : IsPrime (comap φ' I) this✝¹ : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this✝ : IsMaximal (comap φ' I) this : IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] have : ((I.comap (algebraMap S Sₘ)).comap φ).IsMaximal := by rwa [comap_comap, hcomm, ← comap_comap] at this [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝⁴ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝³ : IsPrime (comap (algebraMap S Sₘ) I) this✝² : IsPrime (comap φ' I) this✝¹ : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this✝ : IsMaximal (comap φ' I) this : IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) ⊢ IsMaximal (comap φ (comap (algebraMap S Sₘ) I)) [PROOFSTEP] rwa [comap_comap, hcomm, ← comap_comap] at this [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝⁵ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝⁴ : IsPrime (comap (algebraMap S Sₘ) I) this✝³ : IsPrime (comap φ' I) this✝² : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this✝¹ : IsMaximal (comap φ' I) this✝ : IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) this : IsMaximal (comap φ (comap (algebraMap S Sₘ) I)) ⊢ IsMaximal (comap (algebraMap S Sₘ) I) [PROOFSTEP] rw [← bot_quotient_isMaximal_iff] at this ⊢ [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝⁵ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝⁴ : IsPrime (comap (algebraMap S Sₘ) I) this✝³ : IsPrime (comap φ' I) this✝² : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this✝¹ : IsMaximal (comap φ' I) this✝ : IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) this : IsMaximal ⊥ ⊢ IsMaximal ⊥ [PROOFSTEP] refine' isMaximal_of_isIntegral_of_isMaximal_comap' f _ ⊥ ((eq_bot_iff.2 (comap_bot_le_of_injective f quotientMap_injective)).symm ▸ this) [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝⁵ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝⁴ : IsPrime (comap (algebraMap S Sₘ) I) this✝³ : IsPrime (comap φ' I) this✝² : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this✝¹ : IsMaximal (comap φ' I) this✝ : IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) this : IsMaximal ⊥ ⊢ RingHom.IsIntegral f [PROOFSTEP] exact f.isIntegral_tower_bot_of_isIntegral g quotientMap_injective ((comp_quotientMap_eq_of_comp_eq hcomm I).symm ▸ RingHom.isIntegral_trans _ _ (RingHom.isIntegral_of_surjective _ (IsLocalization.surjective_quotientMap_of_maximal_of_localization (Submonoid.powers x) Rₘ (by rwa [comap_comap, hcomm, ← bot_quotient_isMaximal_iff]))) (RingHom.isIntegral_quotient_of_isIntegral _ hφ')) [GOAL] R✝ : Type u_1 S : Type u_2 inst✝¹³ : CommRing R✝ inst✝¹² : CommRing S inst✝¹¹ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝¹⁰ : CommRing Rₘ✝ inst✝⁹ : CommRing Sₘ✝ R : Type u_5 inst✝⁸ : CommRing R inst✝⁷ : IsDomain R inst✝⁶ : IsJacobson R Rₘ : Type u_6 Sₘ : Type u_7 inst✝⁵ : CommRing Rₘ inst✝⁴ : CommRing Sₘ φ : R →+* S hφ : Function.Injective ↑φ x : R hx : x ≠ 0 inst✝³ : Algebra R Rₘ inst✝² : IsLocalization.Away x Rₘ inst✝¹ : Algebra S Sₘ inst✝ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) hM : Submonoid.map φ (Submonoid.powers x) ≤ nonZeroDivisors S this✝⁵ : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors S hM φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x))) I : Ideal Sₘ hI : IsMaximal I this✝⁴ : IsPrime (comap (algebraMap S Sₘ) I) this✝³ : IsPrime (comap φ' I) this✝² : IsPrime ⊥ hcomm : RingHom.comp φ' (algebraMap R Rₘ) = RingHom.comp (algebraMap S Sₘ) φ f : R ⧸ comap φ (comap (algebraMap S Sₘ) I) →+* S ⧸ comap (algebraMap S Sₘ) I := quotientMap (comap (algebraMap S Sₘ) I) φ (_ : comap φ (comap (algebraMap S Sₘ) I) ≤ comap φ (comap (algebraMap S Sₘ) I)) g : S ⧸ comap (algebraMap S Sₘ) I →+* Sₘ ⧸ I := quotientMap I (algebraMap S Sₘ) (_ : comap (algebraMap S Sₘ) I ≤ comap (algebraMap S Sₘ) I) this✝¹ : IsMaximal (comap φ' I) this✝ : IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) this : IsMaximal ⊥ ⊢ IsMaximal (comap (algebraMap R Rₘ) (comap φ' I)) [PROOFSTEP] rwa [comap_comap, hcomm, ← bot_quotient_isMaximal_iff] [GOAL] R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 ⊢ jacobson P = P [PROOFSTEP] by_cases Pb : P = ⊥ [GOAL] case pos R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : P = ⊥ ⊢ jacobson P = P [PROOFSTEP] exact Pb.symm ▸ jacobson_bot_polynomial_of_jacobson_bot (hR.out isRadical_bot_of_noZeroDivisors) [GOAL] case neg R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ ⊢ jacobson P = P [PROOFSTEP] rw [jacobson_eq_iff_jacobson_quotient_eq_bot] [GOAL] case neg R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let P' := P.comap (C : R →+* R[X]) [GOAL] case neg R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] haveI : P'.IsPrime := comap_isPrime C P [GOAL] case neg R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] haveI hR' : IsJacobson (R ⧸ P') := by infer_instance [GOAL] R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' ⊢ IsJacobson (R ⧸ P') [PROOFSTEP] infer_instance [GOAL] case neg R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] obtain ⟨p, pP, p0⟩ := exists_nonzero_mem_of_ne_bot Pb hP [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let x := (Polynomial.map (Quotient.mk P') p).leadingCoeff [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] have hx : x ≠ 0 := by rwa [Ne.def, leadingCoeff_eq_zero] [GOAL] R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) ⊢ x ≠ 0 [PROOFSTEP] rwa [Ne.def, leadingCoeff_eq_zero] [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let φ : R ⧸ P' →+* R[X] ⧸ P := Ideal.quotientMap P (C : R →+* R[X]) le_rfl [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let hφ : Function.Injective ↑φ := quotientMap_injective [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hφ : Function.Injective ↑φ := quotientMap_injective ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let Rₘ := Localization.Away x [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ✝ : Type u_3 Sₘ : Type u_4 inst✝⁴ : CommRing Rₘ✝ inst✝³ : CommRing Sₘ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hφ : Function.Injective ↑φ := quotientMap_injective Rₘ : Type u_5 := Localization.Away x ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] let Sₘ := (Localization ((Submonoid.powers x).map φ : Submonoid (R[X] ⧸ P))) [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝⁴ : CommRing Rₘ✝ inst✝³ : CommRing Sₘ✝ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hφ : Function.Injective ↑φ := quotientMap_injective Rₘ : Type u_5 := Localization.Away x Sₘ : Type u_5 := Localization (Submonoid.map φ (Submonoid.powers x)) ⊢ jacobson ⊥ = ⊥ [PROOFSTEP] refine' jacobson_bot_of_integral_localization (S := R[X] ⧸ P) (R := R ⧸ P') Rₘ Sₘ _ hφ _ hx _ [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝⁴ : CommRing Rₘ✝ inst✝³ : CommRing Sₘ✝ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hφ : Function.Injective ↑φ := quotientMap_injective Rₘ : Type u_5 := Localization.Away x Sₘ : Type u_5 := Localization (Submonoid.map φ (Submonoid.powers x)) ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) [PROOFSTEP] haveI islocSₘ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ := by infer_instance [GOAL] R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝⁴ : CommRing Rₘ✝ inst✝³ : CommRing Sₘ✝ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hφ : Function.Injective ↑φ := quotientMap_injective Rₘ : Type u_5 := Localization.Away x Sₘ : Type u_5 := Localization (Submonoid.map φ (Submonoid.powers x)) ⊢ IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ [PROOFSTEP] infer_instance [GOAL] case neg.intro.intro R✝ : Type u_1 S : Type u_2 inst✝⁷ : CommRing R✝ inst✝⁶ : CommRing S inst✝⁵ : IsDomain S Rₘ✝ : Type u_3 Sₘ✝ : Type u_4 inst✝⁴ : CommRing Rₘ✝ inst✝³ : CommRing Sₘ✝ R : Type u_5 inst✝² : CommRing R inst✝¹ : IsDomain R hR : IsJacobson R P : Ideal R[X] inst✝ : IsPrime P hP : ∀ (x : R), ↑C x ∈ P → x = 0 Pb : ¬P = ⊥ P' : Ideal R := comap C P this : IsPrime P' hR' : IsJacobson (R ⧸ P') p : R[X] pP : p ∈ P p0 : Polynomial.map (Quotient.mk (comap C P)) p ≠ 0 x : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') p) hx : x ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hφ : Function.Injective ↑φ := quotientMap_injective Rₘ : Type u_5 := Localization.Away x Sₘ : Type u_5 := Localization (Submonoid.map φ (Submonoid.powers x)) islocSₘ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ ⊢ RingHom.IsIntegral (IsLocalization.map Sₘ φ (_ : Submonoid.powers x ≤ Submonoid.comap φ (Submonoid.map φ (Submonoid.powers x)))) [PROOFSTEP] exact @isIntegral_isLocalization_polynomial_quotient R _ Rₘ Sₘ _ _ P p pP _ _ _ islocSₘ [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R ⊢ IsJacobson R[X] [PROOFSTEP] rw [isJacobson_iff_prime_eq] [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R ⊢ ∀ (P : Ideal R[X]), IsPrime P → jacobson P = P [PROOFSTEP] intro I hI [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I ⊢ jacobson I = I [PROOFSTEP] let R' : Subring (R[X] ⧸ I) := ((Quotient.mk I).comp C).range [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) ⊢ jacobson I = I [PROOFSTEP] let i : R →+* R' := ((Quotient.mk I).comp C).rangeRestrict [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) ⊢ jacobson I = I [PROOFSTEP] have hi : Function.Surjective ↑i := ((Quotient.mk I).comp C).rangeRestrict_surjective [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i ⊢ jacobson I = I [PROOFSTEP] have hi' : RingHom.ker (mapRingHom i) ≤ I [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i ⊢ RingHom.ker (mapRingHom i) ≤ I [PROOFSTEP] intro f hf [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i f : R[X] hf : f ∈ RingHom.ker (mapRingHom i) ⊢ f ∈ I [PROOFSTEP] apply polynomial_mem_ideal_of_coeff_mem_ideal I f [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i f : R[X] hf : f ∈ RingHom.ker (mapRingHom i) ⊢ ∀ (n : ℕ), coeff f n ∈ comap C I [PROOFSTEP] intro n [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i f : R[X] hf : f ∈ RingHom.ker (mapRingHom i) n : ℕ ⊢ coeff f n ∈ comap C I [PROOFSTEP] replace hf := congrArg (fun g : Polynomial ((Quotient.mk I).comp C).range => g.coeff n) hf [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i f : R[X] n : ℕ hf : (fun g => coeff g n) (↑(mapRingHom i) f) = (fun g => coeff g n) 0 ⊢ coeff f n ∈ comap C I [PROOFSTEP] change (Polynomial.map ((Quotient.mk I).comp C).rangeRestrict f).coeff n = 0 at hf [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i f : R[X] n : ℕ hf : coeff (Polynomial.map (RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C)) f) n = 0 ⊢ coeff f n ∈ comap C I [PROOFSTEP] rw [coeff_map, Subtype.ext_iff] at hf [GOAL] case hi' R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i f : R[X] n : ℕ hf : ↑(↑(RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C)) (coeff f n)) = ↑0 ⊢ coeff f n ∈ comap C I [PROOFSTEP] rwa [mem_comap, ← Quotient.eq_zero_iff_mem, ← RingHom.comp_apply] [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I ⊢ jacobson I = I [PROOFSTEP] have R'_jacob : IsJacobson R' := isJacobson_of_surjective ⟨i, hi⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } ⊢ jacobson I = I [PROOFSTEP] let J := map (mapRingHom i) I [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I ⊢ jacobson I = I [PROOFSTEP] have h_surj : Function.Surjective (mapRingHom i) := Polynomial.map_surjective i hi [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) ⊢ jacobson I = I [PROOFSTEP] have : IsPrime J := map_isPrime_of_surjective h_surj hi' [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J ⊢ jacobson I = I [PROOFSTEP] suffices h : J.jacobson = J [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J h : jacobson J = J ⊢ jacobson I = I [PROOFSTEP] replace h := congrArg (comap (Polynomial.mapRingHom i)) h [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J h : comap (mapRingHom i) (jacobson J) = comap (mapRingHom i) J ⊢ jacobson I = I [PROOFSTEP] rw [← map_jacobson_of_surjective h_surj hi', comap_map_of_surjective _ h_surj, comap_map_of_surjective _ h_surj] at h [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J h : jacobson I ⊔ comap (mapRingHom i) ⊥ = I ⊔ comap (mapRingHom i) ⊥ ⊢ jacobson I = I [PROOFSTEP] refine le_antisymm ?_ le_jacobson [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J h : jacobson I ⊔ comap (mapRingHom i) ⊥ = I ⊔ comap (mapRingHom i) ⊥ ⊢ jacobson I ≤ I [PROOFSTEP] exact le_trans (le_sup_of_le_left le_rfl) (le_trans (le_of_eq h) (sup_le le_rfl hi')) [GOAL] case h R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J ⊢ jacobson J = J [PROOFSTEP] apply isJacobson_polynomial_of_domain R' J [GOAL] case h R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ hR : IsJacobson R I : Ideal R[X] hI : IsPrime I R' : Subring (R[X] ⧸ I) := RingHom.range (RingHom.comp (Quotient.mk I) C) i : R →+* { x // x ∈ R' } := RingHom.rangeRestrict (RingHom.comp (Quotient.mk I) C) hi : Function.Surjective ↑i hi' : RingHom.ker (mapRingHom i) ≤ I R'_jacob : IsJacobson { x // x ∈ R' } J : Ideal { x // x ∈ R' }[X] := map (mapRingHom i) I h_surj : Function.Surjective ↑(mapRingHom i) this : IsPrime J ⊢ ∀ (x : { x // x ∈ R' }), ↑C x ∈ J → x = 0 [PROOFSTEP] exact (eq_zero_of_polynomial_mem_map_range I) [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ ⊢ IsJacobson R[X] ↔ IsJacobson R [PROOFSTEP] refine' ⟨_, isJacobson_polynomial_of_isJacobson⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ ⊢ IsJacobson R[X] → IsJacobson R [PROOFSTEP] intro H [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ H : IsJacobson R[X] ⊢ IsJacobson R [PROOFSTEP] exact isJacobson_of_surjective ⟨eval₂RingHom (RingHom.id _) 1, fun x => ⟨C x, by simp only [coe_eval₂RingHom, RingHom.id_apply, eval₂_C]⟩⟩ [GOAL] R : Type u_1 S : Type u_2 inst✝⁴ : CommRing R inst✝³ : CommRing S inst✝² : IsDomain S Rₘ : Type u_3 Sₘ : Type u_4 inst✝¹ : CommRing Rₘ inst✝ : CommRing Sₘ H : IsJacobson R[X] x : R ⊢ ↑(eval₂RingHom (RingHom.id R) 1) (↑C x) = x [PROOFSTEP] simp only [coe_eval₂RingHom, RingHom.id_apply, eval₂_C] [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 ⊢ IsMaximal (comap C P) [PROOFSTEP] let P' := comap (C : R →+* R[X]) P [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P ⊢ IsMaximal (comap C P) [PROOFSTEP] haveI hP'_prime : P'.IsPrime := comap_isPrime C P [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' ⊢ IsMaximal (comap C P) [PROOFSTEP] obtain ⟨⟨m, hmem_P⟩, hm⟩ := Submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_isField) [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 ⊢ IsMaximal (comap C P) [PROOFSTEP] have hm' : m ≠ 0 := by simpa [Submodule.coe_eq_zero] using hm [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 ⊢ m ≠ 0 [PROOFSTEP] simpa [Submodule.coe_eq_zero] using hm [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 ⊢ IsMaximal (comap C P) [PROOFSTEP] let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P (C : R →+* R[X]) le_rfl [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') ⊢ IsMaximal (comap C P) [PROOFSTEP] let a : R ⧸ P' := (m.map (Quotient.mk P')).leadingCoeff [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) ⊢ IsMaximal (comap C P) [PROOFSTEP] let M : Submonoid (R ⧸ P') := Submonoid.powers a [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a ⊢ IsMaximal (comap C P) [PROOFSTEP] rw [← bot_quotient_isMaximal_iff] [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a ⊢ IsMaximal ⊥ [PROOFSTEP] have hp0 : a ≠ 0 := fun hp0' => hm' <| map_injective (Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R)) ((injective_iff_map_eq_zero (Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R))).2 fun x hx => by rwa [Quotient.eq_zero_iff_mem, (by rwa [eq_bot_iff] : (P.comap C : Ideal R) = ⊥)] at hx ) (by simpa only [leadingCoeff_eq_zero, Polynomial.map_zero] using hp0') [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0' : a = 0 x : R hx : ↑(Quotient.mk (comap C P)) x = 0 ⊢ x = 0 [PROOFSTEP] rwa [Quotient.eq_zero_iff_mem, (by rwa [eq_bot_iff] : (P.comap C : Ideal R) = ⊥)] at hx [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0' : a = 0 x : R hx : x ∈ comap C P ⊢ comap C P = ⊥ [PROOFSTEP] rwa [eq_bot_iff] [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0' : a = 0 ⊢ Polynomial.map (Quotient.mk (comap C P)) m = Polynomial.map (Quotient.mk (comap C P)) 0 [PROOFSTEP] simpa only [leadingCoeff_eq_zero, Polynomial.map_zero] using hp0' [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 ⊢ IsMaximal ⊥ [PROOFSTEP] have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 (pow_eq_zero hn) [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M ⊢ IsMaximal ⊥ [PROOFSTEP] suffices (⊥ : Ideal (Localization M)).IsMaximal by rw [← IsLocalization.comap_map_of_isPrime_disjoint M (Localization M) ⊥ bot_prime (disjoint_iff_inf_le.mpr fun x hx => hM (hx.2 ▸ hx.1))] refine' ((isMaximal_iff_isMaximal_disjoint (Localization M) _ _).mp (by rwa [map_bot])).1 [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M this : IsMaximal ⊥ ⊢ IsMaximal ⊥ [PROOFSTEP] rw [← IsLocalization.comap_map_of_isPrime_disjoint M (Localization M) ⊥ bot_prime (disjoint_iff_inf_le.mpr fun x hx => hM (hx.2 ▸ hx.1))] [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M this : IsMaximal ⊥ ⊢ IsMaximal (comap (algebraMap (R ⧸ P') (Localization M)) (map (algebraMap (R ⧸ P') (Localization M)) ⊥)) [PROOFSTEP] refine' ((isMaximal_iff_isMaximal_disjoint (Localization M) _ _).mp (by rwa [map_bot])).1 [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M this : IsMaximal ⊥ ⊢ IsMaximal (map (algebraMap (R ⧸ P') (Localization M)) ⊥) [PROOFSTEP] rwa [map_bot] [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M ⊢ IsMaximal ⊥ [PROOFSTEP] let M' : Submonoid (R[X] ⧸ P) := M.map φ [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ IsMaximal ⊥ [PROOFSTEP] have hM' : (0 : R[X] ⧸ P) ∉ M' := fun ⟨z, hz⟩ => hM (quotientMap_injective (_root_.trans hz.2 φ.map_zero.symm) ▸ hz.1) [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' ⊢ IsMaximal ⊥ [PROOFSTEP] haveI : IsDomain (Localization M') := IsLocalization.isDomain_localization (le_nonZeroDivisors_of_noZeroDivisors hM') [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this : IsDomain (Localization M') ⊢ IsMaximal ⊥ [PROOFSTEP] suffices (⊥ : Ideal (Localization M')).IsMaximal by rw [le_antisymm bot_le (comap_bot_le_of_injective _ (IsLocalization.map_injective_of_injective M (Localization M) (Localization M') quotientMap_injective))] refine' isMaximal_comap_of_isIntegral_of_isMaximal' _ _ ⊥ this have isloc : IsLocalization (Submonoid.map φ M) (Localization M') := by infer_instance exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P m hmem_P _ _ _ isloc [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this✝ : IsDomain (Localization M') this : IsMaximal ⊥ ⊢ IsMaximal ⊥ [PROOFSTEP] rw [le_antisymm bot_le (comap_bot_le_of_injective _ (IsLocalization.map_injective_of_injective M (Localization M) (Localization M') quotientMap_injective))] [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this✝ : IsDomain (Localization M') this : IsMaximal ⊥ ⊢ IsMaximal (comap (IsLocalization.map (Localization M') (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : M ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) M))) ⊥) [PROOFSTEP] refine' isMaximal_comap_of_isIntegral_of_isMaximal' _ _ ⊥ this [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this✝ : IsDomain (Localization M') this : IsMaximal ⊥ ⊢ RingHom.IsIntegral (IsLocalization.map (Localization M') (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : M ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) M))) [PROOFSTEP] have isloc : IsLocalization (Submonoid.map φ M) (Localization M') := by infer_instance [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this✝ : IsDomain (Localization M') this : IsMaximal ⊥ ⊢ IsLocalization (Submonoid.map φ M) (Localization M') [PROOFSTEP] infer_instance [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this✝ : IsDomain (Localization M') this : IsMaximal ⊥ isloc : IsLocalization (Submonoid.map φ M) (Localization M') ⊢ RingHom.IsIntegral (IsLocalization.map (Localization M') (quotientMap P C (_ : comap C P ≤ comap C P)) (_ : M ≤ Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P)) (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P)) M))) [PROOFSTEP] exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P m hmem_P _ _ _ isloc [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this : IsDomain (Localization M') ⊢ IsMaximal ⊥ [PROOFSTEP] rw [(map_bot.symm : (⊥ : Ideal (Localization M')) = map (algebraMap (R[X] ⧸ P) (Localization M')) ⊥)] [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this : IsDomain (Localization M') ⊢ IsMaximal (map (algebraMap (R[X] ⧸ P) (Localization M')) ⊥) [PROOFSTEP] let bot_maximal := (bot_quotient_isMaximal_iff _).mpr hP [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this : IsDomain (Localization M') bot_maximal : IsMaximal ⊥ := Iff.mpr (bot_quotient_isMaximal_iff P) hP ⊢ IsMaximal (map (algebraMap (R[X] ⧸ P) (Localization M')) ⊥) [PROOFSTEP] refine' map.isMaximal (algebraMap (R[X] ⧸ P) (Localization M')) _ bot_maximal [GOAL] case intro.mk R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this : IsDomain (Localization M') bot_maximal : IsMaximal ⊥ := Iff.mpr (bot_quotient_isMaximal_iff P) hP ⊢ Function.Bijective ↑(algebraMap (R[X] ⧸ P) (Localization M')) [PROOFSTEP] apply IsField.localization_map_bijective hM' [GOAL] case intro.mk.hR R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P hP'_prime : IsPrime P' m : R[X] hmem_P : m ∈ P hm : { val := m, property := hmem_P } ≠ 0 hm' : m ≠ 0 φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') m) M : Submonoid (R ⧸ P') := Submonoid.powers a hp0 : a ≠ 0 hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : ¬0 ∈ M' this : IsDomain (Localization M') bot_maximal : IsMaximal ⊥ := Iff.mpr (bot_quotient_isMaximal_iff P) hP ⊢ IsField (R[X] ⧸ P) [PROOFSTEP] rwa [← Quotient.maximal_ideal_iff_isField_quotient, ← bot_quotient_isMaximal_iff] [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] refine' (isIntegral_quotientMap_iff _).mp _ [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] let P' : Ideal R := P.comap C [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] obtain ⟨pX, hpX, hp0⟩ := exists_nonzero_mem_of_ne_bot (ne_of_lt (bot_lt_of_maximal P polynomial_not_isField)).symm hP' [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] let a : R ⧸ P' := (pX.map (Quotient.mk P')).leadingCoeff [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] let M : Submonoid (R ⧸ P') := Submonoid.powers a [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] haveI hP'_prime : P'.IsPrime := comap_isPrime C P [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 <| leadingCoeff_eq_zero.mp (pow_eq_zero hn) [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] let M' : Submonoid (R[X] ⧸ P) := M.map φ [GOAL] case intro.intro R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ RingHom.IsIntegral (quotientMap P C (_ : comap C P ≤ comap C P)) [PROOFSTEP] refine' φ.isIntegral_tower_bot_of_isIntegral (algebraMap _ (Localization M')) _ _ [GOAL] case intro.intro.refine'_1 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ Function.Injective ↑(algebraMap (R[X] ⧸ P) (Localization M')) [PROOFSTEP] refine' IsLocalization.injective (Localization M') (show M' ≤ _ from le_nonZeroDivisors_of_noZeroDivisors fun hM' => hM _) [GOAL] case intro.intro.refine'_1 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M hM' : 0 ∈ M' ⊢ 0 ∈ M [PROOFSTEP] exact let ⟨z, zM, z0⟩ := hM' quotientMap_injective (_root_.trans z0 φ.map_zero.symm) ▸ zM [GOAL] case intro.intro.refine'_2 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ RingHom.IsIntegral (RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ) [PROOFSTEP] suffices : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = (IsLocalization.map (Localization M') φ M.le_comap_map).comp (algebraMap (R ⧸ P') (Localization M)) [GOAL] case intro.intro.refine'_2 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M this : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) ⊢ RingHom.IsIntegral (RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ) case this R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) [PROOFSTEP] rw [this] [GOAL] case intro.intro.refine'_2 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M this : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) ⊢ RingHom.IsIntegral (RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M))) case this R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) [PROOFSTEP] refine' RingHom.isIntegral_trans (algebraMap (R ⧸ P') (Localization M)) (IsLocalization.map (Localization M') φ M.le_comap_map) _ _ [GOAL] case intro.intro.refine'_2.refine'_1 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M this : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) ⊢ RingHom.IsIntegral (algebraMap (R ⧸ P') (Localization M)) [PROOFSTEP] exact (algebraMap (R ⧸ P') (Localization M)).isIntegral_of_surjective (IsField.localization_map_bijective hM ((Quotient.maximal_ideal_iff_isField_quotient _).mp (isMaximal_comap_C_of_isMaximal P hP'))).2 [GOAL] case intro.intro.refine'_2.refine'_2 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M this : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) ⊢ RingHom.IsIntegral (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) [PROOFSTEP] have isloc : IsLocalization M' (Localization M') := by infer_instance [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M this : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) ⊢ IsLocalization M' (Localization M') [PROOFSTEP] infer_instance [GOAL] case intro.intro.refine'_2.refine'_2 R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M this : RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) isloc : IsLocalization M' (Localization M') ⊢ RingHom.IsIntegral (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) [PROOFSTEP] exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P pX hpX _ _ _ isloc [GOAL] case this R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P inst✝ : Nontrivial R hR : IsJacobson R hP' : ∀ (x : R), ↑C x ∈ P → x = 0 P' : Ideal R := comap C P pX : R[X] hpX : pX ∈ P hp0 : Polynomial.map (Quotient.mk (comap C P)) pX ≠ 0 a : R ⧸ P' := Polynomial.leadingCoeff (Polynomial.map (Quotient.mk P') pX) M : Submonoid (R ⧸ P') := Submonoid.powers a φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P') hP'_prime : IsPrime P' hM : ¬0 ∈ M M' : Submonoid (R[X] ⧸ P) := Submonoid.map φ M ⊢ RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = RingHom.comp (IsLocalization.map (Localization M') φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))) (algebraMap (R ⧸ P') (Localization M)) [PROOFSTEP] rw [IsLocalization.map_comp M.le_comap_map] [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] let P' : Ideal R := P.comap C [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] haveI : P'.IsPrime := comap_isPrime C P [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] let f : R[X] →+* Polynomial (R ⧸ P') := Polynomial.mapRingHom (Quotient.mk P') [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] have hf : Function.Surjective ↑f := map_surjective (Quotient.mk P') Quotient.mk_surjective [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] have hPJ : P = (P.map f).comap f := by rw [comap_map_of_surjective _ hf] refine' le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl _) refine' fun p hp => polynomial_mem_ideal_of_coeff_mem_ideal P p fun n => Quotient.eq_zero_iff_mem.mp _ simpa only [coeff_map, coe_mapRingHom] using (Polynomial.ext_iff.mp hp) n [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f ⊢ P = comap f (map f P) [PROOFSTEP] rw [comap_map_of_surjective _ hf] [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f ⊢ P = P ⊔ comap f ⊥ [PROOFSTEP] refine' le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl _) [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f ⊢ comap f ⊥ ≤ P [PROOFSTEP] refine' fun p hp => polynomial_mem_ideal_of_coeff_mem_ideal P p fun n => Quotient.eq_zero_iff_mem.mp _ [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f p : R[X] hp : p ∈ comap f ⊥ n : ℕ ⊢ ↑(Quotient.mk (comap C P)) (coeff p n) = 0 [PROOFSTEP] simpa only [coeff_map, coe_mapRingHom] using (Polynomial.ext_iff.mp hp) n [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) C) [PROOFSTEP] refine' RingHom.isIntegral_tower_bot_of_isIntegral _ _ (injective_quotient_le_comap_map P) _ [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) ⊢ RingHom.IsIntegral (RingHom.comp (quotientMap (map (mapRingHom (Quotient.mk (comap C P))) P) (mapRingHom (Quotient.mk (comap C P))) (_ : P ≤ comap (mapRingHom (Quotient.mk (comap C P))) (map (mapRingHom (Quotient.mk (comap C P))) P))) (RingHom.comp (Quotient.mk P) C)) [PROOFSTEP] rw [← quotient_mk_maps_eq] [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) ⊢ RingHom.IsIntegral (RingHom.comp (RingHom.comp (Quotient.mk (map (mapRingHom (Quotient.mk (comap C P))) P)) C) (Quotient.mk (comap C P))) [PROOFSTEP] refine RingHom.isIntegral_trans _ _ ((Quotient.mk P').isIntegral_of_surjective Quotient.mk_surjective) ?_ [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk (map (mapRingHom (Quotient.mk (comap C P))) P)) C) [PROOFSTEP] have : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) [GOAL] case this R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) ⊢ IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) [PROOFSTEP] exact Or.recOn (map_eq_top_or_isMaximal_of_surjective f hf hP) (fun h => absurd (_root_.trans (h ▸ hPJ : P = comap f ⊤) comap_top : P = ⊤) hP.ne_top) id [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk (map (mapRingHom (Quotient.mk (comap C P))) P)) C) [PROOFSTEP] apply quotient_mk_comp_C_isIntegral_of_jacobson' _ ?_ (fun x hx => ?_) [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) ⊢ IsJacobson (R ⧸ comap C P) R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) x : R ⧸ comap C P hx : ↑C x ∈ map (mapRingHom (Quotient.mk (comap C P))) P ⊢ x = 0 [PROOFSTEP] any_goals exact Ideal.isJacobson_quotient [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) ⊢ IsJacobson (R ⧸ comap C P) [PROOFSTEP] exact Ideal.isJacobson_quotient [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) x : R ⧸ comap C P hx : ↑C x ∈ map (mapRingHom (Quotient.mk (comap C P))) P ⊢ x = 0 [PROOFSTEP] exact Ideal.isJacobson_quotient [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) x : R ⧸ comap C P hx : ↑C x ∈ map (mapRingHom (Quotient.mk (comap C P))) P ⊢ x = 0 [PROOFSTEP] obtain ⟨z, rfl⟩ := Quotient.mk_surjective x [GOAL] case intro R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P P' : Ideal R := comap C P this✝ : IsPrime P' f : R[X] →+* (R ⧸ P')[X] := mapRingHom (Quotient.mk P') hf : Function.Surjective ↑f hPJ : P = comap f (map f P) this : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) z : R hx : ↑C (↑(Quotient.mk (comap C P)) z) ∈ map (mapRingHom (Quotient.mk (comap C P))) P ⊢ ↑(Quotient.mk (comap C P)) z = 0 [PROOFSTEP] rwa [Quotient.eq_zero_iff_mem, mem_comap, hPJ, mem_comap, coe_mapRingHom, map_C] [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P ⊢ IsMaximal (comap C P) [PROOFSTEP] rw [← @mk_ker _ _ P, RingHom.ker_eq_comap_bot, comap_comap] [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal R[X] hP : IsMaximal P ⊢ IsMaximal (comap (RingHom.comp (Quotient.mk P) C) ⊥) [PROOFSTEP] exact isMaximal_comap_of_isIntegral_of_isMaximal' _ (quotient_mk_comp_C_isIntegral_of_jacobson P) ⊥ ((bot_quotient_isMaximal_iff _).mpr hP) [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P✝ : Ideal R[X] hP✝ : IsMaximal P✝ P : Ideal R[X] hP : IsMaximal P ⊢ IsMaximal (comap C P) [PROOFSTEP] haveI := hP [GOAL] R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P✝ : Ideal R[X] hP✝ : IsMaximal P✝ P : Ideal R[X] hP this : IsMaximal P ⊢ IsMaximal (comap C P) [PROOFSTEP] exact isMaximal_comap_C_of_isJacobson P [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S hf : Function.Surjective ↑f ⊢ RingHom.IsIntegral (RingHom.comp f C) [PROOFSTEP] haveI : f.ker.IsMaximal := RingHom.ker_isMaximal_of_surjective f hf [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S hf : Function.Surjective ↑f this : IsMaximal (RingHom.ker f) ⊢ RingHom.IsIntegral (RingHom.comp f C) [PROOFSTEP] let g : R[X] ⧸ (RingHom.ker f) →+* S := Ideal.Quotient.lift (RingHom.ker f) f fun _ h => h [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S hf : Function.Surjective ↑f this : IsMaximal (RingHom.ker f) g : R[X] ⧸ RingHom.ker f →+* S := Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f) ⊢ RingHom.IsIntegral (RingHom.comp f C) [PROOFSTEP] have hfg : g.comp (Quotient.mk (RingHom.ker f)) = f := ringHom_ext' rfl rfl [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S hf : Function.Surjective ↑f this : IsMaximal (RingHom.ker f) g : R[X] ⧸ RingHom.ker f →+* S := Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f) hfg : RingHom.comp g (Quotient.mk (RingHom.ker f)) = f ⊢ RingHom.IsIntegral (RingHom.comp f C) [PROOFSTEP] rw [← hfg, RingHom.comp_assoc] [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S hf : Function.Surjective ↑f this : IsMaximal (RingHom.ker f) g : R[X] ⧸ RingHom.ker f →+* S := Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f) hfg : RingHom.comp g (Quotient.mk (RingHom.ker f)) = f ⊢ RingHom.IsIntegral (RingHom.comp g (RingHom.comp (Quotient.mk (RingHom.ker f)) C)) [PROOFSTEP] refine RingHom.isIntegral_trans _ g (quotient_mk_comp_C_isIntegral_of_jacobson (RingHom.ker f)) (g.isIntegral_of_surjective ?_) [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S hf : Function.Surjective ↑f this : IsMaximal (RingHom.ker f) g : R[X] ⧸ RingHom.ker f →+* S := Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f) hfg : RingHom.comp g (Quotient.mk (RingHom.ker f)) = f ⊢ Function.Surjective ↑g [PROOFSTEP] rw [← hfg] at hf [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S this : IsMaximal (RingHom.ker f) g : R[X] ⧸ RingHom.ker f →+* S := Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f) hf : Function.Surjective ↑(RingHom.comp g (Quotient.mk (RingHom.ker f))) hfg : RingHom.comp g (Quotient.mk (RingHom.ker f)) = f ⊢ Function.Surjective ↑g [PROOFSTEP] norm_num at hf [GOAL] R : Type u_1 inst✝² : CommRing R inst✝¹ : IsJacobson R P : Ideal R[X] hP : IsMaximal P S : Type u_2 inst✝ : Field S f : R[X] →+* S this : IsMaximal (RingHom.ker f) g : R[X] ⧸ RingHom.ker f →+* S := Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f) hf : Function.Surjective (↑(Quotient.lift (RingHom.ker f) f (_ : ∀ (x : R[X]), x ∈ RingHom.ker f → x ∈ RingHom.ker f)) ∘ ↑(Quotient.mk (RingHom.ker f))) hfg : RingHom.comp g (Quotient.mk (RingHom.ker f)) = f ⊢ Function.Surjective ↑g [PROOFSTEP] exact Function.Surjective.of_comp hf [GOAL] R : Type u_1 inst✝² : CommRing R ι : Type u_2 inst✝¹ : _root_.Finite ι inst✝ : IsJacobson R ⊢ IsJacobson (MvPolynomial ι R) [PROOFSTEP] cases nonempty_fintype ι [GOAL] case intro R : Type u_1 inst✝² : CommRing R ι : Type u_2 inst✝¹ : _root_.Finite ι inst✝ : IsJacobson R val✝ : Fintype ι ⊢ IsJacobson (MvPolynomial ι R) [PROOFSTEP] haveI := Classical.decEq ι [GOAL] case intro R : Type u_1 inst✝² : CommRing R ι : Type u_2 inst✝¹ : _root_.Finite ι inst✝ : IsJacobson R val✝ : Fintype ι this : DecidableEq ι ⊢ IsJacobson (MvPolynomial ι R) [PROOFSTEP] let e := Fintype.equivFin ι [GOAL] case intro R : Type u_1 inst✝² : CommRing R ι : Type u_2 inst✝¹ : _root_.Finite ι inst✝ : IsJacobson R val✝ : Fintype ι this : DecidableEq ι e : ι ≃ Fin (Fintype.card ι) := Fintype.equivFin ι ⊢ IsJacobson (MvPolynomial ι R) [PROOFSTEP] rw [isJacobson_iso (renameEquiv R e).toRingEquiv] [GOAL] case intro R : Type u_1 inst✝² : CommRing R ι : Type u_2 inst✝¹ : _root_.Finite ι inst✝ : IsJacobson R val✝ : Fintype ι this : DecidableEq ι e : ι ≃ Fin (Fintype.card ι) := Fintype.equivFin ι ⊢ IsJacobson (MvPolynomial (Fin (Fintype.card ι)) R) [PROOFSTEP] exact isJacobson_MvPolynomial_fin _ [GOAL] n : ℕ R : Type u S : Type v inst✝² : CommRing R inst✝¹ : CommRing S inst✝ : Algebra R S src✝ : S →+* S[X] := Polynomial.C r : R ⊢ OneHom.toFun (↑↑{ toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0), map_add' := (_ : ∀ (x y : S), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }) (↑(algebraMap R S) r) = ↑(algebraMap R S[X]) r [PROOFSTEP] rfl [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] let Q := P.comap v.toAlgHom.toRingHom [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] have hw : Ideal.map v Q = P := map_comap_of_surjective v v.surjective P [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] haveI hQ : IsMaximal Q := comap_isMaximal_of_surjective _ v.surjective [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] let w : (S[X] ⧸ Q) ≃ₐ[R] (T ⧸ P) := Ideal.quotientEquivAlg Q P v hw.symm [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] let Q' := Q.comap (Polynomial.C) [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] let w' : (S ⧸ Q') →ₐ[R] (S[X] ⧸ Q) := Ideal.quotientMapₐ Q (Cₐ R S) le_rfl [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] have h_eq : algebraMap R (T ⧸ P) = w.toRingEquiv.toRingHom.comp (w'.toRingHom.comp (algebraMap R (S ⧸ Q'))) := by ext r simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe, RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe, AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes] [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') ⊢ algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) [PROOFSTEP] ext r [GOAL] case a n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') r : R ⊢ ↑(algebraMap R (T ⧸ P)) r = ↑(RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q')))) r [PROOFSTEP] simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe, RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe, AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes] [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral (algebraMap R (T ⧸ P)) [PROOFSTEP] rw [h_eq] [GOAL] n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral (RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q')))) [PROOFSTEP] apply RingHom.isIntegral_trans [GOAL] case hf n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) case hg n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) [PROOFSTEP] apply RingHom.isIntegral_trans [GOAL] case hf.hf n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral (algebraMap R (S ⧸ Q')) [PROOFSTEP] apply IH [GOAL] case hf.hf.a n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ IsMaximal Q' [PROOFSTEP] apply Polynomial.isMaximal_comap_C_of_isJacobson' [GOAL] case hf.hf.a.hP n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ IsMaximal Q [PROOFSTEP] exact hQ [GOAL] case hf.hg n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral ↑w' [PROOFSTEP] suffices : w'.toRingHom = Ideal.quotientMap Q (Polynomial.C) le_rfl [GOAL] case hf.hg n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) this : ↑w' = quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q) ⊢ RingHom.IsIntegral ↑w' [PROOFSTEP] rw [this] [GOAL] case hf.hg n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) this : ↑w' = quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q) ⊢ RingHom.IsIntegral (quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q)) [PROOFSTEP] rw [isIntegral_quotientMap_iff _] [GOAL] case hf.hg n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) this : ↑w' = quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q) ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk Q) Polynomial.C) [PROOFSTEP] apply Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson [GOAL] case this n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ ↑w' = quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q) [PROOFSTEP] rfl [GOAL] case hg n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ RingHom.IsIntegral (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) [PROOFSTEP] apply RingHom.isIntegral_of_surjective [GOAL] case hg.hf n : ℕ R : Type u S : Type v T : Type w inst✝⁵ : CommRing R inst✝⁴ : CommRing S inst✝³ : CommRing T inst✝² : IsJacobson S inst✝¹ : Algebra R S inst✝ : Algebra R T IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q)) v : S[X] ≃ₐ[R] T P : Ideal T hP : IsMaximal P Q : Ideal S[X] := comap (↑↑v) P hw : map v Q = P hQ : IsMaximal Q w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q) Q' : Ideal S := comap Polynomial.C Q w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q') h_eq : algebraMap R (T ⧸ P) = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q'))) ⊢ Function.Surjective ↑(RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) [PROOFSTEP] exact w.surjective [GOAL] n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal (MvPolynomial (Fin n) R) hP : IsMaximal P ⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) [PROOFSTEP] induction' n with n IH [GOAL] case zero n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P✝ : Ideal (MvPolynomial (Fin n) R) hP✝ : IsMaximal P✝ P : Ideal (MvPolynomial (Fin Nat.zero) R) hP : IsMaximal P ⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin Nat.zero) R ⧸ P)) [PROOFSTEP] apply RingHom.isIntegral_of_surjective [GOAL] case zero.hf n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P✝ : Ideal (MvPolynomial (Fin n) R) hP✝ : IsMaximal P✝ P : Ideal (MvPolynomial (Fin Nat.zero) R) hP : IsMaximal P ⊢ Function.Surjective ↑(algebraMap R (MvPolynomial (Fin Nat.zero) R ⧸ P)) [PROOFSTEP] apply Function.Surjective.comp Quotient.mk_surjective [GOAL] case zero.hf n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P✝ : Ideal (MvPolynomial (Fin n) R) hP✝ : IsMaximal P✝ P : Ideal (MvPolynomial (Fin Nat.zero) R) hP : IsMaximal P ⊢ Function.Surjective fun x => ↑(algebraMap R (MvPolynomial (Fin Nat.zero) R)) x [PROOFSTEP] exact C_surjective (Fin 0) [GOAL] case succ n✝ : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P✝ : Ideal (MvPolynomial (Fin n✝) R) hP✝ : IsMaximal P✝ n : ℕ IH : ∀ (P : Ideal (MvPolynomial (Fin n) R)), IsMaximal P → RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) P : Ideal (MvPolynomial (Fin (Nat.succ n)) R) hP : IsMaximal P ⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin (Nat.succ n)) R ⧸ P)) [PROOFSTEP] apply aux_IH IH (finSuccEquiv R n).symm P hP [GOAL] n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal (MvPolynomial (Fin n) R) hP : IsMaximal P ⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) MvPolynomial.C) [PROOFSTEP] change RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) [GOAL] n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal (MvPolynomial (Fin n) R) hP : IsMaximal P ⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) [PROOFSTEP] apply quotient_mk_comp_C_isIntegral_of_jacobson' [GOAL] case hP n : ℕ R : Type u_1 inst✝¹ : CommRing R inst✝ : IsJacobson R P : Ideal (MvPolynomial (Fin n) R) hP : IsMaximal P ⊢ IsMaximal P [PROOFSTEP] infer_instance [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] cases nonempty_fintype σ [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] have e := (Fintype.equivFin σ).symm [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective (↑f ∘ ↑(renameEquiv R e)) ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] change Function.Surjective ↑f' at hf' [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] have : (f'.comp C).IsIntegral := by haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf' let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S := Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h have hfg : g.comp (Quotient.mk (RingHom.ker f')) = f' := ringHom_ext (fun r => rfl) fun i => rfl rw [← hfg, RingHom.comp_assoc] refine' RingHom.isIntegral_trans _ g (quotient_mk_comp_C_isIntegral_of_jacobson (RingHom.ker f')) (g.isIntegral_of_surjective _) rw [← hfg] at hf' norm_num at hf' exact Function.Surjective.of_comp hf' [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' ⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C) [PROOFSTEP] haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf' [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : IsMaximal (ker f') ⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C) [PROOFSTEP] let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S := Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : IsMaximal (ker f') g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ (x : MvPolynomial (Fin (Fintype.card σ)) R), x ∈ ker f' → x ∈ ker f') ⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C) [PROOFSTEP] have hfg : g.comp (Quotient.mk (RingHom.ker f')) = f' := ringHom_ext (fun r => rfl) fun i => rfl [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : IsMaximal (ker f') g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ (x : MvPolynomial (Fin (Fintype.card σ)) R), x ∈ ker f' → x ∈ ker f') hfg : RingHom.comp g (Quotient.mk (ker f')) = f' ⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C) [PROOFSTEP] rw [← hfg, RingHom.comp_assoc] [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : IsMaximal (ker f') g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ (x : MvPolynomial (Fin (Fintype.card σ)) R), x ∈ ker f' → x ∈ ker f') hfg : RingHom.comp g (Quotient.mk (ker f')) = f' ⊢ RingHom.IsIntegral (RingHom.comp g (RingHom.comp (Quotient.mk (ker f')) MvPolynomial.C)) [PROOFSTEP] refine' RingHom.isIntegral_trans _ g (quotient_mk_comp_C_isIntegral_of_jacobson (RingHom.ker f')) (g.isIntegral_of_surjective _) [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : IsMaximal (ker f') g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ (x : MvPolynomial (Fin (Fintype.card σ)) R), x ∈ ker f' → x ∈ ker f') hfg : RingHom.comp g (Quotient.mk (ker f')) = f' ⊢ Function.Surjective ↑g [PROOFSTEP] rw [← hfg] at hf' [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) this : IsMaximal (ker f') g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ (x : MvPolynomial (Fin (Fintype.card σ)) R), x ∈ ker f' → x ∈ ker f') hf' : Function.Surjective ↑(RingHom.comp g (Quotient.mk (ker f'))) hfg : RingHom.comp g (Quotient.mk (ker f')) = f' ⊢ Function.Surjective ↑g [PROOFSTEP] norm_num at hf' [GOAL] n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) this : IsMaximal (ker f') g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ (x : MvPolynomial (Fin (Fintype.card σ)) R), x ∈ ker f' → x ∈ ker f') hf' : Function.Surjective (↑(Quotient.lift (ker f') (RingHom.comp f ↑↑(renameEquiv R e)) (_ : ∀ (a : MvPolynomial (Fin (Fintype.card σ)) R), a ∈ ker f' → ↑(RingHom.comp f ↑↑(renameEquiv R e)) a = 0)) ∘ ↑(Quotient.mk (ker (RingHom.comp f ↑↑(renameEquiv R e))))) hfg : RingHom.comp g (Quotient.mk (ker f')) = f' ⊢ Function.Surjective ↑g [PROOFSTEP] exact Function.Surjective.of_comp hf' [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C) ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] rw [RingHom.comp_assoc] at this [GOAL] case intro n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : RingHom.IsIntegral (RingHom.comp f (RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) MvPolynomial.C)) ⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C) [PROOFSTEP] convert this [GOAL] case h.e'_5.h.e'_8 n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : RingHom.IsIntegral (RingHom.comp f (RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) MvPolynomial.C)) ⊢ MvPolynomial.C = RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) MvPolynomial.C [PROOFSTEP] refine' RingHom.ext fun x => _ [GOAL] case h.e'_5.h.e'_8 n : ℕ R : Type u_1 inst✝³ : CommRing R inst✝² : IsJacobson R σ : Type u_2 inst✝¹ : _root_.Finite σ S : Type u_3 inst✝ : Field S f : MvPolynomial σ R →+* S hf : Function.Surjective ↑f val✝ : Fintype σ e : Fin (Fintype.card σ) ≃ σ f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S := RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) hf' : Function.Surjective ↑f' this : RingHom.IsIntegral (RingHom.comp f (RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) MvPolynomial.C)) x : R ⊢ ↑MvPolynomial.C x = ↑(RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e))) MvPolynomial.C) x [PROOFSTEP] exact ((renameEquiv R e).commutes' x).symm
#ifndef problems_h #define problems_h #include <ceed.h> #include <petsc.h> #include "../problems/cl-problems.h" #include "../problems/neo-hookean.h" #include "../problems/mooney-rivlin.h" // Physics options #define SOLIDS_PROBLEM_REGISTER(list, name, fname, physics) \ ierr = PetscFunctionListAdd(&list->setupPhysics, name, \ PhysicsContext_ ## physics); CHKERRQ(ierr); \ ierr = PetscFunctionListAdd(&list->setupSmootherPhysics, name, \ PhysicsSmootherContext_ ## physics); CHKERRQ(ierr); \ ierr = PetscFunctionListAdd(&list->setupLibceedFineLevel, name, \ SetupLibceedFineLevel_ ## fname); CHKERRQ(ierr); \ ierr = PetscFunctionListAdd(&list->setupLibceedLevel, name, \ SetupLibceedLevel_ ## fname); CHKERRQ(ierr); \ typedef struct ProblemFunctions_ *ProblemFunctions; struct ProblemFunctions_ { PetscFunctionList setupPhysics, setupSmootherPhysics, setupLibceedFineLevel, setupLibceedLevel; }; PetscErrorCode RegisterProblems(ProblemFunctions problem_functions); #define SOLIDS_PROBLEM(name) \ PetscErrorCode SetupLibceedFineLevel_ ## name (DM dm, DM dm_energy, \ DM dm_diagnostic, Ceed ceed, AppCtx app_ctx, CeedQFunctionContext phys_ctx, \ PetscInt fine_level, PetscInt num_comp_u, PetscInt U_g_size, \ PetscInt U_loc_size, CeedVector force_ceed, CeedVector neumann_ceed, \ CeedData *data); \ PetscErrorCode SetupLibceedLevel_ ## name (DM dm, Ceed ceed, \ AppCtx app_ctx, PetscInt level, PetscInt num_comp_u, PetscInt U_g_size, \ PetscInt u_loc_size, CeedVector fine_mult, CeedData *data); \ SOLIDS_PROBLEM(ElasLinear); SOLIDS_PROBLEM(ElasSSNH); SOLIDS_PROBLEM(ElasFSCurrentNH1); SOLIDS_PROBLEM(ElasFSCurrentNH2); SOLIDS_PROBLEM(ElasFSInitialNH1); SOLIDS_PROBLEM(ElasFSInitialNH2); SOLIDS_PROBLEM(ElasFSInitialMR1); #endif //problems_h
He is mentioned numerous times in author Robert <unk> 's thriller Deadlock ( 2009 ) . Zhou is first featured in chapter eight during a conversation between the main character John " Hutch " Hutchinson , a journalist bent on stopping the maniacal plans of a billionaire madman , and his friend 's young son Dillon , an archery enthusiast . When Hutch asks him if he had ever heard of the archery @-@ champion @-@ turned @-@ actor Howard Hill , Dillon replies : " I don 't think so ... You told me about Zhou Tong " . Hutch then says : " Oh , yeah . Zhou Tong was something . Taught the Song Dynasty to be the best military archers in history . But Howard Hill [ was the best ] " . Later in chapter fifty , while Hutch is trailing a killer through an airport , a page goes out over the intercom system for a " Mr. Zhou Tong " . When the page goes out again , Hutch muses : " Zhou Tong had been a famous archery teacher and military arts tutor in the Song Dynasty . [ Dillon and I ] had long telephone conversations about him , because of Tong 's blending of archery skills and self @-@ discipline . He was an inspiration to [ me ] . Dillon had sensed that and wanted to known everything about him " . He finally realizes that the page had to have been left by Dillon 's mother Laura to catch his attention . The page is sent to warn him of a trap , but Hutch receives it too late .
theory mccarthy91_M1 imports Main "$HIPSTER_HOME/IsaHipster" begin function m :: "int => int" where "m x = (if x > 100 then x - 10 else m (m (x + 11)))" by pat_completeness auto (*hipster m *) theorem x0 : "!! (n :: int) . (n <= 100) ==> ((m n) = 91)" by (tactic \<open>Subgoal.FOCUS_PARAMS (K (Tactic_Data.hard_tac @{context})) @{context} 1\<close>) end
section \<open>Standard Models\<close> text \<open>We define the kind of models we are interested in here. In particular, we care about standard graphs. To allow some reuse, we distinguish a generic version called @{term standard}, from an instantiated abbreviation @{term standard'}. There is little we can prove about these definition here, except for Lemma 2.\<close> theory StandardModels imports LabeledGraphSemantics Main begin abbreviation "a_bot \<equiv> A_Lbl S_Bot" abbreviation "a_top \<equiv> A_Lbl S_Top" abbreviation "a_idt \<equiv> A_Lbl S_Idt" notation a_bot ("\<bottom>") notation a_top ("\<top>") notation a_idt ("\<one>") type_synonym 'v std_term = "'v Standard_Constant allegorical_term" type_synonym 'v std_sentence = "'v std_term \<times> 'v std_term" type_synonym ('v,'a) std_graph = "('v Standard_Constant, ('v+'a)) labeled_graph" abbreviation ident_rel where "ident_rel idt G \<equiv> getRel idt G = (\<lambda> x.(x,x)) ` vertices G" lemma ident_relI[intro]: assumes min:"\<And> x. x \<in> vertices G \<Longrightarrow> (x,x) \<in> getRel idt G" and max1:"\<And> x y. (x,y) \<in> getRel idt G \<Longrightarrow> x = y" and max2:"\<And> x y. (x,y) \<in> getRel idt G \<Longrightarrow> x \<in> vertices G" shows "ident_rel idt G" proof from max1 max2 have "\<And> x y. (x,y) \<in> getRel idt G \<Longrightarrow> (x = y \<and> x \<in> vertices G)" by simp thus "getRel idt G \<subseteq> (\<lambda>x. (x, x)) ` vertices G" by auto show "(\<lambda>x. (x, x)) ` vertices G \<subseteq> getRel idt G" using min by auto qed text \<open>Definition 4, generically.\<close> definition standard :: "('l \<times> 'v) set \<Rightarrow> 'l \<Rightarrow> 'l \<Rightarrow> 'l \<Rightarrow> ('l, 'v) labeled_graph \<Rightarrow> bool" where "standard C b t idt G \<equiv> G = restrict G \<and> vertices G \<noteq> {} \<and> ident_rel idt G \<and> getRel b G = {} \<and> getRel t G = {(x,y). x\<in>vertices G \<and> y\<in>vertices G} \<and> (\<forall> (l,v) \<in> C. getRel l G = {(v,v)})" text \<open>Definition 4.\<close> abbreviation standard' :: "'v set \<Rightarrow> ('v,'a) std_graph \<Rightarrow> bool" where "standard' C \<equiv> standard ((\<lambda> c. (S_Const c,Inl c)) ` C) S_Bot S_Top S_Idt" text \<open>Definition 5.\<close> definition model :: "'v set \<Rightarrow> ('v,'a) std_graph \<Rightarrow> ('v std_sentence) set \<Rightarrow> bool" where "model C G T \<equiv> standard' C G \<and> (\<forall> S \<in> T. G \<Turnstile> S)" text \<open>Definition 5.\<close> abbreviation consistent :: "'b itself \<Rightarrow> 'v set \<Rightarrow> ('v std_sentence) set \<Rightarrow> bool" where "consistent _ C T \<equiv> \<exists> (G::('v,'b) std_graph). model C G T" text \<open>Definition 6.\<close> definition entails :: "'b itself \<Rightarrow> 'v set \<Rightarrow> ('v std_sentence) set \<Rightarrow> 'v std_sentence \<Rightarrow> bool" where "entails _ C T S \<equiv> \<forall> (G::('v,'b) std_graph). model C G T \<longrightarrow> G \<Turnstile> S" lemma standard_top_not_bot[intro]: "standard' C G \<Longrightarrow> :G:\<lbrakk>\<bottom>\<rbrakk> \<noteq> :G:\<lbrakk>\<top>\<rbrakk>" unfolding standard_def by auto text \<open>Lemma 2.\<close> lemma consistent_iff_entails_nonsense: "consistent t C T = (\<not> entails t C T (\<bottom>,\<top>))" proof show "consistent t C T \<Longrightarrow> \<not> entails t C T (\<bottom>, \<top>)" using standard_top_not_bot unfolding entails_def model_def by fastforce qed (auto simp:entails_def model_def) end
(* Title: ZF/AC/AC18_AC19.thy Author: Krzysztof Grabczewski The proof of AC1 \<Longrightarrow> AC18 \<Longrightarrow> AC19 \<Longrightarrow> AC1 *) theory AC18_AC19 imports AC_Equiv begin definition uu :: "i \<Rightarrow> i" where "uu(a) \<equiv> {c \<union> {0}. c \<in> a}" (* ********************************************************************** *) (* AC1 \<Longrightarrow> AC18 *) (* ********************************************************************** *) lemma PROD_subsets: "\<lbrakk>f \<in> (\<Prod>b \<in> {P(a). a \<in> A}. b); \<forall>a \<in> A. P(a)<=Q(a)\<rbrakk> \<Longrightarrow> (\<lambda>a \<in> A. f`P(a)) \<in> (\<Prod>a \<in> A. Q(a))" by (rule lam_type, drule apply_type, auto) lemma lemma_AC18: "\<lbrakk>\<forall>A. 0 \<notin> A \<longrightarrow> (\<exists>f. f \<in> (\<Prod>X \<in> A. X)); A \<noteq> 0\<rbrakk> \<Longrightarrow> (\<Inter>a \<in> A. \<Union>b \<in> B(a). X(a, b)) \<subseteq> (\<Union>f \<in> \<Prod>a \<in> A. B(a). \<Inter>a \<in> A. X(a, f`a))" apply (rule subsetI) apply (erule_tac x = "{{b \<in> B (a) . x \<in> X (a,b) }. a \<in> A}" in allE) apply (erule impE, fast) apply (erule exE) apply (rule UN_I) apply (fast elim!: PROD_subsets) apply (simp, fast elim!: not_emptyE dest: apply_type [OF _ RepFunI]) done lemma AC1_AC18: "AC1 \<Longrightarrow> PROP AC18" unfolding AC1_def apply (rule AC18.intro) apply (fast elim!: lemma_AC18 apply_type intro!: equalityI INT_I UN_I) done (* ********************************************************************** *) (* AC18 \<Longrightarrow> AC19 *) (* ********************************************************************** *) theorem (in AC18) AC19 unfolding AC19_def apply (intro allI impI) apply (rule AC18 [of _ "\<lambda>x. x", THEN mp], blast) done (* ********************************************************************** *) (* AC19 \<Longrightarrow> AC1 *) (* ********************************************************************** *) lemma RepRep_conj: "\<lbrakk>A \<noteq> 0; 0 \<notin> A\<rbrakk> \<Longrightarrow> {uu(a). a \<in> A} \<noteq> 0 \<and> 0 \<notin> {uu(a). a \<in> A}" apply (unfold uu_def, auto) apply (blast dest!: sym [THEN RepFun_eq_0_iff [THEN iffD1]]) done lemma lemma1_1: "\<lbrakk>c \<in> a; x = c \<union> {0}; x \<notin> a\<rbrakk> \<Longrightarrow> x - {0} \<in> a" apply clarify apply (rule subst_elem, assumption) apply (fast elim: notE subst_elem) done lemma lemma1_2: "\<lbrakk>f`(uu(a)) \<notin> a; f \<in> (\<Prod>B \<in> {uu(a). a \<in> A}. B); a \<in> A\<rbrakk> \<Longrightarrow> f`(uu(a))-{0} \<in> a" apply (unfold uu_def, fast elim!: lemma1_1 dest!: apply_type) done lemma lemma1: "\<exists>f. f \<in> (\<Prod>B \<in> {uu(a). a \<in> A}. B) \<Longrightarrow> \<exists>f. f \<in> (\<Prod>B \<in> A. B)" apply (erule exE) apply (rule_tac x = "\<lambda>a\<in>A. if (f` (uu(a)) \<in> a, f` (uu(a)), f` (uu(a))-{0})" in exI) apply (rule lam_type) apply (simp add: lemma1_2) done lemma lemma2_1: "a\<noteq>0 \<Longrightarrow> 0 \<in> (\<Union>b \<in> uu(a). b)" by (unfold uu_def, auto) lemma lemma2: "\<lbrakk>A\<noteq>0; 0\<notin>A\<rbrakk> \<Longrightarrow> (\<Inter>x \<in> {uu(a). a \<in> A}. \<Union>b \<in> x. b) \<noteq> 0" apply (erule not_emptyE) apply (rule_tac a = 0 in not_emptyI) apply (fast intro!: lemma2_1) done lemma AC19_AC1: "AC19 \<Longrightarrow> AC1" apply (unfold AC19_def AC1_def, clarify) apply (case_tac "A=0", force) apply (erule_tac x = "{uu (a) . a \<in> A}" in allE) apply (erule impE) apply (erule RepRep_conj, assumption) apply (rule lemma1) apply (drule lemma2, assumption, auto) done end
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Sander Dahmen -/ import linear_algebra.basis import linear_algebra.std_basis import set_theory.cardinal_ordinal /-! # Dimension of modules and vector spaces ## Main definitions * The rank of a module is defined as `module.rank : cardinal`. This is currently only defined for vector spaces, i.e., when the base semiring is a field. ## Main statements * `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same cardinality. * `dim_quotient_add_dim`: if V₁ is a submodule of V, then `module.rank (V/V₁) + module.rank V₁ = module.rank V`. * `dim_range_add_dim_ker`: the rank-nullity theorem. ## Implementation notes Many theorems in this file are not universe-generic when they relate dimensions in different universes. They should be as general as they can be without inserting `lift`s. The types `V`, `V'`, ... all live in different universes, and `V₁`, `V₂`, ... all live in the same universe. -/ noncomputable theory universes u v v' v'' u₁' w w' variables {K : Type u} {V V₁ V₂ V₃ : Type v} {V' V'₁ : Type v'} {V'' : Type v''} variables {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*} open_locale classical big_operators section module variables [field K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁] include K open submodule function set variables (K V) /-- The rank of a module, defined as a term of type `cardinal`. In a vector space, this is the same as the dimension of the space. TODO: this is currently only defined for vector spaces, as the cardinality of the basis set. It should be generalized to modules in general. The definition is marked as protected to avoid conflicts with `_root_.rank`, the rank of a linear map. -/ protected def module.rank : cardinal := cardinal.min (nonempty_subtype.2 (@exists_is_basis K V _ _ _)) (λ b, cardinal.mk b.1) variables {K V} section theorem is_basis.le_span {v : ι → V} {J : set V} (hv : is_basis K v) (hJ : span K J = ⊤) : cardinal.mk (range v) ≤ cardinal.mk J := begin cases le_or_lt cardinal.omega (cardinal.mk J) with oJ oJ, { have := cardinal.mk_range_eq_of_injective (linear_independent.injective hv.1), let S : J → set ι := λ j, ↑(is_basis.repr hv j).support, let S' : J → set V := λ j, v '' S j, have hs : range v ⊆ ⋃ j, S' j, { intros b hb, rcases mem_range.1 hb with ⟨i, hi⟩, have : span K J ≤ comap hv.repr (finsupp.supported K K (⋃ j, S j)) := span_le.2 (λ j hj x hx, ⟨_, ⟨⟨j, hj⟩, rfl⟩, hx⟩), rw hJ at this, replace : hv.repr (v i) ∈ (finsupp.supported K K (⋃ j, S j)) := this trivial, rw [hv.repr_eq_single, finsupp.mem_supported, finsupp.support_single_ne_zero one_ne_zero] at this, { subst b, rcases mem_Union.1 (this (finset.mem_singleton_self _)) with ⟨j, hj⟩, exact mem_Union.2 ⟨j, (mem_image _ _ _).2 ⟨i, hj, rfl⟩⟩ }, { apply_instance } }, refine le_of_not_lt (λ IJ, _), suffices : cardinal.mk (⋃ j, S' j) < cardinal.mk (range v), { exact not_le_of_lt this ⟨set.embedding_of_subset _ _ hs⟩ }, refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk (cardinal.sum_le_sum _ (λ _, cardinal.omega) _)) _, { exact λ j, le_of_lt (cardinal.lt_omega_iff_finite.2 $ (finset.finite_to_set _).image _) }, { rwa [cardinal.sum_const, cardinal.mul_eq_max oJ (le_refl _), max_eq_left oJ] } }, { rcases exists_finite_card_le_of_finite_of_linear_independent_of_span (cardinal.lt_omega_iff_finite.1 oJ) hv.1.to_subtype_range _ with ⟨fI, hi⟩, { rwa [← cardinal.nat_cast_le, cardinal.finset_card, set.finite.coe_to_finset, cardinal.finset_card, set.finite.coe_to_finset] at hi, }, { rw hJ, apply set.subset_univ } }, end end /-- dimension theorem -/ theorem mk_eq_mk_of_basis {v : ι → V} {v' : ι' → V} (hv : is_basis K v) (hv' : is_basis K v') : cardinal.lift.{w w'} (cardinal.mk ι) = cardinal.lift.{w' w} (cardinal.mk ι') := begin rw ←cardinal.lift_inj.{(max w w') v}, rw [cardinal.lift_lift, cardinal.lift_lift], apply le_antisymm, { convert cardinal.lift_le.{v (max w w')}.2 (hv.le_span hv'.2), { rw cardinal.lift_max.{w v w'}, apply (cardinal.mk_range_eq_of_injective hv.injective).symm, }, { rw cardinal.lift_max.{w' v w}, apply (cardinal.mk_range_eq_of_injective hv'.injective).symm, }, }, { convert cardinal.lift_le.{v (max w w')}.2 (hv'.le_span hv.2), { rw cardinal.lift_max.{w' v w}, apply (cardinal.mk_range_eq_of_injective hv'.injective).symm, }, { rw cardinal.lift_max.{w v w'}, apply (cardinal.mk_range_eq_of_injective hv.injective).symm, }, } end theorem mk_eq_mk_of_basis' {ι' : Type w} {v : ι → V} {v' : ι' → V} (hv : is_basis K v) (hv' : is_basis K v') : cardinal.mk ι = cardinal.mk ι' := cardinal.lift_inj.1 $ mk_eq_mk_of_basis hv hv' theorem is_basis.mk_eq_dim'' {ι : Type v} {v : ι → V} (h : is_basis K v) : cardinal.mk ι = module.rank K V := begin obtain ⟨v', e : module.rank K V = _⟩ := cardinal.min_eq _ _, rw e, rw ← cardinal.mk_range_eq _ h.injective, exact mk_eq_mk_of_basis' h.range v'.2 end theorem is_basis.mk_range_eq_dim {v : ι → V} (h : is_basis K v) : cardinal.mk (range v) = module.rank K V := h.range.mk_eq_dim'' theorem is_basis.mk_eq_dim {v : ι → V} (h : is_basis K v) : cardinal.lift.{w v} (cardinal.mk ι) = cardinal.lift.{v w} (module.rank K V) := by rw [←h.mk_range_eq_dim, cardinal.mk_range_eq_of_injective h.injective] theorem {m} is_basis.mk_eq_dim' {v : ι → V} (h : is_basis K v) : cardinal.lift.{w (max v m)} (cardinal.mk ι) = cardinal.lift.{v (max w m)} (module.rank K V) := by simpa using h.mk_eq_dim theorem dim_le {n : ℕ} (H : ∀ s : finset V, linear_independent K (λ i : (↑s : set V), (i : V)) → s.card ≤ n) : module.rank K V ≤ n := let ⟨b, hb⟩ := exists_is_basis K V in hb.mk_eq_dim'' ▸ cardinal.card_le_of (λ s, @finset.card_map _ _ ⟨_, subtype.val_injective⟩ s ▸ H _ (by { refine hb.1.mono (λ y h, _), rw [finset.mem_coe, finset.mem_map] at h, rcases h with ⟨x, hx, rfl⟩, exact x.2 } )) variables [add_comm_group V'] [module K V'] /-- Two linearly equivalent vector spaces have the same dimension, a version with different universes. -/ theorem linear_equiv.lift_dim_eq (f : V ≃ₗ[K] V') : cardinal.lift.{v v'} (module.rank K V) = cardinal.lift.{v' v} (module.rank K V') := let ⟨b, hb⟩ := exists_is_basis K V in calc cardinal.lift.{v v'} (module.rank K V) = cardinal.lift.{v v'} (cardinal.mk b) : congr_arg _ hb.mk_eq_dim''.symm ... = cardinal.lift.{v' v} (module.rank K V') : (f.is_basis hb).mk_eq_dim /-- Two linearly equivalent vector spaces have the same dimension. -/ theorem linear_equiv.dim_eq (f : V ≃ₗ[K] V₁) : module.rank K V = module.rank K V₁ := cardinal.lift_inj.1 f.lift_dim_eq /-- Two vector spaces are isomorphic if they have the same dimension. -/ theorem nonempty_linear_equiv_of_lift_dim_eq (cond : cardinal.lift.{v v'} (module.rank K V) = cardinal.lift.{v' v} (module.rank K V')) : nonempty (V ≃ₗ[K] V') := begin obtain ⟨B, h⟩ := exists_is_basis K V, obtain ⟨B', h'⟩ := exists_is_basis K V', have : cardinal.lift.{v v'} (cardinal.mk B) = cardinal.lift.{v' v} (cardinal.mk B'), by rw [h.mk_eq_dim'', cond, h'.mk_eq_dim''], exact (cardinal.lift_mk_eq.{v v' 0}.1 this).map (linear_equiv_of_is_basis h h') end /-- Two vector spaces are isomorphic if they have the same dimension. -/ theorem nonempty_linear_equiv_of_dim_eq (cond : module.rank K V = module.rank K V₁) : nonempty (V ≃ₗ[K] V₁) := nonempty_linear_equiv_of_lift_dim_eq $ congr_arg _ cond section variables (V V' V₁) /-- Two vector spaces are isomorphic if they have the same dimension. -/ def linear_equiv.of_lift_dim_eq (cond : cardinal.lift.{v v'} (module.rank K V) = cardinal.lift.{v' v} (module.rank K V')) : V ≃ₗ[K] V' := classical.choice (nonempty_linear_equiv_of_lift_dim_eq cond) /-- Two vector spaces are isomorphic if they have the same dimension. -/ def linear_equiv.of_dim_eq (cond : module.rank K V = module.rank K V₁) : V ≃ₗ[K] V₁ := classical.choice (nonempty_linear_equiv_of_dim_eq cond) end /-- Two vector spaces are isomorphic if and only if they have the same dimension. -/ theorem linear_equiv.nonempty_equiv_iff_lift_dim_eq : nonempty (V ≃ₗ[K] V') ↔ cardinal.lift.{v v'} (module.rank K V) = cardinal.lift.{v' v} (module.rank K V') := ⟨λ ⟨h⟩, linear_equiv.lift_dim_eq h, λ h, nonempty_linear_equiv_of_lift_dim_eq h⟩ /-- Two vector spaces are isomorphic if and only if they have the same dimension. -/ theorem linear_equiv.nonempty_equiv_iff_dim_eq : nonempty (V ≃ₗ[K] V₁) ↔ module.rank K V = module.rank K V₁ := ⟨λ ⟨h⟩, linear_equiv.dim_eq h, λ h, nonempty_linear_equiv_of_dim_eq h⟩ @[simp] lemma dim_bot : module.rank K (⊥ : submodule K V) = 0 := by letI := classical.dec_eq V; rw [← cardinal.lift_inj, ← (is_basis_empty (⊥ : submodule K V) not_nonempty_pempty).mk_eq_dim, cardinal.mk_pempty] @[simp] lemma dim_top : module.rank K (⊤ : submodule K V) = module.rank K V := linear_equiv.dim_eq (linear_equiv.of_top _ rfl) lemma dim_of_field (K : Type*) [field K] : module.rank K K = 1 := by rw [←cardinal.lift_inj, ← (@is_basis_singleton_one punit K _ _).mk_eq_dim, cardinal.mk_punit] lemma dim_span {v : ι → V} (hv : linear_independent K v) : module.rank K ↥(span K (range v)) = cardinal.mk (range v) := by rw [←cardinal.lift_inj, ← (is_basis_span hv).mk_eq_dim, cardinal.mk_range_eq_of_injective (@linear_independent.injective ι K V v _ _ _ _ hv)] lemma dim_span_set {s : set V} (hs : linear_independent K (λ x, x : s → V)) : module.rank K ↥(span K s) = cardinal.mk s := by { rw [← @set_of_mem_eq _ s, ← subtype.range_coe_subtype], exact dim_span hs } lemma {m} cardinal_lift_le_dim_of_linear_independent {ι : Type w} {v : ι → V} (hv : linear_independent K v) : cardinal.lift.{w (max v m)} (cardinal.mk ι) ≤ cardinal.lift.{v (max w m)} (module.rank K V) := begin obtain ⟨ι', v', is⟩ := exists_sum_is_basis hv, rw [← cardinal.lift_umax, ← cardinal.lift_umax.{v}], simpa using le_trans (cardinal.lift_mk_le.{w _ (max v m)}.2 ⟨@function.embedding.inl ι ι'⟩) (le_of_eq $ is_basis.mk_eq_dim'.{_ _ _ (max w m)} is), end lemma cardinal_le_dim_of_linear_independent {ι : Type v} {v : ι → V} (hv : linear_independent K v) : cardinal.mk ι ≤ module.rank K V := by simpa using cardinal_lift_le_dim_of_linear_independent hv lemma cardinal_le_dim_of_linear_independent' {s : set V} (hs : linear_independent K (λ x, x : s → V)) : cardinal.mk s ≤ module.rank K V := cardinal_le_dim_of_linear_independent hs lemma dim_span_le (s : set V) : module.rank K (span K s) ≤ cardinal.mk s := begin classical, rcases exists_linear_independent (linear_independent_empty K V) (set.empty_subset s) with ⟨b, hb, _, hsb, hlib⟩, have hsab : span K s = span K b, from span_eq_of_le _ hsb (span_le.2 (λ x hx, subset_span (hb hx))), convert cardinal.mk_le_mk_of_subset hb, rw [hsab, dim_span_set hlib] end lemma dim_span_of_finset (s : finset V) : module.rank K (span K (↑s : set V)) < cardinal.omega := calc module.rank K (span K (↑s : set V)) ≤ cardinal.mk (↑s : set V) : dim_span_le ↑s ... = s.card : by rw ←cardinal.finset_card ... < cardinal.omega : cardinal.nat_lt_omega _ theorem dim_prod : module.rank K (V × V₁) = module.rank K V + module.rank K V₁ := begin rcases exists_is_basis K V with ⟨b, hb⟩, rcases exists_is_basis K V₁ with ⟨c, hc⟩, rw [← cardinal.lift_inj, ← @is_basis.mk_eq_dim K (V × V₁) _ _ _ _ _ (is_basis_inl_union_inr hb hc), cardinal.lift_add, cardinal.lift_mk, ← hb.mk_eq_dim, ← hc.mk_eq_dim, cardinal.lift_mk, cardinal.lift_mk, cardinal.add_def (ulift b) (ulift c)], exact cardinal.lift_inj.1 (cardinal.lift_mk_eq.2 ⟨equiv.ulift.trans (equiv.sum_congr (@equiv.ulift b) (@equiv.ulift c)).symm ⟩), end theorem dim_quotient_add_dim (p : submodule K V) : module.rank K p.quotient + module.rank K p = module.rank K V := by classical; exact let ⟨f⟩ := quotient_prod_linear_equiv p in dim_prod.symm.trans f.dim_eq theorem dim_quotient_le (p : submodule K V) : module.rank K p.quotient ≤ module.rank K V := by { rw ← dim_quotient_add_dim p, exact self_le_add_right _ _ } /-- rank-nullity theorem -/ theorem dim_range_add_dim_ker (f : V →ₗ[K] V₁) : module.rank K f.range + module.rank K f.ker = module.rank K V := begin haveI := λ (p : submodule K V), classical.dec_eq p.quotient, rw [← f.quot_ker_equiv_range.dim_eq, dim_quotient_add_dim] end lemma dim_range_le (f : V →ₗ[K] V₁) : module.rank K f.range ≤ module.rank K V := by { rw ← dim_range_add_dim_ker f, exact self_le_add_right _ _ } lemma dim_map_le (f : V →ₗ V₁) (p : submodule K V) : module.rank K (p.map f) ≤ module.rank K p := begin have h := dim_range_le (f.comp (submodule.subtype p)), rwa [linear_map.range_comp, range_subtype] at h, end lemma dim_range_of_surjective (f : V →ₗ[K] V') (h : surjective f) : module.rank K f.range = module.rank K V' := by rw [linear_map.range_eq_top.2 h, dim_top] lemma dim_eq_of_surjective (f : V →ₗ[K] V₁) (h : surjective f) : module.rank K V = module.rank K V₁ + module.rank K f.ker := by rw [← dim_range_add_dim_ker f, ← dim_range_of_surjective f h] lemma dim_le_of_surjective (f : V →ₗ[K] V₁) (h : surjective f) : module.rank K V₁ ≤ module.rank K V := by { rw [dim_eq_of_surjective f h], refine self_le_add_right _ _ } lemma dim_eq_of_injective (f : V →ₗ[K] V₁) (h : injective f) : module.rank K V = module.rank K f.range := by rw [← dim_range_add_dim_ker f, linear_map.ker_eq_bot.2 h]; simp [dim_bot] lemma dim_submodule_le (s : submodule K V) : module.rank K s ≤ module.rank K V := by { rw ← dim_quotient_add_dim s, exact self_le_add_left _ _ } lemma dim_le_of_injective (f : V →ₗ[K] V₁) (h : injective f) : module.rank K V ≤ module.rank K V₁ := by { rw [dim_eq_of_injective f h], exact dim_submodule_le _ } lemma dim_le_of_submodule (s t : submodule K V) (h : s ≤ t) : module.rank K s ≤ module.rank K t := dim_le_of_injective (of_le h) $ assume ⟨x, hx⟩ ⟨y, hy⟩ eq, subtype.eq $ show x = y, from subtype.ext_iff_val.1 eq lemma linear_independent_le_dim {v : ι → V} (hv : linear_independent K v) : cardinal.lift.{w v} (cardinal.mk ι) ≤ cardinal.lift.{v w} (module.rank K V) := calc cardinal.lift.{w v} (cardinal.mk ι) = cardinal.lift.{v w} (cardinal.mk (set.range v)) : (cardinal.mk_range_eq_of_injective (linear_independent.injective hv)).symm ... = cardinal.lift.{v w} (module.rank K (submodule.span K (set.range v))) : by rw (dim_span hv).symm ... ≤ cardinal.lift.{v w} (module.rank K V) : cardinal.lift_le.2 (dim_submodule_le (submodule.span K _)) theorem {u₁} linear_independent_le_dim' {v : ι → V} (hs : linear_independent K v) : ((cardinal.mk ι).lift : cardinal.{(max w v u₁)}) ≤ ((module.rank K V).lift : cardinal.{(max v w u₁)}) := cardinal.mk_range_eq_lift hs.injective ▸ dim_span hs ▸ cardinal.lift_le.2 (dim_submodule_le _) section variables [add_comm_group V₂] [module K V₂] variables [add_comm_group V₃] [module K V₃] open linear_map /-- This is mostly an auxiliary lemma for `dim_sup_add_dim_inf_eq`. -/ lemma dim_add_dim_split (db : V₂ →ₗ[K] V) (eb : V₃ →ₗ[K] V) (cd : V₁ →ₗ[K] V₂) (ce : V₁ →ₗ[K] V₃) (hde : ⊤ ≤ db.range ⊔ eb.range) (hgd : ker cd = ⊥) (eq : db.comp cd = eb.comp ce) (eq₂ : ∀d e, db d = eb e → (∃c, cd c = d ∧ ce c = e)) : module.rank K V + module.rank K V₁ = module.rank K V₂ + module.rank K V₃ := have hf : surjective (coprod db eb), begin refine (range_eq_top.1 $ top_unique $ _), rwa [← map_top, ← prod_top, map_coprod_prod, ←range_eq_map, ←range_eq_map] end, begin conv {to_rhs, rw [← dim_prod, dim_eq_of_surjective _ hf] }, congr' 1, apply linear_equiv.dim_eq, refine linear_equiv.of_bijective _ _ _, { refine cod_restrict _ (prod cd (- ce)) _, { assume c, simp only [add_eq_zero_iff_eq_neg, prod_apply, mem_ker, coprod_apply, neg_neg, map_neg, neg_apply], exact linear_map.ext_iff.1 eq c } }, { rw [ker_cod_restrict, ker_prod, hgd, bot_inf_eq] }, { rw [eq_top_iff, range_cod_restrict, ← map_le_iff_le_comap, map_top, range_subtype], rintros ⟨d, e⟩, have h := eq₂ d (-e), simp only [add_eq_zero_iff_eq_neg, prod_apply, mem_ker, set_like.mem_coe, prod.mk.inj_iff, coprod_apply, map_neg, neg_apply, linear_map.mem_range] at ⊢ h, assume hde, rcases h hde with ⟨c, h₁, h₂⟩, refine ⟨c, h₁, _⟩, rw [h₂, _root_.neg_neg] } end lemma dim_sup_add_dim_inf_eq (s t : submodule K V) : module.rank K (s ⊔ t : submodule K V) + module.rank K (s ⊓ t : submodule K V) = module.rank K s + module.rank K t := dim_add_dim_split (of_le le_sup_left) (of_le le_sup_right) (of_le inf_le_left) (of_le inf_le_right) begin rw [← map_le_map_iff' (ker_subtype $ s ⊔ t), map_sup, map_top, ← linear_map.range_comp, ← linear_map.range_comp, subtype_comp_of_le, subtype_comp_of_le, range_subtype, range_subtype, range_subtype], exact le_refl _ end (ker_of_le _ _ _) begin ext ⟨x, hx⟩, refl end begin rintros ⟨b₁, hb₁⟩ ⟨b₂, hb₂⟩ eq, have : b₁ = b₂ := congr_arg subtype.val eq, subst this, exact ⟨⟨b₁, hb₁, hb₂⟩, rfl, rfl⟩ end lemma dim_add_le_dim_add_dim (s t : submodule K V) : module.rank K (s ⊔ t : submodule K V) ≤ module.rank K s + module.rank K t := by { rw [← dim_sup_add_dim_inf_eq], exact self_le_add_right _ _ } end section fintype variable [fintype η] variables [∀i, add_comm_group (φ i)] [∀i, module K (φ i)] open linear_map lemma dim_pi : module.rank K (Πi, φ i) = cardinal.sum (λi, module.rank K (φ i)) := begin choose b hb using assume i, exists_is_basis K (φ i), have : is_basis K (λ (ji : Σ j, b j), std_basis K (λ j, φ j) ji.fst ji.snd.val), by apply pi.is_basis_std_basis _ hb, rw [←cardinal.lift_inj, ← this.mk_eq_dim], simp [λ i, (hb i).mk_range_eq_dim.symm, cardinal.sum_mk] end lemma dim_fun {V η : Type u} [fintype η] [add_comm_group V] [module K V] : module.rank K (η → V) = fintype.card η * module.rank K V := by rw [dim_pi, cardinal.sum_const, cardinal.fintype_card] lemma dim_fun_eq_lift_mul : module.rank K (η → V) = (fintype.card η : cardinal.{max u₁' v}) * cardinal.lift.{v u₁'} (module.rank K V) := by rw [dim_pi, cardinal.sum_const_eq_lift_mul, cardinal.fintype_card, cardinal.lift_nat_cast] lemma dim_fun' : module.rank K (η → K) = fintype.card η := by rw [dim_fun_eq_lift_mul, dim_of_field K, cardinal.lift_one, mul_one, cardinal.nat_cast_inj] lemma dim_fin_fun (n : ℕ) : module.rank K (fin n → K) = n := by simp [dim_fun'] end fintype lemma exists_mem_ne_zero_of_ne_bot {s : submodule K V} (h : s ≠ ⊥) : ∃ b : V, b ∈ s ∧ b ≠ 0 := begin classical, by_contradiction hex, have : ∀x∈s, (x:V) = 0, { simpa only [not_exists, not_and, not_not, ne.def] using hex }, exact (h $ bot_unique $ assume s hs, (submodule.mem_bot K).2 $ this s hs) end lemma exists_mem_ne_zero_of_dim_pos {s : submodule K V} (h : 0 < module.rank K s) : ∃ b : V, b ∈ s ∧ b ≠ 0 := exists_mem_ne_zero_of_ne_bot $ assume eq, by rw [eq, dim_bot] at h; exact lt_irrefl _ h lemma exists_is_basis_fintype (h : module.rank K V < cardinal.omega) : ∃ s : (set V), (is_basis K (subtype.val : s → V)) ∧ nonempty (fintype s) := begin cases exists_is_basis K V with s hs, rw [←cardinal.lift_lt, ← is_basis.mk_eq_dim hs, cardinal.lift_lt, cardinal.lt_omega_iff_fintype] at h, exact ⟨s, hs, h⟩ end section rank /-- `rank f` is the rank of a `linear_map f`, defined as the dimension of `f.range`. -/ def rank (f : V →ₗ[K] V') : cardinal := module.rank K f.range lemma rank_le_domain (f : V →ₗ[K] V₁) : rank f ≤ module.rank K V := by { rw [← dim_range_add_dim_ker f], exact self_le_add_right _ _ } lemma rank_le_range (f : V →ₗ[K] V₁) : rank f ≤ module.rank K V₁ := dim_submodule_le _ lemma rank_add_le (f g : V →ₗ[K] V') : rank (f + g) ≤ rank f + rank g := calc rank (f + g) ≤ module.rank K (f.range ⊔ g.range : submodule K V') : begin refine dim_le_of_submodule _ _ _, exact (linear_map.range_le_iff_comap.2 $ eq_top_iff'.2 $ assume x, show f x + g x ∈ (f.range ⊔ g.range : submodule K V'), from mem_sup.2 ⟨_, ⟨x, rfl⟩, _, ⟨x, rfl⟩, rfl⟩) end ... ≤ rank f + rank g : dim_add_le_dim_add_dim _ _ @[simp] lemma rank_zero : rank (0 : V →ₗ[K] V') = 0 := by rw [rank, linear_map.range_zero, dim_bot] lemma rank_finset_sum_le {η} (s : finset η) (f : η → V →ₗ[K] V') : rank (∑ d in s, f d) ≤ ∑ d in s, rank (f d) := @finset.sum_hom_rel _ _ _ _ _ (λa b, rank a ≤ b) f (λ d, rank (f d)) s (le_of_eq rank_zero) (λ i g c h, le_trans (rank_add_le _ _) (add_le_add_left h _)) variables [add_comm_group V''] [module K V''] lemma rank_comp_le1 (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : rank (f.comp g) ≤ rank f := begin refine dim_le_of_submodule _ _ _, rw [linear_map.range_comp], exact linear_map.map_le_range, end variables [add_comm_group V'₁] [module K V'₁] lemma rank_comp_le2 (g : V →ₗ[K] V') (f : V' →ₗ V'₁) : rank (f.comp g) ≤ rank g := by rw [rank, rank, linear_map.range_comp]; exact dim_map_le _ _ end rank lemma dim_zero_iff_forall_zero : module.rank K V = 0 ↔ ∀ x : V, x = 0 := begin split, { intros h x, cases exists_is_basis K V with w hw, have card_mk_range := hw.mk_range_eq_dim, rw [h, cardinal.mk_emptyc_iff, subtype.range_coe] at card_mk_range, simpa [card_mk_range] using hw.mem_span x }, { intro h, have : (⊤ : submodule K V) = ⊥, { ext x, simp [h x] }, rw [←dim_top, this, dim_bot] } end lemma dim_zero_iff : module.rank K V = 0 ↔ subsingleton V := dim_zero_iff_forall_zero.trans (subsingleton_iff_forall_eq 0).symm lemma is_basis_of_dim_eq_zero {ι : Type*} (h : ¬ nonempty ι) (hV : module.rank K V = 0) : is_basis K (λ x : ι, (0 : V)) := begin haveI : subsingleton V := dim_zero_iff.1 hV, exact is_basis_empty _ h end lemma is_basis_of_dim_eq_zero' (hV : module.rank K V = 0) : is_basis K (λ x : fin 0, (0 : V)) := is_basis_of_dim_eq_zero (finset.univ_eq_empty.mp rfl) hV lemma dim_pos_iff_exists_ne_zero : 0 < module.rank K V ↔ ∃ x : V, x ≠ 0 := begin rw ←not_iff_not, simpa using dim_zero_iff_forall_zero end lemma dim_pos_iff_nontrivial : 0 < module.rank K V ↔ nontrivial V := dim_pos_iff_exists_ne_zero.trans (nontrivial_iff_exists_ne 0).symm lemma dim_pos [h : nontrivial V] : 0 < module.rank K V := dim_pos_iff_nontrivial.2 h lemma le_dim_iff_exists_linear_independent {c : cardinal} : c ≤ module.rank K V ↔ ∃ s : set V, cardinal.mk s = c ∧ linear_independent K (coe : s → V) := begin split, { intro h, rcases exists_is_basis K V with ⟨t, ht⟩, rw [← ht.mk_eq_dim'', cardinal.le_mk_iff_exists_subset] at h, rcases h with ⟨s, hst, hsc⟩, exact ⟨s, hsc, ht.1.mono hst⟩ }, { rintro ⟨s, rfl, si⟩, exact cardinal_le_dim_of_linear_independent si } end lemma le_dim_iff_exists_linear_independent_finset {n : ℕ} : ↑n ≤ module.rank K V ↔ ∃ s : finset V, s.card = n ∧ linear_independent K (coe : (s : set V) → V) := begin simp only [le_dim_iff_exists_linear_independent, cardinal.mk_eq_nat_iff_finset], split, { rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩, exact ⟨t, rfl, si⟩ }, { rintro ⟨s, rfl, si⟩, exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ } end lemma le_rank_iff_exists_linear_independent {c : cardinal} {f : V →ₗ[K] V'} : c ≤ rank f ↔ ∃ s : set V, cardinal.lift.{v v'} (cardinal.mk s) = cardinal.lift.{v' v} c ∧ linear_independent K (λ x : s, f x) := begin rcases f.range_restrict.exists_right_inverse_of_surjective f.range_range_restrict with ⟨g, hg⟩, have fg : left_inverse f.range_restrict g, from linear_map.congr_fun hg, refine ⟨λ h, _, _⟩, { rcases le_dim_iff_exists_linear_independent.1 h with ⟨s, rfl, si⟩, refine ⟨g '' s, cardinal.mk_image_eq_lift _ _ fg.injective, _⟩, replace fg : ∀ x, f (g x) = x, by { intro x, convert congr_arg subtype.val (fg x) }, replace si : linear_independent K (λ x : s, f (g x)), by simpa only [fg] using si.map' _ (ker_subtype _), exact si.image_of_comp s g f }, { rintro ⟨s, hsc, si⟩, have : linear_independent K (λ x : s, f.range_restrict x), from linear_independent.of_comp (f.range.subtype) (by convert si), convert cardinal_le_dim_of_linear_independent this.image, rw [← cardinal.lift_inj, ← hsc, cardinal.mk_image_eq_of_inj_on_lift], exact inj_on_iff_injective.2 this.injective } end lemma le_rank_iff_exists_linear_independent_finset {n : ℕ} {f : V →ₗ[K] V'} : ↑n ≤ rank f ↔ ∃ s : finset V, s.card = n ∧ linear_independent K (λ x : (s : set V), f x) := begin simp only [le_rank_iff_exists_linear_independent, cardinal.lift_nat_cast, cardinal.lift_eq_nat_iff, cardinal.mk_eq_nat_iff_finset], split, { rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩, exact ⟨t, rfl, si⟩ }, { rintro ⟨s, rfl, si⟩, exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ } end /-- A vector space has dimension at most `1` if and only if there is a single vector of which all vectors are multiples. -/ lemma dim_le_one_iff : module.rank K V ≤ 1 ↔ ∃ v₀ : V, ∀ v, ∃ r : K, r • v₀ = v := begin obtain ⟨b, h⟩ := exists_is_basis K V, split, { intro hd, rw [←is_basis.mk_eq_dim'' h, cardinal.le_one_iff_subsingleton, subsingleton_coe] at hd, rcases eq_empty_or_nonempty b with rfl | ⟨⟨v₀, hv₀⟩⟩, { use 0, have h' : ∀ v : V, v = 0, { simpa [submodule.eq_bot_iff] using h.2.symm }, intro v, simp [h' v] }, { use v₀, have h' : (K ∙ v₀) = ⊤, { simpa [hd.eq_singleton_of_mem hv₀] using h.2 }, intro v, have hv : v ∈ (⊤ : submodule K V) := mem_top, rwa [←h', mem_span_singleton] at hv } }, { rintros ⟨v₀, hv₀⟩, have h : (K ∙ v₀) = ⊤, { ext, simp [mem_span_singleton, hv₀] }, rw [←dim_top, ←h], convert dim_span_le _, simp } end /-- A submodule has dimension at most `1` if and only if there is a single vector in the submodule such that the submodule is contained in its span. -/ lemma dim_submodule_le_one_iff (s : submodule K V) : module.rank K s ≤ 1 ↔ ∃ v₀ ∈ s, s ≤ K ∙ v₀ := begin simp_rw [dim_le_one_iff, le_span_singleton_iff], split, { rintro ⟨⟨v₀, hv₀⟩, h⟩, use [v₀, hv₀], intros v hv, obtain ⟨r, hr⟩ := h ⟨v, hv⟩, use r, simp_rw [subtype.ext_iff, coe_smul, coe_mk] at hr, exact hr }, { rintro ⟨v₀, hv₀, h⟩, use ⟨v₀, hv₀⟩, rintro ⟨v, hv⟩, obtain ⟨r, hr⟩ := h v hv, use r, simp_rw [subtype.ext_iff, coe_smul, coe_mk], exact hr } end /-- A submodule has dimension at most `1` if and only if there is a single vector, not necessarily in the submodule, such that the submodule is contained in its span. -/ lemma dim_submodule_le_one_iff' (s : submodule K V) : module.rank K s ≤ 1 ↔ ∃ v₀, s ≤ K ∙ v₀ := begin rw dim_submodule_le_one_iff, split, { rintros ⟨v₀, hv₀, h⟩, exact ⟨v₀, h⟩ }, { rintros ⟨v₀, h⟩, by_cases hw : ∃ w : V, w ∈ s ∧ w ≠ 0, { rcases hw with ⟨w, hw, hw0⟩, use [w, hw], rcases mem_span_singleton.1 (h hw) with ⟨r', rfl⟩, have h0 : r' ≠ 0, { rintro rfl, simpa using hw0 }, rwa span_singleton_smul_eq _ h0 }, { push_neg at hw, rw ←submodule.eq_bot_iff at hw, simp [hw] } } end end module section unconstrained_universes variables {E : Type v'} variables [field K] [add_comm_group V] [module K V] [add_comm_group E] [module K E] open module /-- Version of linear_equiv.dim_eq without universe constraints. -/ theorem linear_equiv.dim_eq_lift (f : V ≃ₗ[K] E) : cardinal.lift.{v v'} (module.rank K V) = cardinal.lift.{v' v} (module.rank K E) := begin cases exists_is_basis K V with b hb, rw [← cardinal.lift_inj.1 hb.mk_eq_dim, ← (f.is_basis hb).mk_eq_dim, cardinal.lift_mk], end end unconstrained_universes
module wee_mpi implicit none interface integer function wee_flags(silent) bind(C) integer, value:: silent end function integer function wee_anim(string) bind(C) use iso_c_binding, only: c_char character(kind=c_char) :: string(*) end function end interface contains integer function f_wee_anim(string) use iso_c_binding, only: C_CHAR, C_NULL_CHAR character(len=*, kind=c_char), intent(in) :: string f_wee_anim = wee_anim(string//C_NULL_CHAR) end function end module
lemma frontier_UNIV [simp]: "frontier UNIV = {}"
import data.nat.prime import tactic.field_simp import tactic.linarith open nat theorem sqrt_2_irr : ∀ q : ℚ, q^2 ≠ 2 := begin intros q q_sqrd_eq_2, have h₁ : q.num.nat_abs^2 = 2 * q.denom^2 := begin rw rat.eq_iff_mul_eq_mul at q_sqrd_eq_2, norm_cast at q_sqrd_eq_2, rw [mul_one, cast_mul, int.coe_nat_bit0, cast_one] at q_sqrd_eq_2, rw ← int.coe_nat_eq_coe_nat_iff, field_simp, simp only [sq] at *, rw [rat.mul_self_num, rat.mul_self_denom] at q_sqrd_eq_2, exact q_sqrd_eq_2, end, have h₂ : 2 ∣ q.num.nat_abs := begin have h := dvd_mul_right 2 (q.denom ^ 2), rw ←h₁ at h, cases (prime.dvd_mul prime_two).1 h with h_1, exact h_1, rw [nat.add, npow_rec, npow_rec, mul_one] at h_1, exact h_1, end, have h₃ : 2 ∣ q.denom := begin have h : 2*2 ∣ q.num.nat_abs ^ 2 := pow_dvd_pow_of_dvd h₂ _, rw h₁ at h, have h' : 2 ∣ q.denom ^ 2 := dvd_of_mul_dvd_mul_left succ_pos' h, cases (prime.dvd_mul prime_two).1 h', exact h_1, rw [nat.add, npow_rec, npow_rec, mul_one] at h_1, exact h_1, end, have h₄ : gcd q.num.nat_abs q.denom ≥ 2 := begin apply exists.elim h₂, intros c_num q_num_eq_2_c_num, apply exists.elim h₃, intros c_denom q_denom_eq_c_denom, have c_denom_ge_1 : c_denom ≥ 1 := by linarith [q.pos], rw [q_num_eq_2_c_num, q_denom_eq_c_denom, gcd_mul_left], linarith [nat.gcd_pos_of_pos_right c_num c_denom_ge_1], end, have h₅ : gcd q.num.nat_abs q.denom = 1 := q.cop, linarith, end theorem sqrt_not_ps_irr : ∀ n : ℕ, ¬ (∃ m : ℕ, n = m^2) → ∀ q : ℚ, q^2 ≠ n := begin intros n n_not_perfect_square q q_sqrd_eq_n, have h₁ : q.num.nat_abs^2 = n * q.denom^2 := begin rw rat.eq_iff_mul_eq_mul at q_sqrd_eq_n, norm_cast at q_sqrd_eq_n, rw [mul_one, cast_mul] at q_sqrd_eq_n, rw ← int.coe_nat_eq_coe_nat_iff, field_simp, simp only [sq] at *, rw [rat.mul_self_num, rat.mul_self_denom] at q_sqrd_eq_n, exact q_sqrd_eq_n, end, by_cases q.denom = 1, { rw [h, one_pow, mul_one] at h₁, apply n_not_perfect_square, use q.num.nat_abs, exact eq.symm h₁, }, { have h₂ : q.denom ∣ q.num.nat_abs := begin repeat {rw sq at h₁}, apply nat.coprime.dvd_of_dvd_mul_left q.cop.symm, use (n * q.denom), rw h₁, ring, end, have q_cop := q.cop, unfold coprime at q_cop, rw nat.gcd_eq_right_iff_dvd.1 h₂ at q_cop, exact h q_cop, }, end
Module SpecificSPL. Require Export maps_int formulatheory_int featuremodelsemantics_int assettheory_int assetmapping_int featuremodelrefinement_int. Require Export maps_def formulatheory_def featuremodelsemantics_def featuremodelrefinement_def assettheory_def assetmapping_def ckcomp_int ckcomp_def. Import FormulaTheory FeatureModelSemantics AssetTheory AssetMapping CKComp Maps FeatureModelRefinimentTheory. Require Export formulatheory_inst featuremodelsemantics_inst assettheory_inst maps_inst assetmapping_inst featuremodelrefinement_inst cktrans_inst ckcomp_inst. Require Import Coq.Lists.ListSet. Variable fm fm1 fm2: FM. Variable am am1 am2 pairs: AM. Variable ck ck1 ck2: CK. Variable item item1 item2: Item. Variable items items1 items2: set Item. Variable c c1 c2: Configuration. Variable expr: Formula. Variable Fe G H opt: Name. Variable a a1 a2 a3: Asset. Variable an an1 an2: AssetName. Axiom item_dec : forall x y:Item, {x = y} + {x <> y}. Axiom pair_dec : forall x y:pair_, {x = y} + {x <> y}. Axiom ns_dec : forall x y:Name, {x = y} + {x <> y}. Axiom an_dec : forall x y:AssetName, {x = y} + {x <> y}. Axiom as_dec : forall x y:AssetName, {x = y} + {x <> y}. Require Export spl_int spl_def spl_proofs spl_inst. Import SPL. (*========= IF WE ADD NEW ASSETS TO AM THAT DID NOT EXIST BEFORE, CK EVALUATION IS THE SAME =============*) Lemma mapSubsetAM {Mp: Maps AssetName Asset AM}: forall (fm: FM) (am1 am2: list pair_) ck, forall an, set_In an (dom_func am2) -> ~(set_In an (dom_func am1)) /\ wfCK_func fm am1 ck -> forall (c: Configuration), set_In c (semantics fm) -> (semantics_func_ ck am1 c = semantics_func_ ck (set_union pair_dec am1 am2) c). Proof. unfold wfCK_func. induction am4. + induction am3. - simpl. intuition. - simpl. intuition. + intuition. specialize (IHam4 ck0 an0). apply set_add_elim in H0. inversion H0. Admitted. (*============= REPLACE FEATURE EXPRESSION ==================*) Definition syntaxReplaceFeatureExp ck1 ck2 item1 item2 items: Prop:= (ck1 = app (items :: nil) (item1 :: nil) ) /\ (ck2 = app (items :: nil) (item2 :: nil)) /\ item1.(assets) = item2.(assets). Definition conditionsReplaceFeatureExp (fm:FM) item1 item2: Prop := wt fm (item2.(exp)) /\ forall c, set_In c (semantics fm) -> iff (satisfies (item1.(exp)) c) (satisfies (item2.(exp)) c). Theorem replaceFeatureExp_EqualCKeval {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall (pl: PL) ck2 item1 item2 items, ( ( wfCK_func (getFM pl) (getAM pl) (getCK pl) /\ syntaxReplaceFeatureExp (getCK pl) ck2 item1 item2 items /\ conditionsReplaceFeatureExp (getFM pl) item1 item2 ) -> forall (c: Configuration), set_In c (semantics (getFM pl)) -> semantics_ (getCK pl)(getAM pl) c = semantics_ ck2 (getAM pl) c ). Proof. intros. destruct H0. destruct H2. unfold syntaxReplaceFeatureExp in H2. destruct H2. destruct H4. rewrite H4. rewrite H2. simpl. induction item4. induction item3. simpl in H5. rewrite H5. intuition. Qed. Theorem replaceFeatureExpression {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall (pl: PL) ck2 item1 item2 items, ( ( wfCK_func (getFM pl) (getAM pl) (getCK pl) /\ syntaxReplaceFeatureExp (getCK pl) ck2 item1 item2 items /\ conditionsReplaceFeatureExp (getFM pl) item1 item2 ) -> plRefinement_func pl (gerPL fm2 (getAM pl) ck2) /\ wfCK_func (getFM pl) (getAM pl) ck2 /\ wfPL (gerPL fm2 (getAM pl) ck2) ). Proof. intros. Search plRefinement. intros. split. unfold plRefinement_func. intros. exists c3. split. + destruct gerPL. unfold getFM_func. simpl. unfold getFM_func in H1. destruct pl in H1. simpl in H1. destruct pls1. simpl. destruct p. simpl in H1. destruct pls0. simpl. destruct p. simpl. destruct f, f0. apply H1. + admit. + unfold syntaxReplaceFeatureExp, conditionsReplaceFeatureExp in H0. simpl in H0. destruct H0. destruct H1. destruct H2. destruct H1. induction item3, item4. simpl in H1, H4, H2, H3. destruct H4. rewrite H1 in H0. rewrite H4. symmetry in H5. rewrite H5. induction exp0. - induction exp1. * intuition. * simpl. simpl in H2, H3. intuition. unfold wfCK_func. split. unfold wfCK_func in H0. destruct H0. - apply H0. - intuition. unfold wfCK_func in H0. destruct H0. destruct H7. specialize (H7 c0). intuition. * unfold wfCK_func in H0. unfold wfCK_func in H0. destruct H0. destruct H7. specialize (H7 c). specialize (H8 exp2). intuition. apply H8. induction exp0. - *) Admitted. (*================== ADD MANDATORY FEATURE ======================*) (* FOR ALL PRODUCTS OF A FM, EVALUATING THE CK WITH A DEAD FEATURE IS EQUIVALENT TO EVALUATING THE CK WITHOUT IT*) Theorem evalCKdeadFeature {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL} {FormT: FormulaTheory Formula Name FM} {FMS: FeatureModelSemantics Formula FM Name} {FMR: FeatureModelRefinement Formula Name FM}: forall pl (opt: Name), ~(set_In opt (nsf_func ((fst(fst pl))))) /\ wfCK (fst(fst pl)) (snd(fst pl)) (snd pl) -> forall c, set_In c (semantics_func (fst(fst pl))) -> semantics_func_ (snd pl) (snd(fst pl)) c = semantics_func_ (snd pl) (snd(fst pl)) (app (opt:: nil) c). Proof. simpl. intuition. simpl. simpl in H1, H2, H0. unfold nsf_func in H1. destruct a4. simpl in H1, H2, H0. destruct f. intuition. destruct opt0, n. simpl in H1. intuition. Qed. Definition syntaxConditionsAddMandatoryFeature (fm1 fm2: FM) (F G: Name) {FormT: FormulaTheory Formula Name FM} {FMS: FeatureModelSemantics Formula FM Name } {FMR: FeatureModelRefinement Formula Name FM}: Prop := addMandatoryNode_func fm1 fm2 F G. (*ADDING A MANDATORY FEATURE G WITHOUT CHANGING CK AND AM IS PL REFINEMENT*) Theorem addMandatoryFeat {Mp: Maps AssetName Asset AM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL} {FormT: FormulaTheory Formula Name FM} {FMS: FeatureModelSemantics Formula FM Name } {FMR: FeatureModelRefinement Formula Name FM}: forall (pl: PL) (F G: Name) (fm2: FM), ( syntaxConditionsAddMandatoryFeature (getFM pl) fm2 F G /\ wfCK (getFM pl) (getAM pl) (getCK pl) -> plRefinement_func pl (gerPL fm2 (getAM pl) (getCK pl)) /\ wfCK fm2 (getAM pl) (getCK pl) /\ wfPL (gerPL fm2 (getAM pl) (getCK pl)) ). Proof. intuition. simpl. unfold syntaxConditionsAddMandatoryFeature in H1. unfold addMandatoryNode_func in H1. destruct F, G0. intuition. unfold syntaxConditionsAddMandatoryFeature in H1. unfold addMandatoryNode_func in H1. destruct F, G0. intuition. unfold syntaxConditionsAddMandatoryFeature in H1. unfold addMandatoryNode_func in H1. destruct F, G0. intuition. Qed. (* ============= SPLIT ASSETS ====================*) (* SPLIT ASSETS conditions *) Definition syntaxSplitAssets am1 am2 (ck1 ck2:CK) (item1 item2: Item) items (an1 an2: AssetName) (a1 a2 a3: Asset) pairs: Prop := am1 = set_add pair_dec (an1, a1) pairs /\ am2 = set_add pair_dec (an1, a2) (set_add pair_dec (an2, a3) pairs) /\ ck1 = app (item1::nil) items /\ ck2 = app (item2::nil) items /\ item1.(exp) = item2.(exp) /\ item1.(assets) = set_add an_dec an1 nil /\ item2.(assets) = set_add an_dec an1 (an2::nil). Definition conditionsSplitAssets a1 a2 a3 an1 an2 items: Prop := assetRef_func (a1::nil) (app (a2::nil) (a3::nil)) /\ forall (item: Item), set_In item items -> ~(set_In an1 (item.(assets))) /\ (~ set_In an2 (item.(assets))). Lemma same_add: forall (p:pair) pairs, set_add pair_dec p pairs = set_add pair_dec p (set_add pair_dec p pairs). Proof. intros. induction p. unfold set_add. induction pairs0. - case_eq (pair_dec (a0,b) (a0,b)). + intros. reflexivity. + intros. intuition. - intuition. case_eq (pair_dec (a0, b) a4). + intros. rewrite e. case_eq (pair_dec (a0,b) a4). * intros. case_eq (pair_dec a4 a4). { intuition. } { intuition. } * intuition. + intuition. Admitted. Theorem splitNotEvalItem {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl am2 ck2 item1 item2 a1 a2 a3 an1 an2 items pairs, ( ( wfCK_func (fst(fst pl)) (snd(fst pl)) (snd pl) /\ syntaxSplitAssets (snd(fst pl)) am2 (snd pl) ck2 item1 item2 items an1 an2 a1 a2 a3 pairs /\ conditionsSplitAssets a1 a2 a3 an1 an2 items ) -> forall c, set_In c (semantics_func (fst(fst pl))) /\ ~(satisfies_func (item1.(exp)) c) -> semantics_func_ (snd pl) (snd(fst pl)) c = semantics_func_ ck2 am2 c). Proof. destruct pl. destruct p. simpl. destruct f. intros am ck item1 item2 a1 a2 a3 an1 an2 items pairs. unfold syntaxSplitAssets. unfold conditionsSplitAssets. simpl. intuition. specialize (H5 item1). rewrite H8 in H5. induction item1, item2. simpl in H1, H2, H0, H5, H3, H4, H6, H7, H8, H10, H11, H12. simpl. intuition. rewrite H4, H2, H6, H3. rewrite H7, H8, H10. rewrite H7, H8 in H5. intuition. case_eq (an_dec an1 an2). + intros. rewrite same_add. destruct an1, a1, a2, an2, a3. reflexivity. + intros. destruct n. destruct an1, an2. reflexivity. Qed. (*When splitting assets, if item1 is evaluated as true, ck evaluation is equal to the asset mapped by this item union evaluation of other items*) Theorem splitEvalItemUnion {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl am2 ck2 item1 item2 a1 a2 a3 an1 an2 items pairs, ( ( wfCK (fst(fst pl)) (snd(fst pl)) (snd pl) /\ syntaxSplitAssets (snd(fst pl)) am2 (snd pl) ck2 item1 item2 items an1 an2 a1 a2 a3 pairs /\ conditionsSplitAssets a1 a2 a3 an1 an2 items ) -> forall c, set_In c (semantics_func (fst(fst pl))) /\ ~(satisfies_func (item1.(exp)) c) -> semantics_func_ (snd pl) (snd (fst pl)) c = app (a1::nil) (semantics_func_ items (snd (fst pl)) c) /\ semantics_func_ ck2 am2 c = app (app (a2:: nil) (a3::nil)) (semantics_func_ items am2 c)). Proof. destruct pl. destruct p. simpl. intros am ck item1 item2 a1 a2 a3 an1 an2 items pairs. induction item1, item2. unfold syntaxSplitAssets. unfold conditionsSplitAssets. simpl. intuition. + rewrite H4. rewrite H8. rewrite H2. simpl. admit. + rewrite H6. rewrite H10. Admitted. Theorem splitEvalRemainingItems {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl am2 ck2 (item1 item2: Item) (a1 a2 a3: Asset) (an1 an2: AssetName) (items: list Item) (pairs: AM), ( ( wfCK (fst(fst pl)) (snd(fst pl)) (snd pl) /\ syntaxSplitAssets (snd(fst pl)) am2 (snd pl) ck2 item1 item2 items an1 an2 a1 a2 a3 pairs /\ conditionsSplitAssets a1 a2 a3 an1 an2 items ) -> forall c, set_In c (semantics (fst(fst pl))) -> (semantics_ items (snd(fst pl)) c) = (semantics_ items am2 c)). Proof. destruct pl. destruct p. simpl. destruct f. intros am ck item1 item2 a1 a2 a3 an1 an2 items pairs. unfold syntaxSplitAssets. unfold conditionsSplitAssets. simpl. intuition. specialize (H5 item1). rewrite H8 in H5. induction item1, item2. simpl in H1, H2, H0, H5, H3, H4, H6, H7, H8, H10. simpl. intuition. rewrite H2, H3. rewrite same_add. destruct an1, a1, a2, an2, a3. reflexivity. Qed. (* Split assets preserves CK well-formedness *) Theorem splitAssetWFCK {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl (am2:AM) (ck2: CK) (item1 item2: Item) (a1 a2 a3: Asset) (an1 an2: AssetName) items pairs, ( ( wfCK_func (fst(fst pl)) (snd(fst pl)) (snd pl) /\ syntaxSplitAssets (snd(fst pl)) am2 (snd pl) ck2 item1 item2 items an1 an2 a1 a2 a3 pairs /\ conditionsSplitAssets a1 a2 a3 an1 an2 items ) -> wfCK_func (fst(fst pl)) am2 ck2). Proof. destruct pl. destruct p. simpl. destruct f. intros am ck item1 item2 a1 a2 a3 an1 an2 items pairs. unfold syntaxSplitAssets. unfold conditionsSplitAssets. simpl. intuition. specialize (H5 item1). rewrite H8 in H5. induction item1, item2. simpl in H1, H2, H0, H5, H3, H4, H6, H7, H8, H10. simpl. intuition. rewrite H6, H3. rewrite H2, H4 in H1. rewrite H10. rewrite H8 in H1. intuition. case_eq (an_dec an1 an2). + intros. rewrite same_add in H1. destruct an1, a1, a2, an2, a3. rewrite H7 in H1. apply H1. + intros. destruct n. destruct an1, an2. reflexivity. Qed. Theorem splitAsset {Mp: Maps Asset AssetName AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall (pl:PL) (am2:AM) (ck2: CK) (item1 item2: Item) (a1 a2 a3: Asset) (an1 an2: AssetName) items pairs, ( ( wfCK_func (getFM pl) (getAM pl) (getCK pl) /\ syntaxSplitAssets (getAM pl) am2 (getCK pl) ck2 item1 item2 items an1 an2 a1 a2 a3 pairs /\ conditionsSplitAssets a1 a2 a3 an1 an2 items ) -> plRefinement_func pl (gerPL (getFM pl) am2 ck2) /\ wfCK_func (getFM pl) am2 ck2) /\ wfPL (gerPL (getFM pl) am2 ck2). Proof. intuition. + unfold plRefinement_func. intros. admit. + Admitted. (* ================= ADD OPTIONAL FEATURE ==================*) Definition syntaxAddOptionalFeature {FormT: FormulaTheory Formula Name FM} {FMS: FeatureModelSemantics Formula FM Name } {FMR: FeatureModelRefinement Formula Name FM} (fm1: FM) (am1: AM) (ck1: CK) (fm2: FM) (am2: AM) (ck2: CK) (F G: Name) items (pairs: AM) :Prop := fst fm2 = app (G::nil) (fst fm1) /\ set_In F (fst fm1) /\ (snd fm2) = set_add form_dec (IMPLIES_FORMULA (NAME_FORMULA(G)) (NAME_FORMULA(F))) (snd fm1) /\ am2 = app am1 (pairs) /\ ck2 = app ck1 items. Definition conditionsAddOptionalFeature (fm1 fm2: FM) (am1 am2 pairs: AM) (ck2: CK) (G: Name) (items: set Item) {Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL} : Prop := wfPL (gerPL fm2 am2 ck2) /\ wfCK_func fm2 am2 ck2 /\ forall an: AssetName, ~(set_In an (dom_func am1)) /\ (~ set_In G (fst fm1)) /\ forall c: Configuration, forall expr, set_In expr (exps items) /\ satisfies expr c -> satisfies (NAME_FORMULA(G)) c. Theorem addOptionalFeatureEqualProducts {Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL} {FormT: FormulaTheory Formula Name FM} {FMS: FeatureModelSemantics Formula FM Name } {FMR: FeatureModelRefinement Formula Name FM}: forall pl (fm2: FM) (am2: AM) (ck2: CK) (F G: Name) (items:set Item) (pairs: AM), wfCK_func (fst (fst pl)) (snd (fst pl)) (snd pl) /\ syntaxAddOptionalFeature (fst (fst pl)) (snd (fst pl)) (snd pl) fm2 am2 ck2 F G items pairs /\ conditionsAddOptionalFeature (fst (fst pl)) fm2 (snd (fst pl)) am2 pairs ck2 G items -> forall c, set_In c (semantics_func (fst (fst pl))) -> semantics_func_ (snd pl) (snd (fst pl)) c = semantics_func_ ck2 am2 c. Proof. unfold syntaxAddOptionalFeature. unfold conditionsAddOptionalFeature. simpl. intros pl fm am ck F G items pairs. destruct pl. destruct p. simpl. intuition. specialize (H7 an). rewrite H6, H9. destruct f. destruct fm. simpl in H5, H2, H0, H6, H3, H1, H4, H8, H7. destruct H7. destruct H10. destruct G, F. intuition. Qed. Theorem addOptionalFeature {Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL} {FormT: FormulaTheory Formula Name FM} {FMS: FeatureModelSemantics Formula FM Name } {FMR: FeatureModelRefinement Formula Name FM}: forall (pl: PL) (fm2: FM) (am2: AM) (ck2: CK) (F G: Name) (items:set Item) (pairs: AM), wfCK_func (getFM pl) (getAM pl) (getCK pl) /\ syntaxAddOptionalFeature (getFM pl) (getAM pl) (getCK pl) fm2 am2 ck2 F G items pairs /\ conditionsAddOptionalFeature (getFM pl) fm2 (getAM pl) am2 pairs ck2 G items -> plRefinement_func pl (gerPL fm2 am2 ck2) /\ wfCK_func fm2 am2 ck2 /\ wfPL (gerPL fm2 am2 ck2). Proof. intros pl fm am ck F G items pairs. unfold syntaxAddOptionalFeature. unfold conditionsAddOptionalFeature. intros. simpl. intuition. rewrite H6, H9. destruct gerPL. unfold plRefinement_func. intros. exists c3. split. + destruct gerPL. unfold getFM_func. simpl. unfold getFM_func in H8. destruct pl in H8. simpl in H8. destruct pls1. simpl. destruct p. destruct pls2 in H8. simpl in H8. destruct p. simpl in H8. destruct f, f0. simpl. apply H8. + specialize (H7 an). destruct H7. destruct H10. destruct G, F. intuition. Qed. (*=================== ADD UNUSED ASSETS ===================*) Fixpoint assetsCK (items:set Item): set AssetName := match items with | nil => nil | x :: xs => x.(assets) ++ assetsCK xs end. Definition Is_truePB (b:Prop) : bool := match b with | True => true end. Fixpoint remov (ls: set AssetName) am1: AM := match am1 with | nil => nil | x :: xs => if Is_truePB(set_In (fst x) (ls)) then remov ls xs else (x :: remov ls xs) end. Definition syntaxAddUnusedAssets (am1 am2 pairs: AM) : Prop := am2 = app pairs (remov (dom_func pairs) am1). Definition conditionsAddUnusedAssets {Mp: Maps AssetName Asset AM} pairs ck: Prop := forall an, set_In an (dom_ pairs) -> (~ set_In an (assetsCK ck)). Theorem addUnusedAssetsSameCK {Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl am2 pairs, ( syntaxAddUnusedAssets (snd( fst pl)) am2 pairs /\ conditionsAddUnusedAssets pairs (snd pl) -> forall (c: Configuration), set_In c (semantics_func (fst(fst pl))) -> (semantics_func_ (snd pl) (snd( fst pl)) c) = semantics_func_ (snd pl) am2 c). Proof. simpl. intuition. simpl. simpl in H0. unfold syntaxAddUnusedAssets in H1. unfold conditionsAddUnusedAssets in H2. specialize (H2 an). simpl in H1, H2, H0. rewrite H1. simpl. (* destruct pl. destruct pls0. destruct p. destruct getFM. destruct c0. simpl. simpl in H1. unfold semantics_func in H1. simpl in H1. *) Admitted. Theorem addUnusedAssets{Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl am2 pairs, ( syntaxAddUnusedAssets (getAM pl) am2 pairs /\ conditionsAddUnusedAssets pairs (getCK pl) -> strongerPLrefinement_func pl (gerPL (getFM pl) am2 (getCK pl)) /\ wfPL (gerPL (getFM pl) am2 (getCK pl))). Proof. intros. destruct H0. unfold syntaxAddUnusedAssets in H0. unfold conditionsAddUnusedAssets in H1. specialize (H1 an). intuition. - unfold strongerPLrefinement_func. intros. split. + unfold getFM_func. simpl. unfold getFM_func in H2. destruct pl in H2. simpl in H2. destruct gerPL. destruct pls1. simpl. destruct p. simpl in H2. destruct pls0 in H2. simpl in H2. destruct p. simpl in H2. destruct f, f0. simpl. apply H2. + destruct gerPL. unfold getCK_func. unfold getAM_func. simpl. induction pl, pls0. simpl. induction pls1. simpl. simpl in H0. admit. - intuition. destruct gerPL. Admitted. (*================== REMOVE UNUSED ASSETS =======================*) Theorem removeUnusedAssetsSameEvalCK {Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall (pl: PL) am2 pairs, ( syntaxAddUnusedAssets am2 (getAM pl) pairs /\ conditionsAddUnusedAssets pairs (getCK pl) -> forall c, set_In c (semantics (getFM pl)) -> (semantics_func_ (getCK pl) (getAM pl) c) = semantics_func_ (getCK pl) am2 c). Proof. unfold syntaxAddUnusedAssets. unfold conditionsAddUnusedAssets. intuition. specialize (H2 an). Admitted. Theorem removeUnusedAssets{Mp: Maps AssetName Asset AM} {Ft: FormulaTheory Formula Name FM} {FtM: FeatureModel FM Configuration} {AssetM: AssetMapping Asset AssetName AM} {ckTrans: CKTrans FM Asset AM CK Configuration} {SPL: SPL Asset Configuration FM AM CK PL}: forall pl am2 pairs, ( syntaxAddUnusedAssets am2 (getAM pl) pairs /\ conditionsAddUnusedAssets pairs (getCK pl) -> strongerPLrefinement_func pl (gerPL (getFM pl) am2 (getCK pl)) /\ wfPL (gerPL (getFM pl) am2 (getCK pl))). Proof. intros. destruct H0. unfold syntaxAddUnusedAssets in H0. unfold conditionsAddUnusedAssets in H1. specialize (H1 an). intuition. - unfold strongerPLrefinement_func. intros. split. + unfold getFM_func. simpl. unfold getFM_func in H2. destruct pl in H2. simpl in H2. destruct gerPL. destruct pls1. simpl. destruct p. simpl in H2. destruct pls0 in H2. simpl in H2. destruct p. simpl in H2. destruct f, f0. simpl. apply H2. + destruct gerPL. unfold getCK_func. unfold getAM_func. simpl. induction pl, pls0. simpl. induction pls1. simpl. simpl in H0. Admitted. End SpecificSPL.
module ExtendedLam where data Bool : Set where false : Bool true : Bool f : Bool → Bool → Bool f = λ { x false → true ; y true → y }
inductive LazyList (α : Type u) | nil : LazyList α | cons (hd : α) (tl : LazyList α) : LazyList α | delayed (t : Thunk (LazyList α)) : LazyList α namespace LazyList def force : LazyList α → Option (α × LazyList α) | delayed as => force as.get | nil => none | cons a as => some (a,as) end LazyList def deq (Q : LazyList τ) : Option (τ × LazyList τ) := match h:Q.force with | some (x, F') => some (x, F') | none => none theorem deq_correct_1 (Q : LazyList τ) : deq Q = none ↔ Q.force = none := by unfold deq cases h' : Q.force <;> simp theorem deq_correct_2 (Q : LazyList τ) : deq Q = none ↔ Q.force = none := by cases h' : Q.force with | none => unfold deq; rw [h']; simp | some => unfold deq; rw [h']; simp theorem deq_correct_3 (Q : LazyList τ) : deq Q = none ↔ Q.force = none := by cases h' : Q.force <;> unfold deq <;> rw [h'] <;> simp
# ------------------------------------------------------------------ # Licensed under the MIT License. See LICENCE in the project root. # ------------------------------------------------------------------ """ Process A geological process of evolution. """ abstract type Process end """ evolve!(state, proc, Δt) Evolve the `state` with process `proc` for a time period `Δt`. """ evolve!(state, proc, Δt::Float64) = error("not implemented") """ TimelessProcess A geological process implemented without the notion of time. """ abstract type TimelessProcess <: Process end """ evolve!(land, proc) Evolve the `land` with timeless process `proc`. """ evolve!(land::Matrix, proc::TimelessProcess) = error("not implemented") """ evolve!(land, proc, Δt) Evolve the `land` with timeless process `proc` for a time period `Δt`. """ function evolve!(land::Matrix, proc::TimelessProcess, Δt::Float64) t = mean(land) evolve!(land, proc) @. land = t + Δt + land nothing end """ evolve!(state, proc, Δt) Evolve the landscape `state` with timeless process `proc` for a time period `Δt`. """ evolve!(state::LandState, proc::TimelessProcess, Δt::Float64) = evolve!(state.land, proc, Δt) #------------------ # IMPLEMENTATIONS #------------------ include("processes/geostats.jl") include("processes/smoothing.jl") include("processes/sequential.jl") include("processes/analytical.jl")
lemma emeasure_lborel_cbox_eq: "emeasure lborel (cbox l u) = (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then \<Prod>b\<in>Basis. (u - l) \<bullet> b else 0)"
import data.real.irrational import topology.basic import algebra.order.floor --OUTPUT 1 theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := begin -- Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from assume (i j : ℤ) (hij : i ≠ j), assume h2 : int.fract (α * ↑i) = int.fract (α * ↑j), have h3 : α = (int.nat_abs (α * ↑i) - int.nat_abs (α * ↑j)) / (i - j), from by { rw [← int.fract_eq_sub_nat_abs, ← int.fract_eq_sub_nat_abs, h2], ring, }, have h4 : (i - j) ≠ 0, from by { assume h5 : (i - j) = 0, have h6 : i = j, from by {rw [h5, sub_eq_zero]}, exact hij h6, }, have h7 : α ∈ ℚ, from by { rw [← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg _), ← int.coe_nat_eq_coe_int_of_nonneg (int.nat_abs_nonneg end --Needs more than 2000 tokens! /- FEW SHOT PROMPTS TO CODEX(START) /--`theorem` Power Set is Closed under Intersection Let $S$ be a set. Let $\powerset S$ be the power set of $S$. Then: :$\forall A, B \in \powerset S: A \cap B \in \powerset S$ `proof` Let $A, B \in \powerset S$. Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$. From Intersection is Subset we have that $A \cap B \subseteq A$. It follows from Subset Relation is Transitive that $A \cap B \subseteq S$. Thus $A \cap B \in \powerset S$ and closure is proved. {{qed}} -/ theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S := begin -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$ assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S), -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB}, -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left, -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left}, -- Hence $(A ∩ B) ∈ 𝒫 S$, by power set definition show (A ∩ B) ∈ 𝒫 S, from by {apply set.mem_powerset h3}, end /--`theorem` Square of Sum :$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$ `proof` Follows from the distribution of multiplication over addition: {{begin-eqn}} {{eqn | l = \left({x + y}\right)^2 | r = \left({x + y}\right) \cdot \left({x + y}\right) }} {{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right) | c = Real Multiplication Distributes over Addition }} {{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y | c = Real Multiplication Distributes over Addition }} {{eqn | r = x^2 + 2xy + y^2 | c = }} {{end-eqn}} {{qed}} -/ theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := begin -- expand the power calc (x + y)^2 = (x+y)*(x+y) : by rw sq -- distributive property of multiplication over addition gives: ... = x*(x+y) + y*(x+y) : by rw add_mul -- applying the above property further gives: ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring} -- rearranging the terms using commutativity and adding gives: ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring} end /--`theorem` Identity of Group is Unique Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$. `proof` From Group has Latin Square Property, there exists a unique $x \in G$ such that: :$a x = b$ and there exists a unique $y \in G$ such that: :$y a = b$ Setting $b = a$, this becomes: There exists a unique $x \in G$ such that: :$a x = a$ and there exists a unique $y \in G$ such that: :$y a = a$ These $x$ and $y$ are both $e$, by definition of identity element. {{qed}} -/ theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a := begin -- Group has Latin Square Property have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by { assume a b : G, use a⁻¹ * b, obviously, }, have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by { assume a b : G, use b * a⁻¹, obviously, }, -- Setting $b = a$, this becomes: have h3 : ∀ a : G, ∃! x : G, a * x = a, from assume a : G, h1 a a, have h4 : ∀ a : G, ∃! y : G, y * a = a, from assume a : G, h2 a a, -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G, exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a))) (mul_one a), have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G, exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by { use (1 : G), have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by { assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a), have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G), exists_unique.unique (h3 a) (hident a).right (classical.some_spec (exists_unique.exists (h3 a))), have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G), exists_unique.unique (h4 a) (hident a).left (classical.some_spec (exists_unique.exists (h4 a))), show e = (1 : G), from eq.trans (h9 e) (h6 _), }, exact ⟨by obviously, h7⟩, } end /--`theorem` Density of irrational orbit The fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval `proof` Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then $$ i \alpha-\lfloor i \alpha\rfloor=\{i \alpha\}=\{j \alpha\}=j \alpha-\lfloor j \alpha\rfloor, $$ which yields the false statement $\alpha=\frac{\lfloor i \alpha\rfloor-\lfloor j \alpha\rfloor}{i-j} \in \mathbb{Q}$. Hence, $$ S:=\{\{i \alpha\} \mid i \in \mathbb{Z}\} $$ is an infinite subset of $\left[0,1\right]$. By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$. To show that $S$ is dense in $[0, 1]$, consider $y \in[0,1]$, and $\epsilon>0$. Then by selecting $x \in S$ such that $\{x\}<\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \cdot\{x\} \leq y<(N+1) \cdot\{x\}$, we get: $|y-\{N x\}|<\epsilon$. QED -/ theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := FEW SHOT PROMPTS TO CODEX(END)-/
using BaseBenchmarks using BenchmarkTools using Distributed addprocs(1) # re-tune the entire suite BaseBenchmarks.loadall!(tune = false) warmup(BaseBenchmarks.SUITE) tune!(BaseBenchmarks.SUITE; verbose = true) BenchmarkTools.save(BaseBenchmarks.PARAMS_PATH, params(BaseBenchmarks.SUITE))
[STATEMENT] theorem even_odd_induct: assumes "R 0" assumes "Q 0" assumes "\<And>n. Q n \<Longrightarrow> R (Suc n)" assumes "\<And>n. R n \<Longrightarrow> Q (Suc n)" shows "R n" "Q n" [PROOF STATE] proof (prove) goal (1 subgoal): 1. R n &&& Q n [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: R 0 Q 0 Q ?n \<Longrightarrow> R (Suc ?n) R ?n \<Longrightarrow> Q (Suc ?n) goal (1 subgoal): 1. R n &&& Q n [PROOF STEP] by induction_schema (pat_completeness+, lexicographic_order)
lemma measure_space_0: "A \<subseteq> Pow \<Omega> \<Longrightarrow> measure_space \<Omega> (sigma_sets \<Omega> A) (\<lambda>x. 0)"
module Test.Extra.StringTest import IdrTest.Test import IdrTest.Expectation import Extra.String export suite : Test suite = describe "String Extra Tests" [ test "Replace String" (\_ => assertEq (replace "abba" "oodle" "My String Yabba Dabba") "My String Yoodle Doodle" ), test "Quote String" (\_ => assertEq (quote "my string\nis cool") "\"my string\\nis cool\"" ), test "Unquote String" (\_ => assertEq (unquote "\"my string\\nis cool\"") "my string\nis cool" ), test "Limit Limited" (\_ => assertEq (limit 4 "this is cool") "this..." ), test "Limit Unlimited" (\_ => assertEq (limit 40 "this is cool") "this is cool" ) ]
/- Exercise 4. Let us define the binary relation ~> as follow: Let X and Y be two sets, and f : X → V be some function between the sets, then ∀ x, y ∈ X, x ~> y if and only if f(x) = f(y). Can you prove that ~> is an equivalence relation? Replace the sorry for your proof. Here are some basic tactics that might help : http://wwwf.imperial.ac.uk/~buzzard/xena/html/source/tactics/guide.html -/ universe u variables {X V : Type u} def bin_rel (X) := X → X → Prop def equivalence_rel (r : bin_rel X) := reflexive r ∧ symmetric r ∧ transitive r def cls (r : bin_rel X) (s : X) := {x : X | r s x} def partition (A : set (set X)) : Prop := (∀ x : X, (∃ B ∈ A, x ∈ B ∧ ∀ C ∈ A, x ∈ C → B = C)) ∧ ∅ ∉ A def rs (A : set (set(X))) (s t : X) := ∃ B ∈ A, s ∈ B ∧ t ∈ B -- The code above is simply used to esablish the definitions! theorem partition_equiv_relation -- I have defined rs to be: def rs (A : set (set(X))) (s t : X) := ∃ B ∈ A, s ∈ B ∧ t ∈ B (C : set (set X)) (h : partition C) : equivalence_rel (rs C) := begin sorry end
/- To run this project, load the contents of this file at: -- https://leanprover-community.github.io/lean-web-editor -- You can either copy-and-paste it or use the load function. -- The Lean web editor will take up to some minutes to load fully and process the code. -- Do not worry! The waiting is normal and happens only once (when the code is loaded). -/ reserve prefix `#` : 9999 -- #_ reserve infix ` >> ` : 1000 -- _ >> _ /- Useful Properties -/ namespace use universes u v /- Proofs from L∃∀N's library regarding negation, conjunction, and disjunction -/ lemma Not_Or {a b : Prop} : ¬ a → ¬ b → ¬ (a ∨ b) | hna hnb (or.inl ha) := absurd ha hna | hna hnb (or.inr hb) := absurd hb hnb lemma Not_Or_iff_And_Not (p q) [d₁ : decidable p] [d₂ : decidable q] : ¬ (p ∨ q) ↔ ¬ p ∧ ¬ q := iff.intro (λ h, match d₁ with | is_true h₁ := false.elim $ h (or.inl h₁) | is_false h₁ := match d₂ with | is_true h₂ := false.elim $ h (or.inr h₂) | is_false h₂ := ⟨h₁, h₂⟩ end end) (λ ⟨np, nq⟩ h, or.elim h np nq) /- Proving the distributive property of "IF-THEN-ELSE" -/ lemma ITE_Distribution {α : Type u}{β : Type v} {IF : Prop}{THEN ELSE : α} [decIF : decidable IF] : ∀(f : α → β), --------------------------- ( f (ite IF THEN ELSE) = ite IF (f THEN) (f ELSE) ) := begin with_cases { by_cases IFs : IF }, case pos { simp [IFs] }, case neg { simp [IFs] } end /- Useful properties regarding Lists -/ lemma Index_LT_Length_of_Mem {α : Type u} [eqα : decidable_eq α] : ∀{a : α}{l : list α}, ( a ∈ l ) → --------------------------- ( list.index_of a l < list.length l ) | a [] := begin assume a_mem, simp [has_mem.mem, list.mem] at a_mem, from false.elim a_mem end | a (HEAD::TAIL) := begin assume a_mem, simp [has_mem.mem, list.mem] at a_mem, simp [list.index_of, list.find_index, list.length], with_cases { by_cases a_eq_head : a = HEAD }, case pos { simp [a_eq_head], have one_le_succ, from nat.add_le_add_left (nat.zero_le (list.length TAIL)) 1, rewrite [nat.add_zero] at one_le_succ, have zero_lt_succ, from nat.lt_of_lt_of_le (nat.zero_lt_one) one_le_succ, rewrite [nat.add_comm] at zero_lt_succ, from nat.lt_of_lt_of_le nat.zero_lt_one zero_lt_succ }, case neg { simp [a_eq_head] at ⊢ a_mem, rewrite [nat.succ_eq_add_one, nat.add_comm], have loop, from Index_LT_Length_of_Mem a_mem, have lt_loop, from nat.add_lt_add_left loop 1, rewrite [nat.add_comm 1 (TAIL.length)] at lt_loop, from lt_loop } end lemma Mem_Remove_of_Mem_of_Not_Mem {α : Type u} [eqα : decidable_eq α] : ∀{nth : α}{l1 l2 : list α}, ( nth ∉ l1 ) → ( nth ∈ l2 ) → --------------------------- ( ∀(a : α), a ∈ l1 → a ∈ l2 → a ∈ list.remove_nth l2 (list.index_of nth l2) ) | nth l1 [] := begin assume nth_not_l1 nth_mem_l2, simp [has_mem.mem, list.mem] at nth_mem_l2, from false.elim nth_mem_l2 end | nth l1 (HEAD2::TAIL2) := begin assume nth_not_l1 nth_mem_l2, simp [list.index_of, list.find_index], with_cases { by_cases nth_eq_head2 : nth = HEAD2 }, case pos { simp [nth_eq_head2] at ⊢ nth_not_l1, simp [list.index_of, list.find_index, list.remove_nth], have case_loop : ∀(a : α), a ∈ l1 → a ∈ (HEAD2::TAIL2) → a ∈ TAIL2, from begin assume loop loop_mem_l1 loop_mem_l2, simp [has_mem.mem, list.mem] at loop_mem_l2, cases loop_mem_l2 with loop_eq_head2 loop_mem_tail2, case or.inl { rewrite [loop_eq_head2] at loop_mem_l1, from absurd loop_mem_l1 nth_not_l1 }, case or.inr { from loop_mem_tail2 } end, from case_loop }, case neg { simp [nth_eq_head2] at ⊢ nth_mem_l2, simp [list.remove_nth], have case_loop : ∀(a : α), a ∈ l1 → a ∈ (HEAD2::TAIL2) → a = HEAD2 ∨ a ∈ list.remove_nth TAIL2 (list.find_index (eq nth) TAIL2), from begin assume loop loop_mem_l1 loop_mem_l2, simp [has_mem.mem, list.mem] at loop_mem_l2, cases loop_mem_l2 with loop_eq_head2 loop_mem_tail2, case or.inl { simp [loop_eq_head2] }, case or.inr { apply (or.intro_right), from Mem_Remove_of_Mem_of_Not_Mem nth_not_l1 nth_mem_l2 loop loop_mem_l1 loop_mem_tail2 } end, from case_loop } end lemma Subset_Self {α : Type u} : ∀(l : list α), --------------------------- ( ∀(a : α), ( a ∈ l ) → ( a ∈ l ) ) | l := begin have subset_self : ∀(a : α), a ∈ l → a ∈ l, from begin assume a a_mem_l, from a_mem_l end, from subset_self end /- Useful properties regarding Natural Numbers (Must be in Order) -/ lemma LT_Add_of_Pos_of_LE : ∀{a b c : ℕ}, ( 0 < a ) → ( b ≤ c ) → --------------------------------- b < a + c | a b c := begin assume a_pos b_le_c, have one_le_a, from nat.succ_le_of_lt a_pos, have b_le_ac, from nat.add_le_add one_le_a b_le_c, rewrite [nat.add_comm] at b_le_ac, from nat.lt_of_succ_le b_le_ac end lemma LT_Add_of_Pos_of_LT : ∀{a b c : ℕ}, ( 0 < a ) → ( b < c ) → --------------------------------- b < a + c | a b c := begin assume a_pos b_lt_c, from LT_Add_of_Pos_of_LE a_pos (nat.le_of_lt b_lt_c) end lemma LT_Add_of_LE_of_Pos : ∀{a b c : ℕ}, ( b ≤ c ) → ( 0 < a ) → --------------------------------- b < c + a | a b c := begin assume b_le_c a_pos, have one_le_a, from nat.succ_le_of_lt a_pos, have b_le_ca, from nat.add_le_add b_le_c one_le_a, from nat.lt_of_succ_le b_le_ca end lemma LT_Add_of_LT_of_Pos : ∀{a b c : ℕ}, ( b < c ) → ( 0 < a ) → --------------------------------- b < c + a | a b c := begin assume b_lt_c a_pos, from LT_Add_of_LE_of_Pos (nat.le_of_lt b_lt_c) a_pos end lemma EQ_of_LT_ONE_of_GE : ∀{a b : ℕ}, ( a ≥ b ) → ( a < 1 + b ) → --------------------------------- ( a = b ) | 0 0 := begin assume a_ge_b a_lt_oneb, from eq.refl 0 end | (a+1) 0 := begin assume a_ge_b a_lt_oneb, rewrite [nat.add_comm] at a_lt_oneb, have zero_lt_a, from nat.lt_of_add_lt_add_left a_lt_oneb, have not_zero_lt_a, from nat.not_lt_zero a, from absurd zero_lt_a not_zero_lt_a end | 0 (b+1) := begin assume a_ge_b a_lt_oneb, have zero_le_b, from nat.zero_le b, have b_le_oneb, from le_trans a_ge_b zero_le_b, rewrite [nat.add_one] at b_le_oneb, from absurd b_le_oneb (nat.not_succ_le_self b) end | (a+1) (b+1) := begin assume a_ge_b a_lt_oneb, have loop_ge : a ≥ b , from nat.le_of_succ_le_succ a_ge_b, rewrite [nat.add_comm] at a_lt_oneb, have loop_lt, from nat.lt_of_add_lt_add_left a_lt_oneb, rewrite [nat.add_comm] at loop_lt, rewrite [EQ_of_LT_ONE_of_GE loop_ge loop_lt] end lemma LE_Mul_Left_of_Pos : ∀{a : ℕ}, ( 0 < a ) → --------------------------------- ( ∀(b : ℕ), b ≤ a * b ) | a := begin assume zero_lt_a b, induction b, case nat.zero { simp [nat.mul_zero] }, case nat.succ { have one_le_a, from nat.succ_le_of_lt zero_lt_a, rewrite [nat.succ_eq_add_one, nat.mul_comm a, nat.add_comm, nat.right_distrib, nat.one_mul, nat.mul_comm], from nat.add_le_add one_le_a b_ih } end /- Useful properties regarding Natural Numbers -/ lemma Add_GE_Add : ∀{a b c d : ℕ}, ( a ≥ b ) → ( c ≥ d ) → --------------------------------- ( a + c ≥ b + d ) | a b c d := begin assume a_ge_b c_ge_d, from nat.add_le_add a_ge_b c_ge_d end lemma Add_Left_EQ_of_EQ : ∀{a b : ℕ}, ( a = b ) → --------------------------------- ( ∀(c : ℕ), c + a = c + b ) | a b := begin assume a_eq_b c, rewrite [a_eq_b] end lemma Add_Right_EQ_of_EQ : ∀{a b : ℕ}, ( a = b ) → --------------------------------- ( ∀(c : ℕ), a + c = b + c ) | a b := begin assume a_eq_b c, rewrite [a_eq_b] end lemma EQ_or_SUCC_LE_iff_LE : ∀{a b : ℕ}, --------------------------- ( a ≤ b ) ↔ ( (a = b) ∨ (a+1 ≤ b) ) := begin have case_to : ∀{a b : ℕ}, a ≤ b → (a = b) ∨ (a+1 ≤ b), from begin assume a b le_a_b, from nat.eq_or_lt_of_le le_a_b end, have case_from : ∀{a b : ℕ}, (a = b) ∨ (a+1 ≤ b) → a ≤ b, from begin assume a b eq_or_succ_le_a_b, cases eq_or_succ_le_a_b with eq_a_b succ_le_a_b, case or.inl { simp [eq_a_b] }, case or.inr { from nat.le_of_succ_le succ_le_a_b } end, assume a b, from iff.intro case_to case_from end lemma EQ_PRED_of_SUCC_EQ : -- Notice that the other way does not hold true, since 0 ≠ 0 - 1 ∀{a b : ℕ}, ( a+1 = b ) → --------------------------- ( a = b-1 ) | a b := begin assume eq_succ_a_b, rewrite [←eq_succ_a_b, eq_comm], from nat.add_sub_cancel a 1 end lemma GE_Cancel_Right : ∀{a b c : ℕ}, ( a ≥ b + c ) → --------------------------------- ( a ≥ b ) | a b c := begin assume a_ge_bc, have bc_ge_b : b + c ≥ b, from begin have b_le_bc, from nat.add_le_add_left (nat.zero_le c) b, rewrite [nat.add_zero] at b_le_bc, from b_le_bc end, from ge_trans a_ge_bc bc_ge_b end lemma GE_iff_Not_LT : ∀{a b : ℕ}, --------------------------- ( a ≥ b ) ↔ ( ¬( a < b ) ) := begin have case_to : ∀{m n : ℕ}, ( m ≥ n ) → ( ¬( m < n ) ), from begin assume m n m_ge_n, from not_lt_of_ge m_ge_n end, have case_from : ∀{m n : ℕ}, ( ¬( m < n ) ) → ( m ≥ n ), from begin assume m n not_m_lt_n, have eq_or_lt, from nat.eq_or_lt_of_not_lt not_m_lt_n, cases eq_or_lt with m_eq_n m_lt_n, case or.inl { apply nat.le_of_eq, from (iff.elim_right eq_comm) m_eq_n }, case or.inr { apply nat.le_of_lt, from m_lt_n }, end, assume a b, from iff.intro case_to case_from end lemma LE_Add_Left : ∀{a b : ℕ}, ( a ≤ b ) → --------------------------------- ( ∀(c : ℕ), ( a ≤ c + b ) ) | a b := begin assume a_le_b c, from le_trans a_le_b (nat.le_add_left b c) end lemma LE_Add_Right : ∀{a b : ℕ}, ( a ≤ b ) → --------------------------------- ( ∀(c : ℕ), ( a ≤ b + c ) ) | a b := begin assume a_le_b c, from le_trans a_le_b (nat.le_add_right b c) end lemma LE_Mul_of_LE : ∀{a b : ℕ}, ∀(c : ℕ), ( a ≤ b ) → --------------------------- ( a * c ≤ b * c ) | a b 0 := begin assume a_le_b, simp [nat.mul_zero] end | a b (c+1) := begin assume a_le_b, rewrite [←nat.mul_comm (c+1), nat.right_distrib, nat.one_mul, nat.mul_comm c], rewrite [←nat.mul_comm (c+1), nat.right_distrib, nat.one_mul, nat.mul_comm c], have loop, from LE_Mul_of_LE c a_le_b, from nat.add_le_add loop a_le_b end lemma LT_Add_Left : ∀{a b : ℕ}, ( a < b ) → --------------------------------- ( ∀(c : ℕ), ( a < c + b ) ) | a b := begin assume a_lt_b c, with_cases {by_cases c_eq_zero : c = 0 }, case pos { simp [c_eq_zero], rewrite [nat.add_comm, nat.add_zero], from a_lt_b }, case neg { rewrite [eq_comm] at c_eq_zero, have c_pos, from lt_of_le_of_ne (nat.zero_le c) (c_eq_zero), from LT_Add_of_Pos_of_LT c_pos a_lt_b } end lemma LT_Add_Right : ∀{a b : ℕ}, ( a < b ) → --------------------------------- ( ∀(c : ℕ), ( a < b + c ) ) | a b := begin assume a_lt_b c, with_cases {by_cases c_eq_zero : c = 0 }, case pos { simp [c_eq_zero], rewrite [nat.add_zero], from a_lt_b }, case neg { rewrite [eq_comm] at c_eq_zero, have c_pos, from lt_of_le_of_ne (nat.zero_le c) (c_eq_zero), from LT_Add_of_LT_of_Pos a_lt_b c_pos } end lemma LT_ZERO_iff_LE_ONE : ∀{a : ℕ}, --------------------------- ( 0 < a ) ↔ ( 1 ≤ a ) := begin have case_to : ∀{a : ℕ}, ( 0 < a ) → ( 1 ≤ a ), from begin assume a zero_lt_a, from nat.le_of_lt_succ (nat.succ_lt_succ zero_lt_a) end, have case_from : ∀{a : ℕ}, ( 1 ≤ a ) → ( 0 < a ), from begin assume a one_le_a, from nat.lt_of_lt_of_le nat.zero_lt_one one_le_a end, assume a, from iff.intro case_to case_from end lemma Not_EQ_of_SUCC_EQ_SUB : ∀{a b c : ℕ}, ( c+1 = a-b ) → --------------------------------- ¬ ( b = a ) | a b c := begin assume succ_eq_sub eq_a_b, rewrite [eq_a_b] at succ_eq_sub, rewrite [nat.sub_self] at succ_eq_sub, simp [nat.add_one_ne_zero] at succ_eq_sub, from succ_eq_sub end lemma Not_SUCC_LE_of_ZERO_EQ_SUB : ∀{a b : ℕ}, ( 0 = a-b ) → --------------------------------- ¬ ( b+1 ≤ a ) | a b := begin assume zero_eq_sub succ_le, rewrite [eq_comm] at zero_eq_sub, have le_a_b, from nat.le_of_sub_eq_zero zero_eq_sub, have le_succ_b_b, from nat.le_trans succ_le le_a_b, simp [nat.not_succ_le_self] at le_succ_b_b, from le_succ_b_b end lemma Sub_Add_Cancel : ∀{a b : ℕ}, ( b ≤ a ) → --------------------------------- ( a - b + b = a ) | a b := begin assume b_le_a, from nat.sub_add_cancel b_le_a end lemma ZERO_LT_Mul_iff_AND_ZERO_LT : ∀{a b : ℕ}, --------------------------------- ( 0 < a * b ) ↔ ( 0 < a ∧ 0 < b ) := begin have case_to : ∀{a b : ℕ}, ( 0 < a * b ) → ( 0 < a ∧ 0 < b ), from begin assume a b zero_lt_ab, with_cases {by_cases a_eq_zero : a = 0 }, case pos { rewrite [a_eq_zero, nat.zero_mul] at zero_lt_ab, from false.elim (nat.not_lt_zero 0 zero_lt_ab) }, case neg { with_cases {by_cases b_eq_zero : b = 0 }, case pos { rewrite [b_eq_zero, nat.mul_zero] at zero_lt_ab, from false.elim (nat.not_lt_zero 0 zero_lt_ab) }, case neg { have zero_le_a, from nat.lt_of_le_and_ne (nat.zero_le a), have zero_le_b, from nat.lt_of_le_and_ne (nat.zero_le b), rewrite [ne.def, eq_comm] at zero_le_a zero_le_b, from and.intro (zero_le_a a_eq_zero) (zero_le_b b_eq_zero) }, } end, have case_from : ∀{a b : ℕ}, ( 0 < a ∧ 0 < b ) → ( 0 < a * b ), from begin assume a b zero_lt_a_and_b, cases zero_lt_a_and_b with zero_lt_a zero_lt_b, have zero_lt_ab, from nat.mul_lt_mul_of_pos_left zero_lt_b zero_lt_a, rewrite [nat.mul_zero] at zero_lt_ab, from zero_lt_ab end, assume a b, from iff.intro case_to case_from end lemma ZERO_LT_of_Not_EQ_ZERO : ∀{a : ℕ}, ¬ ( a = 0 ) → --------------------------------- ( 0 < a ) | 0 := begin assume not_refl_zero, from absurd (eq.refl 0) not_refl_zero end | (a+1) := begin assume not_succ_eq_zero, rewrite [nat.add_comm], from nat.zero_lt_one_add a end end use /- Auxiliary Definitions -/ namespace aux universes u /- Methods for determining the size of nested lists -/ -- The order of the following definitions is important class has_size (α : Type u) := (size : α → ℕ) instance is_default_size (α : Type u) : has_size α := ⟨ (λx, 1) ⟩ -- First the size method checks if it has been given a list, if not it goes to its default case def size {α : Type u} [hcα : has_size α] : α → ℕ := has_size.size def list_size {α : Type u} [hcα : has_size α] : list α → ℕ | [] := 0 | (h::l) := size h + list_size l -- Writing [hcα : has_size α] means that α ay have either is_list_size or is_default_size -- If [hcα : has_size α] is omitted, than α must have is_default_size instance is_list_size (α : Type u) [hcα : has_size α] : has_size (list α) := ⟨list_size⟩ /- Properties about list size -/ lemma Deafault_Size_EQ_Length {α : Type} : ∀{l : list α}, --------------------------- ( list_size l = list.length l ) | [] := by simp [list.length, list_size] | (HEAD::TAIL) := begin simp [list.length, list_size], simp [size, has_size.size], rewrite [Deafault_Size_EQ_Length], from nat.add_comm 1 (list.length TAIL) end lemma ZERO_LT_Length_of_LT_Size {α : Type} [hcα : has_size α] : ∀{l : list α}{num : ℕ}, ( num < list_size l ) → --------------------------- ( 0 < list.length l ) | [] num := begin assume num_lt_size, simp [list_size] at num_lt_size, from absurd num_lt_size (nat.not_lt_zero num) end | (HEAD::TAIL) num := begin assume num_lt_size, simp [list.length, nat.add_comm], from nat.zero_lt_one_add (list.length TAIL) end end aux /- Auxiliary Definitions (Leaf) -/ namespace a_leaf universes u /- Combinatory theorem about nested lists -/ theorem Main_Combinatory_Nested {α : Type u} [hsα : aux.has_size α] : ∀{num : ℕ}{ll : list (list α)}, ( (list.length ll) * num < aux.list_size ll ) → --------------------------------- ( ∃(l : list α), l ∈ ll ∧ num < aux.list_size l ) | num [] := begin assume mul_lt_ll, simp [aux.list_size] at mul_lt_ll, rewrite [nat.mul_comm, nat.mul_zero] at mul_lt_ll, from false.elim (nat.not_lt_zero 0 mul_lt_ll) end | num (HEAD::TAIL) := begin assume mul_lt_ll, simp [aux.list_size] at mul_lt_ll, with_cases { by_cases num_lt_head : num < aux.size HEAD }, case pos { --If HEAD is big apply exists.intro HEAD, simp [has_mem.mem, list.mem], from num_lt_head }, case neg { --If HEAD isn't big with_cases { by_cases mul_lt_tail : (list.length TAIL) * num < aux.list_size TAIL }, case pos { --If TAIL is big have main_combinatory, from Main_Combinatory_Nested mul_lt_tail, cases main_combinatory with la main_combinatory, cases main_combinatory with mem_la_tail num_lt_la, apply exists.intro la, simp [has_mem.mem, list.mem] at ⊢ mem_la_tail, simp [mem_la_tail], from num_lt_la }, case neg { --If TAIL isn't big rewrite [nat.right_distrib (list.length TAIL) 1 num, nat.one_mul] at mul_lt_ll, rewrite [←use.GE_iff_Not_LT] at num_lt_head, rewrite [←use.GE_iff_Not_LT] at mul_lt_tail, have not_mul_lt_ll, from use.Add_GE_Add mul_lt_tail num_lt_head, rewrite [use.GE_iff_Not_LT, nat.add_comm (aux.list_size TAIL)] at not_mul_lt_ll, from absurd mul_lt_ll not_mul_lt_ll } } end end a_leaf /- Auxiliary Definitions (Branch) -/ namespace a_branch universes u /- Methods for counting the number diferent elements in a list -/ def list_set {α : Type u} [eqα : decidable_eq α] : list α → list α | [] := [] | (HEAD::TAIL) := if HEAD ∈ TAIL then list_set TAIL else HEAD :: list_set TAIL def list_filter {α : Type u} [eqα : decidable_eq α] : α → list α → list α | _ [] := [] | a (HEAD::TAIL) := if a = HEAD then HEAD :: list_filter a TAIL else list_filter a TAIL def list_delete {α : Type u} [eqα : decidable_eq α] : α → list α → list α | _ [] := [] | a (HEAD::TAIL) := if a = HEAD then list_delete a TAIL else HEAD :: list_delete a TAIL /- Properties about list set, filter, and delete (Used outside this namespace) -/ lemma Length_Set_LE_Length_of_Subset {α : Type u} [eqα : decidable_eq α] : ∀{l1 l2 : list α}, ( ∀(a : α), ( a ∈ l1 ) → ( a ∈ l2 ) ) → --------------------------- ( list.length (list_set l1) ≤ list.length l2 ) | [] l2 := begin assume case_mem, simp [list_set], from nat.zero_le (list.length l2) end | (HEAD1::TAIL1) l2 := begin assume case_mem, have head1_mem_l2 : HEAD1 ∈ l2, from begin apply (case_mem HEAD1), simp [has_mem.mem, list.mem] end, have case_mem_tail1 : ∀ (a : α), a ∈ TAIL1 → a ∈ l2, from begin assume loop loop_mem_tail1, simp [has_mem.mem, list.mem] at case_mem, apply (case_mem loop), simp [has_mem.mem, list.mem] at loop_mem_tail1, simp [loop_mem_tail1] end, simp [list_set], with_cases { by_cases head1_mem_tail1 : HEAD1 ∈ TAIL1 }, -- case pos { simp [head1_mem_tail1], from Length_Set_LE_Length_of_Subset case_mem_tail1 }, case neg { simp [head1_mem_tail1], have case_loop : ∀ (a : α), a ∈ TAIL1 → a ∈ list.remove_nth l2 (list.index_of HEAD1 l2), from begin assume loop loop_mem_tail1, have loop_mem_l2, from case_mem_tail1 loop loop_mem_tail1, have case_remove, from use.Mem_Remove_of_Mem_of_Not_Mem head1_mem_tail1 head1_mem_l2, from case_remove loop loop_mem_tail1 loop_mem_l2 end, have loop, from Length_Set_LE_Length_of_Subset case_loop, have case_index, from use.Index_LT_Length_of_Mem head1_mem_l2, rewrite [list.length_remove_nth l2 (list.index_of HEAD1 l2) case_index] at loop, have one_le_l2, from nat.lt_of_le_of_lt (nat.zero_le (list.index_of HEAD1 l2)) case_index, rewrite [use.LT_ZERO_iff_LE_ONE] at one_le_l2, rewrite [←use.Sub_Add_Cancel one_le_l2], from nat.add_le_add loop (nat.le_refl 1) } end /- Properties about list set, filter, and delete (Used only within this namespace) -/ lemma Mem_of_Mem_Delete {α : Type u} [eqα : decidable_eq α] : ∀{a1 a2 : α}{l : list α}, ( a1 ∈ (list_delete a2 l) ) → --------------------------- ( a1 ∈ l ) | a1 a2 [] := begin assume a1_mem_del, simp [list_delete, has_mem.mem, list.mem] at a1_mem_del, from false.elim a1_mem_del end | a1 a2 (HEAD::TAIL) := begin assume a1_mem_del, simp [list_delete, has_mem.mem, list.mem] at ⊢ a1_mem_del, with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If HEAD = a2 simp [a2_eq_head] at a1_mem_del, have loop, from Mem_of_Mem_Delete a1_mem_del, simp [has_mem.mem, list.mem] at ⊢ loop, simp [loop] }, case neg { -- If HEAD ≠ a2 simp [a2_eq_head, list.mem] at a1_mem_del, cases a1_mem_del with a1_eq_head a1_mem_del, case or.inl { simp [a1_eq_head] }, case or.inr { have loop, from Mem_of_Mem_Delete a1_mem_del, simp [has_mem.mem, list.mem] at ⊢ loop, simp [loop] } } end lemma Size_Filter_Delete {α : Type u} [eqα : decidable_eq α] : ∀(a : α)(l : list α), --------------------------- ( aux.list_size (list_filter a (list_delete a l)) = 0 ) | a [] := by simp [list_delete, list_filter, aux.list_size] | a (HEAD::TAIL) := begin with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD simp [a_eq_head, list_delete], from Size_Filter_Delete HEAD TAIL }, case neg { -- If a ≠ HEAD simp [a_eq_head, list_delete, list_filter], from Size_Filter_Delete a TAIL } end lemma Size_Delete_LE_Size {α : Type u} [eqα : decidable_eq α] : ∀(a1 a2 : α)(l : list α), --------------------------- ( aux.list_size (list_filter a1 (list_delete a2 l)) ≤ aux.list_size (list_filter a1 l) ) | a1 a2 [] := by simp [list_delete, list_filter] | a1 a2 (HEAD::TAIL) := begin simp [list_delete], with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If a2 = HEAD simp [a2_eq_head, list_filter], with_cases { by_cases a1_eq_head : a1 = HEAD }, case pos { -- If a1 = HEAD simp [a1_eq_head, aux.list_size], from use.LE_Add_Left (Size_Delete_LE_Size HEAD HEAD TAIL) (aux.size HEAD) }, case neg { -- If a1 ≠ HEAD simp [a1_eq_head, aux.list_size], from Size_Delete_LE_Size a1 HEAD TAIL } }, case neg { -- If a2 ≠ HEAD simp [a2_eq_head, list_filter], with_cases { by_cases a1_eq_head : a1 = HEAD }, case pos { -- If a1 = HEAD simp [a1_eq_head, aux.list_size], from nat.add_le_add (nat.le_refl (aux.size HEAD)) (Size_Delete_LE_Size HEAD a2 TAIL) }, case neg { -- If a1 ≠ HEAD simp [a1_eq_head, aux.list_size], from Size_Delete_LE_Size a1 a2 TAIL } } end lemma Size_Filter_Delete_EQ_Size {α : Type u} [eqα : decidable_eq α] : ∀(a : α)(l : list α), --------------------------- ( aux.list_size (list_filter a l) + aux.list_size (list_delete a l) = aux.list_size l ) | a [] := by simp [list_delete, list_filter, aux.list_size] | a (HEAD::TAIL) := begin simp [list_filter, list_delete], with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD simp [a_eq_head, aux.list_size], rewrite [nat.add_assoc], have loop, from Size_Filter_Delete_EQ_Size HEAD TAIL, from use.Add_Left_EQ_of_EQ loop (aux.size HEAD) }, case neg { -- If a ≠ HEAD simp [a_eq_head, aux.list_size], rewrite [←nat.add_assoc], rewrite [nat.add_comm (aux.list_size (list_filter a TAIL)) (aux.size HEAD)], rewrite [nat.add_assoc], have loop, from Size_Filter_Delete_EQ_Size a TAIL, from use.Add_Left_EQ_of_EQ loop (aux.size HEAD) } end /- Properties about list set, filter, and delete (Must be left in order) -/ lemma Case_Not_Mem_Del {α : Type u} [eqα : decidable_eq α] : ∀{a1 a2 : α}{l : list α}, ( a2 ≠ a1 ) → ( a1 ∉ l ) → --------------------------- ( a1 ∉ list_delete a2 l ) | a1 a2 [] := by simp [list_delete] | a1 a2 (HEAD::TAIL) := begin assume a1_ne_a2 a1_not_mem, simp [has_mem.mem, list.mem] at a1_not_mem, rewrite [use.Not_Or_iff_And_Not] at a1_not_mem, cases a1_not_mem with a1_ne_head a1_not_mem_tail, -- with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If a2 = HEAD simp [a2_eq_head, list_delete] at ⊢ a1_ne_a2, rewrite [eq_comm] at a1_ne_head, from Case_Not_Mem_Del a1_ne_head a1_not_mem_tail }, case neg { -- If a2 ≠ HEAD simp [a2_eq_head, list_delete], from use.Not_Or a1_ne_head (Case_Not_Mem_Del a1_ne_a2 a1_not_mem_tail) } end lemma Case_Mem_Del {α : Type u} [eqα : decidable_eq α] : ∀{a1 a2 : α}{l : list α}, ( a2 ≠ a1 ) → ( a1 ∈ l ) → --------------------------- ( a1 ∈ list_delete a2 l ) | a1 a2 [] := begin assume a1_ne_a2 a1_mem, simp [list_delete] at a1_mem, from false.elim a1_mem end | a1 a2 (HEAD::TAIL) := begin assume a1_ne_a2 a1_mem, simp [has_mem.mem, list.mem] at a1_mem, -- with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If a2 = HEAD simp [a2_eq_head, list_delete] at ⊢ a1_ne_a2, cases a1_mem with a1_eq_head a1_mem_tail, case or.inl { rewrite [eq_comm] at a1_eq_head, from absurd a1_eq_head a1_ne_a2 }, case or.inr { from Case_Mem_Del a1_ne_a2 a1_mem_tail } }, case neg { -- If a2 ≠ HEAD simp [a2_eq_head, list_delete], cases a1_mem with a1_eq_head a1_mem_tail, case or.inl { simp [a1_eq_head] }, case or.inr { simp [Case_Mem_Del a1_ne_a2 a1_mem_tail] } } end lemma Lenght_EQ_Lenght_Set_Delete {α : Type u} [eqα : decidable_eq α] : ∀(a : α)(l : list α), --------------------------- ( list.length (list_set (a::l)) = 1 + list.length (list_set (list_delete a l)) ) | a [] := by simp [list_delete, list_set] | a (HEAD::TAIL) := begin have loop_head, from Lenght_EQ_Lenght_Set_Delete HEAD TAIL, have loop_a, from Lenght_EQ_Lenght_Set_Delete a TAIL, simp [list_delete] at ⊢ loop_head loop_a, with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD simp [a_eq_head, list_set] at ⊢ loop_head, with_cases { by_cases head_mem_tail : HEAD ∈ TAIL }, case pos { -- If HEAD ∈ TAIL simp [head_mem_tail, list.length] at ⊢ loop_head, from loop_head }, case neg { -- If HEAD ∉ TAIL simp [head_mem_tail, list.length] at ⊢ loop_head, from loop_head } }, case neg { -- If a ≠ HEAD simp [a_eq_head, list_set] at ⊢ loop_a, with_cases { by_cases a_mem_tail : a ∈ TAIL }, case pos { -- If a ∈ TAIL simp [a_mem_tail, list.length] at ⊢ loop_a, with_cases { by_cases head_mem_tail : HEAD ∈ TAIL }, case pos { -- If HEAD ∈ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Mem_Del a_eq_head head_mem_tail], from loop_a }, case neg { -- If HEAD ∉ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Not_Mem_Del a_eq_head head_mem_tail], rewrite [nat.add_comm (list.length (list_set TAIL)) 1], rewrite [nat.add_comm] at loop_a, from use.Add_Left_EQ_of_EQ loop_a 1 } }, case neg { -- If a ∉ TAIL simp [a_mem_tail, list.length] at ⊢ loop_a, with_cases { by_cases head_mem_tail : HEAD ∈ TAIL }, case pos { -- If HEAD ∈ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Mem_Del a_eq_head head_mem_tail], from loop_a }, case neg { -- If HEAD ∉ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Not_Mem_Del a_eq_head head_mem_tail], rewrite [nat.add_comm 1 (list.length (list_set (list_delete a TAIL)))] at loop_a, rewrite [nat.add_comm (list.length (list_set TAIL) + 1) 1], from use.Add_Left_EQ_of_EQ loop_a 1 } } } end /- Combinatory theorem about lists (Filter) -/ theorem Main_Combinatory_Filter {α : Type} [eqα : decidable_eq α] : ∀(num : ℕ)(l : list α), ( list.length (list_set l) * num < aux.list_size l ) → --------------------------------- ( ∃(a : α), a ∈ l ∧ num < aux.list_size (list_filter a l) ) | num [] := begin assume mul_lt_l, simp [aux.list_size] at mul_lt_l, from false.elim (nat.not_lt_zero (list.length (list_set []) * num) mul_lt_l) end | num (HEAD::TAIL) := begin assume mul_lt_l, with_cases { by_cases num_lt_head : num < 1 + aux.list_size (list_filter HEAD TAIL) }, case pos { -- If list_filter HEAD (HEAD::TAIL) is big apply exists.intro HEAD, simp [list_filter, aux.list_size, has_mem.mem, list.mem, aux.size, aux.has_size.size], from num_lt_head }, case neg { -- If list_filter HEAD (HEAD::TAIL) isn't big with_cases { by_cases mul_lt_del : list.length (list_set (list_delete HEAD TAIL)) * num < aux.list_size (list_delete HEAD TAIL) }, case pos { -- If list_delete HEAD (HEAD::TAIL) is big have main_combinatory : ∃(a : α), a ∈ list_delete HEAD TAIL ∧ num < aux.list_size (list_filter a (list_delete HEAD TAIL)), from Main_Combinatory_Filter num (list_delete HEAD TAIL) mul_lt_del, -- sorry, cases main_combinatory with a main_combinatory, cases main_combinatory with a_mem_del num_lt_a, apply exists.intro a, simp [has_mem.mem, list.mem] at ⊢ a_mem_del, simp [a_mem_del, list_filter], with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD rewrite [a_eq_head] at num_lt_a a_mem_del, rewrite [Size_Filter_Delete HEAD TAIL] at num_lt_a, from absurd num_lt_a (nat.not_lt_zero num) }, case neg { -- If a ≠ HEAD simp [a_eq_head], have a_mem_tail, from Mem_of_Mem_Delete a_mem_del, simp [has_mem.mem] at a_mem_tail, simp [a_mem_tail], from nat.lt_of_lt_of_le num_lt_a (Size_Delete_LE_Size a HEAD TAIL) } }, case neg { --If list_delete HEAD (HEAD::TAIL) isn't big rewrite [Lenght_EQ_Lenght_Set_Delete, nat.right_distrib, nat.one_mul] at mul_lt_l, simp [list_delete, aux.list_size, aux.size, aux.has_size.size] at mul_lt_l, rewrite [←use.GE_iff_Not_LT] at mul_lt_del, rewrite [←use.GE_iff_Not_LT] at num_lt_head, have mul_ge_l, from use.Add_GE_Add num_lt_head mul_lt_del, rewrite [nat.add_assoc, Size_Filter_Delete_EQ_Size] at mul_ge_l, rewrite [use.GE_iff_Not_LT] at mul_ge_l, -- This proof is the same as Main_Combinatory_Nested from absurd mul_lt_l mul_ge_l } } end using_well_founded -- So that the recursion is explicitly done over the list-type { rel_tac := λ _ _, `[exact ⟨_, measure_wf (λ t, list.sizeof t.snd)⟩] } -- L∃∀N gives us a warning that the recursion at Main_Combinatory_Filter is not a well founded relation -- @has_well_founded.r (Σ' (num : ℕ), list α) -- (@has_well_founded.mk (Σ' (num : ℕ), list α) -- (@measure (Σ' (num : ℕ), list α) -- (λ (t : Σ' (num : ℕ), list α), @list.sizeof α (default_has_sizeof α) t.snd)) -- _) -- The nested exception message contains the failure state for the decreasing tactic: -- ⊢ (list_delete HEAD TAIL).sizeof < 1 + 0 + TAIL.sizeof -- However, we show this target is true for all type-instances -- Proving that, despite the warning, the recursion used in Main_Combinatory_Filter is well-founded lemma Well_Founded_Delete {α : Type u} [eqα : decidable_eq α] : ∀(head : α)(tail : list α), --------------------------------- ( list.sizeof (list_delete head tail) < 1 + 0 + list.sizeof tail ) | head [] := begin rewrite [nat.add_zero], simp [list_delete], simp [list.sizeof], have del_lt_sizeof, from nat.add_lt_add_left nat.zero_lt_one 1, rewrite [nat.add_zero] at del_lt_sizeof, from del_lt_sizeof end | head (HEAD::TAIL) := begin rewrite [nat.add_zero], simp [list_delete], with_cases { by_cases eq_head : head = HEAD }, case pos { -- If head = HEAD simp [eq_head], simp [list.sizeof], have loop_0, from Well_Founded_Delete HEAD TAIL, have loop_1, from use.LT_Add_Right loop_0 (sizeof HEAD), rewrite [nat.add_assoc] at loop_1, from use.LT_Add_Left loop_1 1 }, case neg { -- If head ≠ HEAD simp [eq_head], simp [list.sizeof], have loop_0, from Well_Founded_Delete head TAIL, have loop_1, from nat.add_lt_add_left loop_0 (sizeof HEAD), rewrite [←nat.add_assoc] at loop_1, rewrite [nat.add_comm (sizeof HEAD) 1] at loop_1, have loop_2, from nat.add_lt_add_left loop_1 1, rewrite [←nat.add_assoc] at loop_2, from loop_2 } end end a_branch /- Type Definitions and Properties -/ namespace types /- Inductive Types: Formula -/ inductive formula | atom (SBL : ℕ) : formula | implication (ANT CON : formula) : formula export formula (atom implication) notation #SBL := formula.atom SBL notation ANT >> CON := formula.implication ANT CON /- Inductive Types: Proof-Graph -/ inductive node_option | leaf : node_option | node : node_option export node_option (leaf node) inductive tree -- Top Formulas and Hypotheses | leaf (LVL : ℕ) (FML : formula) : tree -- Nodes resulting from →Introduction | u_tree (LVL : ℕ) (FML : formula) (UNI : tree) : tree -- Nodes resulting from →Elimination | lr_tree (LVL : ℕ) (FML : formula) (MNR MJR : tree) : tree export tree (leaf u_tree lr_tree) inductive branch -- The First Node of the Branch (Always a leaf when a Proof-Branch) | leaf (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Nodes resulting from →Introduction | u_branch (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Nodes resulting from →Elimination, connected to their Minor Premise | l_branch (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Nodes resulting from →Elimination, connected to their Major Premise | r_branch (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Pointer to the Ending of the Branch (Always the Root of the Proof-Tree before Pruning) | root : branch export branch (leaf u_branch l_branch r_branch root) /- Instances of Decidability (Equality): Formula -/ instance formula.decidable_eq : ∀(f1 f2 : formula), --------------------------------- decidable (f1 = f2) -- ATOM: | (atom SBL1) (atom SBL2) := begin simp [eq.decidable], from @nat.decidable_eq SBL1 SBL2 end | (atom _) (implication _ _) := begin simp [eq.decidable], from is_false not_false end -- IMPLICATION: | (implication _ _) (atom _) := begin simp [eq.decidable], from is_false not_false end | (implication ANT1 CON1) (implication ANT2 CON2) := begin simp [eq.decidable], from @and.decidable (ANT1 = ANT2) (CON1 = CON2) (@formula.decidable_eq ANT1 ANT2) (@formula.decidable_eq CON1 CON2) end /- Instances of Decidability (Equality): Proof-Graph -/ instance node_option.decidable_eq : ∀(opt1 opt2 : node_option), --------------------------------- decidable (opt1 = opt2) -- LEAF: | leaf leaf := begin simp [eq.decidable], from is_true trivial end | leaf node := begin simp [eq.decidable], from is_false not_false end -- NODE: | node leaf := begin simp [eq.decidable], from is_false not_false end | node node := begin simp [eq.decidable], from is_true trivial end instance tree.decidable_eq : ∀(t1 t2 : tree), --------------------------------- decidable (t1 = t2) -- LEAF: | (leaf LVL1 FML1) (leaf LVL2 FML2) := begin simp [eq.decidable], from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2) end | (leaf _ _) (u_tree _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _) (lr_tree _ _ _ _) := begin simp [eq.decidable], from is_false not_false end -- U_Tree: | (u_tree _ _ UNI1) (leaf _ _) := begin simp [eq.decidable], from is_false not_false end | (u_tree LVL1 FML1 UNI1) (u_tree LVL2 FML2 UNI2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (FML1 = FML2) (UNI1 = UNI2) (@formula.decidable_eq FML1 FML2) (@tree.decidable_eq UNI1 UNI2), from @and.decidable (LVL1 = LVL2) (FML1 = FML2 ∧ UNI1 = UNI2) (@nat.decidable_eq LVL1 LVL2) dec_and1 end | (u_tree _ _ _) (lr_tree _ _ _ _) := begin simp [eq.decidable], from is_false not_false end -- LR_Tree: | (lr_tree _ _ MNR1 MJR1) (leaf _ _) := begin simp [eq.decidable], from is_false not_false end | (lr_tree _ _ MNR1 MJR1) (u_tree _ _ _) := begin simp [eq.decidable], from is_false not_false end | (lr_tree LVL1 FML1 MNR1 MJR1) (lr_tree LVL2 FML2 MNR2 MJR2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (MNR1 = MNR2) (MJR1 = MJR2) (@tree.decidable_eq MNR1 MNR2) (@tree.decidable_eq MJR1 MJR2), have dec_and2, from @and.decidable (FML1 = FML2) (MNR1 = MNR2 ∧ MJR1 = MJR2) (@formula.decidable_eq FML1 FML2) dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2 ∧ MNR1 = MNR2 ∧ MJR1 = MJR2) (@nat.decidable_eq LVL1 LVL2) dec_and2 end instance branch.decidable_eq : ∀(p1 p2 : branch), --------------------------------- decidable (p1 = p2) -- LEAF: | (leaf BRC1 OPT1 LVL1 FML1) (leaf BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (leaf _ _ _ _) (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _ _ _) (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _ _ _) (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- U_Path: | (u_branch _ _ _ _) (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (u_branch BRC1 OPT1 LVL1 FML1) (u_branch BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (u_branch _ _ _ _) (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (u_branch _ _ _ _) (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (u_branch _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- L_Path: | (l_branch _ _ _ _) (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (l_branch _ _ _ _) (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (l_branch BRC1 OPT1 LVL1 FML1) (l_branch BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (l_branch _ _ _ _) (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (l_branch _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- R_Path: | (r_branch _ _ _ _) (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (r_branch _ _ _ _) (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (r_branch _ _ _ _) (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (r_branch BRC1 OPT1 LVL1 FML1) (r_branch BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (r_branch _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- ROOT: | root (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root root := begin simp [eq.decidable], from is_true trivial end /- Get Methods: Formula -/ def is_atomic : formula → Prop | (atom _) := true | (implication _ _) := false instance formula.is_atomic : ∀(f : formula), --------------------------------- decidable (is_atomic f) | (atom _) := begin simp [is_atomic], from is_true trivial end | (implication _ _) := begin simp [is_atomic], from is_false not_false end def not_atomic : formula → Prop | (atom _) := false | (implication _ _) := true instance formula.not_atomic : ∀(f : formula), --------------------------------- decidable (not_atomic f) | (atom _) := begin simp [not_atomic], from is_false not_false end | (implication _ _) := begin simp [not_atomic], from is_true trivial end def get_antecedent : formula → formula | (atom SBL) := #0 -- NULL | (implication ANT _) := ANT def get_consequent : formula → formula | (atom SBL) := #0 -- NULL | (implication _ CON) := CON /- Get Methods: Proof-Graph -/ def not_root : branch → Prop | (leaf _ _ _ _) := true | (u_branch _ _ _ _) := true | (l_branch _ _ _ _) := true | (r_branch _ _ _ _) := true | root := false instance branch.not_root : ∀(b : branch), --------------------------------- decidable (not_root b) | (leaf _ _ _ _) := begin simp [not_root], from is_true trivial end | (u_branch _ _ _ _) := begin simp [not_root], from is_true trivial end | (l_branch _ _ _ _) := begin simp [not_root], from is_true trivial end | (r_branch _ _ _ _) := begin simp [not_root], from is_true trivial end | root := begin simp [not_root], from is_false not_false end def get_option : branch → node_option | (leaf _ OPT _ _) := OPT | (u_branch _ OPT _ _) := OPT | (l_branch _ OPT _ _) := OPT | (r_branch _ OPT _ _) := OPT | root := node -- NULL def get_level : branch → ℕ | (leaf _ _ LVL _) := LVL | (u_branch _ _ LVL _) := LVL | (l_branch _ _ LVL _) := LVL | (r_branch _ _ LVL _) := LVL | root := 0 -- NULL def get_formula : branch → formula | (leaf _ _ _ FML) := FML | (u_branch _ _ _ FML) := FML | (l_branch _ _ _ FML) := FML | (r_branch _ _ _ FML) := FML | root := #0 -- NULL /- Numbber of Levels and Formulas -/ def list_levels : tree → list (ℕ) | (leaf LVL _) := [LVL] | (u_tree LVL _ UNI) := if LVL ∈ list_levels UNI then list_levels UNI else [LVL] ++ list_levels UNI | (lr_tree LVL _ MNR MJR) := if LVL ∈ (list_levels MNR ∩ list_levels MJR) then (list_levels MNR ∩ list_levels MJR) else [LVL] ++ (list_levels MNR ∩ list_levels MJR) def list_formulas : tree → list (formula) | (leaf _ FML) := [FML] | (u_tree _ FML UNI) := if FML ∈ list_formulas UNI then list_formulas UNI else [FML] ++ list_formulas UNI | (lr_tree _ FML MNR MJR) := if FML ∈ (list_formulas MNR ∩ list_formulas MJR) then (list_formulas MNR ∩ list_formulas MJR) else [FML] ++ (list_formulas MNR ∩ list_formulas MJR) def count_levels : tree → ℕ | t := list.length (list_levels t) def count_formulas : tree → ℕ | t := list.length (list_formulas t) /- For this proof, trees are viewed as lists of nodes(which are also trees) -/ -- The lists are arranged in an orderly fashion, splitting the tree by types of node, levels, and formulas -- The lists return a branch from the original tree's root to a node given by the by type/level/formula def loop_tree_option_level_formula : branch → tree → node_option → ℕ → formula → list (branch) -- Matched node_option with the type of tree constructor | BRC (leaf LVL FML) leaf lvl fml := if LVL=lvl ∧ FML=fml then [leaf BRC leaf LVL FML] else [] | BRC (u_tree LVL FML UNI) node lvl fml := if LVL=lvl ∧ FML=fml then [leaf BRC node LVL FML] else loop_tree_option_level_formula (u_branch BRC node LVL FML) UNI node lvl fml | BRC (lr_tree LVL FML MNR MJR) node lvl fml := if LVL=lvl ∧ FML=fml then [leaf BRC node LVL FML] else loop_tree_option_level_formula (l_branch BRC node LVL FML) MNR node lvl fml ++ loop_tree_option_level_formula (r_branch BRC node LVL FML) MJR node lvl fml -- Mismatched node_option with the type of tree constructor | BRC (leaf LVL FML) node lvl fml := [] | BRC (u_tree LVL FML UNI) leaf lvl fml := loop_tree_option_level_formula (u_branch BRC node LVL FML) UNI leaf lvl fml | BRC (lr_tree LVL FML MNR MJR) leaf lvl fml := loop_tree_option_level_formula (l_branch BRC node LVL FML) MNR leaf lvl fml ++ loop_tree_option_level_formula (r_branch BRC node LVL FML) MJR leaf lvl fml -- Returns all the nodes in the tree, with a given constructor, at a given level, and with a specific formula def list_tree_option_level_formula : tree → node_option → ℕ → formula → list (branch) | t opt lvl fml := loop_tree_option_level_formula root t opt lvl fml -- Returns all the nodes in the tree, with a given constructor, and at a given level def loop_tree_option_level : tree → node_option → ℕ → list (formula) → list (list (branch)) | t opt lvl [] := [] | t opt lvl (HEAD::TAIL) := [list_tree_option_level_formula t opt lvl HEAD] ++ loop_tree_option_level t opt lvl TAIL def list_tree_option_level : tree → node_option → ℕ → list (list (branch)) | t opt lvl := loop_tree_option_level t opt lvl (list_formulas t) -- Returns all the nodes in the tree, with a given constructor def loop_tree_option :tree → node_option → list (ℕ) → list (list (list (branch))) | t opt [] := [] | t opt (HEAD::TAIL) := [list_tree_option_level t opt HEAD] ++ loop_tree_option t opt TAIL def list_tree_option : tree → node_option → list (list (list (branch))) | t opt := loop_tree_option t opt (list_levels t) -- Returns all the nodes in the tree def list_tree : tree → list (list (list (list (branch)))) | t := [list_tree_option t leaf] ++ [list_tree_option t node] /- Prooving the correctness of the list_tree_option_level_formula method -/ lemma Loop_Level_Formula_Option : ∀(mem b : branch)(t : tree)(opt : node_option)(lvl : ℕ)(fml : formula), ( mem ∈ loop_tree_option_level_formula b t opt lvl fml ) → --------------------------- ( (get_option mem = opt) ∧ (get_level mem = lvl) ∧ (get_formula mem = fml) ) -- When mem and opt match | mem BRC (leaf LVL FML) leaf lvl fml := begin assume mem_node, -- Simplifying ∈ at the condition(mem_node) simp [loop_tree_option_level_formula] at mem_node, simp [has_mem.mem] at mem_node, simp [use.ITE_Distribution (list.mem mem)] at mem_node, simp [list.mem] at mem_node, -- Cases over (LVL=lvl ∧ FML=fml) with_cases { by_cases and_eq : (LVL=lvl ∧ FML=fml) }, case pos { simp [and_eq] at mem_node, simp [mem_node, get_option, get_level, get_formula] }, -- The case where ¬(LVL=lvl ∧ FML=fml) is impossible, since b ∉ [] case neg { simp [and_eq] at mem_node, from false.elim mem_node } end | mem BRC (u_tree LVL FML UNI) node lvl fml := begin assume mem_node, -- Simplifying ∈ at the condition(mem_node) simp [loop_tree_option_level_formula] at mem_node, simp [has_mem.mem] at mem_node, simp [use.ITE_Distribution (list.mem mem)] at mem_node, simp [list.mem] at mem_node, -- Cases over (LVL=lvl ∧ FML=fml) with_cases { by_cases and_eq : (LVL=lvl ∧ FML=fml) }, case pos { simp [and_eq] at mem_node, simp [mem_node, get_option, get_level, get_formula] }, -- The case where ¬(LVL=lvl ∧ FML=fml) continues up the single child case neg { simp [and_eq] at mem_node, from Loop_Level_Formula_Option mem (u_branch BRC node LVL FML) UNI node lvl fml mem_node } end | mem BRC (lr_tree LVL FML MNR MJR) node lvl fml := begin assume mem_node, -- Simplifying ∈ at the condition(mem_node) simp [loop_tree_option_level_formula] at mem_node, simp [has_mem.mem] at mem_node, simp [use.ITE_Distribution (list.mem mem)] at mem_node, simp [list.mem] at mem_node, -- Cases over (LVL=lvl ∧ FML=fml) with_cases { by_cases and_eq : (LVL=lvl ∧ FML=fml) }, case pos { simp [and_eq] at mem_node, simp [mem_node, get_option, get_level, get_formula] }, -- The case where ¬(LVL=lvl ∧ FML=fml) continues up both children case neg { simp [and_eq] at mem_node, -- Using the relation between append[++] and or[∨] regarding item membership over lists have or_mem_node, from (iff.elim_left list.mem_append) mem_node, cases or_mem_node with mem_node mem_node, case or.inl { from Loop_Level_Formula_Option mem (l_branch BRC node LVL FML) MNR node lvl fml mem_node }, case or.inr { from Loop_Level_Formula_Option mem (r_branch BRC node LVL FML) MJR node lvl fml mem_node } } end -- When mem and opt don't match | mem BRC (leaf LVL FML) node lvl fml := begin assume mem_node, simp [loop_tree_option_level_formula] at mem_node, from false.elim mem_node end | mem BRC (u_tree LVL FML UNI) leaf lvl fml := begin assume mem_node, simp [loop_tree_option_level_formula] at mem_node, from Loop_Level_Formula_Option mem (u_branch BRC node LVL FML) UNI leaf lvl fml mem_node end | mem BRC (lr_tree LVL FML MNR MJR) leaf lvl fml := begin simp [loop_tree_option_level_formula], assume mem_node, cases mem_node, case or.inl { from Loop_Level_Formula_Option mem (l_branch BRC node LVL FML) MNR leaf lvl fml mem_node }, case or.inr { from Loop_Level_Formula_Option mem (r_branch BRC node LVL FML) MJR leaf lvl fml mem_node } end lemma From_Level_Formula_Option : ∀(mem : branch)(t : tree)(opt : node_option)(lvl : ℕ)(fml : formula), ( mem ∈ list_tree_option_level_formula t opt lvl fml ) → --------------------------- ( (get_option mem = opt) ∧ (get_level mem = lvl) ∧ (get_formula mem = fml) ) | mem t opt lvl fml := begin assume mem_node, simp [list_tree_option_level_formula] at mem_node, from Loop_Level_Formula_Option mem root t opt lvl fml mem_node end end types export types.formula (atom implication) export types.node_option (leaf node) export types.tree (leaf u_tree lr_tree) export types.branch (leaf u_branch l_branch r_branch root) /- Proof: Leaf Redundancy -/ namespace p_leaf /- Restrictions Regarding Proof-Trees -/ -- Trees must be finite, meaning that every node must have a path ending on a leaf def is_finite : types.tree → Prop | t := ∀(lvl : ℕ), --------------------------- ( aux.list_size (types.list_tree_option_level t node lvl) ≤ aux.list_size (types.list_tree_option t leaf) ) lemma Case_Option : ∀(t : types.tree), ∀(lll : list (list (list (types.branch)))), ( lll ∈ (types.list_tree t ) ) → --------------------------- ( ∃(opt : types.node_option), lll = types.list_tree_option t opt ) | t lll := begin assume or_eq, simp [types.list_tree] at or_eq, -- ∨-Elimination cases or_eq with eq_leaf eq_node, case or.inl { from exists.intro leaf eq_leaf }, case or.inr { from exists.intro node eq_node } end lemma Length_Tree : ∀(t : types.tree), --------------------------- ( 2 = list.length (types.list_tree t) ) | t := by simp [types.list_tree] lemma Tree_to_Option : ∀(t : types.tree), ∀{num : ℕ}, ( 2 * num < aux.list_size (types.list_tree t) ) → --------------------------- ( ∃(opt : types.node_option), num < aux.list_size (types.list_tree_option t opt) ) | t n := begin assume big_tree, -- Combinatory Property rewrite [Length_Tree t] at big_tree, have main_combinatory, from a_leaf.Main_Combinatory_Nested big_tree, cases main_combinatory with list_opt main_combinatory, cases main_combinatory with list_mem main_combinatory, -- Substitution have case_opt, from Case_Option t list_opt list_mem, cases case_opt with opt case_opt, rewrite [case_opt] at main_combinatory, -- ∃-Introduction from exists.intro opt main_combinatory end lemma Case_Level : ∀(t : types.tree)(opt : types.node_option)(loop : list (ℕ)), ∀(ll : list (list (types.branch))), ( ll ∈ types.loop_tree_option t opt loop ) → --------------------------- ( ∃(lvl : ℕ), lvl ∈ loop ∧ ll = types.list_tree_option_level t opt lvl ) | t opt [] ll := begin assume ll_mem, simp [types.loop_tree_option] at ll_mem, from false.elim ll_mem end | t opt (HEAD::TAIL) ll := begin simp [types.loop_tree_option], assume or_eq_mem, cases or_eq_mem with eq_head list_mem, case or.inl { apply exists.intro HEAD, simp [eq.refl HEAD], from eq_head }, case or.inr { have case_inductive, from Case_Level t opt TAIL ll list_mem, cases case_inductive with lvl case_inductive, apply exists.intro lvl, cases case_inductive with mem_lvl eq_lllt, simp [mem_lvl], from eq_lllt } end lemma Length_Tree_Option : ∀(t : types.tree)(opt : types.node_option), --------------------------- ( types.count_levels t = list.length (types.list_tree_option t opt) ) | t opt := begin simp [types.list_tree_option, types.count_levels], induction (types.list_levels t), case list.nil { simp [types.loop_tree_option] }, case list.cons { simp [types.loop_tree_option, ih] } end lemma Option_to_Level : ∀(t : types.tree)(opt : types.node_option), ∀{num : ℕ}, ( (types.count_levels t) * num < aux.list_size (types.list_tree_option t opt) ) → --------------------------- ( ∃(lvl : ℕ), lvl ∈ types.list_levels t ∧ num < aux.list_size (types.list_tree_option_level t opt lvl) ) | t opt num := begin assume big_option, -- Combinatory Property rewrite [Length_Tree_Option t opt] at big_option, have main_combinatory, from a_leaf.Main_Combinatory_Nested big_option, cases main_combinatory with list_lvl main_combinatory, cases main_combinatory with list_mem main_combinatory, -- Substitution have case_level, from Case_Level t opt (types.list_levels t) list_lvl list_mem, cases case_level with lvl case_level, cases case_level with mem_lvl case_level, rewrite [case_level] at main_combinatory, -- ∃-Introduction and ∧-Introduction apply exists.intro lvl, from and.intro mem_lvl main_combinatory end lemma Case_Formula : ∀(t : types.tree)(opt : types.node_option)(lvl : ℕ)(loop : list (types.formula)), ∀(l : list (types.branch)), ( l ∈ types.loop_tree_option_level t opt lvl loop ) → --------------------------- ( ∃(fml : types.formula), fml ∈ loop ∧ l = types.list_tree_option_level_formula t opt lvl fml ) | t opt lvl [] ll := begin assume l_mem, simp [types.loop_tree_option_level] at l_mem, from false.elim l_mem end | t opt lvl (HEAD::TAIL) ll := begin simp [types.loop_tree_option_level], assume or_eq_mem, cases or_eq_mem with eq_head list_mem, case or.inl { apply exists.intro HEAD, simp [eq.refl HEAD], from eq_head }, case or.inr { have case_inductive, from Case_Formula t opt lvl TAIL ll list_mem, cases case_inductive with fml case_inductive, apply exists.intro fml, cases case_inductive with mem_fml eq_llt, simp [mem_fml], from eq_llt } end lemma Length_Tree_Option_Level: ∀(t : types.tree)(opt : types.node_option)(lvl : ℕ), --------------------------- ( types.count_formulas t = list.length (types.list_tree_option_level t opt lvl) ) | t opt lvl := begin simp [types.list_tree_option_level, types.count_formulas], induction (types.list_formulas t), case list.nil { simp [types.loop_tree_option_level] }, case list.cons { simp [types.loop_tree_option_level, ih] } end lemma Level_to_Formula : ∀(t : types.tree)(opt : types.node_option)(lvl : ℕ), ∀{num : ℕ}, ( (types.count_formulas t) * num < aux.list_size (types.list_tree_option_level t opt lvl) ) → --------------------------- ( ∃(fml : types.formula), fml ∈ types.list_formulas t ∧ num < aux.list_size (types.list_tree_option_level_formula t opt lvl fml) ) | t opt lvl num := begin assume big_option_level, -- Combinatory Property rewrite [Length_Tree_Option_Level t opt lvl] at big_option_level, have main_combinatory, from a_leaf.Main_Combinatory_Nested big_option_level, cases main_combinatory with list_fml main_combinatory, cases main_combinatory with list_mem main_combinatory, -- Substitution have case_fml, from Case_Formula t opt lvl (types.list_formulas t) list_fml list_mem, cases case_fml with fml case_fml, cases case_fml with mem_fml case_fml, rewrite [case_fml] at main_combinatory, -- ∃-Introduction and ∧-Introduction apply exists.intro fml, from and.intro mem_fml main_combinatory end lemma Option_to_Leaf : ∀(t : types.tree)(opt : types.node_option), ∀{num : ℕ}, ( is_finite t ) → ( (types.count_levels t) * num < aux.list_size (types.list_tree_option t opt) ) → --------------------------- ( num < aux.list_size (types.list_tree_option t leaf) ) | t leaf num := begin assume finite big_option, have levels_pos, from aux.ZERO_LT_Length_of_LT_Size big_option, rewrite [←Length_Tree_Option t leaf] at levels_pos, have le_mul, from use.LE_Mul_Left_of_Pos levels_pos num, from nat.lt_of_le_of_lt le_mul big_option end | t node num := begin assume finite big_option, have big_lrnode_level, from Option_to_Level t node big_option, cases big_lrnode_level with lvl big_lrnode_level, cases big_lrnode_level with mem_lvl big_lrnode, from nat.lt_of_lt_of_le big_lrnode (finite lvl) end theorem Main_Theorem_Leaves : ∀(t : types.tree)(mul num : ℕ), ( is_finite t ) → ( mul = (2 * (types.count_levels t * (types.count_levels t * (types.count_formulas t * (types.count_formulas t * num))))) ) → ( mul < aux.list_size (types.list_tree t) ) → --------------------------- ( ∃(lvl : ℕ)(fml : types.formula), lvl ∈ types.list_levels t ∧ fml ∈ types.list_formulas t ∧ (types.count_formulas t) * num < aux.list_size (types.list_tree_option_level_formula t leaf lvl fml) ) | t mul num := begin assume finite mul_constant big_tree, rewrite [mul_constant] at big_tree, -- Find a redundant type-constructor within the tree: have big_option, from Tree_to_Option t big_tree, cases big_option with opt big_option, -- Since the tree is finite, there must be a redundant number of leaves within the tree: have big_leaf, from Option_to_Leaf t opt finite big_option, -- Find a redundant level within the repeating leaf-constructor: have big_leaf_level, from Option_to_Level t leaf big_leaf, cases big_leaf_level with lvl big_leaf_level, cases big_leaf_level with mem_lvl big_leaf_level, apply exists.intro lvl, simp [mem_lvl], -- Find a redundant formula within the repeating leaf-constructor/level: have big_leaf_level_formula, from Level_to_Formula t leaf lvl big_leaf_level, cases big_leaf_level_formula with fml big_leaf_level_formula, cases big_leaf_level_formula with mem_fml big_leaf_level_formula, apply exists.intro fml, simp [mem_fml], from big_leaf_level_formula end end p_leaf /- Proof: Leaf Redundancy Implies Proof-Branch Redundancy -/ namespace p_branch /- Methods Regarding Proof-Branchs (Prop) -/ -- Proofs and Derivations in Natural Deduction can be seen as Proof-Trees -- Proofs have no open formulas, while Derivations may have open formulas -- In a Normal Proof-Tree, every Leaf is part of a Proof-Branch -- A Proof-Branch can be obtained by pruning the Branch which connects its Leaf to the proof's conclusion -- This pruning is done top-down, from the Leaf to either the minor premise of an →ELIMINATION or the proof's conclusion -- Along the pruning, if a visited node in the unpruned Branch is the result of an: -- →ELIMINATION from its major premise: visited node = CON; visited premise = _ >> CON; the Proof-Branch continues -- →ELIMINATION from its minor premise: visited node = some formula; the Proof-Branch ends at the visited premise -- →INTRODUCTION: -- In a Normal Proof-Tree, an →INTRODUCTION can only be followed by an: -- →INTRODUCTION: visited node = _ >> CON; visited premise = CON; the Proof-Branch continues -- →ELIMINATION from its minor premise: visited node = some formula; the Proof-Branch ends at the visited premise -- The proof's conclusion: the Proof-Branch ends at the proof's conclusion -- But no matter where this →INTRODUCTION sequence ends, the formula where it ends determines the sequence -- Every Proof-Branch of a Normal Proof-Tree is either: -- Composed of an →ELIMINATION (from its major premise) part followed by an →INTRODUCTION part -- Composed of an →ELIMINATION (from its major premise) only -- Composed of an →INTRODUCTION only -- A Leaf that is the minor premise of an →ELIMINATION -- In an Atomicaly Expanded Normal Proof-Tree: -- If there is an →ELIMINATION part, it ends in a atomic formula -- If there is an →INTRODUCTION part, it begins in a atomic formula -- That is to say, in an Atomicaly Expanded Normal Proof-Tree: -- The Proof-Branch's Leaf determines completely the →ELIMINATION part -- The Proof-Branch's Ending Formula completely determines the →INTRODUCTION part -- Loops over the →INTRODUCTION part def loop_check_intro : ℕ → types.formula → types.branch → Prop | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1 ) ∧ loop_check_intro LVL0 FML0 BRC | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) | lvl1 fml1 root := ( lvl1 = 1 ) | _ _ _ := false -- Loops over the →ELIMINATION part and verifies if the minimal formula is atomic def loop_check_elim : ℕ → types.formula → types.branch → Prop | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1 ) ∧ loop_check_intro LVL0 FML0 BRC | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.is_atomic fml1 ) | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0 ) ∧ loop_check_elim LVL0 FML0 BRC | lvl1 fml1 root := ( lvl1 = 1 ) ∧ ( types.is_atomic fml1 ) | _ _ _ := false -- Verifies the type of branch (→ELIMINATION→INTRODUCTION; →ELIMINATION; →INTRODUCTION; Leaf) def check_leaf : ℕ → types.formula → types.branch → Prop | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1 ) ∧ loop_check_intro LVL0 FML0 BRC | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0 ) ∧ loop_check_elim LVL0 FML0 BRC | _ _ _ := false -- To check if a regular Branch, ending at the Proof-Tree's conclusion, can be pruned into a Proof-Branch def check_proof_branch : types.branch → Prop | (leaf BRC leaf LVL0 FML0) := check_leaf LVL0 FML0 BRC | _ := false -- Using check_proof_branch as an if-clause demands a proof of decidability for each method instance types.branch.loop_check_intro : ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), --------------------------------- decidable (loop_check_intro lvl1 fml1 b) | _ _ (leaf _ _ _ _) := begin simp [loop_check_intro], from is_false not_false end | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := begin simp [loop_check_intro], have dec_and1, from @and.decidable (types.not_atomic FML0) (types.get_consequent FML0 = fml1) (@types.formula.not_atomic FML0) (@types.formula.decidable_eq (types.get_consequent FML0) fml1), have dec_and2, from @and.decidable (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (loop_check_intro LVL0 FML0 BRC) dec_and1 (@types.branch.loop_check_intro LVL0 FML0 BRC), have dec_and3, from @and.decidable (lvl1 = LVL0+1) ((types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and2, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and3 end | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := begin simp [loop_check_intro], from @and.decidable (OPT = node) (lvl1 = LVL0 + 1) (@types.node_option.decidable_eq OPT node) (@nat.decidable_eq lvl1 (LVL0+1)) end | _ _ (r_branch _ _ _ _) := begin simp [loop_check_intro], from is_false not_false end | lvl1 fml1 root := begin simp [loop_check_intro], from @nat.decidable_eq lvl1 1 end instance types.branch.loop_check_elim : ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), --------------------------------- decidable (loop_check_elim lvl1 fml1 b) | _ _ (leaf _ _ _ _) := begin simp [loop_check_elim], from is_false not_false end | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := begin simp [loop_check_elim], have dec_and1, from @and.decidable (types.not_atomic FML0) (types.get_consequent FML0 = fml1) (@types.formula.not_atomic FML0) (@types.formula.decidable_eq (types.get_consequent FML0) fml1), have dec_and2, from @and.decidable (types.is_atomic fml1) (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (@types.formula.is_atomic fml1) dec_and1, have dec_and3, from @and.decidable (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (loop_check_intro LVL0 FML0 BRC) dec_and2 (@types.branch.loop_check_intro LVL0 FML0 BRC), have dec_and4, from @and.decidable (lvl1 = LVL0+1) ((types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and3, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and4 end | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := begin simp [loop_check_elim], have dec_and1, from @and.decidable (lvl1 = LVL0 + 1) (types.is_atomic fml1) (@nat.decidable_eq lvl1 (LVL0+1)) (@types.formula.is_atomic fml1), from @and.decidable (OPT = node) (lvl1 = LVL0 + 1 ∧ types.is_atomic fml1) (@types.node_option.decidable_eq OPT node) dec_and1 end | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := begin simp [loop_check_elim], have dec_and1, from @and.decidable (types.not_atomic fml1) (types.get_consequent fml1 = FML0) (@types.formula.not_atomic fml1) (@types.formula.decidable_eq (types.get_consequent fml1) FML0), have dec_and2, from @and.decidable (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) (loop_check_elim LVL0 FML0 BRC) dec_and1 (@types.branch.loop_check_elim LVL0 FML0 BRC), have dec_and3, from @and.decidable (lvl1 = LVL0+1) ((types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and2, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and3 end | lvl1 fml1 root := begin simp [loop_check_elim], from @and.decidable (lvl1 = 1) (types.is_atomic fml1) (@nat.decidable_eq lvl1 1) (@types.formula.is_atomic fml1) end instance types.branch.check_leaf : ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), --------------------------------- decidable (check_leaf lvl1 fml1 b) | _ _ (leaf _ _ _ _) := begin simp [check_leaf], from is_false not_false end | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := begin simp [check_leaf], have dec_and1, from @and.decidable (types.not_atomic FML0) (types.get_consequent FML0 = fml1) (@types.formula.not_atomic FML0) (@types.formula.decidable_eq (types.get_consequent FML0) fml1), have dec_and2, from @and.decidable (types.is_atomic fml1) (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (@types.formula.is_atomic fml1) dec_and1, have dec_and3, from @and.decidable (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (loop_check_intro LVL0 FML0 BRC) dec_and2 (@types.branch.loop_check_intro LVL0 FML0 BRC), have dec_and4, from @and.decidable (lvl1 = LVL0+1) ((types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and3, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and4 end | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := begin simp [check_leaf], from @and.decidable (OPT = node) (lvl1 = LVL0 + 1) (@types.node_option.decidable_eq OPT node) (@nat.decidable_eq lvl1 (LVL0+1)) end | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := begin simp [check_leaf], have dec_and1, from @and.decidable (types.not_atomic fml1) (types.get_consequent fml1 = FML0) (@types.formula.not_atomic fml1) (@types.formula.decidable_eq (types.get_consequent fml1) FML0), have dec_and2, from @and.decidable (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) (loop_check_elim LVL0 FML0 BRC) dec_and1 (@types.branch.loop_check_elim LVL0 FML0 BRC), have dec_and3, from @and.decidable (lvl1 = LVL0+1) ((types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and2, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and3 end | _ _ root := begin simp [check_leaf], from is_false not_false end instance types.branch.check_proof_branch : ∀(b : types.branch), --------------------------------- decidable (check_proof_branch b) | (leaf BRC leaf LVL0 FML0) := begin simp [check_proof_branch], from @types.branch.check_leaf LVL0 FML0 BRC end | (leaf _ node _ _) := begin simp [check_proof_branch], from is_false not_false end | (u_branch _ _ _ _) := begin simp [check_proof_branch], from is_false not_false end | (l_branch _ _ _ _) := begin simp [check_proof_branch], from is_false not_false end | (r_branch _ _ _ _) := begin simp [check_proof_branch], from is_false not_false end | root := begin simp [check_proof_branch], from is_false not_false end /- Methods Regarding Proof-Branchs (Formulas) -/ -- Finally, the pruning, per se def loop_prune_intro : ℕ → types.formula → types.branch → types.formula | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := if loop_check_intro lvl1 fml1 (u_branch BRC OPT LVL0 FML0) then loop_prune_intro LVL0 FML0 BRC else #0 --false | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := if loop_check_intro lvl1 fml1 (l_branch BRC OPT LVL0 FML0) then fml1 else #0 --false | lvl1 fml1 root := if loop_check_intro lvl1 fml1 root then fml1 else #0 --false | _ _ _ := #0 --false def loop_prune_elim : ℕ → types.formula → types.branch → types.formula | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := if loop_check_elim lvl1 fml1 (u_branch BRC OPT LVL0 FML0) then loop_prune_intro LVL0 FML0 BRC else #0 --false | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := if loop_check_elim lvl1 fml1 (l_branch BRC OPT LVL0 FML0) then fml1 else #0 --false | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := if loop_check_elim lvl1 fml1 (r_branch BRC OPT LVL0 FML0) then loop_prune_elim LVL0 FML0 BRC else #0 --false | lvl1 fml1 root := if loop_check_elim lvl1 fml1 root then fml1 else #0 --false | _ _ _ := #0 --false def prune_leaf : ℕ → types.formula → types.branch → types.formula | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := if check_leaf lvl1 fml1 (u_branch BRC OPT LVL0 FML0) then loop_prune_intro LVL0 FML0 BRC else #0 --false | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := if check_leaf lvl1 fml1 (l_branch BRC OPT LVL0 FML0) then fml1 else #0 --false | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := if check_leaf lvl1 fml1 (r_branch BRC OPT LVL0 FML0) then loop_prune_elim LVL0 FML0 BRC else #0 --false | _ _ _ := #0 --false def prune_proof_branch : types.branch → types.formula | (leaf BRC leaf LVL0 FML0) := prune_leaf LVL0 FML0 BRC | _ := #0 --false def prune_branch : types.branch → (types.formula) | (leaf BRC leaf LVL FML) := #0 | _ := #0 --false -- Defining a method to prune all the branches in a list of branches def prune_list_branch : list (types.branch) → list (types.formula) | [] := [] | (HEAD::TAIL) := if check_proof_branch HEAD then [prune_branch HEAD] ++ prune_list_branch TAIL else prune_list_branch TAIL -- def list_proof_branch_root : types.tree → types.node_option → ℕ → types.formula→ types.formula → list (types.formula) | t opt lvl1 fml1 fml0 := a_branch.list_filter fml0 (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1)) /- Restrictions Regarding Proof-Branchs -/ -- In a Normal Proof-Tree, every Leaf is part of a Proof-Branch def is_normal_check : types.tree → Prop | t := ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), ( b ∈ (types.list_tree_option_level_formula t leaf lvl1 fml1) ) → --------------------------- ( check_proof_branch b ) def is_normal_mem : types.tree → Prop | t := ∀(lvl1 : ℕ)(fml1 fml0 : types.formula), ( fml0 ∈ prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1) ) → --------------------------- ( fml0 ∈ types.list_formulas t ) lemma Case_Size : ∀{t : types.tree}{lvl1 : ℕ}{fml1 : types.formula}, ∀{l : list (types.branch)}, ( is_normal_check t ) → ( ∀(b : types.branch), b ∈ l → b ∈ types.list_tree_option_level_formula t leaf lvl1 fml1 ) → --------------------------- ( aux.list_size l = aux.list_size (prune_list_branch l) ) | t lvl1 fml1 [] := begin assume normal_check subset, simp [prune_list_branch, aux.list_size] end | t lvl1 fml1 (HEAD::TAIL) := begin assume normal_check subset, have head_mem : HEAD ∈ types.list_tree_option_level_formula t leaf lvl1 fml1, from begin apply (subset HEAD), simp [has_mem.mem, list.mem] end, have tail_subset : ∀(b : types.branch), b ∈ TAIL → b ∈ types.list_tree_option_level_formula t leaf lvl1 fml1, from begin assume loop loop_mem_tail, apply (subset loop), simp [has_mem.mem, list.mem] at ⊢ loop_mem_tail, simp [loop_mem_tail] end, simp [prune_list_branch], rewrite [use.ITE_Distribution (aux.list_size)], simp [aux.list_size, aux.size, aux.has_size.size], have check_head, from normal_check lvl1 fml1 HEAD head_mem, simp [implies, has_mem.mem, list.mem] at check_head, simp [check_head], rewrite [Case_Size normal_check tail_subset] end lemma Normal_Size : ∀(t : types.tree)(lvl1 : ℕ)(fml1 : types.formula), ( is_normal_check t ) → --------------------------- ( aux.list_size (types.list_tree_option_level_formula t leaf lvl1 fml1) = aux.list_size (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1)) ) | t lvl1 fml1 := begin assume normal_check, from Case_Size normal_check (use.Subset_Self (types.list_tree_option_level_formula t leaf lvl1 fml1)) end lemma Case_Set : ∀(t : types.tree)(lvl1 : ℕ)(fml1 : types.formula)(n : ℕ), ( is_normal_mem t ) → --------------------------- ( list.length (a_branch.list_set (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1))) * n ≤ list.length (types.list_formulas t) * n ) | t lvl1 fml1 n := begin assume normal_mem, have set_le_formulas, from a_branch.Length_Set_LE_Length_of_Subset (normal_mem lvl1 fml1), from use.LE_Mul_of_LE n set_le_formulas end theorem Main_Theorem_Branchs : ∀(t : types.tree)(lvl1 : ℕ)(fml1 : types.formula)(num : ℕ), ( is_normal_check t ) → ( is_normal_mem t ) → ( (types.count_formulas t) * num < aux.list_size (types.list_tree_option_level_formula t leaf lvl1 fml1) ) → --------------------------- ( ∃(fml0 : types.formula), fml0 ∈ prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1) ∧ num < aux.list_size (list_proof_branch_root t leaf lvl1 fml1 fml0) ) | t lvl1 fml1 num := begin assume normal_check normal_mem big_leaf_level_formula, simp [list_proof_branch_root, aux.list_size] at ⊢ big_leaf_level_formula, simp [types.count_formulas, nat.mul_assoc] at big_leaf_level_formula, rewrite [Normal_Size t lvl1 fml1 normal_check] at big_leaf_level_formula, -- have main_combinatory, from a_branch.Main_Combinatory_Filter num (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1)), -- have case_set, from Case_Set t lvl1 fml1 num normal_mem, have big_branch, from main_combinatory (nat.lt_of_le_of_lt case_set big_leaf_level_formula), cases big_branch with fml0 big_branch, cases big_branch with mem_fml0 big_branch, apply exists.intro fml0, simp [mem_fml0], from big_branch end end p_branch /- Proof: Theorem of Proof-Branch Redundancy -/ theorem Proof_Branch_Redundancy : ∀(t : types.tree)(mul num : ℕ), ( p_leaf.is_finite t ) → ( p_branch.is_normal_check t ) → ( p_branch.is_normal_mem t ) → ( mul = (2 * (types.count_levels t * (types.count_levels t * (types.count_formulas t * (types.count_formulas t * num))))) ) → ( mul < aux.list_size (types.list_tree t) ) → --------------------------- ( ∃(lvl1 : ℕ)(fml1 fml0 : types.formula), lvl1 ∈ types.list_levels t ∧ fml1 ∈ types.list_formulas t ∧ fml0 ∈ p_branch.prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1) ∧ num < aux.list_size (p_branch.list_proof_branch_root t leaf lvl1 fml1 fml0) ) | t mul num := begin assume finite normal_check normal_mem mul_constant big_tree, -- Find a repeating leaf-constructor/level/formula: have big_leaf_level_formula, from p_leaf.Main_Theorem_Leaves t mul num finite mul_constant big_tree, cases big_leaf_level_formula with lvl1 big_leaf_level_formula, cases big_leaf_level_formula with fml1 big_leaf_level_formula, cases big_leaf_level_formula with mem_lvl1 big_leaf_level_formula, cases big_leaf_level_formula with mem_fml1 big_leaf_level_formula, apply exists.intro lvl1, simp [mem_lvl1], apply exists.intro fml1, simp [mem_fml1], -- Find a redundant proof-branch from the repeating leaf-constructor/level/formula: have big_branch, from p_branch.Main_Theorem_Branchs t lvl1 fml1 num normal_check normal_mem big_leaf_level_formula, cases big_branch with fml0 big_branch, cases big_branch with mem_fml0 big_branch, apply exists.intro fml0, simp [mem_fml0], from big_branch end
\chapter*{Preface} This is an example of ``frontmatter'', which comes before the main text of the book. Note the asterisk after the chapter command (``chapter star''), which suppresses \LaTeX's default numbering.
[STATEMENT] lemma (in -) GS_initial_correct: assumes REL: "(I,D)\<in>oGS_rel" assumes A: "v0\<notin>D" shows "GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}],D,{v0}\<times>succs)" (is ?G1) and "GS_invar (GS_initial_impl I v0 succs)" (is ?G2) [PROOF STATE] proof (prove) goal (1 subgoal): 1. GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}], D, {v0} \<times> succs) &&& GS_invar (GS_initial_impl I v0 succs) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (2 subgoals): 1. GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}], D, {v0} \<times> succs) 2. GS_invar (GS_initial_impl I v0 succs) [PROOF STEP] from REL [PROOF STATE] proof (chain) picking this: (I, D) \<in> oGS_rel [PROOF STEP] have [simp]: "D = oGS_\<alpha> I" and I: "oGS_invar I" [PROOF STATE] proof (prove) using this: (I, D) \<in> oGS_rel goal (1 subgoal): 1. D = oGS_\<alpha> I &&& oGS_invar I [PROOF STEP] by (simp_all add: oGS_rel_def br_def) [PROOF STATE] proof (state) this: D = oGS_\<alpha> I oGS_invar I goal (2 subgoals): 1. GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}], D, {v0} \<times> succs) 2. GS_invar (GS_initial_impl I v0 succs) [PROOF STEP] from I [PROOF STATE] proof (chain) picking this: oGS_invar I [PROOF STEP] have [simp]: "\<And>j v. I v \<noteq> Some (STACK j)" [PROOF STATE] proof (prove) using this: oGS_invar I goal (1 subgoal): 1. \<And>j v. I v \<noteq> Some (STACK j) [PROOF STEP] by (simp add: oGS_invar_def) [PROOF STATE] proof (state) this: I ?v \<noteq> Some (STACK ?j) goal (2 subgoals): 1. GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}], D, {v0} \<times> succs) 2. GS_invar (GS_initial_impl I v0 succs) [PROOF STEP] show ?G1 [PROOF STATE] proof (prove) goal (1 subgoal): 1. GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}], D, {v0} \<times> succs) [PROOF STEP] unfolding GS.\<alpha>_def GS_initial_impl_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. (GS.p_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]), GS.D_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]), GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) = ([{v0}], D, {v0} \<times> succs) [PROOF STEP] apply (simp split del: if_split) [PROOF STATE] proof (prove) goal (1 subgoal): 1. GS.p_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = [{v0}] \<and> GS.D_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = oGS_\<alpha> I \<and> GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] apply (intro conjI) [PROOF STATE] proof (prove) goal (3 subgoals): 1. GS.p_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = [{v0}] 2. GS.D_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = oGS_\<alpha> I 3. GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] unfolding GS.p_\<alpha>_def GS.seg_def[abs_def] GS.seg_start_def GS.seg_end_def [PROOF STATE] proof (prove) goal (3 subgoals): 1. map (\<lambda>i. {GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) ! j |j. GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) ! i \<le> j \<and> j < (if i + 1 = length (GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) then length (GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) else GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) ! (i + 1))}) [0..<length (GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]))] = [{v0}] 2. GS.D_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = oGS_\<alpha> I 3. GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] apply (auto) [] [PROOF STATE] proof (prove) goal (2 subgoals): 1. GS.D_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = oGS_\<alpha> I 2. GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] using A [PROOF STATE] proof (prove) using this: v0 \<notin> D goal (2 subgoals): 1. GS.D_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = oGS_\<alpha> I 2. GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] unfolding GS.D_\<alpha>_def [PROOF STATE] proof (prove) using this: v0 \<notin> D goal (2 subgoals): 1. {v. GS.I ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) v = Some DONE} = oGS_\<alpha> I 2. GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] apply (auto simp: oGS_\<alpha>_def) [] [PROOF STATE] proof (prove) goal (1 subgoal): 1. GS.pE_\<alpha> ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) = {v0} \<times> succs [PROOF STEP] unfolding GS.pE_\<alpha>_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. {(u, v). \<exists>j Ia. (j, Ia) \<in> set (GS.P ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) \<and> u = GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) ! j \<and> v \<in> Ia} = {v0} \<times> succs [PROOF STEP] apply auto [] [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: GS.\<alpha> (GS_initial_impl I v0 succs) = ([{v0}], D, {v0} \<times> succs) goal (1 subgoal): 1. GS_invar (GS_initial_impl I v0 succs) [PROOF STEP] show ?G2 [PROOF STATE] proof (prove) goal (1 subgoal): 1. GS_invar (GS_initial_impl I v0 succs) [PROOF STEP] unfolding GS_initial_impl_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. GS_invar ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) [PROOF STEP] apply unfold_locales [PROOF STATE] proof (prove) goal (9 subgoals): 1. set (GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) \<subseteq> {0..<length (GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]))} 2. sorted (GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) 3. distinct (GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) 4. GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) \<noteq> [] \<Longrightarrow> GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) \<noteq> [] \<and> GS.B ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) ! 0 = 0 5. distinct (GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) 6. \<And>v j. (GS.I ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) v = Some (STACK j)) = (j < length (GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) \<and> v = GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]) ! j) 7. sorted (map fst (GS.P ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]))) 8. distinct (map fst (GS.P ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]))) 9. set (GS.P ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)])) \<subseteq> {0..<length (GS.S ([v0], [0], I(v0 \<mapsto> STACK 0), if succs = {} then [] else [(0, succs)]))} \<times> {y. {} \<noteq> y} [PROOF STEP] apply auto [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: GS_invar (GS_initial_impl I v0 succs) goal: No subgoals! [PROOF STEP] qed
/- Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://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. Authors: Moritz Firsching -/ import tactic /-! # The spectral theorem and Hadamard's determinant problem ## TODO - statement Theorem 1. - proof - Lemma - (A) - (B) - (C) - The Hadamard determinant problem - Hadamard matreices esixt for all $n = 2^m$ - Theorem 2. -/
import smt2 constants f g : Prop → int → int attribute [smt2] f attribute [smt2] g constants x y z : int attribute [smt2] x attribute [smt2] y attribute [smt2] z constants Heq : forall (x x' : Prop) (y : int), (x -> x') -> f x y = g x' y attribute [smt2] Heq lemma uninterpreted_functions_with_attr : f (x < 0) ((x + y) +z) = g (x < 0) (z + (y + x)) := begin intros, z3 "foo.log" end
[STATEMENT] lemma gbinomial_code [code]: "a gchoose k = (if k = 0 then 1 else fold_atLeastAtMost_nat (\<lambda>k acc. (a - of_nat k) * acc) 0 (k - 1) 1 / fact k)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. a gchoose k = (if k = 0 then 1::'a else fold_atLeastAtMost_nat (\<lambda>k. (*) (a - of_nat k)) 0 (k - 1) (1::'a) / fact k) [PROOF STEP] by (cases k) (simp_all add: gbinomial_prod_rev prod_atLeastAtMost_code [symmetric] atLeastLessThanSuc_atLeastAtMost)
import numpy as np import autodiff as ad x = ad.Variable(name = "x") w = ad.Variable(name = "w") b = ad.Variable(name = "b") labels = ad.Variable(name = "lables") # TODO: 使用给定的Ops, 实现sigmoid函数 def sigmoid(x): rst = _ return rst # TODO: 使用给定的Ops, 实现逻辑回归的BCE损失函数 def bce_loss(xs, labels): loss = _ return loss p = sigmoid(ad.matmul_op(w, x)) loss = bce_loss(p, labels) grad_y_w, = ad.gradients(loss, [w]) num_features = 2 num_points = 200 num_iterations = 1000 learning_rate = 0.01 # The dummy dataset consists of two classes. # The classes are modelled as a random normal variables with different means. class_1 = np.random.normal(2, 0.1, (num_points / 2, num_features)) class_2 = np.random.normal(4, 0.1, (num_points / 2, num_features)) x_val = np.concatenate((class_1, class_2), axis = 0).T x_val = np.concatenate((x_val, np.ones((1, num_points))), axis = 0) w_val = np.random.normal(size = (1, num_features + 1)) labels_val = np.concatenate((np.zeros((class_1.shape[0], 1)), np.ones((class_2.shape[0], 1))), axis=0).T executor = ad.Executor([loss, grad_y_w]) for i in xrange(100000): # evaluate the graph loss_val, grad_y_w_val = executor.run(feed_dict={x:x_val, w:w_val, labels:labels_val}) # TODO: update the parameters using SGD w_val = _ if i % 1000 == 0: print loss_val
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import analysis.calculus.mean_value /-! # Darboux's theorem In this file we prove that the derivative of a differentiable function on an interval takes all intermediate values. The proof is based on the [Wikipedia](https://en.wikipedia.org/wiki/Darboux%27s_theorem_(analysis)) page about this theorem. -/ open filter set open_locale topological_space classical variables {a b : ℝ} {f f' : ℝ → ℝ} /-- Darboux's theorem: if `a ≤ b` and `f' a < m < f' b`, then `f' c = m` for some `c ∈ [a, b]`. -/ theorem exists_has_deriv_within_at_eq_of_gt_of_lt (hab : a ≤ b) (hf : ∀ x ∈ (Icc a b), has_deriv_within_at f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a < m) (hmb : m < f' b) : m ∈ f' '' (Icc a b) := begin have hab' : a < b, { refine lt_of_le_of_ne hab (λ hab', _), subst b, exact lt_asymm hma hmb }, set g : ℝ → ℝ := λ x, f x - m * x, have hg : ∀ x ∈ Icc a b, has_deriv_within_at g (f' x - m) (Icc a b) x, { intros x hx, simpa using (hf x hx).sub ((has_deriv_within_at_id x _).const_mul m) }, obtain ⟨c, cmem, hc⟩ : ∃ c ∈ Icc a b, is_min_on g (Icc a b) c, from compact_Icc.exists_forall_le (nonempty_Icc.2 $ hab) (λ x hx, (hg x hx).continuous_within_at), have cmem' : c ∈ Ioo a b, { cases eq_or_lt_of_le cmem.1 with hac hac, -- Show that `c` can't be equal to `a` { subst c, refine absurd (sub_nonneg.1 $ nonneg_of_mul_nonneg_left _ (sub_pos.2 hab')) (not_le_of_lt hma), have : b - a ∈ pos_tangent_cone_at (Icc a b) a, from mem_pos_tangent_cone_at_of_segment_subset (segment_eq_Icc hab ▸ subset.refl _), simpa [-sub_nonneg, -continuous_linear_map.map_sub] using hc.localize.has_fderiv_within_at_nonneg (hg a (left_mem_Icc.2 hab)) this }, cases eq_or_lt_of_le cmem.2 with hbc hbc, -- Show that `c` can't be equal to `b` { subst c, refine absurd (sub_nonpos.1 $ nonpos_of_mul_nonneg_right _ (sub_lt_zero.2 hab')) (not_le_of_lt hmb), have : a - b ∈ pos_tangent_cone_at (Icc a b) b, from mem_pos_tangent_cone_at_of_segment_subset (by rw [segment_symm, segment_eq_Icc hab]), simpa [-sub_nonneg, -continuous_linear_map.map_sub] using hc.localize.has_fderiv_within_at_nonneg (hg b (right_mem_Icc.2 hab)) this }, exact ⟨hac, hbc⟩ }, use [c, cmem], rw [← sub_eq_zero], have : Icc a b ∈ 𝓝 c, by rwa [← mem_interior_iff_mem_nhds, interior_Icc], exact (hc.is_local_min this).has_deriv_at_eq_zero ((hg c cmem).has_deriv_at this) end /-- Darboux's theorem: if `a ≤ b` and `f' a > m > f' b`, then `f' c = m` for some `c ∈ [a, b]`. -/ theorem exists_has_deriv_within_at_eq_of_lt_of_gt (hab : a ≤ b) (hf : ∀ x ∈ (Icc a b), has_deriv_within_at f (f' x) (Icc a b) x) {m : ℝ} (hma : m < f' a) (hmb : f' b < m) : m ∈ f' '' (Icc a b) := let ⟨c, cmem, hc⟩ := exists_has_deriv_within_at_eq_of_gt_of_lt hab (λ x hx, (hf x hx).neg) (neg_lt_neg hma) (neg_lt_neg hmb) in ⟨c, cmem, neg_injective hc⟩ /-- Darboux's theorem: the image of a convex set under `f'` is a convex set. -/ theorem convex_image_has_deriv_at {s : set ℝ} (hs : convex s) (hf : ∀ x ∈ s, has_deriv_at f (f' x) x) : convex (f' '' s) := begin refine real.convex_iff_ord_connected.2 ⟨_⟩, rintros _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ m ⟨hma, hmb⟩, cases eq_or_lt_of_le hma with hma hma, by exact hma ▸ mem_image_of_mem f' ha, cases eq_or_lt_of_le hmb with hmb hmb, by exact hmb.symm ▸ mem_image_of_mem f' hb, cases le_total a b with hab hab, { have : Icc a b ⊆ s, from hs.ord_connected.out ha hb, rcases exists_has_deriv_within_at_eq_of_gt_of_lt hab (λ x hx, (hf x $ this hx).has_deriv_within_at) hma hmb with ⟨c, cmem, hc⟩, exact ⟨c, this cmem, hc⟩ }, { have : Icc b a ⊆ s, from hs.ord_connected.out hb ha, rcases exists_has_deriv_within_at_eq_of_lt_of_gt hab (λ x hx, (hf x $ this hx).has_deriv_within_at) hmb hma with ⟨c, cmem, hc⟩, exact ⟨c, this cmem, hc⟩ } end /-- If the derivative of a function is never equal to `m`, then either it is always greater than `m`, or it is always less than `m`. -/ theorem deriv_forall_lt_or_forall_gt_of_forall_ne {s : set ℝ} (hs : convex s) (hf : ∀ x ∈ s, has_deriv_at f (f' x) x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) : (∀ x ∈ s, f' x < m) ∨ (∀ x ∈ s, m < f' x) := begin contrapose! hf', rcases hf' with ⟨⟨b, hb, hmb⟩, ⟨a, ha, hma⟩⟩, exact (convex_image_has_deriv_at hs hf).ord_connected.out (mem_image_of_mem f' ha) (mem_image_of_mem f' hb) ⟨hma, hmb⟩ end
lemma example3 (a b : mynat) (h : succ a = b) : succ(succ(a)) = succ(b) := begin rw h, refl, end
lemma rcis_eq_zero_iff [simp]: "rcis r a = 0 \<longleftrightarrow> r = 0"
import tutorial_world.level11_cases2_or --hide open set IncidencePlane --hide variables {Ω : Type} [IncidencePlane Ω] --hide /- Suppose now that your hypothesis says there is some element `x` satisfying a certain property `P`. That is, you have `h : ∃ x, P x`. Then `cases h with x hx` will replace `h` with `x : X` and `hx : P x`. That is, from the fact that you know that some `x` exists, it will give you one such `x` with the property that it is supposed to satisfy. -/ /- Lemma : no-side-bar A line through 4 points given lines through two subsets of three -/ lemma exists_line_example (P Q R S : Ω) (h : Q ≠ R) (h1 : ∃ ℓ : Line Ω, P ∈ ℓ ∧ Q ∈ ℓ ∧ R ∈ ℓ) (h2 : ∃ ℓ : Line Ω, Q ∈ ℓ ∧ R ∈ ℓ ∧ S ∈ ℓ) : ∃ ℓ : Line Ω, P ∈ ℓ ∧ Q ∈ ℓ ∧ R ∈ ℓ ∧ S ∈ ℓ := begin cases h1 with r hr, cases h2 with s hs, have H : r = s, { exact equal_lines_of_contain_two_points h hr.2.1 hs.1 hr.2.2 hs.2.1, }, use r, split, exact hr.1, split, exact hr.2.1, split, exact hr.2.2, rw H, exact hs.2.2, end
[GOAL] R : Type u inst✝¹ : CommRing R D : Type v inst✝ : SmallCategory D I : D ⥤ Ideal R X✝ Y✝ Z✝ : D f : X✝ ⟶ Y✝ g : Y✝ ⟶ Z✝ ⊢ { obj := fun t => ModuleCat.of R (R ⧸ I.obj t), map := fun {X Y} w => Submodule.mapQ (I.obj X) (I.obj Y) LinearMap.id (_ : I.obj X ≤ I.obj Y) }.map (f ≫ g) = { obj := fun t => ModuleCat.of R (R ⧸ I.obj t), map := fun {X Y} w => Submodule.mapQ (I.obj X) (I.obj Y) LinearMap.id (_ : I.obj X ≤ I.obj Y) }.map f ≫ { obj := fun t => ModuleCat.of R (R ⧸ I.obj t), map := fun {X Y} w => Submodule.mapQ (I.obj X) (I.obj Y) LinearMap.id (_ : I.obj X ≤ I.obj Y) }.map g [PROOFSTEP] apply Submodule.linearMap_qext [GOAL] case h R : Type u inst✝¹ : CommRing R D : Type v inst✝ : SmallCategory D I : D ⥤ Ideal R X✝ Y✝ Z✝ : D f : X✝ ⟶ Y✝ g : Y✝ ⟶ Z✝ ⊢ LinearMap.comp ({ obj := fun t => ModuleCat.of R (R ⧸ I.obj t), map := fun {X Y} w => Submodule.mapQ (I.obj X) (I.obj Y) LinearMap.id (_ : I.obj X ≤ I.obj Y) }.map (f ≫ g)) (Submodule.mkQ (I.obj X✝)) = LinearMap.comp ({ obj := fun t => ModuleCat.of R (R ⧸ I.obj t), map := fun {X Y} w => Submodule.mapQ (I.obj X) (I.obj Y) LinearMap.id (_ : I.obj X ≤ I.obj Y) }.map f ≫ { obj := fun t => ModuleCat.of R (R ⧸ I.obj t), map := fun {X Y} w => Submodule.mapQ (I.obj X) (I.obj Y) LinearMap.id (_ : I.obj X ≤ I.obj Y) }.map g) (Submodule.mkQ (I.obj X✝)) [PROOFSTEP] rfl [GOAL] R : Type u inst✝ : CommRing R J : Ideal R k : ℕᵒᵖ ⊢ J ≤ Ideal.radical ((idealPowersDiagram J).obj k) [PROOFSTEP] change _ ≤ (J ^ unop k).radical [GOAL] R : Type u inst✝ : CommRing R J : Ideal R k : ℕᵒᵖ ⊢ J ≤ Ideal.radical (J ^ k.unop) [PROOFSTEP] cases' unop k with n [GOAL] case zero R : Type u inst✝ : CommRing R J : Ideal R k : ℕᵒᵖ ⊢ J ≤ Ideal.radical (J ^ Nat.zero) [PROOFSTEP] simp [Ideal.radical_top, pow_zero, Ideal.one_eq_top, le_top, Nat.zero_eq] [GOAL] case succ R : Type u inst✝ : CommRing R J : Ideal R k : ℕᵒᵖ n : ℕ ⊢ J ≤ Ideal.radical (J ^ Nat.succ n) [PROOFSTEP] simp only [J.radical_pow _ n.succ_pos, Ideal.le_radical] [GOAL] R : Type u inst✝ : CommRing R I J K : Ideal R hIJ : I ≤ Ideal.radical J hJ : Ideal.FG (Ideal.radical J) ⊢ ∃ k, I ^ k ≤ J [PROOFSTEP] obtain ⟨k, hk⟩ := J.exists_radical_pow_le_of_fg hJ [GOAL] case intro R : Type u inst✝ : CommRing R I J K : Ideal R hIJ : I ≤ Ideal.radical J hJ : Ideal.FG (Ideal.radical J) k : ℕ hk : Ideal.radical J ^ k ≤ J ⊢ ∃ k, I ^ k ≤ J [PROOFSTEP] use k [GOAL] case h R : Type u inst✝ : CommRing R I J K : Ideal R hIJ : I ≤ Ideal.radical J hJ : Ideal.FG (Ideal.radical J) k : ℕ hk : Ideal.radical J ^ k ≤ J ⊢ I ^ k ≤ J [PROOFSTEP] calc I ^ k ≤ J.radical ^ k := Ideal.pow_mono hIJ _ _ ≤ J := hk [GOAL] R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J ⊢ IsConnected (CostructuredArrow (idealPowersToSelfLERadical J) J') [PROOFSTEP] apply (config := { allowSynthFailures := true }) zigzag_isConnected [GOAL] case inst R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J ⊢ Nonempty (CostructuredArrow (idealPowersToSelfLERadical J) J') [PROOFSTEP] obtain ⟨k, hk⟩ := Ideal.exists_pow_le_of_le_radical_of_fG J'.2 (isNoetherian_def.mp hR _) [GOAL] case inst.intro R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J k : ℕ hk : J ^ k ≤ J'.obj ⊢ Nonempty (CostructuredArrow (idealPowersToSelfLERadical J) J') [PROOFSTEP] exact ⟨CostructuredArrow.mk (⟨⟨hk⟩⟩ : (idealPowersToSelfLERadical J).obj (op k) ⟶ J')⟩ [GOAL] case h R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J ⊢ ∀ (j₁ j₂ : CostructuredArrow (idealPowersToSelfLERadical J) J'), Zigzag j₁ j₂ [PROOFSTEP] intro j1 j2 [GOAL] case h R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' ⊢ Zigzag j1 j2 [PROOFSTEP] apply Relation.ReflTransGen.single [GOAL] case h.hab R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' ⊢ Zag j1 j2 [PROOFSTEP] cases' le_total (unop j1.left) (unop j2.left) with h h [GOAL] case h.hab.inl R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' h : j1.left.unop ≤ j2.left.unop ⊢ Zag j1 j2 case h.hab.inr R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' h : j2.left.unop ≤ j1.left.unop ⊢ Zag j1 j2 [PROOFSTEP] right [GOAL] case h.hab.inl.h R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' h : j1.left.unop ≤ j2.left.unop ⊢ Nonempty (j2 ⟶ j1) case h.hab.inr R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' h : j2.left.unop ≤ j1.left.unop ⊢ Zag j1 j2 [PROOFSTEP] exact ⟨CostructuredArrow.homMk (homOfLE h).op (AsTrue.get trivial)⟩ [GOAL] case h.hab.inr R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' h : j2.left.unop ≤ j1.left.unop ⊢ Zag j1 j2 [PROOFSTEP] left [GOAL] case h.hab.inr.h R : Type u inst✝ : CommRing R I J K : Ideal R hR : IsNoetherian R R J' : SelfLERadical J j1 j2 : CostructuredArrow (idealPowersToSelfLERadical J) J' h : j2.left.unop ≤ j1.left.unop ⊢ Nonempty (j1 ⟶ j2) [PROOFSTEP] exact ⟨CostructuredArrow.homMk (homOfLE h).op (AsTrue.get trivial)⟩ [GOAL] R : Type u inst✝ : CommRing R I J K : Ideal R hJK : Ideal.radical J = Ideal.radical K L : Ideal R hL : J ≤ Ideal.radical L ⊢ K ≤ Ideal.radical L [PROOFSTEP] rw [← Ideal.radical_le_radical_iff] at hL ⊢ [GOAL] R : Type u inst✝ : CommRing R I J K : Ideal R hJK : Ideal.radical J = Ideal.radical K L : Ideal R hL : Ideal.radical J ≤ Ideal.radical L ⊢ Ideal.radical K ≤ Ideal.radical L [PROOFSTEP] exact hJK.symm.trans_le hL
/- Copyright (c) 2022 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler ! This file was ported from Lean 3 source module measure_theory.integral.exp_decay ! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.MeasureTheory.Integral.IntervalIntegral import Mathbin.MeasureTheory.Integral.IntegralEqImproper /-! # Integrals with exponential decay at ∞ As easy special cases of general theorems in the library, we prove the following test for integrability: * `integrable_of_is_O_exp_neg`: If `f` is continuous on `[a,∞)`, for some `a ∈ ℝ`, and there exists `b > 0` such that `f(x) = O(exp(-b x))` as `x → ∞`, then `f` is integrable on `(a, ∞)`. -/ noncomputable section open Real intervalIntegral MeasureTheory Set Filter /-- Integral of `exp (-b * x)` over `(a, X)` is bounded as `X → ∞`. -/ theorem integral_exp_neg_le {b : ℝ} (a X : ℝ) (h2 : 0 < b) : (∫ x in a..X, exp (-b * x)) ≤ exp (-b * a) / b := by rw [integral_deriv_eq_sub' fun x => -exp (-b * x) / b] -- goal 1/4: F(X) - F(a) is bounded · simp only [tsub_le_iff_right] rw [neg_div b (exp (-b * a)), neg_div b (exp (-b * X)), add_neg_self, neg_le, neg_zero] exact (div_pos (exp_pos _) h2).le -- goal 2/4: the derivative of F is exp(-b x) · ext1 simp [h2.ne'] -- goal 3/4: F is differentiable · intro x hx simp [h2.ne'] -- goal 4/4: exp(-b x) is continuous · apply Continuous.continuousOn continuity #align integral_exp_neg_le integral_exp_neg_le /-- `exp (-b * x)` is integrable on `(a, ∞)`. -/ theorem expNegIntegrableOnIoi (a : ℝ) {b : ℝ} (h : 0 < b) : IntegrableOn (fun x : ℝ => exp (-b * x)) (Ioi a) := by have : ∀ X : ℝ, integrable_on (fun x : ℝ => exp (-b * x)) (Ioc a X) := by intro X exact (continuous_const.mul continuous_id).exp.integrableOnIoc apply integrable_on_Ioi_of_interval_integral_norm_bounded (exp (-b * a) / b) a this tendsto_id simp only [eventually_at_top, norm_of_nonneg (exp_pos _).le] exact ⟨a, fun b2 hb2 => integral_exp_neg_le a b2 h⟩ #align exp_neg_integrable_on_Ioi expNegIntegrableOnIoi /-- If `f` is continuous on `[a, ∞)`, and is `O (exp (-b * x))` at `∞` for some `b > 0`, then `f` is integrable on `(a, ∞)`. -/ theorem integrableOfIsOExpNeg {f : ℝ → ℝ} {a b : ℝ} (h0 : 0 < b) (h1 : ContinuousOn f (Ici a)) (h2 : f =O[atTop] fun x => exp (-b * x)) : IntegrableOn f (Ioi a) := by cases' h2.is_O_with with c h3 rw [Asymptotics.isOWith_iff, eventually_at_top] at h3 cases' h3 with r bdr let v := max a r -- show integrable on `(a, v]` from continuity have int_left : integrable_on f (Ioc a v) := by rw [← intervalIntegrable_iff_integrable_Ioc_of_le (le_max_left a r)] have u : Icc a v ⊆ Ici a := Icc_subset_Ici_self exact (h1.mono u).intervalIntegrableOfIcc (le_max_left a r) suffices integrable_on f (Ioi v) by have t : integrable_on f (Ioc a v ∪ Ioi v) := integrable_on_union.mpr ⟨int_left, this⟩ simpa only [Ioc_union_Ioi_eq_Ioi, le_max_iff, le_refl, true_or_iff] using t -- now show integrable on `(v, ∞)` from asymptotic constructor · exact (h1.mono <| Ioi_subset_Ici <| le_max_left a r).AeStronglyMeasurable measurableSet_Ioi have : has_finite_integral (fun x : ℝ => c * exp (-b * x)) (volume.restrict (Ioi v)) := (expNegIntegrableOnIoi v h0).HasFiniteIntegral.const_mul c apply this.mono refine' (ae_restrict_iff' measurableSet_Ioi).mpr _ refine' ae_of_all _ fun x h1x => _ rw [norm_mul, norm_eq_abs] rw [mem_Ioi] at h1x specialize bdr x ((le_max_right a r).trans h1x.le) exact bdr.trans (mul_le_mul_of_nonneg_right (le_abs_self c) (norm_nonneg _)) #align integrable_of_is_O_exp_neg integrableOfIsOExpNeg
module vectors implicit none type vector integer, allocatable :: elements(:) end type contains subroutine set_elements(input) class(*), pointer, intent(in) :: input select type (input) type is (vector) input%elements=[2] end select end subroutine end module implicit none call set_vector contains subroutine set_vector() use vectors type (vector), target :: v class(*), pointer :: v_ptr v_ptr => v call set_elements ( v_ptr ) select type ( v_ptr ) type is ( vector ) print *, v%elements(1), '<-- should be 2' end select end subroutine end
!*** Copyright (c) 1998, NVIDIA CORPORATION. All rights reserved. !*** !*** Licensed under the Apache License, Version 2.0 (the "License"); !*** you may not use this file except in compliance with the License. !*** You may obtain a copy of the License at !*** !*** http://www.apache.org/licenses/LICENSE-2.0 !*** !*** Unless required by applicable law or agreed to in writing, software !*** distributed under the License is distributed on an "AS IS" BASIS, !*** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. !*** See the License for the specific language governing permissions and !*** limitations under the License. ! ! simple derived type parameters subroutine sub(a,x) type tscope sequence integer :: scope end type integer a type(tscope)::x type (tscope), parameter :: local = tscope(2) type (tscope), parameter :: global = tscope(1) select case(x%scope) case(local%scope) a = 11 case(global%scope) a = 22 case default a = 33 end select end subroutine program p type tscope sequence integer :: scope end type interface subroutine sub(a,x) type tscope sequence integer :: scope end type integer a type(tscope)::x end subroutine end interface type(tscope)::l,g,m integer result(3) integer expect(3) data expect/11,22,33/ l%scope = 2 g%scope = 1 m%scope = 3 call sub(result(1),l) call sub(result(2),g) call sub(result(3),m) call check(result, expect, 3) end
! should pass 'implicit-none' test with no cases detected. program example2 implicit none print *, f(1) contains integer function f(x) ! IMPLICIT NONE is not necessary here as it inherits the previous ! one, however we do provide 'implicit-none-all' functionality ! just in case you want to check all program units regardless of ! the inheritance rule. integer :: x f = 1 + x end function f end program example2
# --- # title: 777. Swap Adjacent in LR String # id: problem777 # author: Indigo # date: 2021-01-28 # difficulty: Medium # categories: Brainteaser # link: <https://leetcode.com/problems/swap-adjacent-in-lr-string/description/> # hidden: true # --- # # In a string composed of `'L'`, `'R'`, and `'X'` characters, like # `"RXXLRXRXL"`, a move consists of either replacing one occurrence of `"XL"` # with `"LX"`, or replacing one occurrence of `"RX"` with `"XR"`. Given the # starting string `start` and the ending string `end`, return `True` if and only # if there exists a sequence of moves to transform one string to the other. # # # # **Example 1:** # # # # Input: start = "RXXLRXRXL", end = "XRLXXRRLX" # Output: true # Explanation: We can transform start to end following these steps: # RXXLRXRXL -> # XRXLRXRXL -> # XRLXRXRXL -> # XRLXXRRXL -> # XRLXXRRLX # # # **Example 2:** # # # # Input: start = "X", end = "L" # Output: false # # # **Example 3:** # # # # Input: start = "LLR", end = "RRL" # Output: false # # # **Example 4:** # # # # Input: start = "XL", end = "LX" # Output: true # # # **Example 5:** # # # # Input: start = "XLLR", end = "LXLX" # Output: false # # # # # **Constraints:** # # * `1 <= start.length <= 104` # * `start.length == end.length` # * Both `start` and `end` will only consist of characters in `'L'`, `'R'`, and `'X'`. # # ## @lc code=start using LeetCode function can_transform(s::String, t::String) i, j = 1, 1 len = length(s) len != length(t) && return false while i <= len || j <= len while i <= len && s[i] == 'X'; i += 1; end while j <= len && t[j] == 'X' ; j += 1; end ((i <= len) ⊻ (j <= len)) && return false if i <= len && j <= len (s[i] != t[j] || (s[i] == 'L' && i < j) || (s[i] == 'R' && i > j)) && return false end i += 1; j += 1 end return true end ## @lc code=end
[STATEMENT] lemma lcm_0_left [simp]: "lcm 0 a = 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lcm (0::'a) a = (0::'a) [PROOF STEP] by (simp add: lcm_gcd)
module Issue512 where postulate Level : Set {-# BUILTIN LEVEL Level #-} data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} data A : Set where a b : A proof : a ≡ a proof = refl f : A → A → A f x y rewrite proof = ? -- gave error below (now complains about LEVELZERO instead of STRING) {- {- No binding for builtin thing STRING, use {-# BUILTIN STRING name #-} to bind it to 'name' when checking that the type of the generated with function (w : A) → _≡_ {"Max []"} {A} w w → (x y : A) → A is well-formed -} -}
\<^marker>\<open>creator "Kevin Kappelmann"\<close> section \<open>Set Equality\<close> theory Equality imports Subset begin lemma eqI [intro]: "(\<And>x. x \<in> A \<Longrightarrow> x \<in> B) \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> x \<in> A) \<Longrightarrow> A = B" by auto lemma eqI': "(\<And>x. x \<in> A \<longleftrightarrow> x \<in> B) \<Longrightarrow> A = B" by auto lemma eqE: "\<lbrakk>A = B; \<lbrakk>A \<subseteq> B ; B \<subseteq> A\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" by blast lemma eqD [dest]: "A = B \<Longrightarrow> (\<And>x. x \<in> A \<longleftrightarrow> x \<in> B)" by auto lemma ne_if_ex_mem_not_mem: "\<exists>x. x \<in> A \<and> x \<notin> B \<Longrightarrow> A \<noteq> B" by auto lemma neD: "A \<noteq> B \<Longrightarrow> \<exists>x. (x \<in> A \<and> x \<notin> B) \<or> (x \<notin> A \<and> x \<in> B)" by auto end
(* @SUITE inline *) theory inline_rename imports "../Tactic_Inline" "../Lang_Simplifier" begin abbreviation "z == Variable ''z'' :: int variable" procedure proc1 :: "(int,int) procedure" where "proc1 = LOCAL x a. proc(a) { x := a; z := x; return z+a }" lemma assumes "LOCAL x a aa. hoare { True } a:=(1::int); aa := z; x := default; x := aa; z := x; z := z+aa { z=undefined }" shows "LOCAL a. hoare { True } a:=(1::int); z:=call proc1(z) { z=undefined }" apply (inline proc1) apply simp by (fact assms) end
import tactic.lint import algebra.group.basic /-! ## Commutativity lemmas should be rejected -/ attribute [simp] add_comm add_left_comm open tactic run_cmd do decl ← get_decl ``add_comm, res ← linter.simp_comm.test decl, -- linter complains guard res.is_some open tactic run_cmd do decl ← get_decl ``add_left_comm, res ← linter.simp_comm.test decl, -- linter complains guard res.is_some /-! ## Floris' trick should be accepted -/ @[simp] lemma list.filter_congr_decidable {α} (s : list α) (p : α → Prop) (h : decidable_pred p) [decidable_pred p] : @list.filter α p h s = s.filter p := by congr -- lemma is unproblematic example : @list.filter _ (λ x, x > 0) (λ _, classical.prop_decidable _) [1,2,3] = [1,2,3] := begin -- can rewrite once simp only [list.filter_congr_decidable], -- but not twice success_if_fail { simp only [list.filter_congr_decidable] }, refl end open tactic set_option pp.all true run_cmd do decl ← get_decl ``list.filter_congr_decidable, res ← linter.simp_comm.test decl, -- linter does not complain guard res.is_none
Experience the best in hot rods, muscle cars, street machines and vintage race cars. Our 3rd Annual Car Show raises money for Camp Quality. Please bring a gold coin for donating.
(* This file is generated by Why3's Coq driver *) (* Beware! Only edit allowed sections below *) Require Import ZArith. Require Import Rbase. Definition unit := unit. Parameter qtmark : Type. Parameter at1: forall (a:Type), a -> qtmark -> a. Implicit Arguments at1. Parameter old: forall (a:Type), a -> a. Implicit Arguments old. Parameter fib: Z -> Z. Axiom fib0 : ((fib 0%Z) = 0%Z). Axiom fib1 : ((fib 1%Z) = 1%Z). Axiom fibn : forall (n:Z), (2%Z <= n)%Z -> ((fib n) = ((fib (n - 1%Z)%Z) + (fib (n - 2%Z)%Z))%Z). Axiom Abs_le : forall (x:Z) (y:Z), ((Zabs x) <= y)%Z <-> (((-y)%Z <= x)%Z /\ (x <= y)%Z). Parameter div: Z -> Z -> Z. Parameter mod1: Z -> Z -> Z. Axiom Div_mod : forall (x:Z) (y:Z), (~ (y = 0%Z)) -> (x = ((y * (div x y))%Z + (mod1 x y))%Z). Axiom Div_bound : forall (x:Z) (y:Z), ((0%Z <= x)%Z /\ (0%Z < y)%Z) -> ((0%Z <= (div x y))%Z /\ ((div x y) <= x)%Z). Axiom Mod_bound : forall (x:Z) (y:Z), (~ (y = 0%Z)) -> ((0%Z <= (mod1 x y))%Z /\ ((mod1 x y) < (Zabs y))%Z). Axiom Mod_1 : forall (x:Z), ((mod1 x 1%Z) = 0%Z). Axiom Div_1 : forall (x:Z), ((div x 1%Z) = x). Inductive t := | mk_t : Z -> Z -> Z -> Z -> t . Definition a11(u:t): Z := match u with | (mk_t a111 _ _ _) => a111 end. Definition a12(u:t): Z := match u with | (mk_t _ a121 _ _) => a121 end. Definition a21(u:t): Z := match u with | (mk_t _ _ a211 _) => a211 end. Definition a22(u:t): Z := match u with | (mk_t _ _ _ a221) => a221 end. Definition mult(x:t) (y:t): t := (mk_t (((a11 x) * (a11 y))%Z + ((a12 x) * (a21 y))%Z)%Z (((a11 x) * (a12 y))%Z + ((a12 x) * (a22 y))%Z)%Z (((a21 x) * (a11 y))%Z + ((a22 x) * (a21 y))%Z)%Z (((a21 x) * (a12 y))%Z + ((a22 x) * (a22 y))%Z)%Z). Parameter power: t -> Z -> t. Axiom Power_0 : forall (x:t), ((power x 0%Z) = (mk_t 1%Z 0%Z 0%Z 1%Z)). Axiom Power_s : forall (x:t) (n:Z), (0%Z <= n)%Z -> ((power x (n + 1%Z)%Z) = (mult x (power x n))). Axiom Power_1 : forall (x:t), ((power x 1%Z) = x). Axiom Power_sum : forall (x:t) (n:Z) (m:Z), ((0%Z <= n)%Z /\ (0%Z <= m)%Z) -> ((power x (n + m)%Z) = (mult (power x n) (power x m))). Axiom Power_mult : forall (x:t) (n:Z) (m:Z), (0%Z <= n)%Z -> ((0%Z <= m)%Z -> ((power x (n * m)%Z) = (power (power x n) m))). (* YOU MAY EDIT THE CONTEXT BELOW *) Hint Resolve fib0 fib1. (* DO NOT EDIT BELOW *) Theorem fib_m : forall (n:Z), (0%Z <= n)%Z -> let p := (power (mk_t 1%Z 1%Z 1%Z 0%Z) n) in (((fib (n + 1%Z)%Z) = (a11 p)) /\ ((fib n) = (a21 p))). (* YOU MAY EDIT THE PROOF BELOW *) intros n hn. pattern n; apply natlike_ind; intuition. rewrite Power_0. unfold a11, a21; simpl; auto. replace (Zsucc x) with (x+1)%Z by omega. rewrite Power_s; auto. destruct H0 as (h1,h2). split. rewrite fibn; try omega. ring_simplify (x+1+1-1)%Z. ring_simplify (x+1+1-2)%Z. unfold a11, mult. rewrite <- h1. rewrite <- h2. unfold a11, a12. ring. unfold a21, mult. rewrite <- h1. rewrite <- h2. unfold a21, a22. ring. Qed. (* DO NOT EDIT BELOW *)
lemma compact_lemma_general: fixes f :: "nat \<Rightarrow> 'a" fixes proj::"'a \<Rightarrow> 'b \<Rightarrow> 'c::heine_borel" (infixl "proj" 60) fixes unproj:: "('b \<Rightarrow> 'c) \<Rightarrow> 'a" assumes finite_basis: "finite basis" assumes bounded_proj: "\<And>k. k \<in> basis \<Longrightarrow> bounded ((\<lambda>x. x proj k) ` range f)" assumes proj_unproj: "\<And>e k. k \<in> basis \<Longrightarrow> (unproj e) proj k = e k" assumes unproj_proj: "\<And>x. unproj (\<lambda>k. x proj k) = x" shows "\<forall>d\<subseteq>basis. \<exists>l::'a. \<exists> r::nat\<Rightarrow>nat. strict_mono r \<and> (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) proj i) (l proj i) < e) sequentially)"
{-# OPTIONS --without-K #-} open import homotopy.3x3.PushoutPushout open import homotopy.3x3.Transpose import homotopy.3x3.To as To import homotopy.3x3.From as From open import homotopy.3x3.Common module homotopy.3x3.Commutes {i} (d : Span^2 {i}) where open Span^2 d open M using (Pushout^2) open To d open From d open import homotopy.3x3.FromTo open import homotopy.3x3.ToFrom abstract theorem : Pushout^2 d ≃ Pushout^2 (transpose d) theorem = equiv to from (to-from d) (from-to d)
informal statement Let $x$ and $y$ be elements of $G$. Prove that $xy=yx$ if and only if $y^{-1}xy=x$ if and only if $x^{-1}y^{-1}xy=1$.formal statement theorem exercise_1_1_22a {G : Type*} [group G] (x g : G) : order_of x = order_of (g⁻¹ * x * g) :=
From iris.bi Require Export bi. From iris.proofmode Require Import base proofmode classes. From iris.base_logic.lib Require Export fancy_updates. Import uPred. (* TODO: upstream? *) Section fupd_plainly_derived. Context {PROP : bi}. Context `{!BiFUpd PROP, !BiPlainly PROP, !BiFUpdPlainly PROP}. Lemma step_fupd_mono Eo Ei (P Q : PROP) : (P ⊢ Q) → (|={Eo}[Ei]▷=> P) ⊢ (|={Eo}[Ei]▷=> Q). Proof. intros HPQ. by apply fupd_mono, later_mono, fupd_mono. Qed. Lemma step_fupd_except_0 E1 E2 (P : PROP) : (|={E1}[E2]▷=> ◇ P) ={E1}[E2]▷=∗ P. Proof. rewrite fupd_except_0 //. Qed. Lemma step_fupdN_except_0 E1 E2 (P : PROP) n : (|={E1}[E2]▷=>^(S n) ◇ P) ={E1}[E2]▷=∗^(S n) P. Proof. induction n as [|n IH]; [apply step_fupd_except_0|]. replace (S (S n)) with (1 + S n)%nat by lia. rewrite 2!step_fupdN_add. by apply step_fupd_mono. Qed. Lemma step_fupdN_plain_forall E {A} (Φ : A → PROP) `{!∀ x, Plain (Φ x)} n : (|={E}▷=>^n ∀ x, Φ x) ⊣⊢ (∀ x, |={E}▷=>^n Φ x). Proof . intros. apply (anti_symm _). { apply forall_intro=> x. apply step_fupdN_mono. eauto. } destruct n; [done|]. trans (∀ x, |={E}=> ▷^(S n) ◇ Φ x)%I. { apply forall_mono=> x. by rewrite step_fupdN_plain. } rewrite -fupd_plain_forall'. rewrite -step_fupdN_except_0 /= -step_fupdN_intro //. apply fupd_elim. rewrite -later_forall -laterN_forall -except_0_forall. apply step_fupd_intro. done. Qed. End fupd_plainly_derived. Section class_instance_updates. Context {PROP : bi}. Global Instance from_forall_step_fupdN `{!BiFUpd PROP, !BiPlainly PROP, !BiFUpdPlainly PROP} E {A} P (Φ : A → PROP) name n : FromForall P Φ name → (∀ x, Plain (Φ x)) → FromForall (|={E}▷=>^n P) (λ a, |={E}▷=>^n (Φ a))%I name. Proof. rewrite /FromForall=>? ?. rewrite -step_fupdN_plain_forall. by apply step_fupdN_mono. Qed. End class_instance_updates.
import incidence_world.level05 --hide open IncidencePlane --hide /- We end this world by proving the existence of triangles using only incidence axioms. -/ variables {Ω : Type} [IncidencePlane Ω] --hide /- Lemma : There exist three lines that do not have a point in common. -/ lemma three_distinct_lines : ∃ (r s t: Line Ω), (∀ (P : Ω), ¬(P ∈ r ∧ P ∈ s ∧ P ∈ t)) := begin rcases existence Ω with ⟨A, B, C, ⟨hAB, hAC, hBC, h⟩⟩, use line_through A B, use line_through A C, use line_through B C, intros P H, have h1 : line_through A C ≠ line_through A B, { exact ne_of_not_share_point (line_through_right A C) h, }, by_cases hPA : P = A, { have hAlBC : A ∈ line_through B C, { rw ← hPA, exact H.2.2, }, have H1 : line_through A C = line_through B C, { exact equal_lines_of_contain_two_points hAC (line_through_left A C) hAlBC (line_through_right A C) (line_through_right B C), }, have H2 : line_through A C = line_through A B, { rw H1, exact equal_lines_of_contain_two_points hAB hAlBC (line_through_left A B) (line_through_left B C) (line_through_right A B), }, exact h1 H2, }, { have h2 : line_through A C = line_through A B, { exact equal_lines_of_contain_two_points hPA H.2.1 H.1 (line_through_left A C) (line_through_left A B), }, exact h1 h2, } end
But Raikkonen remains sceptical about Lotus’s pace. “I knew the gap was quite big still and we don’t have that speed right now,” he said. “Second is not too bad, it is the best I can gain with the team. I’d rather be in first place, but we didn’t have the speed. “We had a very small update, I would say it is the same as in the last race,” he said. “It seems to be working OK. We have some issues with some stuff, but it’s a similar story to Malaysia. Championship leader Sebastian Vettel and McLaren’s Jenson Button chose to sit out the pole battle and run medium tyres in Q3, hoping for a race strategy advantage. Raikkonen was confident Lotus’s tactics were right.
[STATEMENT] lemma prop_normalise [rule_format]: "(A | B) | C == A | B | C" "(A & B) & C == A & B & C" "A | B == ~(~A & ~B)" "~~ A == A" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (((A \<or> B) \<or> C \<equiv> A \<or> B \<or> C) &&& (A \<and> B) \<and> C \<equiv> A \<and> B \<and> C) &&& (A \<or> B \<equiv> \<not> (\<not> A \<and> \<not> B)) &&& \<not> \<not> A \<equiv> A [PROOF STEP] by auto
module Idris.Codegen.ExtSTG.ANFToSTG import public Idris.Codegen.ExtSTG.Core import Compiler.ANF import Core.Context import Core.Core import Core.TT import Data.IOArray import Libraries.Data.IntMap import Data.List import Libraries.Data.StringMap import Data.Strings import Data.Vect import Idris.Codegen.ExtSTG.STG import Idris.Codegen.ExtSTG.String import Prelude import Idris.Codegen.ExtSTG.StringTable import Idris.Codegen.ExtSTG.PrimOp import Idris.Codegen.ExtSTG.Erased import Idris.Codegen.ExtSTG.ADTMap import Idris.Codegen.ExtSTG.Foreign import Idris.Codegen.ExtSTG.ExternalTopIds import Debug.Trace tracef : (Show b) => (a -> b) -> a -> a tracef f a = trace (show (f a)) a {- Implementation notes * Idris primitive types are represented as Boxed values in STG. They are unboxed when they are applied to primitive operations, because primitive operations in STG work unboxed values. And they are unboxed when Idris' case expression matches on primitive values. * Handle of String literals from Idris to STG is different. In Idris ANF we can case match on string literals, but in STG it is not possible. In this case we have to generate a ifthenelse like embedded case matching for STG where the case scrutinee is a primitive operation to compare the value from the literal found in the case alternatives. Which introduces the next problem, string literals in STG are top-binders and they are represented as Addr# by the CMM. Having LitString with String is very misleading. So the points here: - When the code generator finds a String matcing case, it creates a top level bindings for String, which is considered as Addr# - When the Strings values are created, eg via readLine, they should do ByteArray allocations, which will be handled bye the garbage collector. When implementing a String Equality check (we must know the representation of the string OR just default back to Addr# ???) This step needs to be further checking TODO - String comparism primitive cStrCmp must be implemented in STG to solve this problem, this should a top level binding, whith a recursive function cStrCmp function. - The case chain which represents the ifthenelse chain should use the cStrCmp function. * Datatypes in STG and Idris ANF's IR are similar. - In STG datatypes are created by the STyCon which associates a type name with a Unique identifier and the list of data constructors SDataCon with their unique IDs too. - In ANF the data constructors and type constructors occupy the same namespace and the ones which are used only appear in the structure of the ANF program. This is not enough information for the STG backend to generate STG data type definitions. - Because there is only partial information in the ANF program, there is a need to look into the GlobalDef Context which is part of the Core compiler abstraction via `Ref Ctxt Defs`. From that source of information we have to remap type names and constructor names, which is currently done by a hack. All this detail can be found in the: TConsAndDCons namespace - TODO: Some words about matching data and type constructors * In ANF Erased values occupy arguments and they meant to be special values. In STG we create a simple data type with one constructor: Erased = Erased. During the ANF compilation when Erased in encuntered the corresponding value constructor in STG is referred. * TODO: Integer and String and AnyPtr * ... TODOs [+] Remove (Name, Name, Name) parameter from StgApp [+] Add FC information to binders [+] Write DataCon -> TypeCon association [+] Separate STG Type and Term namespaces [+] Fix mkDataConId [+] Implement primitive values marshalled to the right GHC boxed primitives [+] Implement Erased values, erased variables [+] Generate StringTable for String literals [.] Handle Data/Type constructors [+] Create StgConApp for data constructors [ ] Represent Type Constructors in unified datatype [ ] Match Type constructors in case expressions [ ] Implement Crash primitive [ ] Handle primitive case matches accordingly [ ] Generate STG main entry [.] Handle String matches with ifthenelse chains, using stringEq primop from STG [ ] Create a test program which reads from input. [.] Implement primitive operations [ ] Implement casting [ ] ShiftL/ShiftR for Word needs a wrapper: Differences in parameters at STG and ANF side. [ ] DoubleFloor/Ceiling also needs a wrapper function as in STG the result is an Integer. [ ] Check if the BelieveMe operation is correct in STG [*] Implement String handling STG code. [ ] FFI calls AExtPrim [ ] Create a test program which FFI calls into a library. [ ] Foreign definitions should be looked up from a file, which can be modified by the user. [ ] Module compilation [+] FIX: Use StgCase instead of StgLet, otherwise strict semantics breaks. [ ] Store defined/referred topLevelBinders [+] Figure out how to use MkAlt with indexed types [ ] Figure out the semantics for LazyReason in ANF Apps [ ] ... -} ||| Define an STG data type with one constructor. definePrimitiveDataType : UniqueMapRef => Ref Counter Int => DataTypeMapRef => (String, String, Constant) -> Core () definePrimitiveDataType (u, m, StringType) = do logLine "Defining String datatype." -- defineDataType (MkUnitId u) (MkModuleName m) !IdrisString -- TODO definePrimitiveDataType (u, m, c) = do t <- typeConNameForConstant c n <- dataConNameForConstant c d <- createSTyCon (t, SsUnhelpfulSpan t) [(n, AlgDataCon !(constantToPrimRep c), SsUnhelpfulSpan n)] defineDataType (MkUnitId u) (MkModuleName m) d ||| Create the primitive types section in the STG module. ||| ||| Idris primitive types are represented as boxed values in STG, with a datatype with one constructor. ||| Eg: data IdrInt = IdrInt #IntRep definePrimitiveDataTypes : UniqueMapRef => Ref Counter Int => DataTypeMapRef => Core () definePrimitiveDataTypes = traverse_ definePrimitiveDataType [ ("ghc-prim", "GHC.Types", IntType) , (MAIN_UNIT, MAIN_MODULE, IntegerType) -- TODO: This is bad, GMP Integer is needed here , ("base", "GHC.Word", Bits8Type) , ("base", "GHC.Word", Bits16Type) , ("base", "GHC.Word", Bits32Type) , ("base", "GHC.Word", Bits64Type) , ("ghc-prim", "GHC.Types", CharType) , ("ghc-prim", "GHC.Types", DoubleType) -- , (MAIN_UNIT, MAIN_MODULE, StringType) , (MAIN_UNIT, MAIN_MODULE, WorldType) ] -- TODO: Create ifthenelse chain for String literals ||| Compile constant for case alternative. compileAltConstant : Constant -> Core Lit compileAltConstant (I i) = pure $ LitNumber LitNumInt $ cast i compileAltConstant (BI i) = pure $ LitNumber LitNumInt i -- ??? How to represent BIG integers ??? compileAltConstant (B8 i) = pure $ LitNumber LitNumWord $ cast i compileAltConstant (B16 i) = pure $ LitNumber LitNumWord $ cast i compileAltConstant (B32 i) = pure $ LitNumber LitNumWord $ cast i compileAltConstant (B64 i) = pure $ LitNumber LitNumWord64 i compileAltConstant (Ch c) = pure $ LitChar c compileAltConstant (Db d) = pure $ LitDouble d compileAltConstant c = coreFail $ InternalError $ "compileAltConstant " ++ show c ||| Compile constant for APrimVal, Boxing a value in STG. compileConstant : Constant -> Core Lit compileConstant (I i) = pure $ LitNumber LitNumInt $ cast i compileConstant (BI i) = pure $ LitNumber LitNumInt i -- ??? How to represent BIG integers ??? compileConstant (B8 i) = pure $ LitNumber LitNumWord $ cast i compileConstant (B16 i) = pure $ LitNumber LitNumWord $ cast i compileConstant (B32 i) = pure $ LitNumber LitNumWord $ cast i compileConstant (B64 i) = pure $ LitNumber LitNumWord64 i compileConstant (Ch c) = pure $ LitChar c compileConstant (Db d) = pure $ LitDouble d compileConstant c = coreFail $ InternalError $ "compileConstant " ++ show c data ValueConstant : Constant -> Type where IntConstant : ValueConstant (I x) BigIntConstant : ValueConstant (BI x) Byte8Constant : ValueConstant (B8 x) Byte16Constant : ValueConstant (B16 x) Byte32Constant : ValueConstant (B32 x) Byte64Constant : ValueConstant (B64 x) CharConstant : ValueConstant (Ch x) DoubleConstant : ValueConstant (Db x) WorldConstant : ValueConstant WorldVal checkValueConstant : (c : Constant) -> Maybe (ValueConstant c) checkValueConstant (I _) = Just IntConstant checkValueConstant (BI _) = Just BigIntConstant checkValueConstant (B8 _) = Just Byte8Constant checkValueConstant (B16 _) = Just Byte16Constant checkValueConstant (B32 _) = Just Byte32Constant checkValueConstant (B64 _) = Just Byte64Constant checkValueConstant (Ch _) = Just CharConstant checkValueConstant (Db _) = Just DoubleConstant checkValueConstant WorldVal = Just WorldConstant checkValueConstant _ = Nothing checkValueConstantM : (c : Constant) -> Core (ValueConstant c) checkValueConstantM c = case checkValueConstant c of Nothing => coreFail $ InternalError $ "checkValueConstantM: " ++ show c ++ " is not a value constant." Just vc => pure vc valueConstantPrimReps : (c : Constant) -> ValueConstant c => List PrimRep valueConstantPrimReps (I _) = [IntRep] valueConstantPrimReps (BI _) = [IntRep] valueConstantPrimReps (B8 _) = [Word8Rep] valueConstantPrimReps (B16 _) = [Word16Rep] valueConstantPrimReps (B32 _) = [Word32Rep] valueConstantPrimReps (B64 _) = [Word64Rep] valueConstantPrimReps (Ch _) = [Word8Rep] valueConstantPrimReps (Db _) = [DoubleRep] valueConstantPrimReps WorldVal = [] valueConstantAlgDataCon : (c : Constant) -> ValueConstant c => DataConRep valueConstantAlgDataCon c = AlgDataCon (valueConstantPrimReps c) valueConstantName : (c : Constant) -> ValueConstant c => String valueConstantName (I _) = "I#" valueConstantName (BI _) = "GMPInt" valueConstantName (B8 _) = "W8#" valueConstantName (B16 _) = "W16#" valueConstantName (B32 _) = "W32#" valueConstantName (B64 _) = "W64#" valueConstantName (Ch _) = "C#" valueConstantName (Db _) = "D#" valueConstantName WorldVal = "IdrWorld" ||| Determine the Data constructor for the boxed primitive value. ||| Used in creating PrimVal ||| ||| The name of terms should coincide the ones that are defined in GHC's ecosystem. This ||| would make the transition easier, I hope. dataConIdForValueConstant : DataTypeMapRef => UniqueMapRef => Ref Counter Int => (c : Constant) -> ValueConstant c => Core DataConIdSg dataConIdForValueConstant c = mkDataConIdStr (valueConstantName c) tyConIdForValueConstant : UniqueMapRef => Ref Counter Int => FC -> Constant -> Core TyConId tyConIdForValueConstant _ (I _) = tyConIdForConstant IntType tyConIdForValueConstant _ (BI _) = tyConIdForConstant IntegerType tyConIdForValueConstant _ (B8 _) = tyConIdForConstant Bits8Type tyConIdForValueConstant _ (B16 _) = tyConIdForConstant Bits16Type tyConIdForValueConstant _ (B32 _) = tyConIdForConstant Bits32Type tyConIdForValueConstant _ (B64 _) = tyConIdForConstant Bits64Type tyConIdForValueConstant _ (Ch _) = tyConIdForConstant CharType tyConIdForValueConstant _ (Db _) = tyConIdForConstant DoubleType tyConIdForValueConstant _ WorldVal = tyConIdForConstant WorldType tyConIdForValueConstant fc other = coreFail $ InternalError $ "tyConIdForValueConstant " ++ show other ++ ":" ++ show fc primTypeForValueConstant : UniqueMapRef => Ref Counter Int => FC -> Constant -> Core PrimRep primTypeForValueConstant _ (I _) = pure IntRep primTypeForValueConstant _ (BI _) = pure IntRep primTypeForValueConstant _ (B8 _) = pure Word8Rep primTypeForValueConstant _ (B16 _) = pure Word16Rep primTypeForValueConstant _ (B32 _) = pure Word32Rep primTypeForValueConstant _ (B64 _) = pure Word64Rep primTypeForValueConstant _ (Ch _) = pure Word8Rep primTypeForValueConstant _ (Db _) = pure DoubleRep primTypeForValueConstant fc other = coreFail $ InternalError $ "primTypeForValueConstant " ++ show other ++ ":" ++ show fc createAlternatives : (r : RepType) -> List (Lit, Expr Core.stgRepType) -> Maybe (List (Alt r Core.stgRepType)) createAlternatives r [] = Just [] createAlternatives r ((l,b) :: ls) = do Refl <- decLitRepType l r a <- decAltLit l map ((MkAlt (AltLit l) () b) ::) $ createAlternatives r ls mutual compileANF : UniqueMapRef => Ref Counter Int => Ref ADTs ADTMap => StringTableRef => Ref Ctxt Defs => DataTypeMapRef => Core.Name.Name -> ANF -> Core (Expr Core.stgRepType) compileANF funName (AV fc var) = pure $ StgApp !(mkBinderIdVar fc funName Core.stgRepType var) [] stgRepType -- TODO: Figure out the semantics for LazyReason compileANF funToCompile (AAppName fc lazyReason funToCall args) = pure $ StgApp !(mkBinderIdName funToCall) !(traverse (mkStgArg fc funToCompile) args) stgRepType compileANF funToCompile (AUnderApp fc funToCall _ args) = pure $ StgApp !(mkBinderIdName funToCall) !(traverse (mkStgArg fc funToCompile) args) stgRepType -- TODO: Figure out the semantics for LazyReason compileANF funName (AApp fc lazyReason closure arg) = pure $ StgApp !(mkBinderIdVar fc funName Core.stgRepType closure) [!(mkStgArg fc funName arg)] stgRepType compileANF funName (ALet fc var expr body) = do pure $ StgCase PolyAlt -- It could be ForceUnbox, and only AltDefault should be used in Strict Let !(compileANF funName expr) !(mkSBinderLocal fc funName var) [ MkAlt AltDefault () !(compileANF funName body) ] -- TODO: Implement -- TODO: Use the ConInfo if possible compileANF _ acon@(ACon fc name coninfo Nothing args) = do -- Types probably will be represented with one STG TyCon and DataCon -- for every type. coreFail $ InternalError $ "Figure out how to represent a type as a value!" compileANF funName acon@(ACon fc name coninfo (Just tag) args) = do -- Lookup the constructor based on the name. -- The tag information is not relevant here. -- Args are variables (rep ** dataConId) <- mkDataConId name conArgs <- compileConArgs fc funName args rep pure $ StgConApp dataConId conArgs -- TODO: Figure out the semantics for LazyReason compileANF funName (AOp fc lazyReason prim args) = compilePrimOp fc funName prim args -- TODO: Implement -- TODO: Figure out the semantics for LazyReason compileANF _ aext@(AExtPrim _ lazyReason name args) = do logLine $ "To be implemented: " ++ show aext pure $ StgApp (!(mkBinderIdStr STRING_FROM_ADDR)) [ mkArgSg $ StgLitArg $ LitString $ "AExtPrim " ++ show name ++ " " ++ show args ] (SingleValue LiftedRep) compileANF funName (AConCase fc scrutinee alts mdef) = do -- Compute the alt-type tyCon <- do -- Lookup the STyCon definition from the alt names namesAndTyCons <- traverse (\(MkAConAlt name coninfo tag args body) => map (name,) (lookupTyCon name)) alts -- Check if there is exactly one STyCon definition is found [] <- pure $ mapMaybe (\(n,x) => case x of { Nothing => Just n; _ => Nothing}) namesAndTyCons | nonDefinedConstructors => coreFail $ InternalError $ unlines $ "Constructors not having type information: " :: map show nonDefinedConstructors case mapMaybe snd namesAndTyCons of [] => coreFail $ InternalError $ "No type constructor is found for: " ++ show fc [t] => pure $ STyCon.Id t ts => case nub (map STyCon.Id ts) of [] => coreFail $ InternalError "Impossible case in compile AConCase" [t] => pure t ts => coreFail $ InternalError $ "More than TyCon found for: " ++ show fc scrutBinder <- mkBinderIdVar fc funName Core.stgRepType scrutinee let stgScrutinee = StgApp scrutBinder [] stgRepType caseBinder <- mkFreshSBinderStr LocalScope fc "conCaseBinder" stgDefAlt <- maybe (pure []) (\x => do stgBody <- compileANF funName x pure [MkAlt AltDefault () stgBody]) mdef stgAlts <- traverse (compileConAlt fc funName) alts pure $ StgCase (AlgAlt tyCon) stgScrutinee caseBinder (stgDefAlt ++ stgAlts) compileANF funName (AConstCase fc scrutinee alts mdef) = do let checkStringAlt : AConstAlt -> Bool checkStringAlt (MkAConstAlt (Str _) _) = True checkStringAlt _ = False let getAltConstant : AConstAlt -> Constant getAltConstant (MkAConstAlt c _) = c case partition checkStringAlt alts of -- No String alts ([], []) => coreFail $ InternalError "Empty alternatives..." ([], alts@(alt::_)) => do [tyCon] <- map nub $ traverse (tyConIdForValueConstant fc . getAltConstant) alts | ts => coreFail $ InternalError $ "Constant case found " ++ show (length ts) ++ " type constructors in " ++ show fc let altConstant = getAltConstant alt valueConst <- checkValueConstantM altConstant ((AlgDataCon [rep]) ** dtCon) <- dataConIdForValueConstant altConstant | wrongRep => coreFail $ InternalError $ "DataConId has wrong RepType: " ++ show (fc, funName, wrongRep) primVal <- mkFreshSBinderRepStr LocalScope (SingleValue rep) fc "primVal" litBodies <- traverse \case (MkAConstAlt c b) => do lit <- compileAltConstant c body <- compileANF funName b pure (lit, body) alts let Just stgAlts = createAlternatives (SingleValue rep) litBodies | Nothing => coreFail $ InternalError $ "Representation in literal types were different then expexted:" ++ show (rep, map fst litBodies) stgDefAlt <- maybe (pure []) (\x => do stgBody <- compileANF funName x pure [the (Alt (SingleValue rep) Core.stgRepType) (MkAlt AltDefault () stgBody)]) mdef -- stgAlts <- traverse (compileConstAlt funName) alts pure $ StgCase (AlgAlt tyCon) (StgApp !(mkBinderIdVar fc funName Core.stgRepType scrutinee) [] stgRepType) !nonused [ MkAlt (AltDataCon (mkDataConIdSg dtCon)) primVal $ StgCase (PrimAlt rep) (StgApp (binderId primVal) [] (SingleValue rep)) !(nonusedRep (SingleValue rep)) (stgDefAlt ++ stgAlts) ] -- String alts (strAlts, []) => do mStgDef <- traverseOpt (compileANF funName) mdef scrutBinder <- mkBinderIdVar fc funName Core.stgRepType scrutinee -- TODO: Make this typesafe let caseChain : List AConstAlt -> Core (Expr Core.stgRepType) caseChain [] = coreFail $ InternalError "Impossible, empty string alternatives." caseChain [MkAConstAlt (Str s) body] = do stringLit <- mkFreshSBinderStr LocalScope fc "stringLitBinder" stringEqResult <- mkFreshSBinderStr LocalScope fc "stringEqResult" unusedBinder <- mkFreshSBinderRepStr LocalScope (SingleValue IntRep) fc "unusedBinder" stringEqResultUnboxed <- mkFreshSBinderRepStr LocalScope (SingleValue IntRep) fc "stringEqResultUnboxed" sBinderId <- registerString fc s ((AlgDataCon [IntRep]) ** ti) <- dataConIdForConstant IntType | wrongRep => coreFail $ InternalError $ "DataConId has wrong RepType: " ++ show (fc, funName, wrongRep) pure $ -- Look up the string from the string table. StgCase (AlgAlt !idrisStringTyConId) (StgApp !stringFromAddrBinderId2 [mkArgSg $ StgVarArg sBinderId] (SingleValue LiftedRep)) stringLit [ MkAlt AltDefault () -- Call the strEq function $ StgCase (AlgAlt !(tyConIdForConstant IntType)) (StgApp !(mkBinderIdStr "Idris.String.strEq") [ mkArgSg $ StgVarArg $ scrutBinder , mkArgSg $ StgVarArg $ binderId stringLit ] stgRepType) stringEqResult [ MkAlt (AltDataCon (mkDataConIdSg ti)) stringEqResultUnboxed $ -- Unbox the result StgCase (PrimAlt IntRep) (StgApp (binderId stringEqResultUnboxed) [] (SingleValue IntRep)) unusedBinder $ catMaybes [ -- Match on False: call default (MkAlt AltDefault ()) <$> mStgDef , -- Match on True: call body Just $ MkAlt (AltLit (LitNumber LitNumInt 1)) () !(compileANF funName body) ] ] ] caseChain ((MkAConstAlt (Str s) body) :: rest) = do stringLit <- mkFreshSBinderStr LocalScope fc "stringLitBinder" stringEqResult <- mkFreshSBinderStr LocalScope fc "stringEqResult" unusedBinder <- mkFreshSBinderRepStr LocalScope (SingleValue IntRep) fc "unusedBinder" stringEqResultUnboxed <- mkFreshSBinderRepStr LocalScope (SingleValue IntRep) fc "stringEqResultUnboxed" sBinderId <- registerString fc s ((AlgDataCon [IntRep]) ** ti) <- dataConIdForConstant IntType | wrongRep => coreFail $ InternalError $ "DataConId has wrong RepType: " ++ show (fc, funName, wrongRep) pure $ -- Look up the string from the string table. StgCase (AlgAlt !idrisStringTyConId) (StgApp !stringFromAddrBinderId2 [mkArgSg $ StgVarArg sBinderId] (SingleValue LiftedRep)) stringLit [ MkAlt AltDefault () -- Call the strEq function $ StgCase (AlgAlt !(tyConIdForConstant IntType)) (StgApp !(mkBinderIdStr "Idris.String.strEq") [ mkArgSg $ StgVarArg scrutBinder , mkArgSg $ StgVarArg $ binderId stringLit ] stgRepType) stringEqResult [ MkAlt (AltDataCon (mkDataConIdSg ti)) stringEqResultUnboxed $ -- Unbox the result StgCase (PrimAlt IntRep) (StgApp (binderId stringEqResultUnboxed) [] (SingleValue IntRep)) unusedBinder $ -- Match on False: check the next alternative [ MkAlt AltDefault () !(caseChain rest) -- Match on True: call body , MkAlt (AltLit (LitNumber LitNumInt 1)) () !(compileANF funName body) ] ] ] caseChain ((MkAConstAlt _ _)::_) = coreFail $ InternalError "Impossible, not expected non-string literal." caseChain strAlts -- Mixed alternatives _ => coreFail $ InternalError $ "Mixed string and non-string constant alts" ++ show fc compileANF _ (APrimVal fc (Str str)) = do topLevelBinder <- registerString fc str stringAddress <- mkFreshSBinderRepStr LocalScope (SingleValue AddrRep) fc "stringPrimVal" pure $ StgCase (PrimAlt AddrRep) (StgApp topLevelBinder [] (SingleValue AddrRep)) -- TODO: Is this right? stringAddress [ MkAlt AltDefault () $ StgApp (snd !stringFromAddrBinderId) [ mkArgSg $ StgVarArg $ binderId stringAddress ] stgRepType ] compileANF _ (APrimVal fc WorldVal) = do (AlgDataCon [] ** dataConId) <- dataConIdForValueConstant WorldVal | other => coreFail $ InternalError $ show (fc,WorldVal) ++ " has different representation: " ++ show other pure $ StgConApp dataConId () compileANF _ (APrimVal fc c) = do -- TODO: Handle WorldVal valueConstant <- checkValueConstantM c (AlgDataCon [rep] ** dataConId) <- dataConIdForValueConstant c | other => coreFail $ InternalError $ show (fc,c) ++ " has different representation: " ++ show other lit <- compileConstant c same <- checkSemiDecEq ("compileANF " ++ show (fc, c)) (SingleValue rep) (litRepType lit) pure $ StgConApp dataConId (StgLitArg lit) compileANF _ (AErased fc) = do sbinder <- mkSBinderStr fc ERASED_TOPLEVEL_NAME pure $ StgApp (binderId sbinder) [] (SingleValue LiftedRep) -- TODO: Implement: Use Crash primop. errorBlech2 for reporting error ("%s", msg) compileANF _ ac@(ACrash _ msg) = do logLine $ "To be implemented: " ++ show ac pure $ StgApp (!(mkBinderIdStr STRING_FROM_ADDR)) [ mkArgSg $ StgLitArg $ LitString $ "ACrash " ++ msg ] (SingleValue LiftedRep) mkArgList : UniqueMapRef => Ref Counter Int => Ref ADTs ADTMap => FC -> Name.Name -> List AVar -> (ps : List PrimRep) -> Core (ArgList ps) mkArgList _ _ [] [] = pure [] mkArgList f n (a::as) (r::rs) = do arg <- map StgVarArg $ mkBinderIdVar f n (SingleValue r) a args <- mkArgList f n as rs pure (arg :: args) mkArgList _ _ _ _ = coreFail $ InternalError "mkArgList: inconsistent state." compileConArgs : UniqueMapRef => Ref Counter Int => Ref ADTs ADTMap => FC -> Name.Name -> List AVar -> (r : DataConRep) -> Core (StgConAppArgType r) compileConArgs fc funName _ (UnboxedTupleCon _) = coreFail $ InternalError "compileConArgs: UnboxedTupleCon" compileConArgs fc funName [] (AlgDataCon []) = pure () compileConArgs fc funName [a] (AlgDataCon [r]) = StgVarArg <$> mkBinderIdVar fc funName (SingleValue r) a compileConArgs fc funName (a0 :: a1 :: as) (AlgDataCon (r0 :: r1 :: rs)) = mkArgList fc funName (a0 :: a1 :: as) (r0 :: r1 :: rs) compileConArgs _ _ _ _ = coreFail $ InternalError "compileConArgs: inconsistent state #2" createConAltBinders : UniqueMapRef => Ref Counter Int => Ref ADTs ADTMap => FC -> Core.Name.Name -> List Int -> (ps : List PrimRep) -> Core (BList ps) createConAltBinders fc funName [] [] = pure [] createConAltBinders fc funName (i :: is) (p :: ps) = do x <- mkSBinderRepLocal (SingleValue p) fc funName i xs <- createConAltBinders fc funName is ps pure (x :: xs) createConAltBinders fc funName is ps = coreFail $ InternalError $ "createConAltBinders found irregularities: " -- ++ show (is,ps) compileConAltArgs : UniqueMapRef => Ref Counter Int => Ref ADTs ADTMap => FC -> Core.Name.Name -> List Int -> (r : DataConRep) -> Core (DataConRepType r) compileConAltArgs fc funName _ (UnboxedTupleCon _) = coreFail $ InternalError $ "Encountered UnboxedTuple when compiling con alt: " ++ show (funName, fc) compileConAltArgs fc funName [] (AlgDataCon []) = pure () compileConAltArgs fc funName [i] (AlgDataCon [rep]) = mkSBinderRepLocal (SingleValue rep) fc funName i compileConAltArgs fc funName (i0 :: i1 :: is) (AlgDataCon (r0 :: r1 :: rs)) = createConAltBinders fc funName (i0 :: i1 :: is) (r0 :: r1 :: rs) compileConAltArgs fc funname is alt = coreFail $ InternalError $ "Encountered irregularities " -- ++ show (is, alt) compileConAlt : UniqueMapRef => Ref Counter Int => Ref ADTs ADTMap => StringTableRef => Ref Ctxt Defs => DataTypeMapRef => FC -> Core.Name.Name -> AConAlt -> Core (Alt (SingleValue LiftedRep) Core.stgRepType) compileConAlt fc funName c@(MkAConAlt name coninfo Nothing args body) = do coreFail $ InternalError $ "Figure out how to do pattern match on type: " ++ show name compileConAlt fc funName c@(MkAConAlt name coninfo (Just tag) args body) = do stgBody <- compileANF funName body stgDataCon <- mkDataConId name stgArgs <- compileConAltArgs fc funName args (fst stgDataCon) pure $ MkAlt (AltDataCon stgDataCon) stgArgs stgBody compileTopBinding : UniqueMapRef => Ref Counter Int => Ref Ctxt Defs => StringTableRef => Ref ADTs ADTMap => Ref ExternalBinder ExtBindMap => DataTypeMapRef => (Core.Name.Name, ANFDef) -> Core (Maybe TopBinding) compileTopBinding (funName,MkAFun args body) = do -- logLine $ "Compiling: " ++ show funName funBody <- compileANF funName body funArguments <- traverse (map mkSBinderSg . mkSBinderLocal emptyFC funName) args funNameBinder <- mkSBinderName emptyFC funName rhs <- pure $ StgRhsClosure ReEntrant funArguments funBody -- Question: Is Reentrant OK here? -- TODO: Calculate Rec or NonRec binding <- pure $ StgRec [(funNameBinder,rhs)] -- Question: Is non-recursive good here? Test it. pure $ Just $ StgTopLifted binding compileTopBinding (name,con@(MkACon aname tag arity)) = do -- logLine $ "TopLevel MkACon: " ++ show (name, aname, con) -- Covered in the LearnDataTypes section pure Nothing compileTopBinding (name,MkAForeign css fargs rtype) = do -- logLine $ "Found foreign: " ++ show name map Just $ foreign name css fargs rtype compileTopBinding (name,MkAError body) = do logLine $ "Skipping error: " ++ show name pure Nothing groupExternalTopIds : List (UnitId, ModuleName, SBinderSg) -> List (UnitId, List (ModuleName, List SBinderSg)) groupExternalTopIds = resultList . unionsMap . map singletonMap where EntryMap : Type EntryMap = StringMap (StringMap (List SBinderSg)) resultList : EntryMap -> List (UnitId, List (ModuleName, List SBinderSg)) resultList = map (bimap MkUnitId (map (mapFst MkModuleName) . toList)) . toList unionsMap : List EntryMap -> EntryMap unionsMap = foldl (mergeWith (mergeWith (++))) empty singletonMap : (UnitId, ModuleName, SBinderSg) -> EntryMap singletonMap (MkUnitId n, MkModuleName m, sbinder) = singleton n (singleton m [sbinder]) partitionBy : (a -> Either b c) -> List a -> (List b, List c) partitionBy f [] = ([], []) partitionBy f (x :: xs) = let (bs, cs) = partitionBy f xs in case f x of (Left b) => (b :: bs, cs) (Right c) => (bs, c :: cs) defineMain : UniqueMapRef => Ref Counter Int => Core TopBinding defineMain = do main <- mkSBinderExtId emptyFC "main" voidArg <- mkSBinderRepLocalStr (SingleValue VoidRep) "mainVoidArg" progMain <- mkSBinderTopLevel "{__mainExpression:0}" pure $ topLevel main [mkSBinderSg voidArg] $ StgApp (binderId progMain) [] stgRepType -- We compile only one enormous module export compileModule : {auto _ : UniqueMapRef} -> {auto _ : Ref Counter Int} -> {auto _ : DataTypeMapRef} -> {auto _ : StringTableRef} -> {auto _ : Ref Ctxt Defs} -> {auto _ : Ref ExternalBinder ExtBindMap} -> List (Core.Name.Name, ANFDef) -> Core Module compileModule anfDefs = do adts <- mkADTs registerHardcodedExtTopIds definePrimitiveDataTypes defineErasedADT createDataTypes defineStringTypes let phase = "Main" let moduleUnitId = MkUnitId "main" let name = MkModuleName "Main" -- : ModuleName let sourceFilePath = "some.idr" -- : String let foreignStubs = NoStubs -- : ForeignStubs -- ??? let hasForeignExported = False -- : Bool let dependency = [] -- : List (UnitId, List ModuleName) mainTopBinding <- defineMain erasedTopBinding <- erasedTopBinding strFunctions1 <- String.stgTopBindings strFunctions2 <- catMaybes <$> traverse compileTopBinding topLevelANFDefs let stringTopBindings = strFunctions1 ++ strFunctions2 compiledTopBindings <- catMaybes <$> traverse compileTopBinding anfDefs stringTableBindings <- StringTable.topLevelBinders let topBindings = mainTopBinding :: erasedTopBinding :: stringTopBindings ++ stringTableBindings ++ compiledTopBindings tyCons <- getDefinedDataTypes -- : List (UnitId, List (ModuleName, List tcBnd)) let foreignFiles = [] -- : List (ForeignSrcLang, FilePath) externalTopIds0 <- genExtTopIds let externalTopIds = groupExternalTopIds externalTopIds0 pure $ MkModule phase moduleUnitId name sourceFilePath foreignStubs hasForeignExported dependency externalTopIds tyCons topBindings foreignFiles {- RepType: How doubles are represented? Write an example program: Boxed vs Unboxed https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/Builtin/primops.txt.pp -}
[STATEMENT] lemma sat_forall: assumes "\<And>v. \<sigma>, s(x := v), \<Delta> \<Turnstile> A" shows "\<sigma>, s, \<Delta> \<Turnstile> Forall x A" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<sigma>, s, \<Delta> \<Turnstile> Forall x A [PROOF STEP] by (simp add: assms)
/- Copyright (c) 2022 Paul Reichert. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Paul Reichert ! This file was ported from Lean 3 source module linear_algebra.affine_space.restrict ! leanprover-community/mathlib commit 09258fb7f75d741b7eda9fa18d5c869e2135d9f1 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace /-! # Affine map restrictions This file defines restrictions of affine maps. ## Main definitions * The domain and codomain of an affine map can be restricted using `AffineMap.restrict`. ## Main theorems * The associated linear map of the restriction is the restriction of the linear map associated to the original affine map. * The restriction is injective if the original map is injective. * The restriction in surjective if the codomain is the image of the domain. -/ variable {k V₁ P₁ V₂ P₂ : Type _} [Ring k] [AddCommGroup V₁] [AddCommGroup V₂] [Module k V₁] [Module k V₂] [AddTorsor V₁ P₁] [AddTorsor V₂ P₂] -- not an instance because it loops with `Nonempty` theorem AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E] {φ : P₁ →ᵃ[k] P₂} : Nonempty (E.map φ) := by obtain ⟨x, hx⟩ := id Ene refine' ⟨⟨φ x, AffineSubspace.mem_map.mpr ⟨x, hx, rfl⟩⟩⟩ #align affine_subspace.nonempty_map AffineSubspace.nonempty_map -- Porting note: removed "local nolint fails_quickly" attribute attribute [local instance] AffineSubspace.nonempty_map AffineSubspace.toAddTorsor /-- Restrict domain and codomain of an affine map to the given subspaces. -/ def AffineMap.restrict (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : E →ᵃ[k] F := by refine' ⟨_, _, _⟩ · exact fun x => ⟨φ x, hEF <| AffineSubspace.mem_map.mpr ⟨x, x.property, rfl⟩⟩ · refine' φ.linear.restrict (_ : E.direction ≤ F.direction.comap φ.linear) rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction] exact AffineSubspace.direction_le hEF · intro p v simp only [Subtype.ext_iff, Subtype.coe_mk, AffineSubspace.coe_vadd] apply AffineMap.map_vadd #align affine_map.restrict AffineMap.restrict theorem AffineMap.restrict.coe_apply (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) (x : E) : ↑(φ.restrict hEF x) = φ x := rfl #align affine_map.restrict.coe_apply AffineMap.restrict.coe_apply theorem AffineMap.restrict.linear_aux {φ : P₁ →ᵃ[k] P₂} {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} (hEF : E.map φ ≤ F) : E.direction ≤ F.direction.comap φ.linear := by rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction] exact AffineSubspace.direction_le hEF #align affine_map.restrict.linear_aux AffineMap.restrict.linear_aux theorem AffineMap.restrict.linear (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : (φ.restrict hEF).linear = φ.linear.restrict (AffineMap.restrict.linear_aux hEF) := rfl #align affine_map.restrict.linear AffineMap.restrict.linear theorem AffineMap.restrict.injective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Injective φ) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : Function.Injective (AffineMap.restrict φ hEF) := by intro x y h simp only [Subtype.ext_iff, Subtype.coe_mk, AffineMap.restrict.coe_apply] at h⊢ exact hφ h #align affine_map.restrict.injective AffineMap.restrict.injective theorem AffineMap.restrict.surjective (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (h : E.map φ = F) : Function.Surjective (AffineMap.restrict φ (le_of_eq h)) := by rintro ⟨x, hx : x ∈ F⟩ rw [← h, AffineSubspace.mem_map] at hx obtain ⟨y, hy, rfl⟩ := hx exact ⟨⟨y, hy⟩, rfl⟩ #align affine_map.restrict.surjective AffineMap.restrict.surjective theorem AffineMap.restrict.bijective {E : AffineSubspace k P₁} [Nonempty E] {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Injective φ) : Function.Bijective (φ.restrict (le_refl (E.map φ))) := ⟨AffineMap.restrict.injective hφ _, AffineMap.restrict.surjective _ rfl⟩ #align affine_map.restrict.bijective AffineMap.restrict.bijective
[STATEMENT] lemma swap_lemma [simp]: "rec_eval (rec_swap f) [x, y] = rec_eval f [y, x]" [PROOF STATE] proof (prove) goal (1 subgoal): 1. rec_eval (rec_swap f) [x, y] = rec_eval f [y, x] [PROOF STEP] by (simp add: rec_swap_def)
[STATEMENT] lemma card_UNION: assumes "finite A" and "\<forall>k \<in> A. finite k" shows "card (\<Union>A) = nat (\<Sum>I | I \<subseteq> A \<and> I \<noteq> {}. (- 1) ^ (card I + 1) * int (card (\<Inter>I)))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. card (\<Union> A) = nat (\<Sum>I | I \<subseteq> A \<and> I \<noteq> {}. (- 1) ^ (card I + 1) * int (card (\<Inter> I))) [PROOF STEP] by (simp only: flip: int_card_UNION [OF assms])
module Control.Monad.Zero where open import Prelude record MonadZero {a b} (M : Set a → Set b) : Set (lsuc a ⊔ b) where instance constructor mkMonadZero field overlap {{super-zero}} : FunctorZero M overlap {{super-monad}} : Monad M open MonadZero public
theory Check imports Submission begin theorem add_assoc: "add (add x y) z = add x (add y z)" by (rule Submission.add_assoc) theorem add_commut: "add x y = add y x" by (rule Submission.add_commut) theorem val_inline: "aval (inline e) s = wval e s" by (rule Submission.val_inline) theorem wval_elim: "wval (elim e) s = wval e s" by (rule Submission.wval_elim) end
lemma convex_set_sum: assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)" shows "convex (\<Sum>i\<in>A. B i)"
------------------------------------------------------------------------------ -- Testing the class AgdaInternal.RemoveProofTerms.RemoveVar: Lam term ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module RemoveVar.LamTerm where -- We add 3 to the fixities of the standard library. infixr 8 _∷_ infixr 7 _,_ infix 7 _≡_ _≈_ infixr 5 _∧_ infix 5 ∃ ------------------------------------------------------------------------------ postulate D : Set _∷_ : D → D → D Stream : D → Set _≈_ : D → D → Set data _∧_ (A B : Set) : Set where _,_ : A → B → A ∧ B data ∃ (A : D → Set) : Set where _,_ : (t : D) → A t → ∃ A syntax ∃ (λ x → e) = ∃[ x ] e data _≡_ (x : D) : D → Set where refl : x ≡ x postulate Stream-gfp₂ : (P : D → Set) → -- P is post-fixed point of StreamF. (∀ {xs} → P xs → ∃[ x' ] ∃[ xs' ] P xs' ∧ xs ≡ x' ∷ xs') → -- Stream is greater than P. ∀ {xs} → P xs → Stream xs postulate ≈-gfp₁ : ∀ {xs ys} → xs ≈ ys → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs' ≈ ys' ∧ xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' {-# ATP axiom ≈-gfp₁ #-} -- See Issue #81. P : D → Set P ws = ∃[ zs ] ws ≈ zs {-# ATP definition P #-} ≈→Stream : ∀ {xs ys} → xs ≈ ys → Stream xs ≈→Stream {xs} {ys} xs≈ys = Stream-gfp₂ P helper (ys , xs≈ys) where postulate helper : ∀ {ws} → P ws → ∃[ w' ] ∃[ ws' ] P ws' ∧ ws ≡ w' ∷ ws' {-# ATP prove helper #-}
! PR fortran/71014 ! { dg-do run } ! { dg-additional-options "-O0" } program pr71014 implicit none integer :: i, j integer, parameter :: t = 100*101/2 integer :: s(16) s(:) = 0 !$omp parallel do do j = 1, 16 associate (k => j) do i = 1, 100 s(j) = s(j) + i end do end associate end do if (any(s /= t)) call abort end program pr71014
// Copyright John Maddock 2006. // Copyright Paul A. Bristow 2007, 2009 // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifdef _MSC_VER # pragma warning (disable : 4996) // POSIX name for this item is deprecated # pragma warning (disable : 4224) // nonstandard extension used : formal parameter 'arg' was previously defined as a type # pragma warning (disable : 4180) // qualifier applied to function type has no meaning; ignored #endif #include <boost/math/concepts/real_concept.hpp> #include <boost/test/test_exec_monitor.hpp> #include <boost/test/floating_point_comparison.hpp> #include <boost/math/special_functions/math_fwd.hpp> #include <boost/math/tools/stats.hpp> #include <boost/math/tools/test.hpp> #include <boost/math/constants/constants.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/array.hpp> #include "functor.hpp" #include "test_beta_hooks.hpp" #include "handle_test_result.hpp" #undef small // VC++ #defines small char !!!!!! #ifndef SC_ #define SC_(x) static_cast<T>(BOOST_JOIN(x, L)) #endif template <class T> void do_test_beta(const T& data, const char* type_name, const char* test_name) { typedef typename T::value_type row_type; typedef typename row_type::value_type value_type; typedef value_type (*pg)(value_type, value_type); #if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS) pg funcp = boost::math::beta<value_type, value_type>; #else pg funcp = boost::math::beta; #endif boost::math::tools::test_result<value_type> result; std::cout << "Testing " << test_name << " with type " << type_name << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; // // test beta against data: // result = boost::math::tools::test( data, bind_func(funcp, 0, 1), extract_result(2)); handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::beta", test_name); #ifdef TEST_OTHER if(::boost::is_floating_point<value_type>::value){ funcp = other::beta; result = boost::math::tools::test( data, bind_func(funcp, 0, 1), extract_result(2)); print_test_result(result, data[result.worst()], result.worst(), type_name, "other::beta"); } #endif std::cout << std::endl; } template <class T> void test_beta(T, const char* name) { // // The actual test data is rather verbose, so it's in a separate file // // The contents are as follows, each row of data contains // three items, input value a, input value b and beta(a, b): // # include "beta_small_data.ipp" do_test_beta(beta_small_data, name, "Beta Function: Small Values"); # include "beta_med_data.ipp" do_test_beta(beta_med_data, name, "Beta Function: Medium Values"); # include "beta_exp_data.ipp" do_test_beta(beta_exp_data, name, "Beta Function: Divergent Values"); } template <class T> void test_spots(T) { // // Basic sanity checks, tolerance is 20 epsilon expressed as a percentage: // T tolerance = boost::math::tools::epsilon<T>() * 20 * 100; T small = boost::math::tools::epsilon<T>() / 1024; BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(1), static_cast<T>(1)), static_cast<T>(1), tolerance); BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(1), static_cast<T>(4)), static_cast<T>(0.25), tolerance); BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), static_cast<T>(1)), static_cast<T>(0.25), tolerance); BOOST_CHECK_CLOSE(::boost::math::beta(small, static_cast<T>(4)), 1/small, tolerance); BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), small), 1/small, tolerance); BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), static_cast<T>(20)), static_cast<T>(0.00002823263692828910220214568040654997176736L), tolerance); BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(0.0125L), static_cast<T>(0.000023L)), static_cast<T>(43558.24045647538375006349016083320744662L), tolerance); }
[GOAL] z : ℂ ⊢ z ∈ circle ↔ ↑normSq z = 1 [PROOFSTEP] simp [Complex.abs] [GOAL] z : { x // x ∈ circle } ⊢ ↑normSq ↑z = 1 [PROOFSTEP] simp [normSq_eq_abs] [GOAL] z : { x // x ∈ circle } ⊢ ↑z⁻¹ = ↑(starRingEnd ℂ) ↑z [PROOFSTEP] rw [coe_inv_circle, inv_def, normSq_eq_of_mem_circle, inv_one, ofReal_one, mul_one] [GOAL] z : ℂ hz : z ≠ 0 ⊢ ↑Complex.abs (↑(starRingEnd ℂ) z / z) = 1 [PROOFSTEP] rw [map_div₀, abs_conj, div_self] [GOAL] z : ℂ hz : z ≠ 0 ⊢ ↑Complex.abs z ≠ 0 [PROOFSTEP] exact Complex.abs.ne_zero hz [GOAL] t : ℝ ⊢ exp (↑t * I) ∈ circle [PROOFSTEP] simp [exp_mul_I, abs_cos_add_sin_mul_I] [GOAL] ⊢ ↑(↑expMapCircle 0) = ↑1 [PROOFSTEP] rw [expMapCircle_apply, ofReal_zero, zero_mul, exp_zero, Submonoid.coe_one] [GOAL] x y : ℝ ⊢ ↑(↑expMapCircle (x + y)) = ↑(↑expMapCircle x * ↑expMapCircle y) [PROOFSTEP] simp only [expMapCircle_apply, Submonoid.coe_mul, ofReal_add, add_mul, Complex.exp_add]
section \<open>Verifying term graph optimizations using Isabelle/HOL\<close> theory TreeSnippets imports Canonicalizations.BinaryNode Canonicalizations.ConditionalPhase Canonicalizations.AddPhase Semantics.TreeToGraphThms Snippets.Snipping "HOL-Library.OptionalSugar" begin \<comment> \<open>First, we disable undesirable markup.\<close> declare [[show_types=false,show_sorts=false]] no_notation ConditionalExpr ("_ ? _ : _") \<comment> \<open>We want to disable and reduce how aggressive automated tactics are as obligations are generated in the paper\<close> method unfold_size = - method unfold_optimization = (unfold rewrite_preservation.simps, unfold rewrite_termination.simps, rule conjE, simp, simp del: le_expr_def) subsection \<open>Markup syntax for common operations\<close> notation (latex) kind ("_\<llangle>_\<rrangle>") notation (latex) valid_value ("_ \<in> _") notation (latex) val_to_bool ("\<^latex>\<open>bool-of\<close> _") notation (latex) constantAsStamp ("\<^latex>\<open>stamp-from-value\<close> _") notation (latex) find_node_and_stamp ("\<^latex>\<open>find-matching\<close> _") notation (latex) add_node ("\<^latex>\<open>insert\<close> _") notation (latex) get_fresh_id ("\<^latex>\<open>fresh-id\<close> _") notation (latex) size ("\<^latex>\<open>trm(\<close>_\<^latex>\<open>)\<close>") subsection \<open>Representing canonicalization optimizations\<close> text \<open> We wish to provide an example of the semantics layers at which optimizations can be expressed. \<close> \<comment> \<open>Algebraic laws\<close> lemma diff_self: fixes x :: int shows "x - x = 0" by simp lemma diff_diff_cancel: fixes x y :: int shows "x - (x - y) = y" by simp thm diff_self thm diff_diff_cancel snipbegin \<open>algebraic-laws\<close> text \<open>\begin{align} @{thm diff_self[show_types=false]}\\ @{thm diff_diff_cancel[show_types=false]} \end{align}\<close> snipend - \<comment> \<open>Values\<close> lemma diff_self_value: "\<forall>x::'a::len word. x - x = 0" by simp lemma diff_diff_cancel_value: "\<forall> x y::'a::len word . x - (x - y) = y" by simp snipbegin \<open>algebraic-laws-values\<close> text_raw \<open>\begin{align} @{thm diff_self_value[show_types]} \label{prop-v-minus-v}\\ @{thm diff_diff_cancel_value[show_types]} \label{prop-redundant-sub} \end{align}\<close> snipend - \<comment> \<open>Expression\<close> translations "n" <= "CONST ConstantExpr (CONST IntVal b n)" "x - y" <= "CONST BinaryExpr (CONST BinSub) x y" notation (ExprRule output) Refines ("_ \<longmapsto> _") lemma diff_self_expr: assumes "\<forall>m p v. [m,p] \<turnstile> exp[x - x] \<mapsto> IntVal b v" shows "exp[x - x] \<ge> exp[const (IntVal b 0)]" using assms apply simp by (metis(full_types) evalDet val_to_bool.simps(1) zero_neq_one) method open_eval = (simp; (rule impI)?; (rule allI)+; rule impI) lemma diff_diff_cancel_expr: shows "exp[x - (x - y)] \<ge> exp[y]" apply open_eval subgoal premises eval for m p v proof - obtain vx where vx: "[m, p] \<turnstile> x \<mapsto> vx" using eval by blast obtain vy where vy: "[m, p] \<turnstile> y \<mapsto> vy" using eval by blast then have e: "[m, p] \<turnstile> exp[x - (x - y)] \<mapsto> val[vx - (vx - vy)]" using vx vy eval by (smt (verit, ccfv_SIG) bin_eval.simps(3) evalDet unfold_binary) then have notUn: "val[vx - (vx - vy)] \<noteq> UndefVal" using evaltree_not_undef by auto then have "val[vx - (vx - vy)] = vy" apply (cases vx; cases vy; auto simp: notUn) using eval_unused_bits_zero vy apply blast by (metis(full_types) intval_sub.simps(5)) then show ?thesis by (metis e eval evalDet vy) qed done thm_oracles diff_diff_cancel_expr snipbegin \<open>algebraic-laws-expressions\<close> text_raw \<open>\begin{align} @{thm[mode=ExprRule] (concl) diff_self_expr} \label{prop-MinusSame} \\ @{thm[mode=ExprRule] (concl) diff_diff_cancel_expr} \end{align}\<close> snipend - no_translations "n" <= "CONST ConstantExpr (CONST IntVal b n)" "x - y" <= "CONST BinaryExpr (CONST BinSub) x y" definition wf_stamp :: "IRExpr \<Rightarrow> bool" where "wf_stamp e = (\<forall>m p v. ([m, p] \<turnstile> e \<mapsto> v) \<longrightarrow> valid_value v (stamp_expr e))" lemma wf_stamp_eval: assumes "wf_stamp e" assumes "stamp_expr e = IntegerStamp b lo hi" shows "\<forall>m p v. ([m, p] \<turnstile> e \<mapsto> v) \<longrightarrow> (\<exists>vv. v = IntVal b vv)" using assms unfolding wf_stamp_def using valid_int_same_bits valid_int by metis phase SnipPhase terminating size begin lemma sub_same_val: assumes "val[x - x] = IntVal b v" shows "val[x - x] = val[IntVal b 0]" using assms by (cases x; auto) snipbegin \<open>sub-same-32\<close> optimization SubIdentity: "x - x \<longmapsto> ConstantExpr (IntVal b 0) when ((stamp_expr exp[x - x] = IntegerStamp b lo hi) \<and> wf_stamp exp[x - x])" snipend - using IRExpr.disc(42) size.simps(4) size_non_const apply simp apply (rule impI) apply simp proof - assume assms: "stamp_binary BinSub (stamp_expr x) (stamp_expr x) = IntegerStamp b lo hi \<and> wf_stamp exp[x - x]" have "\<forall>m p v . ([m, p] \<turnstile> exp[x - x] \<mapsto> v) \<longrightarrow> (\<exists>vv. v = IntVal b vv)" using assms wf_stamp_eval by (metis stamp_expr.simps(2)) then show "\<forall>m p v. ([m,p] \<turnstile> BinaryExpr BinSub x x \<mapsto> v) \<longrightarrow> ([m,p] \<turnstile> ConstantExpr (IntVal b 0) \<mapsto> v)" using wf_value_def by (smt (verit, best) BinaryExprE TreeSnippets.wf_stamp_def assms bin_eval.simps(3) constantAsStamp.simps(1) evalDet stamp_expr.simps(2) sub_same_val unfold_const valid_stamp.simps(1) valid_value.simps(1)) qed thm_oracles SubIdentity snipbegin \<open>RedundantSubtract\<close> optimization RedundantSubtract: "x - (x - y) \<longmapsto> y" snipend - using size_simps apply simp using diff_diff_cancel_expr by presburger end subsection \<open>Representing terms\<close> text \<open> We wish to show a simple example of expressions represented as terms. \<close> snipbegin \<open>ast-example\<close> text "@{value[display,margin=40] \<open>BinaryExpr BinAdd (BinaryExpr BinMul x x) (BinaryExpr BinMul x x)\<close>}" snipend - text \<open> Then we need to show the datatypes that compose the example expression. \<close> snipbegin \<open>abstract-syntax-tree\<close> text \<open>@{datatype[display,margin=40] IRExpr}\<close> snipend - snipbegin \<open>value\<close> text \<open>@{datatype[display,margin=40,show_abbrevs] Value}\<close> snipend - subsection \<open>Term semantics\<close> text \<open> The core expression evaluation functions need to be introduced. \<close> snipbegin \<open>eval\<close> text \<open>@{term_type[mode=type_def] unary_eval}\\ @{term_type[mode=type_def] bin_eval}\<close> snipend - text \<open> We then provide the full semantics of IR expressions. \<close> no_translations ("prop") "P \<and> Q \<Longrightarrow> R" <= ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" translations ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" <= ("prop") "P \<and> Q \<Longrightarrow> R" snipbegin \<open>tree-semantics\<close> text \<open> \induct{@{thm[mode=Rule] evaltree.UnaryExpr [no_vars]}}{semantics:unary} \induct{@{thm[mode=Rule] evaltree.BinaryExpr [no_vars]}}{semantics:binary} \induct{@{thm[mode=Rule] evaltree.ConditionalExpr [no_vars]}}{semantics:conditional} \induct{@{thm[mode=Rule] evaltree.ConstantExpr [no_vars]}}{semantics:constant} \induct{@{thm[mode=Rule] evaltree.ParameterExpr [no_vars]}}{semantics:parameter} \induct{@{thm[mode=Rule] evaltree.LeafExpr [no_vars]}}{semantics:leaf} \<close> snipend - no_translations ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" <= ("prop") "P \<and> Q \<Longrightarrow> R" translations ("prop") "P \<and> Q \<Longrightarrow> R" <= ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" text \<open>And show that expression evaluation is deterministic.\<close> snipbegin \<open>tree-evaluation-deterministic\<close> text \<open>@{thm[display] evalDet [no_vars]}\<close> snipend - text \<open> We then want to start demonstrating the obligations for optimizations. For this we define refinement over terms. \<close> snipbegin \<open>expression-refinement\<close> text \<open>@{thm le_expr_def [no_vars]} \<close> snipend - text \<open> To motivate this definition we show the obligations generated by optimization definitions. \<close> phase SnipPhase terminating size begin snipbegin \<open>InverseLeftSub\<close> optimization InverseLeftSub: "(x - y) + y \<longmapsto> x" snipend - snipbegin \<open>InverseLeftSubObligation\<close> text \<open>@{subgoals[display]}\<close> snipend - using RedundantSubAdd by auto snipbegin \<open>InverseRightSub\<close> optimization InverseRightSub: "y + (x - y) \<longmapsto> x" snipend - snipbegin \<open>InverseRightSubObligation\<close> text \<open>@{subgoals[display]}\<close> snipend - using RedundantSubAdd2(2) rewrite_termination.simps(1) apply blast using RedundantSubAdd2(1) rewrite_preservation.simps(1) by blast end snipbegin \<open>expression-refinement-monotone\<close> text \<open>@{thm[display,margin=60] mono_unary} @{thm[display,margin=60] mono_binary} @{thm[display,margin=60] mono_conditional} \<close> snipend - phase SnipPhase terminating size begin snipbegin \<open>BinaryFoldConstant\<close> optimization BinaryFoldConstant: "BinaryExpr op (const v1) (const v2) \<longmapsto> ConstantExpr (bin_eval op v1 v2)" snipend - snipbegin \<open>BinaryFoldConstantObligation\<close> text \<open>@{subgoals[display]}\<close> snipend - using BinaryFoldConstant(1) by auto snipbegin \<open>AddCommuteConstantRight\<close> optimization AddCommuteConstantRight: "(const v) + y \<longmapsto> y + (const v) when \<not>(is_ConstantExpr y)" snipend - snipbegin \<open>AddCommuteConstantRightObligation\<close> text \<open>@{subgoals[display,margin=50]}\<close> snipend - using AddShiftConstantRight by auto snipbegin \<open>AddNeutral\<close> optimization AddNeutral: "x + (const (IntVal 32 0)) \<longmapsto> x" snipend - snipbegin \<open>AddNeutralObligation\<close> text \<open>@{subgoals[display]}\<close> snipend - apply auto using AddNeutral(1) rewrite_preservation.simps(1) by force snipbegin \<open>AddToSub\<close> optimization AddToSub: "-x + y \<longmapsto> y - x" snipend - snipbegin \<open>AddToSubObligation\<close> text \<open>@{subgoals[display]}\<close> snipend - using AddLeftNegateToSub by auto end definition trm where "trm = size" lemma trm_defn[size_simps]: "trm x = size x" by (simp add: trm_def) snipbegin \<open>phase\<close> phase AddCanonicalizations terminating trm begin text_raw "\\dots" end snipend - hide_const (open) "Form.wf_stamp" snipbegin \<open>phase-example\<close> phase Conditional terminating trm begin snipend - snipbegin \<open>phase-example-1\<close>optimization NegateCond: "((!c) ? t : f) \<longmapsto> (c ? f : t)"snipend - apply (simp add: size_simps) using ConditionalPhase.NegateConditionFlipBranches(1) by simp snipbegin \<open>phase-example-2\<close>optimization TrueCond: "(true ? t : f) \<longmapsto> t"snipend - by (auto simp: trm_def) snipbegin \<open>phase-example-3\<close>optimization FalseCond: "(false ? t : f) \<longmapsto> f"snipend - by (auto simp: trm_def) snipbegin \<open>phase-example-4\<close>optimization BranchEqual: "(c ? x : x) \<longmapsto> x"snipend - by (auto simp: trm_def) snipbegin \<open>phase-example-5\<close>optimization LessCond: "((u < v) ? t : f) \<longmapsto> t when (stamp_under (stamp_expr u) (stamp_expr v) \<and> wf_stamp u \<and> wf_stamp v)"snipend - apply (auto simp: trm_def) using ConditionalPhase.condition_bounds_x(1) by (metis(full_types) StampEvalThms.wf_stamp_def TreeSnippets.wf_stamp_def bin_eval.simps(12) stamp_under_defn) snipbegin \<open>phase-example-6\<close>optimization condition_bounds_y: "((x < y) ? x : y) \<longmapsto> y when (stamp_under (stamp_expr y) (stamp_expr x) \<and> wf_stamp x \<and> wf_stamp y)"snipend - apply (auto simp: trm_def) using ConditionalPhase.condition_bounds_y(1) by (metis(full_types) StampEvalThms.wf_stamp_def TreeSnippets.wf_stamp_def bin_eval.simps(12) stamp_under_defn_inverse) snipbegin \<open>phase-example-7\<close>end snipend - lemma simplified_binary: "\<not>(is_ConstantExpr b) \<Longrightarrow> size (BinaryExpr op a b) = size a + size b + 2" by (induction b; induction op; auto simp: is_ConstantExpr_def) thm bin_size thm bin_const_size thm unary_size thm size_non_add snipbegin \<open>termination\<close> text \<open> @{thm[display,margin=80] unary_size} @{thm[display,margin=80] bin_const_size} @{thm[display,margin=80] (concl) simplified_binary} @{thm[display,margin=80] cond_size} @{thm[display,margin=80] const_size} @{thm[display,margin=80] param_size} @{thm[display,margin=80] leaf_size} \<close> snipend - (* definition 5 (semantics-preserving) is there a distinction in Isabelle? *) snipbegin \<open>graph-representation\<close> text \<open>@{bold \<open>typedef\<close>} IRGraph = @{term[source] \<open>{g :: ID \<rightharpoonup> (IRNode \<times> Stamp) . finite (dom g)}\<close>}\<close> snipend - no_translations ("prop") "P \<and> Q \<Longrightarrow> R" <= ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" translations ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" <= ("prop") "P \<and> Q \<Longrightarrow> R" snipbegin \<open>graph2tree\<close> text \<open> \induct{@{thm[mode=Rule] rep.ConstantNode [no_vars]}}{rep:constant} \induct{@{thm[mode=Rule] rep.ParameterNode [no_vars]}}{rep:parameter} \induct{@{thm[mode=Rule] rep.ConditionalNode [no_vars]}}{rep:conditional} \induct{@{thm[mode=Rule] rep.AbsNode [no_vars]}}{rep:unary} \induct{@{thm[mode=Rule] rep.SignExtendNode [no_vars]}}{rep:convert} \induct{@{thm[mode=Rule] rep.AddNode [no_vars]}}{rep:binary} \induct{@{thm[mode=Rule] rep.LeafNode [no_vars]}}{rep:leaf} \induct{@{thm[mode=Rule] rep.RefNode [no_vars]}}{rep:ref} \<close> snipend - snipbegin \<open>tree2graph\<close> text \<open> \induct{@{thm[mode=Rule] unrep.UnaryNodeSame [no_vars]}}{unrep:unarysame} \induct{@{thm[mode=Rule] unrep.ConstantNodeNew [no_vars]}}{unrep:constantnew} \induct{@{thm[mode=Rule] unrep.ParameterNodeNew [no_vars]}}{unrep:parameternew} \induct{@{thm[mode=Rule] unrep.UnaryNodeNew [no_vars]}}{unrep:unarynew} \induct{@{thm[mode=Rule] unrep.BinaryNodeNew [no_vars]}}{unrep:binarynew} \induct{@{thm[mode=Rule] unrep.AllLeafNodes [no_vars]}}{unrep:leaf} \<close> snipend - no_translations ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" <= ("prop") "P \<and> Q \<Longrightarrow> R" translations ("prop") "P \<and> Q \<Longrightarrow> R" <= ("prop") "P \<Longrightarrow> Q \<Longrightarrow> R" snipbegin \<open>preeval\<close> text \<open>@{thm is_preevaluated.simps}\<close> snipend - snipbegin \<open>deterministic-representation\<close> text \<open>@{thm[display] repDet [no_vars]}\<close> snipend - thm_oracles repDet snipbegin \<open>well-formed-term-graph\<close> text "@{thm (rhs) wf_term_graph_def [no_vars]}" snipend - (* definition 9 (well-formed graph) no? *) snipbegin \<open>graph-semantics\<close> text \<open>@{thm encodeeval_def}\<close> snipend - snipbegin \<open>graph-semantics-deterministic\<close> text \<open>@{thm graphDet [no_vars]}\<close> snipend - thm_oracles graphDet notation (latex) graph_refinement ("\<^latex>\<open>term-graph-refinement\<close> _") snipbegin \<open>graph-refinement\<close> text \<open>@{thm[display, margin=60] graph_refinement_def [no_vars]}\<close> snipend - (* hide as_set, should treat IRGraph as a set of pairs in paper *) translations "n" <= "CONST as_set n" snipbegin \<open>graph-semantics-preservation\<close> text \<open>@{thm[display, margin=30] graph_semantics_preservation_subscript [no_vars]}\<close> snipend - thm_oracles graph_semantics_preservation_subscript snipbegin \<open>maximal-sharing\<close> text \<open>@{thm[display, margin=50] maximal_sharing [no_vars]}\<close> snipend - snipbegin \<open>tree-to-graph-rewriting\<close> text \<open>@{thm[display, margin=30] tree_to_graph_rewriting [no_vars]}\<close> snipend - thm_oracles tree_to_graph_rewriting snipbegin \<open>term-graph-refines-term\<close> text \<open>@{thm[display] graph_represents_expression_def [no_vars]}\<close> snipend - snipbegin \<open>term-graph-evaluation\<close> text \<open>@{thm[display] term_graph_evaluation [no_vars]}\<close> snipend - snipbegin \<open>graph-construction\<close> text \<open>@{thm[display, margin=40] graph_construction [no_vars]}\<close> snipend - thm_oracles graph_construction snipbegin \<open>term-graph-reconstruction\<close> text \<open>@{thm[display] term_graph_reconstruction [no_vars]}\<close> snipend - snipbegin \<open>refined-insert\<close> text \<open>@{thm[display, margin=40] refined_insert [no_vars]}\<close> snipend - end
(* Title: HOL/Proofs/Extraction/QuotRem.thy Author: Stefan Berghofer, TU Muenchen *) section \<open>Quotient and remainder\<close> theory QuotRem imports Util begin text \<open>Derivation of quotient and remainder using program extraction.\<close> theorem division: "\<exists>r q. a = Suc b * q + r \<and> r \<le> b" proof (induct a) case 0 have "0 = Suc b * 0 + 0 \<and> 0 \<le> b" by simp then show ?case by iprover next case (Suc a) then obtain r q where I: "a = Suc b * q + r" and "r \<le> b" by iprover from nat_eq_dec show ?case proof assume "r = b" with I have "Suc a = Suc b * (Suc q) + 0 \<and> 0 \<le> b" by simp then show ?case by iprover next assume "r \<noteq> b" with \<open>r \<le> b\<close> have "r < b" by (simp add: order_less_le) with I have "Suc a = Suc b * q + (Suc r) \<and> (Suc r) \<le> b" by simp then show ?case by iprover qed qed extract division text \<open> The program extracted from the above proof looks as follows @{thm [display] division_def [no_vars]} The corresponding correctness theorem is @{thm [display] division_correctness [no_vars]} \<close> lemma "division 9 2 = (0, 3)" by eval end
inductive MyBool := | MyTrue | MyFalse inductive T := | mk (b: MyBool) (u: Unit) inductive isTrue: T → Type := | intro: isTrue (.mk .MyTrue ()) example {τ: T} (h: isTrue τ): Unit := match τ, h with | .mk .MyTrue (), .intro => ()
informal statement Suppose $a \in R^{1}, f$ is a twice-differentiable real function on $(a, \infty)$, and $M_{0}, M_{1}, M_{2}$ are the least upper bounds of $|f(x)|,\left|f^{\prime}(x)\right|,\left|f^{\prime \prime}(x)\right|$, respectively, on $(a, \infty)$. Prove that $M_{1}^{2} \leq 4 M_{0} M_{2} .$formal statement theorem exercise_13_1 (X : Type*) [topological_space X] (A : set X) (h1 : ∀ x ∈ A, ∃ U : set X, x ∈ U ∧ is_open U ∧ U ⊆ A) : is_open A :=
[STATEMENT] lemma length_not_greater_eq_2_iff [simp]: \<open>\<not> 2 \<le> LENGTH('a::len) \<longleftrightarrow> LENGTH('a) = 1\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<not> 2 \<le> LENGTH('a)) = (LENGTH('a) = 1) [PROOF STEP] by (auto simp add: not_le dest: less_2_cases)
id : Set → Set id A = A F : Set → Set → Set F _*_ = G where G : Set → Set G _*_ = id _*_ G : Set → Set → Set G _*_ = λ _*_ → id _*_ H : Set → Set → Set H = λ _*_ _*_ → id _*_
[GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V ⊢ IsNoetherian K V ↔ Module.rank K V < ℵ₀ [PROOFSTEP] let b := Basis.ofVectorSpace K V [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V ⊢ IsNoetherian K V ↔ Module.rank K V < ℵ₀ [PROOFSTEP] rw [← b.mk_eq_rank'', lt_aleph0_iff_set_finite] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V ⊢ IsNoetherian K V ↔ Set.Finite (Basis.ofVectorSpaceIndex K V) [PROOFSTEP] constructor [GOAL] case mp K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V ⊢ IsNoetherian K V → Set.Finite (Basis.ofVectorSpaceIndex K V) [PROOFSTEP] intro [GOAL] case mp K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V a✝ : IsNoetherian K V ⊢ Set.Finite (Basis.ofVectorSpaceIndex K V) [PROOFSTEP] exact finite_of_linearIndependent (Basis.ofVectorSpaceIndex.linearIndependent K V) [GOAL] case mpr K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V ⊢ Set.Finite (Basis.ofVectorSpaceIndex K V) → IsNoetherian K V [PROOFSTEP] intro hbfinite [GOAL] case mpr K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V hbfinite : Set.Finite (Basis.ofVectorSpaceIndex K V) ⊢ IsNoetherian K V [PROOFSTEP] refine' @isNoetherian_of_linearEquiv K (⊤ : Submodule K V) V _ _ _ _ _ (LinearEquiv.ofTop _ rfl) (id _) [GOAL] case mpr K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V hbfinite : Set.Finite (Basis.ofVectorSpaceIndex K V) ⊢ IsNoetherian K { x // x ∈ ⊤ } [PROOFSTEP] refine' isNoetherian_of_fg_of_noetherian _ ⟨Set.Finite.toFinset hbfinite, _⟩ [GOAL] case mpr K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V b : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V hbfinite : Set.Finite (Basis.ofVectorSpaceIndex K V) ⊢ span K ↑(Set.Finite.toFinset hbfinite) = ⊤ [PROOFSTEP] rw [Set.Finite.coe_toFinset, ← b.span_eq, Basis.coe_ofVectorSpace, Subtype.range_coe] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : IsNoetherian K V ⊢ ↑(Basis.ofVectorSpaceIndex K V) ≃ { x // x ∈ finsetBasisIndex K V } [PROOFSTEP] rw [coeSort_finsetBasisIndex] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : IsNoetherian K V ⊢ Set.range ↑(finsetBasis K V) = Basis.ofVectorSpaceIndex K V [PROOFSTEP] rw [finsetBasis, Basis.range_reindex, Basis.range_ofVectorSpace] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V ⊢ IsNoetherian K V ↔ Module.Finite K V [PROOFSTEP] constructor [GOAL] case mp K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V ⊢ IsNoetherian K V → Module.Finite K V [PROOFSTEP] intro h [GOAL] case mp K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : IsNoetherian K V ⊢ Module.Finite K V [PROOFSTEP] exact ⟨⟨finsetBasisIndex K V, by convert (finsetBasis K V).span_eq simp⟩⟩ [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : IsNoetherian K V ⊢ span K ↑(finsetBasisIndex K V) = ⊤ [PROOFSTEP] convert (finsetBasis K V).span_eq [GOAL] case h.e'_2.h.e'_6 K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : IsNoetherian K V ⊢ ↑(finsetBasisIndex K V) = Set.range ↑(finsetBasis K V) [PROOFSTEP] simp [GOAL] case mpr K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V ⊢ Module.Finite K V → IsNoetherian K V [PROOFSTEP] rintro ⟨s, hs⟩ [GOAL] case mpr.mk.intro K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V s : Finset V hs : span K ↑s = ⊤ ⊢ IsNoetherian K V [PROOFSTEP] rw [IsNoetherian.iff_rank_lt_aleph0, ← rank_top, ← hs] [GOAL] case mpr.mk.intro K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V s : Finset V hs : span K ↑s = ⊤ ⊢ Module.rank K { x // x ∈ span K ↑s } < ℵ₀ [PROOFSTEP] exact lt_of_le_of_lt (rank_span_le _) s.finite_toSet.lt_aleph0
Require Import Basics. Require Import Types. Require Import DPath. Declare Scope square_scope. Delimit Scope square_scope with square. Local Unset Elimination Schemes. (* Homogeneous squares *) (* x00 ----pi0---- x01 | | | | p0i ==> p1i | | | | x01-----pi1-----x11 *) (* Contents: * Definition of PathSquare * Degnerate PathSquares as paths between paths * Flipping squares horizontally and vertically * PathSquare transpose * PathSquare inverse * PathSquare rotations * Edge rewriting * Concatenation * Kan fillers * natural squares from ap *) (* Definition of PathSquare *) (* PathSquare left right up down *) Cumulative Inductive PathSquare {A} : forall a00 {a10 a01 a11 : A}, a00 = a10 -> a01 = a11 -> a00 = a01 -> a10 = a11 -> Type := sq_id : forall {x : A}, PathSquare x 1 1 1 1. Arguments sq_id {A x}. Arguments PathSquare {A _ _ _ _}. Notation "1" := sq_id : square_scope. (* It seems coq has difficulty actually using these, but destruct seems to work fine. TODO: Work out if these are correct. *) Scheme PathSquare_ind := Induction for PathSquare Sort Type. Arguments PathSquare_ind {A} P f {_ _ _ _ _ _ _ _} _. Scheme PathSquare_rec := Minimality for PathSquare Sort Type. Arguments PathSquare_rec {A} P f {_ _ _ _ _ _ _ _} _. (* PathSquare_ind is an equivalence, similar to how paths_ind is *) Global Instance isequiv_PathSquare_ind `{Funext} {A} (P : forall (a00 a10 a01 a11 : A) (p : a00 = a10) (p0 : a01 = a11) (p1 : a00 = a01) (p2 : a10 = a11), PathSquare p p0 p1 p2 -> Type) : IsEquiv (PathSquare_ind P). Proof. serapply isequiv_adjointify. 1: intros X ?; apply X. 2: intro; reflexivity. intro. do 8 (apply path_forall; intro). apply path_forall. by intros []. Defined. (* PathSquares can be given by 2-dimensional paths *) Definition sq_path {A} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : px0 @ p1x = p0x @ px1 -> PathSquare px0 px1 p0x p1x. Proof. destruct p0x, p1x. intro e. generalize (e @ concat_1p _). intro e'. destruct e', px0. exact sq_id. Defined. Global Instance isequiv_sq_path {A} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : IsEquiv (@sq_path _ _ _ _ _ px0 px1 p0x p1x). Proof. serapply isequiv_adjointify; try by intros []. destruct p0x, p1x. intros e. pattern e. pose (e' := @ e @ concat_1p _). pose (e'' := e' @ (concat_1p _)^). refine (@transport _ _ e'' e _ _). - subst e' e''; hott_simpl. - clearbody e'; clear e. destruct e', px0. reflexivity. Defined. Definition equiv_sq_path {A} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : px0 @ p1x = p0x @ px1 <~> PathSquare px0 px1 p0x p1x := Build_Equiv _ _ sq_path _. (** Squares in (n+2)-truncated types are n-truncated *) Global Instance istrunc_sq n {A} `{!IsTrunc n.+2 A} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : IsTrunc n (PathSquare px0 px1 p0x p1x). Proof. serapply (trunc_equiv _ sq_path). Defined. (* We can give degenerate squares *) Section PathSquaresFromPaths. (* NOTE: These are much easier to prove but stringing them along with equivalences is how we get them to be equivalences *) Context {A : Type} {a00 a10 a01 : A} {p p' : a00 = a10} {q q' : a00 = a01}. Definition sq_G1 : p = p' -> PathSquare p p' 1 1. Proof. intro. by apply sq_path, (equiv_concat_lr (concat_p1 _)^ (concat_1p _))^-1. Defined. Global Instance isequiv_sq_G1 : IsEquiv sq_G1 := _. Definition equiv_sq_G1 : p = p' <~> PathSquare p p' 1 1 := Build_Equiv _ _ sq_G1 _. Definition sq_1G : q = q' -> PathSquare 1 1 q q'. Proof. intro. by apply sq_path, (equiv_concat_lr (concat_1p _)^ (concat_p1 _))^-1. Defined. Global Instance isequiv_sq_1G : IsEquiv sq_G1 := _. Definition equiv_sq_1G : q = q' <~> PathSquare 1 1 q q' := Build_Equiv _ _ sq_1G _. End PathSquaresFromPaths. (* PathSquare horizontal reflexivity *) Definition sq_refl_h {A} {a0 a1 : A} (p : a0 = a1) : PathSquare p p 1 1 := sq_G1 1. (* PathSquare vertical reflexivity *) Definition sq_refl_v {A} {a0 a1 : A} (p : a0 = a1) : PathSquare 1 1 p p := sq_1G 1. (* Horizontal flip *) Definition sq_flip_h {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : PathSquare px0 px1 p0x p1x -> PathSquare px1 px0 p0x^ p1x^. Proof. destruct p0x, p1x. intro. by apply sq_G1, inverse, sq_G1^-1. Defined. Global Instance isequiv_sq_flip_h {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : IsEquiv (sq_flip_h (px0:=px0) (px1:=px1) (p0x:=p0x) (p1x:=p1x)). Proof. destruct p0x, p1x; exact _. Defined. (* Vertical flip *) Definition sq_flip_v {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : PathSquare px0 px1 p0x p1x -> PathSquare px0^ px1^ p1x p0x. Proof. destruct px0, px1. intro. by apply sq_1G, inverse, sq_1G^-1. Defined. Global Instance isequiv_sq_flip_v {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : IsEquiv (sq_flip_v (px0:=px0) (px1:=px1) (p0x:=p0x) (p1x:=p1x)). Proof. destruct px0, px1; exact _. Defined. (* Transpose of a square *) Definition sq_tr {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : PathSquare px0 px1 p0x p1x -> PathSquare p0x p1x px0 px1. Proof. by intros []. Defined. (** [sq_tr] is "involutive" *) Definition sq_tr_sq_tr {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} (s : PathSquare px0 px1 p0x p1x) : sq_tr (sq_tr s) = s. Proof. destruct s. reflexivity. Defined. (* NOTE: sq_tr ought to be some sort of involution but it obviously isn't since it is not of the form A -> A. Perhaps there is a more general "involution" but between equivalent types? But then that very equivalence is given by sq_tr so it seems a bit circular... *) Section sq_tr_args. Local Arguments sq_tr {_ _ _ _ _} _ _ _ _. Global Instance isequiv_sq_tr {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : IsEquiv (sq_tr px0 px1 p0x p1x). Proof. serapply isequiv_adjointify. 1: apply sq_tr. 1,2: exact sq_tr_sq_tr. Defined. End sq_tr_args. Definition sq_tr_refl_h {A} {a b : A} {p : a = b} : sq_tr (sq_refl_h p) = sq_refl_v p. Proof. by destruct p. Defined. Definition sq_tr_refl_v {A} {a b : A} {p : a = b} : sq_tr (sq_refl_v p) = sq_refl_h p. Proof. by destruct p. Defined. (* Operations on squares *) Section PathSquareOps. Context {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11}. (* Inverse square *) Definition sq_V : PathSquare px0 px1 p0x p1x -> PathSquare px1^ px0^ p1x^ p0x^. Proof. intro. by apply sq_path, (equiv_concat_lr (inv_pp _ _ )^ (inv_pp _ _)), inverse2, sq_path^-1, sq_tr. Defined. Global Instance isequiv_sq_V : IsEquiv sq_V := _. (* Left rotation : left right top bottom -> top bottom right left *) Definition sq_rot_l : PathSquare px0 px1 p0x p1x -> PathSquare p0x^ p1x^ px1 px0. Proof. intro. by apply sq_path, moveR_Vp, (equiv_concat_r (concat_pp_p _ _ _)), moveL_pV, sq_path^-1. Defined. Global Instance isequiv_sq_rot_l : IsEquiv sq_rot_l := _. (* Right rotation : left right top bottom -> bottom top left right *) Definition sq_rot_r : PathSquare px0 px1 p0x p1x -> PathSquare p1x p0x px0^ px1^. Proof. intro. by apply sq_path, moveL_Vp, (equiv_concat_l (concat_p_pp _ _ _)), moveR_pV, sq_path^-1. Defined. Global Instance isequiv_sq_rot_r : IsEquiv sq_rot_r := _. End PathSquareOps. (* Lemmas for rewriting sides of squares *) Section PathSquareRewriting. Context {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11}. (* These are all special cases of the following "rewrite all sides" lemma which we prove is an equivalence giving us all special cases as equivalences too *) Definition sq_GGGG {px0' px1' p0x' p1x'} (qx0 : px0 = px0') (qx1 : px1 = px1') (q0x : p0x = p0x') (q1x : p1x = p1x') : PathSquare px0 px1 p0x p1x -> PathSquare px0' px1' p0x' p1x'. Proof. by destruct qx0, qx1, q0x, q1x. Defined. Global Instance isequiv_sq_GGGG {px0' px1' p0x' p1x'} (qx0 : px0 = px0') (qx1 : px1 = px1') (q0x : p0x = p0x') (q1x : p1x = p1x') : IsEquiv (sq_GGGG qx0 qx1 q0x q1x). Proof. destruct qx0, qx1, q0x, q1x; exact _. Defined. Context {px0' px1' p0x' p1x'} (qx0 : px0 = px0') (qx1 : px1 = px1') (q0x : p0x = p0x') (q1x : p1x = p1x'). Definition sq_Gccc := sq_GGGG qx0 1 1 1. Definition sq_cGcc := sq_GGGG 1 qx1 1 1. Definition sq_ccGc := sq_GGGG 1 1 q0x 1. Definition sq_cccG := sq_GGGG 1 1 1 q1x. Definition sq_GGcc := sq_GGGG qx0 qx1 1 1. Definition sq_GcGc := sq_GGGG qx0 1 q0x 1. Definition sq_GccG := sq_GGGG qx0 1 1 q1x. Definition sq_cGGc := sq_GGGG 1 qx1 q0x 1. Definition sq_cGcG := sq_GGGG 1 qx1 1 q1x. Definition sq_ccGG := sq_GGGG 1 1 q0x q1x. Definition sq_GGGc := sq_GGGG qx0 qx1 q0x 1. Definition sq_cGGG := sq_GGGG 1 qx1 q0x q1x. End PathSquareRewriting. Section MovePaths. Context {A : Type} {x x00 x20 x02 x22 : A} {f10 : x00 = x20} {f12 : x02 = x22} {f01 : x00 = x02} {f21 : x20 = x22}. (** Operations to move paths around a square. We define all these operations immediately as equvialences. The naming first number indicates in which argument the path that moves is on the left of the equivalence, and the second number where it is on the right. The equivalences are all set up so that on the right, there is no path inversion. For the [24] and [13] equivalences there is a path inverse on the left. The corresponding equivalences [42] and [31] are the symmetric versions of these, but the path inverse is in another place. *) Definition sq_move_23 {f12'' : x02 = x} {f12' : x = x22} : PathSquare f10 (f12'' @ f12') f01 f21 <~> PathSquare f10 f12' (f01 @ f12'') f21. Proof. clear f12. destruct f12''. serapply Build_Equiv. + refine (fun s => sq_ccGc (concat_p1 _)^ (sq_cGcc (concat_1p _) s)). + exact _. Defined. Definition sq_move_14 {f10'' : x00 = x} {f10' : x = x20} : PathSquare (f10'' @ f10') f12 f01 f21 <~> PathSquare f10'' f12 f01 (f10' @ f21). Proof. clear f10. destruct f10'. serapply Build_Equiv. + refine (fun s => sq_cccG (concat_1p _)^ (sq_Gccc (concat_p1 _) s)). + exact _. Defined. Definition sq_move_24 {f12'' : x02 = x} {f12' : x22 = x} : PathSquare f10 (f12'' @ f12'^) f01 f21 <~> PathSquare f10 f12'' f01 (f21 @ f12'). Proof. clear f12. destruct f12'. serapply Build_Equiv. + refine (fun s => sq_cccG (concat_p1 _)^ (sq_cGcc (concat_p1 _) s)). + exact _. Defined. Definition sq_move_42 {f12'' : x02 = x} {f12' : x = x22} : PathSquare f10 f12'' f01 (f21 @ f12'^) <~> PathSquare f10 (f12'' @ f12') f01 f21. Proof. clear f12. destruct f12'. symmetry. serapply Build_Equiv. + refine (fun s => sq_cccG (concat_p1 _)^ (sq_cGcc (concat_p1 _) s)). + exact _. Defined. Definition sq_move_13 {f10'' : x = x00} {f10' : x = x20} : PathSquare (f10''^ @ f10') f12 f01 f21 <~> PathSquare f10' f12 (f10'' @ f01) f21. Proof. clear f10. destruct f10''. serapply Build_Equiv. + refine (fun s => sq_ccGc (concat_1p _)^ (sq_Gccc (concat_1p _) s)). + exact _. Defined. Definition sq_move_31 {f10'' : x00 = x} {f10' : x = x20} : PathSquare f10' f12 (f10''^ @ f01) f21 <~> PathSquare (f10'' @ f10') f12 f01 f21. Proof. clear f10. destruct f10''. symmetry. refine (Build_Equiv _ _ (fun s => sq_ccGc (concat_1p _)^ (sq_Gccc (concat_1p _) s)) _). Defined. End MovePaths. Section DPathPathSquare. (* An alternative equivalent definition for PathSquares in terms of DPaths. This is the original one Mike had written. *) Context {A} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11}. (* Depdent path product definition of PathSquare *) Definition sq_dp_prod : DPath (fun xy => fst xy = snd xy) (path_prod' p0x p1x) px0 px1 -> PathSquare px0 px1 p0x p1x. Proof. intro. set (p := (dp_paths_FlFr _ _ _)^-1 X). apply (equiv_concat_l (concat_pp_p _ _ _) _)^-1, moveL_Mp, sq_path in p. exact (sq_ccGG (ap_fst_path_prod _ _) (ap_snd_path_prod _ _) p). Defined. Global Instance isequiv_sq_dpath_prod : IsEquiv sq_dp_prod := _. End DPathPathSquare. (* Concatenation of squares *) Section PathSquareConcat. Context {A : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11}. (* Horizontal concatenation of squares *) Definition sq_concat_h {a02 a12 : A} {p0y : a01 = a02} {p1y : a11 = a12} {px2 : a02 = a12} : PathSquare px0 px1 p0x p1x -> PathSquare px1 px2 p0y p1y -> PathSquare px0 px2 (p0x @ p0y) (p1x @ p1y). Proof. intros a b. destruct b. refine (sq_ccGG _ _ a). 1,2: apply inverse, concat_p1. Defined. (* Vertical concatenation of squares *) Definition sq_concat_v {a20 a21 : A} {py0 : a10 = a20} {py1 : a11 = a21} {p2x : a20 = a21} : PathSquare px0 px1 p0x p1x -> PathSquare py0 py1 p1x p2x -> PathSquare (px0 @ py0) (px1 @ py1) p0x p2x. Proof. intros a b. destruct b. refine (sq_GGcc _ _ a). 1,2: apply inverse, concat_p1. Defined. End PathSquareConcat. (* Notations for horizontal and vertical concatenation *) Infix "@h" := sq_concat_h (at level 10) : square_scope. Infix "@v" := sq_concat_v (at level 10) : square_scope. (* Horizontal groupoid laws for concatenation *) Section GroupoidLawsH. (* There are many more laws to write, but it seems we don't really need them *) Context {A : Type} {a00 a10 a01 a11 a02 a12 a20 a21 a03 a13 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} {px2 : a02 = a12} {p0y : a01 = a02} {p1y : a11 = a12} {px3 : a03 = a13} {p0z : a02 = a03} {p1z : a12 = a13} (s : PathSquare px0 px1 p0x p1x). Local Open Scope square_scope. Notation hr := (sq_refl_h _). Definition sq_concat_h_s1 : s @h hr = sq_ccGG (concat_p1 _)^ (concat_p1 _)^ s. Proof. by destruct s. Defined. Definition sq_concat_h_1s : hr @h s = sq_ccGG (concat_1p _)^ (concat_1p _)^ s. Proof. by destruct s. Defined. Context (t : PathSquare px1 px2 p0y p1y) (u : PathSquare px2 px3 p0z p1z). Definition sq_concat_h_ss_s : (s @h t) @h u = sq_ccGG (concat_p_pp _ _ _) (concat_p_pp _ _ _) (s @h (t @h u)). Proof. by destruct s, u, (sq_1G^-1 t), p0y. Defined. End GroupoidLawsH. (* PathSquare Kan fillers ~ Every open box has a lid *) Section Kan. (* These can be used to prove groupoid laws about paths *) Context {A : Type} {a00 a10 a01 a11 : A}. Definition sq_fill_l (px1 : a01 = a11) (p0x : a00 = a01) (p1x : a10 = a11) : {px0 : a00 = a10 & PathSquare px0 px1 p0x p1x}. Proof. exists (p0x @ px1 @ p1x^). by destruct px1, p0x, p1x. Defined. Definition sq_fill_r (px0 : a00 = a10) (p0x : a00 = a01) (p1x : a10 = a11) : {px1 : a01 = a11 & PathSquare px0 px1 p0x p1x}. Proof. exists (p0x^ @ px0 @ p1x). by destruct px0, p0x, p1x. Defined. Definition sq_fill_t (px0 : a00 = a10) (px1 : a01 = a11) (p1x : a10 = a11) : {p0x : a00 = a01 & PathSquare px0 px1 p0x p1x}. Proof. exists (px0 @ p1x @ px1^). by destruct px0, px1, p1x. Defined. Definition sq_fill_b (px0 : a00 = a10) (px1 : a01 = a11) (p0x : a00 = a01) : {p1x : a10 = a11 & PathSquare px0 px1 p0x p1x}. Proof. exists (px0^ @ p0x @ px1). by destruct px0, px1, p0x. Defined. End Kan. (* Apply a function to the sides of square *) Definition sq_ap {A B : Type} {a00 a10 a01 a11 : A} (f : A -> B) {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} : PathSquare px0 px1 p0x p1x -> PathSquare (ap f px0) (ap f px1) (ap f p0x) (ap f p1x). Proof. by intros []. Defined. (** This preserves reflexivity *) Definition sq_ap_refl_h {A B} (f : A -> B) {a0 a1 : A} (p : a0 = a1) : sq_ap f (sq_refl_h p) = sq_refl_h (ap f p). Proof. by destruct p. Defined. Definition sq_ap_refl_v {A B} (f : A -> B) {a0 a1 : A} (p : a0 = a1) : sq_ap f (sq_refl_v p) = sq_refl_v (ap f p). Proof. by destruct p. Defined. (* Curried version of the following equivalence *) Definition sq_prod {A B : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} {b00 b10 b01 b11 : B} {qx0 : b00 = b10} {qx1 : b01 = b11} {q0x : b00 = b01} {q1x : b10 = b11} : PathSquare px0 px1 p0x p1x -> PathSquare qx0 qx1 q0x q1x -> PathSquare (path_prod' px0 qx0) (path_prod' px1 qx1) (path_prod' p0x q0x) (path_prod' p1x q1x). Proof. by intros [] []. Defined. (* (* PathSquares respect products *) (* TODO: Finish this: we ought to have some sort of eta for sq_prod that might help *) Definition equiv_sq_prod {A B : Type} {a00 a10 a01 a11 : A} {px0 : a00 = a10} {px1 : a01 = a11} {p0x : a00 = a01} {p1x : a10 = a11} {b00 b10 b01 b11 : B} {qx0 : b00 = b10} {qx1 : b01 = b11} {q0x : b00 = b01} {q1x : b10 = b11} : (PathSquare px0 px1 p0x p1x) * (PathSquare qx0 qx1 q0x q1x) <~> PathSquare (path_prod' px0 qx0) (path_prod' px1 qx1) (path_prod' p0x q0x) (path_prod' p1x q1x). Proof. serapply equiv_adjointify. 1: apply uncurry, sq_prod. { intro c. destruct p1x, q1x, p0x, q0x. apply sq_G1^-1 in c. set (f := ap (ap fst) c); clearbody f. set (s := ap (ap snd) c); clearbody s. destruct ((ap_fst_path_prod _ _)^ @ ap (ap fst) c @ ap_fst_path_prod _ _). destruct ((ap_snd_path_prod _ _)^ @ ap (ap snd) c @ ap_snd_path_prod _ _). split. 1,2: apply sq_refl_h. } { intro c. set (s1 := sq_GGGG (ap_fst_path_prod _ _) (ap_fst_path_prod _ _) (ap_fst_path_prod _ _) (ap_fst_path_prod _ _) (sq_ap fst c)). set (s2 := sq_GGGG (ap_snd_path_prod _ _) (ap_snd_path_prod _ _) (ap_snd_path_prod _ _) (ap_snd_path_prod _ _) (sq_ap snd c)). admit. } by intros [[] []]. Admitted. *) (* The natural square from an ap *) Definition ap_nat {A B} {f f' : A -> B} (h : f == f') {x y : A} (p : x = y) : PathSquare (ap f p) (ap f' p) (h x) (h y). Proof. by destruct p; apply sq_1G. Defined. (* The transpose of the natural square *) Definition ap_nat' {A B} {f f' : A -> B} (h : f == f') {x y : A} (p : x = y) : PathSquare (h x) (h y) (ap f p) (ap f' p). Proof. by destruct p; apply sq_G1. Defined. (* ap_compose fits naturally into a square *) Definition ap_compose_sq {A B C} (f : A -> B) (g : B -> C) {x y : A} (p : x = y) : PathSquare (ap (g o f) p) (ap g (ap f p)) 1 1 := sq_G1 (ap_compose f g p). Definition ap_idmap_sq {A} {x y : A} (p : x = y) : PathSquare (ap idmap p) p 1 1 := sq_G1 (ap_idmap p). (* A DPath of a certain form can be turned into a square *) Definition sq_dp {A B : Type} {f g : A -> B} {a1 a2 : A} {p : a1 = a2} {q1 : f a1 = g a1} {q2 : f a2 = g a2} : DPath (fun x => f x = g x) p q1 q2 -> PathSquare q1 q2 (ap f p) (ap g p). Proof. destruct p. exact sq_G1. Defined. Global Instance isequiv_sq_dp {A B : Type} {f g : A -> B} {a1 a2 : A} {p : a1 = a2} {q1 : f a1 = g a1} {q2 : f a2 = g a2} : IsEquiv (sq_dp (p:=p) (q1:=q1) (q2:=q2)). Proof. destruct p; exact _. Defined. Definition equiv_sq_dp {A B : Type} (f g : A -> B) {a1 a2 : A} (p : a1 = a2) (q1 : f a1 = g a1) (q2 : f a2 = g a2) : DPath (fun x => f x = g x) p q1 q2 <~> PathSquare q1 q2 (ap f p) (ap g p) := Build_Equiv _ _ (@sq_dp A B f g a1 a2 p q1 q2) _. (* ap011 fits into a square *) Definition sq_ap011 {A B C} (f : A -> B -> C) {a a' : A} (p : a = a') {b b' : B} (q : b = b') : PathSquare (ap (fun x => f x b) p) (ap (fun x => f x b') p) (ap (f a) q) (ap (f a') q) := sq_dp (dp_apD (fun y => ap (fun x => f x y) _) _).
Require Import PocklingtonRefl. Open Local Scope positive_scope. Lemma prime5846725286581 : prime 5846725286581. Proof. apply (Pocklington_refl (Pock_certif 5846725286581 2 ((10267, 1)::(2,2)::nil) 25246) ((Proof_certif 10267 prime10267) :: (Proof_certif 2 prime2) :: nil)). vm_cast_no_check (refl_equal true). Qed. Lemma prime2345678901234567890123567: prime 2345678901234567890123567. apply (Pocklington_refl (Ell_certif 2345678901234567890123567 77361229 ((30321117329139797,1)::nil) 2345678901215618787857727 31749105730618655022 74219 5508459961) ( (Ell_certif 30321117329139797 5186 ((5846725286581,1)::nil) 11370418998427425 0 15160558664569900 22740837996854850) :: (Proof_certif 5846725286581 prime5846725286581) :: nil)). vm_cast_no_check (refl_equal true). Time Qed.
theory Scratch_Tactic imports Main begin lemma "x@[] = x" (* apply (rule append_Nil2) done *) apply (tactic \<open>FIRSTGOAL (resolve0_tac [@{thm append_Nil2}])\<close>) done ML \<open> resolve_tac; op THEN_ALL_NEW; \<close> end
section \<open>Frequency Moment $2$\<close> theory Frequency_Moment_2 imports Universal_Hash_Families.Carter_Wegman_Hash_Family Equivalence_Relation_Enumeration.Equivalence_Relation_Enumeration Landau_Ext Median_Method.Median Product_PMF_Ext Universal_Hash_Families.Field Frequency_Moments begin text \<open>This section contains a formalization of the algorithm for the second frequency moment. It is based on the algorithm described in \<^cite>\<open>\<open>\textsection 2.2\<close> in "alon1999"\<close>. The only difference is that the algorithm is adapted to work with prime field of odd order, which greatly reduces the implementation complexity.\<close> fun f2_hash where "f2_hash p h k = (if even (ring.hash (mod_ring p) k h) then int p - 1 else - int p - 1)" type_synonym f2_state = "nat \<times> nat \<times> nat \<times> (nat \<times> nat \<Rightarrow> nat list) \<times> (nat \<times> nat \<Rightarrow> int)" fun f2_init :: "rat \<Rightarrow> rat \<Rightarrow> nat \<Rightarrow> f2_state pmf" where "f2_init \<delta> \<epsilon> n = do { let s\<^sub>1 = nat \<lceil>6 / \<delta>\<^sup>2\<rceil>; let s\<^sub>2 = nat \<lceil>-(18 * ln (real_of_rat \<epsilon>))\<rceil>; let p = prime_above (max n 3); h \<leftarrow> prod_pmf ({..<s\<^sub>1} \<times> {..<s\<^sub>2}) (\<lambda>_. pmf_of_set (bounded_degree_polynomials (mod_ring p) 4)); return_pmf (s\<^sub>1, s\<^sub>2, p, h, (\<lambda>_ \<in> {..<s\<^sub>1} \<times> {..<s\<^sub>2}. (0 :: int))) }" fun f2_update :: "nat \<Rightarrow> f2_state \<Rightarrow> f2_state pmf" where "f2_update x (s\<^sub>1, s\<^sub>2, p, h, sketch) = return_pmf (s\<^sub>1, s\<^sub>2, p, h, \<lambda>i \<in> {..<s\<^sub>1} \<times> {..<s\<^sub>2}. f2_hash p (h i) x + sketch i)" fun f2_result :: "f2_state \<Rightarrow> rat pmf" where "f2_result (s\<^sub>1, s\<^sub>2, p, h, sketch) = return_pmf (median s\<^sub>2 (\<lambda>i\<^sub>2 \<in> {..<s\<^sub>2}. (\<Sum>i\<^sub>1\<in>{..<s\<^sub>1} . (rat_of_int (sketch (i\<^sub>1, i\<^sub>2)))\<^sup>2) / (((rat_of_nat p)\<^sup>2-1) * rat_of_nat s\<^sub>1)))" fun f2_space_usage :: "(nat \<times> nat \<times> rat \<times> rat) \<Rightarrow> real" where "f2_space_usage (n, m, \<epsilon>, \<delta>) = ( let s\<^sub>1 = nat \<lceil>6 / \<delta>\<^sup>2 \<rceil> in let s\<^sub>2 = nat \<lceil>-(18 * ln (real_of_rat \<epsilon>))\<rceil> in 3 + 2 * log 2 (s\<^sub>1 + 1) + 2 * log 2 (s\<^sub>2 + 1) + 2 * log 2 (9 + 2 * real n) + s\<^sub>1 * s\<^sub>2 * (5 + 4*log 2 (8 + 2 * real n) + 2 * log 2 (real m * (18 + 4 * real n) + 1 )))" definition encode_f2_state :: "f2_state \<Rightarrow> bool list option" where "encode_f2_state = N\<^sub>e \<Join>\<^sub>e (\<lambda>s\<^sub>1. N\<^sub>e \<Join>\<^sub>e (\<lambda>s\<^sub>2. N\<^sub>e \<Join>\<^sub>e (\<lambda>p. (List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e P\<^sub>e p 4) \<times>\<^sub>e (List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e I\<^sub>e))))" lemma "inj_on encode_f2_state (dom encode_f2_state)" proof - have " is_encoding encode_f2_state" unfolding encode_f2_state_def by (intro dependent_encoding exp_golomb_encoding fun_encoding list_encoding int_encoding poly_encoding) thus ?thesis by (rule encoding_imp_inj) qed context fixes \<epsilon> \<delta> :: rat fixes n :: nat fixes as :: "nat list" fixes result assumes \<epsilon>_range: "\<epsilon> \<in> {0<..<1}" assumes \<delta>_range: "\<delta> > 0" assumes as_range: "set as \<subseteq> {..<n}" defines "result \<equiv> fold (\<lambda>a state. state \<bind> f2_update a) as (f2_init \<delta> \<epsilon> n) \<bind> f2_result" begin private definition s\<^sub>1 where "s\<^sub>1 = nat \<lceil>6 / \<delta>\<^sup>2\<rceil>" lemma s1_gt_0: "s\<^sub>1 > 0" using \<delta>_range by (simp add:s\<^sub>1_def) private definition s\<^sub>2 where "s\<^sub>2 = nat \<lceil>-(18* ln (real_of_rat \<epsilon>))\<rceil>" lemma s2_gt_0: "s\<^sub>2 > 0" using \<epsilon>_range by (simp add:s\<^sub>2_def) private definition p where "p = prime_above (max n 3)" lemma p_prime: "Factorial_Ring.prime p" unfolding p_def using prime_above_prime by blast lemma p_ge_3: "p \<ge> 3" unfolding p_def by (meson max.boundedE prime_above_lower_bound) lemma p_gt_0: "p > 0" using p_ge_3 by linarith lemma p_gt_1: "p > 1" using p_ge_3 by simp lemma p_ge_n: "p \<ge> n" unfolding p_def by (meson max.boundedE prime_above_lower_bound ) interpretation carter_wegman_hash_family "mod_ring p" 4 using carter_wegman_hash_familyI[OF mod_ring_is_field mod_ring_finite] using p_prime by auto definition sketch where "sketch = fold (\<lambda>a state. state \<bind> f2_update a) as (f2_init \<delta> \<epsilon> n)" private definition \<Omega> where"\<Omega> = prod_pmf ({..<s\<^sub>1} \<times> {..<s\<^sub>2}) (\<lambda>_. pmf_of_set space)" private definition \<Omega>\<^sub>p where"\<Omega>\<^sub>p = measure_pmf \<Omega>" private definition sketch_rv where "sketch_rv \<omega> = of_int (sum_list (map (f2_hash p \<omega>) as))^2" private definition mean_rv where "mean_rv \<omega> = (\<lambda>i\<^sub>2. (\<Sum>i\<^sub>1 = 0..<s\<^sub>1. sketch_rv (\<omega> (i\<^sub>1, i\<^sub>2))) / (((of_nat p)\<^sup>2 - 1) * of_nat s\<^sub>1))" private definition result_rv where "result_rv \<omega> = median s\<^sub>2 (\<lambda>i\<^sub>2\<in>{..<s\<^sub>2}. mean_rv \<omega> i\<^sub>2)" lemma mean_rv_alg_sketch: "sketch = \<Omega> \<bind> (\<lambda>\<omega>. return_pmf (s\<^sub>1, s\<^sub>2, p, \<omega>, \<lambda>i \<in> {..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (\<omega> i)) as)))" proof - have "sketch = fold (\<lambda>a state. state \<bind> f2_update a) as (f2_init \<delta> \<epsilon> n)" by (simp add:sketch_def) also have "... = \<Omega> \<bind> (\<lambda>\<omega>. return_pmf (s\<^sub>1, s\<^sub>2, p, \<omega>, \<lambda>i \<in> {..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (\<omega> i)) as)))" proof (induction as rule:rev_induct) case Nil then show ?case by (simp add:s\<^sub>1_def s\<^sub>2_def space_def p_def[symmetric] \<Omega>_def restrict_def Let_def) next case (snoc a as) have "fold (\<lambda>a state. state \<bind> f2_update a) (as @ [a]) (f2_init \<delta> \<epsilon> n) = \<Omega> \<bind> (\<lambda>\<omega>. return_pmf (s\<^sub>1, s\<^sub>2, p, \<omega>, \<lambda>s \<in> {..<s\<^sub>1} \<times> {..<s\<^sub>2}. (\<Sum>x \<leftarrow> as. f2_hash p (\<omega> s) x)) \<bind> f2_update a)" using snoc by (simp add: bind_assoc_pmf restrict_def del:f2_hash.simps f2_init.simps) also have "... = \<Omega> \<bind> (\<lambda>\<omega>. return_pmf (s\<^sub>1, s\<^sub>2, p, \<omega>, \<lambda>i \<in> {..<s\<^sub>1} \<times> {..<s\<^sub>2}. (\<Sum>x \<leftarrow> as@[a]. f2_hash p (\<omega> i) x)))" by (subst bind_return_pmf) (simp add: add.commute del:f2_hash.simps cong:restrict_cong) finally show ?case by blast qed finally show ?thesis by auto qed lemma distr: "result = map_pmf result_rv \<Omega>" proof - have "result = sketch \<bind> f2_result" by (simp add:result_def sketch_def) also have "... = \<Omega> \<bind> (\<lambda>x. f2_result (s\<^sub>1, s\<^sub>2, p, x, \<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (x i)) as)))" by (simp add: mean_rv_alg_sketch bind_assoc_pmf bind_return_pmf) also have "... = map_pmf result_rv \<Omega>" by (simp add:map_pmf_def result_rv_def mean_rv_def sketch_rv_def lessThan_atLeast0 cong:restrict_cong) finally show ?thesis by simp qed private lemma f2_hash_pow_exp: assumes "k < p" shows "expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)" proof - have "odd p" using p_prime p_ge_3 prime_odd_nat assms by simp then obtain t where t_def: "p=2*t+1" using oddE by blast have "Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}" by (rule in_image_by_witness[where g="\<lambda>x. x div 2"], simp, linarith) moreover have " (*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}" by (rule image_subsetI, simp) ultimately have "card ({k. even k} \<inter> {..<p}) = card ((\<lambda>x. 2*x) ` {..<t+1})" unfolding t_def using order_antisym by metis also have "... = card {..<t+1}" by (rule card_image, simp add: inj_on_mult) also have "... = t+1" by simp finally have card_even: "card ({k. even k} \<inter> {..<p}) = t+1" by simp hence "card ({k. even k} \<inter> {..<p}) * 2 = (p+1)" by (simp add:t_def) hence prob_even: "prob {\<omega>. hash k \<omega> \<in> Collect even} = (real p + 1)/(2*real p)" using assms by (subst prob_range, auto simp:frac_eq_eq p_gt_0 mod_ring_def) have "p = card {..<p}" by simp also have "... = card (({k. odd k} \<inter> {..<p}) \<union> ({k. even k} \<inter> {..<p}))" by (rule arg_cong[where f="card"], auto) also have "... = card ({k. odd k} \<inter> {..<p}) + card ({k. even k} \<inter> {..<p})" by (rule card_Un_disjoint, simp, simp, blast) also have "... = card ({k. odd k} \<inter> {..<p}) + t+1" by (simp add:card_even) finally have "p = card ({k. odd k} \<inter> {..<p}) + t+1" by simp hence "card ({k. odd k} \<inter> {..<p}) * 2 = (p-1)" by (simp add:t_def) hence prob_odd: "prob {\<omega>. hash k \<omega> \<in> Collect odd} = (real p - 1)/(2*real p)" using assms by (subst prob_range, auto simp add: frac_eq_eq mod_ring_def) have "expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = expectation (\<lambda>\<omega>. indicator {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1)^m + indicator {\<omega>. odd (hash k \<omega>)} \<omega> * (-real p - 1)^m)" by (rule Bochner_Integration.integral_cong, simp, simp) also have "... = prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> Collect odd} * (-real p - 1) ^ m " by (simp, simp add:M_def) also have "... = (real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p)" by (subst prob_even, subst prob_odd, simp) also have "... = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)" by (simp add:add_divide_distrib ac_simps) finally show "expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)" by simp qed lemma shows var_sketch_rv:"variance sketch_rv \<le> 2*(real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2" (is "?A") and exp_sketch_rv:"expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2-1)" (is "?B") proof - define h where "h = (\<lambda>\<omega> x. real_of_int (f2_hash p \<omega> x))" define c where "c = (\<lambda>x. real (count_list as x))" define r where "r = (\<lambda>(m::nat). ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p))" define h_prod where "h_prod = (\<lambda>as \<omega>. prod_list (map (h \<omega>) as))" define exp_h_prod :: "nat list \<Rightarrow> real" where "exp_h_prod = (\<lambda>as. (\<Prod>i \<in> set as. r (count_list as i)))" have f_eq: "sketch_rv = (\<lambda>\<omega>. (\<Sum>x \<in> set as. c x * h \<omega> x)^2)" by (rule ext, simp add:sketch_rv_def c_def h_def sum_list_eval del:f2_hash.simps) have r_one: "r (Suc 0) = 0" by (simp add:r_def algebra_simps) have r_two: "r 2 = (real p^2-1)" using p_gt_0 unfolding r_def power2_eq_square by (simp add:nonzero_divide_eq_eq, simp add:algebra_simps) have"(real p)^2 \<ge> 2^2" by (rule power_mono, use p_gt_1 in linarith, simp) hence p_square_ge_4: "(real p)\<^sup>2 \<ge> 4" by simp have "r 4 = (real p)^4+2*(real p)\<^sup>2 - 3" using p_gt_0 unfolding r_def by (subst nonzero_divide_eq_eq, auto simp:power4_eq_xxxx power2_eq_square algebra_simps) also have "... \<le> (real p)^4+2*(real p)\<^sup>2 + 3" by simp also have "... \<le> 3 * r 2 * r 2" using p_square_ge_4 by (simp add:r_two power4_eq_xxxx power2_eq_square algebra_simps mult_left_mono) finally have r_four_est: "r 4 \<le> 3 * r 2 * r 2" by simp have exp_h_prod_elim: "exp_h_prod = (\<lambda>as. prod_list (map (r \<circ> count_list as) (remdups as)))" by (simp add:exp_h_prod_def prod.set_conv_list[symmetric]) have exp_h_prod: "\<And>x. set x \<subseteq> set as \<Longrightarrow> length x \<le> 4 \<Longrightarrow> expectation (h_prod x) = exp_h_prod x" proof - fix x assume "set x \<subseteq> set as" hence x_sub_p: "set x \<subseteq> {..<p}" using as_range p_ge_n by auto hence x_le_p: "\<And>k. k \<in> set x \<Longrightarrow> k < p" by auto assume "length x \<le> 4" hence card_x: "card (set x) \<le> 4" using card_length dual_order.trans by blast have "set x \<subseteq> carrier (mod_ring p) " using x_sub_p by (simp add:mod_ring_def) hence h_indep: "indep_vars (\<lambda>_. borel) (\<lambda>i \<omega>. h \<omega> i ^ count_list x i) (set x)" using k_wise_indep_vars_subset[OF k_wise_indep] card_x as_range h_def by (auto intro:indep_vars_compose2[where X="hash" and M'=" (\<lambda>_. discrete)"]) have "expectation (h_prod x) = expectation (\<lambda>\<omega>. \<Prod> i \<in> set x. h \<omega> i^(count_list x i))" by (simp add:h_prod_def prod_list_eval) also have "... = (\<Prod>i \<in> set x. expectation (\<lambda>\<omega>. h \<omega> i^(count_list x i)))" by (simp add: indep_vars_lebesgue_integral[OF _ h_indep]) also have "... = (\<Prod>i \<in> set x. r (count_list x i))" using f2_hash_pow_exp x_le_p by (simp add:h_def r_def M_def[symmetric] del:f2_hash.simps) also have "... = exp_h_prod x" by (simp add:exp_h_prod_def) finally show "expectation (h_prod x) = exp_h_prod x" by simp qed have "\<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y" proof - fix x y :: "nat list" assume a:"kernel_of x = kernel_of y" then obtain f where b:"bij_betw f (set x) (set y)" and c:"\<And>z. z \<in> set x \<Longrightarrow> count_list x z = count_list y (f z)" using kernel_of_eq_imp_bij by blast have "exp_h_prod x = prod ( (\<lambda>i. r(count_list y i)) \<circ> f) (set x)" by (simp add:exp_h_prod_def c) also have "... = (\<Prod>i \<in> f ` (set x). r(count_list y i))" by (metis b bij_betw_def prod.reindex) also have "... = exp_h_prod y" unfolding exp_h_prod_def by (rule prod.cong, metis b bij_betw_def) simp finally show "exp_h_prod x = exp_h_prod y" by simp qed hence exp_h_prod_cong: "\<And>p x. of_bool (kernel_of x = kernel_of p) * exp_h_prod p = of_bool (kernel_of x = kernel_of p) * exp_h_prod x" by (metis (full_types) of_bool_eq_0_iff vector_space_over_itself.scale_zero_left) have c:"(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r" if a:"length xs = n" for xs :: "nat list" and n and r :: real proof - have "(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * 1) = (1::real)" using equiv_rels_2[OF a[symmetric]] by (simp add:equiv_rels_def comp_def) thus "(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = (r::real)" by (simp add:sum_list_mult_const) qed have "expectation sketch_rv = (\<Sum>i\<in>set as. (\<Sum>j\<in>set as. c i * c j * expectation (h_prod [i,j])))" by (simp add:f_eq h_prod_def power2_eq_square sum_distrib_left sum_distrib_right Bochner_Integration.integral_sum algebra_simps) also have "... = (\<Sum>i\<in>set as. (\<Sum>j\<in>set as. c i * c j * exp_h_prod [i,j]))" by (simp add:exp_h_prod) also have "... = (\<Sum>i \<in> set as. (\<Sum>j \<in> set as. c i * c j * (sum_list (map (\<lambda>p. of_bool (kernel_of [i,j] = kernel_of p) * exp_h_prod p) (enum_rgfs 2)))))" by (subst exp_h_prod_cong, simp add:c) also have "... = (\<Sum>i\<in>set as. c i * c i * r 2)" by (simp add: numeral_eq_Suc kernel_of_eq All_less_Suc exp_h_prod_elim r_one distrib_left sum.distrib sum_collapse) also have "... = real_of_rat (F 2 as) * ((real p)^2-1)" by (simp add: sum_distrib_right[symmetric] c_def F_def power2_eq_square of_rat_sum of_rat_mult r_two) finally show b:?B by simp have "expectation (\<lambda>x. (sketch_rv x)\<^sup>2) = (\<Sum>i1 \<in> set as. (\<Sum>i2 \<in> set as. (\<Sum>i3 \<in> set as. (\<Sum>i4 \<in> set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4])))))" by (simp add:f_eq h_prod_def power4_eq_xxxx sum_distrib_left sum_distrib_right Bochner_Integration.integral_sum algebra_simps) also have "... = (\<Sum>i1 \<in> set as. (\<Sum>i2 \<in> set as. (\<Sum>i3 \<in> set as. (\<Sum>i4 \<in> set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1,i2,i3,i4]))))" by (simp add:exp_h_prod) also have "... = (\<Sum>i1 \<in> set as. (\<Sum>i2 \<in> set as. (\<Sum>i3 \<in> set as. (\<Sum>i4 \<in> set as. c i1 * c i2 * c i3 * c i4 * (sum_list (map (\<lambda>p. of_bool (kernel_of [i1,i2,i3,i4] = kernel_of p) * exp_h_prod p) (enum_rgfs 4)))))))" by (subst exp_h_prod_cong, simp add:c) also have "... = 3 * (\<Sum>i \<in> set as. (\<Sum>j \<in> set as. c i^2 * c j^2 * r 2 * r 2)) + ((\<Sum> i \<in> set as. c i^4 * r 4) - 3 * (\<Sum> i \<in> set as. c i ^ 4 * r 2 * r 2))" apply (simp add: numeral_eq_Suc exp_h_prod_elim r_one) (* large intermediate terms *) apply (simp add: kernel_of_eq All_less_Suc numeral_eq_Suc distrib_left sum.distrib sum_collapse neq_commute of_bool_not_iff) apply (simp add: algebra_simps sum_subtractf sum_collapse) apply (simp add: sum_distrib_left algebra_simps) done also have "... = 3 * (\<Sum>i \<in> set as. c i^2 * r 2)^2 + (\<Sum> i \<in> set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))" by (simp add:power2_eq_square sum_distrib_left algebra_simps sum_subtractf) also have "... = 3 * (\<Sum>i \<in> set as. c i^2)^2 * (r 2)^2 + (\<Sum>i \<in> set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))" by (simp add:power_mult_distrib sum_distrib_right[symmetric]) also have "... \<le> 3 * (\<Sum>i \<in> set as. c i^2)^2 * (r 2)^2 + (\<Sum>i \<in> set as. c i ^ 4 * 0)" using r_four_est by (auto intro!: sum_nonpos simp add:mult_nonneg_nonpos) also have "... = 3 * (real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2" by (simp add:c_def r_two F_def of_rat_sum of_rat_power) finally have "expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2" by simp thus "variance sketch_rv \<le> 2*(real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2" by (simp add: variance_eq, simp add:power_mult_distrib b) qed lemma space_omega_1 [simp]: "Sigma_Algebra.space \<Omega>\<^sub>p = UNIV" by (simp add:\<Omega>\<^sub>p_def) interpretation \<Omega>: prob_space "\<Omega>\<^sub>p" by (simp add:\<Omega>\<^sub>p_def prob_space_measure_pmf) lemma integrable_\<Omega>: fixes f :: "((nat \<times> nat) \<Rightarrow> (nat list)) \<Rightarrow> real" shows "integrable \<Omega>\<^sub>p f" unfolding \<Omega>\<^sub>p_def \<Omega>_def by (rule integrable_measure_pmf_finite, auto intro:finite_PiE simp:set_prod_pmf) lemma sketch_rv_exp: assumes "i\<^sub>2 < s\<^sub>2" assumes "i\<^sub>1 \<in> {0..<s\<^sub>1}" shows "\<Omega>.expectation (\<lambda>\<omega>. sketch_rv (\<omega> (i\<^sub>1, i\<^sub>2))) = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)" proof - have "\<Omega>.expectation (\<lambda>\<omega>. (sketch_rv (\<omega> (i\<^sub>1, i\<^sub>2))) :: real) = expectation sketch_rv" using integrable_\<Omega> integrable_M assms unfolding \<Omega>_def \<Omega>\<^sub>p_def M_def by (subst expectation_Pi_pmf_slice, auto) also have "... = (real_of_rat (F 2 as)) * ((real p)\<^sup>2 - 1)" using exp_sketch_rv by simp finally show ?thesis by simp qed lemma sketch_rv_var: assumes "i\<^sub>2 < s\<^sub>2" assumes "i\<^sub>1 \<in> {0..<s\<^sub>1}" shows "\<Omega>.variance (\<lambda>\<omega>. sketch_rv (\<omega> (i\<^sub>1, i\<^sub>2))) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2" proof - have "\<Omega>.variance (\<lambda>\<omega>. (sketch_rv (\<omega> (i\<^sub>1, i\<^sub>2)) :: real)) = variance sketch_rv" using integrable_\<Omega> integrable_M assms unfolding \<Omega>_def \<Omega>\<^sub>p_def M_def by (subst variance_prod_pmf_slice, auto) also have "... \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2" using var_sketch_rv by simp finally show ?thesis by simp qed lemma mean_rv_exp: assumes "i < s\<^sub>2" shows "\<Omega>.expectation (\<lambda>\<omega>. mean_rv \<omega> i) = real_of_rat (F 2 as)" proof - have a:"(real p)\<^sup>2 > 1" using p_gt_1 by simp have "\<Omega>.expectation (\<lambda>\<omega>. mean_rv \<omega> i) = (\<Sum>i\<^sub>1 = 0..<s\<^sub>1. \<Omega>.expectation (\<lambda>\<omega>. sketch_rv (\<omega> (i\<^sub>1, i)))) / (((real p)\<^sup>2 - 1) * real s\<^sub>1)" using assms integrable_\<Omega> by (simp add:mean_rv_def) also have "... = (\<Sum>i\<^sub>1 = 0..<s\<^sub>1. real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)) / (((real p)\<^sup>2 - 1) * real s\<^sub>1)" using sketch_rv_exp[OF assms] by simp also have "... = real_of_rat (F 2 as)" using s1_gt_0 a by simp finally show ?thesis by simp qed lemma mean_rv_var: assumes "i < s\<^sub>2" shows "\<Omega>.variance (\<lambda>\<omega>. mean_rv \<omega> i) \<le> (real_of_rat (\<delta> * F 2 as))\<^sup>2 / 3" proof - have a: "\<Omega>.indep_vars (\<lambda>_. borel) (\<lambda>i\<^sub>1 x. sketch_rv (x (i\<^sub>1, i))) {0..<s\<^sub>1}" using assms unfolding \<Omega>\<^sub>p_def \<Omega>_def by (intro indep_vars_restrict_intro'[where f="fst"]) (auto simp add: restrict_dfl_def case_prod_beta lessThan_atLeast0) have p_sq_ne_1: "(real p)^2 \<noteq> 1" by (metis p_gt_1 less_numeral_extra(4) of_nat_power one_less_power pos2 semiring_char_0_class.of_nat_eq_1_iff) have s1_bound: " 6 / (real_of_rat \<delta>)\<^sup>2 \<le> real s\<^sub>1" unfolding s\<^sub>1_def by (metis (mono_tags, opaque_lifting) of_rat_ceiling of_rat_divide of_rat_numeral_eq of_rat_power real_nat_ceiling_ge) have "\<Omega>.variance (\<lambda>\<omega>. mean_rv \<omega> i) = \<Omega>.variance (\<lambda>\<omega>. \<Sum>i\<^sub>1 = 0..<s\<^sub>1. sketch_rv (\<omega> (i\<^sub>1, i))) / (((real p)\<^sup>2 - 1) * real s\<^sub>1)\<^sup>2" unfolding mean_rv_def by (subst \<Omega>.variance_divide[OF integrable_\<Omega>], simp) also have "... = (\<Sum>i\<^sub>1 = 0..<s\<^sub>1. \<Omega>.variance (\<lambda>\<omega>. sketch_rv (\<omega> (i\<^sub>1, i)))) / (((real p)\<^sup>2 - 1) * real s\<^sub>1)\<^sup>2" by (subst \<Omega>.var_sum_all_indep[OF _ _ integrable_\<Omega> a]) (auto simp: \<Omega>_def \<Omega>\<^sub>p_def) also have "... \<le> (\<Sum>i\<^sub>1 = 0..<s\<^sub>1. 2*(real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2) / (((real p)\<^sup>2 - 1) * real s\<^sub>1)\<^sup>2" by (rule divide_right_mono, rule sum_mono[OF sketch_rv_var[OF assms]], auto) also have "... = 2 * (real_of_rat (F 2 as)^2) / real s\<^sub>1" using p_sq_ne_1 s1_gt_0 by (subst frac_eq_eq, auto simp:power2_eq_square) also have "... \<le> 2 * (real_of_rat (F 2 as)^2) / (6 / (real_of_rat \<delta>)\<^sup>2)" using s1_gt_0 \<delta>_range by (intro divide_left_mono mult_pos_pos s1_bound) auto also have "... = (real_of_rat (\<delta> * F 2 as))\<^sup>2 / 3" by (simp add:of_rat_mult algebra_simps) finally show ?thesis by simp qed lemma mean_rv_bounds: assumes "i < s\<^sub>2" shows "\<Omega>.prob {\<omega>. real_of_rat \<delta> * real_of_rat (F 2 as) < \<bar>mean_rv \<omega> i - real_of_rat (F 2 as)\<bar>} \<le> 1/3" proof (cases "as = []") case True then show ?thesis using assms by (subst mean_rv_def, subst sketch_rv_def, simp add:F_def) next case False hence "F 2 as > 0" using F_gr_0 by auto hence a: "0 < real_of_rat (\<delta> * F 2 as)" using \<delta>_range by simp have [simp]: "(\<lambda>\<omega>. mean_rv \<omega> i) \<in> borel_measurable \<Omega>\<^sub>p" by (simp add:\<Omega>_def \<Omega>\<^sub>p_def) have "\<Omega>.prob {\<omega>. real_of_rat \<delta> * real_of_rat (F 2 as) < \<bar>mean_rv \<omega> i - real_of_rat (F 2 as)\<bar>} \<le> \<Omega>.prob {\<omega>. real_of_rat (\<delta> * F 2 as) \<le> \<bar>mean_rv \<omega> i - real_of_rat (F 2 as)\<bar>}" by (rule \<Omega>.pmf_mono[OF \<Omega>\<^sub>p_def], simp add:of_rat_mult) also have "... \<le> \<Omega>.variance (\<lambda>\<omega>. mean_rv \<omega> i) / (real_of_rat (\<delta> * F 2 as))\<^sup>2" using \<Omega>.Chebyshev_inequality[where a="real_of_rat (\<delta> * F 2 as)" and f="\<lambda>\<omega>. mean_rv \<omega> i",simplified] a prob_space_measure_pmf[where p="\<Omega>"] mean_rv_exp[OF assms] integrable_\<Omega> by simp also have "... \<le> ((real_of_rat (\<delta> * F 2 as))\<^sup>2/3) / (real_of_rat (\<delta> * F 2 as))\<^sup>2" by (rule divide_right_mono, rule mean_rv_var[OF assms], simp) also have "... = 1/3" using a by force finally show ?thesis by blast qed lemma f2_alg_correct': "\<P>(\<omega> in measure_pmf result. \<bar>\<omega> - F 2 as\<bar> \<le> \<delta> * F 2 as) \<ge> 1-of_rat \<epsilon>" proof - have a: "\<Omega>.indep_vars (\<lambda>_. borel) (\<lambda>i \<omega>. mean_rv \<omega> i) {0..<s\<^sub>2}" using s1_gt_0 unfolding \<Omega>\<^sub>p_def \<Omega>_def by (intro indep_vars_restrict_intro'[where f="snd"]) (auto simp: \<Omega>\<^sub>p_def \<Omega>_def mean_rv_def restrict_dfl_def) have b: "- 18 * ln (real_of_rat \<epsilon>) \<le> real s\<^sub>2" unfolding s\<^sub>2_def using of_nat_ceiling by auto have "1 - of_rat \<epsilon> \<le> \<Omega>.prob {\<omega>. \<bar>median s\<^sub>2 (mean_rv \<omega>) - real_of_rat (F 2 as) \<bar> \<le> of_rat \<delta> * of_rat (F 2 as)}" using \<epsilon>_range \<Omega>.median_bound_2[OF _ a b, where \<delta>="real_of_rat \<delta> * real_of_rat (F 2 as)" and \<mu>="real_of_rat (F 2 as)"] mean_rv_bounds by simp also have "... = \<Omega>.prob {\<omega>. \<bar>real_of_rat (result_rv \<omega>) - of_rat (F 2 as) \<bar> \<le> of_rat \<delta> * of_rat (F 2 as)}" by (simp add:result_rv_def median_restrict lessThan_atLeast0 median_rat[OF s2_gt_0] mean_rv_def sketch_rv_def of_rat_divide of_rat_sum of_rat_mult of_rat_diff of_rat_power) also have "... = \<Omega>.prob {\<omega>. \<bar>result_rv \<omega> - F 2 as\<bar> \<le> \<delta> * F 2 as} " by (simp add:of_rat_less_eq of_rat_mult[symmetric] of_rat_diff[symmetric] set_eq_iff) finally have "\<Omega>.prob {y. \<bar>result_rv y - F 2 as\<bar> \<le> \<delta> * F 2 as} \<ge> 1-of_rat \<epsilon> " by simp thus ?thesis by (simp add: distr \<Omega>\<^sub>p_def) qed lemma f2_exact_space_usage': "AE \<omega> in sketch . bit_count (encode_f2_state \<omega>) \<le> f2_space_usage (n, length as, \<epsilon>, \<delta>)" proof - have "p \<le> 2 * max n 3 + 2" by (subst p_def, rule prime_above_upper_bound) also have "... \<le> 2 * n + 8" by (cases "n \<le> 2", simp_all) finally have p_bound: "p \<le> 2 * n + 8" by simp have "bit_count (N\<^sub>e p) \<le> ereal (2 * log 2 (real p + 1) + 1)" by (rule exp_golomb_bit_count) also have "... \<le> ereal (2 * log 2 (2 * real n + 9) + 1)" using p_bound by simp finally have p_bit_count: "bit_count (N\<^sub>e p) \<le> ereal (2 * log 2 (2 * real n + 9) + 1)" by simp have a: "bit_count (encode_f2_state (s\<^sub>1, s\<^sub>2, p, y, \<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (y i)) as))) \<le> ereal (f2_space_usage (n, length as, \<epsilon>, \<delta>))" if a:"y\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2} \<rightarrow>\<^sub>E bounded_degree_polynomials (mod_ring p) 4" for y proof - have "y \<in> extensional ({..<s\<^sub>1} \<times> {..<s\<^sub>2})" using a PiE_iff by blast hence y_ext: "y \<in> extensional (set (List.product [0..<s\<^sub>1] [0..<s\<^sub>2]))" by (simp add:lessThan_atLeast0) have h_bit_count_aux: "bit_count (P\<^sub>e p 4 (y x)) \<le> ereal (4 + 4 * log 2 (8 + 2 * real n))" if b:"x \<in> set (List.product [0..<s\<^sub>1] [0..<s\<^sub>2])" for x proof - have "y x \<in> bounded_degree_polynomials (Field.mod_ring p) 4" using b a by force hence "bit_count (P\<^sub>e p 4 (y x)) \<le> ereal ( real 4 * (log 2 (real p) + 1))" by (rule bounded_degree_polynomial_bit_count[OF p_gt_1] ) also have "... \<le> ereal (real 4 * (log 2 (8 + 2 * real n) + 1) )" using p_gt_0 p_bound by simp also have "... \<le> ereal (4 + 4 * log 2 (8 + 2 * real n))" by simp finally show ?thesis by blast qed have h_bit_count: "bit_count ((List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e P\<^sub>e p 4) y) \<le> ereal (real s\<^sub>1 * real s\<^sub>2 * (4 + 4 * log 2 (8 + 2 * real n)))" using fun_bit_count_est[where e="P\<^sub>e p 4", OF y_ext h_bit_count_aux] by simp have sketch_bit_count_aux: "bit_count (I\<^sub>e (sum_list (map (f2_hash p (y x)) as))) \<le> ereal (1 + 2 * log 2 (real (length as) * (18 + 4 * real n) + 1))" (is "?lhs \<le> ?rhs") if " x \<in> {0..<s\<^sub>1} \<times> {0..<s\<^sub>2}" for x proof - have "\<bar>sum_list (map (f2_hash p (y x)) as)\<bar> \<le> sum_list (map (abs \<circ> (f2_hash p (y x))) as)" by (subst map_map[symmetric]) (rule sum_list_abs) also have "... \<le> sum_list (map (\<lambda>_. (int p+1)) as)" by (rule sum_list_mono) (simp add:p_gt_0) also have "... = int (length as) * (int p+1)" by (simp add: sum_list_triv) also have "... \<le> int (length as) * (9+2*(int n))" using p_bound by (intro mult_mono, auto) finally have "\<bar>sum_list (map (f2_hash p (y x)) as)\<bar> \<le> int (length as) * (9 + 2 * int n)" by simp hence "?lhs \<le> ereal (2 * log 2 (real_of_int (2* (int (length as) * (9 + 2 * int n)) + 1)) + 1)" by (rule int_bit_count_est) also have "... = ?rhs" by (simp add:algebra_simps) finally show "?thesis" by simp qed have "bit_count ((List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e I\<^sub>e) (\<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (y i)) as))) \<le> ereal (real (length (List.product [0..<s\<^sub>1] [0..<s\<^sub>2]))) * (ereal (1 + 2 * log 2 (real (length as) * (18 + 4 * real n) + 1)))" by (intro fun_bit_count_est) (simp_all add:extensional_def lessThan_atLeast0 sketch_bit_count_aux del:f2_hash.simps) also have "... = ereal (real s\<^sub>1 * real s\<^sub>2 * (1 + 2 * log 2 (real (length as) * (18 + 4 * real n) + 1)))" by simp finally have sketch_bit_count: "bit_count ((List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e I\<^sub>e) (\<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (y i)) as))) \<le> ereal (real s\<^sub>1 * real s\<^sub>2 * (1 + 2 * log 2 (real (length as) * (18 + 4 * real n) + 1)))" by simp have "bit_count (encode_f2_state (s\<^sub>1, s\<^sub>2, p, y, \<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (y i)) as))) \<le> bit_count (N\<^sub>e s\<^sub>1) + bit_count (N\<^sub>e s\<^sub>2) +bit_count (N\<^sub>e p) + bit_count ((List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e P\<^sub>e p 4) y) + bit_count ((List.product [0..<s\<^sub>1] [0..<s\<^sub>2] \<rightarrow>\<^sub>e I\<^sub>e) (\<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (y i)) as)))" by (simp add:Let_def s\<^sub>1_def s\<^sub>2_def encode_f2_state_def dependent_bit_count add.assoc) also have "... \<le> ereal (2 * log 2 (real s\<^sub>1 + 1) + 1) + ereal (2 * log 2 (real s\<^sub>2 + 1) + 1) + ereal (2 * log 2 (2 * real n + 9) + 1) + (ereal (real s\<^sub>1 * real s\<^sub>2) * (4 + 4 * log 2 (8 + 2 * real n))) + (ereal (real s\<^sub>1 * real s\<^sub>2) * (1 + 2 * log 2 (real (length as) * (18 + 4 * real n) + 1) ))" by (intro add_mono exp_golomb_bit_count p_bit_count, auto intro: h_bit_count sketch_bit_count) also have "... = ereal (f2_space_usage (n, length as, \<epsilon>, \<delta>))" by (simp add:distrib_left add.commute s\<^sub>1_def[symmetric] s\<^sub>2_def[symmetric] Let_def) finally show "bit_count (encode_f2_state (s\<^sub>1, s\<^sub>2, p, y, \<lambda>i\<in>{..<s\<^sub>1} \<times> {..<s\<^sub>2}. sum_list (map (f2_hash p (y i)) as))) \<le> ereal (f2_space_usage (n, length as, \<epsilon>, \<delta>))" by simp qed have "set_pmf \<Omega> = {..<s\<^sub>1} \<times> {..<s\<^sub>2} \<rightarrow>\<^sub>E bounded_degree_polynomials (Field.mod_ring p) 4" by (simp add: \<Omega>_def set_prod_pmf) (simp add: space_def) thus ?thesis by (simp add:mean_rv_alg_sketch AE_measure_pmf_iff del:f2_space_usage.simps, metis a) qed end text \<open>Main results of this section:\<close> theorem f2_alg_correct: assumes "\<epsilon> \<in> {0<..<1}" assumes "\<delta> > 0" assumes "set as \<subseteq> {..<n}" defines "\<Omega> \<equiv> fold (\<lambda>a state. state \<bind> f2_update a) as (f2_init \<delta> \<epsilon> n) \<bind> f2_result" shows "\<P>(\<omega> in measure_pmf \<Omega>. \<bar>\<omega> - F 2 as\<bar> \<le> \<delta> * F 2 as) \<ge> 1-of_rat \<epsilon>" using f2_alg_correct'[OF assms(1,2,3)] \<Omega>_def by auto theorem f2_exact_space_usage: assumes "\<epsilon> \<in> {0<..<1}" assumes "\<delta> > 0" assumes "set as \<subseteq> {..<n}" defines "M \<equiv> fold (\<lambda>a state. state \<bind> f2_update a) as (f2_init \<delta> \<epsilon> n)" shows "AE \<omega> in M. bit_count (encode_f2_state \<omega>) \<le> f2_space_usage (n, length as, \<epsilon>, \<delta>)" using f2_exact_space_usage'[OF assms(1,2,3)] by (subst (asm) sketch_def[OF assms(1,2,3)], subst M_def, simp) theorem f2_asymptotic_space_complexity: "f2_space_usage \<in> O[at_top \<times>\<^sub>F at_top \<times>\<^sub>F at_right 0 \<times>\<^sub>F at_right 0](\<lambda> (n, m, \<epsilon>, \<delta>). (ln (1 / of_rat \<epsilon>)) / (of_rat \<delta>)\<^sup>2 * (ln (real n) + ln (real m)))" (is "_ \<in> O[?F](?rhs)") proof - define n_of :: "nat \<times> nat \<times> rat \<times> rat \<Rightarrow> nat" where "n_of = (\<lambda>(n, m, \<epsilon>, \<delta>). n)" define m_of :: "nat \<times> nat \<times> rat \<times> rat \<Rightarrow> nat" where "m_of = (\<lambda>(n, m, \<epsilon>, \<delta>). m)" define \<epsilon>_of :: "nat \<times> nat \<times> rat \<times> rat \<Rightarrow> rat" where "\<epsilon>_of = (\<lambda>(n, m, \<epsilon>, \<delta>). \<epsilon>)" define \<delta>_of :: "nat \<times> nat \<times> rat \<times> rat \<Rightarrow> rat" where "\<delta>_of = (\<lambda>(n, m, \<epsilon>, \<delta>). \<delta>)" define g where "g = (\<lambda>x. (1/ (of_rat (\<delta>_of x))\<^sup>2) * (ln (1 / of_rat (\<epsilon>_of x))) * (ln (real (n_of x)) + ln (real (m_of x))))" have evt: "(\<And>x. 0 < real_of_rat (\<delta>_of x) \<and> 0 < real_of_rat (\<epsilon>_of x) \<and> 1/real_of_rat (\<delta>_of x) \<ge> \<delta> \<and> 1/real_of_rat (\<epsilon>_of x) \<ge> \<epsilon> \<and> real (n_of x) \<ge> n \<and> real (m_of x) \<ge> m\<Longrightarrow> P x) \<Longrightarrow> eventually P ?F" (is "(\<And>x. ?prem x \<Longrightarrow> _) \<Longrightarrow> _") for \<delta> \<epsilon> n m P apply (rule eventually_mono[where P="?prem" and Q="P"]) apply (simp add:\<epsilon>_of_def case_prod_beta' \<delta>_of_def n_of_def m_of_def) apply (intro eventually_conj eventually_prod1' eventually_prod2' sequentially_inf eventually_at_right_less inv_at_right_0_inf) by (auto simp add:prod_filter_eq_bot) have unit_1: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. 1 / (real_of_rat (\<delta>_of x))\<^sup>2)" using one_le_power by (intro landau_o.big_mono evt[where \<delta>="1"], auto simp add:power_one_over[symmetric]) have unit_2: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. ln (1 / real_of_rat (\<epsilon>_of x)))" by (intro landau_o.big_mono evt[where \<epsilon>="exp 1"]) (auto intro!:iffD2[OF ln_ge_iff] simp add:abs_ge_iff) have unit_3: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. real (n_of x))" by (intro landau_o.big_mono evt, auto) have unit_4: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. real (m_of x))" by (intro landau_o.big_mono evt, auto) have unit_5: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. ln (real (n_of x)))" by (auto intro!: landau_o.big_mono evt[where n="exp 1"]) (metis abs_ge_self linorder_not_le ln_ge_iff not_exp_le_zero order.trans) have unit_6: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. ln (real (n_of x)) + ln (real (m_of x)))" by (intro landau_sum_1 evt unit_5 iffD2[OF ln_ge_iff], auto) have unit_7: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. 1 / real_of_rat (\<epsilon>_of x))" by (intro landau_o.big_mono evt[where \<epsilon>="1"], auto) have unit_8: "(\<lambda>_. 1) \<in> O[?F](g)" unfolding g_def by (intro landau_o.big_mult_1 unit_1 unit_2 unit_6) have unit_9: "(\<lambda>_. 1) \<in> O[?F](\<lambda>x. real (n_of x) * real (m_of x))" by (intro landau_o.big_mult_1 unit_3 unit_4) have " (\<lambda>x. 6 * (1 / (real_of_rat (\<delta>_of x))\<^sup>2)) \<in> O[?F](\<lambda>x. 1 / (real_of_rat (\<delta>_of x))\<^sup>2)" by (subst landau_o.big.cmult_in_iff, simp_all) hence l1: "(\<lambda>x. real (nat \<lceil>6 / (\<delta>_of x)\<^sup>2\<rceil>)) \<in> O[?F](\<lambda>x. 1 / (real_of_rat (\<delta>_of x))\<^sup>2)" by (intro landau_real_nat landau_rat_ceil[OF unit_1]) (simp_all add:of_rat_divide of_rat_power) have "(\<lambda>x. - ( ln (real_of_rat (\<epsilon>_of x)))) \<in> O[?F](\<lambda>x. ln (1 / real_of_rat (\<epsilon>_of x)))" by (intro landau_o.big_mono evt) (subst ln_div, auto) hence l2: "(\<lambda>x. real (nat \<lceil>- (18 * ln (real_of_rat (\<epsilon>_of x)))\<rceil>)) \<in> O[?F](\<lambda>x. ln (1 / real_of_rat (\<epsilon>_of x)))" by (intro landau_real_nat landau_ceil[OF unit_2], simp) have l3_aux: " (\<lambda>x. real (m_of x) * (18 + 4 * real (n_of x)) + 1) \<in> O[?F](\<lambda>x. real (n_of x) * real (m_of x))" by (rule sum_in_bigo[OF _unit_9], subst mult.commute) (intro landau_o.mult sum_in_bigo, auto simp:unit_3) have "(\<lambda>x. ln (real (m_of x) * (18 + 4 * real (n_of x)) + 1)) \<in> O[?F](\<lambda>x. ln (real (n_of x) * real (m_of x)))" apply (rule landau_ln_2[where a="2"], simp, simp) apply (rule evt[where m="2" and n="1"]) apply (metis dual_order.trans mult_left_mono mult_of_nat_commute of_nat_0_le_iff verit_prod_simplify(1)) using l3_aux by simp also have "(\<lambda>x. ln (real (n_of x) * real (m_of x))) \<in> O[?F](\<lambda>x. ln (real (n_of x)) + ln(real (m_of x)))" by (intro landau_o.big_mono evt[where m="1" and n="1"], auto simp add:ln_mult) finally have l3: "(\<lambda>x. ln (real (m_of x) * (18 + 4 * real (n_of x)) + 1)) \<in> O[?F](\<lambda>x. ln (real (n_of x)) + ln (real (m_of x)))" using landau_o.big_trans by simp have l4: "(\<lambda>x. ln (8 + 2 * real (n_of x))) \<in> O[?F](\<lambda>x. ln (real (n_of x)) + ln (real (m_of x)))" by (intro landau_sum_1 evt[where n="2"] landau_ln_2[where a="2"] iffD2[OF ln_ge_iff]) (auto intro!: sum_in_bigo simp add:unit_3) have l5: "(\<lambda>x. ln (9 + 2 * real (n_of x))) \<in> O[?F](\<lambda>x. ln (real (n_of x)) + ln (real (m_of x)))" by (intro landau_sum_1 evt[where n="2"] landau_ln_2[where a="2"] iffD2[OF ln_ge_iff]) (auto intro!: sum_in_bigo simp add:unit_3) have l6: "(\<lambda>x. ln (real (nat \<lceil>6 / (\<delta>_of x)\<^sup>2\<rceil>) + 1)) \<in> O[?F](g)" unfolding g_def by (intro landau_o.big_mult_1 landau_ln_3 sum_in_bigo unit_6 unit_2 l1 unit_1, simp) have l7: "(\<lambda>x. ln (9 + 2 * real (n_of x))) \<in> O[?F](g)" unfolding g_def by (intro landau_o.big_mult_1' unit_1 unit_2 l5) have l8: "(\<lambda>x. ln (real (nat \<lceil>- (18 * ln (real_of_rat (\<epsilon>_of x)))\<rceil>) + 1) ) \<in> O[?F](g)" unfolding g_def by (intro landau_o.big_mult_1 unit_6 landau_o.big_mult_1' unit_1 landau_ln_3 sum_in_bigo l2 unit_2) simp have l9: "(\<lambda>x. 5 + 4 * ln (8 + 2 * real (n_of x)) / ln 2 + 2 * ln (real (m_of x) * (18 + 4 * real (n_of x)) + 1) / ln 2) \<in> O[?F](\<lambda>x. ln (real (n_of x)) + ln (real (m_of x)))" by (intro sum_in_bigo, auto simp: l3 l4 unit_6) have l10: "(\<lambda>x. real (nat \<lceil>6 / (\<delta>_of x)\<^sup>2\<rceil>) * real (nat \<lceil>- (18 * ln (real_of_rat (\<epsilon>_of x)))\<rceil>) * (5 + 4 * ln (8 + 2 * real (n_of x)) / ln 2 + 2 * ln(real (m_of x) * (18 + 4 * real (n_of x)) + 1) / ln 2)) \<in> O[?F](g)" unfolding g_def by (intro landau_o.mult, auto simp: l1 l2 l9) have "f2_space_usage = (\<lambda>x. f2_space_usage (n_of x, m_of x, \<epsilon>_of x, \<delta>_of x))" by (simp add:case_prod_beta' n_of_def \<epsilon>_of_def \<delta>_of_def m_of_def) also have "... \<in> O[?F](g)" by (auto intro!:sum_in_bigo simp:Let_def log_def l6 l7 l8 l10 unit_8) also have "... = O[?F](?rhs)" by (simp add:case_prod_beta' g_def n_of_def \<epsilon>_of_def \<delta>_of_def m_of_def) finally show ?thesis by simp qed end
Formal statement is: lemma no_trailing_coeffs [simp]: "no_trailing (HOL.eq 0) (coeffs p)" Informal statement is: The coefficients of a polynomial are non-zero.