text
stringlengths 0
3.34M
|
---|
(**
Tanay Gavankar
tgavanka
15-414 F12
*)
(****************Homework 3************Due: 3pm Oct. 3rd*****************************************************)
(*****To prove some of the following theorems, you may need to first prove some lemmas.***************************)
(*****You are welcome to use whatever is proved in the class in Basics.v and Lists.v *****************************)
(*****For this homework, automatic tactics of Coq (auto, tauto, trivial, intuition, omega, etc.) are not allowed.*)
(***********************************************************************)
(***** Submit solutions in a single coq file via email to the TAs ******)
(***********************************************************************)
(******************************* question 1*******************************************************8 points*)
(** Prove [andb_true_elim2], marking cases (and subcases) when
you use [destruct]. *)
Theorem andb_true_elim2 : forall b c : bool,
andb b c = true -> c = true.
Proof.
intros.
destruct c.
(* Case c = true *)
reflexivity.
(* Case c = false *)
rewrite <- H.
destruct b.
(* Case b = true *)
reflexivity.
(* Case b = false *)
reflexivity.
Qed.
(******************************* question 2*******************************************************16 points*)
(*a*)
Theorem plus_assoc : forall n m p : nat,
n + (m + p) = (n + m) + p.
Proof.
intros.
induction n.
reflexivity.
simpl.
rewrite -> IHn.
reflexivity.
Qed.
(*b*)
Theorem plus_distr : forall n m: nat, S (n + m) = n + (S m).
Proof.
intros.
induction n.
induction m.
simpl.
reflexivity.
rewrite <- IHm.
simpl.
reflexivity.
simpl.
rewrite <- IHn.
reflexivity.
Qed.
(*c*)
Theorem plus_comm : forall n m : nat,
n + m = m + n.
Proof.
intros.
induction n.
induction m.
reflexivity.
simpl.
rewrite <- IHm.
simpl.
reflexivity.
simpl.
rewrite -> IHn.
apply plus_distr.
Qed.
(** [] *)
(*d*)
(** Translate your solution for [plus_comm] into an informal proof. *)
(** Theorem: Addition is commutative.
forall n m : nat, n + m = m + n
Proof:
Induct on n and m.
n = 0, m = 0
0 + 0 = 0 + 0
0 = 0
True
n = 0
IH: 0 + m = m + 0
P(k+1) => 1 + m = 1 + (m+0)
By IH: 1 + m = 1 + (0+m)
1 + m = 1 + m
True
IH: n + m = m + n
P(k+1) => (1+n) + m = m + (1+n)
1 + (n + m) = m + (1+n)
By IH: 1 + (m + n) = m + (1+n)
By distr: 1 + m + n = 1 + m + n
True
[]
*)
(******************************* question 3*******************************************************8 points*)
Fixpoint double (n:nat) :=
match n with
| O => O
| S n' => S (S (double n'))
end.
Lemma double_plus : forall n, double n = n + n .
Proof.
intros.
induction n.
reflexivity.
simpl.
rewrite -> IHn.
rewrite <- plus_distr.
reflexivity.
Qed.
(******************************* question 4*******************************************************8 points*)
(** Use [assert] to help prove this theorem. You shouldn't need to use induction. *)
Theorem plus_swap : forall n m p : nat,
n + (m + p) = m + (n + p).
Proof.
intros.
rewrite -> plus_assoc.
rewrite -> plus_assoc.
assert (H1: n + m = m + n).
apply plus_comm.
rewrite <- H1.
reflexivity.
Qed.
(******************************* question 5*******************************************************10 points*)
Lemma mult_zero : forall n : nat, n * 0 = 0.
Proof.
intros.
induction n.
reflexivity.
simpl.
rewrite -> IHn.
reflexivity.
Qed.
Lemma mult_iden : forall n m : nat, n + n * m = n * S m.
Proof.
intros.
induction n.
induction m.
reflexivity.
reflexivity.
simpl.
rewrite <- IHn.
rewrite -> plus_assoc.
rewrite -> plus_assoc.
assert (H: n + m = m + n).
rewrite -> plus_comm.
reflexivity.
rewrite -> H.
reflexivity.
Qed.
Theorem mult_comm : forall m n : nat,
m * n = n * m.
Proof.
intros.
induction m.
simpl.
rewrite -> mult_zero.
reflexivity.
induction n.
simpl.
rewrite -> mult_zero.
reflexivity.
simpl.
rewrite -> IHm.
simpl.
rewrite -> plus_swap.
rewrite -> mult_iden.
reflexivity.
Qed.
(******************************* question 6*******************************************************10 points*)
Theorem mult_plus_distr_r : forall n m p : nat,
(n + m) * p = (n * p) + (m * p).
Proof.
intros.
induction n.
induction m.
simpl.
reflexivity.
simpl.
reflexivity.
simpl.
rewrite -> IHn.
rewrite -> plus_assoc.
reflexivity.
Qed.
(***** Some definitions/notations for lists, as we saw in class *****)
Inductive natlist : Type :=
| nil : natlist
| cons : nat -> natlist -> natlist.
Notation "x :: l" := (cons x l) (at level 60, right associativity).
Notation "[ ]" := nil.
Notation "[ x , .. , y ]" := (cons x .. (cons y nil) ..).
Fixpoint app (l1 l2 : natlist) : natlist :=
match l1 with
| nil => l2
| h :: t => h :: (app t l2)
end.
Notation "x ++ y" := (app x y)
(right associativity, at level 60).
Fixpoint snoc (l:natlist) (v:nat) : natlist :=
match l with
| nil => [v]
| h :: t => h :: (snoc t v)
end.
Fixpoint rev (l:natlist) : natlist :=
match l with
| nil => nil
| h :: t => snoc (rev t) h
end.
(******************************* question 7*******************************************************12 points*)
(*a*) (* 2 points *)
Theorem app_nil_end : forall l : natlist,
l ++ [] = l.
Proof.
intros.
induction l.
simpl.
reflexivity.
simpl.
rewrite -> IHl.
reflexivity.
Qed.
Lemma snoc_rev : forall (l:natlist) (n:nat), rev(snoc l n) = n::rev(l).
Proof.
intros.
induction l.
simpl.
reflexivity.
simpl.
rewrite -> IHl.
simpl.
reflexivity.
Qed.
(*b*) (* 10 points *)
Theorem rev_involutive : forall l : natlist,
rev (rev l) = l.
Proof.
intros.
induction l.
simpl.
reflexivity.
simpl.
rewrite -> snoc_rev.
rewrite -> IHl.
reflexivity.
Qed.
(******************************* question 8*******************************************************16 points*)
(*a*) (* 4 points *)
Theorem snoc_append : forall (l:natlist) (n:nat),
snoc l n = l ++ [n].
Proof.
intros.
induction l.
reflexivity.
simpl.
rewrite <- IHl.
reflexivity.
Qed.
Lemma distr_snoc : forall (l1 l2 : natlist) (n:nat), snoc (l1 ++ l2) n = l1 ++ snoc l2 n.
intros.
induction l1.
induction l2.
simpl.
reflexivity.
simpl.
reflexivity.
simpl.
rewrite IHl1.
reflexivity.
Qed.
(*b*) (* 12 points *)
Theorem distr_rev : forall l1 l2 : natlist,
rev (l1 ++ l2) = (rev l2) ++ (rev l1).
Proof.
intros.
induction l1.
induction l2.
simpl.
reflexivity.
simpl.
rewrite app_nil_end.
reflexivity.
simpl.
rewrite -> IHl1.
rewrite -> distr_snoc.
reflexivity.
Qed.
(***** Some definitions on bags, as we saw in class *****)
Definition bag := natlist.
Fixpoint ble_nat (n m : nat) : bool :=
match n with
| O => true
| S n' =>
match m with
| O => false
| S m' => ble_nat n' m'
end
end.
Require Import Arith.
Fixpoint count (v:nat) (s:bag) : nat :=
match s with
nil => 0
| h :: t => if (beq_nat h v) then S (count v t)
else count v t
end.
Fixpoint remove_one (v:nat) (s:bag) : bag :=
match s with
nil => nil
| h::t => if (beq_nat v h)
then t
else h::(remove_one v t)
end.
(******************************* question 9*******************************************************12 points*)
(*a*) (* 2 points *)
Theorem count_member_nonzero : forall (s : bag),
ble_nat 1 (count 1 (1 :: s)) = true.
Proof.
intros.
induction s.
simpl.
reflexivity.
simpl.
reflexivity.
Qed.
(** The following lemma about [ble_nat] might help you in the next proof. *)
Theorem ble_n_Sn : forall n,
ble_nat n (S n) = true.
Proof.
intros n. induction n as [| n'].
simpl. reflexivity.
simpl. rewrite IHn'. reflexivity. Qed.
(*b*) (* 10 points *)
Theorem remove_decreases_count: forall (s : bag),
ble_nat (count 0 (remove_one 0 s)) (count 0 s) = true.
Proof.
intros.
induction s.
simpl.
reflexivity.
destruct n.
simpl.
rewrite -> ble_n_Sn.
reflexivity.
simpl.
rewrite IHs.
reflexivity.
Qed.
(******************************* BONUS QUESTION*******************************************************10 points*)
Theorem rev_inj : forall (l1 l2 : natlist), rev l1 = rev l2 -> l1 = l2.
Proof.
intros.
rewrite <- (rev_involutive l2).
rewrite <- (rev_involutive l1).
rewrite <- H.
reflexivity.
Qed. |
Our Darling ’ s First Book ( written in collaboration with Dorothy Barker ) ; Blackie , 1929
|
section
example (p q : Prop) (hp : p) : p ∨ q :=
begin left, assumption end
example (p q : Prop) (hqp : q ∨ p) : p ∨ q :=
begin
cases hqp with hq hp,
right, assumption,
left, assumption,
end
example (p q : Prop) (hqp : q ∧ p) : p ∧ q :=
begin
cases hqp with hq hp,
split; assumption,
end
example (p q : Prop) (hp : p) : p ∨ q :=
begin { left, assumption } <|> { right, assumption} end
example (p q : Prop) (hq : q) : p ∨ q :=
by { left, assumption } <|> { right, assumption}
example (p q : Prop) (hqp : q ∨ p) : p ∨ q :=
begin
cases hqp with hq hp; {left, assumption} <|> {right, assumption}
end
meta def my_tac : tactic unit :=
`[ repeat { {left, assumption} <|> right <|> assumption } ]
example (p q r : Prop) (hp : p) : p ∨ q ∨ r :=
by my_tac
example (p q r : Prop) (hq : q) : p ∨ q ∨ r :=
by my_tac
example (p q r : Prop) (hr : r) : p ∨ q ∨ r :=
by my_tac
example (p q r : Prop) (hp : p) (hq : q) (hr : r) :
p ∧ q ∧ r :=
by split; try {split}; assumption
example (p q r : Prop) (hp : p) (hq : q) (hr : r) :
p ∧ q ∧ r :=
begin
split,
all_goals { try {split} },
any_goals { assumption }
end
example (p q r : Prop) (hp : p) (hq : q) (hr : r) :
p ∧ ((p ∧ q) ∧ r) ∧ (q ∧ r ∧ p) :=
begin
repeat { any_goals { split }},
all_goals { assumption }
end
example (p q r : Prop) (hp : p) (hq : q) (hr : r) :
p ∧ ((p ∧ q) ∧ r) ∧ (q ∧ r ∧ p) :=
by repeat { any_goals { split <|> assumption} }
variables (f : ℕ → ℕ) (k : ℕ)
example (h1 : f 0 = 0) (h2 : k = 0) :
f k = 0 :=
begin
rw h2,
rw h1
end
example (x y : ℕ) (p : ℕ → Prop) (q : Prop) (h : q → x = y)
(h' : p y) (hq : q) : p x :=
by { rw (h hq), assumption }
variables (a b : nat)
example (h1 : a = b) (h2 : f a = 0) : f b = 0 :=
begin
rw [←h1 , h2 ]
end
example (a b c : nat) : a + b + c = a + c + b :=
begin
rw [add_assoc, add_comm b, ←add_assoc]
end
example (a b c : nat) : a + b + c = a + c + b :=
begin
rw [add_assoc, add_assoc, add_comm b]
end
example (a b c : nat) : a + b + c = a + c + b :=
begin
rw [add_assoc, add_assoc, add_comm _ b]
end
end
section
variables (f : nat → nat) (a : nat)
example (h : a + 0 = 0) : f a = f 0 :=
by { rw add_zero at h, rw h }
end
section
universe u
def tuple (α : Type u) (n : nat) :=
{ l : list α // list.length l = n }
variables {α : Type u} {n : nat}
example (h : n = 0) (t : tuple α n) : tuple α 0 :=
begin
rw h at t,
exact t
end
example {α : Type u} [ring α] (a b c : α) :
a * 0 + 0 * b + c * 0 + 0 * a = 0 :=
begin
rw [mul_zero, mul_zero, zero_mul, zero_mul],
repeat { rw add_zero }
end
example {α : Type u} [group α] {a b : α} (h : a * b = 1) :
a⁻¹ = b :=
by rw [←(mul_one a⁻¹ ), ←h, inv_mul_cancel_left]
end
|
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
⊢ OfLocalizationSpan P ↔ OfLocalizationFiniteSpan P
[PROOFSTEP]
delta RingHom.OfLocalizationSpan RingHom.OfLocalizationFiniteSpan
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
⊢ (∀ ⦃R S : Type u⦄ [inst : CommRing R] [inst_1 : CommRing S] (f : R →+* S) (s : Set R),
Ideal.span s = ⊤ → (∀ (r : ↑s), P (Localization.awayMap f ↑r)) → P f) ↔
∀ ⦃R S : Type u⦄ [inst : CommRing R] [inst_1 : CommRing S] (f : R →+* S) (s : Finset R),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap f ↑r)) → P f
[PROOFSTEP]
apply forall₅_congr
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
⊢ ∀ (a b : Type u) (c : CommRing a) (d : CommRing b) (e : a →+* b),
(∀ (s : Set a), Ideal.span s = ⊤ → (∀ (r : ↑s), P (Localization.awayMap e ↑r)) → P e) ↔
∀ (s : Finset a), Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e ↑r)) → P e
[PROOFSTEP]
intros
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
⊢ (∀ (s : Set a✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (Localization.awayMap e✝ ↑r)) → P e✝) ↔
∀ (s : Finset a✝), Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e✝ ↑r)) → P e✝
[PROOFSTEP]
constructor
[GOAL]
case h.mp
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
⊢ (∀ (s : Set a✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (Localization.awayMap e✝ ↑r)) → P e✝) →
∀ (s : Finset a✝), Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e✝ ↑r)) → P e✝
[PROOFSTEP]
intro h s
[GOAL]
case h.mp
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
h : ∀ (s : Set a✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (Localization.awayMap e✝ ↑r)) → P e✝
s : Finset a✝
⊢ Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e✝ ↑r)) → P e✝
[PROOFSTEP]
exact h s
[GOAL]
case h.mpr
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
⊢ (∀ (s : Finset a✝), Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e✝ ↑r)) → P e✝) →
∀ (s : Set a✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (Localization.awayMap e✝ ↑r)) → P e✝
[PROOFSTEP]
intro h s hs hs'
[GOAL]
case h.mpr
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
h : ∀ (s : Finset a✝), Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e✝ ↑r)) → P e✝
s : Set a✝
hs : Ideal.span s = ⊤
hs' : ∀ (r : ↑s), P (Localization.awayMap e✝ ↑r)
⊢ P e✝
[PROOFSTEP]
obtain ⟨s', h₁, h₂⟩ := (Ideal.span_eq_top_iff_finite s).mp hs
[GOAL]
case h.mpr.intro.intro
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
h : ∀ (s : Finset a✝), Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (Localization.awayMap e✝ ↑r)) → P e✝
s : Set a✝
hs : Ideal.span s = ⊤
hs' : ∀ (r : ↑s), P (Localization.awayMap e✝ ↑r)
s' : Finset a✝
h₁ : ↑s' ⊆ s
h₂ : Ideal.span ↑s' = ⊤
⊢ P e✝
[PROOFSTEP]
exact h s' h₂ fun x => hs' ⟨_, h₁ x.prop⟩
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
⊢ OfLocalizationSpanTarget P ↔ OfLocalizationFiniteSpanTarget P
[PROOFSTEP]
delta RingHom.OfLocalizationSpanTarget RingHom.OfLocalizationFiniteSpanTarget
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
⊢ (∀ ⦃R S : Type u⦄ [inst : CommRing R] [inst_1 : CommRing S] (f : R →+* S) (s : Set S),
Ideal.span s = ⊤ → (∀ (r : ↑s), P (comp (algebraMap S (Localization.Away ↑r)) f)) → P f) ↔
∀ ⦃R S : Type u⦄ [inst : CommRing R] [inst_1 : CommRing S] (f : R →+* S) (s : Finset S),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap S (Localization.Away ↑r)) f)) → P f
[PROOFSTEP]
apply forall₅_congr
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
⊢ ∀ (a b : Type u) (c : CommRing a) (d : CommRing b) (e : a →+* b),
(∀ (s : Set b), Ideal.span s = ⊤ → (∀ (r : ↑s), P (comp (algebraMap b (Localization.Away ↑r)) e)) → P e) ↔
∀ (s : Finset b),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b (Localization.Away ↑r)) e)) → P e
[PROOFSTEP]
intros
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
⊢ (∀ (s : Set b✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝) ↔
∀ (s : Finset b✝),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
[PROOFSTEP]
constructor
[GOAL]
case h.mp
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
⊢ (∀ (s : Set b✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝) →
∀ (s : Finset b✝),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
[PROOFSTEP]
intro h s
[GOAL]
case h.mp
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
h : ∀ (s : Set b✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
s : Finset b✝
⊢ Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
[PROOFSTEP]
exact h s
[GOAL]
case h.mpr
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
⊢ (∀ (s : Finset b✝),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝) →
∀ (s : Set b✝), Ideal.span s = ⊤ → (∀ (r : ↑s), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
[PROOFSTEP]
intro h s hs hs'
[GOAL]
case h.mpr
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
h :
∀ (s : Finset b✝),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
s : Set b✝
hs : Ideal.span s = ⊤
hs' : ∀ (r : ↑s), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)
⊢ P e✝
[PROOFSTEP]
obtain ⟨s', h₁, h₂⟩ := (Ideal.span_eq_top_iff_finite s).mp hs
[GOAL]
case h.mpr.intro.intro
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
a✝ b✝ : Type u
c✝ : CommRing a✝
d✝ : CommRing b✝
e✝ : a✝ →+* b✝
h :
∀ (s : Finset b✝),
Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)) → P e✝
s : Set b✝
hs : Ideal.span s = ⊤
hs' : ∀ (r : ↑s), P (comp (algebraMap b✝ (Localization.Away ↑r)) e✝)
s' : Finset b✝
h₁ : ↑s' ⊆ s
h₂ : Ideal.span ↑s' = ⊤
⊢ P e✝
[PROOFSTEP]
exact h s' h₂ fun x => hs' ⟨_, h₁ x.prop⟩
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
⊢ RespectsIso P
[PROOFSTEP]
apply hP.StableUnderComposition.respectsIso
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
⊢ ∀ {R S : Type u} [inst : CommRing R] [inst_1 : CommRing S] (e : R ≃+* S), P (RingEquiv.toRingHom e)
[PROOFSTEP]
introv
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
e : R ≃+* S
⊢ P (RingEquiv.toRingHom e)
[PROOFSTEP]
letI := e.toRingHom.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
e : R ≃+* S
this : Algebra R S := toAlgebra (RingEquiv.toRingHom e)
⊢ P (RingEquiv.toRingHom e)
[PROOFSTEP]
have : IsLocalization.Away (1 : R) S := by apply IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.bijective
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
e : R ≃+* S
this : Algebra R S := toAlgebra (RingEquiv.toRingHom e)
⊢ IsLocalization.Away 1 S
[PROOFSTEP]
apply IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.bijective
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
e : R ≃+* S
this✝ : Algebra R S := toAlgebra (RingEquiv.toRingHom e)
this : IsLocalization.Away 1 S
⊢ P (RingEquiv.toRingHom e)
[PROOFSTEP]
exact RingHom.PropertyIsLocal.HoldsForLocalizationAway hP S (1 : R)
[GOAL]
R S : Type u
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R →+* S
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
H : LocalizationPreserves P
r : R
inst✝¹ : IsLocalization.Away r R'
inst✝ : IsLocalization.Away (↑f r) S'
hf : P f
⊢ P (IsLocalization.Away.map R' S' f r)
[PROOFSTEP]
have : IsLocalization ((Submonoid.powers r).map f) S' := by rw [Submonoid.map_powers]; assumption
[GOAL]
R S : Type u
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R →+* S
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
H : LocalizationPreserves P
r : R
inst✝¹ : IsLocalization.Away r R'
inst✝ : IsLocalization.Away (↑f r) S'
hf : P f
⊢ IsLocalization (Submonoid.map f (Submonoid.powers r)) S'
[PROOFSTEP]
rw [Submonoid.map_powers]
[GOAL]
R S : Type u
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R →+* S
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
H : LocalizationPreserves P
r : R
inst✝¹ : IsLocalization.Away r R'
inst✝ : IsLocalization.Away (↑f r) S'
hf : P f
⊢ IsLocalization (Submonoid.powers (↑f r)) S'
[PROOFSTEP]
assumption
[GOAL]
R S : Type u
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R →+* S
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
H : LocalizationPreserves P
r : R
inst✝¹ : IsLocalization.Away r R'
inst✝ : IsLocalization.Away (↑f r) S'
hf : P f
this : IsLocalization (Submonoid.map f (Submonoid.powers r)) S'
⊢ P (IsLocalization.Away.map R' S' f r)
[PROOFSTEP]
exact H f (Submonoid.powers r) R' S' hf
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
⊢ OfLocalizationSpan P
[PROOFSTEP]
introv R hs hs'
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
hs : Ideal.span s = ⊤
hs' : ∀ (r : ↑s), P (Localization.awayMap f ↑r)
⊢ P f
[PROOFSTEP]
apply_fun Ideal.map f at hs
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
hs' : ∀ (r : ↑s), P (Localization.awayMap f ↑r)
hs : Ideal.map f (Ideal.span s) = Ideal.map f ⊤
⊢ P f
[PROOFSTEP]
rw [Ideal.map_span, Ideal.map_top] at hs
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
hs' : ∀ (r : ↑s), P (Localization.awayMap f ↑r)
hs : Ideal.span (↑f '' s) = ⊤
⊢ P f
[PROOFSTEP]
apply hP.OfLocalizationSpanTarget _ _ hs
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
hs' : ∀ (r : ↑s), P (Localization.awayMap f ↑r)
hs : Ideal.span (↑f '' s) = ⊤
⊢ ∀ (r : ↑(↑f '' s)), P (comp (algebraMap S (Localization.Away ↑r)) f)
[PROOFSTEP]
rintro ⟨_, r, hr, rfl⟩
[GOAL]
case mk.intro.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
hs' : ∀ (r : ↑s), P (Localization.awayMap f ↑r)
hs : Ideal.span (↑f '' s) = ⊤
r : R
hr : r ∈ s
⊢ P (comp (algebraMap S (Localization.Away ↑{ val := ↑f r, property := (_ : ∃ a, a ∈ s ∧ ↑f a = ↑f r) })) f)
[PROOFSTEP]
convert hP.StableUnderComposition _ _ (hP.HoldsForLocalizationAway (Localization.Away r) r) (hs' ⟨r, hr⟩) using 1
[GOAL]
case h.e'_5
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
R S : Type u
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
hs' : ∀ (r : ↑s), P (Localization.awayMap f ↑r)
hs : Ideal.span (↑f '' s) = ⊤
r : R
hr : r ∈ s
⊢ comp (algebraMap S (Localization.Away ↑{ val := ↑f r, property := (_ : ∃ a, a ∈ s ∧ ↑f a = ↑f r) })) f =
comp (Localization.awayMap f ↑{ val := r, property := hr }) (algebraMap R (Localization.Away r))
[PROOFSTEP]
exact (IsLocalization.map_comp _).symm
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
⊢ I ≤ J
[PROOFSTEP]
intro x hx
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
⊢ x ∈ J
[PROOFSTEP]
suffices J.colon (Ideal.span { x }) = ⊤ by
simpa using
Submodule.mem_colon.mp (show (1 : R) ∈ J.colon (Ideal.span { x }) from this.symm ▸ Submodule.mem_top) x
(Ideal.mem_span_singleton_self x)
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
this : Submodule.colon J (span {x}) = ⊤
⊢ x ∈ J
[PROOFSTEP]
simpa using
Submodule.mem_colon.mp (show (1 : R) ∈ J.colon (Ideal.span { x }) from this.symm ▸ Submodule.mem_top) x
(Ideal.mem_span_singleton_self x)
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
⊢ Submodule.colon J (span {x}) = ⊤
[PROOFSTEP]
refine' Not.imp_symm (J.colon (Ideal.span { x })).exists_le_maximal _
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
⊢ ¬∃ M, IsMaximal M ∧ Submodule.colon J (span {x}) ≤ M
[PROOFSTEP]
push_neg
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
⊢ ∀ (M : Ideal R), IsMaximal M → ¬Submodule.colon J (span {x}) ≤ M
[PROOFSTEP]
intro P hP le
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
P : Ideal R
hP : IsMaximal P
le : Submodule.colon J (span {x}) ≤ P
⊢ False
[PROOFSTEP]
obtain ⟨⟨⟨a, ha⟩, ⟨s, hs⟩⟩, eq⟩ :=
(IsLocalization.mem_map_algebraMap_iff P.primeCompl _).mp (h P hP (Ideal.mem_map_of_mem _ hx))
[GOAL]
case intro.mk.mk.mk
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
P : Ideal R
hP : IsMaximal P
le : Submodule.colon J (span {x}) ≤ P
a : R
ha : a ∈ J
s : R
hs : s ∈ primeCompl P
eq :
↑(algebraMap R (Localization.AtPrime P)) x *
↑(algebraMap R (Localization.AtPrime P)) ↑({ val := a, property := ha }, { val := s, property := hs }).snd =
↑(algebraMap R (Localization.AtPrime P)) ↑({ val := a, property := ha }, { val := s, property := hs }).fst
⊢ False
[PROOFSTEP]
rw [← _root_.map_mul, ← sub_eq_zero, ← map_sub] at eq
[GOAL]
case intro.mk.mk.mk
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
P : Ideal R
hP : IsMaximal P
le : Submodule.colon J (span {x}) ≤ P
a : R
ha : a ∈ J
s : R
hs : s ∈ primeCompl P
eq✝ :
↑(algebraMap R (Localization.AtPrime P)) (x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd) =
↑(algebraMap R (Localization.AtPrime P)) ↑({ val := a, property := ha }, { val := s, property := hs }).fst
eq :
↑(algebraMap R (Localization.AtPrime P))
(x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd -
↑({ val := a, property := ha }, { val := s, property := hs }).fst) =
0
⊢ False
[PROOFSTEP]
obtain ⟨⟨m, hm⟩, eq⟩ := (IsLocalization.map_eq_zero_iff P.primeCompl _ _).mp eq
[GOAL]
case intro.mk.mk.mk.intro.mk
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
P : Ideal R
hP : IsMaximal P
le : Submodule.colon J (span {x}) ≤ P
a : R
ha : a ∈ J
s : R
hs : s ∈ primeCompl P
eq✝¹ :
↑(algebraMap R (Localization.AtPrime P)) (x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd) =
↑(algebraMap R (Localization.AtPrime P)) ↑({ val := a, property := ha }, { val := s, property := hs }).fst
eq✝ :
↑(algebraMap R (Localization.AtPrime P))
(x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd -
↑({ val := a, property := ha }, { val := s, property := hs }).fst) =
0
m : R
hm : m ∈ primeCompl P
eq :
↑{ val := m, property := hm } *
(x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd -
↑({ val := a, property := ha }, { val := s, property := hs }).fst) =
0
⊢ False
[PROOFSTEP]
refine' hs ((hP.isPrime.mem_or_mem (le (Ideal.mem_colon_singleton.mpr _))).resolve_right hm)
[GOAL]
case intro.mk.mk.mk.intro.mk
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
P : Ideal R
hP : IsMaximal P
le : Submodule.colon J (span {x}) ≤ P
a : R
ha : a ∈ J
s : R
hs : s ∈ primeCompl P
eq✝¹ :
↑(algebraMap R (Localization.AtPrime P)) (x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd) =
↑(algebraMap R (Localization.AtPrime P)) ↑({ val := a, property := ha }, { val := s, property := hs }).fst
eq✝ :
↑(algebraMap R (Localization.AtPrime P))
(x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd -
↑({ val := a, property := ha }, { val := s, property := hs }).fst) =
0
m : R
hm : m ∈ primeCompl P
eq :
↑{ val := m, property := hm } *
(x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd -
↑({ val := a, property := ha }, { val := s, property := hs }).fst) =
0
⊢ s * m * x ∈ J
[PROOFSTEP]
simp only [Subtype.coe_mk, mul_sub, sub_eq_zero, mul_comm x s, mul_left_comm] at eq
[GOAL]
case intro.mk.mk.mk.intro.mk
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I J : Ideal R
h :
∀ (P : Ideal R) (hP : IsMaximal P),
map (algebraMap R (Localization.AtPrime P)) I ≤ map (algebraMap R (Localization.AtPrime P)) J
x : R
hx : x ∈ I
P : Ideal R
hP : IsMaximal P
le : Submodule.colon J (span {x}) ≤ P
a : R
ha : a ∈ J
s : R
hs : s ∈ primeCompl P
eq✝¹ :
↑(algebraMap R (Localization.AtPrime P)) (x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd) =
↑(algebraMap R (Localization.AtPrime P)) ↑({ val := a, property := ha }, { val := s, property := hs }).fst
eq✝ :
↑(algebraMap R (Localization.AtPrime P))
(x * ↑({ val := a, property := ha }, { val := s, property := hs }).snd -
↑({ val := a, property := ha }, { val := s, property := hs }).fst) =
0
m : R
hm : m ∈ primeCompl P
eq : s * (m * x) = m * a
⊢ s * m * x ∈ J
[PROOFSTEP]
simpa only [mul_assoc, eq] using J.mul_mem_left m ha
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I : Ideal R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), Ideal.map (algebraMap R (Localization.AtPrime J)) I = ⊥
P : Ideal R
hP : Ideal.IsMaximal P
⊢ Ideal.map (algebraMap R (Localization.AtPrime P)) I = Ideal.map (algebraMap R (Localization.AtPrime P)) ⊥
[PROOFSTEP]
simpa using h P hP
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I : Ideal R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), IsLocalization.coeSubmodule (Localization.AtPrime J) I = ⊥
P : Ideal R
hP : Ideal.IsMaximal P
x : R
hx : x ∈ I
⊢ x ∈ RingHom.ker (algebraMap R (Localization.AtPrime P))
[PROOFSTEP]
rw [RingHom.mem_ker, ← Submodule.mem_bot R, ← h P hP, IsLocalization.mem_coeSubmodule]
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
I : Ideal R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), IsLocalization.coeSubmodule (Localization.AtPrime J) I = ⊥
P : Ideal R
hP : Ideal.IsMaximal P
x : R
hx : x ∈ I
⊢ ∃ y, y ∈ I ∧ ↑(algebraMap R ((fun x => Localization.AtPrime P) x)) y = ↑(algebraMap R (Localization.AtPrime P)) x
[PROOFSTEP]
exact ⟨x, hx, rfl⟩
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
⊢ r = 0
[PROOFSTEP]
rw [← Ideal.span_singleton_eq_bot]
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
⊢ Ideal.span {r} = ⊥
[PROOFSTEP]
apply ideal_eq_bot_of_localization
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
⊢ ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), IsLocalization.coeSubmodule (Localization.AtPrime J) (Ideal.span {r}) = ⊥
[PROOFSTEP]
intro J hJ
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
J : Ideal R
hJ : Ideal.IsMaximal J
⊢ IsLocalization.coeSubmodule (Localization.AtPrime J) (Ideal.span {r}) = ⊥
[PROOFSTEP]
delta IsLocalization.coeSubmodule
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
J : Ideal R
hJ : Ideal.IsMaximal J
⊢ Submodule.map (Algebra.linearMap R (Localization.AtPrime J)) (Ideal.span {r}) = ⊥
[PROOFSTEP]
erw [Submodule.map_span, Submodule.span_eq_bot]
[GOAL]
case h
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
J : Ideal R
hJ : Ideal.IsMaximal J
⊢ ∀ (x : Localization.AtPrime J), x ∈ ↑(Algebra.linearMap R (Localization.AtPrime J)) '' {r} → x = 0
[PROOFSTEP]
rintro _ ⟨_, h', rfl⟩
[GOAL]
case h.intro.intro
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
J : Ideal R
hJ : Ideal.IsMaximal J
w✝ : R
h' : w✝ ∈ {r}
⊢ ↑(Algebra.linearMap R (Localization.AtPrime J)) w✝ = 0
[PROOFSTEP]
cases Set.mem_singleton_iff.mpr h'
[GOAL]
case h.intro.intro.refl
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
r : R
h : ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) r = 0
J : Ideal R
hJ : Ideal.IsMaximal J
h' : r ∈ {r}
⊢ ↑(Algebra.linearMap R (Localization.AtPrime J)) r = 0
[PROOFSTEP]
exact h J hJ
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ LocalizationPreserves fun R hR => IsReduced R
[PROOFSTEP]
introv R _ _
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
⊢ IsReduced S
[PROOFSTEP]
constructor
[GOAL]
case eq_zero
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
⊢ ∀ (x : S), IsNilpotent x → x = 0
[PROOFSTEP]
rintro x ⟨_ | n, e⟩
[GOAL]
case eq_zero.intro.zero
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
e : x ^ Nat.zero = 0
⊢ x = 0
[PROOFSTEP]
simpa using congr_arg (· * x) e
[GOAL]
case eq_zero.intro.succ
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
⊢ x = 0
[PROOFSTEP]
obtain ⟨⟨y, m⟩, hx⟩ := IsLocalization.surj M x
[GOAL]
case eq_zero.intro.succ.intro.mk
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑(y, m).snd = ↑(algebraMap R S) (y, m).fst
⊢ x = 0
[PROOFSTEP]
dsimp only at hx
[GOAL]
case eq_zero.intro.succ.intro.mk
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
⊢ x = 0
[PROOFSTEP]
let hx' := congr_arg (· ^ n.succ) hx
[GOAL]
case eq_zero.intro.succ.intro.mk
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : (fun x => x ^ Nat.succ n) (x * ↑(algebraMap R S) ↑m) = (fun x => x ^ Nat.succ n) (↑(algebraMap R S) y) :=
congr_arg (fun x => x ^ Nat.succ n) hx
⊢ x = 0
[PROOFSTEP]
simp only [mul_pow, e, zero_mul, ← RingHom.map_pow] at hx'
[GOAL]
case eq_zero.intro.succ.intro.mk
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
⊢ x = 0
[PROOFSTEP]
rw [← (algebraMap R S).map_zero] at hx'
[GOAL]
case eq_zero.intro.succ.intro.mk
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
⊢ x = 0
[PROOFSTEP]
obtain ⟨m', hm'⟩ := (IsLocalization.eq_iff_exists M S).mp hx'
[GOAL]
case eq_zero.intro.succ.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : ↑m' * 0 = ↑m' * y ^ Nat.succ n
⊢ x = 0
[PROOFSTEP]
apply_fun (· * (m' : R) ^ n) at hm'
[GOAL]
case eq_zero.intro.succ.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : ↑m' * 0 * ↑m' ^ n = ↑m' * y ^ Nat.succ n * ↑m' ^ n
⊢ x = 0
[PROOFSTEP]
simp only [mul_assoc, zero_mul, mul_zero] at hm'
[GOAL]
case eq_zero.intro.succ.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : 0 = ↑m' * (y ^ Nat.succ n * ↑m' ^ n)
⊢ x = 0
[PROOFSTEP]
rw [← mul_left_comm, ← pow_succ, ← mul_pow] at hm'
[GOAL]
case eq_zero.intro.succ.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : 0 = (y * ↑m') ^ Nat.succ n
⊢ x = 0
[PROOFSTEP]
replace hm' := IsNilpotent.eq_zero ⟨_, hm'.symm⟩
[GOAL]
case eq_zero.intro.succ.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : y * ↑m' = 0
⊢ x = 0
[PROOFSTEP]
rw [← (IsLocalization.map_units S m).mul_left_inj, hx, zero_mul, IsLocalization.map_eq_zero_iff M]
[GOAL]
case eq_zero.intro.succ.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : y * ↑m' = 0
⊢ ∃ m, ↑m * y = 0
[PROOFSTEP]
exact ⟨m', by rw [← hm', mul_comm]⟩
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R : Type u_1
hR : CommRing R
M : Submonoid R
S : Type u_1
hS : CommRing S
inst✝¹ : Algebra R S
inst✝ : IsLocalization M S
a✝ : IsReduced R
x : S
n : ℕ
e : x ^ Nat.succ n = 0
y : R
m : { x // x ∈ M }
hx : x * ↑(algebraMap R S) ↑m = ↑(algebraMap R S) y
hx' : ↑(algebraMap R S) 0 = ↑(algebraMap R S) (y ^ Nat.succ n)
m' : { x // x ∈ M }
hm' : y * ↑m' = 0
⊢ ↑m' * y = 0
[PROOFSTEP]
rw [← hm', mul_comm]
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ OfLocalizationMaximal fun R hR => IsReduced R
[PROOFSTEP]
introv R h
[GOAL]
R✝ S : Type u
inst✝⁶ : CommRing R✝
inst✝⁵ : CommRing S
M : Submonoid R✝
N : Submonoid S
R' S' : Type u
inst✝⁴ : CommRing R'
inst✝³ : CommRing S'
f : R✝ →+* S
inst✝² : Algebra R✝ R'
inst✝¹ : Algebra S S'
R : Type u_1
inst✝ : CommRing R
h :
∀ (J : Ideal R) (x : Ideal.IsMaximal J),
(fun R hR => IsReduced R) (Localization.AtPrime J) Localization.instCommRingLocalizationToCommMonoid
⊢ IsReduced R
[PROOFSTEP]
constructor
[GOAL]
case eq_zero
R✝ S : Type u
inst✝⁶ : CommRing R✝
inst✝⁵ : CommRing S
M : Submonoid R✝
N : Submonoid S
R' S' : Type u
inst✝⁴ : CommRing R'
inst✝³ : CommRing S'
f : R✝ →+* S
inst✝² : Algebra R✝ R'
inst✝¹ : Algebra S S'
R : Type u_1
inst✝ : CommRing R
h :
∀ (J : Ideal R) (x : Ideal.IsMaximal J),
(fun R hR => IsReduced R) (Localization.AtPrime J) Localization.instCommRingLocalizationToCommMonoid
⊢ ∀ (x : R), IsNilpotent x → x = 0
[PROOFSTEP]
intro x hx
[GOAL]
case eq_zero
R✝ S : Type u
inst✝⁶ : CommRing R✝
inst✝⁵ : CommRing S
M : Submonoid R✝
N : Submonoid S
R' S' : Type u
inst✝⁴ : CommRing R'
inst✝³ : CommRing S'
f : R✝ →+* S
inst✝² : Algebra R✝ R'
inst✝¹ : Algebra S S'
R : Type u_1
inst✝ : CommRing R
h :
∀ (J : Ideal R) (x : Ideal.IsMaximal J),
(fun R hR => IsReduced R) (Localization.AtPrime J) Localization.instCommRingLocalizationToCommMonoid
x : R
hx : IsNilpotent x
⊢ x = 0
[PROOFSTEP]
apply eq_zero_of_localization
[GOAL]
case eq_zero.h
R✝ S : Type u
inst✝⁶ : CommRing R✝
inst✝⁵ : CommRing S
M : Submonoid R✝
N : Submonoid S
R' S' : Type u
inst✝⁴ : CommRing R'
inst✝³ : CommRing S'
f : R✝ →+* S
inst✝² : Algebra R✝ R'
inst✝¹ : Algebra S S'
R : Type u_1
inst✝ : CommRing R
h :
∀ (J : Ideal R) (x : Ideal.IsMaximal J),
(fun R hR => IsReduced R) (Localization.AtPrime J) Localization.instCommRingLocalizationToCommMonoid
x : R
hx : IsNilpotent x
⊢ ∀ (J : Ideal R) (hJ : Ideal.IsMaximal J), ↑(algebraMap R (Localization.AtPrime J)) x = 0
[PROOFSTEP]
intro J hJ
[GOAL]
case eq_zero.h
R✝ S : Type u
inst✝⁶ : CommRing R✝
inst✝⁵ : CommRing S
M : Submonoid R✝
N : Submonoid S
R' S' : Type u
inst✝⁴ : CommRing R'
inst✝³ : CommRing S'
f : R✝ →+* S
inst✝² : Algebra R✝ R'
inst✝¹ : Algebra S S'
R : Type u_1
inst✝ : CommRing R
h :
∀ (J : Ideal R) (x : Ideal.IsMaximal J),
(fun R hR => IsReduced R) (Localization.AtPrime J) Localization.instCommRingLocalizationToCommMonoid
x : R
hx : IsNilpotent x
J : Ideal R
hJ : Ideal.IsMaximal J
⊢ ↑(algebraMap R (Localization.AtPrime J)) x = 0
[PROOFSTEP]
specialize h J hJ
[GOAL]
case eq_zero.h
R✝ S : Type u
inst✝⁶ : CommRing R✝
inst✝⁵ : CommRing S
M : Submonoid R✝
N : Submonoid S
R' S' : Type u
inst✝⁴ : CommRing R'
inst✝³ : CommRing S'
f : R✝ →+* S
inst✝² : Algebra R✝ R'
inst✝¹ : Algebra S S'
R : Type u_1
inst✝ : CommRing R
x : R
hx : IsNilpotent x
J : Ideal R
hJ : Ideal.IsMaximal J
h : IsReduced (Localization.AtPrime J)
⊢ ↑(algebraMap R (Localization.AtPrime J)) x = 0
[PROOFSTEP]
exact (hx.map <| algebraMap R <| Localization.AtPrime J).eq_zero
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.LocalizationPreserves fun {R S} x x_1 f => Function.Surjective ↑f
[PROOFSTEP]
introv R H x
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
H : Function.Surjective ↑f
x : S'
⊢ ∃ a, ↑(IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) a = x
[PROOFSTEP]
obtain ⟨x, ⟨_, s, hs, rfl⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
[GOAL]
case intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
H : Function.Surjective ↑f
x : S
s : R
hs : s ∈ ↑M
⊢ ∃ a,
↑(IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) a =
IsLocalization.mk' S' x { val := ↑f s, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f s) }
[PROOFSTEP]
obtain ⟨y, rfl⟩ := H x
[GOAL]
case intro.intro.mk.intro.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
H : Function.Surjective ↑f
s : R
hs : s ∈ ↑M
y : R
⊢ ∃ a,
↑(IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) a =
IsLocalization.mk' S' (↑f y) { val := ↑f s, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f s) }
[PROOFSTEP]
use IsLocalization.mk' R' y ⟨s, hs⟩
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
H : Function.Surjective ↑f
s : R
hs : s ∈ ↑M
y : R
⊢ ↑(IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
(IsLocalization.mk' R' y { val := s, property := hs }) =
IsLocalization.mk' S' (↑f y) { val := ↑f s, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f s) }
[PROOFSTEP]
rw [IsLocalization.map_mk']
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.OfLocalizationSpan fun {R S} x x_1 f => Function.Surjective ↑f
[PROOFSTEP]
introv R e H
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
⊢ Function.Surjective ↑f
[PROOFSTEP]
rw [← Set.range_iff_surjective, Set.eq_univ_iff_forall]
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
⊢ ∀ (x : S), x ∈ Set.range ↑f
[PROOFSTEP]
letI := f.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
⊢ ∀ (x : S), x ∈ Set.range ↑f
[PROOFSTEP]
intro x
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
⊢ x ∈ Set.range ↑f
[PROOFSTEP]
apply Submodule.mem_of_span_eq_top_of_smul_pow_mem (LinearMap.range (Algebra.linearMap R S)) s e
[GOAL]
case H
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
⊢ ∀ (r : ↑s), ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
intro r
[GOAL]
case H
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
obtain ⟨a, e'⟩ := H r (algebraMap _ _ x)
[GOAL]
case H.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
a : Localization.Away ↑r
e' : ↑(Localization.awayMap f ↑r) a = ↑(algebraMap S (Localization.Away (↑f ↑r))) x
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
obtain ⟨b, ⟨_, n, rfl⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers (r : R)) a
[GOAL]
case H.intro.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
b : R
n : ℕ
e' :
↑(Localization.awayMap f ↑r)
(IsLocalization.mk' (Localization.Away ↑r) b
{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) }) =
↑(algebraMap S (Localization.Away (↑f ↑r))) x
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
erw [IsLocalization.map_mk'] at e'
[GOAL]
case H.intro.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
b : R
n : ℕ
e' :
IsLocalization.mk' (Localization.Away (↑f ↑r)) (↑f b)
{
val :=
↑f
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) },
property :=
(_ :
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) } ∈
Submonoid.comap f (Submonoid.powers (↑f ↑r))) } =
↑(algebraMap S (Localization.Away (↑f ↑r))) x
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
rw [eq_comm, IsLocalization.eq_mk'_iff_mul_eq, Subtype.coe_mk, Subtype.coe_mk, ← map_mul] at e'
[GOAL]
case H.intro.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
b : R
n : ℕ
e' :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(x *
↑{
val :=
↑f
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) },
property :=
(_ :
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) } ∈
Submonoid.comap f (Submonoid.powers (↑f ↑r))) }) =
↑(algebraMap ((fun x => S) b) (Localization.Away (↑f ↑r))) (↑f b)
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
obtain ⟨⟨_, n', rfl⟩, e''⟩ := (IsLocalization.eq_iff_exists (Submonoid.powers (f r)) _).mp e'
[GOAL]
case H.intro.intro.intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
b : R
n : ℕ
e' :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(x *
↑{
val :=
↑f
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) },
property :=
(_ :
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) } ∈
Submonoid.comap f (Submonoid.powers (↑f ↑r))) }) =
↑(algebraMap ((fun x => S) b) (Localization.Away (↑f ↑r))) (↑f b)
n' : ℕ
e'' :
↑{ val := (fun x x_1 => x ^ x_1) (↑f ↑r) n',
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑f ↑r) y = (fun x x_1 => x ^ x_1) (↑f ↑r) n') } *
(x *
↑{
val :=
↑f
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) },
property :=
(_ :
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) } ∈
Submonoid.comap f (Submonoid.powers (↑f ↑r))) }) =
↑{ val := (fun x x_1 => x ^ x_1) (↑f ↑r) n',
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑f ↑r) y = (fun x x_1 => x ^ x_1) (↑f ↑r) n') } *
↑f b
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
dsimp only at e''
[GOAL]
case H.intro.intro.intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
b : R
n : ℕ
e' :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(x *
↑{
val :=
↑f
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) },
property :=
(_ :
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) } ∈
Submonoid.comap f (Submonoid.powers (↑f ↑r))) }) =
↑(algebraMap ((fun x => S) b) (Localization.Away (↑f ↑r))) (↑f b)
n' : ℕ
e'' : ↑f ↑r ^ n' * (x * ↑f (↑r ^ n)) = ↑f ↑r ^ n' * ↑f b
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
rw [mul_comm x, ← mul_assoc, ← map_pow, ← map_mul, ← map_mul, ← pow_add] at e''
[GOAL]
case H.intro.intro.intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Set R
e : Ideal.span s = ⊤
H :
∀ (r : ↑s),
(fun {R S} x x_1 f => Function.Surjective ↑f) Localization.instCommRingLocalizationToCommMonoid
Localization.instCommRingLocalizationToCommMonoid (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
x : S
r : ↑s
b : R
n : ℕ
e' :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(x *
↑{
val :=
↑f
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) },
property :=
(_ :
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n) } ∈
Submonoid.comap f (Submonoid.powers (↑f ↑r))) }) =
↑(algebraMap ((fun x => S) b) (Localization.Away (↑f ↑r))) (↑f b)
n' : ℕ
e'' : ↑f (↑r ^ (n' + n)) * x = ↑f (↑r ^ n' * b)
⊢ ∃ n, ↑r ^ n • x ∈ LinearMap.range (Algebra.linearMap R S)
[PROOFSTEP]
exact ⟨n' + n, _, e''.symm⟩
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.LocalizationPreserves @RingHom.Finite
[PROOFSTEP]
introv R hf
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
letI := f.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
this : Algebra R S := RingHom.toAlgebra f
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
letI := ((algebraMap S S').comp f).toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
this✝ : Algebra R S := RingHom.toAlgebra f
this : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
this✝ : Algebra R S := RingHom.toAlgebra f
this : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
letI := f'.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
this✝¹ : Algebra R S := RingHom.toAlgebra f
this✝ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this : Algebra R' S' := RingHom.toAlgebra f'
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
haveI : IsScalarTower R R' S' := IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
let fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') fun c x =>
RingHom.map_mul _ _
_
-- We claim that if `S` is generated by `T` as an `R`-module,
-- then `S'` is generated by `T` as an `R'`-module.
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.Finite f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
obtain ⟨T, hT⟩ := hf
[GOAL]
case mk.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
⊢ RingHom.Finite (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
use T.image (algebraMap S S')
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
⊢ Submodule.span R' ↑(Finset.image (↑(algebraMap S S')) T) = ⊤
[PROOFSTEP]
rw [eq_top_iff]
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
⊢ ⊤ ≤ Submodule.span R' ↑(Finset.image (↑(algebraMap S S')) T)
[PROOFSTEP]
rintro x
-
-- By the hypotheses, for each `x : S'`, we have `x = y / (f r)` for some `y : S` and `r : M`.
-- Since `S` is generated by `T`, the image of `y` should fall in the span of the image of `T`.
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
x : S'
⊢ x ∈ Submodule.span R' ↑(Finset.image (↑(algebraMap S S')) T)
[PROOFSTEP]
obtain ⟨y, ⟨_, ⟨r, hr, rfl⟩⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ IsLocalization.mk' S' y { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } ∈
Submodule.span R' ↑(Finset.image (↑(algebraMap S S')) T)
[PROOFSTEP]
rw [IsLocalization.mk'_eq_mul_mk'_one, mul_comm, Finset.coe_image]
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Submodule.span R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
have hy : y ∈ Submodule.span R ↑T := by rw [hT]; trivial
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ y ∈ Submodule.span R ↑T
[PROOFSTEP]
rw [hT]
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ y ∈ ⊤
[PROOFSTEP]
trivial
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : y ∈ Submodule.span R ↑T
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Submodule.span R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
replace hy : algebraMap S S' y ∈ Submodule.map fₐ.toLinearMap (Submodule.span R (T : Set S)) :=
Submodule.mem_map_of_mem hy
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.map (AlgHom.toLinearMap fₐ) (Submodule.span R ↑T)
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Submodule.span R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
rw [Submodule.map_span fₐ.toLinearMap T] at hy
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Submodule.span R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
have H : Submodule.span R (algebraMap S S' '' T) ≤ (Submodule.span R' (algebraMap S S' '' T)).restrictScalars R := by
rw [Submodule.span_le]; exact Submodule.subset_span
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
⊢ Submodule.span R (↑(algebraMap S S') '' ↑T) ≤
Submodule.restrictScalars R (Submodule.span R' (↑(algebraMap S S') '' ↑T))
[PROOFSTEP]
rw [Submodule.span_le]
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
⊢ ↑(algebraMap S S') '' ↑T ⊆ ↑(Submodule.restrictScalars R (Submodule.span R' (↑(algebraMap S S') '' ↑T)))
[PROOFSTEP]
exact Submodule.subset_span
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
H :
Submodule.span R (↑(algebraMap S S') '' ↑T) ≤
Submodule.restrictScalars R (Submodule.span R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Submodule.span R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
convert (Submodule.span R' (algebraMap S S' '' T)).smul_mem (IsLocalization.mk' R' (1 : R) ⟨r, hr⟩) (H hy) using 1
[GOAL]
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
H :
Submodule.span R (↑(algebraMap S S') '' ↑T) ≤
Submodule.restrictScalars R (Submodule.span R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y =
IsLocalization.mk' R' 1 { val := r, property := hr } • ↑(algebraMap S S') y
[PROOFSTEP]
rw [Algebra.smul_def]
[GOAL]
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
H :
Submodule.span R (↑(algebraMap S S') '' ↑T) ≤
Submodule.restrictScalars R (Submodule.span R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y =
↑(algebraMap R' S') (IsLocalization.mk' R' 1 { val := r, property := hr }) * ↑(algebraMap S S') y
[PROOFSTEP]
erw [IsLocalization.map_mk' M.le_comap_map]
[GOAL]
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Submodule.span R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Submodule.span R (↑(AlgHom.toLinearMap fₐ) '' ↑T)
H :
Submodule.span R (↑(algebraMap S S') '' ↑T) ≤
Submodule.restrictScalars R (Submodule.span R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y =
IsLocalization.mk' S' (↑f 1)
{ val := ↑f ↑{ val := r, property := hr },
property := (_ : ↑{ val := r, property := hr } ∈ Submonoid.comap f (Submonoid.map f M)) } *
↑(algebraMap S S') y
[PROOFSTEP]
rw [map_one]
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
let g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') fun c x => by
simp [Algebra.algebraMap_eq_smul_one]
-- We first obtain the `y' ∈ M` such that `s' = y' • s` is falls in the image of `S` in `S'`.
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x✝ : S
s : Finset S'
hx : ↑(algebraMap S S') x✝ ∈ Submodule.span R ↑s
c : R
x : S
⊢ ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x
[PROOFSTEP]
simp [Algebra.algebraMap_eq_smul_one]
-- We first obtain the `y' ∈ M` such that `s' = y' • s` is falls in the image of `S` in `S'`.
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
let y := IsLocalization.commonDenomOfFinset (M.map (algebraMap R S)) s
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
have hx₁ : (y : S) • (s : Set S') = g '' _ := (IsLocalization.finsetIntegerMultiple_image _ s).symm
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
obtain ⟨y', hy', e : algebraMap R S y' = y⟩ := y.prop
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
have : algebraMap R S y' • (s : Set S') = y' • (s : Set S') := by
simp_rw [Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
⊢ ↑(algebraMap R S) y' • ↑s = y' • ↑s
[PROOFSTEP]
simp_rw [Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
rw [← e, this] at hx₁
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hx₁ : y' • ↑s = ↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
replace hx₁ := congr_arg (Submodule.span R) hx₁
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
rw [Submodule.span_smul] at hx₁
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Submodule.span R ↑s
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
replace hx : _ ∈ y' • Submodule.span R (s : Set S') := Set.smul_mem_smul_set hx
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx : y' • ↑(algebraMap S S') x ∈ y' • Submodule.span R ↑s
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
rw [hx₁] at hx
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx : y' • ↑(algebraMap S S') x ∈ Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
erw [← g.map_smul, ← Submodule.map_span (g : S →ₗ[R] S')] at hx
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx : ↑g (y' • x) ∈ Submodule.map (↑↑g) (Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
obtain ⟨x', hx', hx'' : algebraMap _ _ _ = _⟩ := hx
[GOAL]
case intro.intro.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
obtain ⟨⟨_, a, ha₁, rfl⟩, ha₂⟩ := (IsLocalization.eq_iff_exists (M.map (algebraMap R S)) S').mp hx''
[GOAL]
case intro.intro.intro.intro.intro.mk.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
a : R
ha₁ : a ∈ ↑M
ha₂ :
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
⊢ ∃ m, m • x ∈ Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
use(⟨a, ha₁⟩ : M) * (⟨y', hy'⟩ : M)
[GOAL]
case h
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
a : R
ha₁ : a ∈ ↑M
ha₂ :
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
⊢ ({ val := a, property := ha₁ } * { val := y', property := hy' }) • x ∈
Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
convert
(Submodule.span R (IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s : Set S)).smul_mem a
hx' using
1
[GOAL]
case h.e'_4
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
a : R
ha₁ : a ∈ ↑M
ha₂ :
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
⊢ ({ val := a, property := ha₁ } * { val := y', property := hy' }) • x = a • x'
[PROOFSTEP]
convert ha₂.symm using 1
[GOAL]
case h.e'_2
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
a : R
ha₁ : a ∈ ↑M
ha₂ :
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
⊢ ({ val := a, property := ha₁ } * { val := y', property := hy' }) • x =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
[PROOFSTEP]
rw [Subtype.coe_mk, Submonoid.smul_def, Submonoid.coe_mul, ← smul_smul]
[GOAL]
case h.e'_2
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
a : R
ha₁ : a ∈ ↑M
ha₂ :
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
⊢ ↑{ val := a, property := ha₁ } • ↑{ val := y', property := hy' } • x = ↑(algebraMap R S) a * y' • x
[PROOFSTEP]
exact Algebra.smul_def _ _
[GOAL]
case h.e'_3
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
g : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S') (_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (c • x) = c • ↑(algebraMap S S') x)
y : { x // x ∈ Submonoid.map (algebraMap R S) M } := commonDenomOfFinset (Submonoid.map (algebraMap R S) M) s
y' : R
hy' : y' ∈ ↑M
e : ↑(algebraMap R S) y' = ↑y
this : ↑(algebraMap R S) y' • ↑s = y' • ↑s
hx₁✝ :
Submodule.span R (y' • ↑s) = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx₁ : y' • Submodule.span R ↑s = Submodule.span R (↑g '' ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
x' : S
hx' : x' ∈ ↑(Submodule.span R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s))
hx'' : ↑(algebraMap S S') x' = ↑g (y' • x)
a : R
ha₁ : a ∈ ↑M
ha₂ :
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
y' • x
⊢ a • x' =
↑{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } *
x'
[PROOFSTEP]
exact Algebra.smul_def _ _
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Submodule.span R' s
⊢ ∃ t, t • x ∈ Submodule.span R s
[PROOFSTEP]
obtain ⟨s', hss', hs'⟩ := Submodule.mem_span_finite_of_mem_span hx
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Submodule.span R' s
s' : Finset S
hss' : ↑s' ⊆ s
hs' : x ∈ Submodule.span R' ↑s'
⊢ ∃ t, t • x ∈ Submodule.span R s
[PROOFSTEP]
rsuffices ⟨t, ht⟩ : ∃ t : M, t • x ∈ Submodule.span R (s' : Set S)
[GOAL]
case intro.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Submodule.span R' s
s' : Finset S
hss' : ↑s' ⊆ s
hs' : x ∈ Submodule.span R' ↑s'
t : { x // x ∈ M }
ht : t • x ∈ Submodule.span R ↑s'
⊢ ∃ t, t • x ∈ Submodule.span R s
[PROOFSTEP]
exact ⟨t, Submodule.span_mono hss' ht⟩
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Submodule.span R' s
s' : Finset S
hss' : ↑s' ⊆ s
hs' : x ∈ Submodule.span R' ↑s'
⊢ ∃ t, t • x ∈ Submodule.span R ↑s'
[PROOFSTEP]
clear hx hss' s
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
x : S
s' : Finset S
hs' : x ∈ Submodule.span R' ↑s'
⊢ ∃ t, t • x ∈ Submodule.span R ↑s'
[PROOFSTEP]
induction s' using Finset.induction_on generalizing x
[GOAL]
case empty
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
x : S
hs' : x ∈ Submodule.span R' ↑∅
⊢ ∃ t, t • x ∈ Submodule.span R ↑∅
[PROOFSTEP]
use 1
[GOAL]
case h
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
x : S
hs' : x ∈ Submodule.span R' ↑∅
⊢ 1 • x ∈ Submodule.span R ↑∅
[PROOFSTEP]
simpa using hs'
[GOAL]
case insert
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a✝² : S
s✝ : Finset S
a✝¹ : ¬a✝² ∈ s✝
a✝ : ∀ (x : S), x ∈ Submodule.span R' ↑s✝ → ∃ t, t • x ∈ Submodule.span R ↑s✝
x : S
hs' : x ∈ Submodule.span R' ↑(insert a✝² s✝)
⊢ ∃ t, t • x ∈ Submodule.span R ↑(insert a✝² s✝)
[PROOFSTEP]
rename_i a s _ hs
[GOAL]
case insert
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
x : S
hs' : x ∈ Submodule.span R' ↑(insert a s)
⊢ ∃ t, t • x ∈ Submodule.span R ↑(insert a s)
[PROOFSTEP]
simp only [Finset.coe_insert, Finset.image_insert, Finset.coe_image, Subtype.coe_mk, Submodule.mem_span_insert] at hs' ⊢
[GOAL]
case insert
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
x : S
hs' : ∃ a_1 z, z ∈ Submodule.span R' ↑s ∧ x = a_1 • a + z
⊢ ∃ t a_1 z, z ∈ Submodule.span R ↑s ∧ t • x = a_1 • a + z
[PROOFSTEP]
rcases hs' with ⟨y, z, hz, rfl⟩
[GOAL]
case insert.intro.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
⊢ ∃ t a_1 z_1, z_1 ∈ Submodule.span R ↑s ∧ t • (y • a + z) = a_1 • a + z_1
[PROOFSTEP]
rcases IsLocalization.surj M y with ⟨⟨y', s'⟩, e⟩
[GOAL]
case insert.intro.intro.intro.intro.mk
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
y' : R
s' : { x // x ∈ M }
e : y * ↑(algebraMap R R') ↑(y', s').snd = ↑(algebraMap R R') (y', s').fst
⊢ ∃ t a_1 z_1, z_1 ∈ Submodule.span R ↑s ∧ t • (y • a + z) = a_1 • a + z_1
[PROOFSTEP]
replace e : _ * a = _ * a := (congr_arg (fun x => algebraMap R' S x * a) e : _)
[GOAL]
case insert.intro.intro.intro.intro.mk
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
y' : R
s' : { x // x ∈ M }
e :
↑(algebraMap R' S) (y * ↑(algebraMap R R') ↑(y', s').snd) * a =
↑(algebraMap R' S) (↑(algebraMap R R') (y', s').fst) * a
⊢ ∃ t a_1 z_1, z_1 ∈ Submodule.span R ↑s ∧ t • (y • a + z) = a_1 • a + z_1
[PROOFSTEP]
simp_rw [RingHom.map_mul, ← IsScalarTower.algebraMap_apply, mul_comm (algebraMap R' S y), mul_assoc, ←
Algebra.smul_def] at e
[GOAL]
case insert.intro.intro.intro.intro.mk
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
y' : R
s' : { x // x ∈ M }
e : ↑s' • y • a = y' • a
⊢ ∃ t a_1 z_1, z_1 ∈ Submodule.span R ↑s ∧ t • (y • a + z) = a_1 • a + z_1
[PROOFSTEP]
rcases hs _ hz with ⟨t, ht⟩
[GOAL]
case insert.intro.intro.intro.intro.mk.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
y' : R
s' : { x // x ∈ M }
e : ↑s' • y • a = y' • a
t : { x // x ∈ M }
ht : t • z ∈ Submodule.span R ↑s
⊢ ∃ t a_1 z_1, z_1 ∈ Submodule.span R ↑s ∧ t • (y • a + z) = a_1 • a + z_1
[PROOFSTEP]
refine' ⟨t * s', t * y', _, (Submodule.span R (s : Set S)).smul_mem s' ht, _⟩
[GOAL]
case insert.intro.intro.intro.intro.mk.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
y' : R
s' : { x // x ∈ M }
e : ↑s' • y • a = y' • a
t : { x // x ∈ M }
ht : t • z ∈ Submodule.span R ↑s
⊢ (t * s') • (y • a + z) = (↑t * y') • a + ↑s' • t • z
[PROOFSTEP]
rw [smul_add, ← smul_smul, mul_comm, ← smul_smul, ← smul_smul, ← e]
[GOAL]
case insert.intro.intro.intro.intro.mk.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
a : S
s : Finset S
a✝ : ¬a ∈ s
hs : ∀ (x : S), x ∈ Submodule.span R' ↑s → ∃ t, t • x ∈ Submodule.span R ↑s
y : R'
z : S
hz : z ∈ Submodule.span R' ↑s
y' : R
s' : { x // x ∈ M }
e : ↑s' • y • a = y' • a
t : { x // x ∈ M }
ht : t • z ∈ Submodule.span R ↑s
⊢ t • s' • y • a + s' • t • z = ↑t • ↑s' • y • a + ↑s' • t • z
[PROOFSTEP]
rfl
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Algebra.adjoin R' s
⊢ ∃ t, t • x ∈ Algebra.adjoin R s
[PROOFSTEP]
change ∃ t : M, t • x ∈ Subalgebra.toSubmodule (Algebra.adjoin R s)
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Algebra.adjoin R' s
⊢ ∃ t, t • x ∈ ↑Subalgebra.toSubmodule (Algebra.adjoin R s)
[PROOFSTEP]
change x ∈ Subalgebra.toSubmodule (Algebra.adjoin R' s) at hx
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ ↑Subalgebra.toSubmodule (Algebra.adjoin R' s)
⊢ ∃ t, t • x ∈ ↑Subalgebra.toSubmodule (Algebra.adjoin R s)
[PROOFSTEP]
simp_rw [Algebra.adjoin_eq_span] at hx ⊢
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R' S
inst✝² : Algebra R S
inst✝¹ : IsScalarTower R R' S
inst✝ : IsLocalization M R'
s : Set S
x : S
hx : x ∈ Submodule.span R' ↑(Submonoid.closure s)
⊢ ∃ t, t • x ∈ Submodule.span R ↑(Submonoid.closure s)
[PROOFSTEP]
exact multiple_mem_span_of_mem_localization_span M R' _ _ hx
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.OfLocalizationSpan @RingHom.Finite
[PROOFSTEP]
rw [RingHom.ofLocalizationSpan_iff_finite]
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.OfLocalizationFiniteSpan @RingHom.Finite
[PROOFSTEP]
introv R hs H
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
⊢ RingHom.Finite f
[PROOFSTEP]
letI := f.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
⊢ RingHom.Finite f
[PROOFSTEP]
letI := fun r : s => (Localization.awayMap f r).toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
⊢ RingHom.Finite f
[PROOFSTEP]
have : ∀ r : s, IsLocalization ((Submonoid.powers (r : R)).map (algebraMap R S)) (Localization.Away (f r)) := by
intro r; rw [Submonoid.map_powers]; exact Localization.isLocalization
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
⊢ ∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
[PROOFSTEP]
intro r
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
r : { x // x ∈ s }
⊢ IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
[PROOFSTEP]
rw [Submonoid.map_powers]
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
r : { x // x ∈ s }
⊢ IsLocalization (Submonoid.powers (↑(algebraMap R S) ↑r)) (Localization.Away (↑f ↑r))
[PROOFSTEP]
exact Localization.isLocalization
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝¹ : Algebra R S := RingHom.toAlgebra f
this✝ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
⊢ RingHom.Finite f
[PROOFSTEP]
haveI : ∀ r : s, IsScalarTower R (Localization.Away (r : R)) (Localization.Away (f r)) := fun r =>
IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp (Submonoid.powers (r : R)).le_comap_map).symm
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
⊢ RingHom.Finite f
[PROOFSTEP]
constructor
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.Finite (Localization.awayMap f ↑r)
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
⊢ Submodule.FG ⊤
[PROOFSTEP]
replace H := fun r => (H r).1
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
H : ∀ (r : { x // x ∈ s }), Submodule.FG ⊤
⊢ Submodule.FG ⊤
[PROOFSTEP]
choose s₁ s₂ using H
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
⊢ Submodule.FG ⊤
[PROOFSTEP]
let sf := fun x : s => IsLocalization.finsetIntegerMultiple (Submonoid.powers (f x)) (s₁ x)
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ Submodule.FG ⊤
[PROOFSTEP]
use s.attach.biUnion sf
[GOAL]
case h
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ Submodule.span R ↑(Finset.biUnion (Finset.attach s) sf) = ⊤
[PROOFSTEP]
rw [Submodule.span_attach_biUnion, eq_top_iff]
-- It suffices to show that `r ^ n • x ∈ span T` for each `r : s`, since `{ r ^ n }` spans `R`.
-- This then follows from the fact that each `x : R` is a linear combination of the generating set
-- of `Sᵣ`. By multiplying a sufficiently large power of `r`, we can cancel out the `r`s in the
-- denominators of both the generating set and the coefficients.
[GOAL]
case h
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ ⊤ ≤ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
rintro x -
[GOAL]
case h
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
⊢ x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
apply Submodule.mem_of_span_eq_top_of_smul_pow_mem _ (s : Set R) hs _ _
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
⊢ ∀ (r : ↑↑s), ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
intro r
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
obtain ⟨⟨_, n₁, rfl⟩, hn₁⟩ :=
multiple_mem_span_of_mem_localization_span (Submonoid.powers (r : R)) (Localization.Away (r : R))
(s₁ r : Set (Localization.Away (f r))) (algebraMap S _ x) (by rw [s₂ r]; trivial)
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
⊢ ↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈ Submodule.span (Localization.Away ↑r) ↑(s₁ r)
[PROOFSTEP]
rw [s₂ r]
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
⊢ ↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈ ⊤
[PROOFSTEP]
trivial
[GOAL]
case intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } •
↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈
Submodule.span R ↑(s₁ r)
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
dsimp only at hn₁
[GOAL]
case intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } • ↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈
Submodule.span R ↑(s₁ r)
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
rw [Submonoid.smul_def, Algebra.smul_def, IsScalarTower.algebraMap_apply R S, ← map_mul] at hn₁
[GOAL]
case intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S) ↑{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } * x) ∈
Submodule.span R ↑(s₁ r)
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
obtain ⟨⟨_, n₂, rfl⟩, hn₂⟩ :=
IsLocalization.smul_mem_finsetIntegerMultiple_span (Submonoid.powers (r : R)) (Localization.Away (f r)) _ (s₁ r) hn₁
[GOAL]
case intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S) ↑{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } * x) ∈
Submodule.span R ↑(s₁ r)
n₂ : ℕ
hn₂ :
{ val := (fun x x_1 => x ^ x_1) (↑r) n₂,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₂) } •
(↑(algebraMap R S) ↑{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } * x) ∈
Submodule.span R
↑(IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (s₁ r))
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
rw [Submonoid.smul_def, ← Algebra.smul_def, smul_smul, Subtype.coe_mk, ← pow_add] at hn₂
[GOAL]
case intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S) ↑{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } * x) ∈
Submodule.span R ↑(s₁ r)
n₂ : ℕ
hn₂ :
↑r ^ (n₂ + n₁) • x ∈
Submodule.span R
↑(IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (s₁ r))
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
simp_rw [Submonoid.map_powers] at hn₂
[GOAL]
case intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S) ↑{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } * x) ∈
Submodule.span R ↑(s₁ r)
n₂ : ℕ
hn₂ :
↑r ^ (n₂ + n₁) • x ∈
Submodule.span R ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑(algebraMap R S) ↑r)) (s₁ r))
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
use n₂ + n₁
[GOAL]
case h
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S) ↑{ val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } * x) ∈
Submodule.span R ↑(s₁ r)
n₂ : ℕ
hn₂ :
↑r ^ (n₂ + n₁) • x ∈
Submodule.span R ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑(algebraMap R S) ↑r)) (s₁ r))
⊢ ↑r ^ (n₂ + n₁) • x ∈ ⨆ (x : { x // x ∈ s }), Submodule.span R ↑(sf x)
[PROOFSTEP]
exact le_iSup (fun x : s => Submodule.span R (sf x : Set S)) r hn₂
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.LocalizationPreserves @RingHom.FiniteType
[PROOFSTEP]
introv R hf
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
letI := f.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this : Algebra R S := RingHom.toAlgebra f
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
letI := ((algebraMap S S').comp f).toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝ : Algebra R S := RingHom.toAlgebra f
this : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝ : Algebra R S := RingHom.toAlgebra f
this : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
letI := f'.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝¹ : Algebra R S := RingHom.toAlgebra f
this✝ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this : Algebra R' S' := RingHom.toAlgebra f'
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
haveI : IsScalarTower R R' S' := IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
obtain ⟨T, hT⟩ := id hf
[GOAL]
case mk.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))
[PROOFSTEP]
use T.image (algebraMap S S')
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
⊢ Algebra.adjoin R' ↑(Finset.image (↑(algebraMap S S')) T) = ⊤
[PROOFSTEP]
rw [eq_top_iff]
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
⊢ ⊤ ≤ Algebra.adjoin R' ↑(Finset.image (↑(algebraMap S S')) T)
[PROOFSTEP]
rintro x -
[GOAL]
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
x : S'
⊢ x ∈ Algebra.adjoin R' ↑(Finset.image (↑(algebraMap S S')) T)
[PROOFSTEP]
obtain ⟨y, ⟨_, ⟨r, hr, rfl⟩⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ IsLocalization.mk' S' y { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } ∈
Algebra.adjoin R' ↑(Finset.image (↑(algebraMap S S')) T)
[PROOFSTEP]
rw [IsLocalization.mk'_eq_mul_mk'_one, mul_comm, Finset.coe_image]
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Algebra.adjoin R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ y ∈ Algebra.adjoin R ↑T
[PROOFSTEP]
rw [hT]
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ y ∈ ⊤
[PROOFSTEP]
trivial
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : y ∈ Algebra.adjoin R ↑T
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Algebra.adjoin R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ := Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Subalgebra.map fₐ (Algebra.adjoin R ↑T)
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Algebra.adjoin R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
rw [fₐ.map_adjoin T] at hy
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Algebra.adjoin R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
have H : Algebra.adjoin R (algebraMap S S' '' T) ≤ (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := by
rw [Algebra.adjoin_le_iff]; exact Algebra.subset_adjoin
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
⊢ Algebra.adjoin R (↑(algebraMap S S') '' ↑T) ≤
Subalgebra.restrictScalars R (Algebra.adjoin R' (↑(algebraMap S S') '' ↑T))
[PROOFSTEP]
rw [Algebra.adjoin_le_iff]
[GOAL]
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
⊢ ↑(algebraMap S S') '' ↑T ⊆ ↑(Subalgebra.restrictScalars R (Algebra.adjoin R' (↑(algebraMap S S') '' ↑T)))
[PROOFSTEP]
exact Algebra.subset_adjoin
[GOAL]
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
H :
Algebra.adjoin R (↑(algebraMap S S') '' ↑T) ≤
Subalgebra.restrictScalars R (Algebra.adjoin R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y ∈
Algebra.adjoin R' (↑(algebraMap S S') '' ↑T)
[PROOFSTEP]
convert (Algebra.adjoin R' (algebraMap S S' '' T)).smul_mem (H hy) (IsLocalization.mk' R' (1 : R) ⟨r, hr⟩) using 1
[GOAL]
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
H :
Algebra.adjoin R (↑(algebraMap S S') '' ↑T) ≤
Subalgebra.restrictScalars R (Algebra.adjoin R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y =
IsLocalization.mk' R' 1 { val := r, property := hr } • ↑(algebraMap S S') y
[PROOFSTEP]
rw [Algebra.smul_def]
[GOAL]
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
H :
Algebra.adjoin R (↑(algebraMap S S') '' ↑T) ≤
Subalgebra.restrictScalars R (Algebra.adjoin R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y =
↑(algebraMap R' S') (IsLocalization.mk' R' 1 { val := r, property := hr }) * ↑(algebraMap S S') y
[PROOFSTEP]
erw [IsLocalization.map_mk' M.le_comap_map]
[GOAL]
case h.e'_4
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
AlgHom.mk' (algebraMap S S')
(_ : ∀ (c : R) (x : S), ↑(algebraMap S S') (↑f c * x) = ↑(algebraMap S S') (↑f c) * ↑(algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : ↑(algebraMap S S') y ∈ Algebra.adjoin R (↑fₐ '' ↑T)
H :
Algebra.adjoin R (↑(algebraMap S S') '' ↑T) ≤
Subalgebra.restrictScalars R (Algebra.adjoin R' (↑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := ↑f r, property := (_ : ∃ a, a ∈ ↑M ∧ ↑f a = ↑f r) } * ↑(algebraMap S S') y =
IsLocalization.mk' S' (↑f 1)
{ val := ↑f ↑{ val := r, property := hr },
property := (_ : ↑{ val := r, property := hr } ∈ Submonoid.comap f (Submonoid.map f M)) } *
↑(algebraMap S S') y
[PROOFSTEP]
rw [map_one]
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
let g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
let y := IsLocalization.commonDenomOfFinset M s
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
have hx₁ : (y : S) • (s : Set S') = g '' _ := (IsLocalization.finsetIntegerMultiple_image _ s).symm
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
obtain ⟨n, hn⟩ :=
Algebra.pow_smul_mem_of_smul_subset_of_mem_adjoin (y : S) (s : Set S') (A.map g)
(by rw [hx₁]; exact Set.image_subset _ hA₁) hx (Set.mem_image_of_mem _ (hA₂ y.2))
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
⊢ ↑y • ↑s ⊆ ↑(Subalgebra.map g A)
[PROOFSTEP]
rw [hx₁]
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
⊢ ↑g '' ↑(finsetIntegerMultiple M s) ⊆ ↑(Subalgebra.map g A)
[PROOFSTEP]
exact Set.image_subset _ hA₁
[GOAL]
case intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
n : ℕ
hn : ∀ (n_1 : ℕ), n_1 ≥ n → ↑y ^ n_1 • ↑(algebraMap S S') x ∈ Subalgebra.map g A
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
obtain ⟨x', hx', hx''⟩ := hn n (le_of_eq rfl)
[GOAL]
case intro.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
n : ℕ
hn : ∀ (n_1 : ℕ), n_1 ≥ n → ↑y ^ n_1 • ↑(algebraMap S S') x ∈ Subalgebra.map g A
x' : S
hx' : x' ∈ ↑A.toSubsemiring
hx'' : ↑↑g x' = ↑y ^ n • ↑(algebraMap S S') x
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
rw [Algebra.smul_def, ← _root_.map_mul] at hx''
[GOAL]
case intro.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
n : ℕ
hn : ∀ (n_1 : ℕ), n_1 ≥ n → ↑y ^ n_1 • ↑(algebraMap S S') x ∈ Subalgebra.map g A
x' : S
hx' : x' ∈ ↑A.toSubsemiring
hx'' : ↑↑g x' = ↑(algebraMap S S') (↑y ^ n * x)
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
obtain ⟨a, ha₂⟩ := (IsLocalization.eq_iff_exists M S').mp hx''
[GOAL]
case intro.intro.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
n : ℕ
hn : ∀ (n_1 : ℕ), n_1 ≥ n → ↑y ^ n_1 • ↑(algebraMap S S') x ∈ Subalgebra.map g A
x' : S
hx' : x' ∈ ↑A.toSubsemiring
hx'' : ↑↑g x' = ↑(algebraMap S S') (↑y ^ n * x)
a : { x // x ∈ M }
ha₂ : ↑a * x' = ↑a * (↑y ^ n * x)
⊢ ∃ m, m • x ∈ A
[PROOFSTEP]
use a * y ^ n
[GOAL]
case h
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
n : ℕ
hn : ∀ (n_1 : ℕ), n_1 ≥ n → ↑y ^ n_1 • ↑(algebraMap S S') x ∈ Subalgebra.map g A
x' : S
hx' : x' ∈ ↑A.toSubsemiring
hx'' : ↑↑g x' = ↑(algebraMap S S') (↑y ^ n * x)
a : { x // x ∈ M }
ha₂ : ↑a * x' = ↑a * (↑y ^ n * x)
⊢ (a * y ^ n) • x ∈ A
[PROOFSTEP]
convert A.mul_mem hx' (hA₂ a.prop) using 1
[GOAL]
case h.e'_4
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M✝ : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
M : Submonoid S
inst✝ : IsLocalization M S'
x : S
s : Finset S'
A : Subalgebra R S
hA₁ : ↑(finsetIntegerMultiple M s) ⊆ ↑A
hA₂ : M ≤ A.toSubmonoid
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
g : S →ₐ[R] S' := IsScalarTower.toAlgHom R S S'
y : { x // x ∈ M } := commonDenomOfFinset M s
hx₁ : ↑y • ↑s = ↑g '' ↑(finsetIntegerMultiple M s)
n : ℕ
hn : ∀ (n_1 : ℕ), n_1 ≥ n → ↑y ^ n_1 • ↑(algebraMap S S') x ∈ Subalgebra.map g A
x' : S
hx' : x' ∈ ↑A.toSubsemiring
hx'' : ↑↑g x' = ↑(algebraMap S S') (↑y ^ n * x)
a : { x // x ∈ M }
ha₂ : ↑a * x' = ↑a * (↑y ^ n * x)
⊢ (a * y ^ n) • x = x' * ↑a
[PROOFSTEP]
rw [Submonoid.smul_def, smul_eq_mul, Submonoid.coe_mul, SubmonoidClass.coe_pow, mul_assoc, ← ha₂, mul_comm]
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
⊢ ∃ m, m • x ∈ Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
obtain ⟨⟨_, a, ha, rfl⟩, e⟩ :=
IsLocalization.exists_smul_mem_of_mem_adjoin (M.map (algebraMap R S)) x s (Algebra.adjoin R _) Algebra.subset_adjoin
(by rintro _ ⟨a, _, rfl⟩; exact Subalgebra.algebraMap_mem _ a) hx
[GOAL]
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
⊢ Submonoid.map (algebraMap R S) M ≤
(Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)).toSubsemiring.toSubmonoid
[PROOFSTEP]
rintro _ ⟨a, _, rfl⟩
[GOAL]
case intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
a : R
left✝ : a ∈ ↑M
⊢ ↑(algebraMap R S) a ∈
(Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)).toSubsemiring.toSubmonoid
[PROOFSTEP]
exact Subalgebra.algebraMap_mem _ a
[GOAL]
case intro.mk.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
a : R
ha : a ∈ ↑M
e :
{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } • x ∈
Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
⊢ ∃ m, m • x ∈ Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
refine' ⟨⟨a, ha⟩, _⟩
[GOAL]
case intro.mk.intro.intro
R S : Type u
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝⁷ : CommRing R'
inst✝⁶ : CommRing S'
f : R →+* S
inst✝⁵ : Algebra R R'
inst✝⁴ : Algebra S S'
inst✝³ : Algebra R S
inst✝² : Algebra R S'
inst✝¹ : IsScalarTower R S S'
inst✝ : IsLocalization (Submonoid.map (algebraMap R S) M) S'
x : S
s : Finset S'
hx : ↑(algebraMap S S') x ∈ Algebra.adjoin R ↑s
a : R
ha : a ∈ ↑M
e :
{ val := ↑(algebraMap R S) a, property := (_ : ∃ a_1, a_1 ∈ ↑M ∧ ↑(algebraMap R S) a_1 = ↑(algebraMap R S) a) } • x ∈
Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
⊢ { val := a, property := ha } • x ∈ Algebra.adjoin R ↑(finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s)
[PROOFSTEP]
simpa only [Submonoid.smul_def, algebraMap_smul] using e
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.OfLocalizationSpan @RingHom.FiniteType
[PROOFSTEP]
rw [RingHom.ofLocalizationSpan_iff_finite]
[GOAL]
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.OfLocalizationFiniteSpan @RingHom.FiniteType
[PROOFSTEP]
introv R hs H
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
⊢ RingHom.FiniteType f
[PROOFSTEP]
letI := f.toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this : Algebra R S := RingHom.toAlgebra f
⊢ RingHom.FiniteType f
[PROOFSTEP]
letI := fun r : s => (Localization.awayMap f r).toAlgebra
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
⊢ RingHom.FiniteType f
[PROOFSTEP]
have : ∀ r : s, IsLocalization ((Submonoid.powers (r : R)).map (algebraMap R S)) (Localization.Away (f r)) := by
intro r; rw [Submonoid.map_powers]; exact Localization.isLocalization
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
⊢ ∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
[PROOFSTEP]
intro r
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
r : { x // x ∈ s }
⊢ IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
[PROOFSTEP]
rw [Submonoid.map_powers]
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝ : Algebra R S := RingHom.toAlgebra f
this : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
r : { x // x ∈ s }
⊢ IsLocalization (Submonoid.powers (↑(algebraMap R S) ↑r)) (Localization.Away (↑f ↑r))
[PROOFSTEP]
exact Localization.isLocalization
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝¹ : Algebra R S := RingHom.toAlgebra f
this✝ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
⊢ RingHom.FiniteType f
[PROOFSTEP]
haveI : ∀ r : s, IsScalarTower R (Localization.Away (r : R)) (Localization.Away (f r)) := fun r =>
IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp (Submonoid.powers (r : R)).le_comap_map).symm
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
⊢ RingHom.FiniteType f
[PROOFSTEP]
constructor
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
H : ∀ (r : { x // x ∈ s }), RingHom.FiniteType (Localization.awayMap f ↑r)
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
⊢ Subalgebra.FG ⊤
[PROOFSTEP]
replace H := fun r => (H r).1
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
H : ∀ (r : { x // x ∈ s }), Subalgebra.FG ⊤
⊢ Subalgebra.FG ⊤
[PROOFSTEP]
choose s₁ s₂ using H
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
⊢ Subalgebra.FG ⊤
[PROOFSTEP]
let sf := fun x : s => IsLocalization.finsetIntegerMultiple (Submonoid.powers (f x)) (s₁ x)
[GOAL]
case out
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ Subalgebra.FG ⊤
[PROOFSTEP]
use s.attach.biUnion sf
[GOAL]
case h
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf) = ⊤
[PROOFSTEP]
convert (Algebra.adjoin_attach_biUnion (R := R) sf).trans _
[GOAL]
case h.convert_2
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ ⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x) = ⊤
[PROOFSTEP]
rw [eq_top_iff]
[GOAL]
case h.convert_2
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
⊢ ⊤ ≤ ⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x)
[PROOFSTEP]
rintro x -
[GOAL]
case h.convert_2
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
⊢ x ∈ ⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x)
[PROOFSTEP]
apply (⨆ x : s, Algebra.adjoin R (sf x : Set S)).toSubmodule.mem_of_span_eq_top_of_smul_pow_mem _ hs _ _
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
⊢ ∀ (r : ↑↑s), ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
intro r
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
⊢ ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
obtain ⟨⟨_, n₁, rfl⟩, hn₁⟩ :=
multiple_mem_adjoin_of_mem_localization_adjoin (Submonoid.powers (r : R)) (Localization.Away (r : R))
(s₁ r : Set (Localization.Away (f r))) (algebraMap S (Localization.Away (f r)) x) (by rw [s₂ r]; trivial)
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
⊢ ↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈ Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r)
[PROOFSTEP]
rw [s₂ r]
[GOAL]
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
⊢ ↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈ ⊤
[PROOFSTEP]
trivial
[GOAL]
case intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } •
↑(algebraMap S (Localization.Away (↑f ↑r))) x ∈
Algebra.adjoin R ↑(s₁ r)
⊢ ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
rw [Submonoid.smul_def, Algebra.smul_def, IsScalarTower.algebraMap_apply R S, ← map_mul] at hn₁
[GOAL]
case intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S)
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } *
x) ∈
Algebra.adjoin R ↑(s₁ r)
⊢ ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
obtain ⟨⟨_, n₂, rfl⟩, hn₂⟩ :=
IsLocalization.lift_mem_adjoin_finsetIntegerMultiple (Submonoid.powers (r : R)) _ (s₁ r) hn₁
[GOAL]
case intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S)
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } *
x) ∈
Algebra.adjoin R ↑(s₁ r)
n₂ : ℕ
hn₂ :
{ val := (fun x x_1 => x ^ x_1) (↑r) n₂,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₂) } •
(↑(algebraMap R S)
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } *
x) ∈
Algebra.adjoin R
↑(IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (s₁ r))
⊢ ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
rw [Submonoid.smul_def, ← Algebra.smul_def, smul_smul, Subtype.coe_mk, ← pow_add] at hn₂
[GOAL]
case intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S)
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } *
x) ∈
Algebra.adjoin R ↑(s₁ r)
n₂ : ℕ
hn₂ :
↑r ^ (n₂ + n₁) • x ∈
Algebra.adjoin R
↑(IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (s₁ r))
⊢ ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
simp_rw [Submonoid.map_powers] at hn₂
[GOAL]
case intro.mk.intro.intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S)
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } *
x) ∈
Algebra.adjoin R ↑(s₁ r)
n₂ : ℕ
hn₂ :
↑r ^ (n₂ + n₁) • x ∈
Algebra.adjoin R ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑(algebraMap R S) ↑r)) (s₁ r))
⊢ ∃ n, ↑r ^ n • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
use n₂ + n₁
[GOAL]
case h
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (↑f ↑r)) :=
fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
∀ (r : { x // x ∈ s }),
IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (↑f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (↑f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (↑f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Algebra.adjoin (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : (x : { x // x ∈ s }) → Finset ((fun x => S) ↑x) :=
fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
↑(algebraMap S (Localization.Away (↑f ↑r)))
(↑(algebraMap R S)
↑{ val := (fun x x_1 => x ^ x_1) (↑r) n₁,
property := (_ : ∃ y, (fun x x_1 => x ^ x_1) (↑r) y = (fun x x_1 => x ^ x_1) (↑r) n₁) } *
x) ∈
Algebra.adjoin R ↑(s₁ r)
n₂ : ℕ
hn₂ :
↑r ^ (n₂ + n₁) • x ∈
Algebra.adjoin R ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers (↑(algebraMap R S) ↑r)) (s₁ r))
⊢ ↑r ^ (n₂ + n₁) • x ∈ ↑Subalgebra.toSubmodule (⨆ (x : { x // x ∈ s }), Algebra.adjoin R ↑(sf x))
[PROOFSTEP]
exact le_iSup (fun x : s => Algebra.adjoin R (sf x : Set S)) r hn₂
|
using Pixell
using Test
import Pixell: degree, arcminute
using DelimitedFiles
include("test_geometry.jl") # creating geometries and sky ↔ pix
include("test_enmap.jl") # enmap features and manipulation
include("test_transforms.jl")
include("test_distance_transform.jl")
include("test_io.jl")
include("test_plot.jl")
|
Require Import Fiat.BinEncoders.NoEnv.Specs.
Set Implicit Arguments.
Definition bin_t := list bool.
Definition bin_encode_correct
(data_t : Type)
(encode : data_t -> bin_t)
(decode : bin_t -> data_t * bin_t) :=
forall data ext, decode (encode data ++ ext) = (data, ext).
Global Instance bin_encode_decoder
(data_t : Type)
(encode : data_t -> bin_t)
(decode : bin_t -> data_t * bin_t)
(encode_correct : bin_encode_correct encode decode)
: decoder (fun _ => True) encode :=
{ decode := fun bin => fst (decode bin) }.
Proof.
unfold encode_decode_correct.
intros data pred.
rewrite <- app_nil_r with (l:=encode data).
rewrite encode_correct; eauto.
Defined.
Definition bin_encode_transform_pair
(data_t : Type)
(encode : data_t -> bin_t) :=
fun bundle : data_t * bin_t => let (_data, _bin) := bundle
in encode _data ++ _bin.
Global Instance bin_encode_transform_pair_decoder
(data_t : Type)
(encode : data_t -> bin_t)
(decode : bin_t -> data_t * bin_t)
(encode_correct : bin_encode_correct encode decode)
: decoder (fun _ => True) (bin_encode_transform_pair encode) :=
{ decode := decode }.
Proof.
unfold encode_decode_correct, bin_encode_transform_pair.
intros [data bin] pred.
rewrite encode_correct; eauto.
Defined.
|
import PowerModelsACDC;
const _PMACDC = PowerModelsACDC;
import PowerModels;
const _PM = PowerModels;
import InfrastructureModels;
const _IM = InfrastructureModels;
import JuMP
import Gurobi
using MAT
using XLSX
using JLD2
using Statistics
include("basencont_nw.jl")
Total_sample = 1 # sample per year
total_yr = 1# the years in horizon, data coming from excels
Prot_system = "Permanentloss"
# Prot_system_coll = ["FS_HDCCB", "NS_CB", "Permanentloss"]
curtailed_gen = [1] #geneartor numbers # change also constraint max(), generating power,file name
syncarea = 2
max_curt = 0
# for proti = 1:3
# Prot_system = Prot_system_coll[proti]
file = "./test/data/4bus_OPF_PLdim.m"
data_sp = _PM.parse_file(file)
_PMACDC.process_additional_data!(data_sp)
include("bkgrnd_cal.jl")
gurobi = JuMP.optimizer_with_attributes(Gurobi.Optimizer, "Presolve" => -1)
no_nw = 2 * Total_sample*total_yr
data_mp = multi_network(file, no_nw)
# year = ["NAT_2050_Generation"]
yr = 1
data_cont, Cont_list, base_list = mp_contignecy_nocl_sensitivity(deepcopy(data_mp), Total_sample*total_yr, 1)
year_base = year_base_networks(Total_sample, total_yr, base_list)
conv_rate = Int(data_cont["nw"]["1"]["convdc"]["1"]["Pacmax"]*100)
Clearingtime = [0.15 0.3 0.45 0.6]
column = ["A" "B" "C" "D" "E" "F" "G" "H"]
filepath = string("C:\\Users\\djaykuma\\OneDrive - Energyville\\Freq_TNEP_paper\\MATLAB\\plots\\OPF\\4bus\\sensitivity\\",conv_rate,"_",Prot_system,".xlsx")
XLSX.openxlsx(filepath, mode="w") do xf
for i = 1:length(Clearingtime)
for (n,nw) in data_cont["nw"]
for (r,reserves) in nw["reserves"]
reserves["Tcl"] = Clearingtime[i]
end
end
if Prot_system == "FS_HDCCB" || Prot_system == "FS_MDCCB"
s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => true, "process_data_internally" => false, "FSprotection" => true, "NSprotection" => false,
"Permanentloss" => false, "Cont_list" => Cont_list,"base_list" => base_list,"Total_sample" =>Total_sample, "curtailed_gen" => curtailed_gen, "max_curt" => max_curt, "syncarea" => syncarea, "year_base" => year_base, "total_yr" => total_yr)
elseif Prot_system == "NS_CB" || Prot_system == "NS_FB"
s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => true, "process_data_internally" => false, "FSprotection" => false, "NSprotection" => true,
"Permanentloss" => false, "Cont_list" => Cont_list,"base_list" => base_list,"Total_sample" =>Total_sample, "curtailed_gen" => curtailed_gen, "max_curt" => max_curt, "syncarea" => syncarea, "year_base" => year_base, "total_yr" => total_yr)
else
s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => true, "process_data_internally" => false, "FSprotection" => false, "NSprotection" => false,
"Permanentloss" => true, "Cont_list" => Cont_list,"base_list" => base_list,"Total_sample" =>Total_sample, "curtailed_gen" => curtailed_gen, "max_curt" => max_curt, "syncarea" => syncarea, "year_base" => year_base, "total_yr" => total_yr)
end
@assert ( s["FSprotection"] == true && (Prot_system == "FS_HDCCB" || Prot_system == "FS_MDCCB") ) || (s["NSprotection"] == true && (Prot_system == "NS_CB" || Prot_system == "NS_FB"))|| (Prot_system == "Permanentloss" && s["NSprotection"] == false && s["FSprotection"] == false)
resultDC1 = _PMACDC.run_acdcscopf_sensitivity(data_cont, _PM.DCPPowerModel, gurobi, multinetwork=true; setting = s)
# curtail, maxFFR, maxFCR, meanFFR, meanFCR = curtailment(data_cont, base_list, resultDC1, curtailed_gen)
display_keyindictionary_OPF_PLdim(resultDC1, "isbuilt", "Pgg")
sheet = xf[1]
cell_no = string(column[i],i)
sheet["$(string(column[i],1))"] = data_cont["nw"]["1"]["reserves"]["2"]["Tcl"]
sheet["$(string(column[i],2))"] = resultDC1["solution"]["nw"]["1"]["FFR_Reserves"]
sheet["$(string(column[i],3))"] = resultDC1["solution"]["nw"]["1"]["FCR_Reserves"]
sheet["$(string(column[i],4))"] = resultDC1["solution"]["nw"]["1"]["Gen_cost"]
# sheet["$(string("A",5))"] = resultDC1["solution"]["nw"]["1"]["Cont"]
sheet["$(string(column[i],5))"] = mean(resultDC1["solution"]["nw"]["1"]["Curt"])
sheet["$(string(column[i],6))"] = resultDC1["objective"]
sheet["$(string(column[i],7))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["z1"]
sheet["$(string(column[i],8))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["z2"]
sheet["$(string(column[i],9))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["z3"]
sheet["$(string(column[i],10))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["z4"]
sheet["$(string(column[i],11))"] = resultDC1["solution"]["nw"]["1"]["branchdc"]["1"]["pf"]
sheet["$(string(column[i],12))"] = resultDC1["solution"]["nw"]["2"]["branchdc"]["1"]["pf"]
sheet["$(string(column[i],13))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k11_dup"]
sheet["$(string(column[i],14))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k12_dup"]
sheet["$(string(column[i],15))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k21_dup"]
sheet["$(string(column[i],16))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k22_dup"]
sheet["$(string(column[i],17))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k23_dup"]
sheet["$(string(column[i],18))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k31"]
sheet["$(string(column[i],19))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k32"]
sheet["$(string(column[i],20))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k33"]
sheet["$(string(column[i],21))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k31_dup"]
sheet["$(string(column[i],22))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k32_dup"]
sheet["$(string(column[i],23))"] = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["k43_dup"]
if round(Int64,resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["z3"]) == 1
t = nadir_time_t3(resultDC1, data_cont)
display("t3")
elseif round(Int64,resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["z4"]) == 1
t = nadir_time_t4(resultDC1, data_cont)
display("t4")
else
t = 500
end
sheet["$(string(column[i],24))"] = t
end
end
# end
function nadir_time_t3(resultDC1, data_cont)
Phvdcoaux = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Phvdcoaux"]
Phvdccaux = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Phvdccaux"]
display("Phvdcoaux:$Phvdcoaux")
display("Phvdccaux:$Phvdccaux")
Pg = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Pgg"]/data_cont["nw"]["1"]["load"]["1"]["pd"]
Pf = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Pff"]/data_cont["nw"]["1"]["load"]["1"]["pd"]
Tcl = data_cont["nw"]["1"]["reserves"]["2"]["Tcl"]
Td = data_cont["nw"]["1"]["reserves"]["2"]["Td"]
Tg = data_cont["nw"]["1"]["reserves"]["2"]["Tg"]
Tf = data_cont["nw"]["1"]["reserves"]["2"]["Tf"]
display("Pg:$Pg")
display("Pf:$Pf")
display(data_cont["nw"]["1"]["load"]["1"]["pd"])
t3 = (Phvdcoaux - Pf + Phvdccaux*Tcl/Td)/((Pg/Tg) + (Phvdccaux/Td))
display("t3:$t3")
return t3
end
function nadir_time_t4(resultDC1, data_cont)
Phvdcoaux = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Phvdcoaux"]
Phvdccaux = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Phvdccaux"]
display("Phvdcoaux:$Phvdcoaux")
display("Phvdccaux:$Phvdccaux")
Pg = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Pgg"]/data_cont["nw"]["1"]["load"]["1"]["pd"]
Pf = resultDC1["solution"]["nw"]["2"]["reserves"]["2"]["Pff"]/data_cont["nw"]["1"]["load"]["1"]["pd"]
Tcl = data_cont["nw"]["1"]["reserves"]["2"]["Tcl"]
Td = data_cont["nw"]["1"]["reserves"]["2"]["Td"]
Tg = data_cont["nw"]["1"]["reserves"]["2"]["Tg"]
Tf = data_cont["nw"]["1"]["reserves"]["2"]["Tf"]
display("Pg:$Pg")
display("Pf:$Pf")
display(data_cont["nw"]["1"]["load"]["1"]["pd"])
t4 = (Phvdcoaux - Phvdccaux - Pf)*Tg/Pg
display("t4:$t4")
return t4
end
|
module Mand where
import Data.List.Split
import Data.Scientific as Scientific
import Data.Complex
type CS = Complex Scientific
type S = Scientific
makeSci :: String -> String -> Scientific
makeSci a b = read (a ++ "e" ++ b) :: Scientific
csqrt :: (Floating a, RealFloat a) => Complex a -> Complex a
csqrt x = (m * cos (t) :+ m * sin(t))
where
p = polar x
m = sqrt $ fst p
t = (snd p)/2
--cubed_iteration c z = c + z * cos (z ** z)
cubed_iteration :: RealFloat a => Complex a -> Complex a -> Complex a
cubed_iteration c z = c + z * z * z
new_iteration :: RealFloat a => Complex a -> Complex a -> Complex a -> Complex a
new_iteration c n_z o_z = c + n_z * o_z
zzcosMask :: RealFloat a => Complex a -> Bool
zzcosMask (x :+y) = ((x > -0.95 && x < 0.1) && (y < 0.47 && y > -0.47)) || (( x <= -0.95 && x > -1.25) && (abs y < 0.42)) || (abs y < 0.2 && x <= -1.25 && x > -1.45) || (abs y < 0.4 && x >= 0.1 && x < 0.2) || (abs y < 0.17 && (x > 0.6 && x < 0.78)) || (abs y < 0.11 && x > 0.4 && x <= 0.85)
zzcos_iteration :: RealFloat a => Complex a -> Complex a -> Complex a
zzcos_iteration c z = c + z * z * (cos z)
mand_iteration :: RealFloat a => Complex a -> Complex a -> Complex a
mand_iteration c z = c + z*z
mand_pow_iteration :: RealFloat a => Int -> Complex a -> Complex a -> Complex a
mand_pow_iteration pow c z = c + z^pow
mand_iterationA :: CS -> CS -> CS
mand_iterationA (c:+b) (z:+x) = (c + z*z - x* x) :+ (b + 2*z*x)
cexp :: Floating a => Complex a -> Complex a
cexp (a :+ b) = (s * cos b :+ s * sin b)
where
s = exp a
csin :: RealFloat a => Complex a -> Complex a
csin x = ((realPart c1 + realPart c2)/2 :+ (imagPart c1 + imagPart c2)/2)
where
c1 = exp x
c2 = exp $ negate x
cpow :: RealFloat a => Complex a -> Complex a -> Complex a
cpow x y = cexp $ y * log x
mand :: (RealFloat a) => Either (Complex a) CS -> Int -> Int
mand (Left c) max = general mand_iteration (Just mandSive) c max
mand (Right c) _ = generalA mand_iterationA c
sciMagnitude :: Complex Scientific -> Scientific
sciMagnitude (a :+b) = a * a + b * b
mandSive :: RealFloat a => Complex a -> Bool
mandSive c@(x:+y) = ( let b = c + (1:+0) in realPart(b*(conjugate b)) < 0.05) ||((x < 0) && ( realPart (c * (conjugate c)) < 0.4)) ||(x < 0.25 && x >= 0 && abs y < 0.5) -- takes 16 seconds
--( let b = a + (1:+0) in realPart(b*(conjugate b)) < 0.05) ||((realPart a < 0) && ( realPart (a * (conjugate a)) < 0.4)) ||(realPart a < 0.25 && realPart a >= 0 && abs (imagPart a) < 0.5) = max -1 -- takes 16 seconds
general :: RealFloat a => (Complex a -> Complex a -> Complex a) -> Maybe (Complex a -> Bool) -> Complex a -> Int -> Int
general g Nothing a max = count_iterations 0 (0 :+ 0) a
where
count_iterations n e x
| n == max = max -1
| realPart (x * (conjugate x)) > 4 = n
| otherwise = count_iterations (n +1) e $ g a x
general g (Just sive) a max
-- | ((realPart a) < 0.25) && ((realPart a) > (-0.5)) && (abs (imagPart a) < 0.5) = 255 takes 21 secods
-- removed real check: (imagPart a == 0 && realPart a < 0.25 && realPart a > -2) ||
| sive a = max - 1
| otherwise = count_iterations 0 (0 :+ 0) a
where
count_iterations n e x
| n == max = max -1
| realPart (x * (conjugate x)) > 4 = n
| otherwise = count_iterations (n +1) e $ g a x
generalA :: (CS -> CS -> CS) -> CS -> Int
generalA g a = count_iterations 0 (0 :+ 0) a
where
count_iterations n e x
-- | n >= 255 = 255
| n >= 16581375 = 16581375
-- if using sci
-- | (sciMagnitude x ) > (makeSci "4" "0") = n
-- | otherwise = count_iterations (n + 1) e $ g a $ roundComplex x
-- if using float
| (realPart x)^2 + (imagPart x)^2 > 4 = n
| otherwise = count_iterations (n +1) e $ g a $ roundComplex x
general_list_R :: (Complex Scientific -> Complex Scientific -> Complex Scientific) -> Complex Scientific -> [Complex Scientific]
general_list_R g a = get_list 0 a (0 :+ 0)
where
get_list 1000 _ _ = []
get_list n (c :+d) (e :+ f)
| (sciMagnitude (e :+ f)) > (scientific 2 0) = []
| otherwise = (e:+f): (get_list (n +1) (c :+d) ( g (c :+ d) (roundComplex (e :+ f))))
-- takes 1:13 to do 1000 iterations using roundComplex
general_list :: (Complex Scientific -> Complex Scientific -> Complex Scientific) -> Complex Scientific -> [Complex Scientific]
general_list g (a :+ b) = get_list 0 (a :+ b) (0 :+ 0)
where
get_list 40 _ _ = []
get_list n (c :+d) (e :+ f)
| (sciMagnitude (e :+ f)) > (makeSci "2" "2") = []
| otherwise = (e:+f): (get_list (n +1) (c :+d) ( g (c :+ d) (e :+ f)))
general_list_D :: RealFloat a => (Complex a -> Complex a -> Complex a) -> Complex a -> [Complex a]
general_list_D g x = getlist 0 x (0 :+ 0)
where
getlist 1000 _ _ = []
getlist n c z
| realPart (z * conjugate z)> 4 = []
| otherwise = z: (getlist (n +1) c (g c z))
roundSci' :: Scientific -> Scientific
roundSci' s = makeSci (getSign:cut) getExp
where
num = splitOn "e" $ show s
removeSign = if s < 0 then tail (num !! 0) else (num !! 0)
getSign = if s < 0 then '-' else ' '
getExp = if (length num) == 1 then "0" else num !! 1
cut = take 100 removeSign
--rounds t 20 dp
roundSci :: Scientific -> Scientific
roundSci s
| d < 0 = s
| otherwise = scientific (div (coefficient s) (10^d)) $ d + base10Exponent s
where
d = (digitCount $ coefficient s) - 20
digitCount :: Integer -> Int
digitCount = go 1 . abs
where
go ds n = if n >= 10 then go (ds + 1) (n `div` 10) else ds
--(fromInteger $ round $ f * (10^n)) / (10.0^^n)
--Integer
roundComplex :: Complex Scientific -> Complex Scientific
roundComplex (a :+ b) = (roundSci' a :+ roundSci' b)
|
(* Title: Code_Target_Bits_Int.thy
Author: Andreas Lochbihler, ETH Zurich
*)
header {* Implementation of bit operations on int by target language operations *}
theory Code_Target_Bits_Int
imports
"Bits_Integer"
"~~/src/HOL/Library/Code_Target_Int"
begin
declare [[code drop:
"bitAND :: int \<Rightarrow> _" "bitOR :: int \<Rightarrow> _" "bitXOR :: int \<Rightarrow> _" "bitNOT :: int \<Rightarrow> _"
"lsb :: int \<Rightarrow> _" "set_bit :: int \<Rightarrow> _" "test_bit :: int \<Rightarrow> _"
"shiftl :: int \<Rightarrow> _" "shiftr :: int \<Rightarrow> _"
bin_last bin_rest bin_nth Bit
int_of_integer_symbolic
]]
context
includes integer.lifting
begin
lemma bitAND_int_code [code]:
"int_of_integer i AND int_of_integer j = int_of_integer (i AND j)"
by transfer simp
lemma bitOR_int_code [code]:
"int_of_integer i OR int_of_integer j = int_of_integer (i OR j)"
by transfer simp
lemma bitXOR_int_code [code]:
"int_of_integer i XOR int_of_integer j = int_of_integer (i XOR j)"
by transfer simp
lemma bitNOT_int_code [code]:
"NOT (int_of_integer i) = int_of_integer (NOT i)"
by transfer simp
declare bin_last_conv_AND [code]
lemma bin_rest_code [code]:
"bin_rest (int_of_integer i) = int_of_integer (bin_rest_integer i)"
by transfer simp
declare bitval_bin_last [code_unfold]
declare bin_nth_conv_AND [code]
lemma Bit_code [code]: "int_of_integer i BIT b = int_of_integer (Bit_integer i b)"
by transfer simp
lemma test_bit_int_code [code]: "int_of_integer x !! n = x !! n"
by transfer simp
lemma lsb_int_code [code]: "lsb (int_of_integer x) = lsb x"
by transfer simp
lemma set_bit_int_code [code]: "set_bit (int_of_integer x) n b = int_of_integer (set_bit x n b)"
by transfer simp
lemma shiftl_int_code [code]: "int_of_integer x << n = int_of_integer (x << n)"
by transfer simp
lemma shiftr_int_code [code]: "int_of_integer x >> n = int_of_integer (x >> n)"
by transfer simp
lemma int_of_integer_symbolic_code [code]:
"int_of_integer_symbolic = int_of_integer"
by(simp add: int_of_integer_symbolic_def)
end
code_identifier code_module Code_Target_Bits_Int \<rightharpoonup>
(SML) Bit_Int and (OCaml) Bit_Int and (Haskell) Bit_Int and (Scala) Bit_Int
end
|
import data.pnat.basic
-- El enunciado del IMO 1977 Q6 es el siguiente:
-- Sea `f : ℕ+ → ℕ+` tal que `f(f(n)) < f(n + 1)` para todo
-- `n`. Demostrar que `f(n) = n` para todo `n`.
theorem Extension
(f : ℕ → ℕ)
(h1 : ∀ n, f (f n) < f (n + 1))
: ∀ n, f n = n :=
begin
have h2: ∀ (k n : ℕ), k ≤ n → k ≤ f n,
{ intro k,
induction k with k h_ind,
{ intros n hn,
exact nat.zero_le (f n), },
{ intros n hk,
apply nat.succ_le_of_lt,
rw nat.succ_eq_add_one at hk,
have hk1: k ≤ n-1 := nat.le_sub_right_of_add_le hk,
have hk2: k ≤ f (n-1):= h_ind (n-1) hk1,
have hk3: k ≤ f(f(n-1)) := h_ind (f(n-1)) hk2,
have h11: f (f (n-1)) < f(n-1+1):= h1 (n-1),
rw nat.sub_add_cancel at h11,
{ calc k ≤ f(f(n-1)) : hk3
... < f(n) : h11,},
have hk0: 1 ≤ k+1 := nat.succ_le_succ (nat.zero_le k),
exact (le_trans hk0 hk), }},
have hf: ∀ n, n ≤ f n,
{ intro n,
apply h2 n n,
exact le_rfl, },
have mon: ∀ n, f n < f(n+1),
{ intro n,
exact lt_of_le_of_lt (hf (f n)) (h1 n), },
have f_mon: strict_mono f := strict_mono.nat mon,
intro n,
apply nat.eq_of_le_of_lt_succ (hf n),
exact (f_mon.lt_iff_lt.mp (h1 n)),
end
theorem imo1977_q62
(f : ℕ+ → ℕ+)
(h : ∀ n, f (f n) < f (n + 1))
: ∀ n, f n = n :=
begin
intro n,
simpa using Extension (λ m, if 0 < m then f m.to_pnat' else 0) _ n,
intro x,
cases x,
{ simp },
{ simpa using h _},
end
|
module ECC.Estimate (estimate,showEstimate) where
import ECC.Types
import qualified Data.Vector.Unboxed as U
import Statistics.Sample (mean)
import Statistics.Resampling (resample, fromResample, Estimator(..))
import Statistics.Resampling.Bootstrap (bootstrapBCA)
import Statistics.Types (Estimate (..), ConfInt, mkCL, ConfInt(..), confidenceLevel)
import System.Random.MWC (create)
import System.Random.MWC
import Numeric
-- Estimate the lower and upper bounds, given a random generator state,
-- a confidence percentage, and a Bit Errors structure.
-- If there are to many samples (as often happens with good error correcting codes),
-- then we cheat, and combine samples.
estimate :: GenIO -> Double -> MessageLength -> BEs -> IO (Maybe (Estimate ConfInt Double))
estimate g confidence m_len bes
| sumBEs bes == 0 = return Nothing
| otherwise =
-- 1000 is the default for criterion
do resamples <- resample g [Mean] 1000 sampleU
-- print $ U.length $ fromResample $ head $ resamples
-- print resamples
return $ Just $ head $ bootstrapBCA (mkCL confidence) sampleU {- [Mean] -} resamples
where
sample = map (\ be -> be / fromIntegral m_len)
$ extractBEs bes
sampleU = U.fromList sample
-- | Show estimate in an understandable format"
showEstimate :: Estimate ConfInt Double -> String
showEstimate est = showEFloat (Just 2) (estPoint est)
$ (" +" ++)
$ (if confIntLDX estErr == 0 then ("?" ++)
else showsPercent ((confIntUDX estErr) / (estPoint est)))
$ (" -" ++)
$ (if confIntUDX estErr == 0 then ("?" ++)
else showsPercent ((confIntLDX estErr) / (estPoint est)))
$ (" " ++)
$ showsPercent (confidenceLevel (confIntCL estErr))
$ ""
where
estErr = estError est
showsPercent f = shows (round (100 * f)) . ("%" ++)
-- (1 - (estLowerBound est) / (estPoint est))))
|
""" Tests for normality checks
Run at the project directory with:
nosetests code/utils/tests/test_normality.py
"""
from __future__ import absolute_import, division, print_function
import numpy as np
import os
import sys
from numpy.testing import assert_almost_equal, assert_array_equal
# Path to the subject 009 fMRI data used in class.
pathtoclassdata = "data/ds114/"
# Add path to functions to the system path.
sys.path.append(os.path.join(os.path.dirname(__file__), "../functions/"))
# Load our Normality functions
from normality import check_sw, check_sw_masked, check_kw
def test_normality():
# Generate some 4-d random uniform data.
# The first 3 dimensions are like voxels, the last like time.
np.random.seed(159)
sim_resids = np.random.rand(2, 2, 2, 200)
# Force one of the time courses to be standard normal.
sim_resids[0,0,0] = np.random.randn(200)
# Do Shaprio-Wilk.
sw_3d = check_sw(sim_resids) # 4-d residuals, 3-d p-values
sw_1d = check_sw_masked(sim_resids.reshape((-1, sim_resids.shape[-1]))) # 2-d residuals, 1-d p-values
# Do Kruskal-Wallis.
kw_3d = check_kw(sim_resids)
assert(sw_3d[0,0,0] > 0.05)
assert(sw_3d[1,0,0] < 0.05)
# Two Shaprio-Wilk functions should do the same thing over arrays of different dimensions.
assert(sw_3d[0,0,0] == sw_1d[0])
assert(kw_3d[0,0,0] > 0.05)
|
/-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import analysis.normed_space.multilinear
/-!
# Formal multilinear series
In this file we define `formal_multilinear_series 𝕜 E F` to be a family of `n`-multilinear maps for
all `n`, designed to model the sequence of derivatives of a function. In other files we use this
notion to define `C^n` functions (called `times_cont_diff` in `mathlib`) and analytic functions.
## Notations
We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.
## Tags
multilinear, formal series
-/
noncomputable theory
open set fin
open_locale topological_space
variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
{E : Type*} [normed_group E] [normed_space 𝕜 E]
{F : Type*} [normed_group F] [normed_space 𝕜 F]
{G : Type*} [normed_group G] [normed_space 𝕜 G]
/-- A formal multilinear series over a field `𝕜`, from `E` to `F`, is given by a family of
multilinear maps from `E^n` to `F` for all `n`. -/
@[derive add_comm_group]
def formal_multilinear_series
(𝕜 : Type*) [nondiscrete_normed_field 𝕜]
(E : Type*) [normed_group E] [normed_space 𝕜 E]
(F : Type*) [normed_group F] [normed_space 𝕜 F] :=
Π (n : ℕ), (E [×n]→L[𝕜] F)
instance : inhabited (formal_multilinear_series 𝕜 E F) := ⟨0⟩
section module
/- `derive` is not able to find the module structure, probably because Lean is confused by the
dependent types. We register it explicitly. -/
local attribute [reducible] formal_multilinear_series
instance : module 𝕜 (formal_multilinear_series 𝕜 E F) :=
begin
letI : ∀ n, module 𝕜 (continuous_multilinear_map 𝕜 (λ (i : fin n), E) F) :=
λ n, by apply_instance,
apply_instance
end
end module
namespace formal_multilinear_series
variables (p : formal_multilinear_series 𝕜 E F)
/-- Forgetting the zeroth term in a formal multilinear series, and interpreting the following terms
as multilinear maps into `E →L[𝕜] F`. If `p` corresponds to the Taylor series of a function, then
`p.shift` is the Taylor series of the derivative of the function. -/
def shift : formal_multilinear_series 𝕜 E (E →L[𝕜] F) :=
λn, (p n.succ).curry_right
/-- Adding a zeroth term to a formal multilinear series taking values in `E →L[𝕜] F`. This
corresponds to starting from a Taylor series for the derivative of a function, and building a Taylor
series for the function itself. -/
def unshift (q : formal_multilinear_series 𝕜 E (E →L[𝕜] F)) (z : F) :
formal_multilinear_series 𝕜 E F
| 0 := (continuous_multilinear_curry_fin0 𝕜 E F).symm z
| (n + 1) := continuous_multilinear_curry_right_equiv' 𝕜 n E F (q n)
/-- Killing the zeroth coefficient in a formal multilinear series -/
def remove_zero (p : formal_multilinear_series 𝕜 E F) : formal_multilinear_series 𝕜 E F
| 0 := 0
| (n + 1) := p (n + 1)
@[simp] lemma remove_zero_coeff_zero : p.remove_zero 0 = 0 := rfl
@[simp] lemma remove_zero_coeff_succ (n : ℕ) : p.remove_zero (n+1) = p (n+1) := rfl
lemma remove_zero_of_pos {n : ℕ} (h : 0 < n) : p.remove_zero n = p n :=
by { rw ← nat.succ_pred_eq_of_pos h, refl }
/-- Convenience congruence lemma stating in a dependent setting that, if the arguments to a formal
multilinear series are equal, then the values are also equal. -/
lemma congr (p : formal_multilinear_series 𝕜 E F) {m n : ℕ} {v : fin m → E} {w : fin n → E}
(h1 : m = n) (h2 : ∀ (i : ℕ) (him : i < m) (hin : i < n), v ⟨i, him⟩ = w ⟨i, hin⟩) :
p m v = p n w :=
by { cases h1, congr' with ⟨i, hi⟩, exact h2 i hi hi }
/-- Composing each term `pₙ` in a formal multilinear series with `(u, ..., u)` where `u` is a fixed
continuous linear map, gives a new formal multilinear series `p.comp_continuous_linear_map u`. -/
def comp_continuous_linear_map (p : formal_multilinear_series 𝕜 F G) (u : E →L[𝕜] F) :
formal_multilinear_series 𝕜 E G :=
λ n, (p n).comp_continuous_linear_map (λ (i : fin n), u)
@[simp] lemma comp_continuous_linear_map_apply
(p : formal_multilinear_series 𝕜 F G) (u : E →L[𝕜] F) (n : ℕ) (v : fin n → E) :
(p.comp_continuous_linear_map u) n v = p n (u ∘ v) := rfl
variables (𝕜) {𝕜' : Type*} [nondiscrete_normed_field 𝕜'] [normed_algebra 𝕜 𝕜']
variables [normed_space 𝕜' E] [is_scalar_tower 𝕜 𝕜' E]
variables [normed_space 𝕜' F] [is_scalar_tower 𝕜 𝕜' F]
/-- Reinterpret a formal `𝕜'`-multilinear series as a formal `𝕜`-multilinear series, where `𝕜'` is a
normed algebra over `𝕜`. -/
@[simp] protected def restrict_scalars (p : formal_multilinear_series 𝕜' E F) :
formal_multilinear_series 𝕜 E F :=
λ n, (p n).restrict_scalars 𝕜
end formal_multilinear_series
|
Formal statement is: lemma dist_add_cancel2 [simp]: "dist (b + a) (c + a) = dist b c" Informal statement is: The distance between $b + a$ and $c + a$ is the same as the distance between $b$ and $c$. |
module TwoMoon.Load where
import Neural
import Numeric.LinearAlgebra
-- Parse two-moon dataset into a list of examples (pairs of a list of feature and a list of labels)
loadExamples :: IO [Example]
loadExamples = do
twomoon <- loadMatrix "data/two_moon.txt"
let x = vector `map` toLists (twomoon ¿ [0, 1])
let gt = mkOneHot `map` toList (flatten (twomoon ¿ [2]))
return $ zip x gt
where
mkOneHot :: Double -> Vector Double
mkOneHot x = if x == 0.0 then vector [1.0, 0.0] else vector [0.0, 1.0]
|
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wwarn #-}
module Data.Distribution
( ToRealFrac(..)
, Distribution(..)
, computeDistribution
, computeDistributionStats
, mapToDistribution
, zeroDistribution
, dPercIx
, dPercSpec
, dPercSpec'
, PercSpec(..)
, renderPercSpec
, Percentile(..)
, pctFrac
, stdPercentiles
-- Aux
, spans
) where
import Prelude (String, (!!), error, head, last, show)
import Cardano.Prelude hiding (head, show)
import Control.Arrow
import Data.Aeson (FromJSON(..), ToJSON(..))
import Data.Foldable qualified as F
import Data.List (span)
import Data.Vector (Vector)
import Data.Vector qualified as Vec
import Statistics.Sample qualified as Stat
import Text.Printf (PrintfArg, printf)
data Distribution a b =
Distribution
{ dSize :: Int
, dAverage :: a
, dPercentiles :: [Percentile a b]
}
deriving (Functor, Generic, Show)
instance (FromJSON a, FromJSON b) => FromJSON (Distribution a b)
instance ( ToJSON a, ToJSON b) => ToJSON (Distribution a b)
newtype PercSpec a = Perc { psFrac :: a } deriving (Eq, Generic, Show)
instance (FromJSON a) => FromJSON (PercSpec a)
instance ( ToJSON a) => ToJSON (PercSpec a)
dPercIx :: Int -> Distribution a b -> b
dPercIx i d = pctSample $ dPercentiles d !! i
dPercSpec :: Eq (PercSpec a) => PercSpec a -> Distribution a b -> Maybe b
dPercSpec p = fmap pctSample . find ((== p) . pctSpec) . dPercentiles
dPercSpec' :: (Show a, Eq (PercSpec a)) => String -> PercSpec a -> Distribution a b -> b
dPercSpec' desc p =
maybe (error er) pctSample . find ((== p) . pctSpec) . dPercentiles
where
er = printf "Missing centile %f in %s" (show $ psFrac p) desc
renderPercSpec :: PrintfArg a => Int -> PercSpec a -> String
renderPercSpec width = \case
Perc x -> printf ("%0."<>show (width-2)<>"f") x
data Percentile a b =
Percentile
{ pctSpec :: !(PercSpec a)
, pctSample :: !b
}
deriving (Functor, Generic, Show)
instance (FromJSON a, FromJSON b) => FromJSON (Percentile a b)
instance ( ToJSON a, ToJSON b) => ToJSON (Percentile a b)
pctFrac :: Percentile a b -> a
pctFrac = psFrac . pctSpec
stdPercentiles :: [PercSpec Float]
stdPercentiles =
[ Perc 0.01, Perc 0.05
, Perc 0.1, Perc 0.2, Perc 0.3, Perc 0.4
, Perc 0.5, Perc 0.6
, Perc 0.7, Perc 0.75
, Perc 0.8, Perc 0.85, Perc 0.875
, Perc 0.9, Perc 0.925, Perc 0.95, Perc 0.97, Perc 0.98, Perc 0.99
, Perc 0.995, Perc 0.997, Perc 0.998, Perc 0.999
, Perc 0.9995, Perc 0.9997, Perc 0.9998, Perc 0.9999
]
zeroDistribution :: Num a => Distribution a b
zeroDistribution =
Distribution
{ dSize = 0
, dAverage = 0
, dPercentiles = mempty
}
-- | For a list of distributions, compute a distribution of averages and rel stddev
-- (aka. coefficient of variance).
computeDistributionStats ::
forall a v
. ( v ~ Double -- 'v' is fixed by Stat.stdDev
, Num a
)
=> String -> [Distribution a v]
-> Either String (Distribution a v, Distribution a v)
computeDistributionStats desc xs = do
when (null xs) $
Left $ "Empty list of distributions in " <> desc
let distPcts = dPercentiles <$> xs
pctDistVals = transpose distPcts
unless (all (pctLen ==) (length <$> distPcts)) $
Left ("Distributions with different percentile counts: " <> show (length <$> distPcts) <> " in " <> desc)
pure $ (join (***) (Distribution (length xs) 0)
:: ([Percentile a v], [Percentile a v]) -> (Distribution a v, Distribution a v))
$ unzip (pctsMeanCoV <$> pctDistVals)
where
pctLen = length . dPercentiles $ head xs
pctsMeanCoV :: [Percentile a v] -> (Percentile a v, Percentile a v)
pctsMeanCoV xs' = join (***) (Percentile . pctSpec $ head xs')
(mean, Stat.stdDev vec / mean)
where
vec = Vec.fromList $ pctSample <$> xs'
mean = Stat.mean vec
mapToDistribution :: (Real v, ToRealFrac v a) => (b -> v) -> [PercSpec a] -> [b] -> Distribution a v
mapToDistribution f pspecs xs = computeDistribution pspecs (f <$> xs)
computeDistribution :: (Real v, ToRealFrac v a) => [PercSpec a] -> [v] -> Distribution a v
computeDistribution percentiles (sort -> sorted) =
Distribution
{ dSize = size
, dAverage = toRealFrac (F.sum sorted) / fromIntegral (size `max` 1)
, dPercentiles =
(Percentile (Perc 0) mini:) .
(<> [Percentile (Perc 1.0) maxi]) $
percentiles <&>
\spec ->
let sample = if size == 0
then 0
else sorted !! indexAtFrac (psFrac spec)
in Percentile spec sample
}
where size = length sorted
indexAtFrac f = floor (fromIntegral (size - 1) * f)
(,) mini maxi =
if size == 0
then (0, 0)
else (head sorted, last sorted)
class RealFrac b => ToRealFrac a b where
toRealFrac :: a -> b
instance RealFrac b => ToRealFrac Int b where
toRealFrac = fromIntegral
instance {-# OVERLAPPABLE #-} (RealFrac b, Real a) => ToRealFrac a b where
toRealFrac = realToFrac
spans :: forall a. (a -> Bool) -> [a] -> [Vector a]
spans f = go []
where
go :: [Vector a] -> [a] -> [Vector a]
go acc [] = reverse acc
go acc xs =
case span f $ dropWhile (not . f) xs of
([], rest) -> go acc rest
(ac, rest) ->
go (Vec.fromList ac:acc) rest
|
theory Prelude_Composition
imports "$HETS_LIB/Isabelle/MainHCPairs"
uses "$HETS_LIB/Isabelle/prelude"
begin
ML "Header.initialize [\"Comp\", \"Comp1\"]"
consts
X__o__X :: "('b => 'c) * ('a => 'b) => 'a => 'c"
axioms
Comp [rule_format] :
"ALL f.
ALL g. makePartial o X__o__X (f, g) = makePartial o (% x. f (g x))"
theorem Comp1 : "ALL f. ALL g. ALL y. X__o__X (f, g) y = f (g y)"
apply(auto)
thm Comp
apply(rule Comp)
by auto
ML "Header.record \"Comp1\""
end
|
lemma smallo_powr: fixes f :: "'a \<Rightarrow> real" assumes "f \<in> o[F](g)" "p > 0" shows "(\<lambda>x. \<bar>f x\<bar> powr p) \<in> o[F](\<lambda>x. \<bar>g x\<bar> powr p)" |
function [yinterp,ypinterp] = ntrp1210(tinterp,t,y,tnew,ynew,klast,phi,psi,idxNonNegative)
%NTRP1210 Interpolation helper function for RKN1210.
%
% YINTERP = NTRP1210(TINTERP,T,Y,TNEW,YNEW,KLAST,PHI,PSI,IDX) uses data
% computed in RKN1210 to approximate the solution at time TINTERP. TINTERP
% may be a scalar or a row vector.
%
% [YINTERP,YPINTERP] = NTRP1210(TINTERP,T,Y,TNEW,YNEW,KLAST,PHI,PSI,IDX)
% returns also the derivative of the polynomial approximating the solution.
%
% IDX has indices of solution components that must be non-negative. Negative
% YINTERP(IDX) are replaced with zeros and the derivative YPINTERP(IDX) is
% set to zero.
%
% See also RKN1210, DEVAL.
% References;
% [1] "Interpolating Runge-Kutta-Nyström Methods of High Order", C.
% Tsitouras, G. Papageorgiou, Intern. J. Computer Math., vol 47,
% pp. 209-217 (1993).
% Please report bugs and inquiries to:
%
% Name : Rody P.S. Oldenhuis
% E-mail : [email protected]
% Licence : 2-clause BSD (See Licence.txt)
% If you find this work useful, please consider a donation:
% https://www.paypal.me/RodyO/3.5
% TODO: make magic happen here
end
|
[STATEMENT]
lemma find_closest_pair_code_dist_eq:
assumes "\<delta> = dist_code c\<^sub>0 c\<^sub>1" "(\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) ps"
shows "\<Delta> = dist_code C\<^sub>0 C\<^sub>1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<delta> = dist_code c\<^sub>0 c\<^sub>1
(\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) ps
goal (1 subgoal):
1. \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
proof (induction "(\<delta>, c\<^sub>0, c\<^sub>1)" ps arbitrary: \<delta> c\<^sub>0 c\<^sub>1 \<Delta> C\<^sub>0 C\<^sub>1 rule: find_closest_pair_code.induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. \<And>\<delta> c\<^sub>0 c\<^sub>1 \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) []\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<And>\<delta> c\<^sub>0 c\<^sub>1 p \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) [p]\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
3. \<And>\<delta> c\<^sub>0 c\<^sub>1 p\<^sub>0 v va \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<delta> \<le> xa; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<not> \<delta> \<le> xa; xa = dist_code p\<^sub>0 y; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (xa, p\<^sub>0, y) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
case (3 \<delta> c\<^sub>0 c\<^sub>1 p\<^sub>0 p\<^sub>2 ps)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps)); (?xa, ?y) = ?x; \<delta> \<le> ?xa; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (?\<Delta>, ?C\<^sub>0, ?C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> ?\<Delta> = dist_code ?C\<^sub>0 ?C\<^sub>1
\<lbrakk>?x = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps)); (?xa, ?y) = ?x; \<not> \<delta> \<le> ?xa; ?xa = dist_code p\<^sub>0 ?y; (?\<Delta>, ?C\<^sub>0, ?C\<^sub>1) = find_closest_pair_code (?xa, p\<^sub>0, ?y) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> ?\<Delta> = dist_code ?C\<^sub>0 ?C\<^sub>1
\<delta> = dist_code c\<^sub>0 c\<^sub>1
(\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # p\<^sub>2 # ps)
goal (3 subgoals):
1. \<And>\<delta> c\<^sub>0 c\<^sub>1 \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) []\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<And>\<delta> c\<^sub>0 c\<^sub>1 p \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) [p]\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
3. \<And>\<delta> c\<^sub>0 c\<^sub>1 p\<^sub>0 v va \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<delta> \<le> xa; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<not> \<delta> \<le> xa; xa = dist_code p\<^sub>0 y; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (xa, p\<^sub>0, y) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
obtain \<delta>' p\<^sub>1 where \<delta>'_def: "(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>\<delta>' p\<^sub>1. (\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis surj_pair)
[PROOF STATE]
proof (state)
this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
goal (3 subgoals):
1. \<And>\<delta> c\<^sub>0 c\<^sub>1 \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) []\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<And>\<delta> c\<^sub>0 c\<^sub>1 p \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) [p]\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
3. \<And>\<delta> c\<^sub>0 c\<^sub>1 p\<^sub>0 v va \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<delta> \<le> xa; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<not> \<delta> \<le> xa; xa = dist_code p\<^sub>0 y; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (xa, p\<^sub>0, y) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
hence A: "\<delta>' = dist_code p\<^sub>0 p\<^sub>1"
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
goal (1 subgoal):
1. \<delta>' = dist_code p\<^sub>0 p\<^sub>1
[PROOF STEP]
using find_closest_bf_code_dist_eq[of "take 7 (p\<^sub>2 # ps)"]
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
\<lbrakk>0 < length (take 7 (p\<^sub>2 # ps)); (?\<delta>, ?c) = find_closest_bf_code ?p (take 7 (p\<^sub>2 # ps))\<rbrakk> \<Longrightarrow> ?\<delta> = dist_code ?p ?c
goal (1 subgoal):
1. \<delta>' = dist_code p\<^sub>0 p\<^sub>1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<delta>' = dist_code p\<^sub>0 p\<^sub>1
goal (3 subgoals):
1. \<And>\<delta> c\<^sub>0 c\<^sub>1 \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) []\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<And>\<delta> c\<^sub>0 c\<^sub>1 p \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) [p]\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
3. \<And>\<delta> c\<^sub>0 c\<^sub>1 p\<^sub>0 v va \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<delta> \<le> xa; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<And>x xa y \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>x = find_closest_bf_code p\<^sub>0 (take 7 (v # va)); (xa, y) = x; \<not> \<delta> \<le> xa; xa = dist_code p\<^sub>0 y; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (xa, p\<^sub>0, y) (v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # v # va)\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
proof (cases "\<delta> \<le> \<delta>'")
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
\<delta> \<le> \<delta>'
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
obtain \<Delta>' C\<^sub>0' C\<^sub>1' where \<Delta>'_def: "(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>\<Delta>' C\<^sub>0' C\<^sub>1'. (\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis prod_cases4)
[PROOF STATE]
proof (state)
this:
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
note defs = \<delta>'_def \<Delta>'_def
[PROOF STATE]
proof (state)
this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
hence "\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'"
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)
goal (1 subgoal):
1. \<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
[PROOF STEP]
using "3.hyps"(1)[of "(\<delta>', p\<^sub>1)" \<delta>' p\<^sub>1] "3.prems"(1) True \<delta>'_def
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)
\<lbrakk>(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps)); (\<delta>', p\<^sub>1) = (\<delta>', p\<^sub>1); \<delta> \<le> \<delta>'; \<delta> = dist_code c\<^sub>0 c\<^sub>1; (?\<Delta>, ?C\<^sub>0, ?C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> ?\<Delta> = dist_code ?C\<^sub>0 ?C\<^sub>1
\<delta> = dist_code c\<^sub>0 c\<^sub>1
\<delta> \<le> \<delta>'
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
goal (1 subgoal):
1. \<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
have "\<Delta> = \<Delta>'" "C\<^sub>0 = C\<^sub>0'" "C\<^sub>1 = C\<^sub>1'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<Delta> = \<Delta>' &&& C\<^sub>0 = C\<^sub>0' &&& C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
using defs True "3.prems"(2)
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)
\<delta> \<le> \<delta>'
(\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # p\<^sub>2 # ps)
goal (1 subgoal):
1. \<Delta> = \<Delta>' &&& C\<^sub>0 = C\<^sub>0' &&& C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
apply (auto split: prod.splits)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
1. \<lbrakk>(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps); \<delta> \<le> \<delta>'; find_closest_bf_code p\<^sub>0 (p\<^sub>2 # take 6 ps) = (\<delta>', p\<^sub>1); (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> \<Delta> = \<Delta>'
2. \<lbrakk>(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps); \<delta> \<le> \<delta>'; find_closest_bf_code p\<^sub>0 (p\<^sub>2 # take 6 ps) = (\<delta>', p\<^sub>1); (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> C\<^sub>0 = C\<^sub>0'
3. \<lbrakk>(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps); \<delta> \<le> \<delta>'; find_closest_bf_code p\<^sub>0 (p\<^sub>2 # take 6 ps) = (\<delta>', p\<^sub>1); (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
by (metis Pair_inject)+
[PROOF STATE]
proof (state)
this:
\<Delta> = \<Delta>'
C\<^sub>0 = C\<^sub>0'
C\<^sub>1 = C\<^sub>1'
goal (2 subgoals):
1. \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
\<Delta> = \<Delta>'
C\<^sub>0 = C\<^sub>0'
C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
\<Delta> = \<Delta>'
C\<^sub>0 = C\<^sub>0'
C\<^sub>1 = C\<^sub>1'
goal (1 subgoal):
1. \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Delta> = dist_code C\<^sub>0 C\<^sub>1
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> \<delta> \<le> \<delta>'
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
obtain \<Delta>' C\<^sub>0' C\<^sub>1' where \<Delta>'_def: "(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>\<Delta>' C\<^sub>0' C\<^sub>1'. (\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis prod_cases4)
[PROOF STATE]
proof (state)
this:
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
note defs = \<delta>'_def \<Delta>'_def
[PROOF STATE]
proof (state)
this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
hence "\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'"
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)
goal (1 subgoal):
1. \<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
[PROOF STEP]
using "3.hyps"(2)[of "(\<delta>', p\<^sub>1)" \<delta>' p\<^sub>1] A False \<delta>'_def
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)
\<lbrakk>(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps)); (\<delta>', p\<^sub>1) = (\<delta>', p\<^sub>1); \<not> \<delta> \<le> \<delta>'; \<delta>' = dist_code p\<^sub>0 p\<^sub>1; (?\<Delta>, ?C\<^sub>0, ?C\<^sub>1) = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> ?\<Delta> = dist_code ?C\<^sub>0 ?C\<^sub>1
\<delta>' = dist_code p\<^sub>0 p\<^sub>1
\<not> \<delta> \<le> \<delta>'
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
goal (1 subgoal):
1. \<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
have "\<Delta> = \<Delta>'" "C\<^sub>0 = C\<^sub>0'" "C\<^sub>1 = C\<^sub>1'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<Delta> = \<Delta>' &&& C\<^sub>0 = C\<^sub>0' &&& C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
using defs False "3.prems"(2)
[PROOF STATE]
proof (prove)
using this:
(\<delta>', p\<^sub>1) = find_closest_bf_code p\<^sub>0 (take 7 (p\<^sub>2 # ps))
(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)
\<not> \<delta> \<le> \<delta>'
(\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) (p\<^sub>0 # p\<^sub>2 # ps)
goal (1 subgoal):
1. \<Delta> = \<Delta>' &&& C\<^sub>0 = C\<^sub>0' &&& C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
apply (auto split: prod.splits)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
1. \<lbrakk>(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps); \<not> \<delta> \<le> \<delta>'; find_closest_bf_code p\<^sub>0 (p\<^sub>2 # take 6 ps) = (\<delta>', p\<^sub>1); (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> \<Delta> = \<Delta>'
2. \<lbrakk>(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps); \<not> \<delta> \<le> \<delta>'; find_closest_bf_code p\<^sub>0 (p\<^sub>2 # take 6 ps) = (\<delta>', p\<^sub>1); (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> C\<^sub>0 = C\<^sub>0'
3. \<lbrakk>(\<Delta>', C\<^sub>0', C\<^sub>1') = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps); \<not> \<delta> \<le> \<delta>'; find_closest_bf_code p\<^sub>0 (p\<^sub>2 # take 6 ps) = (\<delta>', p\<^sub>1); (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>', p\<^sub>0, p\<^sub>1) (p\<^sub>2 # ps)\<rbrakk> \<Longrightarrow> C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
by (metis Pair_inject)+
[PROOF STATE]
proof (state)
this:
\<Delta> = \<Delta>'
C\<^sub>0 = C\<^sub>0'
C\<^sub>1 = C\<^sub>1'
goal (1 subgoal):
1. \<not> \<delta> \<le> \<delta>' \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
\<Delta> = \<Delta>'
C\<^sub>0 = C\<^sub>0'
C\<^sub>1 = C\<^sub>1'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Delta>' = dist_code C\<^sub>0' C\<^sub>1'
\<Delta> = \<Delta>'
C\<^sub>0 = C\<^sub>0'
C\<^sub>1 = C\<^sub>1'
goal (1 subgoal):
1. \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Delta> = dist_code C\<^sub>0 C\<^sub>1
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<Delta> = dist_code C\<^sub>0 C\<^sub>1
goal (2 subgoals):
1. \<And>\<delta> c\<^sub>0 c\<^sub>1 \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) []\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
2. \<And>\<delta> c\<^sub>0 c\<^sub>1 p \<Delta> C\<^sub>0 C\<^sub>1. \<lbrakk>\<delta> = dist_code c\<^sub>0 c\<^sub>1; (\<Delta>, C\<^sub>0, C\<^sub>1) = find_closest_pair_code (\<delta>, c\<^sub>0, c\<^sub>1) [p]\<rbrakk> \<Longrightarrow> \<Delta> = dist_code C\<^sub>0 C\<^sub>1
[PROOF STEP]
qed auto |
SUBROUTINE ZSPDI (IFLTAB, CPATH, NORD, NCURVE, IHORIZ,
* C1UNIT, C1TYPE, C2UNIT, C2TYPE, SVALUES, DVALUES,
* LDOUBLE, CLABEL, LABEL, IUHEAD, NUHEAD, IPLAN, ISTAT)
C
implicit none
C
C Internal Store Paired DATA
C
INTEGER IFLTAB(*), IUHEAD(*),zdssVersion
CHARACTER CPATH*(*), CLABEL(*)*(*)
CHARACTER C1UNIT*(*), C1TYPE*(*), C2UNIT*(*), C2TYPE*(*)
REAL SVALUES(*)
DOUBLE PRECISION DVALUES(*)
LOGICAL LABEL, LDOUBLE
INTEGER NORD, NCURVE, IHORIZ, IPLAN, NUHEAD, ISTAT
C
C
IF (zdssVersion(IFLTAB).EQ.6) THEN
CALL ZSPDI6 (IFLTAB, CPATH, NORD, NCURVE, IHORIZ,
* C1UNIT, C1TYPE, C2UNIT, C2TYPE, SVALUES, DVALUES,
* LDOUBLE, CLABEL, LABEL, IUHEAD, NUHEAD, IPLAN, ISTAT)
ELSE
if (LDOUBLE) then
CALL ZSPDI7 (IFLTAB, CPATH, NORD, NCURVE, IHORIZ,
* C1UNIT, C1TYPE, C2UNIT, C2TYPE, SVALUES, DVALUES,
* LDOUBLE, CLABEL, LABEL, IUHEAD, NUHEAD, IPLAN, ISTAT)
else
CALL ZSPDI7 (IFLTAB, CPATH, NORD, NCURVE, IHORIZ,
* C1UNIT, C1TYPE, C2UNIT, C2TYPE, SVALUES, DVALUES,
* LDOUBLE, CLABEL, LABEL, IUHEAD, NUHEAD, IPLAN, ISTAT)
endif
ENDIF
C
RETURN
END
|
(* http://www.cse.chalmers.se/research/group/logic/TypesSS05/resources/coq/CoqArt/contents.html *)
(* Chapter 3 *)
(* Section 3.1 *)
Require Import Arith.
Require Import ZArith.
Require Import Bool.
Section Minimal_propositional_logic.
Variables P Q R T : Prop.
Theorem imp_trans_auto : (P -> Q) -> (Q -> R) -> P -> R.
Proof.
auto.
Qed.
Theorem imp_trans : (P -> Q) -> (Q -> R) -> P -> R.
Proof.
intros H H' p.
apply H'.
apply H.
exact p.
Qed.
Print imp_trans_auto.
Print imp_trans.
(* Section 3.2 *)
Section example_of_assumption.
Hypothesis H : P -> Q -> R.
Lemma L1 : P -> Q -> R.
Proof.
assumption.
Qed.
End example_of_assumption.
Theorem delta : (P -> P -> Q) -> P -> Q.
Proof.
exact (fun (H : P -> P -> Q) (p:P) => H p p).
Qed.
Theorem delta2 : (P -> P -> Q) -> P -> Q.
Proof (fun (H : P -> P -> Q) (p:P) => H p p).
Theorem apply_example : (Q -> R -> T) -> (P -> Q) -> P -> R -> T.
Proof.
intros H H0 p.
apply H.
exact (H0 p).
Qed.
Theorem imp_dist_auto : (P -> Q -> R) -> (P -> Q) -> (P -> R).
Proof.
auto.
Qed.
Print imp_dist_auto.
Theorem imp_dist : (P -> Q -> R) -> (P -> Q) -> (P -> R).
Proof.
intros H H' p.
apply H.
- exact p.
- exact (H' p).
Qed.
Theorem K : P -> Q -> P.
Proof.
intros p q.
exact p.
Qed.
(* Section 3.3 *)
(* Exercise 3.2 *)
Lemma id_P : P -> P.
Proof.
intro p.
exact p.
Qed.
Lemma id_PP : (P -> P) -> (P -> P).
Proof.
intro p.
exact p.
Qed.
Lemma imp_trans' : (P -> Q) -> (Q -> R) -> P -> R.
Proof.
intros Hpq Hqr p.
apply Hqr.
apply Hpq.
exact p.
Qed.
Lemma imp_perm : (P -> Q -> R) -> (Q -> P -> R).
Proof.
intros Hpqr q p.
apply Hpqr.
- exact p.
- exact q.
Qed.
Lemma ignore_Q : (P -> R) -> P -> Q -> R.
Proof.
intros Hpr p q.
apply Hpr.
exact p.
Qed.
Lemma delta_imp : (P -> P -> Q) -> P -> Q.
Proof.
intros Hppq p.
apply Hppq.
- exact p.
- exact p.
Qed.
Lemma delta_impR : (P -> Q) -> (P -> P -> Q).
Proof.
intros Hpq p1 p2.
apply Hpq.
exact p1.
Qed.
Lemma diamond : (P -> Q) -> (P -> R) -> (Q -> R -> T) -> P -> T.
Proof.
intros Hpq Hpr Hqrt p.
apply Hqrt.
- apply Hpq.
exact p.
- apply Hpr.
exact p.
Qed.
Lemma weak_peirce : ((((P -> Q) -> P) -> P) -> Q) -> Q.
Proof.
intro H0.
apply H0.
intro H1.
apply H1.
intro p.
apply H0.
intro H2.
exact p.
Qed.
(* Section 3.4*)
Definition unreliable : (nat -> bool) -> (nat -> bool) -> nat -> bool.
intros f1 f2.
assumption.
Defined.
Print unreliable.
Eval compute in (unreliable (fun n => true) (fun n => false) 45).
Opaque unreliable.
Eval compute in (unreliable (fun n => true) (fun n => false) 45).
(* Section 3.5 *)
Section proof_of_triple_impl.
Hypothesis H : ((P -> Q) -> Q) -> Q.
Hypothesis p : P.
Lemma Rem : (P -> Q) -> Q.
Proof (fun H0 : P -> Q => H0 p).
Theorem triple_impl : Q.
Proof (H Rem).
End proof_of_triple_impl.
Print Rem.
Print triple_impl.
(* Section 3.6 *)
Theorem then_example : P -> Q -> (P -> Q -> R) -> R.
Proof.
intros p q Hpq.
apply Hpq; assumption.
Qed.
Theorem triple_impl_one_go : (((P -> Q) -> Q) -> Q) -> P -> Q.
Proof.
intros H p; apply H; intro H0; apply H0; assumption.
Qed.
Theorem compose_example : (P -> Q -> R) -> (P -> Q) -> P -> R.
Proof.
intros Hpqr Hpq p.
apply Hpqr; [assumption | apply Hpq; assumption].
Qed.
Theorem orelse_example : (P -> Q) -> R -> ((P -> Q) -> R -> (T -> Q) -> T) -> T.
Proof.
intros Hpq r H.
apply H;(assumption || intro H1).
Abort.
(* Exercise 3.3 - TODO *)
Lemma id_P_1 : P -> P.
Proof.
intros p; assumption.
Qed.
Lemma id_PP_1 : (P -> P) -> (P -> P).
Proof.
intros Hpp p; assumption.
Qed.
Lemma imp_trans_1 : (P -> Q) -> (Q -> R) -> P -> R.
Proof.
intros Hpq Hqr p; apply Hqr; apply Hpq; assumption.
Qed.
Lemma imp_perm_1 : (P -> Q -> R) -> (Q -> P -> R).
Proof.
intros Hpqr q p; apply Hpqr; assumption.
Qed.
Lemma ignore_Q_1 : (P -> R) -> P -> Q -> R.
Proof.
intros Hpr p q; apply Hpr; assumption.
Abort.
Lemma delta_imp_1 : (P -> P -> Q) -> P -> Q.
Proof.
intros Hppq p; apply Hppq; assumption.
Qed.
Lemma delta_impR_1 : (P -> Q) -> (P -> P -> Q).
Proof.
intros Hpq p0 p1; apply Hpq; assumption.
Qed.
Lemma diamond_1 : (P -> Q) -> (P -> R) -> (Q -> R -> T) -> P -> T.
Proof.
intros Hpq Hpr Hqrt p; apply Hqrt; (apply Hpr || apply Hpq); assumption.
Qed.
Lemma weak_peirce_1 : ((((P -> Q) -> P) -> P) -> Q) -> Q.
Proof.
auto. (*TODO*)
Qed.
(* Section 3.7 *)
Section section_for_cut_example.
Hypotheses
(H : P -> Q)
(H0 : Q -> R)
(H1 : (P -> R) -> T -> Q)
(H2 : (P -> R) -> T).
Theorem cut_example : Q.
Proof.
cut (P -> R).
intro H3.
- apply H1; [assumption | apply H2; assumption ].
- intro p.
apply H0.
apply H.
exact p.
Qed.
Print cut_example.
End section_for_cut_example.
(* Exercise 3.5 *)
End Minimal_propositional_logic.
(* Section 3.9 *)
Print imp_dist.
Section using_imp_dict.
Variables (P1 P2 P3 : Prop).
Check (imp_dist P1 P2 P3).
End using_imp_dict.
|
function Population = DecompositionSelection(Global,Population,associate,Cosinemax)
% The decomposition-based method environmental selection
%------------------------------- Copyright --------------------------------
% Copyright (c) 2023 BIMK Group. You are free to use the PlatEMO for
% research purposes. All publications which use this platform or any code
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform
% for evolutionary multi-objective optimization [educational forum], IEEE
% Computational Intelligence Magazine, 2017, 12(4): 73-87".
%--------------------------------------------------------------------------
% This function is written by Shufen Qin
% E-mail: [email protected]
np = length(Population);
%% Normalization
Obj = Population.objs;
Obj = (Obj-repmat(min(Obj),np,1))./(repmat(max(Obj),np,1)-repmat(min(Obj),np,1));
%% Select one solution for each reference vector
list = unique(associate)';
Next = zeros(length(list),1);
t = 1;
for i = list
current = find(associate == i);
dist = pdist2(Obj(current,:),zeros(1,Global.M),'Euclidean');
Fan = Cosinemax(current)./dist;
[~,best] = max(Fan);
Next(t) = current(best);
t = t +1;
end
% Population for next generation
Population = Population(Next);
end |
// matrix/snowboy-blas.h
// Copyright 2016 KITT.AI (author: Guoguo Chen)
#ifndef SNOWBOY_MATRIX_SNOWBOY_BLAS_H_
#define SNOWBOY_MATRIX_SNOWBOY_BLAS_H_
#ifdef HAVE_ATLAS
extern "C" {
#include <cblas.h>
#include <clapack.h>
}
#elif defined(HAVE_CLAPACK)
#ifdef __APPLE__
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#define vImage_Utilities_h
#define vImage_CVUtilities_h
#include <Accelerate/Accelerate.h>
typedef __CLPK_integer integer;
typedef __CLPK_logical logical;
// typedef __CLPK_real real;
typedef __CLPK_doublereal doublereal;
typedef __CLPK_complex complex;
typedef __CLPK_doublecomplex doublecomplex;
typedef __CLPK_ftnlen ftnlen;
#else
extern "C" {
#include <cblas.h>
#include <f2c.h>
#include <clapack.h>
// Removes dangerous macros from f2c.h.
#undef abs
#undef dabs
#undef min
#undef max
#undef dmin
#undef dmax
#undef bit_test
#undef bit_clear
#undef bit_set
}
#endif
// Defines SnowboyBlasInt type that will be used in SVD.
typedef integer SnowboyBlasInt;
#elif defined(HAVE_OPENBLAS)
#include "cblas.h"
#ifndef NO_FORTRAN
#include "lapacke.h"
#endif
#undef I
#undef complex
// get rid of macros from f2c.h -- these are dangerous.
#undef abs
#undef dabs
#undef min
#undef max
#undef dmin
#undef dmax
#undef bit_test
#undef bit_clear
#undef bit_set
#else
#error "You have to define HAVE_CLAPACK or HAVE_ATLAS or HAVE_OPENBLAS."
#endif
#endif // SNOWBOY_MATRIX_SNOWBOY_BLAS_H_
|
import algebra.big_operators.basic
import data.real.basic
/-
Canadian Mathematical Olympiad 1998, Problem 3
Let n be a natural number such that n ≥ 2. Show that
(1/(n + 1))(1 + 1/3 + ... + 1/(2n -1)) > (1/n)(1/2 + 1/4 + ... + 1/2n).
-/
open_locale big_operators
-- n' + 1 = n
theorem canada1998_q3 (n' : ℕ) (hn : 1 ≤ n') :
((1:ℝ)/(n'+2)) * ∑ (i:ℕ) in finset.range n', (1/(2 * n' + 1)) >
((1:ℝ)/(n'+1)) * ∑ (i:ℕ) in finset.range n', (1/(2 * n' + 2)) :=
begin
cases n',
{ sorry, },
clear hn,
sorry
end
|
classdef xt_reserves < mp.extension
% MATPOWER
% Copyright (c) 2022, Power Systems Engineering Research Center (PSERC)
% by Ray Zimmerman, PSERC Cornell
%
% This file is part of MATPOWER.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See https://matpower.org for more info.
% properties
% end %% properties
methods
function dmc_elements = dmc_element_classes(obj, dmc_class, fmt, mpopt)
switch fmt
case 'mpc2'
dmc_elements = { @mp.dmce_reserve_gen_mpc2, ...
@mp.dmce_reserve_zone_mpc2 };
otherwise
dmc_elements = {}; %% no modifications
end
end
function dm_elements = dm_element_classes(obj, dm_class, task_tag, mpopt)
switch task_tag
case 'OPF'
dm_elements = { @mp.dme_reserve_gen, ...
@mp.dme_reserve_zone };
otherwise
dm_elements = {}; %% no modifications
end
end
function mm_elements = mm_element_classes(obj, mm_class, task_tag, mpopt)
switch task_tag
case {'OPF'}
mm_elements = { @mp.mme_reserve_gen, ...
@mp.mme_reserve_zone };
otherwise
mm_elements = {}; %% no modifications
end
end
end %% methods
end %% classdef
|
module AutomatedReviewAnalyzer where
import Numeric.LinearAlgebra as LA
import Data.List.Split (splitOn)
import qualified Data.Map.Strict as M
import System.IO
import Data.Char (isAlpha, toLower)
import SentimentAnalysis
classify :: Matrix R -> Vector R -> R -> Vector R
classify x theta thata0 = cmap check (theta LA.<# LA.tr' x + theta0s)
where
theta0s = rows x LA.|> repeat 0
check z = if z > 0 then 1.0 else -1.0
accuracy :: Vector R -> Vector R -> R
accuracy pred target = sum xs / fromIntegral (length xs)
where
xs = zipWith check (toList pred) (toList target)
check a b = if a == b then 1 else 0
classifierAccuracy :: (Matrix R -> Vector R -> Int -> [Int] -> (Vector R, R))
-> Matrix R -> Matrix R -> Vector R -> Vector R -> Int -> [Int] -> (R, R)
classifierAccuracy classifier x x' y y' t zs =
(accuracy (classify x theta theta0) y, accuracy (classify x' theta theta0) y')
where
(theta, theta0) = classifier x y t zs
classifierAccuracy' :: (Matrix R -> Vector R -> Int -> R -> [Int] -> (Vector R, R))
-> Matrix R -> Matrix R -> Vector R -> Vector R -> Int -> R -> [Int] -> (R, R)
classifierAccuracy' classifier x x' y y' t lambda zs =
(accuracy (classify x theta theta0) y, accuracy (classify x' theta theta0) y')
where
(theta, theta0) = classifier x y t lambda zs
separate :: String -> String
separate = concatMap separate'
where
separate' c = if isAlpha c then [toLower c] else [' ', c, ' ']
addWord :: String -> M.Map String R -> M.Map String R
addWord w map = if M.member w map then map else M.insert w 1.0 map
countWord :: String -> M.Map String R -> M.Map String R
countWord w = M.insertWith (+) w 1
extractFeatures :: [String] -> M.Map String R -> Matrix R
extractFeatures xs d = (length xss >< M.size d) ys
where
xss = map (words . separate) xs
ds = map (foldl (flip countWord) M.empty) xss
ys = concatMap f $ zip ds (repeat d)
f (d'', d') = map (g . flip M.lookup d'') (M.keys d')
g Nothing = 0
g (Just a) = a
main :: IO ()
main = do
h1 <- openFile "reviews_train.tsv" ReadMode
hSetEncoding h1 latin1
trainDta <- hGetContents h1
h2 <- openFile "reviews_val.tsv" ReadMode
hSetEncoding h2 latin1
valDta <- hGetContents h2
-- testDta <- readFile "reviews_test.tsv"
orderDta <- readFile "4000.txt"
let t = 20
let lambda = 0.005
let (labels, text) = unzip $ map ((\ i -> ((read . head) i, i !! 4)) . splitOn "\t") (drop 1 $ lines trainDta)
let bagOfWords = foldr addWord M.empty $ concatMap (words . separate) text
let features = extractFeatures text bagOfWords
let (labels', text') = unzip $ map ((\ i -> ((read . head) i, i !! 4)) . splitOn "\t") (drop 1 $ lines valDta)
let features' = extractFeatures text' bagOfWords
let indices = map read $ splitOn "," orderDta
let (trainAccuracy, validationAccuracy) = classifierAccuracy perceptron features features' (vector labels) (vector labels') t indices
let (trainAccuracy', validationAccuracy') = classifierAccuracy averagePerceptron features features' (vector labels) (vector labels') t indices
let (trainAccuracy'', validationAccuracy'') = classifierAccuracy' pegasos features features' (vector labels) (vector labels') t lambda indices
putStrLn "Classifier accuracy:"
-- print $ (takeColumns 10 . takeRows 4) features
print $ "Training accuracy for perceptron: " ++ show trainAccuracy
print $ "Validation accuracy for perceptron: " ++ show validationAccuracy
print $ "Training accuracy for average perceptron: " ++ show trainAccuracy'
print $ "Validation accuracy for average perceptron: " ++ show validationAccuracy'
print $ "Training accuracy for pegasos: " ++ show trainAccuracy''
print $ "Validation accuracy for pegasos: " ++ show validationAccuracy''
|
% PACKAGES INCLUDED HERE
% DO NOT NEED TO CHANGE
\documentclass[conference]{IEEEtran}
%\IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
% TITLE GOES HERE
\title{Analyzing the Effects of Non-Academic Features on Student Performance\\}
% AUTHOR NAMES GOES HERE
\author{\IEEEauthorblockN{1\textsuperscript{st} Gabriela Castillo-Rivera}
\IEEEauthorblockA{\textit{Department of Computer Science} \\
\textit{Middle Tennessee State University}\\
Murfreesboro, United States \\
[email protected]}
\and
\IEEEauthorblockN{2\textsuperscript{nd} Jeffrey Hooper}
\IEEEauthorblockA{\textit{Department of Computer Science} \\
\textit{Middle Tennessee State University}\\
Murfreesboro, United States \\
[email protected]}
\and
\IEEEauthorblockN{3\textsuperscript{rd} Austin Leverette}
\IEEEauthorblockA{\textit{Department of Computer Science} \\
\textit{Middle Tennessee State University}\\
Murfreesboro, United States \\
[email protected]}
\and
\IEEEauthorblockN{4\textsuperscript{th} James Scruggs}
\IEEEauthorblockA{\textit{Department of Computer Science} \\
\textit{Middle Tennessee State University}\\
Murfreesboro, United States \\
[email protected]}
}
\maketitle
% ABSTRACT
\begin{abstract}
This document is a model and instructions for \LaTeX.
This and the IEEEtran.cls file define the components of your paper [title, text, heads, etc.]. *CRITICAL: Do Not Use Symbols, Special Characters, Footnotes,
or Math in Paper Title or Abstract.
\end{abstract}
% KEYWORDS
\begin{IEEEkeywords}
component, formatting, style, styling, insert
\end{IEEEkeywords}
% INTRODUCTION SECTION
\section{Introduction}
It is said that our children are our future, and for that reason we, as a society, try our best to prepare them for the world they live. Secondary education helps accomplish this by bridging the gap from primary education to either post-secondary, vocational training, or the work force. Whichever path an individual decides to take, secondary education is crucial for the prosperity of a nation. With secondary education related to unemployment and incarceration rates, the importance of education becomes apparent to a society \cite{mitra}. The United States addresses this by spending 5.62\% of its GDP on education -- this equals more than a trillion dollars \cite{nationmaster}. However, many students still fall short of finishing a post-secondary education. Yearly, over 1.2 million individuals in high school dropout in the United States \cite{miller2011}. Can we assume that there are certain contributing factors to a student's success in a secondary institution? And if we can, how do we identify what they are? Using a neural network, this is what we intend to find out.
% BACKGROUND SECTION
\section{Background}
Research in student performance has been aided many times using neural networks. Researchers at the University of Technology Mara Malaysia used a neural network to determine which early subjects in electrical engineering contributed the most towards the student’s success in the major. Data on 391 students was collected from the university. The input data consisted of student grades for individual subjects (six subjects per student) in an early semester while the output is predicting the cumulative grade point average. Using sigmoid for the hidden layer, purelin for the outer layer, they were able to achieve a relatively low Mean Squared Error (0.05544) \cite{arsad2013}. However, this neural network is limited in that it only considers quantitative data.
In the European Union, Portugal ranks the lowest with student success rates. Paulo Cortez and Alice Silva, Information Systems Scientists at the University of Minho in Portugal, collected data on the secondary public-school system to see if a neural network could determine factors contributing to the high failure rates of their youth. In their study, 788 students were given questionnaires with predefined options. Along with the questionnaires, past exam grades and attendance were collected; 139 samples were discarded due to faulty sampling leaving 649 confident samples. Using a feed-forward classification neural network, they were able to achieve 72\% accuracy with three classes and 62\% accuracy with nine classes \cite{cortez2008}. This study considered both qualitative and quantitative data which is why we use the same sample collected for our neural network.
% METHODS SECTION
\section{Methods}
Our data consists of information concerning students from two schools in Portugal during the 2005-2006 school year. Information was collected both from school results along with questionnaires, which are used to determine additional details about the students’ environments. We are interested in grade information, which is scored on a scale of 0-20, along with other information about the students’ environment. Some of the information includes parental education, alcohol consumption, health status, and past class failures. We looked at student performance in Portuguese of which there are 649 records.
With some of our input data being qualitative, we had to encode it for the network. This was done by using a label encoder tool provided by Scikit-learn. This was done for all binomial and nominal data. Zeros (0) were encoded to negative ones (-1) for the binomial data to ensure proper weight updates. In addition, we needed to shuffle our dataset due to its ordered nature. Without this step, we would be training on data exclusively from one school, then testing on data from a different school.
For our network’s output shape, we decided to attempt classification of student’s scores into 5 categories. The categories range from 0, the worst score, to 4. We use a keras sequential model with two hidden layers for our simple feed-forward network. Both of these layers have the rectified linear unit as its activation function. ReLU is used because it avoids activations of zero, which can be an issue with softmax, while still allowing for nonlinearity. The function is defined as $f(x) = max(0,x)$ \cite{kaggle}. An image of the function is shown in Figure \ref{relu}.
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{relu.jpg}}
\caption{A graph showing the form of ReLU \cite{kaggle}.}
\label{relu}
\end{figure}
The first hidden layer has 800 units while the second has 400. The final, output layer uses the softmax activation function, which allows us to predict one of several categories. The error function we selected is categorical cross entropy due to its ability to help us classify students into one of multiple different categories.
Now that we have a network which we believe can predict student scores, we split our data into two sets, one for training and one for testing of the trained network. After several trials, we decided that beyond 7 epochs, our model began overfitting, so we stopped at that point. As our main objective is determining what factors contribute the most to student success, after an initial test, we began testing the network while removing a single feature every trial. Afterwards, we attempted to determine which features had the greatest impact on our model’s performance. We then selected the most detrimental of those features and removed them all at the same time, hoping to improve our results.
% RESULTS SECTION
\section{Results}
During the initial test of the network, a test accuracy of 77\% was achieved while using all features in the data set. It was thought that this accuracy could be increased by removing redundant features. This test is depicted in figure \ref{results1}
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{results1.png}}
\caption{Initial test results.}
\label{results1}
\end{figure}
There were two features whose removal from the training data had little effect on the network’s accuracy. The removal of the school and grade three features saw little to no increase in network accuracy. Figure \ref{results2} is from the network that trained on the data without the grade three feature.
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{results2.png}}
\caption{Test results without grade 3.}
\label{results2}
\end{figure}
Aside from the two features listed above, the removal of any other feature from the data set caused the network’s test accuracy to increase significantly. The removal of the feature that describe the mother’s occupation caused the test accuracy to increase to 88\%. The same is true for the feature that describes the number of absences the student has, and the higher education feature. Figure \ref{results3} depicts network accuracy and loss with the absence feature removed.
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{results3.png}}
\caption{Test results without absences.}
\label{results3}
\end{figure}
The highest test accuracy achieved was 97\% accuracy. This accuracy rating was reached on three different occasions of feature removal: the removal of the age feature, the removal of the address feature, and the removal of the free time feature. Figure \ref{results4} depicts the overall accuracy and loss of the network after the removal of the age feature.
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{results4.png}}
\caption{Test results without age.}
\label{results4}
\end{figure}
The removal of other features from the training set generally resulted in a test accuracy between 90\% and 97\%. The highest accuracy among this group is 96\%, after the removal of the feature that described how much alcohol a student drank on the weekend. A test accuracy of 90\% was the lowest accuracy score of this group, after the removal of the travel time feature from the training set. Figure \ref{results5} shows the accuracy and loss of the network that was trained without the travel time feature.
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{results5.png}}
\caption{Test results without travel time.}
\label{results5}
\end{figure}
Other notable features are the grade one and grade two feature, whose removal saw an increase in test accuracy to 90\% and 93\% respectively. Features like internet access and romantic involvement, after removal, saw a test accuracy of 95% and 96% respectively.
Lastly, we removed several features that seemed to have the most negative effects on accuracy and trained the network on the new data set. The features removed were student internet accessibility, father’s job, mother’s job, and father’s education. This test yielded an accuracy of 92% and a loss of .172.
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{fam.png}}
\caption{Distribution of grades among students with family educational support.}
\label{fam}
\end{figure}
\begin{figure}[htbp]
\centerline{\includegraphics[width=\linewidth]{nofam.png}}
\caption{Distribution of grades among students without family educational support.}
\label{fam}
\end{figure}
% DISCUSSION SECTION
\section{Discussion}
Start typing here \cite{b5}.
% REFERENCES
% THIS IS CREATED AUTOMATICALLY
\bibliographystyle{IEEEtran}
\bibliography{References} % change if another name is used for References file
\end{document}
|
There have been debates about whether or not or not natural food is best than typical meals. Lower-carb foods like vegetable noodles , cauliflower rice , and candy potato toast flooded food blogs in every single place, added sugar became one thing increasingly more people tried to avoid, and turmeric was a straight star. Whilst sales of natural products are taking off, the share value of Complete Meals has fallen 50 % from its excessive this year, as buyers worry about its prices and more competitors. The draw back to everyone understanding about it, is that you will have to wait in line fairly a while to get your food at lunch. We already love coconut oil, coconut water, and coconut milk, however this well being food-favourite is available in many other types—kinds Entire Meals experiences are prone to get their fifteen minutes of fame in 2017. It is troublesome for the average shopper to know what to do. However i thought vitamins have been under the FDA (Food and Drug Administration) and came with some sort of supervision and approval.
Laura-Jane is a raw food skilled and is the host of the popular Uncooked Meals Podcast, creator of the e book called Uncooked Meals Favourites, and speaks about her uncooked food eating suggestions at conferences across the US and Canada. I think my vitamins are good high quality (I get them organized online since I can not find them in stores) however in gentle of this text, I’m going to examine to make sure. Once you contact us by phone or email regarding particular well being questions, we’re restricted in the amount and kind of information we can legally supply. She often updates her weblog, offering readers with delicious recipes made up of the very best healthy meals to eat. Gena is an expert nutritionist who is passionate about vegan and uncooked food.
But common practices in our fashionable, industrial meals system are creating significant global well being and environmental problems Within the United States, the 4 leading causes of death—and largest sources of healthcare expenditure— are instantly linked to meals : stroke, diabetes, most cancers, and heart problems.
For a food lover, there are most likely few things in life that are as nice as sitting down and having fun with a nice meal. Most dietary supplements on the market are produced with excessive warmth, so by the point you take them – they’re almost worthless! Meals lovers and fans reside for the moments that they will get a chance to actually sit down at a desk and luxuriate in a fine feast either by themselves or in the company of household and or buddies. Not only can you find an enormous collection of health meals , supplements, and vitamins, you’ll be able to seize a delicious meal while you shop!
Their philosophy is providing a big variety of high quality natural natural meals and products which can be eco-friendly. The spherical of financing for the beginning-up, which aims to offer healthy, natural meals at low prices, was led by the funding firm Invus. Meet with Ali on her wonderful meals blog and get the access to simple, healthy and delicious recipes you could make with a meals spiralizer. I went on a search and found a few of the Finest Health Meals Shops in Chattanooga Tennessee. This course of extends shelf lifetime of food, yet there isn’t any label to tell you if a meals has been irradiated. And for those who’re sick of honey and agave, you might enjoy coconut sugar, which, although no better for you” than different sugars (not that sugar is ever good for you), Whole Foods touts as a tasty alternative to your regular sweeteners. |
Get Involved | Libraries, LTD.
We invite you to join with us in promoting literacy among Arizona children. Our organization is partially supported through stock dividends and a grant from the Spalding Foundation. However, our members and friends are the backbone of our organization.
Volunteers perform all our activities.
Any donation of time, money, or new children’s books is gratefully accepted, and will help support our mission of providing books and literacy materials to underserved communities in Arizona.
Libraries, Ltd. is a 501( c )3 tax-exempt organization. |
Require Driver.
Cd "extracted".
Set Extraction AccessOpaque.
Extraction Blacklist String List.
Extract Inductive bool => bool [ true false ].
Extract Inductive option => option [ Some None ].
Extract Inductive unit => unit [ "()" ].
Extract Inductive list => list [ "[]" "( :: )" ].
Extract Inductive prod => "( * )" [ "" ].
(** NB: The "" above is a hack, but produce nicer code than "(,)" *)
(** Mapping sumbool to bool and sumor to option is not always nicer,
but it helps when realizing stuff like [lt_eq_lt_dec] *)
Extract Inductive sumbool => bool [ true false ].
Extract Inductive sumor => option [ Some None ].
(** Restore lazyness of andb, orb.
NB: without these Extract Constant, andb/orb would be inlined
by extraction in order to have lazyness, producing inelegant
(if ... then ... else false) and (if ... then true else ...).
*)
Extract Inlined Constant andb => "(&&)".
Extract Inlined Constant orb => "(||)".
Extract Inductive nat => int [ "0" "Pervasives.succ" ]
"(fun fO fS n -> if n=0 then fO () else fS (n-1))".
(** Efficient (but uncertified) versions for usual [nat] functions *)
Extract Constant plus => "(+)".
Extract Constant pred => "fun n -> max 0 (n-1)".
Extract Constant minus => "fun n m -> max 0 (n-m)".
Extract Constant mult => "( * )".
Extract Inlined Constant max => max.
Extract Inlined Constant min => min.
(*Extract Inlined Constant nat_beq => "(=)".*)
Extract Inlined Constant EqNat.beq_nat => "(=)".
Extract Inlined Constant EqNat.eq_nat_decide => "(=)".
Extract Inlined Constant Peano_dec.eq_nat_dec => "(=)".
Extract Constant Compare_dec.nat_compare =>
"fun n m -> if n=m then Eq else if n<m then Lt else Gt".
Extract Inlined Constant Compare_dec.leb => "(<=)".
Extract Inlined Constant Compare_dec.le_lt_dec => "(<=)".
Extract Constant Compare_dec.lt_eq_lt_dec =>
"fun n m -> if n>m then None else Some (n<m)".
Extract Constant Even.even_odd_dec => "fun n -> n mod 2 = 0".
Extract Constant Div2.div2 => "fun n -> n/2".
Separate Extraction Driver.
|
// Copyright (c) 2021 The DRiyal Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <consensus/validation.h>
#include <key_io.h>
#include <policy/packages.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <script/standard.h>
#include <test/util/setup_common.h>
#include <validation.h>
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(txpackage_tests)
// Create placeholder transactions that have no meaning.
inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outputs)
{
CMutableTransaction mtx = CMutableTransaction();
mtx.vin.resize(num_inputs);
mtx.vout.resize(num_outputs);
auto random_script = CScript() << ToByteVector(InsecureRand256()) << ToByteVector(InsecureRand256());
for (size_t i{0}; i < num_inputs; ++i) {
mtx.vin[i].prevout.hash = InsecureRand256();
mtx.vin[i].prevout.n = 0;
mtx.vin[i].scriptSig = random_script;
}
for (size_t o{0}; o < num_outputs; ++o) {
mtx.vout[o].nValue = 1 * CENT;
mtx.vout[o].scriptPubKey = random_script;
}
return MakeTransactionRef(mtx);
}
BOOST_FIXTURE_TEST_CASE(package_sanitization_tests, TestChain100Setup)
{
// Packages can't have more than 25 transactions.
Package package_too_many;
package_too_many.reserve(MAX_PACKAGE_COUNT + 1);
for (size_t i{0}; i < MAX_PACKAGE_COUNT + 1; ++i) {
package_too_many.emplace_back(create_placeholder_tx(1, 1));
}
PackageValidationState state_too_many;
BOOST_CHECK(!CheckPackage(package_too_many, state_too_many));
BOOST_CHECK_EQUAL(state_too_many.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(state_too_many.GetRejectReason(), "package-too-many-transactions");
// Packages can't have a total size of more than 101KvB.
CTransactionRef large_ptx = create_placeholder_tx(150, 150);
Package package_too_large;
auto size_large = GetVirtualTransactionSize(*large_ptx);
size_t total_size{0};
while (total_size <= MAX_PACKAGE_SIZE * 1000) {
package_too_large.push_back(large_ptx);
total_size += size_large;
}
BOOST_CHECK(package_too_large.size() <= MAX_PACKAGE_COUNT);
PackageValidationState state_too_large;
BOOST_CHECK(!CheckPackage(package_too_large, state_too_large));
BOOST_CHECK_EQUAL(state_too_large.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(state_too_large.GetRejectReason(), "package-too-large");
}
BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
{
LOCK(cs_main);
unsigned int initialPoolSize = m_node.mempool->size();
// Parent and Child Package
CKey parent_key;
parent_key.MakeNewKey(true);
CScript parent_locking_script = GetScriptForDestination(PKHash(parent_key.GetPubKey()));
auto mtx_parent = CreateValidMempoolTransaction(/*input_transaction=*/ m_coinbase_txns[0], /*input_vout=*/0,
/*input_height=*/ 0, /*input_signing_key=*/coinbaseKey,
/*output_destination=*/ parent_locking_script,
/*output_amount=*/ CAmount(49 * COIN), /*submit=*/false);
CTransactionRef tx_parent = MakeTransactionRef(mtx_parent);
CKey child_key;
child_key.MakeNewKey(true);
CScript child_locking_script = GetScriptForDestination(PKHash(child_key.GetPubKey()));
auto mtx_child = CreateValidMempoolTransaction(/*input_transaction=*/ tx_parent, /*input_vout=*/0,
/*input_height=*/ 101, /*input_signing_key=*/parent_key,
/*output_destination=*/child_locking_script,
/*output_amount=*/ CAmount(48 * COIN), /*submit=*/false);
CTransactionRef tx_child = MakeTransactionRef(mtx_child);
const auto result_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {tx_parent, tx_child}, /*test_accept=*/true);
BOOST_CHECK_MESSAGE(result_parent_child.m_state.IsValid(),
"Package validation unexpectedly failed: " << result_parent_child.m_state.GetRejectReason());
auto it_parent = result_parent_child.m_tx_results.find(tx_parent->GetWitnessHash());
auto it_child = result_parent_child.m_tx_results.find(tx_child->GetWitnessHash());
BOOST_CHECK(it_parent != result_parent_child.m_tx_results.end());
BOOST_CHECK_MESSAGE(it_parent->second.m_state.IsValid(),
"Package validation unexpectedly failed: " << it_parent->second.m_state.GetRejectReason());
BOOST_CHECK(it_child != result_parent_child.m_tx_results.end());
BOOST_CHECK_MESSAGE(it_child->second.m_state.IsValid(),
"Package validation unexpectedly failed: " << it_child->second.m_state.GetRejectReason());
// A single, giant transaction submitted through ProcessNewPackage fails on single tx policy.
CTransactionRef giant_ptx = create_placeholder_tx(999, 999);
BOOST_CHECK(GetVirtualTransactionSize(*giant_ptx) > MAX_PACKAGE_SIZE * 1000);
auto result_single_large = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {giant_ptx}, /*test_accept=*/true);
BOOST_CHECK(result_single_large.m_state.IsInvalid());
BOOST_CHECK_EQUAL(result_single_large.m_state.GetResult(), PackageValidationResult::PCKG_TX);
BOOST_CHECK_EQUAL(result_single_large.m_state.GetRejectReason(), "transaction failed");
auto it_giant_tx = result_single_large.m_tx_results.find(giant_ptx->GetWitnessHash());
BOOST_CHECK(it_giant_tx != result_single_large.m_tx_results.end());
BOOST_CHECK_EQUAL(it_giant_tx->second.m_state.GetRejectReason(), "tx-size");
// Check that mempool size hasn't changed.
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize);
}
BOOST_FIXTURE_TEST_CASE(noncontextual_package_tests, TestChain100Setup)
{
// The signatures won't be verified so we can just use a placeholder
CKey placeholder_key;
placeholder_key.MakeNewKey(true);
CScript spk = GetScriptForDestination(PKHash(placeholder_key.GetPubKey()));
CKey placeholder_key_2;
placeholder_key_2.MakeNewKey(true);
CScript spk2 = GetScriptForDestination(PKHash(placeholder_key_2.GetPubKey()));
// Parent and Child Package
{
auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0, 0, coinbaseKey, spk,
CAmount(49 * COIN), /* submit */ false);
CTransactionRef tx_parent = MakeTransactionRef(mtx_parent);
auto mtx_child = CreateValidMempoolTransaction(tx_parent, 0, 101, placeholder_key, spk2,
CAmount(48 * COIN), /* submit */ false);
CTransactionRef tx_child = MakeTransactionRef(mtx_child);
PackageValidationState state;
BOOST_CHECK(CheckPackage({tx_parent, tx_child}, state));
BOOST_CHECK(!CheckPackage({tx_child, tx_parent}, state));
BOOST_CHECK_EQUAL(state.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(state.GetRejectReason(), "package-not-sorted");
BOOST_CHECK(IsChildWithParents({tx_parent, tx_child}));
}
// 24 Parents and 1 Child
{
Package package;
CMutableTransaction child;
for (int i{0}; i < 24; ++i) {
auto parent = MakeTransactionRef(CreateValidMempoolTransaction(m_coinbase_txns[i + 1],
0, 0, coinbaseKey, spk, CAmount(48 * COIN), false));
package.emplace_back(parent);
child.vin.push_back(CTxIn(COutPoint(parent->GetHash(), 0)));
}
child.vout.push_back(CTxOut(47 * COIN, spk2));
// The child must be in the package.
BOOST_CHECK(!IsChildWithParents(package));
// The parents can be in any order.
FastRandomContext rng;
Shuffle(package.begin(), package.end(), rng);
package.push_back(MakeTransactionRef(child));
PackageValidationState state;
BOOST_CHECK(CheckPackage(package, state));
BOOST_CHECK(IsChildWithParents(package));
package.erase(package.begin());
BOOST_CHECK(IsChildWithParents(package));
// The package cannot have unrelated transactions.
package.insert(package.begin(), m_coinbase_txns[0]);
BOOST_CHECK(!IsChildWithParents(package));
}
// 2 Parents and 1 Child where one parent depends on the other.
{
CMutableTransaction mtx_parent;
mtx_parent.vin.push_back(CTxIn(COutPoint(m_coinbase_txns[0]->GetHash(), 0)));
mtx_parent.vout.push_back(CTxOut(20 * COIN, spk));
mtx_parent.vout.push_back(CTxOut(20 * COIN, spk2));
CTransactionRef tx_parent = MakeTransactionRef(mtx_parent);
CMutableTransaction mtx_parent_also_child;
mtx_parent_also_child.vin.push_back(CTxIn(COutPoint(tx_parent->GetHash(), 0)));
mtx_parent_also_child.vout.push_back(CTxOut(20 * COIN, spk));
CTransactionRef tx_parent_also_child = MakeTransactionRef(mtx_parent_also_child);
CMutableTransaction mtx_child;
mtx_child.vin.push_back(CTxIn(COutPoint(tx_parent->GetHash(), 1)));
mtx_child.vin.push_back(CTxIn(COutPoint(tx_parent_also_child->GetHash(), 0)));
mtx_child.vout.push_back(CTxOut(39 * COIN, spk));
CTransactionRef tx_child = MakeTransactionRef(mtx_child);
PackageValidationState state;
BOOST_CHECK(IsChildWithParents({tx_parent, tx_parent_also_child}));
BOOST_CHECK(IsChildWithParents({tx_parent, tx_child}));
BOOST_CHECK(IsChildWithParents({tx_parent, tx_parent_also_child, tx_child}));
// IsChildWithParents does not detect unsorted parents.
BOOST_CHECK(IsChildWithParents({tx_parent_also_child, tx_parent, tx_child}));
BOOST_CHECK(CheckPackage({tx_parent, tx_parent_also_child, tx_child}, state));
BOOST_CHECK(!CheckPackage({tx_parent_also_child, tx_parent, tx_child}, state));
BOOST_CHECK_EQUAL(state.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(state.GetRejectReason(), "package-not-sorted");
}
}
BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
{
LOCK(cs_main);
unsigned int expected_pool_size = m_node.mempool->size();
CKey parent_key;
parent_key.MakeNewKey(true);
CScript parent_locking_script = GetScriptForDestination(PKHash(parent_key.GetPubKey()));
// Unrelated transactions are not allowed in package submission.
Package package_unrelated;
for (size_t i{0}; i < 10; ++i) {
auto mtx = CreateValidMempoolTransaction(/* input_transaction */ m_coinbase_txns[i + 25], /* vout */ 0,
/* input_height */ 0, /* input_signing_key */ coinbaseKey,
/* output_destination */ parent_locking_script,
/* output_amount */ CAmount(49 * COIN), /* submit */ false);
package_unrelated.emplace_back(MakeTransactionRef(mtx));
}
auto result_unrelated_submit = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
package_unrelated, /* test_accept */ false);
BOOST_CHECK(result_unrelated_submit.m_state.IsInvalid());
BOOST_CHECK_EQUAL(result_unrelated_submit.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(result_unrelated_submit.m_state.GetRejectReason(), "package-not-child-with-parents");
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
// Parent and Child (and Grandchild) Package
Package package_parent_child;
Package package_3gen;
auto mtx_parent = CreateValidMempoolTransaction(/* input_transaction */ m_coinbase_txns[0], /* vout */ 0,
/* input_height */ 0, /* input_signing_key */ coinbaseKey,
/* output_destination */ parent_locking_script,
/* output_amount */ CAmount(49 * COIN), /* submit */ false);
CTransactionRef tx_parent = MakeTransactionRef(mtx_parent);
package_parent_child.push_back(tx_parent);
package_3gen.push_back(tx_parent);
CKey child_key;
child_key.MakeNewKey(true);
CScript child_locking_script = GetScriptForDestination(PKHash(child_key.GetPubKey()));
auto mtx_child = CreateValidMempoolTransaction(/* input_transaction */ tx_parent, /* vout */ 0,
/* input_height */ 101, /* input_signing_key */ parent_key,
/* output_destination */ child_locking_script,
/* output_amount */ CAmount(48 * COIN), /* submit */ false);
CTransactionRef tx_child = MakeTransactionRef(mtx_child);
package_parent_child.push_back(tx_child);
package_3gen.push_back(tx_child);
CKey grandchild_key;
grandchild_key.MakeNewKey(true);
CScript grandchild_locking_script = GetScriptForDestination(PKHash(grandchild_key.GetPubKey()));
auto mtx_grandchild = CreateValidMempoolTransaction(/* input_transaction */ tx_child, /* vout */ 0,
/* input_height */ 101, /* input_signing_key */ child_key,
/* output_destination */ grandchild_locking_script,
/* output_amount */ CAmount(47 * COIN), /* submit */ false);
CTransactionRef tx_grandchild = MakeTransactionRef(mtx_grandchild);
package_3gen.push_back(tx_grandchild);
// 3 Generations is not allowed.
{
auto result_3gen_submit = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
package_3gen, /* test_accept */ false);
BOOST_CHECK(result_3gen_submit.m_state.IsInvalid());
BOOST_CHECK_EQUAL(result_3gen_submit.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(result_3gen_submit.m_state.GetRejectReason(), "package-not-child-with-parents");
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
}
// Child with missing parent.
mtx_child.vin.push_back(CTxIn(COutPoint(package_unrelated[0]->GetHash(), 0)));
Package package_missing_parent;
package_missing_parent.push_back(tx_parent);
package_missing_parent.push_back(MakeTransactionRef(mtx_child));
{
const auto result_missing_parent = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
package_missing_parent, /* test_accept */ false);
BOOST_CHECK(result_missing_parent.m_state.IsInvalid());
BOOST_CHECK_EQUAL(result_missing_parent.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
BOOST_CHECK_EQUAL(result_missing_parent.m_state.GetRejectReason(), "package-not-child-with-unconfirmed-parents");
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
}
// Submit package with parent + child.
{
const auto submit_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
package_parent_child, /* test_accept */ false);
expected_pool_size += 2;
BOOST_CHECK_MESSAGE(submit_parent_child.m_state.IsValid(),
"Package validation unexpectedly failed: " << submit_parent_child.m_state.GetRejectReason());
auto it_parent = submit_parent_child.m_tx_results.find(tx_parent->GetWitnessHash());
auto it_child = submit_parent_child.m_tx_results.find(tx_child->GetWitnessHash());
BOOST_CHECK(it_parent != submit_parent_child.m_tx_results.end());
BOOST_CHECK(it_parent->second.m_state.IsValid());
BOOST_CHECK(it_child != submit_parent_child.m_tx_results.end());
BOOST_CHECK(it_child->second.m_state.IsValid());
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_parent->GetHash())));
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_child->GetHash())));
}
// Already-in-mempool transactions should be detected and de-duplicated.
{
const auto submit_deduped = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
package_parent_child, /* test_accept */ false);
BOOST_CHECK_MESSAGE(submit_deduped.m_state.IsValid(),
"Package validation unexpectedly failed: " << submit_deduped.m_state.GetRejectReason());
auto it_parent_deduped = submit_deduped.m_tx_results.find(tx_parent->GetWitnessHash());
auto it_child_deduped = submit_deduped.m_tx_results.find(tx_child->GetWitnessHash());
BOOST_CHECK(it_parent_deduped != submit_deduped.m_tx_results.end());
BOOST_CHECK(it_parent_deduped->second.m_state.IsValid());
BOOST_CHECK(it_parent_deduped->second.m_result_type == MempoolAcceptResult::ResultType::MEMPOOL_ENTRY);
BOOST_CHECK(it_child_deduped != submit_deduped.m_tx_results.end());
BOOST_CHECK(it_child_deduped->second.m_state.IsValid());
BOOST_CHECK(it_child_deduped->second.m_result_type == MempoolAcceptResult::ResultType::MEMPOOL_ENTRY);
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_parent->GetHash())));
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_child->GetHash())));
}
}
BOOST_AUTO_TEST_SUITE_END()
|
import sys, copy
import numpy as np
import scipy as sp
import scipy.linalg
from VyPy.exceptions import EvaluationFailure
from VyPy.data import IndexableDict
from VyPy.tools import vector_distance, atleast_2d
class Modeling(object):
def __init__(self,Learn,Scaling=None):
# pack
self.Learn = Learn
self.Infer = Learn.Infer
self.Kernel = Learn.Kernel
self.Train = Learn.Train
self.Hypers = Learn.Hypers
self.Scaling = Scaling
# useful data
self._current = False
# try to precalc Kernel
##self.safe_precalc()
return
#: def __init__()
def predict(self,XI):
if not self.Scaling is None:
XI = self.Scaling.X.set_scaling(XI)
# will skip if current
self.safe_precalc()
# prediction
data = self.Infer.predict(XI)
if not self.Scaling is None:
data = self.Scaling.unset_scaling(data)
return data
def predict_YI(self,XI):
return self.predict(XI).YI
def safe_precalc(self):
if self._current:
return
try:
self.precalc()
except EvaluationFailure:
try:
self.learn()
except EvaluationFailure:
raise EvaluationFailure , 'could not precalculate Kernel'
self._current = True
return
def precalc(self):
self.Infer.precalc()
def learn(self):
self.Learn.learn()
#: class Modeling() |
#include "sparse-matrix.h"
#include "sparse-solver.h"
#include "sparse-solver-private.h"
#include <stdlib.h>
#include <string.h>
#if HAVE_MKL_LAPACK
#include <mkl_lapacke.h>
#else
#include <lapacke.h>
#endif
#include <assert.h>
void
sparse_lapack_init (SparseSolver *solver)
{
}
void
sparse_lapack_clear (SparseSolver *solver)
{
}
int
sparse_lapack_solve (SparseSolver *solver,
SparseMatrix *A,
void *x,
const void *b)
{
lapack_int ret;
assert (A->storage == SPARSE_MATRIX_STORAGE_DENSE);
assert (A->shape[0] == A->shape[1]);
lapack_int *pivot = malloc (A->shape[0] * sizeof (lapack_int));
if (A->type == SPARSE_MATRIX_TYPE_DOUBLE)
{
memcpy (x, b, A->shape[1] * sizeof (double));
ret = LAPACKE_dgesv (LAPACK_ROW_MAJOR,
A->shape[0],
1,
A->data,
A->shape[1],
pivot,
(double*) x,
1);
}
else if (A->type == SPARSE_MATRIX_TYPE_FLOAT)
{
memcpy (x, b, A->shape[1] * sizeof (float));
ret = LAPACKE_sgesv (LAPACK_ROW_MAJOR,
A->shape[0],
1,
A->data,
A->shape[1],
pivot,
(float*) x,
1);
}
else
{
assert (0);
}
free (pivot);
return ret == 0;
}
|
From iris.bi Require Export big_op.
From iris.proofmode Require Import tactics.
From iris.program_logic Require Export total_weakestpre.
From iris.prelude Require Import options.
Section lifting.
Context `{!irisG Λ Σ}.
Implicit Types v : val Λ.
Implicit Types e : expr Λ.
Implicit Types σ : state Λ.
Implicit Types P Q : iProp Σ.
Implicit Types Φ : val Λ → iProp Σ.
Local Hint Resolve reducible_no_obs_reducible : core.
Lemma twp_lift_step s E Φ e1 :
to_val e1 = None →
(∀ σ1 κs n, state_interp σ1 κs n ={E,∅}=∗
⌜if s is NotStuck then reducible_no_obs e1 σ1 else True⌝ ∗
∀ κ e2 σ2 efs, ⌜prim_step e1 σ1 κ e2 σ2 efs⌝ ={∅,E}=∗
⌜κ = []⌝ ∗
state_interp σ2 κs (length efs + n) ∗
WP e2 @ s; E [{ Φ }] ∗
[∗ list] ef ∈ efs, WP ef @ s; ⊤ [{ fork_post }])
⊢ WP e1 @ s; E [{ Φ }].
Proof. by rewrite twp_unfold /twp_pre=> ->. Qed.
(** Derived lifting lemmas. *)
Lemma twp_lift_pure_step_no_fork `{!Inhabited (state Λ)} s E Φ e1 :
(∀ σ1, reducible_no_obs e1 σ1) →
(∀ σ1 κ e2 σ2 efs, prim_step e1 σ1 κ e2 σ2 efs → κ = [] ∧ σ2 = σ1 ∧ efs = []) →
(|={E}=> ∀ κ e2 efs σ, ⌜prim_step e1 σ κ e2 σ efs⌝ → WP e2 @ s; E [{ Φ }])
⊢ WP e1 @ s; E [{ Φ }].
Proof.
iIntros (Hsafe Hstep) ">H". iApply twp_lift_step.
{ eapply reducible_not_val, reducible_no_obs_reducible, (Hsafe inhabitant). }
iIntros (σ1 κs n) "Hσ".
iApply fupd_mask_intro; first by set_solver. iIntros "Hclose". iSplit.
{ iPureIntro. destruct s; auto. }
iIntros (κ e2 σ2 efs ?). destruct (Hstep σ1 κ e2 σ2 efs) as (->&<-&->); auto.
iMod "Hclose" as "_". iModIntro.
iDestruct ("H" with "[//]") as "H". simpl. by iFrame.
Qed.
(* Atomic steps don't need any mask-changing business here, one can
use the generic lemmas here. *)
Lemma twp_lift_atomic_step {s E Φ} e1 :
to_val e1 = None →
(∀ σ1 κs n, state_interp σ1 κs n ={E}=∗
⌜if s is NotStuck then reducible_no_obs e1 σ1 else True⌝ ∗
∀ κ e2 σ2 efs, ⌜prim_step e1 σ1 κ e2 σ2 efs⌝ ={E}=∗
⌜κ = []⌝ ∗
state_interp σ2 κs (length efs + n) ∗
from_option Φ False (to_val e2) ∗
[∗ list] ef ∈ efs, WP ef @ s; ⊤ [{ fork_post }])
⊢ WP e1 @ s; E [{ Φ }].
Proof.
iIntros (?) "H".
iApply (twp_lift_step _ E _ e1)=>//; iIntros (σ1 κs n) "Hσ1".
iMod ("H" $! σ1 with "Hσ1") as "[$ H]".
iApply fupd_mask_intro; first set_solver.
iIntros "Hclose" (κ e2 σ2 efs) "%". iMod "Hclose" as "_".
iMod ("H" $! κ e2 σ2 efs with "[#]") as "($ & $ & HΦ & $)"; first by eauto.
destruct (to_val e2) eqn:?; last by iExFalso.
iApply twp_value; last done. by apply of_to_val.
Qed.
Lemma twp_lift_pure_det_step_no_fork `{!Inhabited (state Λ)} {s E Φ} e1 e2 :
(∀ σ1, reducible_no_obs e1 σ1) →
(∀ σ1 κ e2' σ2 efs', prim_step e1 σ1 κ e2' σ2 efs' →
κ = [] ∧ σ2 = σ1 ∧ e2' = e2 ∧ efs' = []) →
(|={E}=> WP e2 @ s; E [{ Φ }]) ⊢ WP e1 @ s; E [{ Φ }].
Proof.
iIntros (? Hpuredet) ">H". iApply (twp_lift_pure_step_no_fork s E); try done.
{ naive_solver. }
iIntros "!>" (κ' e' efs' σ (_&_&->&->)%Hpuredet); auto.
Qed.
Lemma twp_pure_step `{!Inhabited (state Λ)} s E e1 e2 φ n Φ :
PureExec φ n e1 e2 →
φ →
WP e2 @ s; E [{ Φ }] ⊢ WP e1 @ s; E [{ Φ }].
Proof.
iIntros (Hexec Hφ) "Hwp". specialize (Hexec Hφ).
iInduction Hexec as [e|n e1 e2 e3 [Hsafe ?]] "IH"; simpl; first done.
iApply twp_lift_pure_det_step_no_fork; [done|naive_solver|].
iModIntro. by iApply "IH".
Qed.
End lifting.
|
(* This file is a part of IsarMathLib -
a library of formalized mathematics for Isabelle/Isar.
Copyright (C) 2005 - 2009 Slawomir Kolodynski
This program is free software; Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
section \<open>Integers 3\<close>
theory Int_ZF_3 imports Int_ZF_2
begin
text\<open>This theory is a continuation of \<open>Int_ZF_2\<close>. We consider
here the properties of slopes (almost homomorphisms on integers)
that allow to define the order relation and multiplicative
inverse on real numbers. We also prove theorems that allow to show
completeness of the order relation of real numbers we define in \<open>Real_ZF\<close>.
\<close>
subsection\<open>Positive slopes\<close>
text\<open>This section provides background material for defining the order relation on real numbers.\<close>
text\<open>Positive slopes are functions (of course.)\<close>
lemma (in int1) Int_ZF_2_3_L1: assumes A1: "f\<in>\<S>\<^sub>+" shows "f:\<int>\<rightarrow>\<int>"
using assms AlmostHoms_def PositiveSet_def by simp
text\<open>A small technical lemma to simplify the proof of the next theorem.\<close>
lemma (in int1) Int_ZF_2_3_L1A:
assumes A1: "f\<in>\<S>\<^sub>+" and A2: "\<exists>n \<in> f``(\<int>\<^sub>+) \<inter> \<int>\<^sub>+. a\<lsq>n"
shows "\<exists>M\<in>\<int>\<^sub>+. a \<lsq> f`(M)"
proof -
from A1 have "f:\<int>\<rightarrow>\<int>" "\<int>\<^sub>+ \<subseteq> \<int>"
using AlmostHoms_def PositiveSet_def by auto
with A2 show ?thesis using func_imagedef by auto
qed
text\<open>The next lemma is Lemma 3 in the Arthan's paper.\<close>
lemma (in int1) Arthan_Lem_3:
assumes A1: "f\<in>\<S>\<^sub>+" and A2: "D \<in> \<int>\<^sub>+"
shows "\<exists>M\<in>\<int>\<^sub>+. \<forall>m\<in>\<int>\<^sub>+. (m\<ra>\<one>)\<cdot>D \<lsq> f`(m\<cdot>M)"
proof -
let ?E = "max\<delta>(f) \<ra> D"
let ?A = "f``(\<int>\<^sub>+) \<inter> \<int>\<^sub>+"
from A1 A2 have I: "D\<lsq>?E"
using Int_ZF_1_5_L3 Int_ZF_2_1_L8 Int_ZF_2_L1A Int_ZF_2_L15D
by simp
from A1 A2 have "?A \<subseteq> \<int>\<^sub>+" "?A \<notin> Fin(\<int>)" "\<two>\<cdot>?E \<in> \<int>"
using int_two_three_are_int Int_ZF_2_1_L8 PositiveSet_def Int_ZF_1_1_L5
by auto
with A1 have "\<exists>M\<in>\<int>\<^sub>+. \<two>\<cdot>?E \<lsq> f`(M)"
using Int_ZF_1_5_L2A Int_ZF_2_3_L1A by simp
then obtain M where II: "M\<in>\<int>\<^sub>+" and III: "\<two>\<cdot>?E \<lsq> f`(M)"
by auto
{ fix m assume "m\<in>\<int>\<^sub>+" then have A4: "\<one>\<lsq>m"
using Int_ZF_1_5_L3 by simp
moreover from II III have "(\<one>\<ra>\<one>) \<cdot>?E \<lsq> f`(\<one>\<cdot>M)"
using PositiveSet_def Int_ZF_1_1_L4 by simp
moreover have "\<forall>k.
\<one>\<lsq>k \<and> (k\<ra>\<one>)\<cdot>?E \<lsq> f`(k\<cdot>M) \<longrightarrow> (k\<ra>\<one>\<ra>\<one>)\<cdot>?E \<lsq> f`((k\<ra>\<one>)\<cdot>M)"
proof -
{ fix k assume A5: "\<one>\<lsq>k" and A6: "(k\<ra>\<one>)\<cdot>?E \<lsq> f`(k\<cdot>M)"
with A1 A2 II have T:
"k\<in>\<int>" "M\<in>\<int>" "k\<ra>\<one> \<in> \<int>" "?E\<in>\<int>" "(k\<ra>\<one>)\<cdot>?E \<in> \<int>" "\<two>\<cdot>?E \<in> \<int>"
using Int_ZF_2_L1A PositiveSet_def int_zero_one_are_int
Int_ZF_1_1_L5 Int_ZF_2_1_L8 by auto
from A1 A2 A5 II have
"\<delta>(f,k\<cdot>M,M) \<in> \<int>" "abs(\<delta>(f,k\<cdot>M,M)) \<lsq> max\<delta>(f)" "\<zero>\<lsq>D"
using Int_ZF_2_L1A PositiveSet_def Int_ZF_1_1_L5
Int_ZF_2_1_L7 Int_ZF_2_L16C by auto
with III A6 have
"(k\<ra>\<one>)\<cdot>?E \<ra> (\<two>\<cdot>?E \<rs> ?E) \<lsq> f`(k\<cdot>M) \<ra> (f`(M) \<ra> \<delta>(f,k\<cdot>M,M))"
using Int_ZF_1_3_L19A int_ineq_add_sides by simp
with A1 T have "(k\<ra>\<one>\<ra>\<one>)\<cdot>?E \<lsq> f`((k\<ra>\<one>)\<cdot>M)"
using Int_ZF_1_1_L1 int_zero_one_are_int Int_ZF_1_1_L4
Int_ZF_1_2_L11 Int_ZF_2_1_L13 by simp
} then show ?thesis by simp
qed
ultimately have "(m\<ra>\<one>)\<cdot>?E \<lsq> f`(m\<cdot>M)" by (rule Induction_on_int)
with A4 I have "(m\<ra>\<one>)\<cdot>D \<lsq> f`(m\<cdot>M)" using Int_ZF_1_3_L13A
by simp
} then have "\<forall>m\<in>\<int>\<^sub>+.(m\<ra>\<one>)\<cdot>D \<lsq> f`(m\<cdot>M)" by simp
with II show ?thesis by auto
qed
text\<open>A special case of \<open> Arthan_Lem_3\<close> when $D=1$.\<close>
corollary (in int1) Arthan_L_3_spec: assumes A1: "f \<in> \<S>\<^sub>+"
shows "\<exists>M\<in>\<int>\<^sub>+.\<forall>n\<in>\<int>\<^sub>+. n\<ra>\<one> \<lsq> f`(n\<cdot>M)"
proof -
have "\<forall>n\<in>\<int>\<^sub>+. n\<ra>\<one> \<in> \<int>"
using PositiveSet_def int_zero_one_are_int Int_ZF_1_1_L5
by simp
then have "\<forall>n\<in>\<int>\<^sub>+. (n\<ra>\<one>)\<cdot>\<one> = n\<ra>\<one>"
using Int_ZF_1_1_L4 by simp
moreover from A1 have "\<exists>M\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. (n\<ra>\<one>)\<cdot>\<one> \<lsq> f`(n\<cdot>M)"
using int_one_two_are_pos Arthan_Lem_3 by simp
ultimately show ?thesis by simp
qed
text\<open>We know from \<open>Group_ZF_3.thy\<close> that finite range functions are almost homomorphisms.
Besides reminding that fact for slopes the next lemma shows
that finite range functions do not belong to \<open>\<S>\<^sub>+\<close>.
This is important, because the projection
of the set of finite range functions defines zero in the real number construction in \<open>Real_ZF_x.thy\<close>
series, while the projection of \<open>\<S>\<^sub>+\<close> becomes the set of (strictly) positive reals.
We don't want zero to be positive, do we? The next lemma is a part of Lemma 5 in the Arthan's paper
\cite{Arthan2004}.\<close>
lemma (in int1) Int_ZF_2_3_L1B:
assumes A1: "f \<in> FinRangeFunctions(\<int>,\<int>)"
shows "f\<in>\<S>" "f \<notin> \<S>\<^sub>+"
proof -
from A1 show "f\<in>\<S>" using Int_ZF_2_1_L1 group1.Group_ZF_3_3_L1
by auto
have "\<int>\<^sub>+ \<subseteq> \<int>" using PositiveSet_def by auto
with A1 have "f``(\<int>\<^sub>+) \<in> Fin(\<int>)"
using Finite1_L21 by simp
then have "f``(\<int>\<^sub>+) \<inter> \<int>\<^sub>+ \<in> Fin(\<int>)"
using Fin_subset_lemma by blast
thus "f \<notin> \<S>\<^sub>+" by auto
qed
text\<open>We want to show that if $f$ is a slope and neither $f$ nor $-f$ are in \<open>\<S>\<^sub>+\<close>,
then $f$ is bounded. The next lemma is the first step towards that goal and
shows that if slope is not in \<open>\<S>\<^sub>+\<close> then $f($\<open>\<int>\<^sub>+\<close>$)$ is bounded above.\<close>
lemma (in int1) Int_ZF_2_3_L2: assumes A1: "f\<in>\<S>" and A2: "f \<notin> \<S>\<^sub>+"
shows "IsBoundedAbove(f``(\<int>\<^sub>+), IntegerOrder)"
proof -
from A1 have "f:\<int>\<rightarrow>\<int>" using AlmostHoms_def by simp
then have "f``(\<int>\<^sub>+) \<subseteq> \<int>" using func1_1_L6 by simp
moreover from A1 A2 have "f``(\<int>\<^sub>+) \<inter> \<int>\<^sub>+ \<in> Fin(\<int>)" by auto
ultimately show ?thesis using Int_ZF_2_T1 group3.OrderedGroup_ZF_2_L4
by simp
qed
text\<open>If $f$ is a slope and $-f\notin$ \<open>\<S>\<^sub>+\<close>, then
$f($\<open>\<int>\<^sub>+\<close>$)$ is bounded below.\<close>
lemma (in int1) Int_ZF_2_3_L3: assumes A1: "f\<in>\<S>" and A2: "\<fm>f \<notin> \<S>\<^sub>+"
shows "IsBoundedBelow(f``(\<int>\<^sub>+), IntegerOrder)"
proof -
from A1 have T: "f:\<int>\<rightarrow>\<int>" using AlmostHoms_def by simp
then have "(\<sm>(f``(\<int>\<^sub>+))) = (\<fm>f)``(\<int>\<^sub>+)"
using Int_ZF_1_T2 group0_2_T2 PositiveSet_def func1_1_L15C
by auto
with A1 A2 T show "IsBoundedBelow(f``(\<int>\<^sub>+), IntegerOrder)"
using Int_ZF_2_1_L12 Int_ZF_2_3_L2 PositiveSet_def func1_1_L6
Int_ZF_2_T1 group3.OrderedGroup_ZF_2_L5 by simp
qed
text\<open>A slope that is bounded on \<open>\<int>\<^sub>+\<close> is bounded everywhere.\<close>
lemma (in int1) Int_ZF_2_3_L4:
assumes A1: "f\<in>\<S>" and A2: "m\<in>\<int>"
and A3: "\<forall>n\<in>\<int>\<^sub>+. abs(f`(n)) \<lsq> L"
shows "abs(f`(m)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> L"
proof -
from A1 A3 have
"\<zero> \<lsq> abs(f`(\<one>))" "abs(f`(\<one>)) \<lsq> L"
using int_zero_one_are_int Int_ZF_2_1_L2B int_abs_nonneg int_one_two_are_pos
by auto
then have II: "\<zero>\<lsq>L" by (rule Int_order_transitive)
note A2
moreover have "abs(f`(\<zero>)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> L"
proof -
from A1 have
"abs(f`(\<zero>)) \<lsq> max\<delta>(f)" "\<zero> \<lsq> max\<delta>(f)"
and T: "max\<delta>(f) \<in> \<int>"
using Int_ZF_2_1_L8 by auto
with II have "abs(f`(\<zero>)) \<lsq> max\<delta>(f) \<ra> max\<delta>(f) \<ra> L"
using Int_ZF_2_L15F by simp
with T show ?thesis using Int_ZF_1_1_L4 by simp
qed
moreover from A1 A3 II have
"\<forall>n\<in>\<int>\<^sub>+. abs(f`(n)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> L"
using Int_ZF_2_1_L8 Int_ZF_1_3_L5A Int_ZF_2_L15F
by simp
moreover have "\<forall>n\<in>\<int>\<^sub>+. abs(f`(\<rm>n)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> L"
proof
fix n assume "n\<in>\<int>\<^sub>+"
with A1 A3 have
"\<two>\<cdot>max\<delta>(f) \<in> \<int>"
"abs(f`(\<rm>n)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> abs(f`(n))"
"abs(f`(n)) \<lsq> L"
using int_two_three_are_int Int_ZF_2_1_L8 Int_ZF_1_1_L5
PositiveSet_def Int_ZF_2_1_L14 by auto
then show "abs(f`(\<rm>n)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> L"
using Int_ZF_2_L15A by blast
qed
ultimately show ?thesis by (rule Int_ZF_2_L19B)
qed
text\<open>A slope whose image of the set of positive integers is bounded
is a finite range function.\<close>
lemma (in int1) Int_ZF_2_3_L4A:
assumes A1: "f\<in>\<S>" and A2: "IsBounded(f``(\<int>\<^sub>+), IntegerOrder)"
shows "f \<in> FinRangeFunctions(\<int>,\<int>)"
proof -
have T1: "\<int>\<^sub>+ \<subseteq> \<int>" using PositiveSet_def by auto
from A1 have T2: "f:\<int>\<rightarrow>\<int>" using AlmostHoms_def by simp
from A2 obtain L where "\<forall>a\<in>f``(\<int>\<^sub>+). abs(a) \<lsq> L"
using Int_ZF_1_3_L20A by auto
with T2 T1 have "\<forall>n\<in>\<int>\<^sub>+. abs(f`(n)) \<lsq> L"
by (rule func1_1_L15B)
with A1 have "\<forall>m\<in>\<int>. abs(f`(m)) \<lsq> \<two>\<cdot>max\<delta>(f) \<ra> L"
using Int_ZF_2_3_L4 by simp
with T2 have "f``(\<int>) \<in> Fin(\<int>)"
by (rule Int_ZF_1_3_L20C)
with T2 show "f \<in> FinRangeFunctions(\<int>,\<int>)"
using FinRangeFunctions_def by simp
qed
text\<open>A slope whose image of the set of positive integers is bounded
below is a finite range function or a positive slope.\<close>
lemma (in int1) Int_ZF_2_3_L4B:
assumes "f\<in>\<S>" and "IsBoundedBelow(f``(\<int>\<^sub>+), IntegerOrder)"
shows "f \<in> FinRangeFunctions(\<int>,\<int>) \<or> f\<in>\<S>\<^sub>+"
using assms Int_ZF_2_3_L2 IsBounded_def Int_ZF_2_3_L4A
by auto
text\<open>If one slope is not greater then another on positive integers,
then they are almost equal or the difference is a positive slope.\<close>
lemma (in int1) Int_ZF_2_3_L4C: assumes A1: "f\<in>\<S>" "g\<in>\<S>" and
A2: "\<forall>n\<in>\<int>\<^sub>+. f`(n) \<lsq> g`(n)"
shows "f\<sim>g \<or> g \<fp> (\<fm>f) \<in> \<S>\<^sub>+"
proof -
let ?h = "g \<fp> (\<fm>f)"
from A1 have "(\<fm>f) \<in> \<S>" using Int_ZF_2_1_L12
by simp
with A1 have I: "?h \<in> \<S>" using Int_ZF_2_1_L12C
by simp
moreover have "IsBoundedBelow(?h``(\<int>\<^sub>+), IntegerOrder)"
proof -
from I have
"?h:\<int>\<rightarrow>\<int>" and "\<int>\<^sub>+\<subseteq>\<int>" using AlmostHoms_def PositiveSet_def
by auto
moreover from A1 A2 have "\<forall>n\<in>\<int>\<^sub>+. \<langle>\<zero>, ?h`(n)\<rangle> \<in> IntegerOrder"
using Int_ZF_2_1_L2B PositiveSet_def Int_ZF_1_3_L10A
Int_ZF_2_1_L12 Int_ZF_2_1_L12B Int_ZF_2_1_L12A
by simp
ultimately show "IsBoundedBelow(?h``(\<int>\<^sub>+), IntegerOrder)"
by (rule func_ZF_8_L1)
qed
ultimately have "?h \<in> FinRangeFunctions(\<int>,\<int>) \<or> ?h\<in>\<S>\<^sub>+"
using Int_ZF_2_3_L4B by simp
with A1 show "f\<sim>g \<or> g \<fp> (\<fm>f) \<in> \<S>\<^sub>+"
using Int_ZF_2_1_L9C by auto
qed
text\<open>Positive slopes are arbitrarily large for large enough arguments.\<close>
lemma (in int1) Int_ZF_2_3_L5:
assumes A1: "f\<in>\<S>\<^sub>+" and A2: "K\<in>\<int>"
shows "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
proof -
from A1 obtain M where I: "M\<in>\<int>\<^sub>+" and II: "\<forall>n\<in>\<int>\<^sub>+. n\<ra>\<one> \<lsq> f`(n\<cdot>M)"
using Arthan_L_3_spec by auto
let ?j = "GreaterOf(IntegerOrder,M,K \<rs> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f)) \<rs> \<one>)"
from A1 I have T1:
"minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f) \<in> \<int>" "M\<in>\<int>"
using Int_ZF_2_1_L15 Int_ZF_2_1_L8 Int_ZF_1_1_L5 PositiveSet_def
by auto
with A2 I have T2:
"K \<rs> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f)) \<in> \<int>"
"K \<rs> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f)) \<rs> \<one> \<in> \<int>"
using Int_ZF_1_1_L5 int_zero_one_are_int by auto
with T1 have III: "M \<lsq> ?j" and
"K \<rs> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f)) \<rs> \<one> \<lsq> ?j"
using Int_ZF_1_3_L18 by auto
with A2 T1 T2 have
IV: "K \<lsq> ?j\<ra>\<one> \<ra> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f))"
using int_zero_one_are_int Int_ZF_2_L9C by simp
let ?N = "GreaterOf(IntegerOrder,\<one>,?j\<cdot>M)"
from T1 III have T3: "?j \<in> \<int>" "?j\<cdot>M \<in> \<int>"
using Int_ZF_2_L1A Int_ZF_1_1_L5 by auto
then have V: "?N \<in> \<int>\<^sub>+" and VI: "?j\<cdot>M \<lsq> ?N"
using int_zero_one_are_int Int_ZF_1_5_L3 Int_ZF_1_3_L18
by auto
{ fix m
let ?n = "m zdiv M"
let ?k = "m zmod M"
assume "?N\<lsq>m"
with VI have "?j\<cdot>M \<lsq> m" by (rule Int_order_transitive)
with I III have
VII: "m = ?n\<cdot>M\<ra>?k"
"?j \<lsq> ?n" and
VIII: "?n \<in> \<int>\<^sub>+" "?k \<in> \<zero>..(M\<rs>\<one>)"
using IntDiv_ZF_1_L5 by auto
with II have
"?j \<ra> \<one> \<lsq> ?n \<ra> \<one>" "?n\<ra>\<one> \<lsq> f`(?n\<cdot>M)"
using int_zero_one_are_int int_ord_transl_inv by auto
then have "?j \<ra> \<one> \<lsq> f`(?n\<cdot>M)"
by (rule Int_order_transitive)
with T1 have
"?j\<ra>\<one> \<ra> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f)) \<lsq>
f`(?n\<cdot>M) \<ra> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f))"
using int_ord_transl_inv by simp
with IV have "K \<lsq> f`(?n\<cdot>M) \<ra> (minf(f,\<zero>..(M\<rs>\<one>)) \<rs> max\<delta>(f))"
by (rule Int_order_transitive)
moreover from A1 I VIII have
"f`(?n\<cdot>M) \<ra> (minf(f,\<zero>..(M\<rs>\<one>))\<rs> max\<delta>(f)) \<lsq> f`(?n\<cdot>M\<ra>?k)"
using PositiveSet_def Int_ZF_2_1_L16 by simp
ultimately have "K \<lsq> f`(?n\<cdot>M\<ra>?k)"
by (rule Int_order_transitive)
with VII have "K \<lsq> f`(m)" by simp
} then have "\<forall>m. ?N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
by simp
with V show ?thesis by auto
qed
text\<open>Positive slopes are arbitrarily small for small enough arguments.
Kind of dual to \<open>Int_ZF_2_3_L5\<close>.\<close>
lemma (in int1) Int_ZF_2_3_L5A: assumes A1: "f\<in>\<S>\<^sub>+" and A2: "K\<in>\<int>"
shows "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> f`(\<rm>m) \<lsq> K"
proof -
from A1 have T1: "abs(f`(\<zero>)) \<ra> max\<delta>(f) \<in> \<int>"
using Int_ZF_2_1_L8 by auto
with A2 have "abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<in> \<int>"
using Int_ZF_1_1_L5 by simp
with A1 have
"\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<lsq> f`(m)"
using Int_ZF_2_3_L5 by simp
then obtain N where I: "N\<in>\<int>\<^sub>+" and II:
"\<forall>m. N\<lsq>m \<longrightarrow> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<lsq> f`(m)"
by auto
{ fix m assume A3: "N\<lsq>m"
with A1 have
"f`(\<rm>m) \<lsq> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> f`(m)"
using Int_ZF_2_L1A Int_ZF_2_1_L14 by simp
moreover
from II T1 A3 have "abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> f`(m) \<lsq>
(abs(f`(\<zero>)) \<ra> max\<delta>(f)) \<rs>(abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K)"
using Int_ZF_2_L10 int_ord_transl_inv by simp
with A2 T1 have "abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> f`(m) \<lsq> K"
using Int_ZF_1_2_L3 by simp
ultimately have "f`(\<rm>m) \<lsq> K"
by (rule Int_order_transitive)
} then have "\<forall>m. N\<lsq>m \<longrightarrow> f`(\<rm>m) \<lsq> K"
by simp
with I show ?thesis by auto
qed
(*lemma (in int1) Int_ZF_2_3_L5A: assumes A1: "f\<in>\<S>\<^sub>+" and A2: "K\<in>\<int>"
shows "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. m\<lsq>(\<rm>N) \<longrightarrow> f`(m) \<lsq> K"
proof -
from A1 have T1: "abs(f`(\<zero>)) \<ra> max\<delta>(f) \<in> \<int>"
using Int_ZF_2_1_L8 by auto;
with A2 have "abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<in> \<int>"
using Int_ZF_1_1_L5 by simp;
with A1 have
"\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<lsq> f`(m)"
using Int_ZF_2_3_L5 by simp;
then obtain N where I: "N\<in>\<int>\<^sub>+" and II:
"\<forall>m. N\<lsq>m \<longrightarrow> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<lsq> f`(m)"
by auto;
{ fix m assume A3: "m\<lsq>(\<rm>N)"
with A1 have T2: "f`(m) \<in> \<int>"
using Int_ZF_2_L1A Int_ZF_2_1_L2B by simp;
from A1 I II A3 have
"abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<lsq> f`(\<rm>m)" and
"f`(\<rm>m) \<lsq> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> f`(m)"
using PositiveSet_def Int_ZF_2_L10AA Int_ZF_2_L1A Int_ZF_2_1_L14
by auto;
then have
"abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> K \<lsq> abs(f`(\<zero>)) \<ra> max\<delta>(f) \<rs> f`(m)"
by (rule Int_order_transitive)
with T1 A2 T2 have "f`(m) \<lsq> K"
using Int_ZF_2_L10AB by simp;
} then have "\<forall>m. m\<lsq>(\<rm>N) \<longrightarrow> f`(m) \<lsq> K"
by simp;
with I show ?thesis by auto;
qed;*)
text\<open>A special case of \<open>Int_ZF_2_3_L5\<close> where $K=1$.\<close>
corollary (in int1) Int_ZF_2_3_L6: assumes "f\<in>\<S>\<^sub>+"
shows "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> f`(m) \<in> \<int>\<^sub>+"
using assms int_zero_one_are_int Int_ZF_2_3_L5 Int_ZF_1_5_L3
by simp
text\<open>A special case of \<open>Int_ZF_2_3_L5\<close> where $m=N$.\<close>
corollary (in int1) Int_ZF_2_3_L6A: assumes "f\<in>\<S>\<^sub>+" and "K\<in>\<int>"
shows "\<exists>N\<in>\<int>\<^sub>+. K \<lsq> f`(N)"
proof -
from assms have "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
using Int_ZF_2_3_L5 by simp
then obtain N where I: "N \<in> \<int>\<^sub>+" and II: "\<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
by auto
then show ?thesis using PositiveSet_def int_ord_is_refl refl_def
by auto
qed
text\<open>If values of a slope are not bounded above,
then the slope is positive.\<close>
lemma (in int1) Int_ZF_2_3_L7: assumes A1: "f\<in>\<S>"
and A2: "\<forall>K\<in>\<int>. \<exists>n\<in>\<int>\<^sub>+. K \<lsq> f`(n)"
shows "f \<in> \<S>\<^sub>+"
proof -
{ fix K assume "K\<in>\<int>"
with A2 obtain n where "n\<in>\<int>\<^sub>+" "K \<lsq> f`(n)"
by auto
moreover from A1 have "\<int>\<^sub>+ \<subseteq> \<int>" "f:\<int>\<rightarrow>\<int>"
using PositiveSet_def AlmostHoms_def by auto
ultimately have "\<exists>m \<in> f``(\<int>\<^sub>+). K \<lsq> m"
using func1_1_L15D by auto
} then have "\<forall>K\<in>\<int>. \<exists>m \<in> f``(\<int>\<^sub>+). K \<lsq> m" by simp
with A1 show "f \<in> \<S>\<^sub>+" using Int_ZF_4_L9 Int_ZF_2_3_L2
by auto
qed
text\<open>For unbounded slope $f$ either $f\in$\<open>\<S>\<^sub>+\<close> of
$-f\in$\<open>\<S>\<^sub>+\<close>.\<close>
theorem (in int1) Int_ZF_2_3_L8:
assumes A1: "f\<in>\<S>" and A2: "f \<notin> FinRangeFunctions(\<int>,\<int>)"
shows "(f \<in> \<S>\<^sub>+) Xor ((\<fm>f) \<in> \<S>\<^sub>+)"
proof -
have T1: "\<int>\<^sub>+ \<subseteq> \<int>" using PositiveSet_def by auto
from A1 have T2: "f:\<int>\<rightarrow>\<int>" using AlmostHoms_def by simp
then have I: "f``(\<int>\<^sub>+) \<subseteq> \<int>" using func1_1_L6 by auto
from A1 A2 have "f \<in> \<S>\<^sub>+ \<or> (\<fm>f) \<in> \<S>\<^sub>+"
using Int_ZF_2_3_L2 Int_ZF_2_3_L3 IsBounded_def Int_ZF_2_3_L4A
by blast
moreover have "\<not>(f \<in> \<S>\<^sub>+ \<and> (\<fm>f) \<in> \<S>\<^sub>+)"
proof -
{ assume A3: "f \<in> \<S>\<^sub>+" and A4: "(\<fm>f) \<in> \<S>\<^sub>+"
from A3 obtain N1 where
I: "N1\<in>\<int>\<^sub>+" and II: "\<forall>m. N1\<lsq>m \<longrightarrow> f`(m) \<in> \<int>\<^sub>+"
using Int_ZF_2_3_L6 by auto
from A4 obtain N2 where
III: "N2\<in>\<int>\<^sub>+" and IV: "\<forall>m. N2\<lsq>m \<longrightarrow> (\<fm>f)`(m) \<in> \<int>\<^sub>+"
using Int_ZF_2_3_L6 by auto
let ?N = "GreaterOf(IntegerOrder,N1,N2)"
from I III have "N1 \<lsq> ?N" "N2 \<lsq> ?N"
using PositiveSet_def Int_ZF_1_3_L18 by auto
with A1 II IV have
"f`(?N) \<in> \<int>\<^sub>+" "(\<fm>f)`(?N) \<in> \<int>\<^sub>+" "(\<fm>f)`(?N) = \<rm>(f`(?N))"
using Int_ZF_2_L1A PositiveSet_def Int_ZF_2_1_L12A
by auto
then have False using Int_ZF_1_5_L8 by simp
} thus ?thesis by auto
qed
ultimately show "(f \<in> \<S>\<^sub>+) Xor ((\<fm>f) \<in> \<S>\<^sub>+)"
using Xor_def by simp
qed
text\<open>The sum of positive slopes is a positive slope.\<close>
theorem (in int1) sum_of_pos_sls_is_pos_sl:
assumes A1: "f \<in> \<S>\<^sub>+" "g \<in> \<S>\<^sub>+"
shows "f\<fp>g \<in> \<S>\<^sub>+"
proof -
{ fix K assume "K\<in>\<int>"
with A1 have "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
using Int_ZF_2_3_L5 by simp
then obtain N where I: "N\<in>\<int>\<^sub>+" and II: "\<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
by auto
from A1 have "\<exists>M\<in>\<int>\<^sub>+. \<forall>m. M\<lsq>m \<longrightarrow> \<zero> \<lsq> g`(m)"
using int_zero_one_are_int Int_ZF_2_3_L5 by simp
then obtain M where III: "M\<in>\<int>\<^sub>+" and IV: "\<forall>m. M\<lsq>m \<longrightarrow> \<zero> \<lsq> g`(m)"
by auto
let ?L = "GreaterOf(IntegerOrder,N,M)"
from I III have V: "?L \<in> \<int>\<^sub>+" "\<int>\<^sub>+ \<subseteq> \<int>"
using GreaterOf_def PositiveSet_def by auto
moreover from A1 V have "(f\<fp>g)`(?L) = f`(?L) \<ra> g`(?L)"
using Int_ZF_2_1_L12B by auto
moreover from I II III IV have "K \<lsq> f`(?L) \<ra> g`(?L)"
using PositiveSet_def Int_ZF_1_3_L18 Int_ZF_2_L15F
by simp
ultimately have "?L \<in> \<int>\<^sub>+" "K \<lsq> (f\<fp>g)`(?L)"
by auto
then have "\<exists>n \<in>\<int>\<^sub>+. K \<lsq> (f\<fp>g)`(n)"
by auto
} with A1 show "f\<fp>g \<in> \<S>\<^sub>+"
using Int_ZF_2_1_L12C Int_ZF_2_3_L7 by simp
qed
text\<open>The composition of positive slopes is a positive slope.\<close>
theorem (in int1) comp_of_pos_sls_is_pos_sl:
assumes A1: "f \<in> \<S>\<^sub>+" "g \<in> \<S>\<^sub>+"
shows "f\<circ>g \<in> \<S>\<^sub>+"
proof -
{ fix K assume "K\<in>\<int>"
with A1 have "\<exists>N\<in>\<int>\<^sub>+. \<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
using Int_ZF_2_3_L5 by simp
then obtain N where "N\<in>\<int>\<^sub>+" and I: "\<forall>m. N\<lsq>m \<longrightarrow> K \<lsq> f`(m)"
by auto
with A1 have "\<exists>M\<in>\<int>\<^sub>+. N \<lsq> g`(M)"
using PositiveSet_def Int_ZF_2_3_L6A by simp
then obtain M where "M\<in>\<int>\<^sub>+" "N \<lsq> g`(M)"
by auto
with A1 I have "\<exists>M\<in>\<int>\<^sub>+. K \<lsq> (f\<circ>g)`(M)"
using PositiveSet_def Int_ZF_2_1_L10
by auto
} with A1 show "f\<circ>g \<in> \<S>\<^sub>+"
using Int_ZF_2_1_L11 Int_ZF_2_3_L7
by simp
qed
text\<open>A slope equivalent to a positive one is positive.\<close>
lemma (in int1) Int_ZF_2_3_L9:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "\<langle>f,g\<rangle> \<in> AlEqRel" shows "g \<in> \<S>\<^sub>+"
proof -
from A2 have T: "g\<in>\<S>" and "\<exists>L\<in>\<int>. \<forall>m\<in>\<int>. abs(f`(m)\<rs>g`(m)) \<lsq> L"
using Int_ZF_2_1_L9A by auto
then obtain L where
I: "L\<in>\<int>" and II: "\<forall>m\<in>\<int>. abs(f`(m)\<rs>g`(m)) \<lsq> L"
by auto
{ fix K assume A3: "K\<in>\<int>"
with I have "K\<ra>L \<in> \<int>"
using Int_ZF_1_1_L5 by simp
with A1 obtain M where III: "M\<in>\<int>\<^sub>+" and IV: "K\<ra>L \<lsq> f`(M)"
using Int_ZF_2_3_L6A by auto
with A1 A3 I have "K \<lsq> f`(M)\<rs>L"
using PositiveSet_def Int_ZF_2_1_L2B Int_ZF_2_L9B
by simp
moreover from A1 T II III have
"f`(M)\<rs>L \<lsq> g`(M)"
using PositiveSet_def Int_ZF_2_1_L2B Int_triangle_ineq2
by simp
ultimately have "K \<lsq> g`(M)"
by (rule Int_order_transitive)
with III have "\<exists>n\<in>\<int>\<^sub>+. K \<lsq> g`(n)"
by auto
} with T show "g \<in> \<S>\<^sub>+"
using Int_ZF_2_3_L7 by simp
qed
text\<open>The set of positive slopes is saturated with respect to the relation of
equivalence of slopes.\<close>
lemma (in int1) pos_slopes_saturated: shows "IsSaturated(AlEqRel,\<S>\<^sub>+)"
proof -
have
"equiv(\<S>,AlEqRel)"
"AlEqRel \<subseteq> \<S> \<times> \<S>"
using Int_ZF_2_1_L9B by auto
moreover have "\<S>\<^sub>+ \<subseteq> \<S>" by auto
moreover have "\<forall>f\<in>\<S>\<^sub>+. \<forall>g\<in>\<S>. \<langle>f,g\<rangle> \<in> AlEqRel \<longrightarrow> g \<in> \<S>\<^sub>+"
using Int_ZF_2_3_L9 by blast
ultimately show "IsSaturated(AlEqRel,\<S>\<^sub>+)"
by (rule EquivClass_3_L3)
qed
text\<open>A technical lemma involving a projection of the set of positive slopes
and a logical epression with exclusive or.\<close>
lemma (in int1) Int_ZF_2_3_L10:
assumes A1: "f\<in>\<S>" "g\<in>\<S>"
and A2: "R = {AlEqRel``{s}. s\<in>\<S>\<^sub>+}"
and A3: "(f\<in>\<S>\<^sub>+) Xor (g\<in>\<S>\<^sub>+)"
shows "(AlEqRel``{f} \<in> R) Xor (AlEqRel``{g} \<in> R)"
proof -
from A1 A2 A3 have
"equiv(\<S>,AlEqRel)"
"IsSaturated(AlEqRel,\<S>\<^sub>+)"
"\<S>\<^sub>+ \<subseteq> \<S>"
"f\<in>\<S>" "g\<in>\<S>"
"R = {AlEqRel``{s}. s\<in>\<S>\<^sub>+}"
"(f\<in>\<S>\<^sub>+) Xor (g\<in>\<S>\<^sub>+)"
using pos_slopes_saturated Int_ZF_2_1_L9B by auto
then show ?thesis by (rule EquivClass_3_L7)
qed
text\<open>Identity function is a positive slope.\<close>
lemma (in int1) Int_ZF_2_3_L11: shows "id(\<int>) \<in> \<S>\<^sub>+"
proof -
let ?f = "id(\<int>)"
{ fix K assume "K\<in>\<int>"
then obtain n where T: "n\<in>\<int>\<^sub>+" and "K\<lsq>n"
using Int_ZF_1_5_L9 by auto
moreover from T have "?f`(n) = n"
using PositiveSet_def by simp
ultimately have "n\<in>\<int>\<^sub>+" and "K\<lsq>?f`(n)"
by auto
then have "\<exists>n\<in>\<int>\<^sub>+. K\<lsq>?f`(n)" by auto
} then show "?f \<in> \<S>\<^sub>+"
using Int_ZF_2_1_L17 Int_ZF_2_3_L7 by simp
qed
text\<open>The identity function is not almost equal to any bounded function.\<close>
lemma (in int1) Int_ZF_2_3_L12: assumes A1: "f \<in> FinRangeFunctions(\<int>,\<int>)"
shows "\<not>(id(\<int>) \<sim> f)"
proof -
{ from A1 have "id(\<int>) \<in> \<S>\<^sub>+"
using Int_ZF_2_3_L11 by simp
moreover assume "\<langle>id(\<int>),f\<rangle> \<in> AlEqRel"
ultimately have "f \<in> \<S>\<^sub>+"
by (rule Int_ZF_2_3_L9)
with A1 have False using Int_ZF_2_3_L1B
by simp
} then show "\<not>(id(\<int>) \<sim> f)" by auto
qed
subsection\<open>Inverting slopes\<close>
text\<open>Not every slope is a 1:1 function. However, we can still invert slopes
in the sense that if $f$ is a slope, then we can find a slope $g$ such that
$f\circ g$ is almost equal to the identity function.
The goal of this this section is to establish this fact for positive slopes.
\<close>
text\<open>If $f$ is a positive slope, then for every positive integer $p$
the set $\{n\in Z_+: p\leq f(n)\}$ is a nonempty subset of positive integers.
Recall that $f^{-1}(p)$ is the notation for the smallest element of this set.\<close>
lemma (in int1) Int_ZF_2_4_L1:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "p\<in>\<int>\<^sub>+" and A3: "A = {n\<in>\<int>\<^sub>+. p \<lsq> f`(n)}"
shows
"A \<subseteq> \<int>\<^sub>+"
"A \<noteq> 0"
"f\<inverse>(p) \<in> A"
"\<forall>m\<in>A. f\<inverse>(p) \<lsq> m"
proof -
from A3 show I: "A \<subseteq> \<int>\<^sub>+" by auto
from A1 A2 have "\<exists>n\<in>\<int>\<^sub>+. p \<lsq> f`(n)"
using PositiveSet_def Int_ZF_2_3_L6A by simp
with A3 show II: "A \<noteq> 0" by auto
from A3 I II show
"f\<inverse>(p) \<in> A"
"\<forall>m\<in>A. f\<inverse>(p) \<lsq> m"
using Int_ZF_1_5_L1C by auto
qed
text\<open>If $f$ is a positive slope and $p$ is a positive integer $p$, then
$f^{-1}(p)$ (defined as the minimum of the set $\{n\in Z_+: p\leq f(n)\}$ )
is a (well defined) positive integer.\<close>
lemma (in int1) Int_ZF_2_4_L2:
assumes "f \<in> \<S>\<^sub>+" and "p\<in>\<int>\<^sub>+"
shows
"f\<inverse>(p) \<in> \<int>\<^sub>+"
"p \<lsq> f`(f\<inverse>(p))"
using assms Int_ZF_2_4_L1 by auto
text\<open>If $f$ is a positive slope and $p$ is a positive integer such
that $n\leq f(p)$, then
$f^{-1}(n) \leq p$.\<close>
lemma (in int1) Int_ZF_2_4_L3:
assumes "f \<in> \<S>\<^sub>+" and "m\<in>\<int>\<^sub>+" "p\<in>\<int>\<^sub>+" and "m \<lsq> f`(p)"
shows "f\<inverse>(m) \<lsq> p"
using assms Int_ZF_2_4_L1 by simp
text\<open>An upper bound $f(f^{-1}(m) -1)$ for positive slopes.\<close>
lemma (in int1) Int_ZF_2_4_L4:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "m\<in>\<int>\<^sub>+" and A3: "f\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
shows "f`(f\<inverse>(m)\<rs>\<one>) \<lsq> m" "f`(f\<inverse>(m)\<rs>\<one>) \<noteq> m"
proof -
from A1 A2 have T: "f\<inverse>(m) \<in> \<int>" using Int_ZF_2_4_L2 PositiveSet_def
by simp
from A1 A3 have "f:\<int>\<rightarrow>\<int>" and "f\<inverse>(m)\<rs>\<one> \<in> \<int>"
using Int_ZF_2_3_L1 PositiveSet_def by auto
with A1 A2 have T1: "f`(f\<inverse>(m)\<rs>\<one>) \<in> \<int>" "m\<in>\<int>"
using apply_funtype PositiveSet_def by auto
{ assume "m \<lsq> f`(f\<inverse>(m)\<rs>\<one>)"
with A1 A2 A3 have "f\<inverse>(m) \<lsq> f\<inverse>(m)\<rs>\<one>"
by (rule Int_ZF_2_4_L3)
with T have False using Int_ZF_1_2_L3AA
by simp
} then have I: "\<not>(m \<lsq> f`(f\<inverse>(m)\<rs>\<one>))" by auto
with T1 show "f`(f\<inverse>(m)\<rs>\<one>) \<lsq> m"
by (rule Int_ZF_2_L19)
from T1 I show "f`(f\<inverse>(m)\<rs>\<one>) \<noteq> m"
by (rule Int_ZF_2_L19)
qed
text\<open>The (candidate for) the inverse of a positive slope is nondecreasing.\<close>
lemma (in int1) Int_ZF_2_4_L5:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "m\<in>\<int>\<^sub>+" and A3: "m\<lsq>n"
shows "f\<inverse>(m) \<lsq> f\<inverse>(n)"
proof -
from A2 A3 have T: "n \<in> \<int>\<^sub>+" using Int_ZF_1_5_L7 by blast
with A1 have "n \<lsq> f`(f\<inverse>(n))" using Int_ZF_2_4_L2
by simp
with A3 have "m \<lsq> f`(f\<inverse>(n))" by (rule Int_order_transitive)
with A1 A2 T show "f\<inverse>(m) \<lsq> f\<inverse>(n)"
using Int_ZF_2_4_L2 Int_ZF_2_4_L3 by simp
qed
text\<open>If $f^{-1}(m)$ is positive and $n$ is a positive integer, then,
then $f^{-1}(m+n)-1$ is positive.\<close>
lemma (in int1) Int_ZF_2_4_L6:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "m\<in>\<int>\<^sub>+" "n\<in>\<int>\<^sub>+" and
A3: "f\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
shows "f\<inverse>(m\<ra>n)\<rs>\<one> \<in> \<int>\<^sub>+"
proof -
from A1 A2 have "f\<inverse>(m)\<rs>\<one> \<lsq> f\<inverse>(m\<ra>n) \<rs> \<one>"
using PositiveSet_def Int_ZF_1_5_L7A Int_ZF_2_4_L2
Int_ZF_2_4_L5 int_zero_one_are_int Int_ZF_1_1_L4
int_ord_transl_inv by simp
with A3 show "f\<inverse>(m\<ra>n)\<rs>\<one> \<in> \<int>\<^sub>+" using Int_ZF_1_5_L7
by blast
qed
text\<open>If $f$ is a slope, then $f(f^{-1}(m+n)-f^{-1}(m) - f^{-1}(n))$ is
uniformly bounded above and below. Will it be the messiest IsarMathLib
proof ever? Only time will tell.\<close>
lemma (in int1) Int_ZF_2_4_L7: assumes A1: "f \<in> \<S>\<^sub>+" and
A2: "\<forall>m\<in>\<int>\<^sub>+. f\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
shows
"\<exists>U\<in>\<int>. \<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n)) \<lsq> U"
"\<exists>N\<in>\<int>. \<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. N \<lsq> f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n))"
proof -
from A1 have "\<exists>L\<in>\<int>. \<forall>r\<in>\<int>. f`(r) \<lsq> f`(r\<rs>\<one>) \<ra> L"
using Int_ZF_2_1_L28 by simp
then obtain L where
I: "L\<in>\<int>" and II: "\<forall>r\<in>\<int>. f`(r) \<lsq> f`(r\<rs>\<one>) \<ra> L"
by auto
from A1 have
"\<exists>M\<in>\<int>. \<forall>r\<in>\<int>.\<forall>p\<in>\<int>.\<forall>q\<in>\<int>. f`(r\<rs>p\<rs>q) \<lsq> f`(r)\<rs>f`(p)\<rs>f`(q)\<ra>M"
"\<exists>K\<in>\<int>. \<forall>r\<in>\<int>.\<forall>p\<in>\<int>.\<forall>q\<in>\<int>. f`(r)\<rs>f`(p)\<rs>f`(q)\<ra>K \<lsq> f`(r\<rs>p\<rs>q)"
using Int_ZF_2_1_L30 by auto
then obtain M K where III: "M\<in>\<int>" and
IV: "\<forall>r\<in>\<int>.\<forall>p\<in>\<int>.\<forall>q\<in>\<int>. f`(r\<rs>p\<rs>q) \<lsq> f`(r)\<rs>f`(p)\<rs>f`(q)\<ra>M"
and
V: "K\<in>\<int>" and VI: "\<forall>r\<in>\<int>.\<forall>p\<in>\<int>.\<forall>q\<in>\<int>. f`(r)\<rs>f`(p)\<rs>f`(q)\<ra>K \<lsq> f`(r\<rs>p\<rs>q)"
by auto
from I III V have
"L\<ra>M \<in> \<int>" "(\<rm>L) \<rs> L \<ra> K \<in> \<int>"
using Int_ZF_1_1_L4 Int_ZF_1_1_L5 by auto
moreover
{ fix m n
assume A3: "m\<in>\<int>\<^sub>+" "n\<in>\<int>\<^sub>+"
have "f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n)) \<lsq> L\<ra>M \<and>
(\<rm>L)\<rs>L\<ra>K \<lsq> f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n))"
proof -
let ?r = "f\<inverse>(m\<ra>n)"
let ?p = "f\<inverse>(m)"
let ?q = "f\<inverse>(n)"
from A1 A3 have T1:
"?p \<in> \<int>\<^sub>+" "?q \<in> \<int>\<^sub>+" "?r \<in> \<int>\<^sub>+"
using Int_ZF_2_4_L2 pos_int_closed_add_unfolded by auto
with A3 have T2:
"m \<in> \<int>" "n \<in> \<int>" "?p \<in> \<int>" "?q \<in> \<int>" "?r \<in> \<int>"
using PositiveSet_def by auto
from A2 A3 have T3:
"?r\<rs>\<one> \<in> \<int>\<^sub>+" "?p\<rs>\<one> \<in> \<int>\<^sub>+" "?q\<rs>\<one> \<in> \<int>\<^sub>+"
using pos_int_closed_add_unfolded by auto
from A1 A3 have VII:
"m\<ra>n \<lsq> f`(?r)"
"m \<lsq> f`(?p)"
"n \<lsq> f`(?q)"
using Int_ZF_2_4_L2 pos_int_closed_add_unfolded by auto
from A1 A3 T3 have VIII:
"f`(?r\<rs>\<one>) \<lsq> m\<ra>n"
"f`(?p\<rs>\<one>) \<lsq> m"
"f`(?q\<rs>\<one>) \<lsq> n"
using pos_int_closed_add_unfolded Int_ZF_2_4_L4 by auto
have "f`(?r\<rs>?p\<rs>?q) \<lsq> L\<ra>M"
proof -
from IV T2 have "f`(?r\<rs>?p\<rs>?q) \<lsq> f`(?r)\<rs>f`(?p)\<rs>f`(?q)\<ra>M"
by simp
moreover
from I II T2 VIII have
"f`(?r) \<lsq> f`(?r\<rs>\<one>) \<ra> L"
"f`(?r\<rs>\<one>) \<ra> L \<lsq> m\<ra>n\<ra>L"
using int_ord_transl_inv by auto
then have "f`(?r) \<lsq> m\<ra>n\<ra>L"
by (rule Int_order_transitive)
with VII have "f`(?r) \<rs> f`(?p) \<lsq> m\<ra>n\<ra>L\<rs>m"
using int_ineq_add_sides by simp
with I T2 VII have "f`(?r) \<rs> f`(?p) \<rs> f`(?q) \<lsq> n\<ra>L\<rs>n"
using Int_ZF_1_2_L9 int_ineq_add_sides by simp
with I III T2 have "f`(?r) \<rs> f`(?p) \<rs> f`(?q) \<ra> M \<lsq> L\<ra>M"
using Int_ZF_1_2_L3 int_ord_transl_inv by simp
ultimately show "f`(?r\<rs>?p\<rs>?q) \<lsq> L\<ra>M"
by (rule Int_order_transitive)
qed
moreover have "(\<rm>L)\<rs>L \<ra>K \<lsq> f`(?r\<rs>?p\<rs>?q)"
proof -
from I II T2 VIII have
"f`(?p) \<lsq> f`(?p\<rs>\<one>) \<ra> L"
"f`(?p\<rs>\<one>) \<ra> L \<lsq> m \<ra>L"
using int_ord_transl_inv by auto
then have "f`(?p) \<lsq> m \<ra>L"
by (rule Int_order_transitive)
with VII have "m\<ra>n \<rs>(m\<ra>L) \<lsq> f`(?r) \<rs> f`(?p)"
using int_ineq_add_sides by simp
with I T2 have "n \<rs> L \<lsq> f`(?r) \<rs> f`(?p)"
using Int_ZF_1_2_L9 by simp
moreover
from I II T2 VIII have
"f`(?q) \<lsq> f`(?q\<rs>\<one>) \<ra> L"
"f`(?q\<rs>\<one>) \<ra> L \<lsq> n \<ra>L"
using int_ord_transl_inv by auto
then have "f`(?q) \<lsq> n \<ra>L"
by (rule Int_order_transitive)
ultimately have
"n \<rs> L \<rs> (n\<ra>L) \<lsq> f`(?r) \<rs> f`(?p) \<rs> f`(?q)"
using int_ineq_add_sides by simp
with I V T2 have
"(\<rm>L)\<rs>L \<ra>K \<lsq> f`(?r) \<rs> f`(?p) \<rs> f`(?q) \<ra> K"
using Int_ZF_1_2_L3 int_ord_transl_inv by simp
moreover from VI T2 have
"f`(?r) \<rs> f`(?p) \<rs> f`(?q) \<ra> K \<lsq> f`(?r\<rs>?p\<rs>?q)"
by simp
ultimately show "(\<rm>L)\<rs>L \<ra>K \<lsq> f`(?r\<rs>?p\<rs>?q)"
by (rule Int_order_transitive)
qed
ultimately show
"f`(?r\<rs>?p\<rs>?q) \<lsq> L\<ra>M \<and>
(\<rm>L)\<rs>L\<ra>K \<lsq> f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n))"
by simp
qed
}
ultimately show
"\<exists>U\<in>\<int>. \<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n)) \<lsq> U"
"\<exists>N\<in>\<int>. \<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. N \<lsq> f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n))"
by auto
qed
text\<open>The expression $f^{-1}(m+n)-f^{-1}(m) - f^{-1}(n)$ is uniformly bounded
for all pairs $\langle m,n \rangle \in$ \<open>\<int>\<^sub>+\<times>\<int>\<^sub>+\<close>.
Recall that in the \<open>int1\<close>
context \<open>\<epsilon>(f,x)\<close> is defined so that
$\varepsilon(f,\langle m,n \rangle ) = f^{-1}(m+n)-f^{-1}(m) - f^{-1}(n)$.\<close>
lemma (in int1) Int_ZF_2_4_L8: assumes A1: "f \<in> \<S>\<^sub>+" and
A2: "\<forall>m\<in>\<int>\<^sub>+. f\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
shows "\<exists>M. \<forall>x\<in>\<int>\<^sub>+\<times>\<int>\<^sub>+. abs(\<epsilon>(f,x)) \<lsq> M"
proof -
from A1 A2 have
"\<exists>U\<in>\<int>. \<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n)) \<lsq> U"
"\<exists>N\<in>\<int>. \<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. N \<lsq> f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n))"
using Int_ZF_2_4_L7 by auto
then obtain U N where I:
"\<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n)) \<lsq> U"
"\<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. N \<lsq> f`(f\<inverse>(m\<ra>n)\<rs>f\<inverse>(m)\<rs>f\<inverse>(n))"
by auto
have "\<int>\<^sub>+\<times>\<int>\<^sub>+ \<noteq> 0" using int_one_two_are_pos by auto
moreover from A1 have "f: \<int>\<rightarrow>\<int>"
using AlmostHoms_def by simp
moreover from A1 have
"\<forall>a\<in>\<int>.\<exists>b\<in>\<int>\<^sub>+.\<forall>x. b\<lsq>x \<longrightarrow> a \<lsq> f`(x)"
using Int_ZF_2_3_L5 by simp
moreover from A1 have
"\<forall>a\<in>\<int>.\<exists>b\<in>\<int>\<^sub>+.\<forall>y. b\<lsq>y \<longrightarrow> f`(\<rm>y) \<lsq> a"
using Int_ZF_2_3_L5A by simp
moreover have
"\<forall>x\<in>\<int>\<^sub>+\<times>\<int>\<^sub>+. \<epsilon>(f,x) \<in> \<int> \<and> f`(\<epsilon>(f,x)) \<lsq> U \<and> N \<lsq> f`(\<epsilon>(f,x))"
proof -
{ fix x assume A3: "x \<in> \<int>\<^sub>+\<times>\<int>\<^sub>+"
let ?m = "fst(x)"
let ?n = "snd(x)"
from A3 have T: "?m \<in> \<int>\<^sub>+" "?n \<in> \<int>\<^sub>+" "?m\<ra>?n \<in> \<int>\<^sub>+"
using pos_int_closed_add_unfolded by auto
with A1 have
"f\<inverse>(?m\<ra>?n) \<in> \<int>" "f\<inverse>(?m) \<in> \<int>" "f\<inverse>(?n) \<in> \<int>"
using Int_ZF_2_4_L2 PositiveSet_def by auto
with I T have
"\<epsilon>(f,x) \<in> \<int> \<and> f`(\<epsilon>(f,x)) \<lsq> U \<and> N \<lsq> f`(\<epsilon>(f,x))"
using Int_ZF_1_1_L5 by auto
} thus ?thesis by simp
qed
ultimately show "\<exists>M.\<forall>x\<in>\<int>\<^sub>+\<times>\<int>\<^sub>+. abs(\<epsilon>(f,x)) \<lsq> M"
by (rule Int_ZF_1_6_L4)
qed
text\<open>The (candidate for) inverse of a positive slope is a (well defined)
function on \<open>\<int>\<^sub>+\<close>.\<close>
lemma (in int1) Int_ZF_2_4_L9:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "g = {\<langle>p,f\<inverse>(p)\<rangle>. p\<in>\<int>\<^sub>+}"
shows
"g : \<int>\<^sub>+\<rightarrow>\<int>\<^sub>+"
"g : \<int>\<^sub>+\<rightarrow>\<int>"
proof -
from A1 have
"\<forall>p\<in>\<int>\<^sub>+. f\<inverse>(p) \<in> \<int>\<^sub>+"
"\<forall>p\<in>\<int>\<^sub>+. f\<inverse>(p) \<in> \<int>"
using Int_ZF_2_4_L2 PositiveSet_def by auto
with A2 show
"g : \<int>\<^sub>+\<rightarrow>\<int>\<^sub>+" and "g : \<int>\<^sub>+\<rightarrow>\<int>"
using ZF_fun_from_total by auto
qed
text\<open>What are the values of the (candidate for) the inverse of a positive slope?\<close>
lemma (in int1) Int_ZF_2_4_L10:
assumes A1: "f \<in> \<S>\<^sub>+" and A2: "g = {\<langle>p,f\<inverse>(p)\<rangle>. p\<in>\<int>\<^sub>+}" and A3: "p\<in>\<int>\<^sub>+"
shows "g`(p) = f\<inverse>(p)"
proof -
from A1 A2 have "g : \<int>\<^sub>+\<rightarrow>\<int>\<^sub>+" using Int_ZF_2_4_L9 by simp
with A2 A3 show "g`(p) = f\<inverse>(p)" using ZF_fun_from_tot_val by simp
qed
text\<open>The (candidate for) the inverse of a positive slope is a slope.\<close>
lemma (in int1) Int_ZF_2_4_L11: assumes A1: "f \<in> \<S>\<^sub>+" and
A2: "\<forall>m\<in>\<int>\<^sub>+. f\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+" and
A3: "g = {\<langle>p,f\<inverse>(p)\<rangle>. p\<in>\<int>\<^sub>+}"
shows "OddExtension(\<int>,IntegerAddition,IntegerOrder,g) \<in> \<S>"
proof -
from A1 A2 have "\<exists>L. \<forall>x\<in>\<int>\<^sub>+\<times>\<int>\<^sub>+. abs(\<epsilon>(f,x)) \<lsq> L"
using Int_ZF_2_4_L8 by simp
then obtain L where I: "\<forall>x\<in>\<int>\<^sub>+\<times>\<int>\<^sub>+. abs(\<epsilon>(f,x)) \<lsq> L"
by auto
from A1 A3 have "g : \<int>\<^sub>+\<rightarrow>\<int>" using Int_ZF_2_4_L9
by simp
moreover have "\<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. abs(\<delta>(g,m,n)) \<lsq> L"
proof-
{ fix m n
assume A4: "m\<in>\<int>\<^sub>+" "n\<in>\<int>\<^sub>+"
then have "\<langle>m,n\<rangle> \<in> \<int>\<^sub>+\<times>\<int>\<^sub>+" by simp
with I have "abs(\<epsilon>(f,\<langle>m,n\<rangle>)) \<lsq> L" by simp
moreover have "\<epsilon>(f,\<langle>m,n\<rangle>) = f\<inverse>(m\<ra>n) \<rs> f\<inverse>(m) \<rs> f\<inverse>(n)"
by simp
moreover from A1 A3 A4 have
"f\<inverse>(m\<ra>n) = g`(m\<ra>n)" "f\<inverse>(m) = g`(m)" "f\<inverse>(n) = g`(n)"
using pos_int_closed_add_unfolded Int_ZF_2_4_L10 by auto
ultimately have "abs(\<delta>(g,m,n)) \<lsq> L" by simp
} thus "\<forall>m\<in>\<int>\<^sub>+. \<forall>n\<in>\<int>\<^sub>+. abs(\<delta>(g,m,n)) \<lsq> L" by simp
qed
ultimately show ?thesis by (rule Int_ZF_2_1_L24)
qed
text\<open>Every positive slope that is at least $2$ on positive integers
almost has an inverse.\<close>
lemma (in int1) Int_ZF_2_4_L12: assumes A1: "f \<in> \<S>\<^sub>+" and
A2: "\<forall>m\<in>\<int>\<^sub>+. f\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
shows "\<exists>h\<in>\<S>. f\<circ>h \<sim> id(\<int>)"
proof -
let ?g = "{\<langle>p,f\<inverse>(p)\<rangle>. p\<in>\<int>\<^sub>+}"
let ?h = "OddExtension(\<int>,IntegerAddition,IntegerOrder,?g)"
from A1 have
"\<exists>M\<in>\<int>. \<forall>n\<in>\<int>. f`(n) \<lsq> f`(n\<rs>\<one>) \<ra> M"
using Int_ZF_2_1_L28 by simp
then obtain M where
I: "M\<in>\<int>" and II: "\<forall>n\<in>\<int>. f`(n) \<lsq> f`(n\<rs>\<one>) \<ra> M"
by auto
from A1 A2 have T: "?h \<in> \<S>"
using Int_ZF_2_4_L11 by simp
moreover have "f\<circ>?h \<sim> id(\<int>)"
proof -
from A1 T have "f\<circ>?h \<in> \<S>" using Int_ZF_2_1_L11
by simp
moreover note I
moreover
{ fix m assume A3: "m\<in>\<int>\<^sub>+"
with A1 have "f\<inverse>(m) \<in> \<int>"
using Int_ZF_2_4_L2 PositiveSet_def by simp
with II have "f`(f\<inverse>(m)) \<lsq> f`(f\<inverse>(m)\<rs>\<one>) \<ra> M"
by simp
moreover from A1 A2 I A3 have "f`(f\<inverse>(m)\<rs>\<one>) \<ra> M \<lsq> m\<ra>M"
using Int_ZF_2_4_L4 int_ord_transl_inv by simp
ultimately have "f`(f\<inverse>(m)) \<lsq> m\<ra>M"
by (rule Int_order_transitive)
moreover from A1 A3 have "m \<lsq> f`(f\<inverse>(m))"
using Int_ZF_2_4_L2 by simp
moreover from A1 A2 T A3 have "f`(f\<inverse>(m)) = (f\<circ>?h)`(m)"
using Int_ZF_2_4_L9 Int_ZF_1_5_L11
Int_ZF_2_4_L10 PositiveSet_def Int_ZF_2_1_L10
by simp
ultimately have "m \<lsq> (f\<circ>?h)`(m) \<and> (f\<circ>?h)`(m) \<lsq> m\<ra>M"
by simp }
ultimately show "f\<circ>?h \<sim> id(\<int>)" using Int_ZF_2_1_L32
by simp
qed
ultimately show "\<exists>h\<in>\<S>. f\<circ>h \<sim> id(\<int>)"
by auto
qed
text\<open>\<open>Int_ZF_2_4_L12\<close> is almost what we need, except that it has an assumption
that the values of the slope that we get the inverse for are not smaller than $2$ on
positive integers. The Arthan's proof of Theorem 11 has a mistake where he says "note that
for all but finitely many $m,n\in N$ $p=g(m)$ and $q=g(n)$ are both positive". Of course
there may be infinitely many pairs $\langle m,n \rangle$ such that $p,q$ are not both
positive. This is however easy to workaround: we just modify the slope by adding a
constant so that the slope is large enough on positive integers and then look
for the inverse.\<close>
theorem (in int1) pos_slope_has_inv: assumes A1: "f \<in> \<S>\<^sub>+"
shows "\<exists>g\<in>\<S>. f\<sim>g \<and> (\<exists>h\<in>\<S>. g\<circ>h \<sim> id(\<int>))"
proof -
from A1 have "f: \<int>\<rightarrow>\<int>" "\<one>\<in>\<int>" "\<two> \<in> \<int>"
using AlmostHoms_def int_zero_one_are_int int_two_three_are_int
by auto
moreover from A1 have
"\<forall>a\<in>\<int>.\<exists>b\<in>\<int>\<^sub>+.\<forall>x. b\<lsq>x \<longrightarrow> a \<lsq> f`(x)"
using Int_ZF_2_3_L5 by simp
ultimately have
"\<exists>c\<in>\<int>. \<two> \<lsq> Minimum(IntegerOrder,{n\<in>\<int>\<^sub>+. \<one> \<lsq> f`(n)\<ra>c})"
by (rule Int_ZF_1_6_L7)
then obtain c where I: "c\<in>\<int>" and
II: "\<two> \<lsq> Minimum(IntegerOrder,{n\<in>\<int>\<^sub>+. \<one> \<lsq> f`(n)\<ra>c})"
by auto
let ?g = "{\<langle>m,f`(m)\<ra>c\<rangle>. m\<in>\<int>}"
from A1 I have III: "?g\<in>\<S>" and IV: "f\<sim>?g" using Int_ZF_2_1_L33
by auto
from IV have "\<langle>f,?g\<rangle> \<in> AlEqRel" by simp
with A1 have T: "?g \<in> \<S>\<^sub>+" by (rule Int_ZF_2_3_L9)
moreover have "\<forall>m\<in>\<int>\<^sub>+. ?g\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
proof
fix m assume A2: "m\<in>\<int>\<^sub>+"
from A1 I II have V: "\<two> \<lsq> ?g\<inverse>(\<one>)"
using Int_ZF_2_1_L33 PositiveSet_def by simp
moreover from A2 T have "?g\<inverse>(\<one>) \<lsq> ?g\<inverse>(m)"
using Int_ZF_1_5_L3 int_one_two_are_pos Int_ZF_2_4_L5
by simp
ultimately have "\<two> \<lsq> ?g\<inverse>(m)"
by (rule Int_order_transitive)
then have "\<two>\<rs>\<one> \<lsq> ?g\<inverse>(m)\<rs>\<one>"
using int_zero_one_are_int Int_ZF_1_1_L4 int_ord_transl_inv
by simp
then show "?g\<inverse>(m)\<rs>\<one> \<in> \<int>\<^sub>+"
using int_zero_one_are_int Int_ZF_1_2_L3 Int_ZF_1_5_L3
by simp
qed
ultimately have "\<exists>h\<in>\<S>. ?g\<circ>h \<sim> id(\<int>)"
by (rule Int_ZF_2_4_L12)
with III IV show ?thesis by auto
qed
subsection\<open>Completeness\<close>
text\<open>In this section we consider properties of slopes that are
needed for the proof of completeness of real numbers constructred
in \<open>Real_ZF_1.thy\<close>. In particular we consider properties
of embedding of integers into the set of slopes by the mapping
$m \mapsto m^S$ , where $m^S$ is defined by $m^S(n) = m\cdot n$.\<close>
text\<open>If m is an integer, then $m^S$ is a slope whose value
is $m\cdot n$ for every integer.\<close>
lemma (in int1) Int_ZF_2_5_L1: assumes A1: "m \<in> \<int>"
shows
"\<forall>n \<in> \<int>. (m\<^sup>S)`(n) = m\<cdot>n"
"m\<^sup>S \<in> \<S>"
proof -
from A1 have I: "m\<^sup>S:\<int>\<rightarrow>\<int>"
using Int_ZF_1_1_L5 ZF_fun_from_total by simp
then show II: "\<forall>n \<in> \<int>. (m\<^sup>S)`(n) = m\<cdot>n" using ZF_fun_from_tot_val
by simp
{ fix n k
assume A2: "n\<in>\<int>" "k\<in>\<int>"
with A1 have T: "m\<cdot>n \<in> \<int>" "m\<cdot>k \<in> \<int>"
using Int_ZF_1_1_L5 by auto
from A1 A2 II T have "\<delta>(m\<^sup>S,n,k) = m\<cdot>k \<rs> m\<cdot>k"
using Int_ZF_1_1_L5 Int_ZF_1_1_L1 Int_ZF_1_2_L3
by simp
also from T have "\<dots> = \<zero>" using Int_ZF_1_1_L4
by simp
finally have "\<delta>(m\<^sup>S,n,k) = \<zero>" by simp
then have "abs(\<delta>(m\<^sup>S,n,k)) \<lsq> \<zero>"
using Int_ZF_2_L18 int_zero_one_are_int int_ord_is_refl refl_def
by simp
} then have "\<forall>n\<in>\<int>.\<forall>k\<in>\<int>. abs(\<delta>(m\<^sup>S,n,k)) \<lsq> \<zero>"
by simp
with I show "m\<^sup>S \<in> \<S>" by (rule Int_ZF_2_1_L5)
qed
text\<open>For any slope $f$ there is an integer $m$ such that there is some slope $g$
that is almost equal to $m^S$ and dominates $f$ in the sense that $f\leq g$
on positive integers (which implies that either $g$ is almost equal to $f$ or
$g-f$ is a positive slope. This will be used in \<open>Real_ZF_1.thy\<close> to show
that for any real number there is an integer that (whose real embedding)
is greater or equal.\<close>
lemma (in int1) Int_ZF_2_5_L2: assumes A1: "f \<in> \<S>"
shows "\<exists>m\<in>\<int>. \<exists>g\<in>\<S>. (m\<^sup>S\<sim>g \<and> (f\<sim>g \<or> g\<fp>(\<fm>f) \<in> \<S>\<^sub>+))"
proof -
from A1 have
"\<exists>m k. m\<in>\<int> \<and> k\<in>\<int> \<and> (\<forall>p\<in>\<int>. abs(f`(p)) \<lsq> m\<cdot>abs(p)\<ra>k)"
using Arthan_Lem_8 by simp
then obtain m k where I: "m\<in>\<int>" and II: "k\<in>\<int>" and
III: "\<forall>p\<in>\<int>. abs(f`(p)) \<lsq> m\<cdot>abs(p)\<ra>k"
by auto
let ?g = "{\<langle>n,m\<^sup>S`(n) \<ra>k\<rangle>. n\<in>\<int>}"
from I have IV: "m\<^sup>S \<in> \<S>" using Int_ZF_2_5_L1 by simp
with II have V: "?g\<in>\<S>" and VI: "m\<^sup>S\<sim>?g" using Int_ZF_2_1_L33
by auto
{ fix n assume A2: "n\<in>\<int>\<^sub>+"
with A1 have "f`(n) \<in> \<int>"
using Int_ZF_2_1_L2B PositiveSet_def by simp
then have "f`(n) \<lsq> abs(f`(n))" using Int_ZF_2_L19C
by simp
moreover
from III A2 have "abs(f`(n)) \<lsq> m\<cdot>abs(n) \<ra> k"
using PositiveSet_def by simp
with A2 have "abs(f`(n)) \<lsq> m\<cdot>n\<ra>k"
using Int_ZF_1_5_L4A by simp
ultimately have "f`(n) \<lsq> m\<cdot>n\<ra>k"
by (rule Int_order_transitive)
moreover
from II IV A2 have "?g`(n) = (m\<^sup>S)`(n)\<ra>k"
using Int_ZF_2_1_L33 PositiveSet_def by simp
with I A2 have "?g`(n) = m\<cdot>n\<ra>k"
using Int_ZF_2_5_L1 PositiveSet_def by simp
ultimately have "f`(n) \<lsq> ?g`(n)"
by simp
} then have "\<forall>n\<in>\<int>\<^sub>+. f`(n) \<lsq> ?g`(n)"
by simp
with A1 V have "f\<sim>?g \<or> ?g \<fp> (\<fm>f) \<in> \<S>\<^sub>+"
using Int_ZF_2_3_L4C by simp
with I V VI show ?thesis by auto
qed
text\<open>The negative of an integer embeds in slopes as a negative of the
orgiginal embedding.\<close>
lemma (in int1) Int_ZF_2_5_L3: assumes A1: "m \<in> \<int>"
shows "(\<rm>m)\<^sup>S = \<fm>(m\<^sup>S)"
proof -
from A1 have "(\<rm>m)\<^sup>S: \<int>\<rightarrow>\<int>" and "(\<fm>(m\<^sup>S)): \<int>\<rightarrow>\<int>"
using Int_ZF_1_1_L4 Int_ZF_2_5_L1 AlmostHoms_def Int_ZF_2_1_L12
by auto
moreover have "\<forall>n\<in>\<int>. ((\<rm>m)\<^sup>S)`(n) = (\<fm>(m\<^sup>S))`(n)"
proof
fix n assume A2: "n\<in>\<int>"
with A1 have
"((\<rm>m)\<^sup>S)`(n) = (\<rm>m)\<cdot>n"
"(\<fm>(m\<^sup>S))`(n) = \<rm>(m\<cdot>n)"
using Int_ZF_1_1_L4 Int_ZF_2_5_L1 Int_ZF_2_1_L12A
by auto
with A1 A2 show "((\<rm>m)\<^sup>S)`(n) = (\<fm>(m\<^sup>S))`(n)"
using Int_ZF_1_1_L5 by simp
qed
ultimately show "(\<rm>m)\<^sup>S = \<fm>(m\<^sup>S)" using fun_extension_iff
by simp
qed
text\<open>The sum of embeddings is the embeding of the sum.\<close>
lemma (in int1) Int_ZF_2_5_L3A: assumes A1: "m\<in>\<int>" "k\<in>\<int>"
shows "(m\<^sup>S) \<fp> (k\<^sup>S) = ((m\<ra>k)\<^sup>S)"
proof -
from A1 have T1: "m\<ra>k \<in> \<int>" using Int_ZF_1_1_L5
by simp
with A1 have T2:
"(m\<^sup>S) \<in> \<S>" "(k\<^sup>S) \<in> \<S>"
"(m\<ra>k)\<^sup>S \<in> \<S>"
"(m\<^sup>S) \<fp> (k\<^sup>S) \<in> \<S>"
using Int_ZF_2_5_L1 Int_ZF_2_1_L12C by auto
then have
"(m\<^sup>S) \<fp> (k\<^sup>S) : \<int>\<rightarrow>\<int>"
"(m\<ra>k)\<^sup>S : \<int>\<rightarrow>\<int>"
using AlmostHoms_def by auto
moreover have "\<forall>n\<in>\<int>. ((m\<^sup>S) \<fp> (k\<^sup>S))`(n) = ((m\<ra>k)\<^sup>S)`(n)"
proof
fix n assume A2: "n\<in>\<int>"
with A1 T1 T2 have "((m\<^sup>S) \<fp> (k\<^sup>S))`(n) = (m\<ra>k)\<cdot>n"
using Int_ZF_2_1_L12B Int_ZF_2_5_L1 Int_ZF_1_1_L1
by simp
also from T1 A2 have "\<dots> = ((m\<ra>k)\<^sup>S)`(n)"
using Int_ZF_2_5_L1 by simp
finally show "((m\<^sup>S) \<fp> (k\<^sup>S))`(n) = ((m\<ra>k)\<^sup>S)`(n)"
by simp
qed
ultimately show "(m\<^sup>S) \<fp> (k\<^sup>S) = ((m\<ra>k)\<^sup>S)"
using fun_extension_iff by simp
qed
text\<open>The composition of embeddings is the embeding of the product.\<close>
lemma (in int1) Int_ZF_2_5_L3B: assumes A1: "m\<in>\<int>" "k\<in>\<int>"
shows "(m\<^sup>S) \<circ> (k\<^sup>S) = ((m\<cdot>k)\<^sup>S)"
proof -
from A1 have T1: "m\<cdot>k \<in> \<int>" using Int_ZF_1_1_L5
by simp
with A1 have T2:
"(m\<^sup>S) \<in> \<S>" "(k\<^sup>S) \<in> \<S>"
"(m\<cdot>k)\<^sup>S \<in> \<S>"
"(m\<^sup>S) \<circ> (k\<^sup>S) \<in> \<S>"
using Int_ZF_2_5_L1 Int_ZF_2_1_L11 by auto
then have
"(m\<^sup>S) \<circ> (k\<^sup>S) : \<int>\<rightarrow>\<int>"
"(m\<cdot>k)\<^sup>S : \<int>\<rightarrow>\<int>"
using AlmostHoms_def by auto
moreover have "\<forall>n\<in>\<int>. ((m\<^sup>S) \<circ> (k\<^sup>S))`(n) = ((m\<cdot>k)\<^sup>S)`(n)"
proof
fix n assume A2: "n\<in>\<int>"
with A1 T2 have
"((m\<^sup>S) \<circ> (k\<^sup>S))`(n) = (m\<^sup>S)`(k\<cdot>n)"
using Int_ZF_2_1_L10 Int_ZF_2_5_L1 by simp
moreover
from A1 A2 have "k\<cdot>n \<in> \<int>" using Int_ZF_1_1_L5
by simp
with A1 A2 have "(m\<^sup>S)`(k\<cdot>n) = m\<cdot>k\<cdot>n"
using Int_ZF_2_5_L1 Int_ZF_1_1_L7 by simp
ultimately have "((m\<^sup>S) \<circ> (k\<^sup>S))`(n) = m\<cdot>k\<cdot>n"
by simp
also from T1 A2 have "m\<cdot>k\<cdot>n = ((m\<cdot>k)\<^sup>S)`(n)"
using Int_ZF_2_5_L1 by simp
finally show "((m\<^sup>S) \<circ> (k\<^sup>S))`(n) = ((m\<cdot>k)\<^sup>S)`(n)"
by simp
qed
ultimately show "(m\<^sup>S) \<circ> (k\<^sup>S) = ((m\<cdot>k)\<^sup>S)"
using fun_extension_iff by simp
qed
text\<open>Embedding integers in slopes preserves order.\<close>
lemma (in int1) Int_ZF_2_5_L4: assumes A1: "m\<lsq>n"
shows "(m\<^sup>S) \<sim> (n\<^sup>S) \<or> (n\<^sup>S)\<fp>(\<fm>(m\<^sup>S)) \<in> \<S>\<^sub>+"
proof -
from A1 have "m\<^sup>S \<in> \<S>" and "n\<^sup>S \<in> \<S>"
using Int_ZF_2_L1A Int_ZF_2_5_L1 by auto
moreover from A1 have "\<forall>k\<in>\<int>\<^sub>+. (m\<^sup>S)`(k) \<lsq> (n\<^sup>S)`(k)"
using Int_ZF_1_3_L13B Int_ZF_2_L1A PositiveSet_def Int_ZF_2_5_L1
by simp
ultimately show ?thesis using Int_ZF_2_3_L4C
by simp
qed
text\<open>We aim at showing that $m\mapsto m^S$ is an injection modulo
the relation of almost equality. To do that we first show that if
$m^S$ has finite range, then $m=0$.\<close>
lemma (in int1) Int_ZF_2_5_L5:
assumes "m\<in>\<int>" and "m\<^sup>S \<in> FinRangeFunctions(\<int>,\<int>)"
shows "m=\<zero>"
using assms FinRangeFunctions_def Int_ZF_2_5_L1 AlmostHoms_def
func_imagedef Int_ZF_1_6_L8 by simp
text\<open>Embeddings of two integers are almost equal only if
the integers are equal.\<close>
lemma (in int1) Int_ZF_2_5_L6:
assumes A1: "m\<in>\<int>" "k\<in>\<int>" and A2: "(m\<^sup>S) \<sim> (k\<^sup>S)"
shows "m=k"
proof -
from A1 have T: "m\<rs>k \<in> \<int>" using Int_ZF_1_1_L5 by simp
from A1 have "(\<fm>(k\<^sup>S)) = ((\<rm>k)\<^sup>S)"
using Int_ZF_2_5_L3 by simp
then have "m\<^sup>S \<fp> (\<fm>(k\<^sup>S)) = (m\<^sup>S) \<fp> ((\<rm>k)\<^sup>S)"
by simp
with A1 have "m\<^sup>S \<fp> (\<fm>(k\<^sup>S)) = ((m\<rs>k)\<^sup>S)"
using Int_ZF_1_1_L4 Int_ZF_2_5_L3A by simp
moreover from A1 A2 have "m\<^sup>S \<fp> (\<fm>(k\<^sup>S)) \<in> FinRangeFunctions(\<int>,\<int>)"
using Int_ZF_2_5_L1 Int_ZF_2_1_L9D by simp
ultimately have "(m\<rs>k)\<^sup>S \<in> FinRangeFunctions(\<int>,\<int>)"
by simp
with T have "m\<rs>k = \<zero>" using Int_ZF_2_5_L5
by simp
with A1 show "m=k" by (rule Int_ZF_1_L15)
qed
text\<open>Embedding of $1$ is the identity slope and embedding of zero is a
finite range function.\<close>
lemma (in int1) Int_ZF_2_5_L7: shows
"\<one>\<^sup>S = id(\<int>)"
"\<zero>\<^sup>S \<in> FinRangeFunctions(\<int>,\<int>)"
proof -
have "id(\<int>) = {\<langle>x,x\<rangle>. x\<in>\<int>}"
using id_def by blast
then show "\<one>\<^sup>S = id(\<int>)" using Int_ZF_1_1_L4 by simp
have "{\<zero>\<^sup>S`(n). n\<in>\<int>} = {\<zero>\<cdot>n. n\<in>\<int>}"
using int_zero_one_are_int Int_ZF_2_5_L1 by simp
also have "\<dots> = {\<zero>}" using Int_ZF_1_1_L4 int_not_empty
by simp
finally have "{\<zero>\<^sup>S`(n). n\<in>\<int>} = {\<zero>}" by simp
then have "{\<zero>\<^sup>S`(n). n\<in>\<int>} \<in> Fin(\<int>)"
using int_zero_one_are_int Finite1_L16 by simp
moreover have "\<zero>\<^sup>S: \<int>\<rightarrow>\<int>"
using int_zero_one_are_int Int_ZF_2_5_L1 AlmostHoms_def
by simp
ultimately show "\<zero>\<^sup>S \<in> FinRangeFunctions(\<int>,\<int>)"
using Finite1_L19 by simp
qed
text\<open>A somewhat technical condition for a embedding of an integer
to be "less or equal" (in the sense apriopriate for slopes) than
the composition of a slope and another integer (embedding).\<close>
lemma (in int1) Int_ZF_2_5_L8:
assumes A1: "f \<in> \<S>" and A2: "N \<in> \<int>" "M \<in> \<int>" and
A3: "\<forall>n\<in>\<int>\<^sub>+. M\<cdot>n \<lsq> f`(N\<cdot>n)"
shows "M\<^sup>S \<sim> f\<circ>(N\<^sup>S) \<or> (f\<circ>(N\<^sup>S)) \<fp> (\<fm>(M\<^sup>S)) \<in> \<S>\<^sub>+"
proof -
from A1 A2 have "M\<^sup>S \<in> \<S>" "f\<circ>(N\<^sup>S) \<in> \<S>"
using Int_ZF_2_5_L1 Int_ZF_2_1_L11 by auto
moreover from A1 A2 A3 have "\<forall>n\<in>\<int>\<^sub>+. (M\<^sup>S)`(n) \<lsq> (f\<circ>(N\<^sup>S))`(n)"
using Int_ZF_2_5_L1 PositiveSet_def Int_ZF_2_1_L10
by simp
ultimately show ?thesis using Int_ZF_2_3_L4C
by simp
qed
text\<open>Another technical condition for the composition of a slope and
an integer (embedding) to be "less or equal" (in the sense apriopriate
for slopes) than embedding of another integer.\<close>
lemma (in int1) Int_ZF_2_5_L9:
assumes A1: "f \<in> \<S>" and A2: "N \<in> \<int>" "M \<in> \<int>" and
A3: "\<forall>n\<in>\<int>\<^sub>+. f`(N\<cdot>n) \<lsq> M\<cdot>n "
shows "f\<circ>(N\<^sup>S) \<sim> (M\<^sup>S) \<or> (M\<^sup>S) \<fp> (\<fm>(f\<circ>(N\<^sup>S))) \<in> \<S>\<^sub>+"
proof -
from A1 A2 have "f\<circ>(N\<^sup>S) \<in> \<S>" "M\<^sup>S \<in> \<S>"
using Int_ZF_2_5_L1 Int_ZF_2_1_L11 by auto
moreover from A1 A2 A3 have "\<forall>n\<in>\<int>\<^sub>+. (f\<circ>(N\<^sup>S))`(n) \<lsq> (M\<^sup>S)`(n) "
using Int_ZF_2_5_L1 PositiveSet_def Int_ZF_2_1_L10
by simp
ultimately show ?thesis using Int_ZF_2_3_L4C
by simp
qed
end |
module IntegerArith
import IntegerOrdering
import IntegerGroupTheory
{-
Strategy (<) type:
To handle case a (-a)
autogen a type which is either a<b or a>b and a proof of it.
match on the with of the generating function, so that you can have distinct cases of the inequality treated as creating different assumptions about the values a and b.
use this pattern matching structure in the definition of gcdBigInt itself.
Reflection shouldn't be needed, then, except maybe for gcdBigInt a 0.
We can implement this inequality type (which mirrors LTE for Nats) using recursion, even though we aren't given a fixed enumeration of Integer, because we have decEq.
decEq 5 3 = No ( _ 5 3 ) : Dec (5 = 3)
decEq 5 5 = Yes Refl : (5=5)
Although actually, a case expression on (decEq a b) may be enough instead of a dependent pattern match, because the case matched on itself has a proof, and one might be able to reuse that...
=======
Strategy rewrite case argument:
If the function you're trying to prove matches an equality has a case expression or equivalent in it, we can show that the function can be computed by assuming this has a particular value, and thus when we can take the case expression outside the equality and the cases being matched on include a proof of something which determines the value of the case argument, we can apply a function using this proof to obtain a proof that the case argument is the required value.
So if our case argument is (decLT (a*b) 0) then we can get a
(decLT (a*b) 0 = Yes pr)
from the (Yes pr : DecLT (a*b) 0) that one is pattern matching on when trying to generate the equality of gcdBigInt with its definition, by a function which manually constructs the proof from (pr) if Refl won't be recognized.
Once that (decLT (a*b) 0 = Yes pr) is used to rewrite the case argument of the equality-with-definition generator from (decLT (a*b) 0) to one of the cases (Yes _) of the case expressions in the gcdBigInt definition, we should be able to use compute to collapse the case expression and obtain the desired equality.
=======
Strategy recursion:
gcdBigInt can probably be reduced to a single case expression step followed by the usual gcd on nonnegative numbers, which by not having a case expression can be proved total just like gcd can. So gcdBigInt could be proved total simply by factorization.
-}
{-
-- IntegerArith.gcdBigInt is possibly not total due to recursive path IntegerArith.gcdBigInt
-- %reflection
total
gcdBigInt : Integer -> Integer -> Integer
gcdBigInt a 0 = a
gcdBigInt a b = if a*b<0 then gcdBigInt (abs a) (abs b) else assert_total (gcdBigInt b (modBigInt a b))
-}
{-
-- IntegerArith.gcdBigInt is possibly not total due to: IntegerArith.case block in gcdBigInt
total
gcdBigInt : Integer -> Integer -> Integer
gcdBigInt a 0 = a
gcdBigInt a b = case ( decLT (a*b) 0 ) of
Yes pr => gcdBigInt (abs a) (abs b)
otherwise => gcdBigInt b (modBigInt a b)
-}
{-
-- IntegerArith.gcdBigInt is possibly not total due to: with block in IntegerArith.gcdBigInt
total
gcdBigInt : Integer -> Integer -> Integer
gcdBigInt a 0 = a
gcdBigInt a b with ( decLT (a*b) 0 )
| Yes pr = gcdBigInt (abs a) (abs b)
| otherwise = gcdBigInt b (modBigInt a b)
-}
{-
%reflection
total
gcdType : Integer -> Integer -> Type
gcdType a 0 = ( gcdBigInt a 0 = a )
gcdType a b with (decEq a (-b))
| Yes pr =
| No pr =
-}
{-
gcdType a b = ( gcdBigInt a b = if a*b<0 then gcdBigInt (abs a) (abs b) else assert_total (gcdBigInt b (modBigInt a b)) )
-}
{-
gcdType a b = if a*b<0 then ( gcdBigInt a b = gcdBigInt (abs a) (abs b) ) else ( gcdBigInt a b = gcdBigInt b (modBigInt a b) )
-}
{-
gcddefBigInt : (a : Integer) -> (b : Integer) -> gcdType a b
gcddefBigInt a 0 = Refl
gcddefBigInt a b = if a*b<0 then the ( gcdBigInt a b = gcdBigInt (abs a) (abs b) ) gcddefBigIntZeroPr else gcddefBigIntPr -- believe_me "by definition"
where
gcddefBigIntZeroPr = ?gcddefBigIntZeroPr'
gcddefBigIntPr = ?gcddefBigIntPr'
-}
total
modBigInt_total : Integer -> Integer -> Integer
modBigInt_total a 0 = a
-- This is wrong too, in fact (div 5 (-2) = -3), so not even close.
-- I suspect we must define remainders as coset representatives or by long division.
modBigInt_total a b = a - div a b
{-
Would have said
modBigInt_total a b = prim__sremBigInt a b
but need to be able to prove modEqBigInt.
If we can't prove this, we might as well switch to a definition of div in.
-}
modEqRem : (a : Integer) -> (b : Integer) -> (nzpr : Not (b=0)) -> (a - div a b = prim__sremBigInt a b)
{-
modeqBigInt : (a : Integer) -> (b : Integer) -> (nzpr : Not (b=0))
-> mod a b + (div (a - mod a b) b)*b = a
-}
modeqBigInt : (a : Integer) -> (b : Integer) -> (nzpr : Not (b=0))
-> modBigInt_total a b + (div (a - modBigInt_total a b) b)*b = a
modeqBigInt a b pr = ?modeqBigIntHole
|
#' Choisit le jour du transit
#'
#' Permet de choisir un jour de semaine (ni samedi ni dimanche dans une plage
#' au milieu de la plage
#'
#' @param plage une plage
#' @param start_time l'heure
#'
#' @return un jour au format date
#' @export
choisir_jour_transit <- function(plage, start_time = "8:00:00") {
jours <- plage[1]:plage[2] |>
lubridate::as_date() |>
purrr::discard( ~ wday(.x) == 1 | wday(.x) == 7)
jours <- jours[ceiling(length(jours) / 2)]
return(lubridate::ymd_hms(paste(jours, start_time)))
}
#' Choisit un jour
#'
#' En prenant un GTFS en entrée, la fonction choisit parmi les jours de semaine
#' un jour qui existe pour tous les réseaux
#'
#' @param directory le répertoire où se trouve le GTFS
#'
#' @return une date
#' @export
choix_jour <- function(directory) {
les_gtfs <- list.files(directory, pattern = "*gtfs*|*GTFS*") |>
purrr::map( ~ tidytransit::read_gtfs(stringr::str_c(directory, .x, sep = "/")))
les_jours <- purrr::map_dfr(les_gtfs, ~ {
if (!("calendar" %in% names(.x)) ) {
tmp <- .x$calendar_dates |>
dplyr::filter(exception_type == 1) |>
dplyr::group_by(date) |>
dplyr::summarise(n = n()) |>
dplyr::filter(lubridate::wday(date) %in% 2:6) |>
dplyr::arrange(-n)
return(tmp |> dplyr::slice(1) |> dplyr::transmute(min = date, max = date))
}
return(data.frame(min = do.call(max, purrr::map(les_gtfs, ~ min(.x$calendar$start_date))),
max = do.call(min, purrr::map(les_gtfs, ~ max(.x$calendar$end_date)))))
})
print(les_jours)
les_jours <- les_jours |>
dplyr::summarise(min = max(min), max = min(max))
return(c(les_jours[[1, "min"]], les_jours[[1, "max"]]))
}
#' Plage de dates d'un GTFS
#'
#' Lit un GTFS et renvoie la plage de dates commune
#' aux différents réseaux du GTFS
#'
#' @param directory Répertoire du GTFS
#'
#' @return
#' @export
plage <- function(directory) {
les_gtfs <- list.files(directory, pattern = "*gtfs*|*GTFS*") |>
purrr::map( ~ tidytransit::read_gtfs(str_c(directory, .x, sep = "/")))
les_plages <- purrr::map_dfr(les_gtfs, get_plage_in_calendar) |>
dplyr::summarise(debut = max(min.date), fin = min(max.date)) |>
unlist()
if (les_plages["debut"] > les_plages["fin"]) {
stop("Les gtfs ne sont pas synchrones")
} else {
les_plages
}
}
# non exportée
get_plage_in_calendar <- function(gtfs) {
if(is.null(gtfs[["calendar"]])) {
plage <- data.frame(min.date = min(gtfs[["calendar_dates"]]$date, na.rm = TRUE),
max.date = max(gtfs[["calendar_dates"]]$date, na.rm = TRUE))
} else {
plage <- data.frame(min.date = min(gtfs[["calendar"]]$start_date, na.rm = TRUE),
max.date = max(gtfs[["calendar"]]$start_date, na.rm = TRUE))
}
}
|
#---
#title: "Rarefaction curves"
#author: "Tal Dahan-Meir"
#date: "18/08/2021"
#rarefaction_sample function written by Thomas James Ellis
#---
### load an output/output_with_colors file generated using the identity_function.r ###
csv=read.csv("data/output_with_colors.csv")
### functions for adjusted polynomials for rarefaction and the mean and the range of their inflection points ###
plot_poly_only=function (vector_of_genotypes = NULL,
add_to_existing_plot = FALSE,
my_y_limits_for_the_plot = NULL,
my_x_limits_for_the_plot = 0,
my_x2_limits_for_the_plot = 150,
n_dots = 200,
retrieve_0derivative = FALSE,
n_dots_derivative = 2000,
color_poly="blue")
{
my_x = 1:length(vector_of_genotypes)
my_y = rarefaction_sample(vector_genotypes)
xx=seq(my_x_limits_for_the_plot,my_x2_limits_for_the_plot,length.out=n_dots)
xx_derivative = seq(my_x_limits_for_the_plot,my_x2_limits_for_the_plot,length.out=n_dots_derivative)
fit = lm(my_y ~ -1 + my_x + I(my_x^2) )
if (!add_to_existing_plot)
{
plot(xx,predict(fit, data.frame(my_x=xx)),
type="l",
ylim = list(range(my_y), my_y_limits_for_the_plot)[[ifelse(is.null(my_y_limits_for_the_plot),1,2)]],
xlim = range(xx),
col = color_poly,
lwd=2)
} else {
lines(xx, predict(fit, data.frame(my_x=xx)),
col = color_poly,
lwd=2)
}
if(retrieve_0derivative) {
c1 = fit$coefficients[1]
c2 = fit$coefficients[2]
Deriv = eval(D(expression(-1 + xx_derivative*c1 + (c2*(xx_derivative^2))),'xx_derivative'))
lowest_Deriv = (which.min(abs(Deriv)) / n_dots_derivative) * my_x2_limits_for_the_plot
return(lowest_Deriv)
}
}
### plot rarefaction curve per year using the rarefaction_sample function (example 1984) ###
csv_1984=csv[grepl("1984",csv$Year),]
csv_1984=csv_1984[!grepl("Zavitan",csv_1984$Sample),]
vector_genotypes=csv_1984$DGG
vector_genotypes
length(unique(csv_1984$DGG))
xs = 1:length(csv_1984$Sample)
rarefaction_sample <- function(x){
n <- length(x)
subsamples <- sapply(
1:n,
function(i) length(
unique(
sample(x, i, replace = F)
)
)
)
return(subsamples)
}
dim(csv_1984)
rarefaction_sample(vector_genotypes)
lines_to_plot = 100
derivatives_zero = rep(-1,lines_to_plot)
pdf("1984_rarefaction.pdf",height=6,width=6)
derivatives_zero[1] = plot_poly_only(vector_of_genotypes = vector_genotypes,
add_to_existing_plot = FALSE,
color_poly = "#E19978",
my_x_limits_for_the_plot = 0,
my_x2_limits_for_the_plot = 120,
retrieve_0derivative = TRUE,
my_y_limits_for_the_plot = c(0,50))
for (i in 2:(lines_to_plot)){
derivatives_zero[i] = plot_poly_only(vector_of_genotypes = vector_genotypes,
add_to_existing_plot = TRUE,
my_x_limits_for_the_plot = 0,
my_x2_limits_for_the_plot = 120,
retrieve_0derivative = TRUE,
color_poly = "#E19978")
}
abline(h=length(unique(csv_1984$IGG)),col="black",lwd=2, lty=2)
abline(v=length(csv_1984$Sample),col="black",lwd=2, lty=2)
text(70,15,paste0("IGGs=",length(unique(csv_1984$IGG))))
text(70,10,paste0("N=",length(csv_1984$Sample)))
segments(min(derivatives_zero),45,max(derivatives_zero),45,
col="lightblue",lwd=5)
points(mean(derivatives_zero), y=45, pch=19, col="salmon")
dev.off()
|
% New SVD based initialization strategy for Non-negative Matrix Factorization
% Hanli Qiao
function [W, H] = Qiao_SVD_Init(Z, rank)
[u, s, v, p] = ChoosingR(Z);
W = abs(u(:,1:rank));
H = abs(s(1:rank,:)*v');
end
function [u, s, v, p] = ChoosingR(Z)
[u,s,v] = svd(Z);
sum1= sum(s);
sum2=sum(sum1);
extract=0;
p = 0;
dsum=0;
while(extract/sum2<0.90)
p = p + 1;
dsum=dsum+s(p,p);
extract=dsum;
end
end
|
module Program
import CommonTestingStuff
import Data.List
export
beforeString : String
beforeString = "before coop"
s150 : PrintString m => CanSleep m => (offset : Time) => Nat -> m String
s150 no = do
printTime offset "s150 proc \{show no}, first"
for 5 $ do
printTime offset "s150 proc \{show no}, before 1000"
sleepFor 1.seconds
printTime offset "s150 proc \{show no}, before 2000"
sleepFor 2.seconds
"long" <$ printTime offset "s150 proc \{show no}, last"
s55 : PrintString m => CanSleep m => (offset : Time) => Nat -> m String
s55 no = do
printTime offset " s55 proc \{show no}, first"
for 5 $ do
printTime offset " s55 proc \{show no}, before 350"
sleepFor 350.millis
printTime offset " s55 proc \{show no}, before 750"
sleepFor 750.millis
"mid 1" <$ printTime offset " s55 proc \{show no}, last"
s35 : PrintString m => CanSleep m => (offset : Time) => Nat -> m String
s35 no = do
printTime offset " s35 proc \{show no}, first"
for 5 $ do
printTime offset " s35 proc \{show no}, before 700"
sleepFor 700.millis
"short" <$ printTime offset " s35 proc \{show no}, last"
s77 : PrintString m => CanSleep m => (offset : Time) => Nat -> m String
s77 no = do
printTime offset " s77 proc \{show no}, first"
for 5 $ do
printTime offset " s77 proc \{show no}, before 1350"
sleepFor 1350.millis
sleepFor 950.millis
"mid 2" <$ printTime offset " s77 proc \{show no}, last"
export
program : PrintString m => CanSleep m => Zippable m => Alternative m => m Unit
program = do
offset <- currentTime
printTime offset "start"
res <- choiceMap
( \(comp, n) => choiceMap (\k => comp k <&> (++ ", var #\{show k}")) $ take n [1..n] )
[(s150, 1), (s55, 2), (s35, 3), (s77, 0)]
printTime offset "top: \{res}"
printTime offset "end"
|
------------------------------------------------------------------------
-- An example that uses natural numbers as names, implemented using
-- the coinductive definition of bisimilarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
module Bisimilarity.CCS.Examples.Natural-numbers where
open import Equality.Propositional
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Prelude.Size
open import Bijection equality-with-J using (_↔_)
open import Equality.Decision-procedures equality-with-J
open import Fin equality-with-J
open import Function-universe equality-with-J as F
hiding (id; _∘_; Distinct↔≢)
open import Nat equality-with-J hiding (Distinct)
open import Bisimilarity.CCS
import Bisimilarity.Equational-reasoning-instances
open import Bisimilarity.CCS.Examples
open import Equational-reasoning
open import Labelled-transition-system.CCS ℕ
open import Bisimilarity CCS
module _ (μ : Action) where
-- Two processes that are strongly bisimilar.
P : ∀ {i} → ℕ → Proc i
P n = Restricted n ∣ (μ · λ { .force → P (1 + n) })
Q : ∀ {i} → Proc i
Q = μ · λ { .force → Q }
P∼Q : ∀ {i n} → [ i ] P n ∼ Q
P∼Q {n = n} =
P n ∼⟨ Restricted∼∅ ∣-cong (refl ·-cong λ { .force → P∼Q }) ⟩
∅ ∣ Q ∼⟨ ∣-left-identity ⟩■
Q
-- Q is not finite.
Q-infinite : ¬ Finite Q
Q-infinite (action f) = Q-infinite f
-- However, Q is regular.
Q-regular : Regular Q
Q-regular = 1 , (λ _ → Q) , (fzero ,_) ∘ lemma
where
lemma : ∀ {P} → Subprocess P Q → Equal ∞ P Q
lemma (refl eq) = eq
lemma (action sub) = lemma sub
-- The processes in the family P are not finite.
P-infinite : ∀ {n} → ¬ Finite (P n)
P-infinite (_ ∣ action f) = P-infinite f
-- Furthermore they are irregular.
P-irregular : ∀ {n} → ¬ Regular (P n)
P-irregular (k , Qs , hyp) = irregular′ k hyp
where
Regular′ : ℕ → ∀ k → (Fin k → Proc ∞) → Type
Regular′ n k Qs =
∀ {Q} → Subprocess Q (P n) →
∃ λ (i : Fin k) → Equal ∞ Q (Qs i)
irregular′ : ∀ {n} k {Qs} → ¬ Regular′ n k Qs
irregular′ {n} zero {Qs} =
Regular′ n zero Qs ↝⟨ _$ refl (Proc-refl _) ⟩
(∃ λ (i : Fin zero) → _) ↝⟨ proj₁ ⟩□
⊥ □
irregular′ {n} (suc k) {Qs} =
Regular′ n (suc k) Qs ↝⟨ lemma₂ ⟩
(∃ λ Qs′ → Regular′ (suc n) k Qs′) ↝⟨ irregular′ k ∘ proj₂ ⟩□
⊥ □
where
lemma₁ :
∀ {Q} m {n} → Subprocess Q (P (1 + m + n)) → ¬ Equal ∞ Q (P n)
lemma₁ m (par-right (action sub)) eq = lemma₁ (suc m) sub eq
lemma₁ m {n} (refl (⟨ν refl ⟩ _ ∣ _)) (⟨ν suc[m+n]≡n ⟩ _ ∣ _) =
≢1+ _ (n ≡⟨ sym suc[m+n]≡n ⟩
suc (m + n) ≡⟨ cong suc (+-comm m) ⟩∎
suc (n + m) ∎)
lemma₁ _ (par-left (refl ())) (_ ∣ _)
lemma₁ _ (par-left (restriction (refl ()))) (_ ∣ _)
lemma₁ _ (par-left (restriction (action (refl ())))) (_ ∣ _)
lemma₁ _ (par-right (refl p)) q
with Proc-trans (Proc-sym p) q
... | ()
lemma₂ : ∀ {n k Qs} →
Regular′ n (suc k) Qs →
∃ λ Qs′ → Regular′ (suc n) k Qs′
lemma₂ {n} {k} {Qs} reg =
let i , Pn≡Qsi = reg (refl (Proc-refl _))
Fin↔ = Fin↔Fin+≢ i
Qs′ =
Fin k ↔⟨ Fin↔ ⟩
(∃ λ (j : Fin (suc k)) → Distinct j i) ↝⟨ Qs ∘ proj₁ ⟩□
Proc ∞ □
in
Qs′ , λ {Q} →
Subprocess Q (P (1 + n)) ↝⟨ (λ sub → reg (par-right (action sub)) , lemma₁ 0 sub) ⟩
(∃ λ (j : Fin (suc k)) → Equal ∞ Q (Qs j)) ×
¬ Equal ∞ Q (P n) ↝⟨ (λ { ((j , Q≡Qsj) , Q≢Pn) →
( j
, (case j Fin.≟ i of λ where
(inj₁ refl) → ⊥-elim $
Q≢Pn (Proc-trans Q≡Qsj (Proc-sym Pn≡Qsi))
(inj₂ j≢i) → _⇔_.from (Distinct↔≢ _) j≢i)
)
, Q≡Qsj }) ⟩
(∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) →
Equal ∞ Q (Qs (proj₁ j))) ↝⟨ ∃-cong (λ _ → ≡⇒↝ _ $ cong (λ j → Equal ∞ Q (Qs (proj₁ j))) $ sym $
_↔_.right-inverse-of Fin↔ _) ⟩
(∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) →
Equal ∞ Q (Qs (proj₁ (_↔_.to Fin↔ (_↔_.from Fin↔ j))))) ↔⟨⟩
(∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) →
Equal ∞ Q (Qs′ (_↔_.from Fin↔ j))) ↝⟨ Σ-cong (inverse Fin↔) (λ _ → F.id) ⟩□
(∃ λ (j : Fin k) → Equal ∞ Q (Qs′ j)) □
|
[STATEMENT]
lemma converse_to_prod_swap:
"R\<inverse> = prod.swap ` R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. R\<inverse> = prod.swap ` R
[PROOF STEP]
by auto |
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
s : Set α
⊢ mulSupport f = s ↔ (∀ (x : α), x ∈ s → f x ≠ 1) ∧ ∀ (x : α), ¬x ∈ s → f x = 1
[PROOFSTEP]
simp (config := { contextual := true }) only [ext_iff, mem_mulSupport, ne_eq, iff_def, not_imp_comm, and_comm,
forall_and]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
s : Set α
⊢ Disjoint (mulSupport f) s ↔ EqOn f 1 s
[PROOFSTEP]
simp_rw [← subset_compl_iff_disjoint_right, mulSupport_subset_iff', not_mem_compl_iff, EqOn, Pi.one_apply]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
s : Set α
⊢ Disjoint s (mulSupport f) ↔ EqOn f 1 s
[PROOFSTEP]
rw [disjoint_comm, mulSupport_disjoint_iff]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
⊢ mulSupport f = ∅ ↔ f = 1
[PROOFSTEP]
simp_rw [← subset_empty_iff, mulSupport_subset_iff', funext_iff]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
⊢ (∀ (x : α), ¬x ∈ ∅ → f x = 1) ↔ ∀ (a : α), f a = OfNat.ofNat 1 a
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
⊢ Set.Nonempty (mulSupport f) ↔ f ≠ 1
[PROOFSTEP]
rw [nonempty_iff_ne_empty, Ne.def, mulSupport_eq_empty_iff]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
⊢ range f ⊆ insert 1 (f '' mulSupport f)
[PROOFSTEP]
simpa only [range_subset_iff, mem_insert_iff, or_iff_not_imp_left] using fun x (hx : x ∈ mulSupport f) =>
mem_image_of_mem f hx
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
c : M
hc : c ≠ 1
⊢ (mulSupport fun x => c) = univ
[PROOFSTEP]
ext x
[GOAL]
case h
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
c : M
hc : c ≠ 1
x : α
⊢ (x ∈ mulSupport fun x => c) ↔ x ∈ univ
[PROOFSTEP]
simp [hc]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
op : M → N → P
op1 : op 1 1 = 1
f : α → M
g : α → N
x : α
hx : x ∈ mulSupport fun x => op (f x) (g x)
hf : f x = 1
hg : g x = 1
⊢ (fun x => op (f x) (g x)) x = 1
[PROOFSTEP]
simp only [hf, hg, op1]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝⁴ : One M
inst✝³ : One N
inst✝² : One P
inst✝¹ : ConditionallyCompleteLattice M
inst✝ : Nonempty ι
f : ι → α → M
⊢ (mulSupport fun x => ⨆ (i : ι), f i x) ⊆ ⋃ (i : ι), mulSupport (f i)
[PROOFSTEP]
rw [mulSupport_subset_iff']
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝⁴ : One M
inst✝³ : One N
inst✝² : One P
inst✝¹ : ConditionallyCompleteLattice M
inst✝ : Nonempty ι
f : ι → α → M
⊢ ∀ (x : α), ¬x ∈ ⋃ (i : ι), mulSupport (f i) → ⨆ (i : ι), f i x = 1
[PROOFSTEP]
simp only [mem_iUnion, not_exists, nmem_mulSupport]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝⁴ : One M
inst✝³ : One N
inst✝² : One P
inst✝¹ : ConditionallyCompleteLattice M
inst✝ : Nonempty ι
f : ι → α → M
⊢ ∀ (x : α), (∀ (x_1 : ι), f x_1 x = 1) → ⨆ (i : ι), f i x = 1
[PROOFSTEP]
intro x hx
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝⁴ : One M
inst✝³ : One N
inst✝² : One P
inst✝¹ : ConditionallyCompleteLattice M
inst✝ : Nonempty ι
f : ι → α → M
x : α
hx : ∀ (x_1 : ι), f x_1 x = 1
⊢ ⨆ (i : ι), f i x = 1
[PROOFSTEP]
simp only [hx, ciSup_const]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
g : M → N
hg : g 1 = 1
f : α → M
x : α
h : f x = 1
⊢ (g ∘ f) x = 1
[PROOFSTEP]
simp only [(· ∘ ·), *]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
g : M → N
f : α → M
hg : ∀ {x : M}, x ∈ range f → (g x = 1 ↔ x = 1)
x : α
⊢ (g ∘ f) x = 1 ↔ f x = 1
[PROOFSTEP]
rw [Function.comp, hg (mem_range_self x)]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M
g : α → N
x : α
⊢ (x ∈ mulSupport fun x => (f x, g x)) ↔ x ∈ mulSupport f ∪ mulSupport g
[PROOFSTEP]
simp only [mulSupport, not_and_or, mem_union, mem_setOf_eq, Prod.mk_eq_one, Ne.def]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α → M × N
⊢ mulSupport f = (mulSupport fun x => (f x).fst) ∪ mulSupport fun x => (f x).snd
[PROOFSTEP]
simp only [← mulSupport_prod_mk, Prod.mk.eta]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : One M
inst✝¹ : One N
inst✝ : One P
f : α × β → M
a : α
x : β
hx : x ∈ mulSupport fun b => f (a, b)
⊢ (a, x) ∈ mulSupport f ∧ (a, x).snd = x
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : Monoid M
f : α → M
n : ℕ
⊢ (mulSupport fun x => f x ^ n) ⊆ mulSupport f
[PROOFSTEP]
induction' n with n hfn
[GOAL]
case zero
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : Monoid M
f : α → M
⊢ (mulSupport fun x => f x ^ Nat.zero) ⊆ mulSupport f
[PROOFSTEP]
simp [pow_zero, mulSupport_one]
[GOAL]
case succ
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : Monoid M
f : α → M
n : ℕ
hfn : (mulSupport fun x => f x ^ n) ⊆ mulSupport f
⊢ (mulSupport fun x => f x ^ Nat.succ n) ⊆ mulSupport f
[PROOFSTEP]
simpa only [pow_succ] using (mulSupport_mul f _).trans (union_subset Subset.rfl hfn)
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : DivisionMonoid G
f g : α → G
⊢ (fun a b => a * b⁻¹) 1 1 = 1
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : MulZeroClass R
f g : α → R
x : α
hfg : x ∈ support fun x => f x * g x
hf : f x = 0
⊢ (fun x => f x * g x) x = 0
[PROOFSTEP]
simp only [hf, zero_mul]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : MulZeroClass R
f g : α → R
x : α
hfg : x ∈ support fun x => f x * g x
hg : g x = 0
⊢ (fun x => f x * g x) x = 0
[PROOFSTEP]
simp only [hg, mul_zero]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : AddMonoid A
inst✝¹ : Monoid B
inst✝ : DistribMulAction B A
b : B
f : α → A
x : α
hbf : x ∈ support (b • f)
hf : f x = 0
⊢ (b • f) x = 0
[PROOFSTEP]
rw [Pi.smul_apply, hf, smul_zero]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : Zero M
inst✝¹ : Zero β
inst✝ : SMulWithZero M β
f : α → M
g : α → β
x : α
hfg : x ∈ support (f • g)
hf : f x = 0
⊢ (f • g) x = 0
[PROOFSTEP]
rw [Pi.smul_apply', hf, zero_smul]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : NoZeroSMulDivisors R M
c : R
g : α → M
hc : c ≠ 0
x : α
⊢ x ∈ support (c • g) ↔ x ∈ support g
[PROOFSTEP]
simp only [hc, mem_support, Pi.smul_apply, Ne.def, smul_eq_zero, false_or_iff]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : GroupWithZero G₀
f g : α → G₀
⊢ (support fun x => f x / g x) = support f ∩ support g
[PROOFSTEP]
simp [div_eq_mul_inv]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : CommMonoid M
s : Finset α
f : α → β → M
⊢ (mulSupport fun x => ∏ i in s, f i x) ⊆ ⋃ (i : α) (_ : i ∈ s), mulSupport (f i)
[PROOFSTEP]
rw [mulSupport_subset_iff']
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : CommMonoid M
s : Finset α
f : α → β → M
⊢ ∀ (x : β), ¬x ∈ ⋃ (i : α) (_ : i ∈ s), mulSupport (f i) → ∏ i in s, f i x = 1
[PROOFSTEP]
simp only [mem_iUnion, not_exists, nmem_mulSupport]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝ : CommMonoid M
s : Finset α
f : α → β → M
⊢ ∀ (x : β), (∀ (x_1 : α), x_1 ∈ s → f x_1 x = 1) → ∏ i in s, f i x = 1
[PROOFSTEP]
exact fun x => Finset.prod_eq_one
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝² : CommMonoidWithZero A
inst✝¹ : NoZeroDivisors A
inst✝ : Nontrivial A
s : Finset α
f : α → β → A
x : β
⊢ (x ∈ support fun x => ∏ i in s, f i x) ↔ x ∈ ⋂ (i : α) (_ : i ∈ s), support (f i)
[PROOFSTEP]
simp [support, Ne.def, Finset.prod_eq_zero_iff, mem_setOf_eq, Set.mem_iInter, not_exists]
[GOAL]
α : Type u_1
β : Type u_2
A : Type u_3
B : Type u_4
M : Type u_5
N : Type u_6
P : Type u_7
R : Type u_8
S : Type u_9
G : Type u_10
M₀ : Type u_11
G₀ : Type u_12
ι : Sort u_13
inst✝¹ : One R
inst✝ : AddGroup R
f : α → R
⊢ mulSupport (1 - f) = support f
[PROOFSTEP]
rw [sub_eq_add_neg, mulSupport_one_add', support_neg']
[GOAL]
α : Type u_1
β : Type u_2
M : Type u_3
inst✝ : One M
f : α → M
s : Set β
g : β → α
⊢ g '' s ∩ mulSupport f = g '' (s ∩ mulSupport (f ∘ g))
[PROOFSTEP]
rw [mulSupport_comp_eq_preimage f g, image_inter_preimage]
[GOAL]
A : Type u_1
B : Type u_2
inst✝¹ : DecidableEq A
inst✝ : One B
a : A
b : B
⊢ mulSupport (mulSingle a 1) = ∅
[PROOFSTEP]
simp
[GOAL]
A : Type u_1
B : Type u_2
inst✝¹ : DecidableEq A
inst✝ : One B
a : A
b : B
h : b ≠ 1
x : A
hx : x = a
⊢ x ∈ mulSupport (mulSingle a b)
[PROOFSTEP]
rwa [mem_mulSupport, hx, mulSingle_eq_same]
[GOAL]
A : Type u_1
B : Type u_2
inst✝² : DecidableEq A
inst✝¹ : One B
a : A
b : B
inst✝ : DecidableEq B
⊢ mulSupport (mulSingle a b) = if b = 1 then ∅ else {a}
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
A : Type u_1
B : Type u_2
inst✝² : DecidableEq A
inst✝¹ : One B
a : A
b : B
inst✝ : DecidableEq B
h : b = 1
⊢ mulSupport (mulSingle a b) = ∅
[PROOFSTEP]
simp [h]
[GOAL]
case neg
A : Type u_1
B : Type u_2
inst✝² : DecidableEq A
inst✝¹ : One B
a : A
b : B
inst✝ : DecidableEq B
h : ¬b = 1
⊢ mulSupport (mulSingle a b) = {a}
[PROOFSTEP]
simp [h]
[GOAL]
A : Type u_1
B : Type u_2
inst✝¹ : DecidableEq A
inst✝ : One B
a : A
b b' : B
hb : b ≠ 1
hb' : b' ≠ 1
i j : A
⊢ Disjoint (mulSupport (mulSingle i b)) (mulSupport (mulSingle j b')) ↔ i ≠ j
[PROOFSTEP]
rw [mulSupport_mulSingle_of_ne hb, mulSupport_mulSingle_of_ne hb', disjoint_singleton]
|
[STATEMENT]
lemma Prop3: "Op A \<longleftrightarrow> \<bullet>\<^bold>\<midarrow>A \<^bold>\<approx> \<^bold>\<bottom>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. [\<^bold>\<turnstile> \<lambda>w. \<I> A w = A w] = [\<^bold>\<turnstile> \<lambda>w. op_det\<^sup>c (\<^bold>\<midarrow>A) w = \<^bold>\<bottom> w]
[PROOF STEP]
by (metis Op_Bzero dual_def dual_symm) |
% OP_GRADSYMV_N_U: assemble the matrix A = [a(i,j)], a(i,j) = (epsilon (gradsym v n)_j, u_i), with n the normal vector.
%
% mat = op_gradsymv_n_u (spu, spv, msh, epsilon);
% [rows, cols, values] = op_gradsymv_n_u (spu, spv, msh, epsilon);
%
% INPUT:
%
% spu: structure representing the space of trial functions (see sp_scalar/sp_evaluate_col)
% spv: structure representing the space of test functions (see sp_scalar/sp_evaluate_col)
% msh: structure containing the domain partition and the quadrature rule for the boundary,
% since it must contain the normal vector (see msh_cartesian/msh_eval_boundary_side)
% epsilon: coefficient
%
% OUTPUT:
%
% mat: assembled matrix
% rows: row indices of the nonzero entries
% cols: column indices of the nonzero entries
% values: values of the nonzero entries
%
% Copyright (C) 2014 Adriano Cortes
% Copyright (C) 2014, 2017, 2020 Rafael Vazquez
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
function varargout = op_gradsymv_n_u (spu, spv, msh, coeff)
gradv = reshape (spv.shape_function_gradients, spv.ncomp, [], ...
msh.nqn, spv.nsh_max, msh.nel);
ndim = size (gradv, 2);
shpu = reshape (spu.shape_functions, spu.ncomp, msh.nqn, spu.nsh_max, msh.nel);
rows = zeros (msh.nel * spu.nsh_max * spv.nsh_max, 1);
cols = zeros (msh.nel * spu.nsh_max * spv.nsh_max, 1);
values = zeros (msh.nel * spu.nsh_max * spv.nsh_max, 1);
jacdet_weights = msh.jacdet .* msh.quad_weights .* coeff;
ncounter = 0;
for iel = 1:msh.nel
if (all (msh.jacdet(:,iel)))
gradv_iel = gradv(:,:,:,:,iel);
normal_iel = reshape (msh.normal(:,:,iel), [1, ndim, msh.nqn]);
%Symmetrize gradv
gradv_iel = 0.5*(gradv_iel + permute (gradv_iel, [2 1 3 4]));
gradv_n = reshape (sum (bsxfun (@times, gradv_iel, normal_iel), 2), spv.ncomp, msh.nqn, spv.nsh_max, 1);
shpu_iel = reshape (shpu(:, :, :, iel), spu.ncomp, msh.nqn, 1, spu.nsh_max);
jacdet_iel = reshape (jacdet_weights(:,iel), [1,msh.nqn,1,1]);
gradv_n_times_jw = bsxfun (@times, jacdet_iel, gradv_n);
tmp1 = sum (bsxfun (@times, gradv_n_times_jw, shpu_iel), 1);
elementary_values = reshape (sum (tmp1, 2), spv.nsh_max, spu.nsh_max);
[rows_loc, cols_loc] = ndgrid (spv.connectivity(:,iel), spu.connectivity(:,iel));
indices = rows_loc & cols_loc;
rows(ncounter+(1:spu.nsh(iel)*spv.nsh(iel))) = rows_loc(indices);
cols(ncounter+(1:spu.nsh(iel)*spv.nsh(iel))) = cols_loc(indices);
values(ncounter+(1:spu.nsh(iel)*spv.nsh(iel))) = elementary_values(indices);
ncounter = ncounter + spu.nsh(iel)*spv.nsh(iel);
else
warning ('geopdes:jacdet_zero_at_quad_node', 'op_gradv_n_u: singular map in element number %d', iel)
end
end
if (nargout == 1 || nargout == 0)
varargout{1} = sparse (rows, cols, values, spv.ndof, spu.ndof);
elseif (nargout == 3)
varargout{1} = rows;
varargout{2} = cols;
varargout{3} = values;
else
error ('op_gradv_n_u: wrong number of output arguments')
end
end
|
lemmas tendsto_of_real [tendsto_intros] = bounded_linear.tendsto [OF bounded_linear_of_real] |
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details
#######################################################################################
# AltiVec 4-way 32-bit float instructions
# shuffle operations
Class(vbinop_4x32f_av, vbinop_av, rec(
v := self >> 4,
#ctype := self >> "float",
)); #Class added for AltiVec
Class(vunpacklo_4x32f_av, vbinop_4x32f_av, rec(
altivec := "vec_mergeh",
semantic := (in1, in2, p) -> unpacklo(in1, in2, 4, 1)
)); #Class added for AltiVec
Class(vunpackhi_4x32f_av, vbinop_4x32f_av, rec(
altivec := "vec_mergel",
semantic := (in1, in2, p) -> unpackhi(in1, in2, 4, 1)
)); #Class added for AltiVec
# binary instructions
vunpacklo_4x32f.altivec := "vec_mergel";
vunpackhi_4x32f.altivec := "vec_mergeh";
Class(vperm_4x32f, vbinop_4x32f_av, rec(
altivec := "vec_perm",
semantic := (in1, in2, p) -> vpermop(in1, in2, p, 4),
params := self >> sparams(4,8),
permparams := aperm
));
# unary instructions
Class(vuperm_4x32f, vunbinop_av, rec(
binop := vperm_4x32f
));
#######################################################################################
# AltiVec 8-way 16-bit integer instructions
# binary instructions
vunpacklo_8x16i.altivec := "vec_mergel";
vunpackhi_8x16i.altivec := "vec_mergeh";
Class(vperm_8x16i, VecExp_8.binary(), rec(
altivec := "vec_perm",
semantic := (in1, in2, p) -> vpermop(in1, in2, p, 8),
params := self >> sparams(8,16),
permparams := aperm
));
# unary instructions
Class(vuperm_8x16i, VecExp_8.unaryFromBinop(vperm_8x16i));
#######################################################################################
# AltiVec 16-way 8-bit integer instructions
# binary instructions
vunpacklo_16x8i.altivec := "vec_mergel";
vunpackhi_16x8i.altivec := "vec_mergeh";
Class(vperm_16x8i, VecExp_8.binary(), rec(
altivec := "vec_perm",
semantic := (in1, in2, p) -> vpermop(in1, in2, p, 16),
params := self >> sparams(16,32),
permparams := aperm
));
# unary instructions
Class(vuperm_16x8i, VecExp_8.unaryFromBinop(vperm_16x8i));
|
From iris.algebra Require Import lib.frac_auth numbers auth.
From iris.proofmode Require Import tactics.
From iris.program_logic Require Export total_adequacy.
From iris.heap_lang Require Export adequacy.
From iris.heap_lang Require Import proofmode notation.
From iris.prelude Require Import options.
Definition heap_total Σ `{!heapPreG Σ} s e σ φ :
(∀ `{!heapG Σ}, ⊢ inv_heap_inv -∗ WP e @ s; ⊤ [{ v, ⌜φ v⌝ }]) →
sn erased_step ([e], σ).
Proof.
intros Hwp; eapply (twp_total' _ _); iIntros (??) "".
iMod (gen_heap_init σ.(heap)) as (?) "[Hh _]".
iMod (inv_heap_init loc (option val)) as (?) ">Hi".
iMod (proph_map_init [] σ.(used_proph_id)) as (?) "Hp".
iMod (own_alloc (●F O ⋅ ◯F 0)) as (γ) "[Hγ Hγ']";
first by apply auth_both_valid_discrete.
iModIntro.
set (hG := (HeapG _ _ _ _ _ _ _ γ)).
iExists
(λ σ ns κs _, (cred_interp ns ∗ gen_heap_interp σ.(heap) ∗ proph_map_interp κs σ.(used_proph_id))%I),
(λ _, True%I), _; iFrame.
iFrame.
iSplitL "Hγ'".
{ iExists 1%Qp. iFrame. }
iApply (Hwp (HeapG _ _ _ _ _ _ _ _)). done.
Qed.
|
function res = sensors(this, type, newsens)
% Sets and gets sensor fields for EEG and MEG
% returns empty matrix if no sensors are defined.
% FORMAT res = sensors(this, type, newsens)
% type - 'EEG' or 'MEG'
% _______________________________________________________________________
% Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging
% Vladimir Litvak
% $Id: sensors.m 6829 2016-07-07 10:16:46Z vladimir $
if nargin<2
error('Sensor type (EEG or MEG) must be specified');
end
switch lower(type)
case 'eeg'
if nargin < 3
if isfield(this.sensors, 'eeg')
res = this.sensors.eeg;
else
res = [];
end
else
this.sensors(1).eeg = newsens;
res = check(this);
end
case 'meg'
if nargin < 3
if isfield(this.sensors, 'meg')
res = this.sensors.meg;
else
res = [];
end
else
this.sensors(1).meg = newsens;
res = check(this);
end
case 'src'
if nargin < 3
if isfield(this.sensors, 'src')
res = this.sensors.src;
else
res = [];
end
else
this.sensors(1).src = newsens;
res = check(this);
end
otherwise
error('Unsupported sensor type');
end
if nargin < 3 && ~isempty(res) && ismember(lower(type), {'eeg', 'meg'}) && this.montage.Mind > 0
sens = res;
montage = this.montage.M(this.montage.Mind);
if ~isempty(intersect(sens.label, montage.labelorg))
sensmontage = montage;
[sel1, sel2] = spm_match_str(sens.label, sensmontage.labelorg);
sensmontage.labelorg = sensmontage.labelorg(sel2);
sensmontage.tra = sensmontage.tra(:, sel2);
selempty = find(all(sensmontage.tra == 0, 2));
sensmontage.tra(selempty, :) = [];
sensmontage.labelnew(selempty) = [];
if isfield(sensmontage, 'chantypeorg')
sensmontage.chantypeorg = sensmontage.chantypeorg(sel2);
end
if isfield(sensmontage, 'chanunitorg')
sensmontage.chanunitorg = sensmontage.chanunitorg(sel2);
end
if isfield(sensmontage, 'chantypenew')
sensmontage.chantypenew(selempty) = [];
end
if isfield(sensmontage, 'chanunitnew')
sensmontage.chanunitnew(selempty) = [];
end
chanunitorig = sens.chanunit(sel1);
chantypeorig = sens.chantype(sel1);
labelorg = sens.label;
keepunused = 'no'; % not sure if this is good for all cases
sens = ft_apply_montage(sens, sensmontage, 'keepunused', keepunused);
if strcmpi(type, 'MEG')
if isfield(sens, 'balance') && ~isequal(sens.balance.current, 'none')
balance = ft_apply_montage(getfield(sens.balance, sens.balance.current), sensmontage, 'keepunused', keepunused);
else
balance = sensmontage;
end
sens.balance.custom = balance;
sens.balance.current = 'custom';
end
% If all the original channels contributing to a new channel have
% the same units, transfer them to the new channel. This might be
% wrong if the montage itself changes the units by scaling the data.
if isfield(sens, 'chanunit')
chanunit = sens.chanunit;
else
chanunit = repmat({'unknown'}, numel(sens.label), 1);
end
if isfield(sens, 'chantype')
chantype = sens.chantype;
else
chantype = repmat({'unknown'}, numel(sens.label), 1);
end
for j = 1:numel(sens.label)
k = strmatch(sens.label{j}, sensmontage.labelnew, 'exact');
if ~isempty(k)
if isequal(chanunit{j}, 'unknown')
unit = unique(chanunitorig(~~abs(sensmontage.tra(k, :))));
if numel(unit)==1
chanunit(j) = unit;
elseif strcmpi(type, 'MEG')
chanunit{j} = 'T';
else
chanunit{j} = 'V';
end
end
if isequal(chantype{j}, 'unknown')
ctype = unique(chantypeorig(~~abs(sensmontage.tra(k, :))));
if numel(ctype)==1
chantype(j) = ctype;
elseif strcmpi(type, 'MEG')
chantype{j} = 'megmag';
else
chantype{j} = 'eeg';
end
end
else %channel was not in the montage, but just copied
k = strmatch(sens.label{j}, labelorg, 'exact');
if isequal(chanunit{j}, 'unknown')
chanunit(j) = chanunitorig(k);
end
if isequal(chantype{j}, 'unknown')
chantype(j) = chantypeorig(k);
end
end
end
sens.chanunit = chanunit;
sens.chantype = chantype;
end
if strcmpi(type, 'MEG')
res = ft_datatype_sens(sens, 'amplitude', 'T', 'distance', 'mm');
else
res = ft_datatype_sens(sens, 'amplitude', 'V', 'distance', 'mm');
end
end
|
function hf_out = lhs_operation_joint(hf, samplesf, reg_filter, feature_reg, init_samplef, XH, init_hf, proj_reg)
% This is the left-hand-side operation in Conjugate Gradient
hf_out = cell(size(hf));
% Extract projection matrix and filter separately
P = cellfun(@real, hf(2,1,:), 'uniformoutput',false);
hf = hf(1,1,:);
% size of the padding
num_features = length(hf);
output_sz = [size(hf{1},1), 2*size(hf{1},2)-1];
% Compute the operation corresponding to the data term in the optimization
% (blockwise matrix multiplications)
%implements: A' diag(sample_weights) A f
% sum over all features in each block
sh_cell = cell(1,1,num_features);
for k = 1:num_features
sh_cell{k} = mtimesx(samplesf{k}, permute(hf{k}, [3 4 1 2]), 'speed');
end
% sum over all feature blocks
sh = sh_cell{1}; % assumes the feature with the highest resolution is first
pad_sz = cell(1,1,num_features);
for k = 2:num_features
pad_sz{k} = (output_sz - [size(hf{k},1), 2*size(hf{k},2)-1]) / 2;
sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) = ...
sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) + sh_cell{k};
end
% weight all the samples
% sh = bsxfun(@times,sample_weights,sh);
% multiply with the transpose
hf_out1 = cell(1,1,num_features);
hf_out1{1} = permute(conj(mtimesx(sh, 'C', samplesf{1}, 'speed')), [3 4 2 1]);
for k = 2:num_features
hf_out1{k} = permute(conj(mtimesx(sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end), 'C', samplesf{k}, 'speed')), [3 4 2 1]);
end
% compute the operation corresponding to the regularization term (convolve
% each feature dimension with the DFT of w, and the tramsposed operation)
% add the regularization part
% hf_conv = cell(1,1,num_features);
for k = 1:num_features
reg_pad = min(size(reg_filter{k},2)-1, size(hf{k},2)-1);
% add part needed for convolution
hf_conv = cat(2, hf{k}, conj(rot90(hf{k}(:, end-reg_pad:end-1, :), 2)));
% do first convolution
hf_conv = convn(hf_conv, reg_filter{k});
% do final convolution and put toghether result
hf_out1{k} = hf_out1{k} + convn(hf_conv(:,1:end-reg_pad,:), reg_filter{k}, 'valid');
end
% Stuff related to the projection matrix
% Set the filter to the current one instead (test)
% init_hf = cellfun(@(hf) permute(hf, [3 4 1 2]), hf, 'uniformoutput', false);
% B * P
BP_cell = cell(1,1,num_features);
for k = 1:num_features
BP_cell{k} = mtimesx(mtimesx(init_samplef{k}, P{k}, 'speed'), init_hf{k}, 'speed');
end
BP = BP_cell{1};
for k = 2:num_features
BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) = ...
BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) + BP_cell{k};
end
% multiply with the transpose: A^H * BP
hf_out{1,1,1} = hf_out1{1} + permute(bsxfun(@times, BP, conj(samplesf{1})), [3 4 2 1]);
% B^H * BP
fBP = cell(1,1,num_features);
fBP{1} = reshape(bsxfun(@times, conj(init_hf{1}), BP), size(init_hf{1},1), []).';
% Compute proj matrix part: B^H * A_m * f
shBP = cell(1,1,num_features);
shBP{1} = reshape(bsxfun(@times, conj(init_hf{1}), sh), size(init_hf{1},1), []).';
for k = 2:num_features
% multiply with the transpose: A^H * BP
hf_out{1,1,k} = hf_out1{k} + permute(bsxfun(@times, BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end), conj(samplesf{k})), [3 4 2 1]);
% B^H * BP
fBP{k} = reshape(bsxfun(@times, conj(init_hf{k}), BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end)), size(init_hf{k},1), []).';
% Compute proj matrix part: B^H * A_m * f
shBP{k} = reshape(bsxfun(@times, conj(init_hf{k}), sh(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end)), size(init_hf{k},1), []).';
end
% hf_out2 = cell(1,1,num_features);
for k = 1:num_features
fi = size(hf{k},1) * (size(hf{k},2)-1) + 1; % index where the last frequency column starts
% B^H * BP
hf_out2 = 2*real(XH{k} * fBP{k} - XH{k}(:,fi:end) * fBP{k}(fi:end,:)) + proj_reg * P{k};
% Compute proj matrix part: B^H * A_m * f
hf_out{2,1,k} = hf_out2 + (2*real(XH{k} * shBP{k} - XH{k}(:,fi:end) * shBP{k}(fi:end,:)));
end
end |
% !TeX root = ../main.tex
\section{Related Work}\label{sec:related}
Parallel run-time performance has been first analyzed for Isabelle
when parallelism was introduced by \citeauthor{Parallel2009Wenzel} in~\cite{Parallel2009Wenzel}.
Benchmarks for multiple different sessions on a single test machine already showed
that the speedup
(in terms of run-time)
peaked at three worker threads with a factor of \num{3.0},
and slightly decreased for four cores.
\citeauthor{PolyParallel2010Matthews} described the necessary adaptations to the Poly/ML run-time
that were necessary for introducing parallelism,
and analyzed the resulting bottlenecks~\cite{PolyParallel2010Matthews}.
They found that the parallelization model for Isabelle sometimes failed to fully utilize all worker threads.
Moreover, the synchronization model that uses a single signal across all threads for guarded access
was identified (but not analyzed) as a potential bottleneck.
Finally, it was observed that the single-threaded garbage collection is responsible for up to \SI{30}{\percent} CPU-time for \num{16} threads.
Overall, a maximum speedup of \num{5.0} to \num{6.2} could be achieved
using \num{8} threads.
In automatic theorem provers, run-time is an important factor,
since it can dictate whether a goal can be proven within the given cut-off time.
As a result, much research includes analysis of the run-time performance of provers
or individual prover components.
Typically, only a single hardware configuration is used,
which is reasonable for the analysis for single-threaded systems~\cite{PerformanceESat2016Schulz}.
However, since performing such analysis on a wide range of different hardware is often impractical,
run-time performance analysis of parallel approaches
is frequently carried out on single systems or clusters~\cite{PerformanceOR1991Ertel,ParallelDeduction1992Jindal,ParallelHyper2001Wu}.
These results don't always generalize, because the hardware used can have a significant impact on the observed results.
In contrast, results for the Isabelle \texttt{sledgehammer} proof-finder tool show that when running \emph{multiple} automatic provers to solve a goal,
run-time becomes less important:
In their \emph{judgement day} study~\cite{Judgementday2010Boehme},
\citeauthor{Judgementday2010Boehme} found that running three different Automated Theorem Provers for five seconds each
solved as many goals as running the most effective one for \SI{120}\second{}.
Subsequently, run-time was not analyzed in follow-up work~\cite{SMTHammer2011Blanchette}.
For automatic provers, a large range of benchmarks exist to judge their effectiveness on a given set of problems.
%A large range of benchmarks exists to judge the effectiveness of automatic provers,
One of these is the widely known TPTP library~\cite{TPTP2009Sutcliffe}.
However, there is not much work investigating the effect of hardware in the field of automated reasoning.
To the best of our knowledge,
there exists no other benchmark comparing the hardware impact on run-time performance of any theorem prover,
and this is the first work that analyzes this effect on a wide range of different hardware. |
import algebra.big_operators.basic
import algebra.big_operators.nat_antidiagonal
import algebra.big_operators.ring
import data.finset.nat_antidiagonal
import data.real.basic
import tactic
namespace OSK2002_5
open_locale big_operators
-- Lemma by Eric Wieser from the Xena Project Discord
lemma pow_sub_pow {R} [ring R] {a b : R} (h : commute a b) {n : ℕ} :
a^n.succ - b^n.succ = (a - b) * ∑ x in finset.nat.antidiagonal n, a^x.1 * b^x.2 :=
begin
rw [sub_mul, sub_eq_sub_iff_add_eq_add, finset.mul_sum, finset.mul_sum],
simp_rw [(h.symm.pow_right _).left_comm, ←mul_assoc a, ←pow_succ],
transitivity ∑ x in finset.nat.antidiagonal n.succ, a^x.1 * b^x.2,
{ rw [finset.nat.sum_antidiagonal_succ', pow_zero, mul_one], },
{ rw [finset.nat.sum_antidiagonal_succ, pow_zero, one_mul, add_comm] },
end
lemma cube_sub_cube {a b : ℝ} : a^3 - b^3 = (a - b) * (a^2 + a * b + b^2) := by ring
-- Added hypothesis that a ≠ 0 that's missing from the original statement
theorem osk2002_5 {a : ℝ} (h : a ≠ 0) : a^3 - a^(-3 : ℤ) = (a - (1 / a)) * (a^2 + 1 + (1 / a^2)) :=
begin
rw zpow_neg,
rw ← inv_zpow,
rw inv_eq_one_div,
norm_cast,
rw ← one_div_pow,
have h1 : 1 = a * (1 / a),
{ rw mul_one_div,
rw div_self,
exact h,},
nth_rewrite_rhs 1 h1,
rw cube_sub_cube,
end
end OSK2002_5 |
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Heather Macbeth
! This file was ported from Lean 3 source module topology.continuous_function.stone_weierstrass
! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Topology.ContinuousFunction.Weierstrass
import Mathbin.Data.IsROrC.Basic
/-!
# The Stone-Weierstrass theorem
If a subalgebra `A` of `C(X, ℝ)`, where `X` is a compact topological space,
separates points, then it is dense.
We argue as follows.
* In any subalgebra `A` of `C(X, ℝ)`, if `f ∈ A`, then `abs f ∈ A.topological_closure`.
This follows from the Weierstrass approximation theorem on `[-‖f‖, ‖f‖]` by
approximating `abs` uniformly thereon by polynomials.
* This ensures that `A.topological_closure` is actually a sublattice:
if it contains `f` and `g`, then it contains the pointwise supremum `f ⊔ g`
and the pointwise infimum `f ⊓ g`.
* Any nonempty sublattice `L` of `C(X, ℝ)` which separates points is dense,
by a nice argument approximating a given `f` above and below using separating functions.
For each `x y : X`, we pick a function `g x y ∈ L` so `g x y x = f x` and `g x y y = f y`.
By continuity these functions remain close to `f` on small patches around `x` and `y`.
We use compactness to identify a certain finitely indexed infimum of finitely indexed supremums
which is then close to `f` everywhere, obtaining the desired approximation.
* Finally we put these pieces together. `L = A.topological_closure` is a nonempty sublattice
which separates points since `A` does, and so is dense (in fact equal to `⊤`).
We then prove the complex version for self-adjoint subalgebras `A`, by separately approximating
the real and imaginary parts using the real subalgebra of real-valued functions in `A`
(which still separates points, by taking the norm-square of a separating function).
## Future work
Extend to cover the case of subalgebras of the continuous functions vanishing at infinity,
on non-compact spaces.
-/
noncomputable section
namespace ContinuousMap
variable {X : Type _} [TopologicalSpace X] [CompactSpace X]
open Polynomial
/-- Turn a function `f : C(X, ℝ)` into a continuous map into `set.Icc (-‖f‖) (‖f‖)`,
thereby explicitly attaching bounds.
-/
def attachBound (f : C(X, ℝ)) : C(X, Set.Icc (-‖f‖) ‖f‖)
where toFun x := ⟨f x, ⟨neg_norm_le_apply f x, apply_le_norm f x⟩⟩
#align continuous_map.attach_bound ContinuousMap.attachBound
@[simp]
theorem attachBound_apply_coe (f : C(X, ℝ)) (x : X) : ((attachBound f) x : ℝ) = f x :=
rfl
#align continuous_map.attach_bound_apply_coe ContinuousMap.attachBound_apply_coe
theorem polynomial_comp_attachBound (A : Subalgebra ℝ C(X, ℝ)) (f : A) (g : ℝ[X]) :
(g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (f : C(X, ℝ)).attachBound =
Polynomial.aeval f g :=
by
ext
simp only [ContinuousMap.coe_comp, Function.comp_apply, ContinuousMap.attachBound_apply_coe,
Polynomial.toContinuousMapOn_apply, Polynomial.aeval_subalgebra_coe,
Polynomial.aeval_continuousMap_apply, Polynomial.toContinuousMap_apply]
#align continuous_map.polynomial_comp_attach_bound ContinuousMap.polynomial_comp_attachBound
/-- Given a continuous function `f` in a subalgebra of `C(X, ℝ)`, postcomposing by a polynomial
gives another function in `A`.
This lemma proves something slightly more subtle than this:
we take `f`, and think of it as a function into the restricted target `set.Icc (-‖f‖) ‖f‖)`,
and then postcompose with a polynomial function on that interval.
This is in fact the same situation as above, and so also gives a function in `A`.
-/
theorem polynomial_comp_attachBound_mem (A : Subalgebra ℝ C(X, ℝ)) (f : A) (g : ℝ[X]) :
(g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (f : C(X, ℝ)).attachBound ∈ A :=
by
rw [polynomial_comp_attach_bound]
apply SetLike.coe_mem
#align continuous_map.polynomial_comp_attach_bound_mem ContinuousMap.polynomial_comp_attachBound_mem
theorem comp_attachBound_mem_closure (A : Subalgebra ℝ C(X, ℝ)) (f : A)
(p : C(Set.Icc (-‖f‖) ‖f‖, ℝ)) : p.comp (attachBound f) ∈ A.topologicalClosure :=
by
-- `p` itself is in the closure of polynomials, by the Weierstrass theorem,
have mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure :=
continuousMap_mem_polynomialFunctions_closure _ _ p
-- and so there are polynomials arbitrarily close.
have frequently_mem_polynomials := mem_closure_iff_frequently.mp mem_closure
-- To prove `p.comp (attached_bound f)` is in the closure of `A`,
-- we show there are elements of `A` arbitrarily close.
apply mem_closure_iff_frequently.mpr
-- To show that, we pull back the polynomials close to `p`,
refine'
((comp_right_continuous_map ℝ (attach_bound (f : C(X, ℝ)))).ContinuousAt
p).Tendsto.frequently_map
_ _ frequently_mem_polynomials
-- but need to show that those pullbacks are actually in `A`.
rintro _ ⟨g, ⟨-, rfl⟩⟩
simp only [SetLike.mem_coe, AlgHom.coe_toRingHom, comp_right_continuous_map_apply,
Polynomial.toContinuousMapOnAlgHom_apply]
apply polynomial_comp_attach_bound_mem
#align continuous_map.comp_attach_bound_mem_closure ContinuousMap.comp_attachBound_mem_closure
theorem abs_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f : A) :
(f : C(X, ℝ)).abs ∈ A.topologicalClosure :=
by
let M := ‖f‖
let f' := attach_bound (f : C(X, ℝ))
let abs : C(Set.Icc (-‖f‖) ‖f‖, ℝ) := { toFun := fun x : Set.Icc (-‖f‖) ‖f‖ => |(x : ℝ)| }
change abs.comp f' ∈ A.topological_closure
apply comp_attach_bound_mem_closure
#align continuous_map.abs_mem_subalgebra_closure ContinuousMap.abs_mem_subalgebra_closure
theorem inf_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f g : A) :
(f : C(X, ℝ)) ⊓ (g : C(X, ℝ)) ∈ A.topologicalClosure :=
by
rw [inf_eq]
refine'
A.topological_closure.smul_mem
(A.topological_closure.sub_mem
(A.topological_closure.add_mem (A.le_topological_closure f.property)
(A.le_topological_closure g.property))
_)
_
exact_mod_cast abs_mem_subalgebra_closure A _
#align continuous_map.inf_mem_subalgebra_closure ContinuousMap.inf_mem_subalgebra_closure
theorem inf_mem_closed_subalgebra (A : Subalgebra ℝ C(X, ℝ)) (h : IsClosed (A : Set C(X, ℝ)))
(f g : A) : (f : C(X, ℝ)) ⊓ (g : C(X, ℝ)) ∈ A :=
by
convert inf_mem_subalgebra_closure A f g
apply SetLike.ext'
symm
erw [closure_eq_iff_isClosed]
exact h
#align continuous_map.inf_mem_closed_subalgebra ContinuousMap.inf_mem_closed_subalgebra
theorem sup_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f g : A) :
(f : C(X, ℝ)) ⊔ (g : C(X, ℝ)) ∈ A.topologicalClosure :=
by
rw [sup_eq]
refine'
A.topological_closure.smul_mem
(A.topological_closure.add_mem
(A.topological_closure.add_mem (A.le_topological_closure f.property)
(A.le_topological_closure g.property))
_)
_
exact_mod_cast abs_mem_subalgebra_closure A _
#align continuous_map.sup_mem_subalgebra_closure ContinuousMap.sup_mem_subalgebra_closure
theorem sup_mem_closed_subalgebra (A : Subalgebra ℝ C(X, ℝ)) (h : IsClosed (A : Set C(X, ℝ)))
(f g : A) : (f : C(X, ℝ)) ⊔ (g : C(X, ℝ)) ∈ A :=
by
convert sup_mem_subalgebra_closure A f g
apply SetLike.ext'
symm
erw [closure_eq_iff_isClosed]
exact h
#align continuous_map.sup_mem_closed_subalgebra ContinuousMap.sup_mem_closed_subalgebra
open Topology
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (f g «expr ∈ » L) -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (f g «expr ∈ » L) -/
-- Here's the fun part of Stone-Weierstrass!
theorem sublattice_closure_eq_top (L : Set C(X, ℝ)) (nA : L.Nonempty)
(inf_mem : ∀ (f) (_ : f ∈ L) (g) (_ : g ∈ L), f ⊓ g ∈ L)
(sup_mem : ∀ (f) (_ : f ∈ L) (g) (_ : g ∈ L), f ⊔ g ∈ L) (sep : L.SeparatesPointsStrongly) :
closure L = ⊤ :=
by
-- We start by boiling down to a statement about close approximation.
apply eq_top_iff.mpr
rintro f -
refine'
Filter.Frequently.mem_closure
((Filter.HasBasis.frequently_iff Metric.nhds_basis_ball).mpr fun ε pos => _)
simp only [exists_prop, Metric.mem_ball]
-- It will be helpful to assume `X` is nonempty later,
-- so we get that out of the way here.
by_cases nX : Nonempty X
swap
exact ⟨nA.some, (dist_lt_iff Pos).mpr fun x => False.elim (nX ⟨x⟩), nA.some_spec⟩
/-
The strategy now is to pick a family of continuous functions `g x y` in `A`
with the property that `g x y x = f x` and `g x y y = f y`
(this is immediate from `h : separates_points_strongly`)
then use continuity to see that `g x y` is close to `f` near both `x` and `y`,
and finally using compactness to produce the desired function `h`
as a maximum over finitely many `x` of a minimum over finitely many `y` of the `g x y`.
-/
dsimp [Set.SeparatesPointsStrongly] at sep
let g : X → X → L := fun x y => (sep f x y).some
have w₁ : ∀ x y, g x y x = f x := fun x y => (sep f x y).choose_spec.1
have w₂ : ∀ x y, g x y y = f y := fun x y => (sep f x y).choose_spec.2
-- For each `x y`, we define `U x y` to be `{z | f z - ε < g x y z}`,
-- and observe this is a neighbourhood of `y`.
let U : X → X → Set X := fun x y => { z | f z - ε < g x y z }
have U_nhd_y : ∀ x y, U x y ∈ 𝓝 y := by
intro x y
refine' IsOpen.mem_nhds _ _
· apply isOpen_lt <;> continuity
· rw [Set.mem_setOf_eq, w₂]
exact sub_lt_self _ Pos
-- Fixing `x` for a moment, we have a family of functions `λ y, g x y`
-- which on different patches (the `U x y`) are greater than `f z - ε`.
-- Taking the supremum of these functions
-- indexed by a finite collection of patches which cover `X`
-- will give us an element of `A` that is globally greater than `f z - ε`
-- and still equal to `f x` at `x`.
-- Since `X` is compact, for every `x` there is some finset `ys t`
-- so the union of the `U x y` for `y ∈ ys x` still covers everything.
let ys : ∀ x, Finset X := fun x => (CompactSpace.elim_nhds_subcover (U x) (U_nhd_y x)).some
let ys_w : ∀ x, (⋃ y ∈ ys x, U x y) = ⊤ := fun x =>
(CompactSpace.elim_nhds_subcover (U x) (U_nhd_y x)).choose_spec
have ys_nonempty : ∀ x, (ys x).Nonempty := fun x =>
Set.nonempty_of_union_eq_top_of_nonempty _ _ nX (ys_w x)
-- Thus for each `x` we have the desired `h x : A` so `f z - ε < h x z` everywhere
-- and `h x x = f x`.
let h : ∀ x, L := fun x =>
⟨(ys x).sup' (ys_nonempty x) fun y => (g x y : C(X, ℝ)),
Finset.sup'_mem _ sup_mem _ _ _ fun y _ => (g x y).2⟩
have lt_h : ∀ x z, f z - ε < h x z := by
intro x z
obtain ⟨y, ym, zm⟩ := Set.exists_set_mem_of_union_eq_top _ _ (ys_w x) z
dsimp [h]
simp only [coeFn_coe_base', Subtype.coe_mk, sup'_coe, Finset.sup'_apply, Finset.lt_sup'_iff]
exact ⟨y, ym, zm⟩
have h_eq : ∀ x, h x x = f x := by
intro x
simp only [coeFn_coe_base'] at w₁
simp [coeFn_coe_base', w₁]
-- For each `x`, we define `W x` to be `{z | h x z < f z + ε}`,
let W : ∀ x, Set X := fun x => { z | h x z < f z + ε }
-- This is still a neighbourhood of `x`.
have W_nhd : ∀ x, W x ∈ 𝓝 x := by
intro x
refine' IsOpen.mem_nhds _ _
· apply isOpen_lt <;> continuity
· dsimp only [W, Set.mem_setOf_eq]
rw [h_eq]
exact lt_add_of_pos_right _ Pos
-- Since `X` is compact, there is some finset `ys t`
-- so the union of the `W x` for `x ∈ xs` still covers everything.
let xs : Finset X := (CompactSpace.elim_nhds_subcover W W_nhd).some
let xs_w : (⋃ x ∈ xs, W x) = ⊤ := (CompactSpace.elim_nhds_subcover W W_nhd).choose_spec
have xs_nonempty : xs.nonempty := Set.nonempty_of_union_eq_top_of_nonempty _ _ nX xs_w
-- Finally our candidate function is the infimum over `x ∈ xs` of the `h x`.
-- This function is then globally less than `f z + ε`.
let k : (L : Type _) :=
⟨xs.inf' xs_nonempty fun x => (h x : C(X, ℝ)),
Finset.inf'_mem _ inf_mem _ _ _ fun x _ => (h x).2⟩
refine' ⟨k.1, _, k.2⟩
-- We just need to verify the bound, which we do pointwise.
rw [dist_lt_iff Pos]
intro z
-- We rewrite into this particular form,
-- so that simp lemmas about inequalities involving `finset.inf'` can fire.
rw [show ∀ a b ε : ℝ, dist a b < ε ↔ a < b + ε ∧ b - ε < a
by
intros
simp only [← Metric.mem_ball, Real.ball_eq_Ioo, Set.mem_Ioo, and_comm']]
fconstructor
· dsimp [k]
simp only [Finset.inf'_lt_iff, ContinuousMap.inf'_apply]
exact Set.exists_set_mem_of_union_eq_top _ _ xs_w z
· dsimp [k]
simp only [Finset.lt_inf'_iff, ContinuousMap.inf'_apply]
intro x xm
apply lt_h
#align continuous_map.sublattice_closure_eq_top ContinuousMap.sublattice_closure_eq_top
/-- The **Stone-Weierstrass Approximation Theorem**,
that a subalgebra `A` of `C(X, ℝ)`, where `X` is a compact topological space,
is dense if it separates points.
-/
theorem subalgebra_topologicalClosure_eq_top_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ))
(w : A.SeparatesPoints) : A.topologicalClosure = ⊤ :=
by
-- The closure of `A` is closed under taking `sup` and `inf`,
-- and separates points strongly (since `A` does),
-- so we can apply `sublattice_closure_eq_top`.
apply SetLike.ext'
let L := A.topological_closure
have n : Set.Nonempty (L : Set C(X, ℝ)) := ⟨(1 : C(X, ℝ)), A.le_topological_closure A.one_mem⟩
convert sublattice_closure_eq_top (L : Set C(X, ℝ)) n
(fun f fm g gm => inf_mem_closed_subalgebra L A.is_closed_topological_closure ⟨f, fm⟩ ⟨g, gm⟩)
(fun f fm g gm => sup_mem_closed_subalgebra L A.is_closed_topological_closure ⟨f, fm⟩ ⟨g, gm⟩)
(Subalgebra.SeparatesPoints.strongly
(Subalgebra.separatesPoints_monotone A.le_topological_closure w))
· simp
#align continuous_map.subalgebra_topological_closure_eq_top_of_separates_points ContinuousMap.subalgebra_topologicalClosure_eq_top_of_separatesPoints
/-- An alternative statement of the Stone-Weierstrass theorem.
If `A` is a subalgebra of `C(X, ℝ)` which separates points (and `X` is compact),
every real-valued continuous function on `X` is a uniform limit of elements of `A`.
-/
theorem continuousMap_mem_subalgebra_closure_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ))
(w : A.SeparatesPoints) (f : C(X, ℝ)) : f ∈ A.topologicalClosure :=
by
rw [subalgebra_topological_closure_eq_top_of_separates_points A w]
simp
#align continuous_map.continuous_map_mem_subalgebra_closure_of_separates_points ContinuousMap.continuousMap_mem_subalgebra_closure_of_separatesPoints
/-- An alternative statement of the Stone-Weierstrass theorem,
for those who like their epsilons.
If `A` is a subalgebra of `C(X, ℝ)` which separates points (and `X` is compact),
every real-valued continuous function on `X` is within any `ε > 0` of some element of `A`.
-/
theorem exists_mem_subalgebra_near_continuousMap_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ))
(w : A.SeparatesPoints) (f : C(X, ℝ)) (ε : ℝ) (pos : 0 < ε) :
∃ g : A, ‖(g : C(X, ℝ)) - f‖ < ε :=
by
have w :=
mem_closure_iff_frequently.mp (continuous_map_mem_subalgebra_closure_of_separates_points A w f)
rw [metric.nhds_basis_ball.frequently_iff] at w
obtain ⟨g, H, m⟩ := w ε Pos
rw [Metric.mem_ball, dist_eq_norm] at H
exact ⟨⟨g, m⟩, H⟩
#align continuous_map.exists_mem_subalgebra_near_continuous_map_of_separates_points ContinuousMap.exists_mem_subalgebra_near_continuousMap_of_separatesPoints
/-- An alternative statement of the Stone-Weierstrass theorem,
for those who like their epsilons and don't like bundled continuous functions.
If `A` is a subalgebra of `C(X, ℝ)` which separates points (and `X` is compact),
every real-valued continuous function on `X` is within any `ε > 0` of some element of `A`.
-/
theorem exists_mem_subalgebra_near_continuous_of_separatesPoints (A : Subalgebra ℝ C(X, ℝ))
(w : A.SeparatesPoints) (f : X → ℝ) (c : Continuous f) (ε : ℝ) (pos : 0 < ε) :
∃ g : A, ∀ x, ‖g x - f x‖ < ε :=
by
obtain ⟨g, b⟩ := exists_mem_subalgebra_near_continuous_map_of_separates_points A w ⟨f, c⟩ ε Pos
use g
rwa [norm_lt_iff _ Pos] at b
#align continuous_map.exists_mem_subalgebra_near_continuous_of_separates_points ContinuousMap.exists_mem_subalgebra_near_continuous_of_separatesPoints
end ContinuousMap
section IsROrC
open IsROrC
-- Redefine `X`, since for the next few lemmas it need not be compact
variable {𝕜 : Type _} {X : Type _} [IsROrC 𝕜] [TopologicalSpace X]
namespace ContinuousMap
/-- A real subalgebra of `C(X, 𝕜)` is `conj_invariant`, if it contains all its conjugates. -/
def ConjInvariantSubalgebra (A : Subalgebra ℝ C(X, 𝕜)) : Prop :=
A.map (conjAe.toAlgHom.compLeftContinuous ℝ conjCle.Continuous) ≤ A
#align continuous_map.conj_invariant_subalgebra ContinuousMap.ConjInvariantSubalgebra
theorem mem_conjInvariantSubalgebra {A : Subalgebra ℝ C(X, 𝕜)} (hA : ConjInvariantSubalgebra A)
{f : C(X, 𝕜)} (hf : f ∈ A) : (conjAe.toAlgHom.compLeftContinuous ℝ conjCle.Continuous) f ∈ A :=
hA ⟨f, hf, rfl⟩
#align continuous_map.mem_conj_invariant_subalgebra ContinuousMap.mem_conjInvariantSubalgebra
/-- If a set `S` is conjugation-invariant, then its `𝕜`-span is conjugation-invariant. -/
theorem subalgebra_conj_invariant {S : Set C(X, 𝕜)}
(hS : ∀ f, f ∈ S → (conjAe.toAlgHom.compLeftContinuous ℝ conjCle.Continuous) f ∈ S) :
ConjInvariantSubalgebra ((Algebra.adjoin 𝕜 S).restrictScalars ℝ) :=
by
rintro _ ⟨f, hf, rfl⟩
change _ ∈ (Algebra.adjoin 𝕜 S).restrictScalars ℝ
change _ ∈ (Algebra.adjoin 𝕜 S).restrictScalars ℝ at hf
rw [Subalgebra.mem_restrictScalars] at hf⊢
apply Algebra.adjoin_induction hf
· exact fun g hg => Algebra.subset_adjoin (hS g hg)
· exact fun c => Subalgebra.algebraMap_mem _ (starRingEnd 𝕜 c)
· intro f g hf hg
convert Subalgebra.add_mem _ hf hg
exact AlgHom.map_add _ f g
· intro f g hf hg
convert Subalgebra.mul_mem _ hf hg
exact AlgHom.map_mul _ f g
#align continuous_map.subalgebra_conj_invariant ContinuousMap.subalgebra_conj_invariant
end ContinuousMap
open ContinuousMap
/-- If a conjugation-invariant subalgebra of `C(X, 𝕜)` separates points, then the real subalgebra
of its purely real-valued elements also separates points. -/
theorem Subalgebra.SeparatesPoints.isROrC_to_real {A : Subalgebra 𝕜 C(X, 𝕜)}
(hA : A.SeparatesPoints) (hA' : ConjInvariantSubalgebra (A.restrictScalars ℝ)) :
((A.restrictScalars ℝ).comap
(ofRealAm.compLeftContinuous ℝ continuous_of_real)).SeparatesPoints :=
by
intro x₁ x₂ hx
-- Let `f` in the subalgebra `A` separate the points `x₁`, `x₂`
obtain ⟨_, ⟨f, hfA, rfl⟩, hf⟩ := hA hx
let F : C(X, 𝕜) := f - const _ (f x₂)
-- Subtract the constant `f x₂` from `f`; this is still an element of the subalgebra
have hFA : F ∈ A :=
by
refine' A.sub_mem hfA (@Eq.subst _ (· ∈ A) _ _ _ <| A.smul_mem A.one_mem <| f x₂)
ext1
simp only [coe_smul, coe_one, Pi.smul_apply, Pi.one_apply, Algebra.id.smul_eq_mul, mul_one,
const_apply]
-- Consider now the function `λ x, |f x - f x₂| ^ 2`
refine' ⟨_, ⟨(⟨IsROrC.normSq, continuous_norm_sq⟩ : C(𝕜, ℝ)).comp F, _, rfl⟩, _⟩
· -- This is also an element of the subalgebra, and takes only real values
rw [SetLike.mem_coe, Subalgebra.mem_comap]
convert(A.restrict_scalars ℝ).mul_mem (mem_conj_invariant_subalgebra hA' hFA) hFA
ext1
rw [mul_comm]
exact (IsROrC.mul_conj _).symm
· -- And it also separates the points `x₁`, `x₂`
have : f x₁ - f x₂ ≠ 0 := sub_ne_zero.mpr hf
simpa only [comp_apply, coe_sub, coe_const, Pi.sub_apply, coe_mk, sub_self, map_zero, Ne.def,
norm_sq_eq_zero] using this
#align subalgebra.separates_points.is_R_or_C_to_real Subalgebra.SeparatesPoints.isROrC_to_real
variable [CompactSpace X]
/-- The Stone-Weierstrass approximation theorem, `is_R_or_C` version,
that a subalgebra `A` of `C(X, 𝕜)`, where `X` is a compact topological space and `is_R_or_C 𝕜`,
is dense if it is conjugation-invariant and separates points.
-/
theorem ContinuousMap.subalgebra_isROrC_topologicalClosure_eq_top_of_separatesPoints
(A : Subalgebra 𝕜 C(X, 𝕜)) (hA : A.SeparatesPoints)
(hA' : ConjInvariantSubalgebra (A.restrictScalars ℝ)) : A.topologicalClosure = ⊤ :=
by
rw [Algebra.eq_top_iff]
-- Let `I` be the natural inclusion of `C(X, ℝ)` into `C(X, 𝕜)`
let I : C(X, ℝ) →ₗ[ℝ] C(X, 𝕜) := of_real_clm.comp_left_continuous ℝ X
-- The main point of the proof is that its range (i.e., every real-valued function) is contained
-- in the closure of `A`
have key : I.range ≤ (A.to_submodule.restrict_scalars ℝ).topologicalClosure :=
by
-- Let `A₀` be the subalgebra of `C(X, ℝ)` consisting of `A`'s purely real elements; it is the
-- preimage of `A` under `I`. In this argument we only need its submodule structure.
let A₀ : Submodule ℝ C(X, ℝ) := (A.to_submodule.restrict_scalars ℝ).comap I
-- By `subalgebra.separates_points.complex_to_real`, this subalgebra also separates points, so
-- we may apply the real Stone-Weierstrass result to it.
have SW : A₀.topological_closure = ⊤ :=
haveI :=
subalgebra_topological_closure_eq_top_of_separates_points _ (hA.is_R_or_C_to_real hA')
congr_arg Subalgebra.toSubmodule this
rw [← Submodule.map_top, ← SW]
-- So it suffices to prove that the image under `I` of the closure of `A₀` is contained in the
-- closure of `A`, which follows by abstract nonsense
have h₁ := A₀.topological_closure_map ((@of_real_clm 𝕜 _).compLeftContinuousCompact X)
have h₂ := (A.to_submodule.restrict_scalars ℝ).map_comap_le I
exact h₁.trans (Submodule.topologicalClosure_mono h₂)
-- In particular, for a function `f` in `C(X, 𝕜)`, the real and imaginary parts of `f` are in the
-- closure of `A`
intro f
let f_re : C(X, ℝ) := (⟨IsROrC.re, is_R_or_C.re_clm.continuous⟩ : C(𝕜, ℝ)).comp f
let f_im : C(X, ℝ) := (⟨IsROrC.im, is_R_or_C.im_clm.continuous⟩ : C(𝕜, ℝ)).comp f
have h_f_re : I f_re ∈ A.topological_closure := key ⟨f_re, rfl⟩
have h_f_im : I f_im ∈ A.topological_closure := key ⟨f_im, rfl⟩
-- So `f_re + I • f_im` is in the closure of `A`
convert A.topological_closure.add_mem h_f_re (A.topological_closure.smul_mem h_f_im IsROrC.i)
-- And this, of course, is just `f`
ext
apply Eq.symm
simp [I, mul_comm IsROrC.i _]
#align continuous_map.subalgebra_is_R_or_C_topological_closure_eq_top_of_separates_points ContinuousMap.subalgebra_isROrC_topologicalClosure_eq_top_of_separatesPoints
end IsROrC
|
{-# LANGUAGE Haskell2010 #-}
import Control.Monad
import Data.Array
import Data.Bits
import Data.Char
import Data.Complex
import Data.Int
import Data.Ix
import Data.List
import Data.Maybe
import Data.Ratio
import Data.Word
import Foreign
import Foreign.C
import Foreign.C.Error
import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Marshal
import Foreign.Marshal.Alloc
import Foreign.Marshal.Array
import Foreign.Marshal.Error
import Foreign.Marshal.Utils
import Foreign.Ptr
import Foreign.StablePtr
import Foreign.Storable
import Numeric
import Prelude
import System.Environment
import System.Exit
import System.IO
import System.IO.Error
main :: IO ()
main = return ()
|
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
!
! Test for IO with the whole implied-shape array.
program test
implicit none
integer :: i, length
character(len = 6) :: str
character(len = 12) :: str2
character(len = 40) :: str3
integer, parameter :: arr1(1:*) = (/(i, i = 1, 6)/)
character, parameter :: arr2(1:*) = (/'a', 'b', 'c', 'd', 'e', 'f'/)
integer, parameter :: arr3(1:*) = [10, 11, 12, 13, 14, 15]
character, parameter :: arr4(1:*) = ['A', 'B', 'C', 'D', 'E', 'F']
integer, parameter :: arr5(1:*,1:*) = reshape((/(i, i = 1, 20)/), (/ 4, 5 /))
write(str, 10) arr1
if (str .ne. '123456') stop 1
write(str, 20) arr2
if (str .ne. 'abcdef') stop 2
write(str2, 30) arr3
if (str2 .ne. '101112131415') stop 3
write(str, 20) arr4
if (str .ne. 'ABCDEF') stop 4
write(str3, 40) arr5
if (str3 .ne. ' 1 2 3 4 5 6 7 8 91011121314151617181920') stop 5
inquire(IOLENGTH = length) arr1
if (length .ne. 24) stop 6
inquire(IOLENGTH = length) arr2
if (length .ne. 6) stop 7
inquire(IOLENGTH = length) arr3
if (length .ne. 24) stop 8
inquire(IOLENGTH = length) arr4
if (length .ne. 6) stop 9
inquire(IOLENGTH = length) arr5
if (length .ne. 80) stop 10
print *, 'PASS'
10 FORMAT (6I1)
20 FORMAT (6A1)
30 FORMAT (6I2)
40 FORMAT (20I2)
end
|
[STATEMENT]
lemma quat_norm_units [simp]: "norm quat_ii = 1" "norm (\<j>::quat) = 1" "norm (\<k>::quat) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. norm \<i> = 1 &&& norm \<j> = 1 &&& norm \<k> = 1
[PROOF STEP]
by (auto simp: norm_quat_def) |
From Equations Require Import Equations.
Require Import Coq.Lists.List.
Import ListNotations.
Require Export SystemFR.ErasedTypeRefine.
Require Export SystemFR.ErasedArrow.
Require Export SystemFR.ErasedTypeApplication.
Require Export SystemFR.ReducibilityEquivalent.
Opaque reducible_values.
Opaque makeFresh.
Definition type_open T1 T2 : tree :=
T_exists T2 (shift_open 0 T1 (lvar 0 term_var)).
(*
Definition equivalent_terms_at (theta: interpretation) T t1 t2 :=
is_erased_term t1 /\
is_erased_term t2 /\
wf t1 0 /\
wf t2 0 /\
pfv t1 term_var = nil /\
pfv t2 term_var = nil /\
forall C,
(forall v, reducible_values theta v T ->
div_reducible theta (open 0 C v) T_top) ->
is_erased_term C ->
wf C 1 ->
pfv C term_var = nil ->
scbv_normalizing (open 0 C t1) <-> scbv_normalizing (open 0 C t2).
*)
(*
Lemma singleton_identity:
is_singleton [] []
(notype_lambda (lvar 0 term_var))
(T_arrow T_nat (singleton (lvar 0 term_var))).
Proof.
unfold is_singleton;
repeat step || simp_red;
t_closer.
- unfold reduces_to; steps; t_closer.
exists a; repeat step || simp_red || rewrite open_none by auto; t_closer.
+ exists uu; repeat step || simp_red; eauto using equivalent_refl.
+ apply star_one.
constructor; t_closer.
- unfold equivalent_terms_at;
repeat step;
t_closer.
*)
Definition sub_singleton tvars gamma v T : Prop :=
forall theta l v',
valid_interpretation theta ->
satisfies (reducible_values theta) gamma l ->
support theta = tvars ->
reducible_values theta v' (psubstitute T l term_var) ->
equivalent_terms v' (psubstitute v l term_var).
Lemma reducibility_open_equivalent2:
forall T t1 t2 ρ t,
[ ρ ⊨ t : open 0 T t1 ] ->
valid_interpretation ρ ->
is_erased_type T ->
wf T 1 ->
pfv T term_var = nil ->
[ t1 ≡ t2 ] ->
[ ρ ⊨ t : open 0 T t2 ].
Proof.
eauto using reducibility_open_equivalent, reducible_values_exprs.
Qed.
Lemma open_subtype_type_application:
forall tvars gamma A B C c,
wf A 0 ->
wf B 1 ->
wf C 0 ->
wf c 0 ->
is_erased_term c ->
is_erased_type A ->
is_erased_type B ->
is_erased_type C ->
subset (fv A) (support gamma) ->
subset (fv B) (support gamma) ->
subset (fv C) (support gamma) ->
subset (fv c) (support gamma) ->
sub_singleton tvars gamma c C ->
[ tvars; gamma ⊨ C <: A ] ->
[ tvars; gamma ⊨ type_application (T_arrow A B) C <: open 0 B c ].
Proof.
unfold open_subtype;
repeat step || simp_red ||
(rewrite open_none in * by eauto with wf) ||
(rewrite (open_none v) in * by t_closer) ||
(rewrite (open_none (psubstitute C l term_var) 1) in * by eauto with wf).
apply reducible_expr_value; t_closer.
eapply reducibility_equivalent2; try eassumption;
repeat step ||
apply wf_open || apply wf_subst ||
apply is_erased_type_open || apply subst_erased_type;
t_closer.
- apply fv_nils2; eauto with fv.
eapply subset_transitive; eauto using fv_open;
repeat step || sets;
t_closer.
- t_substitutions.
apply reducibility_open_equivalent2 with a0;
repeat step || apply_any; t_closer.
Qed.
Lemma sub_singleton_value:
forall v T,
closed_value v ->
sub_singleton [] [] v (T_singleton T v).
Proof.
unfold sub_singleton;
repeat step || simp_red ||
(rewrite open_none in * by t_closer) ||
(rewrite shift_nothing2 in * by t_closer).
Qed.
|
State Before: r p : ℝ≥0
h : p ≠ 0
⊢ r < p⁻¹ ↔ r * p < 1 State After: no goals Tactic: rw [← mul_lt_mul_left (pos_iff_ne_zero.2 h), mul_inv_cancel h, mul_comm] |
Generalizable All Variables.
Set Implicit Arguments.
Require Import
Coq.Lists.List
Coq.Strings.String
Coq.Arith.Arith
Fiat.Common.ilist
Fiat.Common.ilist2.
Section i2list2.
(* Lists of elements whose types depend on a pairs of indexing set
(CPDT's hlists). *)
Variable A : Type. (* The indexing type. *)
Variable B B' : A -> Type. (* The type of indexed elements. *)
Variable C : forall a, B a -> B' a -> Type. (* The type of doubly-indexed elements. *)
Record prim_prod_3 A B C :=
{ prim_3_fst : A;
prim_3_snd : B;
prim_3_thd : C }.
Import Vectors.VectorDef.VectorNotations.
Fixpoint i2list2 {n}
(l : Vector.t A n)
(il1 : ilist (B := B) l)
(il2 : ilist (B := B') l) : Type :=
match l return ilist (B := B) l
-> ilist (B := B') l
-> Type with
| Vector.nil =>
fun il1 il2 => unit
| Vector.cons a n' l =>
fun il1 il2 =>
@prim_prod (C (prim_fst il1) (prim_fst il2))
(i2list2 l (prim_snd il1) (prim_snd il2))
end il1 il2.
Definition i2cons2
{a : A}
{n}
{l : Vector.t A n}
(b1 : B a)
(il1 : ilist (B := B) l)
(b2 : B' a)
(il2 : ilist (B := B') l)
(c : C b1 b2)
(i2l' : i2list2 l il1 il2)
: i2list2 (a :: l) (icons b1 il1) (icons b2 il2)
:= {| prim_fst := c; prim_snd := i2l' |}.
Definition inil : i2list2 [] inil inil := tt.
(* Get the car of an i2list2. *)
Definition i2list2_hd {n} {As : Vector.t A n}
{il1 : ilist (B := B) As}
{il2 : ilist (B := B') As}
(i2l : i2list2 As il1 il2) :
match As return
forall
(il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 As il1 il2 -> Type with
| Vector.cons a _ As' =>
fun Bs Bs' i2l => C (ilist_hd Bs) (ilist_hd Bs')
| Vector.nil => fun _ _ _ => unit
end il1 il2 i2l :=
match As return
forall il1 il2 i2l,
match As return
forall
(il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 As il1 il2 -> Type with
| Vector.cons a _ As' =>
fun Bs Bs' i2l => C (ilist_hd Bs) (ilist_hd Bs')
| Vector.nil => fun _ _ _ => unit
end il1 il2 i2l
with
| Vector.cons a _ As' =>
fun il1 il2 i2l => prim_fst i2l
| Vector.nil => fun _ _ _ => tt
end il1 il2 i2l.
(* Get the cdr of an i2list2. *)
Definition i2list2_tl {n}
{As : Vector.t A n}
{il1 : ilist (B := B) As}
{il2 : ilist (B := B') As}
(i2l : i2list2 As il1 il2) :
match As return
forall
(il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 As il1 il2 -> Type with
| Vector.cons a _ As' =>
fun Bs Bs' i2l => i2list2 _ (ilist_tl Bs) (ilist_tl Bs')
| Vector.nil => fun _ _ _ => unit
end il1 il2 i2l :=
match As return
forall il1 il2 i2l,
match As return
forall
(il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 As il1 il2 -> Type with
| Vector.cons a _ As' =>
fun Bs Bs' i2l => i2list2 _ (ilist_tl Bs) (ilist_tl Bs')
| Vector.nil => fun _ _ _ => unit
end il1 il2 i2l
with
| Vector.cons a _ As' =>
fun il1 il2 i2l => prim_snd i2l
| Vector.nil => fun _ _ _ => tt
end il1 il2 i2l.
Fixpoint i2th2
{m : nat}
{As : Vector.t A m}
(il1 : ilist (B := B) As)
(il2 : ilist (B := B') As)
(i2l : i2list2 As il1 il2)
(n : Fin.t m)
: C (ith il1 n) (ith il2 n) :=
match n in Fin.t m return
forall (As : Vector.t A m)
(il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 _ il1 il2
-> C (ith il1 n) (ith il2 n) with
| Fin.F1 k =>
fun As =>
Vector.caseS (fun n As =>
forall (il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 As il1 il2
-> C (ith il1 (@Fin.F1 n))
(ith il2 (@Fin.F1 n)))
(fun h n t il1 il2 i2l => i2list2_hd i2l) As
| Fin.FS k n' =>
fun As =>
Vector_caseS' Fin.t
(fun n As n' =>
forall (il1 : ilist (B := B) As)
(il2 : ilist (B := B') As),
i2list2 As il1 il2
-> C (ith il1 (@Fin.FS n n'))
(ith il2 (@Fin.FS n n')))
(fun h n t m il1 il2 i2l =>
i2th2 (ilist_tl il1)
(ilist_tl il2)
(i2list2_tl i2l) m)
As n'
end As il1 il2 i2l.
(*
(* Membership in a doubly-indexed list. *)
Inductive i2list2_In
: forall {a : A} {b : B a} {b' : B' a}
(c : C b b') (As : list A)
(il : ilist B As)
(il' : ilist B' As)
(i2l : i2list2 il il'), Prop :=
| In2_hd : forall a' As
(Bs : ilist B (a' :: As))
(Bs' : ilist B' (a' :: As))
(i2l : i2list2 (ilist_tl Bs) (ilist_tl Bs')) c,
i2list2_In c (i2cons2 Bs Bs' c i2l)
| In2_tl : forall a a' As
(Bs : ilist B (a' :: As))
(Bs' : ilist B' (a' :: As))
(b : B a) (b' : B' a) c'
(i2l : i2list2 (ilist_tl Bs) (ilist_tl Bs'))
(c : C b b'),
i2list2_In c i2l ->
i2list2_In c (i2cons2 Bs Bs' c' i2l).
(* Looking up the ith value, returning None for indices not in the list *)
(* A doubly-dependent option. *)
Fixpoint i2th_error2'
(As : list A)
(Bs : ilist B As)
(Bs' : ilist B' As)
(i2l : i2list2 Bs Bs')
(n : nat)
{struct n}
: Dep_Option_elim_T2 C (ith_error Bs n) (ith_error Bs' n) :=
match n as n' return
forall (Bs : ilist B As)
(Bs' : ilist B' As),
i2list2 Bs Bs'
-> Dep_Option_elim_T2 C (ith_error Bs n') (ith_error Bs' n')
with
| 0 =>
fun Bs Bs' i2l =>
match i2l as i2l' in i2list2 Bss Bss' return
Dep_Option_elim_T2 C (ith_error Bss 0) (ith_error Bss' 0) with
| i2nil2 _ _ => tt
| i2cons2 a As' Bss Bss' c i2l' => c
end
| S n => fun Bs Bs' i2l =>
match i2l as i2l' in i2list2 Bss Bss' return
Dep_Option_elim_T2 C (ith_error Bss (S n))
(ith_error Bss' (S n)) with
| i2nil2 _ _ => tt
| i2cons2 a As' Bss Bss' c i2l' => i2th_error2' i2l' n
end
end Bs Bs' i2l.
(* Looking up the ith value, returning a default value
for indices not in the list.
Fixpoint i2th_default2
(default_A : A)
(default_B : B default_A)
(default_C : C default_B)
(As : list A)
(Bs : ilist B As)
(i2l : i2list2 Bs)
(n : nat)
{struct As}
: C (ith2_default default_A default_B Bs n) :=
match As as As', n as n' return
forall (Bs' : ilist B As'),
i2list2 Bs'
-> C (ith2_default default_A default_B Bs' n') with
| a :: As', 0 => @i2list2_hd (a :: As')
| a :: As', S n' => fun il i2l => i2th_default2 default_C (i2list2_tl i2l) n'
| nil , 0 => fun il i2l => default_C
| nil , S n' => fun il i2l => default_C
end Bs i2l.
Lemma i2list2_invert (As : list A) (Bs : ilist B As) (Cs : i2list2 Bs):
match Bs as Bs' return i2list2 Bs' -> Prop with
| icons2 a As b Bs' => fun Cs =>
exists (c : C b) (Cs' : i2list2 Bs'),
Cs = i2cons2 (icons2 a b Bs') c Cs'
| inil2 => fun Cs => Cs = i2nil2 (inil2 _)
end Cs.
Proof.
destruct Cs.
- destruct (ilist_invert Bs) as [b [Bs' Bs'_eq]]; subst.
eexists; eauto.
- pose (ilist_invert Bs) as Bs_eq; simpl in Bs_eq; subst; eauto.
Qed.
Lemma i2th_default2_In :
forall (n : nat)
(As : list A)
(Bs : ilist B As)
(Cs : i2list2 Bs)
(default_A : A)
(default_B : B default_A)
(default_C : C default_B),
n < List.length As ->
i2list2_In (i2th_default2 default_C Cs n) Cs.
Proof.
ith2_induction n As; simpl;
destruct (i2list2_invert Cs) as [c [Cs' Cs_eq]]; subst; simpl;
[apply (In2_hd (icons2 a b il) Cs' c) | constructor 2];
eauto with arith.
Qed.
Lemma i2th_default2_indep :
forall (n : nat)
(As : list A)
(Bs : ilist B As)
(Cs : i2list2 Bs)
(default_A : A)
(default_B : B default_A)
(default_C default_C' : C default_B),
n < List.length As ->
i2th_default2 default_C Cs n = i2th_default2 default_C' Cs n.
Proof.
ith_induction n As; simpl; eauto with arith.
Qed. *)
*)
End i2list2.
(*
Section i2list2_replace.
(* Replacing an element of an indexed list. *)
Variable A : Type. (* The indexing type. *)
Variable B : A -> Type. (* The two types of indexed elements. *)
Variable C : forall a, B a -> Type. (* The type of doubly-indexed elements. *)
Program Fixpoint replace_2Index2
(n : nat)
(As : list A)
(Bs : ilist B As)
(Cs : i2list2 C Bs)
(new_c : Dep_Option_elim_P C (ith2_error Bs n))
{struct Bs} : i2list2 C Bs :=
match n return
i2list2 C Bs
-> Dep_Option_elim_P C (ith2_error Bs n)
-> i2list2 C Bs with
| 0 => match Bs return
i2list2 C Bs
-> Dep_Option_elim_P C (ith2_error Bs 0)
-> i2list2 C Bs with
| inil2 =>
fun il _ => i2nil2 _ _
| icons2 a b As' Bs' =>
fun Cs' new_c =>
i2cons2 _ new_c (i2list2_tl Cs')
end
| S n => match Bs return
i2list2 C Bs
-> Dep_Option_elim_P C (ith2_error Bs (S n))
-> i2list2 C Bs with
| inil2 => fun il _ => i2nil2 _ _
| icons2 a As' b Bs' =>
fun Cs' new_c =>
i2cons2 _ (i2list2_hd Cs')
(@replace_2Index2 n As' Bs'
(i2list2_tl Cs') new_c)
end
end Cs new_c.
Lemma i2th_replace2_Index_neq
: forall
(n : nat)
(As : list A)
(Bs : ilist _ As)
(Cs : i2list2 C Bs)
(n' : nat)
(new_c : Dep_Option_elim_P C (ith2_error Bs n')),
n <> n'
-> i2th_error2 (replace_2Index2 n' Cs new_c) n =
i2th_error2 Cs n.
Proof.
induction n; simpl; destruct Bs; intros; icons2_invert;
simpl in *; auto;
destruct n'; simpl; try congruence.
eapply IHn; congruence.
Qed.
Lemma i2th_replace2_Index_eq
: forall
(n : nat)
(As : list A)
(Bs : ilist _ As)
(Cs : i2list2 C Bs)
(new_c : Dep_Option_elim_P C (ith2_error Bs n)),
i2th_error2 (replace_2Index2 n Cs new_c) n = new_c.
Proof.
induction n; destruct Bs; simpl; auto; intros;
destruct new_c; eauto.
Qed.
Program Fixpoint replace_2Index2'
(n : nat)
(As : list A)
(Bs : ilist B As)
(Cs : i2list2 C Bs)
(new_c : Dep_Option_elim_P C (ith2_error Bs n))
{struct Cs} : i2list2 C Bs :=
match n return
Dep_Option_elim_P C (ith2_error Bs n)
-> i2list2 C Bs with
| 0 => match Cs in i2list2 _ Bs return
Dep_Option_elim_P C (ith2_error Bs 0)
-> i2list2 C Bs with
| i2nil2 Bs =>
fun _ => i2nil2 _ Bs
| i2cons2 a As' Bs' c i2l' =>
fun new_c =>
i2cons2 Bs' new_c i2l'
end
| S n => match Cs in i2list2 _ Bs return
Dep_Option_elim_P C (ith2_error Bs (S n))
-> i2list2 C Bs with
| i2nil2 Bs => fun _ => i2nil2 _ Bs
| i2cons2 a As' Bs' c i2l' =>
fun new_c =>
i2cons2 Bs' c (@replace_2Index2' n As' (ilist_tl Bs') i2l' new_c)
end
end new_c.
Lemma i2th_replace_2Index2'_neq
: forall
(n : nat)
(As : list A)
(Bs : ilist _ As)
(Cs : i2list2 C Bs)
(n' : nat)
(new_c : Dep_Option_elim_P C (ith2_error Bs n')),
n <> n'
-> i2th_error2' (replace_2Index2' n' Cs new_c) n =
i2th_error2' Cs n.
Proof.
induction n; simpl; destruct Cs; intros; icons2_invert;
simpl in *; auto;
destruct n'; simpl; try congruence.
unfold replace_2Index2.
eapply IHn; congruence.
Qed.
Lemma i2th_replace_2Index2'_eq
: forall
(n : nat)
(As : list A)
(Bs : ilist _ As)
(Cs : i2list2 C Bs)
(new_c : Dep_Option_elim_P C (ith2_error Bs n)),
i2th_error2' (replace_2Index2' n Cs new_c) n = new_c.
Proof.
induction n; destruct Cs; simpl; auto; intros;
destruct new_c; eauto.
Qed.
End i2list2_replace. *)
|
[STATEMENT]
lemma not_iIN_iMODb_subset: "\<lbrakk> 0 < d'; m \<noteq> Suc 0 \<rbrakk> \<Longrightarrow> \<not> [n'\<dots>,d'] \<subseteq> [r, mod m, c]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 < d'; m \<noteq> Suc 0\<rbrakk> \<Longrightarrow> \<not> [n'\<dots>,d'] \<subseteq> [ r, mod m, c ]
[PROOF STEP]
apply (rule Suc_in_imp_not_subset_iMODb[of n'])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
1. \<lbrakk>0 < d'; m \<noteq> Suc 0\<rbrakk> \<Longrightarrow> n' \<in> [n'\<dots>,d']
2. \<lbrakk>0 < d'; m \<noteq> Suc 0\<rbrakk> \<Longrightarrow> Suc n' \<in> [n'\<dots>,d']
3. \<lbrakk>0 < d'; m \<noteq> Suc 0\<rbrakk> \<Longrightarrow> m \<noteq> Suc 0
[PROOF STEP]
apply (simp add: iIN_iff)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
/-
This file contains the Tseitin encoding for XOR.
Both the pooled and linear encodigns are included here.
Authors: Cayden Codel, Jeremy Avidgad, Marijn Heule
Carnegie Mellon University
-/
import cnf.literal
import cnf.clause
import cnf.cnf
import cnf.encoding
import cnf.gensym
import xor.xor
import xor.direct_xor
import data.list.basic
import data.nat.basic
universe u
variables {V : Type u} [inhabited V] [decidable_eq V]
open literal
open clause
open cnf
open Xor
open encoding
open gensym
open nat
open list
open list.perm
open assignment
open function
namespace tseitin_xor
variables {l : list (literal V)} {g : gensym V} {k : nat} (hk : k ≥ 3) {v : V} {τ : assignment V}
lemma disjoint_fresh_of_disjoint : disjoint g.stock (clause.vars l) →
disjoint g.fresh.2.stock (clause.vars ((Pos g.fresh.1) :: (l.drop (k - 1)))) :=
begin
intro h,
apply set.disjoint_right.mpr,
intros v hv,
simp [clause.vars] at hv,
rcases hv with rfl | hv,
{ rw var,
exact fresh_not_mem_fresh_stock g },
{ intro hcon,
rw set.disjoint_right at h,
have := vars_subset_of_subset (drop_subset (k - 1) l),
exact absurd ((fresh_stock_subset g) hcon) (h (this hv)) }
end
lemma drop_len_lt (lit : literal V) (hk : k ≥ 3) :
length l > k → length (lit :: (l.drop (k - 1))) < length l :=
begin
intro hl,
rw length_cons,
rcases exists_append_of_gt_length hl with ⟨x₁, x₂, rfl, hl₁⟩,
simp only [hl₁, length_drop, length_append],
rw [add_comm k x₂.length, nat.add_sub_assoc (nat.sub_le k 1),
nat.sub_sub_self (le_of_add_le_right hk), add_assoc],
apply add_lt_add_left,
exact succ_le_iff.mp hk,
end
variables {p : list (literal V) → list (literal V)} (hp : ∀ l, perm l (p l))
def tseitin_xor : list (literal V) → gensym V → cnf V
| l g := if h : length l ≤ k then direct_xor l else
have length (p (Pos g.fresh.1 :: (l.drop (k - 1)))) < length l,
from (perm.length_eq (hp (Pos g.fresh.1 :: (l.drop (k - 1))))) ▸
(drop_len_lt _ hk (not_le.mp h)),
(direct_xor (l.take (k - 1) ++ [(Neg g.fresh.1)])) ++
(tseitin_xor (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)
using_well_founded {
rel_tac := λ a b, `[exact ⟨_, measure_wf (λ σ, list.length σ.1)⟩],
dec_tac := tactic.assumption
}
lemma tseitin_base_case : length l ≤ k → tseitin_xor hk hp l g = direct_xor l :=
assume h, by { rw tseitin_xor, simp only [h, if_true] }
theorem mem_tseitin_xor_vars_of_mem_vars
(hdis : disjoint g.stock (clause.vars l)) :
v ∈ (clause.vars l) → v ∈ (tseitin_xor hk hp l g).vars :=
begin
induction l using strong_induction_on_lists with l ih generalizing g,
by_cases hl : length l ≤ k,
{ rw [tseitin_base_case hk hp hl, vars_direct_xor], exact id },
{ intro h,
rw tseitin_xor,
simp [hl],
rw [← take_append_drop (k - 1) l, clause.vars_append] at h,
rw cnf.vars_append,
rcases finset.mem_union.mp h with (h | h),
{ apply finset.mem_union_left,
rw [vars_direct_xor, clause.vars_append],
exact finset.mem_union_left _ h },
{ rw not_le at hl,
have h₁ := drop_len_lt (Pos g.fresh.1) hk hl,
have h₂ := disjoint_fresh_of_disjoint hdis,
rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂,
have := ih _ h₁ h₂,
rw ← clause.vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,
exact finset.mem_union_right _ (this (mem_vars_cons_of_mem_vars _ h)) } }
end
theorem not_mem_tseitin_xor_vars_of_not_mem_vars_of_not_mem_stock
(hdis : disjoint g.stock (clause.vars l)) :
v ∉ (clause.vars l) → v ∉ g.stock → v ∉ (tseitin_xor hk hp l g).vars :=
begin
induction l using strong_induction_on_lists with l ih generalizing g,
by_cases hl : length l ≤ k,
{ rw [tseitin_base_case hk hp hl, vars_direct_xor l], tautology },
{ intros hvars hg,
rw tseitin_xor,
simp [hl],
rw cnf.vars_append,
apply finset.not_mem_union.mpr,
split,
{ rw [vars_direct_xor, clause.vars_append],
apply finset.not_mem_union.mpr,
split,
{ intro hcon,
have := (vars_subset_of_subset (take_subset (k - 1) l)),
exact absurd (this hcon) hvars },
{ simp [var],
intro hcon,
rw hcon at hg,
exact absurd (fresh_mem_stock g) hg } },
{ have h₁ := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),
have h₂ := disjoint_fresh_of_disjoint hdis,
have h₃ : v ∉ clause.vars (Pos g.fresh.1 :: drop (k - 1) l),
{ simp [clause.vars, var],
rintros (rfl | h),
{ exact hg (fresh_mem_stock g) },
{ exact hvars (vars_subset_of_subset (drop_subset (k - 1) l) h) } },
have h₄ : v ∉ g.fresh.2.stock,
{ intro hcon,
exact hg ((fresh_stock_subset g) hcon) },
rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂ h₃,
exact ih _ h₁ h₂ h₃ h₄ } }
end
lemma tseitin_forward (hdis : disjoint g.stock (clause.vars l)) :
Xor.eval τ l = tt → ∃ (σ : assignment V),
(tseitin_xor hk hp l g).eval σ = tt ∧ (eqod τ σ (clause.vars l)) :=
begin
intro he,
induction l using strong_induction_on_lists with l ih generalizing g τ,
by_cases hl : length l ≤ k,
{ use τ, rw [tseitin_base_case hk hp hl, eval_direct_xor_eq_eval_Xor], simp [he] },
{
rw [eval_eq_bodd_count_tt,
← (take_append_drop (k - 1) l), clause.count_tt_append, bodd_add] at he,
have hnotmem := set.disjoint_left.mp hdis (g.fresh_mem_stock),
have h₁ := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),
have h₂ := disjoint_fresh_of_disjoint hdis,
rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂,
have htakevars := vars_subset_of_subset (take_subset (k - 1) l),
have hdropvars := vars_subset_of_subset (drop_subset (k - 1) l),
rw tseitin_xor,
simp [hl, cnf.eval_append],
-- Case on the truth value of the last n - k + 1 variables
-- Note: the proof is symmetric, so any tightening-up can be done in both
cases hc : bodd (clause.count_tt τ (take (k - 1) l)),
{ rw [hc, bool.bxor_ff_left] at he,
rcases exists_eqod_and_eq_of_not_mem τ ff hnotmem with ⟨γ, heqod, hg⟩,
have : bodd (clause.count_tt γ (Pos g.fresh.1 :: drop (k - 1) l)) = tt,
{ simp only [clause.count_tt_cons, literal.eval, hg, cond,
← count_tt_eq_of_eqod (eqod_subset hdropvars heqod), he] },
rw [← eval_eq_bodd_count_tt, eval_eq_of_perm (hp (Pos g.fresh.1 :: drop (k - 1) l))] at this,
-- Apply the induction hypothesis
rcases (ih _ h₁ h₂ this) with ⟨γ₂, he₂, hg₂⟩,
have heqod₂ : eqod (assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ) γ (clause.vars l),
{ intros v hv,
by_cases hmem : v ∈ clause.vars (l.drop (k - 1)),
{ have h₃ := mem_vars_cons_of_mem_vars (Pos g.fresh.1) hmem,
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₃,
rw [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ h₃), hg₂ v h₃] },
{ have hdis₂ := set.disjoint_right.mp hdis hv,
have hne : v ≠ g.fresh.1,
{ intro hcon,
exact (hcon ▸ hdis₂) (fresh_mem_stock g) },
have : v ∉ clause.vars (Pos g.fresh.1 :: drop (k - 1) l),
{ simp [clause.vars, var],
rintros (hcon | hcon),
{ exact hne hcon },
{ exact hmem hcon } },
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,
have hstock : v ∉ g.fresh.2.stock,
{ intro hcon,
exact hdis₂ ((fresh_stock_subset g) hcon) },
rw ite_neg (not_mem_tseitin_xor_vars_of_not_mem_vars_of_not_mem_stock hk hp h₂ this hstock) } },
use assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ,
split,
{ split,
{ simp [eval_direct_xor_eq_eval_Xor, eval_eq_bodd_count_tt,
clause.count_tt_append, bodd_add, literal.eval, hg],
have : g.fresh.1 ∈ clause.vars (Pos g.fresh.1 :: (l.drop (k - 1))),
{ exact mem_vars_cons_self _ _ },
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,
simp [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ this),
← (hg₂ g.fresh.1 this), hg,
count_tt_eq_of_eqod (eqod_subset htakevars heqod₂),
← count_tt_eq_of_eqod (eqod_subset htakevars heqod), hc] },
{ exact he₂ ▸ eval_eq_of_eqod (ite_eqod _ _ _) } },
{ exact eqod.trans heqod (heqod₂.symm) } },
{ simp only [hc, bnot_eq_true_eq_eq_ff, tt_bxor] at he,
rcases exists_eqod_and_eq_of_not_mem τ tt hnotmem with ⟨γ, heqod, hg⟩,
have : bodd (clause.count_tt γ (Pos g.fresh.1 :: drop (k - 1) l)) = tt,
{ simp only [clause.count_tt_cons, literal.eval, hg, cond,
← count_tt_eq_of_eqod (eqod_subset hdropvars heqod), he, bodd_succ,
bodd_add, bodd_zero, bool.bnot_ff, bxor_tt_left], },
rw [← eval_eq_bodd_count_tt, eval_eq_of_perm (hp (Pos g.fresh.1 :: drop (k - 1) l))] at this,
-- Apply the induction hypothesis
rcases (ih _ h₁ h₂ this) with ⟨γ₂, he₂, hg₂⟩,
have heqod₂ : eqod (assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ) γ (clause.vars l),
{ intros v hv,
by_cases hmem : v ∈ clause.vars (l.drop (k - 1)),
{ have h₃ := mem_vars_cons_of_mem_vars (Pos g.fresh.1) hmem,
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₃,
rw [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ h₃), hg₂ v h₃] },
{ have hdis₂ := set.disjoint_right.mp hdis hv,
have hne : v ≠ g.fresh.1,
{ intro hcon,
exact (hcon ▸ hdis₂) (fresh_mem_stock g) },
have : v ∉ clause.vars (Pos g.fresh.1 :: drop (k - 1) l),
{ simp [clause.vars, var],
rintros (hcon | hcon),
{ exact hne hcon },
{ exact hmem hcon } },
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,
have hstock : v ∉ g.fresh.2.stock,
{ intro hcon,
exact hdis₂ ((fresh_stock_subset g) hcon) },
rw ite_neg (not_mem_tseitin_xor_vars_of_not_mem_vars_of_not_mem_stock hk hp h₂ this hstock) } },
use assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ,
split,
{ split,
{ simp [eval_direct_xor_eq_eval_Xor, eval_eq_bodd_count_tt,
clause.count_tt_append, bodd_add, literal.eval, hg],
have : g.fresh.1 ∈ clause.vars (Pos g.fresh.1 :: (l.drop (k - 1))),
{ exact mem_vars_cons_self _ _ },
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,
simp [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ this),
← (hg₂ g.fresh.1 this), hg,
count_tt_eq_of_eqod (eqod_subset htakevars heqod₂),
← count_tt_eq_of_eqod (eqod_subset htakevars heqod), hc] },
{ exact he₂ ▸ eval_eq_of_eqod (ite_eqod _ _ _) } },
{ exact eqod.trans heqod heqod₂.symm } } }
end
lemma tseitin_reverse (hdis : disjoint g.stock (clause.vars l)) :
cnf.eval τ (tseitin_xor hk hp l g) = tt → Xor.eval τ l = tt :=
begin
intro he,
induction l using strong_induction_on_lists with l ih generalizing g,
by_cases hl : length l ≤ k,
{ rw [tseitin_base_case hk hp hl, eval_direct_xor_eq_eval_Xor] at he, exact he },
{ rw tseitin_xor at he,
simp [hl, cnf.eval_append] at he,
rcases he with ⟨hdir, hrec⟩,
have h₁ := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),
have h₂ := disjoint_fresh_of_disjoint hdis,
rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,
rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂,
have ihred := ih _ h₁ h₂ hrec,
rw eval_direct_xor_eq_eval_Xor at hdir,
rw eval_eq_bodd_count_tt at ihred hdir |-,
rw ← clause.count_tt_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at ihred,
have := congr_arg ((clause.count_tt τ)) (take_append_drop (k - 1) l).symm,
have := congr_arg bodd this,
cases hnew : (τ g.fresh.1),
{ simp [clause.count_tt_cons, clause.count_tt_append, hnew, literal.eval] at ihred hdir,
rw [clause.count_tt_append, bodd_add, hdir, ihred, ff_bxor] at this,
exact this },
{ simp [clause.count_tt_cons, clause.count_tt_append, hnew, literal.eval] at ihred hdir,
rw [clause.count_tt_append, bodd_add, hdir, ihred, bxor_ff] at this,
exact this } }
end
theorem tseitin_xor_encodes_Xor (hdis : disjoint g.stock (clause.vars l)) :
encodes Xor (tseitin_xor hk hp l g) l :=
begin
intro τ,
split,
{ exact tseitin_forward hk hp hdis },
{ rintros ⟨σ, he, heqod⟩,
rw [← Xor.eval, Xor.eval_eq_of_eqod heqod],
exact tseitin_reverse hk hp hdis he }
end
def linear_perm (l : list (literal V)) : list (literal V) := l
lemma linear_perm_is_perm : ∀ (l : list (literal V)), l ~ linear_perm l :=
begin
intro l,
rw linear_perm
end
def linear_xor (l : list (literal V)) (g : gensym V) : cnf V :=
tseitin_xor hk linear_perm_is_perm l g
theorem linear_xor_encodes_Xor (hdis : disjoint g.stock (clause.vars l)) :
encodes Xor (linear_xor hk l g) l :=
tseitin_xor_encodes_Xor hk linear_perm_is_perm hdis
def pooled_perm : list (literal V) → list (literal V)
| [] := []
| (x :: xs) := xs ++ [x]
lemma pooled_perm_is_perm : ∀ (l : list (literal V)), l ~ pooled_perm l :=
begin
intro l,
cases l,
{ refl },
{ rw [pooled_perm, ← singleton_append],
exact perm_append_comm }
end
def pooled_xor (l : list (literal V)) (g : gensym V) : cnf V :=
tseitin_xor hk pooled_perm_is_perm l g
theorem pooled_xor_encodes_Xor (hdis : disjoint g.stock (clause.vars l)) :
encodes Xor (pooled_xor hk l g) l :=
tseitin_xor_encodes_Xor hk pooled_perm_is_perm hdis
end tseitin_xor |
module NeuralNet.Problem (
Problem (),
RunStep (),
createProblem,
runProblem,
runStepIteration,
runStepAccuracy,
runStepCost,
problemTestSet
) where
import NeuralNet.Example
import NeuralNet.Net
import NeuralNet.Layer
import NeuralNet.Cost
import NeuralNet.Train
import Numeric.LinearAlgebra
type NumIterations = Int
type LearningRate = Double
data Problem = Problem NeuralNetDefinition ExampleSet ExampleSet LearningRate NumIterations
deriving (Show, Eq)
type IterationNum = Int
type Cost = Double
type Accuracy = Double
data RunStep = RunStep IterationNum Cost Accuracy
deriving (Show, Eq)
runStepIteration :: RunStep -> IterationNum
runStepIteration (RunStep i _ _) = i
runStepCost :: RunStep -> Cost
runStepCost (RunStep _ c _) = c
runStepAccuracy :: RunStep -> Accuracy
runStepAccuracy (RunStep _ _ a) = a
problemNNDef :: Problem -> NeuralNetDefinition
problemNNDef (Problem d _ _ _ _) = d
problemTrainSet :: Problem -> ExampleSet
problemTrainSet (Problem _ t _ _ _) = t
problemTestSet :: Problem -> ExampleSet
problemTestSet (Problem _ _ t _ _) = t
problemLearningRate :: Problem -> LearningRate
problemLearningRate (Problem _ _ _ l _) = l
problemNumIterations :: Problem -> NumIterations
problemNumIterations (Problem _ _ _ _ i) = i
createProblem :: NeuralNetDefinition -> ExampleSet -> ExampleSet -> LearningRate -> NumIterations -> Problem
createProblem def trainSet testSet learningRate numIterations
| not (isExampleSetCompatibleWithNNDef trainSet def) = error "trainSet not compatible with nn"
| not (isExampleSetCompatibleWithNNDef testSet def) = error "testSet not compatible with nn"
| numIterations <= 0 = error "Must provide positive numIterations"
| learningRate <= 0 = error "Must provide positive learningRate"
| otherwise = Problem def trainSet testSet learningRate numIterations
runProblem :: WeightsStream -> Problem -> (Double -> Double -> Bool) -> (NeuralNet, [RunStep], Double)
runProblem g p accuracyCheck = (resultNN, tail allSteps, testAccuracy)
where
startNN = initNN g (problemNNDef p)
startStep = RunStep 0 1 0
iterations = [1..(problemNumIterations p)]
allNNAndSteps = reverse (foldl (\steps@((nn,_):_) i -> runProblemStep p i nn accuracyCheck : steps) [(startNN, startStep)] iterations)
allSteps = map snd allNNAndSteps
resultNN = fst (last allNNAndSteps)
testSet = problemTestSet p
testA = forwardPropA (last (nnForwardSet resultNN testSet))
testAccuracy = calcAccuracy accuracyCheck testA (exampleSetY testSet)
runProblemStep :: Problem -> IterationNum -> NeuralNet -> (Double -> Double -> Bool) -> (NeuralNet, RunStep)
runProblemStep p i nn accuracyCheck = (newNN, RunStep i cost accuracy)
where
trainSet = problemTrainSet p
forwardSteps = nnForwardSet nn trainSet
al = forwardPropA (last forwardSteps)
y = exampleSetY trainSet
grads = nnBackward nn forwardSteps trainSet
cost = computeCost al y
newNN = updateNNParams nn grads (problemLearningRate p)
accuracy = calcAccuracy accuracyCheck al y
calcAccuracy :: (Double -> Double -> Bool) -> Matrix Double -> Matrix Double -> Double
calcAccuracy accuracyCheck yHat y = fromIntegral numCorrect / fromIntegral (cols y)
where
numCorrect = length (filter (uncurry accuracyCheck) (zip (concat (toLists yHat)) (concat (toLists y))))
-- TODO: Search for concat (toLists - should be an easier way
|
[STATEMENT]
lemma analz_subset_cong:
"\<lbrakk> analz G \<subseteq> analz G'; analz H \<subseteq> analz H' \<rbrakk>
\<Longrightarrow> analz (G \<union> H) \<subseteq> analz (G' \<union> H')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>analz G \<subseteq> analz G'; analz H \<subseteq> analz H'\<rbrakk> \<Longrightarrow> analz (G \<union> H) \<subseteq> analz (G' \<union> H')
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>G \<subseteq> analz G'; H \<subseteq> analz H'\<rbrakk> \<Longrightarrow> G \<subseteq> analz (G' \<union> H') \<and> H \<subseteq> analz (G' \<union> H')
[PROOF STEP]
apply (iprover intro: conjI subset_trans analz_mono Un_upper1 Un_upper2)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
Bases of topologies. Countability axioms.
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.topology.continuous_on
import Mathlib.PostPort
universes u l u_1 u_2
namespace Mathlib
namespace topological_space
/- countability axioms
For our applications we are interested that there exists a countable basis, but we do not need the
concrete basis itself. This allows us to declare these type classes as `Prop` to use them as mixins.
-/
/-- A topological basis is one that satisfies the necessary conditions so that
it suffices to take unions of the basis sets to get a topology (without taking
finite intersections as well). -/
def is_topological_basis {α : Type u} [t : topological_space α] (s : set (set α)) :=
(∀ (t₁ : set α) (H : t₁ ∈ s) (t₂ : set α) (H : t₂ ∈ s) (x : α) (H : x ∈ t₁ ∩ t₂),
∃ (t₃ : set α), ∃ (H : t₃ ∈ s), x ∈ t₃ ∧ t₃ ⊆ t₁ ∩ t₂) ∧
⋃₀s = set.univ ∧ t = generate_from s
theorem is_topological_basis_of_subbasis {α : Type u} [t : topological_space α] {s : set (set α)}
(hs : t = generate_from s) :
is_topological_basis
((fun (f : set (set α)) => ⋂₀f) ''
set_of fun (f : set (set α)) => set.finite f ∧ f ⊆ s ∧ set.nonempty (⋂₀f)) :=
sorry
theorem is_topological_basis_of_open_of_nhds {α : Type u} [t : topological_space α]
{s : set (set α)} (h_open : ∀ (u : set α), u ∈ s → is_open u)
(h_nhds :
∀ (a : α) (u : set α), a ∈ u → is_open u → ∃ (v : set α), ∃ (H : v ∈ s), a ∈ v ∧ v ⊆ u) :
is_topological_basis s :=
sorry
theorem mem_nhds_of_is_topological_basis {α : Type u} [t : topological_space α] {a : α} {s : set α}
{b : set (set α)} (hb : is_topological_basis b) :
s ∈ nhds a ↔ ∃ (t : set α), ∃ (H : t ∈ b), a ∈ t ∧ t ⊆ s :=
sorry
theorem is_topological_basis.nhds_has_basis {α : Type u} [t : topological_space α] {b : set (set α)}
(hb : is_topological_basis b) {a : α} :
filter.has_basis (nhds a) (fun (t : set α) => t ∈ b ∧ a ∈ t) fun (t : set α) => t :=
sorry
theorem is_open_of_is_topological_basis {α : Type u} [t : topological_space α] {s : set α}
{b : set (set α)} (hb : is_topological_basis b) (hs : s ∈ b) : is_open s :=
sorry
theorem mem_basis_subset_of_mem_open {α : Type u} [t : topological_space α] {b : set (set α)}
(hb : is_topological_basis b) {a : α} {u : set α} (au : a ∈ u) (ou : is_open u) :
∃ (v : set α), ∃ (H : v ∈ b), a ∈ v ∧ v ⊆ u :=
iff.mp (mem_nhds_of_is_topological_basis hb) (mem_nhds_sets ou au)
theorem sUnion_basis_of_is_open {α : Type u} [t : topological_space α] {B : set (set α)}
(hB : is_topological_basis B) {u : set α} (ou : is_open u) :
∃ (S : set (set α)), ∃ (H : S ⊆ B), u = ⋃₀S :=
sorry
theorem Union_basis_of_is_open {α : Type u} [t : topological_space α] {B : set (set α)}
(hB : is_topological_basis B) {u : set α} (ou : is_open u) :
∃ (β : Type u), ∃ (f : β → set α), (u = set.Union fun (i : β) => f i) ∧ ∀ (i : β), f i ∈ B :=
sorry
/-- A separable space is one with a countable dense subset, available through
`topological_space.exists_countable_dense`. If `α` is also known to be nonempty, then
`topological_space.dense_seq` provides a sequence `ℕ → α` with dense range, see
`topological_space.dense_range_dense_seq`.
If `α` is a uniform space with countably generated uniformity filter (e.g., an `emetric_space`),
then this condition is equivalent to `topological_space.second_countable_topology α`. In this case
the latter should be used as a typeclass argument in theorems because Lean can automatically deduce
`separable_space` from `second_countable_topology` but it can't deduce `second_countable_topology`
and `emetric_space`. -/
class separable_space (α : Type u) [t : topological_space α] where
exists_countable_dense : ∃ (s : set α), set.countable s ∧ dense s
theorem exists_countable_dense (α : Type u) [t : topological_space α] [separable_space α] :
∃ (s : set α), set.countable s ∧ dense s :=
separable_space.exists_countable_dense
/-- A nonempty separable space admits a sequence with dense range. Instead of running `cases` on the
conclusion of this lemma, you might want to use `topological_space.dense_seq` and
`topological_space.dense_range_dense_seq`.
If `α` might be empty, then `exists_countable_dense` is the main way to use separability of `α`. -/
theorem exists_dense_seq (α : Type u) [t : topological_space α] [separable_space α] [Nonempty α] :
∃ (u : ℕ → α), dense_range u :=
sorry
/-- A sequence dense in a non-empty separable topological space.
If `α` might be empty, then `exists_countable_dense` is the main way to use separability of `α`. -/
def dense_seq (α : Type u) [t : topological_space α] [separable_space α] [Nonempty α] : ℕ → α :=
classical.some (exists_dense_seq α)
/-- The sequence `dense_seq α` has dense range. -/
@[simp] theorem dense_range_dense_seq (α : Type u) [t : topological_space α] [separable_space α]
[Nonempty α] : dense_range (dense_seq α) :=
classical.some_spec (exists_dense_seq α)
end topological_space
/-- If `α` is a separable space and `f : α → β` is a continuous map with dense range, then `β` is
a separable space as well. E.g., the completion of a separable uniform space is separable. -/
protected theorem dense_range.separable_space {α : Type u_1} {β : Type u_2} [topological_space α]
[topological_space.separable_space α] [topological_space β] {f : α → β} (h : dense_range f)
(h' : continuous f) : topological_space.separable_space β :=
sorry
namespace topological_space
/-- A first-countable space is one in which every point has a
countable neighborhood basis. -/
class first_countable_topology (α : Type u) [t : topological_space α] where
nhds_generated_countable : ∀ (a : α), filter.is_countably_generated (nhds a)
namespace first_countable_topology
theorem tendsto_subseq {α : Type u} [t : topological_space α] [first_countable_topology α]
{u : ℕ → α} {x : α} (hx : map_cluster_pt x filter.at_top u) :
∃ (ψ : ℕ → ℕ), strict_mono ψ ∧ filter.tendsto (u ∘ ψ) filter.at_top (nhds x) :=
filter.is_countably_generated.subseq_tendsto (nhds_generated_countable x) hx
end first_countable_topology
theorem is_countably_generated_nhds {α : Type u} [t : topological_space α]
[first_countable_topology α] (x : α) : filter.is_countably_generated (nhds x) :=
first_countable_topology.nhds_generated_countable x
theorem is_countably_generated_nhds_within {α : Type u} [t : topological_space α]
[first_countable_topology α] (x : α) (s : set α) :
filter.is_countably_generated (nhds_within x s) :=
filter.is_countably_generated.inf_principal (is_countably_generated_nhds x) s
/-- A second-countable space is one with a countable basis. -/
class second_countable_topology (α : Type u) [t : topological_space α] where
is_open_generated_countable : ∃ (b : set (set α)), set.countable b ∧ t = generate_from b
protected instance second_countable_topology.to_first_countable_topology (α : Type u)
[t : topological_space α] [second_countable_topology α] : first_countable_topology α :=
sorry
theorem second_countable_topology_induced (α : Type u) (β : Type u_1) [t : topological_space β]
[second_countable_topology β] (f : α → β) : second_countable_topology α :=
sorry
protected instance subtype.second_countable_topology (α : Type u) [t : topological_space α]
(s : set α) [second_countable_topology α] : second_countable_topology ↥s :=
second_countable_topology_induced (↥s) α coe
theorem is_open_generated_countable_inter (α : Type u) [t : topological_space α]
[second_countable_topology α] :
∃ (b : set (set α)), set.countable b ∧ ¬∅ ∈ b ∧ is_topological_basis b :=
sorry
/- TODO: more fine grained instances for first_countable_topology, separable_space, t2_space, ... -/
protected instance prod.second_countable_topology (α : Type u) [t : topological_space α]
{β : Type u_1} [topological_space β] [second_countable_topology α]
[second_countable_topology β] : second_countable_topology (α × β) :=
second_countable_topology.mk sorry
protected instance second_countable_topology_fintype {ι : Type u_1} {π : ι → Type u_2} [fintype ι]
[t : (a : ι) → topological_space (π a)] [sc : ∀ (a : ι), second_countable_topology (π a)] :
second_countable_topology ((a : ι) → π a) :=
(fun
(this :
∀ (i : ι), ∃ (b : set (set (π i))), set.countable b ∧ ¬∅ ∈ b ∧ is_topological_basis b) =>
sorry)
fun (a : ι) => is_open_generated_countable_inter (π a)
protected instance second_countable_topology.to_separable_space (α : Type u)
[t : topological_space α] [second_countable_topology α] : separable_space α :=
sorry
theorem is_open_Union_countable {α : Type u} [t : topological_space α] [second_countable_topology α]
{ι : Type u_1} (s : ι → set α) (H : ∀ (i : ι), is_open (s i)) :
∃ (T : set ι),
set.countable T ∧
(set.Union fun (i : ι) => set.Union fun (H : i ∈ T) => s i) =
set.Union fun (i : ι) => s i :=
sorry
theorem is_open_sUnion_countable {α : Type u} [t : topological_space α]
[second_countable_topology α] (S : set (set α)) (H : ∀ (s : set α), s ∈ S → is_open s) :
∃ (T : set (set α)), set.countable T ∧ T ⊆ S ∧ ⋃₀T = ⋃₀S :=
sorry
/-- In a topological space with second countable topology, if `f` is a function that sends each
point `x` to a neighborhood of `x`, then for some countable set `s`, the neighborhoods `f x`,
`x ∈ s`, cover the whole space. -/
theorem countable_cover_nhds {α : Type u} [t : topological_space α] [second_countable_topology α]
{f : α → set α} (hf : ∀ (x : α), f x ∈ nhds x) :
∃ (s : set α),
set.countable s ∧ (set.Union fun (x : α) => set.Union fun (H : x ∈ s) => f x) = set.univ :=
sorry
end Mathlib |
**Tarea Nro. 3 - LinAlg + Sympy**
- Nombre y apellido: Ivo Andrés Astudillo
- Fecha: 7 de diciembre de 2020
# Producto punto
## Use un producto punto y la lista de compras de la tabla 9.4 para determinar su cuenta total en la tienda.
```python
import numpy as np
```
```python
articulo = np.array([2, 1, 2, 5, 1])
costo = np.array([3.50, 1.25, 4.25, 1.55, 3.15])
print("Cuenta total:", np.dot(articulo, costo))
```
Cuenta total: 27.65
# Multiplicación matricial
## Con un calorímetro de bomba se realizó una serie de experimentos. En cada experimento se usó una cantidad diferente de agua. Calcule la capacidad calorífica total para el calorímetro en cada uno de los experimentos, mediante multiplicación matricial, los datos de la tabla 9.8 y la información acerca de la capacidad calorífica que sigue a la tabla.
<br><br>
```python
bomba = np.array([
[110, 250, 10],
[100, 250, 10],
[101, 250, 10],
[98.6, 250, 10],
[99.4, 250, 10]
]).reshape(5, 3)
capacidad_calorica = np.array([4.2, 0.45, 0.90]).reshape(3, 1)
capacidad_calorica_total = np.dot(bomba, capacidad_calorica)
i=1
for c in capacidad_calorica_total:
print(f'Capacidad calórica del experimento {i} = {float(c)}')
i+=1
```
Capacidad calórica del experimento 1 = 583.5
Capacidad calórica del experimento 2 = 541.5
Capacidad calórica del experimento 3 = 545.7
Capacidad calórica del experimento 4 = 535.62
Capacidad calórica del experimento 5 = 538.98
# Determinantes e inversos
## Recuerde que no todas las matrices tienen inverso. Una matriz es singular (es decir: no tiene inverso) si su determinante es igual a 0 (es decir, |A| = 0). Use la función determinante para probar si cada una de las siguientes matrices tiene inverso:
Si existe un inverso, calcúlelo.
```python
def detInv(m, nombre):
det = np.linalg.det(m)
if det != 0:
inv = np.linalg.inv(m)
print(f'El determinante de la matriz {nombre} es: {det}')
print(f'El inverso de la matriz {nombre} es:')
print(inv)
print('\n')
else:
print(f'El determinante de la matriz {nombre} es: {det} por lo tanto no tiene inverso.')
print('\n')
A = np.array([
[2, -1],
[4, 5]
]).reshape(2,2)
B = np.array([
[4, 2],
[2, 1]
]).reshape(2,2)
C = np.array([
[2, 0, 0],
[1, 2, 2],
[5, 4, 0]
]).reshape(3, 3)
detInv(A, 'A')
detInv(B, 'B')
detInv(C, 'C')
```
El determinante de la matriz A es: 14.000000000000004
El inverso de la matriz A es:
[[ 0.35714286 0.07142857]
[-0.28571429 0.14285714]]
El determinante de la matriz B es: 0.0 por lo tanto no tiene inverso.
El determinante de la matriz C es: -15.999999999999998
El inverso de la matriz C es:
[[ 0.5 0. 0. ]
[-0.625 -0. 0.25 ]
[ 0.375 0.5 -0.25 ]]
# Resolución de sistemas ecuaciones lineales
## Resuelva el siguiente sistema de ecuaciones
```python
M = np.array([
[3, 4, 2, -1, 1, 7, 1],
[2, -2, 3, -4, 5, 2, 8],
[1, 2, 3, 1, 2, 4, 6],
[5, 10, 4, 3, 9, -2, 1],
[3, 2, -2, -4, -5, -6, 7],
[-2, 9, 1, 3, -3, 5, 1],
[1, -2, -8, 4, 2, 4, 5],
]).reshape(7, 7)
res = np.array([42, 32, 12, -5, 10, 18, 17]).reshape(7, 1)
print('Solución del sistema de ecuaciones:\n')
print(np.linalg.solve(M, res))
```
Solución del sistema de ecuaciones:
[[-0.18899493]
[ 2.54589061]
[-3.28057396]
[-6.75778176]
[ 1.32124449]
[ 4.31944831]
[ 0.62940585]]
# Cálculo
La capacidad calorífica C<sub>p</sub> de un gas se puede modelar con la ecuación empírica
\begin{equation}
C_p = a + bT + cT^2+dT^3
\end{equation}
donde a, b, c y d son constantes empíricas y T es la temperatura en grados Kelvin. El cambio en entalpía (una medida de energía) conforme el gas se caliente de T 2 es la integral de esta ecuación con respecto a T:
\begin{equation}
\bigtriangleup h = \int_{T_{1}}^{T_{2}} C_{p}\,dT
\end{equation}
## Encuentre el cambio en entalpía del oxígeno gaseoso conforme se calienta de 300 K a 1000 K. Los valores de a, b, c y d para el oxígeno son
\begin{equation}
\begin{split}
a & = 25.48 \\
b & = 1.520 x 10^{-2} \\
c & = -0.7155 x 10^{-5} \\
d & = 1.312 x 10^{-9}
\end{split}
\end{equation}
```python
a, b, c, d, C_p, T, T_1, T_2, h = sp.symbols('a b c d C_p T T_1 T_2 h')
```
```python
a = 25.480
b = 1.52 * (10**-2)
c = -0.7155 * (10**-5)
d = 1.312 * (10**-9)
T_1 = 300
T_2 = 1000
```
```python
C_p = a + b*(T_2) + c*(T_2**2) + d*(T_2**3)
C_p
```
34.836999999999996
```python
h = sp.Integral(C_p, (T, T_1, T_2))
h
```
$\displaystyle \int\limits_{300}^{1000} 34.837\, dT$
```python
h.doit()
```
$\displaystyle 24385.9$
|
State Before: l m r : List Char
p : Char → Bool
⊢ ValidFor l (List.takeWhile p m) (List.dropWhile p m ++ r)
(Substring.takeWhile
{ str := { data := l ++ m ++ r }, startPos := { byteIdx := utf8Len l },
stopPos := { byteIdx := utf8Len l + utf8Len m } }
p) State After: l m r : List Char
p : Char → Bool
⊢ ValidFor l (List.takeWhile p m) (List.dropWhile p m ++ r)
{ str := { data := l ++ m ++ r }, startPos := { byteIdx := utf8Len l },
stopPos := { byteIdx := utf8Len l + utf8Len (List.takeWhile p m) } } Tactic: simp only [Substring.takeWhile, takeWhileAux_of_valid] State Before: l m r : List Char
p : Char → Bool
⊢ ValidFor l (List.takeWhile p m) (List.dropWhile p m ++ r)
{ str := { data := l ++ m ++ r }, startPos := { byteIdx := utf8Len l },
stopPos := { byteIdx := utf8Len l + utf8Len (List.takeWhile p m) } } State After: case refine'_1
l m r : List Char
p : Char → Bool
⊢ m ++ r = List.takeWhile p m ++ (List.dropWhile p m ++ r) Tactic: refine' .of_eq .. <;> simp State Before: case refine'_1
l m r : List Char
p : Char → Bool
⊢ m ++ r = List.takeWhile p m ++ (List.dropWhile p m ++ r) State After: no goals Tactic: rw [← List.append_assoc, List.takeWhile_append_dropWhile] |
#ifndef libceed_solids_examples_setup_libceed_h
#define libceed_solids_examples_setup_libceed_h
#include <ceed.h>
#include <petsc.h>
#include "../include/structs.h"
// -----------------------------------------------------------------------------
// libCEED Functions
// -----------------------------------------------------------------------------
// Destroy libCEED objects
PetscErrorCode CeedDataDestroy(CeedInt level, CeedData data);
// Utility function - essential BC dofs are encoded in closure indices as -(i+1)
PetscInt Involute(PetscInt i);
// Utility function to create local CEED restriction from DMPlex
PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height,
DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr);
// Utility function to get Ceed Restriction for each domain
PetscErrorCode GetRestrictionForDomain(Ceed ceed, DM dm, CeedInt height,
DMLabel domain_label, PetscInt value,
CeedInt Q, CeedInt q_data_size,
CeedElemRestriction *elem_restr_q,
CeedElemRestriction *elem_restr_x,
CeedElemRestriction *elem_restr_qd_i);
// Set up libCEED for a given degree
PetscErrorCode SetupLibceedFineLevel(DM dm, DM dm_energy, DM dm_diagnostic,
Ceed ceed, AppCtx app_ctx,
CeedQFunctionContext phys_ctx,
ProblemData problem_data,
PetscInt fine_level, PetscInt num_comp_u,
PetscInt U_g_size, PetscInt U_loc_size,
CeedVector force_ceed,
CeedVector neumann_ceed, CeedData *data);
// Set up libCEED multigrid level for a given degree
PetscErrorCode SetupLibceedLevel(DM dm, Ceed ceed, AppCtx app_ctx,
ProblemData problem_data, PetscInt level,
PetscInt num_comp_u, PetscInt U_g_size,
PetscInt U_loc_size, CeedVector fine_mult,
CeedData *data);
#endif // libceed_solids_examples_setup_libceed_h
|
\documentclass{article}
\usepackage[a4paper,margin=2cm,landscape]{geometry}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{multicol}
\usepackage{dirtree} % texlive-generic-extra
%\linespread{0.5}
% Black section* with white text
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\titleformat{name=\section,numberless}{\normalfont\Large\bfseries}{}{0em}{\colorbox{black}{
\parbox{\dimexpr\textwidth/3-8\fboxsep}{\textcolor{white}{#1}}
}}
% Vertical lines between columns
\setlength{\columnseprule}{1pt}
\def\columnseprulecolor{\color{black}}
% Header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
% Fixed Header parts
\lhead{CMNB - Quick Reference} % No left header
\rhead{Last update: 2017-05-25}
% Fixed Footer parts
\lfoot{https://github.com/INTI-CMNB-FPGA/guidelines}
\newcommand{\licenseurl} {http://creativecommons.org/licenses/by/4.0/}
\newcommand{\licensedesc} {Creative Commons Attribution 4.0 International License}
\rfoot{This work is licensed under a \href{\licenseurl}{\licensedesc}.}
\cfoot{} % No central footer
% -------------------------------------------------------------------------------------------------
\begin{document}
% -------------------------------------------------------------------------------------------------
\chead{FPGA Project Conventions}
\begin{multicols}{3}
% \dirtree{%
% .1 project\_name.
% .2 core.
% .3 tb.
% .2 doc.
% .2 info.
% .2 FPGA.
% .2 helpers.
% .2 hardware.
% .2 softdware.
% .2 firmware.
% .2 verification.
% }
\section*{Directory structure}
Mandatory:
\begin{itemize}
\item \textit{core:} HDL code of the core
\item \textit{core/tb:} HDL code of the testbench
\item \textit{doc:} generated documentation, such as specifications, manuals, notes, block diagrams, etc
\end{itemize}
Common used:
\begin{itemize}
\item \textit{info:} downloaded documentation, such as standards, application notes, datasheets, example code, etc
\item \textit{FPGA:} synthesis projects distributed in directories called as \textit{boardname\_corename}
\item \textit{helpers:} developed scripts
\end{itemize}
Others:
\begin{itemize}
\item \textit{hardware:} schematics and PCBs
\item \textit{software:} developed for the project
\item \textit{firmware:} code for processors
\item \textit{verification:} formal verification
\end{itemize}
And needed git submodules such as \textit{fpga\_lib} in the root directory
\section*{Files}
\begin{itemize}
\item Add a README.md (Markdown) at least in main directories
\item README.md in the root directory must explain the project
\item README.md in core directory must explain main blocks and how to use quickly
\item Add Makefiles, Bash scripts or at least explain in README.md how to run simulation and synthesis
\item Makefile in root directory must provide a target to analyze, compile and simulate all the project
\item Add AUTHORS in the root directory, with name, email and what they work on
\end{itemize}
\section*{Names}
\begin{itemize}
\item Coherent and descriptive
\item Avoid spaces and especial symbols (be careful with downloaded files)
\item Do not use dates and version numbers
\end{itemize}
\section*{Considerations}
\begin{itemize}
\item For complex IP cores with multiple layers use several directories inside \textit{core}
(with its own \textit{tb})
\item Make one Library per project
\item Make one Package per layer
\item Use separated Packages for test if needed
\item Automate with Makefiles and/or Bash scripts
\end{itemize}
\section*{Control version}
\begin{itemize}
\item Use Git as control version system
\item Logs format:
\begin{lstlisting}[]
Mandatory short description
Optional long description if
clarification is needed. Here
you can use * as bullets to
separate concepts.
\end{lstlisting}
\item Avoid multiple versions, use tags instead
\item Use branches to add new features
\item Try to use text formats also for documentation (LaTeX, flat of LibreOffice)
\item Avoid generated and binary files (exception: production bitstream, delivered
documentation, manufactured gerbers)
\item Try to avoid name changes (\textit{git mv}), but if needed be clear in the log file
(do a commit only indicating old names and new names)
\end{itemize}
\end{multicols}
% -------------------------------------------------------------------------------------------------
\newpage
\chead{HDL Conventions}
\begin{multicols}{3}
\section*{General}
\begin{itemize}
\item Use VHDL 93 (default) or Verilog 2001 (if justified)
\item English for all (code, names, comments, doc, etc)
\item Make useful comments
\item Use meaningful names
\item Never use reserved words as name
\item Separate words with underscores
\item Use positive (active high) logic if feasible
\end{itemize}
\section*{Files and Units}
\begin{itemize}
\item File extensions:
\begin{itemize}
\item \textit{.vhdl} for VHDL
\item \textit{.v} for Verilog
\item \textit{.vh} for Verilog Header
\item \textit{.sv} for System Verilog
\end{itemize}
\item Use \textit{example.vhdl} for a Entity called \textit{example} and its Architecture[s]
\item Use \textit{example.v} for a Module called \textit{example}
\item Use \textit{example\_pkg.vhdl} for a Package called \textit{example}
[and its Package Body]
\item Use the suffix \textit{\_tb} for testbenches (file and Entity/Module names)
\item Use \textit{example\_cfg.vhdl} for VHDL configurations (not commonly used)
\item Architecture names:
\begin{itemize}
\item \textit{Structural} (instantiations), \textit{RTL}, \textit{Behav} (simulation)
\item \textit{Power}, \textit{Area}, \textit{Speed} (if optimized for)
\item Vendor or family names (if optimized for)
\end{itemize}
\item Considerations:
\begin{itemize}
\item Only one Entity and all its Architecture[s] per file
\item Only one Module per file
\item Only one Package [and its Package Body] per file
\end{itemize}
\end{itemize}
\section*{Case}
\begin{itemize}
\item Lowercase is the default
\item Uppercase for constants, generics/params and enumerations
\item Mixed case for entity/module, architecture, packages and libraries names
\end{itemize}
\section*{Indentation}
\begin{itemize}
\item 3 spaces is the default
\item 4 spaces with \textit{for}
\item Never use tabs
\item Line length less than 100 characters when feasible
\item Use a space between a language statement and its bracket
\item No space between names and its bracket
\item Blocks:
\begin{lstlisting}[language=vhdl]
if (...) open_symbol
something
close_symbol else open_symbol
something
close_symbol
\end{lstlisting}
\end{itemize}
\section*{Header}
\begin{lstlisting}[language=vhdl]
--
-- [Long] name of the core
--
-- Author(s):
-- * Name
--
-- Copyright Notice
-- License Notice
--
-- Description:
-- Long functional description.
--
\end{lstlisting}
\section*{Libraries (VHDL)}
\begin{itemize}
\item Only include one Library or Package per line
\item Avoid to use deprecated IEEE libraries (Synopsis, Cadence, Mentor)
\item You normally will use:
\begin{lstlisting}[language=vhdl]
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
\end{lstlisting}
\end{itemize}
\section*{Port declaration}
\begin{itemize}
\item One port per line
\item Comment \textbf{each} port
\item Use only std\_logic and std\_logic\_vector (un/signed when meaningful)
\item Records could be use in submodules (separated inputs and outputs)
\end{itemize}
\section*{Suffixes}
\begin{itemize}
\item \textit{\_i} input port
\item \textit{\_o} output port
\item \textit{\_io} bidirectional port
\item \textit{\_n\_i} active low input port
\item \textit{\_n\_o} active low output port
\item \textit{\_r} internal register
\item \textit{\_t} defined type
\end{itemize}
\section*{Labels}
\begin{itemize}
\item Use \textit{p\_} for processes
\item Use \textit{i\_} for instantiations
\item Use \textit{g\_} for generates
\item Put the label in the same line of its target
\item Use the full \textit{end} form
\end{itemize}
\section*{Common abbreviations}
\begin{itemize}
\item \textit{ack:} acknowledge
\item \textit{addr:} address
\item \textit{clk:} clock
\item \textit{cnt, count:} counter
\item \textit{ctrl:} control
\item \textit{ena:} enable
\item \textit{idx:} index
\item \textit{irq:} interrupt
\item \textit{num:} number (of)
\item \textit{ptr:} pointer
\item \textit{re, rena:} read enable
\item \textit{rd:} read
\item \textit{rst:} reset
\item \textit{stb:} strobe
\item \textit{we, wena:} write enable
\item \textit{wr:} write
\end{itemize}
\end{multicols}
% FSM one process
% * enumeration/parameters
% Clock starvation
% Component, functions and procedures in package
% Signal declaration. No global, no shared
% Variables for intermediate values
% -------------------------------------------------------------------------------------------------
%\newpage
%\chead{HDL Conventions}
%\begin{multicols}{3}
% \section*{Ranges}
% \begin{itemize}
% \item Use a range for integers and subtypes (synthesis)
% \item Use downto for std\_logic\_vector and subtypes
% \end{itemize}
%\end{multicols}
% Full sync
% -------------------------------------------------------------------------------------------------
\end{document}
|
% sandwich_solve solves the linear equation X=A*X*B+C
%
% ::
%
% [X,retcode]=sandwich_solve(A,B,C)
%
% Args:
% - A :
% - B :
% - C :
%
% Returns:
% :
% - X :
% - retcode :
%
% Note:
%
% Example:
%
% See also:
% |
lemma starlike_imp_contractible_gen: fixes S :: "'a::real_normed_vector set" assumes S: "starlike S" and P: "\<And>a T. \<lbrakk>a \<in> S; 0 \<le> T; T \<le> 1\<rbrakk> \<Longrightarrow> P(\<lambda>x. (1 - T) *\<^sub>R x + T *\<^sub>R a)" obtains a where "homotopic_with_canon P S S (\<lambda>x. x) (\<lambda>x. a)" |
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
-----------------------------------------------------------------------------
-- |
-- Copyright : (c) Edward Kmett 2010-2021
-- License : BSD3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : GHC only
--
-----------------------------------------------------------------------------
module Numeric.AD.Mode
(
-- * AD modes
Mode(..)
, pattern KnownZero
, pattern Auto
) where
import Numeric.Natural
import Data.Complex
import Data.Int
import Data.Ratio
import Data.Word
infixr 7 *^
infixl 7 ^*
infixr 7 ^/
class (Num t, Num (Scalar t)) => Mode t where
type Scalar t
type Scalar t = t
-- | allowed to return False for items with a zero derivative, but we'll give more NaNs than strictly necessary
isKnownConstant :: t -> Bool
isKnownConstant _ = False
asKnownConstant :: t -> Maybe (Scalar t)
asKnownConstant _ = Nothing
-- | allowed to return False for zero, but we give more NaN's than strictly necessary
isKnownZero :: t -> Bool
isKnownZero _ = False
-- | Embed a constant
auto :: Scalar t -> t
default auto :: (Scalar t ~ t) => Scalar t -> t
auto = id
-- | Scalar-vector multiplication
(*^) :: Scalar t -> t -> t
a *^ b = auto a * b
-- | Vector-scalar multiplication
(^*) :: t -> Scalar t -> t
a ^* b = a * auto b
-- | Scalar division
(^/) :: Fractional (Scalar t) => t -> Scalar t -> t
a ^/ b = a ^* recip b
-- |
-- @'zero' = 'lift' 0@
zero :: t
zero = auto 0
pattern KnownZero :: Mode s => s
pattern KnownZero <- (isKnownZero -> True) where
KnownZero = zero
pattern Auto :: Mode s => Scalar s -> s
pattern Auto n <- (asKnownConstant -> Just n) where
Auto n = auto n
instance Mode Double where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Float where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Int where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Integer where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Int8 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Int16 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Int32 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Int64 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Natural where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Word where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Word8 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Word16 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Word32 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Mode Word64 where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance RealFloat a => Mode (Complex a) where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
instance Integral a => Mode (Ratio a) where
isKnownConstant _ = True
asKnownConstant = Just
isKnownZero x = 0 == x
(^/) = (/)
|
theory PhiSem_CF_Routine_Basic
imports PhiSem_CF_Basic
begin
section \<open>Routine\<close>
text \<open>Procedure in \<open>\<phi>\<close>-system is a program segment, which does not correspond to a function
in the target language necessarily. To model them, we formalize a specific semantic statement
and we call them \<^emph>\<open>routine\<close> to distinguish with \<^emph>\<open>procedure\<close>.\<close>
definition op_routine_basic :: \<open>TY list \<Rightarrow> TY list \<Rightarrow> ('a::FIX_ARITY_VALs, 'b::FIX_ARITY_VALs) proc' \<Rightarrow> ('a,'b) proc'\<close>
where \<open>op_routine_basic argtys rettys F = (\<lambda>args.
\<phi>M_assert (args \<in> Well_Typed_Vals argtys)
\<ggreater> F args
\<bind> (\<lambda>rets. \<phi>M_assert (rets \<in> Well_Typed_Vals rettys)
\<ggreater> Return rets))\<close>
lemma "__routine_basic__":
\<open> \<phi>_Have_Types X TY_ARGs
\<Longrightarrow> \<phi>_Have_Types Y TY_RETs
\<Longrightarrow> \<r>Success
\<Longrightarrow> (\<And>(vs:: 'a::FIX_ARITY_VALs \<phi>arg <named> 'names).
\<p>\<r>\<o>\<c> F (case_named id vs) \<lbrace> X (case_named id vs) \<longmapsto> Y \<rbrace> \<t>\<h>\<r>\<o>\<w>\<s> E)
\<Longrightarrow> \<p>\<r>\<o>\<c> op_routine_basic TY_ARGs TY_RETs F vs \<lbrace> X vs \<longmapsto> Y \<rbrace> \<t>\<h>\<r>\<o>\<w>\<s> E\<close>
unfolding op_routine_basic_def \<phi>_Have_Types_def named_All named.case id_apply
by (rule \<phi>SEQ, rule \<phi>SEQ, rule \<phi>M_assert, blast, assumption, rule \<phi>SEQ,
rule \<phi>M_assert, blast, rule \<phi>M_Success')
ML_file \<open>library/cf_routine.ML\<close>
attribute_setup routine_basic =
\<open>Scan.succeed (Phi_Modifier.wrap_to_attribute
(PhiSem_Control_Flow.routine_mod I (K I) @{thm "__routine_basic__"}))\<close>
end |
function [success] = omparameter (modelname,name,wert);
% Change parameter in *_init.txt file; Returns linenumber replaced if
% succeeded, -1 if not.
% SYNTAX: [linenumber] = omparameter(modelname,parameter,value)
% Beispiel: omparameter('package.model','stop value',10)
%
% Feedback/problems: Christian Schaad, [email protected]
success=-1;
inputfile=[modelname,'_init_original.xml'];
outputfile=[modelname,'_init.xml'];
%def_output=['outputFormat = "mat"'];
%plt_output=['outputFormat = "plt"'];
fid=fopen(inputfile);
i=0;
while 1
i=i+1;
tline0 = fgetl(fid);
if ~ischar(tline0), break, end
tline= [tline0,char(10)];
%if ~isempty(strfind(tline,def_output));
%tline=[plt_output,char(10)];
%disp('MAT-Output changed to PLT-Output')
%end
if ~isempty(strfind(tline,['name = "',name,'"',char(10)]))
for k=0:7
dataset(i+k).string=tline;
tline0 = fgetl(fid);
tline= [tline0,char(10)];
end
i=i+k+1;
tline=['<Real start="',wert,'" fixed="true" />',char(10) ];
%disp(tline)
success=i;
end
dataset(i).string=tline;
clear tline tline0;
end
fclose(fid);
fid=fopen(outputfile,'w');
for j=1:i-1
fprintf(fid,[dataset(j).string]);
end
fclose(fid);
switch success
case -1
error(['Parameter ',name,' not found!']);
end;
disp(['Replaced line number ',num2str(success),', parameter ',num2str(name),' with ',num2str(wert) ]);
|
[STATEMENT]
lemma fMax_fold [code]: "fMax (fset_of_list (a#as)) = fold max as a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fMax (fset_of_list (a # as)) = fold max as a
[PROOF STEP]
by (metis Max.set_eq_fold fMax.F.rep_eq fset_of_list.rep_eq) |
module Feldspar
( module Prelude.EDSL
, module Control.Monad
-- * Types
-- ** Syntax
, Data
, Syntax
, Comp
-- ** Object-language types
, module Data.Int
, module Data.Word
, Complex (..)
, PrimType'
, PrimType
, Type
, Length
, Index
, Ref, DRef
, Arr, DArr
, IArr, DIArr
, Inhabited
, Syntactic
, Domain
, Internal
-- * Front end
, eval
, showAST
, drawAST
, module Feldspar.Frontend
, Bits
, FiniteBits
, Integral
, Ord
, RealFloat
, RealFrac
, Border (..)
, IxRange
, AssertionLabel (..)
) where
import Prelude.EDSL
import Control.Monad hiding (foldM)
import Data.Bits (Bits, FiniteBits)
import Data.Complex (Complex (..))
import Data.Int
import Data.Word
import Language.Syntactic (Syntactic, Domain, Internal)
import qualified Language.Syntactic as Syntactic
import Language.Embedded.Imperative (Border (..), IxRange)
import Data.Inhabited
import Feldspar.Primitive.Representation
import Feldspar.Representation
import Feldspar.Frontend
import Feldspar.Optimize
-- | Show the syntax tree using Unicode art
--
-- Only user assertions will be included.
showAST :: (Syntactic a, Domain a ~ FeldDomain) => a -> String
showAST = Syntactic.showAST . optimize onlyUserAssertions . Syntactic.desugar
-- | Draw the syntax tree on the terminal using Unicode art
--
-- Only user assertions will be included.
drawAST :: (Syntactic a, Domain a ~ FeldDomain) => a -> IO ()
drawAST = Syntactic.drawAST . optimize onlyUserAssertions . Syntactic.desugar
|
lemma algebraic_int_minus_iff [simp]: "algebraic_int (-x) \<longleftrightarrow> algebraic_int (x :: 'a :: field_char_0)" |
Require Import NArith Ring Monoid_instances Euclidean_Chains Pow
Strategies Dichotomy BinaryStrat.
Import Addition_Chains.
Open Scope N_scope.
(* begin snippet FibDef *)
Fixpoint fib (n:nat) : N :=
match n with
0%nat | 1%nat => 1
| (S ((S p) as q)) => fib p + fib q
end.
Compute fib 20.
(* end snippet FibDef *)
Lemma fib_ind (P:nat->Prop) :
P 0%nat -> P 1%nat -> (forall n, P n -> P (S n) -> P(S (S n))) ->
forall n, P n.
Proof.
intros H0 H1 HS n; assert (P n /\ P (S n)).
{ induction n.
- split;auto.
- destruct IHn; split; auto.
}
tauto.
Qed.
Lemma fib_SSn : forall (n:nat) , fib (S (S n)) = (fib n + fib (S n)).
Proof.
intro n; pattern n; apply fib_ind; try reflexivity.
Qed.
(** Yves' encoding *)
(* begin snippet mul2Def *)
Definition mul2 (p q : N * N) :=
match p, q with
(a, b),(c,d) => (a*c + a*d + b*c, a*c + b*d)
end.
(* end snippet mul2Def *)
Lemma neutral_l p : mul2 (0,1) p = p.
unfold mul2. destruct p; f_equal; ring.
Qed.
Lemma neutral_r p : mul2 p (0,1) = p.
unfold mul2. destruct p; f_equal; ring.
Qed.
(* begin snippet mul2Monoid *)
#[ global ] Instance Mul2 : Monoid mul2 (0,1).
(* end snippet mul2Monoid *)
Proof.
split.
destruct x,y,z; unfold mul2; cbn; f_equal; ring.
intro x; now rewrite neutral_l.
intro x; now rewrite neutral_r.
Qed.
(* begin snippet nextFib:: no-out *)
Lemma next_fib (n:nat) : mul2 (1,0) (fib (S n), fib n) =
(fib (S (S n)), fib (S n)).
(* end snippet nextFib *)
Proof.
unfold mul2; f_equal; ring_simplify.
- rewrite fib_SSn. ring.
- reflexivity.
Qed.
(* begin snippet fibMul2Def *)
Definition fib_mul2 n := let (a,b) := power (M:=Mul2) (1,0) n
in (a+b).
Compute fib_mul2 20.
(* end snippet fibMul2Def *)
(* begin snippet fibMul2OK0:: no-out *)
Lemma fib_mul2_OK_0 (n:nat) :
power (M:=Mul2) (1,0) (S (S n)) =
(fib (S n), fib n).
Proof.
induction n.
(* ... *)
(* end snippet fibMul2OK0 *)
- reflexivity.
- now rewrite power_eq2, IHn, next_fib.
Qed.
(* begin snippet fibMul2OK:: no-out *)
Lemma fib_mul2_OK n : fib n = fib_mul2 n.
(* end snippet fibMul2OK *)
Proof.
unfold fib_mul2; pattern n;apply fib_ind; try reflexivity.
- intros; rewrite fib_mul2_OK_0; now rewrite fib_SSn, N.add_comm.
Qed.
(* begin snippet TimeFibMul2 *)
Time Compute fib_mul2 87.
(* end snippet TimeFibMul2 *)
(* begin snippet fibPos *)
Definition fib_pos n :=
let (a,b) := Pos_bpow (M:= Mul2) (1,0) n in
(a+b).
Compute fib_pos xH.
Compute fib_pos 10%positive.
Time Compute fib_pos 153%positive.
(* end snippet fibPos *)
Locate chain_apply.
About chain_apply.
(* begin snippet fibEuclDemo *)
Definition fib_eucl gamma `{Hgamma: Strategy gamma} n :=
let c := make_chain gamma n
in let r := chain_apply c (M:=Mul2) (1,0) in
fst r + snd r.
Time Compute fib_eucl dicho 153.
Time Compute fib_eucl two 153.
Time Compute fib_eucl half 153.
(* end snippet fibEuclDemo *)
(* 68330027629092351019822533679447
: N
Finished transaction in 0.002 secs (0.002u,0.s) (successful)
*)
Require Import AM.
Definition fib_with_chain c :=
match chain_apply c Mul2 (1,0) with
Some ((a,b), nil) => Some (a+b) | _ => None end.
Definition c153 := chain_gen dicho (gen_F 153%positive).
Compute c153.
(*
= (PUSH :: SQR :: SQR :: SQR :: MUL :: PUSH ::
SQR :: SQR :: SQR :: SQR :: MUL :: nil)%list
: code
*)
(* number of multiplications and squares *)
Compute mults_squares c153.
Compute fib_with_chain c153 .
(*
= Some 68330027629092351019822533679447
: option N
*)
Compute mults_squares (chain_gen dicho (gen_F 30000%positive)).
(* = (6%nat, 13%nat)
: nat * nat *)
|
deriving instance TypeName for Nat
deriving instance TypeName for String
example : (Dynamic.mk 42).get? String = none := by native_decide
example : (Dynamic.mk 42).get? Nat = some 42 := by native_decide
example : (Dynamic.mk 42).typeName = ``Nat := by native_decide
|
[STATEMENT]
theorem par_com: "tr1 \<parallel> tr2 = tr2 \<parallel> tr1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
let ?\<theta> = "\<lambda> trA trB. \<exists> tr1 tr2. trA = tr1 \<parallel> tr2 \<and> trB = tr2 \<parallel> tr1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
fix trA trB
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
assume "?\<theta> trA trB"
[PROOF STATE]
proof (state)
this:
\<exists>tr1 tr2. trA = tr1 \<parallel> tr2 \<and> trB = tr2 \<parallel> tr1
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
hence "trA = trB"
[PROOF STATE]
proof (prove)
using this:
\<exists>tr1 tr2. trA = tr1 \<parallel> tr2 \<and> trB = tr2 \<parallel> tr1
goal (1 subgoal):
1. trA = trB
[PROOF STEP]
apply (induct rule: dtree_coinduct)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>tr1 tr2. \<exists>tr1a tr2a. tr1 = tr1a \<parallel> tr2a \<and> tr2 = tr2a \<parallel> tr1a \<Longrightarrow> root tr1 = root tr2 \<and> rel_set (rel_sum (=) (\<lambda>a b. \<exists>tr1 tr2. a = tr1 \<parallel> tr2 \<and> b = tr2 \<parallel> tr1)) (cont tr1) (cont tr2)
[PROOF STEP]
unfolding rel_set_rel_sum rel_set_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>tr1 tr2. \<exists>tr1a tr2a. tr1 = tr1a \<parallel> tr2a \<and> tr2 = tr2a \<parallel> tr1a \<Longrightarrow> root tr1 = root tr2 \<and> Inl -` cont tr1 = Inl -` cont tr2 \<and> rel_set (\<lambda>a b. \<exists>tr1 tr2. a = tr1 \<parallel> tr2 \<and> b = tr2 \<parallel> tr1) (Inr -` cont tr1) (Inr -` cont tr2)
[PROOF STEP]
unfolding rel_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>tr1 tr2. \<exists>tr1a tr2a. tr1 = tr1a \<parallel> tr2a \<and> tr2 = tr2a \<parallel> tr1a \<Longrightarrow> root tr1 = root tr2 \<and> Inl -` cont tr1 = Inl -` cont tr2 \<and> (\<forall>x\<in>Inr -` cont tr1. \<exists>a\<in>Inr -` cont tr2. \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1) \<and> (\<forall>y\<in>Inr -` cont tr2. \<exists>x\<in>Inr -` cont tr1. \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. \<And>tr1 tr2 tr1a tr2a. root (tr1a \<parallel> tr2a) = root (tr2a \<parallel> tr1a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> x \<in> Inl -` cont (tr2a \<parallel> tr1a)
3. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
4. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
5. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
fix tr1 tr2
[PROOF STATE]
proof (state)
goal (5 subgoals):
1. \<And>tr1 tr2 tr1a tr2a. root (tr1a \<parallel> tr2a) = root (tr2a \<parallel> tr1a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> x \<in> Inl -` cont (tr2a \<parallel> tr1a)
3. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
4. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
5. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
show "root (tr1 \<parallel> tr2) = root (tr2 \<parallel> tr1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. root (tr1 \<parallel> tr2) = root (tr2 \<parallel> tr1)
[PROOF STEP]
unfolding root_par
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. root tr1 + root tr2 = root tr2 + root tr1
[PROOF STEP]
by (rule Nplus_comm)
[PROOF STATE]
proof (state)
this:
root (tr1 \<parallel> tr2) = root (tr2 \<parallel> tr1)
goal (4 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> x \<in> Inl -` cont (tr2a \<parallel> tr1a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
3. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
4. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> x \<in> Inl -` cont (tr2a \<parallel> tr1a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
3. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
4. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
fix n tr1 tr2
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> x \<in> Inl -` cont (tr2a \<parallel> tr1a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
3. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
4. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
assume "Inl n \<in> cont (tr1 \<parallel> tr2)"
[PROOF STATE]
proof (state)
this:
Inl n \<in> cont (tr1 \<parallel> tr2)
goal (4 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> x \<in> Inl -` cont (tr2a \<parallel> tr1a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
3. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
4. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
thus "n \<in> Inl -` (cont (tr2 \<parallel> tr1))"
[PROOF STATE]
proof (prove)
using this:
Inl n \<in> cont (tr1 \<parallel> tr2)
goal (1 subgoal):
1. n \<in> Inl -` cont (tr2 \<parallel> tr1)
[PROOF STEP]
unfolding Inl_in_cont_par
[PROOF STATE]
proof (prove)
using this:
Inl n \<in> cont tr1 \<or> Inl n \<in> cont tr2
goal (1 subgoal):
1. n \<in> Inl -` cont (tr2 \<parallel> tr1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n \<in> Inl -` cont (tr2 \<parallel> tr1)
goal (3 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
3. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
3. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
fix n tr1 tr2
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
3. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
assume "Inl n \<in> cont (tr2 \<parallel> tr1)"
[PROOF STATE]
proof (state)
this:
Inl n \<in> cont (tr2 \<parallel> tr1)
goal (3 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inl x \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> x \<in> Inl -` cont (tr1a \<parallel> tr2a)
2. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
3. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
thus "n \<in> Inl -` (cont (tr1 \<parallel> tr2))"
[PROOF STATE]
proof (prove)
using this:
Inl n \<in> cont (tr2 \<parallel> tr1)
goal (1 subgoal):
1. n \<in> Inl -` cont (tr1 \<parallel> tr2)
[PROOF STEP]
unfolding Inl_in_cont_par
[PROOF STATE]
proof (prove)
using this:
Inl n \<in> cont tr2 \<or> Inl n \<in> cont tr1
goal (1 subgoal):
1. n \<in> Inl -` cont (tr1 \<parallel> tr2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n \<in> Inl -` cont (tr1 \<parallel> tr2)
goal (2 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
2. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
2. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
fix tr1 tr2 trA'
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
2. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
assume "Inr trA' \<in> cont (tr1 \<parallel> tr2)"
[PROOF STATE]
proof (state)
this:
Inr trA' \<in> cont (tr1 \<parallel> tr2)
goal (2 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
2. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Inr trA' \<in> cont (tr1 \<parallel> tr2)
[PROOF STEP]
obtain tr1' tr2' where "trA' = tr1' \<parallel> tr2'"
and "Inr tr1' \<in> cont tr1" and "Inr tr2' \<in> cont tr2"
[PROOF STATE]
proof (prove)
using this:
Inr trA' \<in> cont (tr1 \<parallel> tr2)
goal (1 subgoal):
1. (\<And>tr1' tr2'. \<lbrakk>trA' = tr1' \<parallel> tr2'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding Inr_in_cont_par
[PROOF STATE]
proof (prove)
using this:
trA' \<in> par ` (Inr -` cont tr1 \<times> Inr -` cont tr2)
goal (1 subgoal):
1. (\<And>tr1' tr2'. \<lbrakk>trA' = tr1' \<parallel> tr2'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trA' = tr1' \<parallel> tr2'
Inr tr1' \<in> cont tr1
Inr tr2' \<in> cont tr2
goal (2 subgoals):
1. \<And>tr1 tr2 tr1a tr2a x xa. Inr x \<in> cont (tr1a \<parallel> tr2a) \<Longrightarrow> \<exists>a\<in>Inr -` cont (tr2a \<parallel> tr1a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> a = tr2 \<parallel> tr1
2. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
thus "\<exists> trB' \<in> Inr -` (cont (tr2 \<parallel> tr1)). ?\<theta> trA' trB'"
[PROOF STATE]
proof (prove)
using this:
trA' = tr1' \<parallel> tr2'
Inr tr1' \<in> cont tr1
Inr tr2' \<in> cont tr2
goal (1 subgoal):
1. \<exists>trB'\<in>Inr -` cont (tr2 \<parallel> tr1). \<exists>tr1 tr2. trA' = tr1 \<parallel> tr2 \<and> trB' = tr2 \<parallel> tr1
[PROOF STEP]
apply(intro bexI[of _ "tr2' \<parallel> tr1'"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>trA' = tr1' \<parallel> tr2'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> \<exists>tr1 tr2. trA' = tr1 \<parallel> tr2 \<and> tr2' \<parallel> tr1' = tr2 \<parallel> tr1
2. \<lbrakk>trA' = tr1' \<parallel> tr2'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> tr2' \<parallel> tr1' \<in> Inr -` cont (tr2 \<parallel> tr1)
[PROOF STEP]
unfolding Inr_in_cont_par
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>trA' = tr1' \<parallel> tr2'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> \<exists>tr1 tr2. trA' = tr1 \<parallel> tr2 \<and> tr2' \<parallel> tr1' = tr2 \<parallel> tr1
2. \<lbrakk>trA' = tr1' \<parallel> tr2'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> tr2' \<parallel> tr1' \<in> Inr -` cont (tr2 \<parallel> tr1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>trB'\<in>Inr -` cont (tr2 \<parallel> tr1). \<exists>tr1 tr2. trA' = tr1 \<parallel> tr2 \<and> trB' = tr2 \<parallel> tr1
goal (1 subgoal):
1. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
fix tr1 tr2 trB'
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
assume "Inr trB' \<in> cont (tr2 \<parallel> tr1)"
[PROOF STATE]
proof (state)
this:
Inr trB' \<in> cont (tr2 \<parallel> tr1)
goal (1 subgoal):
1. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Inr trB' \<in> cont (tr2 \<parallel> tr1)
[PROOF STEP]
obtain tr1' tr2' where "trB' = tr2' \<parallel> tr1'"
and "Inr tr1' \<in> cont tr1" and "Inr tr2' \<in> cont tr2"
[PROOF STATE]
proof (prove)
using this:
Inr trB' \<in> cont (tr2 \<parallel> tr1)
goal (1 subgoal):
1. (\<And>tr2' tr1'. \<lbrakk>trB' = tr2' \<parallel> tr1'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding Inr_in_cont_par
[PROOF STATE]
proof (prove)
using this:
trB' \<in> par ` (Inr -` cont tr2 \<times> Inr -` cont tr1)
goal (1 subgoal):
1. (\<And>tr2' tr1'. \<lbrakk>trB' = tr2' \<parallel> tr1'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trB' = tr2' \<parallel> tr1'
Inr tr1' \<in> cont tr1
Inr tr2' \<in> cont tr2
goal (1 subgoal):
1. \<And>tr1 tr2 tr1a tr2a y x. Inr y \<in> cont (tr2a \<parallel> tr1a) \<Longrightarrow> \<exists>x\<in>Inr -` cont (tr1a \<parallel> tr2a). \<exists>tr1 tr2. x = tr1 \<parallel> tr2 \<and> y = tr2 \<parallel> tr1
[PROOF STEP]
thus "\<exists> trA' \<in> Inr -` (cont (tr1 \<parallel> tr2)). ?\<theta> trA' trB'"
[PROOF STATE]
proof (prove)
using this:
trB' = tr2' \<parallel> tr1'
Inr tr1' \<in> cont tr1
Inr tr2' \<in> cont tr2
goal (1 subgoal):
1. \<exists>trA'\<in>Inr -` cont (tr1 \<parallel> tr2). \<exists>tr1 tr2. trA' = tr1 \<parallel> tr2 \<and> trB' = tr2 \<parallel> tr1
[PROOF STEP]
apply(intro bexI[of _ "tr1' \<parallel> tr2'"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>trB' = tr2' \<parallel> tr1'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> \<exists>tr1 tr2. tr1' \<parallel> tr2' = tr1 \<parallel> tr2 \<and> trB' = tr2 \<parallel> tr1
2. \<lbrakk>trB' = tr2' \<parallel> tr1'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> tr1' \<parallel> tr2' \<in> Inr -` cont (tr1 \<parallel> tr2)
[PROOF STEP]
unfolding Inr_in_cont_par
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<lbrakk>trB' = tr2' \<parallel> tr1'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> \<exists>tr1 tr2. tr1' \<parallel> tr2' = tr1 \<parallel> tr2 \<and> trB' = tr2 \<parallel> tr1
2. \<lbrakk>trB' = tr2' \<parallel> tr1'; Inr tr1' \<in> cont tr1; Inr tr2' \<in> cont tr2\<rbrakk> \<Longrightarrow> tr1' \<parallel> tr2' \<in> Inr -` cont (tr1 \<parallel> tr2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>trA'\<in>Inr -` cont (tr1 \<parallel> tr2). \<exists>tr1 tr2. trA' = tr1 \<parallel> tr2 \<and> trB' = tr2 \<parallel> tr1
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
trA = trB
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<exists>tr1 tr2. ?trA2 = tr1 \<parallel> tr2 \<and> ?trB2 = tr2 \<parallel> tr1 \<Longrightarrow> ?trA2 = ?trB2
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>tr1 tr2. ?trA2 = tr1 \<parallel> tr2 \<and> ?trB2 = tr2 \<parallel> tr1 \<Longrightarrow> ?trA2 = ?trB2
goal (1 subgoal):
1. tr1 \<parallel> tr2 = tr2 \<parallel> tr1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
tr1 \<parallel> tr2 = tr2 \<parallel> tr1
goal:
No subgoals!
[PROOF STEP]
qed |
[STATEMENT]
lemma (in edge_space) random_prob_independent:
assumes "n \<ge> k" "k \<ge> 2"
shows "prob {es \<in> space P. k \<le> \<alpha> (edge_ugraph es)}
\<le> (n choose k)*(1-p)^(k choose 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
let "?k_sets" = "{vs. vs \<subseteq> S_verts \<and> card vs = k}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
fix vs
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
assume A: "vs \<in> ?k_sets"
[PROOF STATE]
proof (state)
this:
vs \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k}
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vs \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k}
[PROOF STEP]
have B: "all_edges vs \<subseteq> S_edges"
[PROOF STATE]
proof (prove)
using this:
vs \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k}
goal (1 subgoal):
1. all_edges vs \<subseteq> S_edges
[PROOF STEP]
unfolding all_edges_def S_edges_def
[PROOF STATE]
proof (prove)
using this:
vs \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k}
goal (1 subgoal):
1. mk_uedge ` {uv \<in> vs \<times> vs. fst uv \<noteq> snd uv} \<subseteq> mk_uedge ` {uv \<in> S_verts \<times> S_verts. fst uv \<noteq> snd uv}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
all_edges vs \<subseteq> S_edges
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
have "{es \<in> space P. vs \<in> independent_sets (edge_ugraph es)}
= cylinder S_edges {} (all_edges vs)" (is "?L = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = cylinder S_edges {} (all_edges vs)
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
vs \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k}
goal (1 subgoal):
1. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = cylinder S_edges {} (all_edges vs)
[PROOF STEP]
by (auto simp: independent_sets_def edge_ugraph_def space_eq cylinder_def)
[PROOF STATE]
proof (state)
this:
{es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = cylinder S_edges {} (all_edges vs)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = cylinder S_edges {} (all_edges vs)
[PROOF STEP]
have "prob ?L = (1-p)^(k choose 2)"
[PROOF STATE]
proof (prove)
using this:
{es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = cylinder S_edges {} (all_edges vs)
goal (1 subgoal):
1. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = (1 - p) ^ (k choose 2)
[PROOF STEP]
using A B finite
[PROOF STATE]
proof (prove)
using this:
{es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = cylinder S_edges {} (all_edges vs)
vs \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k}
all_edges vs \<subseteq> S_edges
finite ?A
goal (1 subgoal):
1. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = (1 - p) ^ (k choose 2)
[PROOF STEP]
by (auto simp: cylinder_prob card_all_edges dest: finite_subset)
[PROOF STATE]
proof (state)
this:
prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)} = (1 - p) ^ (k choose 2)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?vs3 \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k} \<Longrightarrow> prob {es \<in> space P. ?vs3 \<in> independent_sets (edge_ugraph es)} = (1 - p) ^ (k choose 2)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
note prob_k_indep = this
\<comment> \<open>probability that a fixed set of k vertices is independent in a random graph\<close>
[PROOF STATE]
proof (state)
this:
?vs3 \<in> {vs. vs \<subseteq> S_verts \<and> card vs = k} \<Longrightarrow> prob {es \<in> space P. ?vs3 \<in> independent_sets (edge_ugraph es)} = (1 - p) ^ (k choose 2)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
have "{es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)}
= (\<Union>vs \<in> ?k_sets. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})" (is "?L = ?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} = (\<Union>vs\<in>{vs. vs \<subseteq> S_verts \<and> card vs = k}. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
[PROOF STEP]
unfolding image_def space_eq independent_sets_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. {es \<in> Pow S_edges. k \<in> {y. \<exists>x\<in>{vs. vs \<subseteq> uverts (edge_ugraph es) \<and> all_edges vs \<inter> uedges (edge_ugraph es) = {}}. y = card x}} = \<Union> {y. \<exists>x\<in>{vs. vs \<subseteq> S_verts \<and> card vs = k}. y = {es \<in> Pow S_edges. x \<in> {vs. vs \<subseteq> uverts (edge_ugraph es) \<and> all_edges vs \<inter> uedges (edge_ugraph es) = {}}}}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} = (\<Union>vs\<in>{vs. vs \<subseteq> S_verts \<and> card vs = k}. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} = (\<Union>vs\<in>{vs. vs \<subseteq> S_verts \<and> card vs = k}. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
[PROOF STEP]
have "prob ?L \<le> (\<Sum>vs \<in> ?k_sets. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})"
[PROOF STATE]
proof (prove)
using this:
{es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} = (\<Union>vs\<in>{vs. vs \<subseteq> S_verts \<and> card vs = k}. {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
goal (1 subgoal):
1. prob {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} \<le> (\<Sum>vs | vs \<subseteq> S_verts \<and> card vs = k. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
[PROOF STEP]
by (auto intro!: finite_measure_subadditive_finite simp: space_eq sets_eq)
[PROOF STATE]
proof (state)
this:
prob {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} \<le> (\<Sum>vs | vs \<subseteq> S_verts \<and> card vs = k. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prob {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} \<le> (\<Sum>vs | vs \<subseteq> S_verts \<and> card vs = k. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)})
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
have "\<dots> = (n choose k)*((1 - p) ^ (k choose 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<Sum>vs | vs \<subseteq> S_verts \<and> card vs = k. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)}) = real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
by (simp add: prob_k_indep S_verts_def n_subsets)
[PROOF STATE]
proof (state)
this:
(\<Sum>vs | vs \<subseteq> S_verts \<and> card vs = k. prob {es \<in> space P. vs \<in> independent_sets (edge_ugraph es)}) = real (n choose k) * (1 - p) ^ (k choose 2)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
prob {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prob {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
using \<open>k \<ge> 2\<close>
[PROOF STATE]
proof (prove)
using this:
prob {es \<in> space P. k \<in> card ` independent_sets (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
2 \<le> k
goal (1 subgoal):
1. prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
[PROOF STEP]
by (simp add: le_\<alpha>_iff)
[PROOF STATE]
proof (state)
this:
prob {es \<in> space P. enat k \<le> \<alpha> (edge_ugraph es)} \<le> real (n choose k) * (1 - p) ^ (k choose 2)
goal:
No subgoals!
[PROOF STEP]
qed |
function figure_num = cube3d_grid_plot ( x1, x2, x3, filename, figure_num )
%*****************************************************************************80
%
%% CUBE3D_GRID_PLOT plots hypersphere gridpoints onto the surface of a 3D cube.
%
% Discussion:
%
% The X1, X2, X3 data has, presumably, been computed by CUBE_GRID for
% a 3D cube.
%
% This function plots the surface, and then the surface plus the
% projected grid points.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 20 May 2013
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, real X1(2*N+1,N+1), X2(2*N+1,N+1), X3(2*N+1,N+1), the coordinates
% of points on the cube surface, projected from the hypersphere.
%
% Input, string FILENAME, the "first name" of the two files to be created:
% filename_surface.png and filename_points.png.
%
% Input/output, int FIGURE_NUM, the current figure index.
%
if ( nargin < 4 )
filename = 'cube';
end
%
% Draw the surface.
%
figure_num = figure_num + 1;
figure ( figure_num )
mesh ( x3, x2, x1, 'FaceColor', 'interp' );
axis equal
grid on
xlabel ( '<---X--->', 'FontSize', 16 );
ylabel ( '<---Y--->', 'FontSize', 16 );
zlabel ( '<---Z--->', 'FontSize', 16 );
title ( 'Cube transition surface', 'FontSize', 24 )
hold off
filename1 = sprintf ( '%s_surface.png', filename );
print ( '-dpng', filename1 );
fprintf ( 1, '\n' );
fprintf ( 1, ' Created plotfile "%s".\n', filename1 );
%
% Draw the surface and points.
%
% Listing the points in the order X1, X2, X3, rational as it may seem,
% is apparently NOT the way to go here.
%
figure_num = figure_num + 1;
figure ( figure_num )
hold on
mesh ( x3, x2, x1, 'FaceColor', 'interp' );
plot3 ( x3, x2, x1, 'k.', 'MarkerSize', 5 );
axis equal
grid on
xlabel ( '<---X--->', 'FontSize', 16 );
ylabel ( '<---Y--->', 'FontSize', 16 );
zlabel ( '<---Z--->', 'FontSize', 16 );
title ( 'Grid points on transition surface', 'FontSize', 24 )
hold off
filename2 = sprintf ( '%s_points.png', filename );
print ( '-dpng', filename2 );
fprintf ( 1, ' Created plotfile "%s".\n', filename2 );
return
end
|
module Oscar.Property where
open import Oscar.Builtin.Numbatural
open import Oscar.Builtin.Objectevel
𝑴 : ℕ → ∀ {𝔬} → Ø 𝔬 → ∀ 𝔪 → Ø 𝔬 ∙̂ ↑̂ 𝔪
𝑴 ∅ 𝔒 𝔪 = 𝔒 → Ø 𝔪
𝑴 (↑ n) 𝔒 𝔪 = 𝔒 → 𝑴 n 𝔒 𝔪
𝑴² : ∀ (m : ℕ) n {𝔬} {𝔒 : Ø 𝔬} {𝔪} → 𝑴 n 𝔒 𝔪 → ∀ 𝔮 → Ø 𝔬 ∙̂ 𝔪 ∙̂ ↑̂ 𝔮
𝑴² m ∅ 𝔒 𝔮 = ∀ {o} → 𝑴 m (𝔒 o) 𝔮
𝑴² m (↑ n) 𝔒 𝔮 = ∀ {o} → 𝑴² m n (𝔒 o) 𝔮
|
* Compute The Average Score For Each Student
Read(*,*)N
100 Read(*,*)S1,S2,S3,S4
Sum=S1+S2+S3+S4
Average=Sum/4
write(*,*) S1,S2,S3,S4, Average
N=N-1
If(N.eq.0)go to 10
Go to 100
10 Stop
End
|
/-
Copyright (c) 2021 Ashvni Narayanan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ashvni Narayanan
-/
import general_bernoulli_number.lim_even_character_of_units
/-!
# A convergence property regarding (ℤ/dp^n ℤ)ˣ
This file proves the second sum in the proof of Theorem 12.2 in Introduction to Cyclotomic Fields, Washington.
It gives a convergence property relating to generalized Bernoulli numbers.
# Main Theorems
* `V`
## Tags
p-adic, L-function, Bernoulli measure, Dirichlet character
-/
open_locale big_operators
local attribute [instance] zmod.topological_space
open filter ind_fn dirichlet_character
open_locale topological_space
open_locale big_operators
variables {p : ℕ} [fact (nat.prime p)] {d : ℕ} [fact (0 < d)] {R : Type*} [normed_comm_ring R] (m : ℕ)
(hd : d.gcd p = 1) (χ : dirichlet_character R (d*(p^m))) {c : ℕ} (hc : c.gcd p = 1)
(hc' : c.gcd d = 1) (na : ∀ (n : ℕ) (f : ℕ → R),
∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(w : continuous_monoid_hom (units (zmod d) × units ℤ_[p]) R)
variables (p d R) [complete_space R] [char_zero R]
open continuous_map
variables [normed_algebra ℚ_[p] R] [fact (0 < m)]
open clopen_from
variable [fact (0 < d)]
lemma ring_equiv.eq_inv_fun_iff {α β : Type*} [semiring α] [semiring β] (h : α ≃+* β) (x : β) (y : α) :
y = h.inv_fun x ↔ h y = x := ⟨λ h, by simp only [h, ring_equiv.inv_fun_eq_symm,
ring_equiv.apply_symm_apply], λ h, by { rw [ring_equiv.inv_fun_eq_symm, ← h,
ring_equiv.symm_apply_apply], }⟩
open eventually_constant_seq clopen_from
open dirichlet_character
variable (hd)
open zmod
variable (c)
/-- The middle sum in the proof of Theorem 12.2. -/
noncomputable def V_def [algebra ℚ R] [norm_one_class R] (n : ℕ) (j : ℕ) :=
∑ (x : (zmod (d * p ^ j))ˣ), ((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R^n)) x : R) *
((((x : zmod (d * p^j))).val)^(n - 1) : R)) •
(algebra_map ℚ R) (↑c * int.fract (((((c : zmod (d * p^(2 * j))))⁻¹ : zmod (d * p^(2 * j))) * x : ℚ) / (↑d * ↑p ^ j)))
variables (hc) (hc')
/-- A part of `V_def`. -/
noncomputable def V_h_def [algebra ℚ R] [norm_one_class R] (n : ℕ) (k : ℕ) :=
∑ (x : (zmod (d * p ^ k))ˣ), (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n)) x) *
(↑(c ^ (n - 1)) * (algebra_map ℚ R) (↑(n - 1) * (↑d * (↑p ^ k *
(↑⌊↑((c : zmod (d * p^(2 * k)))⁻¹.val * ((x : zmod (d * p^k)) ).val) / ((d : ℚ) * ↑p ^ k)⌋ *
(↑d * (↑p ^ k * int.fract (((c : zmod (d * p^(2 * k)))⁻¹.val * ((x : zmod (d * p^k)) ).val : ℕ) /
((d : ℚ) * ↑p ^ k))))^(n - 1 - 1)))) * (↑c * int.fract ((((c : zmod (d * p^(2 * k)))⁻¹ : zmod (d * p^(2 * k)))
* (x : ℚ)) / ((d : ℚ) * ↑p ^ k)))))
lemma exists_V_h1_3 [algebra ℚ R] [norm_one_class R] (hc' : c.coprime d) (hc : c.coprime p)
(n k : ℕ) (hn : 0 < n) (x : (zmod (d * p^k))ˣ) : ∃ z : ℕ, ((x : zmod (d * p^k)).val)^n = c^n *
(((c : zmod (d * p^(2 * k))))⁻¹.val * (x : zmod (d * p^k)).val)^n - z * (d * p^(2 * k)) :=
begin
rw mul_pow, rw ← mul_assoc, rw ← mul_pow,
obtain ⟨z₁, hz₁⟩ := exists_mul_inv_val_eq hc' hc k,
--obtain ⟨z₂, hz₂⟩ := exists_V_h1_2 p d R c _ x,
rw hz₁,
by_cases (d * p^(2 * k)) = 1,
{ refine ⟨0, _⟩, rw zero_mul,
{ rw nat.sub_zero,
have h' : d * p^k = 1,
{ rw nat.mul_eq_one_iff, rw nat.mul_eq_one_iff at h, rw pow_mul' at h, rw pow_two at h,
rw nat.mul_eq_one_iff at h, refine ⟨h.1, h.2.1⟩, },
have : (x : (zmod (d * p ^ k))).val = 0,
{ -- better way to do this?
rw zmod.val_eq_zero, rw ← zmod.cast_id _ (x : zmod (d * p^k)), rw ← zmod.nat_cast_val,
rw zmod.nat_coe_zmod_eq_zero_iff_dvd, conv { congr, rw h', }, apply one_dvd _, },
rw this, rw zero_pow, rw mul_zero, apply hn, }, },
rw dif_pos (nat.one_lt_mul_pow_of_ne_one h),
rw add_pow, rw finset.sum_range_succ, rw one_pow, rw one_mul, rw nat.sub_self, rw pow_zero,
rw one_mul, rw nat.choose_self, rw nat.cast_one, rw add_comm, rw add_mul, rw one_mul,
simp_rw one_pow, simp_rw one_mul, simp_rw mul_pow _ (d * p^(2 * k)),
conv { congr, funext, conv { to_rhs, congr, congr, skip, congr, apply_congr, skip,
rw ← nat.succ_pred_eq_of_pos (nat.pos_of_ne_zero (finset.mem_range_sub_ne_zero H)),
rw pow_succ (d * p^(2 * k)) _, rw ← mul_assoc _ (d * p^(2 * k)) _,
rw mul_comm _ (d * p^(2 * k)), rw mul_assoc, rw mul_assoc, }, },
rw ← finset.mul_sum, rw mul_assoc, rw mul_comm (d * p^(2 * k)) _,
refine ⟨(∑ (x : ℕ) in finset.range n, z₁ ^ (n - x).pred.succ *
((d * p ^ (2 * k)) ^ (n - x).pred * ↑(n.choose x))) * (x : zmod (d * p^k)).val ^ n, _⟩,
rw nat.add_sub_cancel _ _,
end
lemma exists_V_h1_4 [algebra ℚ R] [norm_one_class R] (n k : ℕ) (hn : 0 < n) (hk : k ≠ 0)
(x : (zmod (d * p^k))ˣ) :
c^n * (((c : zmod (d * p^(2 * k))))⁻¹.val * (x : zmod (d * p^k)).val)^n >
(classical.some (exists_V_h1_3 p d R c hc' hc n k hn x)) * (d * p^(2 * k)) :=
begin
apply nat.lt_of_sub_eq_succ,
rw ← classical.some_spec (exists_V_h1_3 p d R c hc' hc _ _ hn x),
swap, { apply ((x : zmod (d * p^k)).val^n).pred, },
rw (nat.succ_pred_eq_of_pos _),
apply pow_pos _, apply nat.pos_of_ne_zero,
haveI : fact (1 < d * p^k),
{ apply fact_iff.2, refine nat.one_lt_mul_pow_of_ne_one _,
intro h,
rw nat.mul_eq_one_iff at h,
have := (pow_eq_one_iff hk).1 h.2,
apply nat.prime.ne_one (fact.out _) this, },
apply zmod.unit_ne_zero,
end
lemma sq_mul (a b : ℚ) : (a * b)^2 = a * b^2 * a := by linarith
lemma exists_V_h1_5 [algebra ℚ R] [norm_one_class R] (n k : ℕ) (hn : n ≠ 0) (x : (zmod (d * p^k))ˣ) :
∃ z : ℤ, ((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : ℕ) : ℚ)^n = (z * (d * p^(2 * k)) : ℚ) + n * (d * p^k) * ((int.floor (( (((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : ℕ)) / (d * p^k) : ℚ))))) * (d * p^k * int.fract (((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : ℕ)) / (d * p^k)))^(n - 1) + (d * p^k * int.fract (((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : ℕ)) / (d * p^k)))^n :=
begin
have h1 : (d * p^k : ℚ) ≠ 0,
{ norm_cast, refine nat.ne_zero_of_lt' 0, },
haveI : fact (0 < d * p^k) := infer_instance,
conv { congr, funext, conv { to_lhs, rw [← mul_div_cancel'
((((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val) : ℕ) : ℚ) h1,
← int.floor_add_fract ((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℕ) / (d * p^k) : ℚ),
mul_add, add_pow, finset.sum_range_succ', pow_zero, one_mul, nat.sub_zero, nat.choose_zero_right,
nat.cast_one, mul_one, ← nat.succ_pred_eq_of_pos (nat.pos_of_ne_zero hn), finset.sum_range_succ',
zero_add, pow_one, nat.succ_pred_eq_of_pos (nat.pos_of_ne_zero hn), nat.choose_one_right,
mul_comm _ (n : ℚ), ← mul_assoc (n : ℚ) _ _, ← mul_assoc (n : ℚ) _ _],
congr, congr, apply_congr, skip, conv { rw pow_succ, rw pow_succ, rw mul_assoc (d * p^k : ℚ) _,
rw ← mul_assoc _ ((d * p^k : ℚ) * _) _, rw ← mul_assoc _ (d * p^k : ℚ) _,
rw mul_comm _ (d * p^k : ℚ), rw ← mul_assoc (d * p^k : ℚ) _ _,
rw ← mul_assoc (d * p^k : ℚ) _ _, rw ← mul_assoc (d * p^k : ℚ) _ _, rw ← sq, rw sq_mul,
rw ← pow_mul', rw mul_assoc (d * p^(2 * k) : ℚ) _ _, rw mul_assoc (d * p^(2 * k) : ℚ) _ _,
rw mul_assoc (d * p^(2 * k) : ℚ) _ _, rw mul_assoc (d * p^(2 * k) : ℚ) _ _,
rw mul_assoc (d * p^(2 * k) : ℚ) _ _, rw mul_comm (d * p^(2 * k) : ℚ),
congr, congr, congr, skip, congr, congr, skip,
rw ← nat.cast_pow,
rw ← nat.cast_mul d (p^k),
rw @fract_eq_of_zmod_eq (d * p^k) _ ((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℕ) : zmod (d * p^k)).val _inst _,
--rw nat.cast_mul d (p^k), rw nat.cast_pow,
rw int.fract_eq_self.2 (@zero_le_div_and_div_lt_one (d * p^k) _ _),
rw nat.cast_mul d (p^k), rw nat.cast_pow, skip,
rw ← zmod.cast_id (d * p^k) ((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℕ) : zmod (d * p^k)),
rw ← zmod.nat_cast_val ((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℕ) : zmod (d * p^k)), apply_congr refl, }, }, },
rw [← finset.sum_mul, mul_div_cancel' _ h1],
simp only [nat.cast_mul, --zmod.nat_cast_val,
add_left_inj, mul_eq_mul_right_iff, mul_eq_zero,
nat.cast_eq_zero, ← int.cast_coe_nat],
norm_cast,
refine ⟨∑ (x_1 : ℕ) in finset.range n.pred, ↑d * ⌊rat.mk ↑((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) ↑(d * p ^ k)⌋ * ⌊rat.mk ↑((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) ↑(d * p ^ k)⌋ * (↑(d * p ^ k) *
⌊rat.mk ↑((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val)
↑(d * p ^ k)⌋) ^ x_1 * ↑((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val : ℕ) : zmod (d * p^k)).val ^ (n - (x_1 + 1 + 1))) *
↑(n.choose (x_1 + 1 + 1)), _⟩,
left, apply finset.sum_congr rfl (λ y hy, rfl),
recover,
apply_instance,
end
-- `helper_299` replaced with `helper_19`
lemma helper_19 {n : ℕ} (hn : 1 < n) (hd : d.coprime p) (hc' : c.coprime d) (hc : c.coprime p) :
c.coprime (χ.mul (teichmuller_character_mod_p' p R ^ n)).lev :=
begin
obtain ⟨x, y, hx, hy, h'⟩ := exists_mul_of_dvd' p d R m χ n hd,
rw (is_primitive_def _).1 (is_primitive.mul _ _) at h',
delta lev,
rw h',
refine (nat.coprime_mul_iff_right.2 ⟨nat.coprime_of_dvd_of_coprime hc' dvd_rfl hx,
nat.coprime_of_dvd_of_coprime (nat.coprime.pow_right _ hc) dvd_rfl hy⟩),
end
-- `helper_300` replaced with `helper_20`
lemma helper_20 [algebra ℚ R] [norm_one_class R] (hd : d.coprime p)
(hc' : c.coprime d) (hc : c.coprime p) (n : ℕ) (hn : 1 < n) : (λ k : ℕ,
(V_def p d R m χ c n k) - (((χ.mul (teichmuller_character_mod_p' p R ^ n))
(zmod.unit_of_coprime c (helper_19 p d R m χ c hn hd hc' hc))) *
(c : R)^n * (U_def p d R m χ n k) + (V_h_def p d R m χ c n k))) =ᶠ[@at_top ℕ _]
(λ k : ℕ, (∑ (x : (zmod (d * p ^ k))ˣ), (asso_dirichlet_character
(χ.mul (teichmuller_character_mod_p' p R ^ n))
(x : zmod (d * p^m))) * (((c ^ (n - 1) : ℕ) : R) *
(algebra_map ℚ R) ((↑d * (↑p ^ k * int.fract (↑((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) / (↑d * ↑p ^ k)))) ^ (n - 1) *
(↑c * int.fract (↑(c : zmod (d * p^(2 * k)))⁻¹ * ↑x / (↑d * ↑p ^ k))))) -
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n)) c) *
(↑c ^ n * (U_def p d R m χ n k)) + (∑ (x : (zmod (d * p ^ k))ˣ),
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))
(x : zmod (d * p^m))) * (((c ^ (n - 1) : ℕ) : R) * (algebra_map ℚ R) (↑(n - 1 : ℕ) *
(↑d * (↑p ^ k * (↑⌊(((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val : ℕ) : ℚ) / (↑d * ↑p ^ k)⌋ *
(↑d * (↑p ^ k * int.fract (↑((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val) /
(↑d * ↑p ^ k)))) ^ (n - 1 - 1)))) * (↑c * int.fract (↑(c : zmod (d * p^(2 * k)))⁻¹ *
(x : ℚ) / (↑d * ↑p ^ k))))) - V_h_def p d R m χ c n k) + (∑ (x : (zmod (d * p ^ k))ˣ),
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))
(x : zmod (d * p^m))) * (-↑(classical.some (exists_V_h1_3 p d R c hc' hc (n - 1) k (nat.sub_pos_of_lt hn) x) * (d * p ^ (2 * k))) *
(algebra_map ℚ R) (↑c * int.fract (↑(c : zmod (d * p^(2 * k)))⁻¹ * ↑x / (↑d * ↑p ^ k)))) +
∑ (x : (zmod (d * p ^ k))ˣ), (asso_dirichlet_character
(χ.mul (teichmuller_character_mod_p' p R ^ n)) (x : zmod (d * p^m))) * (↑(c ^ (n - 1) : ℕ) *
(algebra_map ℚ R) (↑(classical.some (exists_V_h1_5 p d R c (n - 1) k (nat.sub_ne_zero hn) x)) *
(↑d * ↑p ^ (2 * k)) * (↑c * int.fract (↑(c : zmod (d * p^(2 * k)))⁻¹ * ↑x / (↑d * ↑p ^ k)))))))) :=
begin
rw eventually_eq, rw eventually_at_top,
refine ⟨1, λ k hk, _⟩,
{ have h3 : k ≠ 0 := ne_zero_of_lt (nat.succ_le_iff.1 hk),
have h4 : n - 1 ≠ 0 := nat.sub_ne_zero hn,
have h5 : (χ.mul (teichmuller_character_mod_p' p R ^ n)).conductor ∣ d * p^m,
{ apply dvd_trans (conductor.dvd_lev _) (dvd_trans (conductor.dvd_lev _) _),
rw helper_4, },
have h6 : char_p (zmod (change_level (dvd_lcm_left (d * p^m) p) χ *
change_level (dvd_lcm_right (d * p^m) p) (teichmuller_character_mod_p' p R ^ n)).conductor)
(χ.mul (teichmuller_character_mod_p' p R ^ n)).conductor,
{ rw (is_primitive_def _).1 (is_primitive.mul _ _),
refine zmod.char_p _, },
conv_rhs { congr, congr, skip, rw V_h_def, rw ← finset.sum_sub_distrib,
conv { apply_congr, skip, rw coe_coe x, rw ←nat_cast_val (x : zmod (d * p^k)),
rw cast_nat_cast h5 _, rw nat_cast_val (x : zmod (d * p^k)), rw ←coe_coe x, rw sub_self, skip,
apply_congr h6, },
rw finset.sum_const_zero, },
rw add_zero, rw add_comm, rw ← sub_sub, rw add_comm, rw ← add_sub_assoc,
rw mul_assoc _ (↑c ^ n) (U_def p d R m χ n k),
apply congr_arg2 _ _ _,
{ delta V_def,
conv_lhs { congr, apply_congr, skip, rw ← nat.cast_pow,
rw classical.some_spec (exists_V_h1_3 p d R c hc' hc _ _ (nat.sub_pos_of_lt hn) x),
rw nat.cast_sub (le_of_lt (exists_V_h1_4 p d R c hc hc' _ _ (nat.sub_pos_of_lt hn) h3 x)),
rw sub_eq_neg_add _ _,
rw nat.cast_mul (c^(n - 1)) _, rw ← map_nat_cast (algebra_map ℚ R) (((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) ^ (n - 1)),
rw nat.cast_pow ((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val) _,
rw classical.some_spec (exists_V_h1_5 p d R c _ _ h4 x), },
simp_rw [← finset.sum_add_distrib, ← mul_add, smul_eq_mul],
delta V_h_def, rw ← finset.sum_sub_distrib,
apply finset.sum_congr,
refl,
{ intros x hx, rw mul_assoc, rw ← mul_sub, apply congr_arg2 _ _ _,
{ apply congr_arg,
--used before as well, make lemma
symmetry,
rw coe_coe x, rw ←nat_cast_val (x : zmod (d * p^k)),
rw cast_nat_cast h5 _, rw nat_cast_val (x : zmod (d * p^k)), rw ←coe_coe x,
apply h6, },
simp_rw [add_mul, add_assoc],
rw add_sub_assoc, apply congr_arg2 _ rfl _,
rw mul_assoc, rw ← mul_sub, rw ← mul_add, congr,
rw ← ring_hom.map_mul, rw ← ring_hom.map_add, rw ← ring_hom.map_sub,
apply congr_arg, rw add_mul, rw add_sub_assoc, apply congr_arg2 _ rfl _, rw ← sub_mul,
apply congr_arg2 _ _ rfl, rw add_sub_right_comm,
conv_rhs { rw ← mul_assoc (↑d) (↑p ^ k) _, },
convert zero_add _, rw sub_eq_zero, simp_rw [mul_assoc], }, },
{ apply congr_arg2 _ _ rfl, rw ← asso_dirichlet_character_eq_char _ _,
rw zmod.coe_unit_of_coprime, }, },
end
.
--`helps` replaced with `norm_sum_le_of_norm_le_forall`
lemma norm_sum_le_of_norm_le_forall (f : Π (n : ℕ), (zmod (d * p^n))ˣ → R)
(na : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥) (k : ℕ → ℝ)
(h : ∀ (n : ℕ) (i : (zmod (d * p^n))ˣ), ∥f n i∥ ≤ k n) (n : ℕ) :
∥∑ i : (zmod (d * p^n))ˣ, f n i∥ ≤ k n :=
begin
apply le_trans (na (d * p^n) (f n)) _,
apply cSup_le _ _,
{ exact set.range_nonempty (λ (i : (zmod (d * p ^ n))ˣ), ∥f n i∥), },
{ intros b hb,
cases hb with y hy,
rw ← hy,
apply h, },
end
lemma helper_3' [algebra ℚ R] [norm_one_class R] (k : ℕ) (x : (zmod (d * p^k))ˣ) :
int.fract (((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : ℕ)) / (d * p^k) : ℚ) = int.fract (((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : zmod(d * p^k))).val / (d * p^k) : ℚ) :=
begin
rw ← nat.cast_pow,
rw ← nat.cast_mul d (p^k),
rw @fract_eq_of_zmod_eq (d * p^k) _ ((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℕ) : zmod (d * p^k)).val _ _,
rw ← nat.cast_mul,
rw zmod.nat_cast_val ((((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℕ) : zmod (d * p^k)),
rw zmod.cast_id,
end
--also used in the major lemma above
lemma helper_4' [algebra ℚ R] [norm_one_class R] (k : ℕ) (x : (zmod (d * p^k))ˣ) :
int.fract (((((((c : zmod (d * p^(2 * k))))⁻¹ : zmod (d * p^(2 * k))) : ℚ) *
x : ℚ)) / (d * p^k) : ℚ) = int.fract (((((c : zmod (d * p^(2 * k))))⁻¹.val *
(x : zmod (d * p^k)).val : zmod(d * p^k))).val / (d * p^k) : ℚ) :=
begin
convert helper_3' p d R c k x,
rw nat.cast_mul,
rw zmod.nat_cast_val _,
rw zmod.nat_cast_val _,
simp only [coe_coe],
any_goals { apply_instance, },
end
lemma helper_5' (a b c : R) : a * b * c = a * c * b := by ring
lemma helper_6' {n : ℕ} [fact (0 < n)] (x : (zmod n)ˣ) : (x : ℚ) = ((x : zmod n).val : ℚ) :=
begin
simp,
end
lemma helper_7' {k : ℕ} (hc' : c.coprime d) (hc : c.coprime p) (a₁ a₂ : (zmod (d * p^k))ˣ)
(h : (((c : zmod (d * p^(2 * k)))⁻¹ : zmod (d * p^(2 * k))) : zmod (d * p^k)) *
(a₁ : zmod (d * p^k)) = (((c : zmod (d * p^(2 * k)))⁻¹ : zmod (d * p^(2 * k))) : zmod (d * p^k)) *
(a₂ : zmod (d * p^k))) : a₁ = a₂ :=
begin
rw units.ext_iff, rw zmod.cast_inv at h, rw zmod.cast_nat_cast _ at h,
have := congr_arg2 has_mul.mul (eq.refl (c : zmod (d * p^k))) h,
simp_rw ← mul_assoc at this,
rw zmod.mul_inv_of_unit _ _ at this, simp_rw one_mul at this,
exact this,
{ apply is_unit_of_is_coprime_dvd dvd_rfl, --rw nat.is_coprime_iff_coprime,
apply nat.coprime.mul_pow k hc' hc, },
swap, { refine zmod.char_p _, },
any_goals { apply mul_dvd_mul_left d (pow_dvd_pow p (nat.le_mul_of_pos_left two_pos)), },
{ apply nat.coprime.mul_pow _ hc' hc, },
end
lemma helper_301 [algebra ℚ R] [norm_one_class R] (hd : d.coprime p)
(hc' : c.coprime d) (hc : c.coprime p) (n : ℕ) (hn : 1 < n) : (λ (x : ℕ), ∑ (x_1 : (zmod (d * p ^ x))ˣ),
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑x_1 *
(↑(c ^ (n - 1) : ℕ) * (algebra_map ℚ R) ((↑d * (↑p ^ x *
int.fract (↑((c : zmod (d * p ^ (2 * x)))⁻¹.val * (x_1 : zmod (d * p ^x)).val : ℕ) / (↑d * ↑p ^ x)))) ^ (n - 1) *
(↑c * int.fract ((((c : zmod (d * p ^ (2 * x)))⁻¹ : zmod (d * p ^ (2 * x))) : ℚ) * (x_1 : ℚ) / (↑d * ↑p ^ x))))) -
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
(↑c ^ n * U_def p d R m χ n x)) =ᶠ[at_top] 0 :=
begin
rw eventually_eq,
rw eventually_at_top,
refine ⟨m, λ k hk, _⟩,
have h' : d * p ^ k ∣ d * p ^ (2 * k) :=
mul_dvd_mul_left d (pow_dvd_pow p (nat.le_mul_of_pos_left two_pos)),
have h1 : (d * p^k : ℚ) ≠ 0,
{ norm_cast, apply nat.mul_ne_zero (ne_zero_of_lt (fact.out _)) _,
exact 0, apply_instance, apply pow_ne_zero k (nat.prime.ne_zero (fact.out _)), apply_instance, },
have h2 : (χ.mul (teichmuller_character_mod_p' p R ^ n)).conductor ∣ d * p^k,
{ apply dvd_trans _ (mul_dvd_mul_left d (pow_dvd_pow p hk)),
apply dvd_trans (conductor.dvd_lev _) (dvd_trans (conductor.dvd_lev _) _),
rw helper_4, },
rw pi.zero_apply, rw sub_eq_zero, delta U_def,
simp_rw [helper_3' p d R, helper_4' p d R, finset.mul_sum, ← mul_assoc, smul_eq_mul, ← mul_assoc],
apply finset.sum_bij,
{ intros a ha, apply finset.mem_univ _, },
swap 4, { intros a ha, apply is_unit.unit,
swap, { exact (c : zmod (d * p^(2 * k)))⁻¹.val * (a : zmod (d * p^k)).val, },
apply is_unit.mul _ _,
{ rw zmod.nat_cast_val, rw zmod.cast_inv (nat.coprime.mul_pow _ hc' hc) h',
rw zmod.cast_nat_cast h', apply zmod.inv_is_unit_of_is_unit,
apply zmod.is_unit_mul _ hc' hc,
{ refine zmod.char_p _, }, },
{ rw zmod.nat_cast_val, rw zmod.cast_id, apply units.is_unit a, }, },
{ intros a ha, conv_rhs { rw helper_5' R _ (c^n : R) _, rw mul_assoc, rw mul_assoc, },
rw mul_assoc, apply congr_arg2,
{ simp_rw ← units.coe_hom_apply,
rw ← monoid_hom.map_mul _, congr,
--rw units.ext_iff,
simp only [units.coe_hom_apply, zmod.nat_cast_val, zmod.cast_id', id.def,
ring_hom.to_monoid_hom_eq_coe, units.coe_map,
ring_hom.coe_monoid_hom, zmod.cast_hom_apply, units.coe_mul, zmod.coe_unit_of_coprime],
rw coe_coe (is_unit.unit _), rw is_unit.unit_spec,
rw zmod.cast_mul h2, rw zmod.cast_inv _ h',
rw zmod.cast_nat_cast h' _, rw zmod.cast_inv _ (dvd_trans _ h2),
rw zmod.cast_nat_cast h2 _,
rw ← mul_assoc, rw zmod.mul_inv_of_unit _, rw one_mul,
rw coe_coe,
any_goals { rw (is_primitive_def _).1 (is_primitive.mul _ _), refine zmod.char_p _, },
any_goals { apply nat.coprime.mul_right hc' (nat.coprime.pow_right _ hc), },
{ apply (zmod.unit_of_coprime c (helper_19 p d R m χ c hn hd hc' hc)).is_unit, },
{ rw (is_primitive_def _).1 (is_primitive.mul _ _), },
{ refine zmod.char_p _, }, },
{ rw ring_hom.map_mul, rw int.fract_eq_self.2 _, rw mul_div_cancel' _,
rw ← mul_assoc, rw ring_hom.map_mul, rw ← mul_assoc, rw map_nat_cast,
rw helper_5' R _ _ (c : R), rw mul_assoc, apply congr_arg2,
{ rw nat.cast_pow, rw ← pow_succ', rw nat.sub_add_cancel _, apply le_of_lt hn, }, --might need change
{ simp_rw [helper_6'],
rw int.fract_eq_self.2 _, rw ← nat.cast_pow, rw map_nat_cast, congr,
{ rw nat.cast_pow, congr, },
{ rw ← nat.cast_pow p k, rw ← nat.cast_mul d (p^k), apply zero_le_div_and_div_lt_one _,
apply_instance, }, },
{ apply h1, },
{ rw ← nat.cast_pow p k, rw ← nat.cast_mul d (p^k), apply zero_le_div_and_div_lt_one _,
apply_instance, }, }, },
{ intros a₁ a₂ ha₁ ha₂ h,
simp only at h, rw units.ext_iff at h,
rw is_unit.unit_spec at h, rw is_unit.unit_spec at h,
simp_rw [zmod.nat_cast_val, zmod.cast_id] at h,
apply helper_7' p d c hc' hc _ _ h, },
{ intros b hb, simp_rw [units.ext_iff, is_unit.unit_spec],
refine ⟨is_unit.unit _, _, _⟩,
{ exact c * (b : zmod (d * p^k)), },
{ apply is_unit.mul _ (units.is_unit _), apply zmod.is_unit_mul _ hc' hc, },
{ apply finset.mem_univ _, },
{ rw is_unit.unit_spec, simp_rw zmod.nat_cast_val, rw zmod.cast_id, rw ← mul_assoc,
rw zmod.cast_inv _ h', rw zmod.cast_nat_cast h' _, rw zmod.inv_mul_of_unit _, rw one_mul,
{ apply zmod.is_unit_mul _ hc' hc, },
{ refine zmod.char_p _, },
{ apply nat.coprime.mul_right hc' (nat.coprime.pow_right (2 * k) hc), }, }, },
end
lemma V_h1 [algebra ℚ R] [norm_one_class R] (hd : d.coprime p)
(hc' : c.coprime d) (hc : c.coprime p)
(na : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥)
(n : ℕ) (hn : 1 < n) :
filter.tendsto (λ (x : ℕ), V_def p d R m χ c n x -
(↑((χ.mul (teichmuller_character_mod_p' p R ^ n)) (zmod.unit_of_coprime c
(helper_19 p d R m χ c hn hd hc' hc))) *
↑c ^ n * U_def p d R m χ n x + V_h_def p d R m χ c n x)) filter.at_top (nhds 0) :=
begin
have mul_ne_zero' : ∀ n : ℕ, d * p^n ≠ 0,
{ intro j, refine @nat.ne_zero_of_lt' 0 (d * p^j) _, },
have h2 : (χ.mul (teichmuller_character_mod_p' p R ^ n)).conductor ∣ d * p^m,
{ --apply dvd_trans _ (mul_dvd_mul_left d (pow_dvd_pow p hk)),
apply dvd_trans (conductor.dvd_lev _) (dvd_trans (conductor.dvd_lev _) _),
rw helper_4, },
rw filter.tendsto_congr' (helper_20 p d R m χ c hd hc' hc n hn),
conv { congr, skip, skip, congr, rw ← add_zero (0 : R), rw ← add_zero ((0 : R) + 0), },
apply tendsto.add, apply tendsto.add,
{ convert tendsto.congr' (helper_301 p d R m χ c hd hc' hc n hn).symm _,
-- why was any of this needed?
{ ext, congr, ext, congr' 1, apply congr_arg,
-- this is causing the problem, is it needed?
--make this a separate lemma
rw coe_coe,
rw ←nat_cast_val (x_1 : zmod (d * p^x)),
rw cast_nat_cast h2, rw nat_cast_val, rw ←coe_coe,
{ rw (is_primitive_def _).1 (is_primitive.mul _ _), refine zmod.char_p _, }, },
{ apply tendsto_const_nhds, }, },
{ delta V_h_def,
convert tendsto_const_nhds,
ext, convert sub_self _,
ext, congr' 1, apply congr_arg,
symmetry,
rw coe_coe,
rw ←nat_cast_val (x_1 : zmod (d * p^x)),
rw cast_nat_cast h2, rw nat_cast_val, rw ←coe_coe,
{ rw (is_primitive_def _).1 (is_primitive.mul _ _), refine zmod.char_p _, }, },
{ simp_rw [← finset.sum_add_distrib, ← mul_add, ring_hom.map_mul, ← mul_assoc, ← add_mul,
mul_assoc _ (algebra_map ℚ R (d : ℚ)) _, ← ring_hom.map_mul _ (d : ℚ) _, ← nat.cast_pow,
← nat.cast_mul d _, map_nat_cast, mul_assoc _ d _, nat.cast_mul _ (d * p^(2 * _)),
mul_comm _ ((d * p^(2 * _) : ℕ) : R), neg_mul_eq_mul_neg, ← mul_add, mul_assoc _ (c : R) _,
mul_assoc, mul_comm ((d * p^(2 * _) : ℕ) : R), ← mul_assoc _ _ ((d * p^(2 * _) : ℕ) : R)],
rw tendsto_zero_iff_norm_tendsto_zero,
rw ← tendsto_zero_iff_norm_tendsto_zero,
have : tendsto (λ n : ℕ, (p^n : R)) at_top (nhds 0),
{ apply tendsto_pow_at_top_nhds_0_of_norm_lt_1,
apply norm_prime_lt_one, },
rw tendsto_iff_norm_tendsto_zero at this,
have h1 := tendsto.mul_const (dirichlet_character.bound (χ.mul
(teichmuller_character_mod_p' p R ^ n))) this,
rw [zero_mul] at h1,
apply squeeze_zero_norm _ h1,
simp only [sub_zero], intro z,
convert norm_sum_le_of_norm_le_forall p d R _ na _ _ z,
intros e x,
simp_rw [two_mul e, pow_add, ← mul_assoc d (p^e) (p^e), nat.cast_mul (d * p^e) (p^e),
← mul_assoc _ (↑(d * p ^ e)) _, nat.cast_pow p e, mul_comm _ (↑p^e)],
apply le_trans (norm_mul_le _ _) _,
rw mul_le_mul_left _,
{ simp_rw [mul_assoc _ _ (↑(d * p ^ e))],
apply le_trans (norm_mul_le _ _) _,
rw ← mul_one (dirichlet_character.bound _),
apply mul_le_mul (le_of_lt (dirichlet_character.lt_bound _ _)) _ (norm_nonneg _)
(le_of_lt (dirichlet_character.bound_pos _)),
simp_rw [← map_nat_cast (algebra_map ℚ R) (d * p^e), ← ring_hom.map_mul],
obtain ⟨z, hz⟩ := int.exists_int_eq_fract_mul_self
((((c : zmod (d * p^(2 * e)))⁻¹).val * (x : zmod (d * p^e)).val )) (mul_ne_zero' e),
{ simp_rw [coe_coe x, ← zmod.nat_cast_val, ← nat.cast_mul],
conv { congr, congr, congr, skip, rw [← hz], },
simp_rw [ring_hom.map_int_cast, ← int.cast_coe_nat, ← int.cast_neg, ← int.cast_mul,
← int.cast_add, ← int.cast_mul],
apply norm_int_le_one p R, }, },
{ rw norm_pos_iff, norm_cast, apply pow_ne_zero _ (nat.prime.ne_zero _), apply fact.out, }, },
end
@[to_additive]
lemma filter.tendsto.one_mul_one {α M : Type*} [topological_space M] [monoid M]
[has_continuous_mul M] {f g : α → M} {x : filter α} (hf : tendsto f x (𝓝 1))
(hg : tendsto g x (𝓝 1)) : tendsto (λx, f x * g x) x (𝓝 1) :=
by { convert tendsto.mul hf hg, rw mul_one, }
lemma V_h2_1 [algebra ℚ R] [norm_one_class R] (hd : d.coprime p) (hc' : c.coprime d)
(hc : c.coprime p) (hp : 2 < p)
(na : ∀ (n : ℕ) (f : ℕ → R), ∥∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(n : ℕ) (hn : 1 < n) (hχ : χ.is_even) :
(λ (x : ℕ), ∑ (x_1 : (zmod (d * p ^ x))ˣ), (asso_dirichlet_character
(χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑x_1 * (↑(n - 1 : ℕ) * ↑(c ^ n : ℕ) *
(algebra_map ℚ R) (↑d * ↑p ^ x * int.fract (↑((c : zmod (d * p^(2 * x)))⁻¹ : zmod (d * p^(2 * x))) *
↑x_1 / ↑(d * p ^ x))) ^ n * (algebra_map ℚ R) (1 / (↑d * ↑p ^ x))) - ↑(n - 1 : ℕ) *
((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
(algebra_map ℚ R) (↑c ^ n)) * U_def p d R m χ n x) =ᶠ[at_top] λ (b : ℕ), 0 :=
begin
apply eventually_eq_iff_sub.1,
rw eventually_eq, rw eventually_at_top,
refine ⟨m, λ k hk, _⟩, delta U_def, rw finset.mul_sum,
have h1 : (d * p^k : ℚ) ≠ 0,
{ norm_cast, refine nat.ne_zero_of_lt' 0, },
have h2 : (χ.mul (teichmuller_character_mod_p' p R ^ n)).conductor ∣ d * p^k,
{ apply dvd_trans _ (mul_dvd_mul_left d (pow_dvd_pow p hk)),
apply dvd_trans (conductor.dvd_lev _) (dvd_trans (conductor.dvd_lev _) _),
rw helper_4, },
have h2' : (change_level (dvd_lcm_left (d * p^m) p) χ *
change_level (dvd_lcm_right (d * p^m) p) (teichmuller_character_mod_p' p R ^ n)).conductor ∣ d * p^k,
{ apply dvd_trans _ (mul_dvd_mul_left d (pow_dvd_pow p hk)),
apply dvd_trans (conductor.dvd_lev _) _, -- use h2
rw helper_4, },
have h5 : ∀ (x : (zmod (d * p^k))ˣ), (x : ℚ) = ((x : zmod (d * p^k)) : ℚ) := coe_coe,
have h' : d * p ^ k ∣ d * p ^ (2 * k) :=
mul_dvd_mul_left d (pow_dvd_pow p (nat.le_mul_of_pos_left two_pos)),
apply finset.sum_bij,
{ intros a ha, apply finset.mem_univ _, },
swap 4, { intros a ha, apply is_unit.unit,
swap, { exact (c : zmod (d * p^(2 * k)))⁻¹.val * (a : zmod (d * p^k)).val, },
-- maybe make a separate lemma?
apply is_unit.mul _ _,
{ rw zmod.nat_cast_val, rw zmod.cast_inv (nat.coprime.mul_pow _ hc' hc) h',
rw zmod.cast_nat_cast h', apply zmod.inv_is_unit_of_is_unit,
apply zmod.is_unit_mul _ hc' hc,
{ refine zmod.char_p _, }, },
{ rw zmod.nat_cast_val, rw zmod.cast_id, apply units.is_unit a, }, },
{ intros a ha,
--rw ← asso_dirichlet_character_eq_char, rw ← asso_dirichlet_character_eq_char,
rw smul_eq_mul, rw mul_comm _ ((algebra_map ℚ R) (c^n : ℚ)),
rw ← mul_assoc ((n - 1 : ℕ) : R) _ _,
rw mul_assoc (((n - 1 : ℕ) : R) * (algebra_map ℚ R) (c^n : ℚ)) _ _,
conv_rhs { congr, skip, conv { congr, skip, rw mul_assoc, }, rw ← mul_assoc, },
conv_rhs { rw ← mul_assoc, rw helper_5', rw mul_comm, }, --rw ← asso_dirichlet_character_eq_char, },
apply congr_arg2,
{ --rw ← asso_dirichlet_character_eq_char,
-- rw ← dirichlet_character.asso_dirichlet_character_mul,
--simp_rw ← units.coe_hom_apply,
rw ← monoid_hom.map_mul (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) _ _,
--rw ← monoid_hom.map_mul (units.coe_hom R), rw ← monoid_hom.map_mul,
congr,
--rw units.ext_iff,
simp only [units.coe_hom_apply, zmod.nat_cast_val, zmod.cast_id', id.def,
ring_hom.to_monoid_hom_eq_coe, units.coe_map,
ring_hom.coe_monoid_hom, zmod.cast_hom_apply, units.coe_mul, zmod.coe_unit_of_coprime],
rw coe_coe (is_unit.unit _),
rw is_unit.unit_spec, rw zmod.cast_mul h2', rw zmod.cast_inv _ h',
rw zmod.cast_nat_cast h' _, rw zmod.cast_inv _ h2', rw zmod.cast_nat_cast h2 _,
rw ← mul_assoc, rw zmod.mul_inv_of_unit _, rw one_mul,
{ rw coe_coe, },
any_goals { refine zmod.char_p _, },
any_goals { apply nat.coprime.mul_right hc' (nat.coprime.pow_right _ hc), },
{ apply (zmod.unit_of_coprime c (helper_19 p d R m χ c hn hd hc' hc)).is_unit, },
{ rw (is_primitive_def _).1 (is_primitive.mul _ _), refine zmod.char_p _, }, },
{ --rw ring_hom.map_mul,
rw nat.cast_mul d _, rw nat.cast_pow p _,
rw helper_4' p d R c k a, rw ←nat.cast_pow p _, rw ←nat.cast_mul d _, rw int.fract_eq_self.2 _,
rw mul_div_cancel' _,
simp_rw [mul_assoc], apply congr_arg2 _ rfl _, rw ← nat.cast_pow c, rw map_nat_cast,
rw map_nat_cast, apply congr_arg2 _ rfl _, rw is_unit.unit_spec,
simp_rw [← map_nat_cast (algebra_map ℚ R), ← ring_hom.map_pow, ← ring_hom.map_mul, mul_one_div],
apply congr_arg, rw h5,
simp_rw is_unit.unit_spec, --rw ← nat.cast_pow p _, rw ← nat.cast_mul d _,
rw fract_eq_val,
rw mul_div, rw ← pow_succ',
rw nat.sub_one, rw nat.add_one, rw nat.succ_pred_eq_of_pos _,
{ apply lt_trans _ hn, apply nat.zero_lt_one, },
{ refine nat.cast_ne_zero.2 (nat.ne_zero_of_lt' 0), },
-- rw helper_5 R _ _ (c : R), rw mul_assoc, apply congr_arg2,
-- { rw nat.cast_mul, rw nat.cast_pow, apply h1, }, --might need change
-- { apply h1, },
-- { simp_rw [helper_6],
-- rw fract_eq_self, rw ← nat.cast_pow, rw map_nat_cast, congr,
-- { rw nat.cast_pow, congr, },
-- { apply (zero_le_and_lt_one p d _ _).1, },
-- { apply (zero_le_and_lt_one p d _ _).2, }, },
-- { apply h1, },
{ refine zero_le_div_and_div_lt_one _, }, }, },
{ intros a₁ a₂ ha₁ ha₂ h,
simp only at h, rw units.ext_iff at h,
rw is_unit.unit_spec at h, rw is_unit.unit_spec at h,
simp_rw [zmod.nat_cast_val, zmod.cast_id] at h,
apply helper_7' p d c hc' hc _ _ h, },
{ intros b hb, simp_rw [units.ext_iff, is_unit.unit_spec],
refine ⟨is_unit.unit _, _, _⟩,
{ exact c * (b : zmod (d * p^k)), },
{ apply is_unit.mul (zmod.is_unit_mul _ hc' hc) (units.is_unit _), },
{ apply finset.mem_univ _, },
{ rw is_unit.unit_spec, simp_rw zmod.nat_cast_val, rw zmod.cast_id, rw ← mul_assoc,
rw zmod.cast_inv _ h', rw zmod.cast_nat_cast h' _, rw zmod.inv_mul_of_unit _, rw one_mul,
{ apply zmod.is_unit_mul _ hc' hc, },
{ refine zmod.char_p _, },
{ apply nat.coprime.mul_right hc' (nat.coprime.pow_right (2 * k) hc), }, }, },
end
lemma helper_V_h2_2 [algebra ℚ R] [norm_one_class R] (hd : d.coprime p) (hc' : c.coprime d)
(hc : c.coprime p) (hp : 2 < p) (n : ℕ) (hn : 1 < n) :
(λ x : ℕ, (algebra_map ℚ R) ↑(n - 1 : ℕ) * (U_def p d R m χ n x)) =ᶠ[at_top]
(λ k : ℕ, ∑ (x : (zmod (d * p ^ k))ˣ), (algebra_map ℚ R) ↑(n - 1 : ℕ) *
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n)) x) *
(algebra_map ℚ R) ((-↑(classical.some ((exists_V_h1_3 p d R c hc' hc n k (lt_trans zero_lt_one hn) x)) * (d * p ^ (2 * k)) : ℕ) +
↑(c ^ n : ℕ) * (↑(classical.some (exists_V_h1_5 p d R c n k (ne_zero_of_lt hn) x)) *
(↑d * ↑p ^ (2 * k)) + ↑n * (↑d * ↑p ^ k) * ↑⌊(((c : zmod (d * p^(2 * k)))⁻¹.val *
(x : zmod (d * p^k)).val) : ℚ) / (↑d * ↑p ^ k)⌋ * (↑d * ↑p ^ k *
int.fract (↑((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val) / (↑d * ↑p ^ k))) ^ (n - 1) +
(↑d * ↑p ^ k * int.fract (↑((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val) / (↑d * ↑p ^ k))) ^ n))
/ (↑d * ↑p ^ k))) :=
begin
rw eventually_eq, rw eventually_at_top,
refine ⟨1, λ k hk, _⟩,
have h2 : ∀ (k : ℕ) (x : (zmod (d * p^k))ˣ), (x : ℚ) = ((x : zmod (d * p^k)).val : ℚ),
{ simp only [coe_coe, zmod.nat_cast_val, eq_self_iff_true, forall_2_true_iff], },
delta U_def,
rw finset.mul_sum, simp_rw smul_eq_mul,
conv_lhs { apply_congr, skip, rw h2,
conv { congr, skip, congr, skip, rw ←nat.cast_pow p, rw ← nat.cast_mul d _, }, },
simp_rw [int.fract_eq_self.2 (zero_le_div_and_div_lt_one _)],
conv_lhs { apply_congr, skip, rw mul_assoc, rw ← map_nat_cast (algebra_map ℚ R) _, rw ← ring_hom.map_pow,
rw ← ring_hom.map_mul, rw mul_div _ _ ((d * p^k : ℕ) : ℚ), rw ← pow_succ', rw ← mul_assoc,
rw nat.sub_add_cancel (le_of_lt hn), conv { congr, congr, skip, skip, rw ← nat.cast_pow,
rw classical.some_spec (exists_V_h1_3 p d R c hc' hc _ _ (lt_trans zero_lt_one hn) x), },
rw nat.cast_sub (le_of_lt (exists_V_h1_4 p d R c hc hc' _ _ (lt_trans zero_lt_one hn) (ne_zero_of_lt hk) x)),
rw sub_eq_neg_add _ _, rw nat.cast_mul (c^n) _,
rw nat.cast_pow ((c : zmod (d * p^(2 * k)))⁻¹.val * (x : zmod (d * p^k)).val) _,
rw classical.some_spec (exists_V_h1_5 p d R c _ _ (ne_zero_of_lt hn) x),
--rw ← zmod.nat_cast_val, rw h2,
rw nat.cast_mul, }, --rw nat.cast_pow p,
--rw ← nat.cast_mul _ (x : zmod (d * p^k)).val, rw ← ring_hom.map_pow, },
simp_rw [add_div, ring_hom.map_add, mul_add, add_div, ring_hom.map_add, mul_add,
finset.sum_add_distrib, ← add_assoc],
congr,
{ simp_rw [nat.cast_mul _ (d * p ^ (2 * k)), ←nat.cast_pow p _, ←nat.cast_mul d _], },
--helper_13],
any_goals { simp_rw [←nat.cast_pow p _, ←nat.cast_mul d _], },
{ simp_rw [nat.cast_mul], },
end
lemma helper_13' (a b c d e f : R) : a + b + c + (d - e - f) = a + b + (c - f) + (d - e) := by ring
lemma V_h2_2 [algebra ℚ R] [norm_one_class R] (hd : d.coprime p) (hc' : c.coprime d)
(hc : c.coprime p) (hp : 2 < p)
(na : ∀ (n : ℕ) (f : ℕ → R), ∥∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(na' : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥)
(n : ℕ) (hn : 1 < n) : tendsto (λ (x : ℕ), (algebra_map ℚ R) ↑(n - 1 : ℕ) * U_def p d R m χ n x -
∑ (x_1 : (zmod (d * p ^ x))ˣ), (asso_dirichlet_character
(χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑x_1 * (↑(n - 1 : ℕ) * ↑(c ^ n : ℕ) *
(algebra_map ℚ R) (↑d * ↑p ^ x * int.fract (↑((c : zmod (d * p^(2 * x)))⁻¹ : zmod (d * p^(2 * x))) *
↑x_1 / ↑(d * p ^ x : ℕ))) ^ n * (algebra_map ℚ R) (1 / (↑d * ↑p ^ x))) -
(algebra_map ℚ R) ↑n * V_h_def p d R m χ c n x) at_top (𝓝 0) :=
begin
simp_rw sub_sub,
apply (tendsto_congr' (eventually_eq.sub (helper_V_h2_2 p d R m χ c hd hc' hc hp n hn)
eventually_eq.rfl)).2,
simp_rw [← sub_sub, mul_add, add_div, ring_hom.map_add, mul_add, finset.sum_add_distrib, ← add_assoc,
← add_sub, helper_13'],
apply filter.tendsto.zero_add_zero, apply filter.tendsto.zero_add_zero,
{ simp_rw [← finset.sum_add_distrib, ← mul_add],
--maybe make a lemma out of this since it is used again?
have : tendsto (λ n : ℕ, (p^n : R)) at_top (nhds 0),
{ apply tendsto_pow_at_top_nhds_0_of_norm_lt_1,
apply norm_prime_lt_one, },
rw tendsto_iff_norm_tendsto_zero at this,
have hbp := tendsto.mul_const (dirichlet_character.bound (χ.mul (teichmuller_character_mod_p' p R ^ n))) this,
rw [zero_mul] at hbp,
apply squeeze_zero_norm _ hbp,
simp only [sub_zero], intro z,
convert norm_sum_le_of_norm_le_forall p d R _ na' _ _ z,
intros e x,
rw [← ring_hom.map_add, nat.cast_mul, ← neg_mul, ← mul_div, ← mul_assoc, ← mul_div,
nat.cast_mul _ (p ^ (2 * e)), nat.cast_pow p, ← add_mul],
simp_rw [two_mul e, pow_add, ← mul_assoc (d : ℚ) (↑p^e) (↑p^e), mul_comm (↑d * ↑p ^ e) _,
← mul_div _ (↑d * ↑p ^ e) _],
apply le_trans (norm_mul_le _ _) _,
rw mul_comm (∥↑p ^ e∥) _,
apply mul_le_mul _ _ (norm_nonneg _) (le_of_lt (dirichlet_character.bound_pos _)),
{ apply le_trans (norm_mul_le _ _) _,
rw ← one_mul (dirichlet_character.bound _),
apply mul_le_mul _ (le_of_lt (dirichlet_character.lt_bound
(χ.mul (teichmuller_character_mod_p' p R ^ n)) _)) (norm_nonneg _) zero_le_one,
simp_rw [ring_hom.map_int_cast, ← int.cast_coe_nat, ring_hom.map_int_cast],
apply norm_int_le_one p R _, },
{ rw [← mul_assoc, ring_hom.map_mul, div_self _, ring_hom.map_one, mul_one, ring_hom.map_mul],
simp_rw [← nat.cast_pow p, map_nat_cast],
apply le_trans (norm_mul_le _ _) _,
rw mul_le_iff_le_one_left _,
{ simp_rw [← int.cast_coe_nat, ← int.cast_neg, ← int.cast_mul, ← int.cast_add,
ring_hom.map_int_cast],
apply norm_int_le_one p R _, },
{ rw norm_pos_iff, norm_cast, apply pow_ne_zero _ (nat.prime.ne_zero _), apply fact.out, },
{ norm_cast, refine nat.ne_zero_of_lt' 0, }, }, },
{ convert tendsto_const_nhds, ext k, rw sub_eq_zero, delta V_h_def, rw finset.mul_sum,
have h1 : (d * p^k : ℚ) ≠ 0,
{ norm_cast, refine nat.ne_zero_of_lt' 0, },
have h2 : ∀ (x : (zmod (d * p^k))ˣ), (x : ℚ) = ((x : zmod (d * p^k)).val : ℚ) :=
λ x, by { rw [zmod.nat_cast_val, coe_coe], },
apply finset.sum_congr _ (λ x hx, _),
{ convert refl _, apply_instance, },
rw map_nat_cast _ n, rw mul_comm (n : R) _,
rw mul_assoc _ _ (n : R), rw mul_comm ((algebra_map ℚ R) ↑(n - 1)) _, rw mul_assoc,
apply congr_arg2 _ rfl _, rw ← nat.pred_eq_sub_one, rw ← nat.succ_pred_eq_of_pos (nat.lt_pred_iff.2 hn),
rw pow_succ _ (n.pred.pred),
have : 0 < n := lt_trans zero_lt_one hn,
rw ← nat.succ_pred_eq_of_pos this, rw pow_succ' c n.pred, rw nat.cast_mul _ c,
rw nat.succ_pred_eq_of_pos this, rw nat.succ_pred_eq_of_pos (nat.lt_pred_iff.2 hn),
simp_rw [← mul_assoc (d : ℚ) _ _, ← nat.cast_pow p _, ← nat.cast_mul d _,
mul_pow, ring_hom.map_mul, map_nat_cast, nat.pred_eq_sub_one],
rw ← mul_assoc, rw ← mul_assoc ((c^(n - 1) : ℕ) : R) (((n - 1 : ℕ) : R) * _) _,
rw ← mul_assoc ((c^(n - 1) : ℕ) : R) ((n - 1 : ℕ) : R) _,
rw mul_comm _ ((n - 1 : ℕ) : R), rw mul_assoc ((n - 1 : ℕ) : R) _ _,
rw mul_assoc ((n - 1 : ℕ) : R) _ _, rw mul_assoc ((n - 1 : ℕ) : R) _ _,
apply congr_arg2 _ rfl _, rw ← mul_div,
simp_rw [ring_hom.map_mul, map_nat_cast, mul_assoc], apply congr_arg2 _ rfl _,
rw ← mul_div ((d * p ^ k : ℕ) : ℚ) _ _,
simp_rw [mul_div_left_comm ((d * p ^ k : ℕ) : ℚ) _ _], rw div_self,
rw mul_one,
ring_nf, simp_rw [nat.cast_mul _ (x : zmod (d * p^k)).val, ← h2, zmod.nat_cast_val],
repeat { apply congr_arg2 _ _ rfl, },
simp_rw [ring_hom.map_mul], rw mul_assoc, apply congr_arg2 _ rfl _, rw mul_comm,
{ rw nat.cast_mul, rw nat.cast_pow, apply h1, }, },
{ convert tendsto_const_nhds, ext, rw sub_eq_zero,
apply finset.sum_congr _ (λ x hx, _),
{ convert refl _, apply_instance, },
{ rw mul_comm ((algebra_map ℚ R) ↑(n - 1)) _, rw mul_assoc, apply congr_arg2 _ rfl _,
rw ← mul_div, rw ring_hom.map_mul, rw map_nat_cast, rw map_nat_cast, rw ← mul_assoc,
rw mul_assoc (↑(n - 1) * ↑(c ^ n)) _ _, apply congr_arg2 _ rfl _,
rw ← ring_hom.map_pow, rw ← ring_hom.map_mul, rw mul_one_div,
simp_rw [nat.cast_mul, zmod.nat_cast_val, ← coe_coe, nat.cast_pow p], }, },
end
lemma V_h2 [no_zero_divisors R] [algebra ℚ R] [norm_one_class R]
(hd : d.coprime p) (hc' : c.coprime d) (hc : c.coprime p) (hp : 2 < p)
(na : ∀ (n : ℕ) (f : ℕ → R), ∥∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(na' : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥)
(n : ℕ) (hn : 1 < n) (hχ : χ.is_even) (hχ' : d ∣ χ.conductor) :
tendsto (λ (x : ℕ), ((algebra_map ℚ R) n) * V_h_def p d R m χ c n x) at_top (𝓝 ((algebra_map ℚ R) ((↑n - 1)) *
(1 - (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
↑c ^ n) * ((1 - (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n)))
↑p * ↑p ^ (n - 1)) * general_bernoulli_number (χ.mul
(teichmuller_character_mod_p' p R ^ n)) n))) :=
begin
conv { congr, funext, rw ← sub_add_cancel ((algebra_map ℚ R) ↑n * V_h_def p d R m χ c n x) ((algebra_map ℚ R) ((n - 1 : ℕ) : ℚ) *
(1 - (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
(algebra_map ℚ R) (c ^ n : ℚ)) * (U_def p d R m χ n x)), skip, skip, congr,
rw ← zero_add (((algebra_map ℚ R) (↑n - 1) * _) * _), },
apply tendsto.add,
{ conv { congr, funext, rw ← neg_neg ((algebra_map ℚ R) ↑n * V_h_def p d R m χ c n x - _), skip,
skip, rw ← neg_neg (0 : R), },
apply tendsto.neg,
rw neg_zero, simp_rw neg_sub,
conv { congr, funext, rw ← sub_add_sub_cancel _ ((algebra_map ℚ R) ((n - 1 : ℕ) : ℚ) * (U_def p d R m χ n x) -
(∑ (x_1 : (zmod (d * p ^ x))ˣ), (asso_dirichlet_character
(χ.mul (teichmuller_character_mod_p' p R ^ n)) (x_1)) *
(((n - 1 : ℕ) : R) * ((c^n : ℕ) : R) * ((algebra_map ℚ R) ((d * p^x : ℚ) *
int.fract (↑((c : zmod (d * p^(2 * x)))⁻¹ : zmod (d * p^(2 * x))) * ↑x_1 / ↑(d * p ^ x)))^n) *
(algebra_map ℚ R) (1 / (d * p^x))))) _, },
apply filter.tendsto.zero_add_zero _ _,
{ apply_instance, },
{ conv { congr, funext, rw [mul_sub, mul_one, sub_mul ((algebra_map ℚ R) ↑(n - 1)) _ _, sub_sub,
add_comm, ← sub_sub, ← sub_add, add_sub_assoc, map_nat_cast, sub_self, zero_add], },
apply (tendsto_congr' _).2 (tendsto_const_nhds),
apply V_h2_1 p d R m χ c hd hc' hc hp na n hn hχ, },
apply V_h2_2 p d R m χ c hd hc' hc hp na na' n hn, },
{ convert (tendsto.const_mul ((algebra_map ℚ R) (↑n - 1) *
(1 - (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n)))
↑c * ↑c ^ n)) (U p d R m χ hd n hn hχ hχ' hp na)),
ext, --rw dirichlet_character.mul_eq_mul, rw ring_hom.map_pow,
rw ←nat.cast_pow c _,
rw map_nat_cast (algebra_map ℚ R) (c^n), rw nat.cast_pow c _, rw nat.cast_sub (le_of_lt hn), rw nat.cast_one, },
end
lemma V_h3 [no_zero_divisors R] [algebra ℚ R] [norm_one_class R] (hd : d.coprime p)
(hc' : c.coprime d) (hc : c.coprime p) (hp : 2 < p)
(na : ∀ (n : ℕ) (f : ℕ → R), ∥∑ i in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(na' : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥)
(n : ℕ) (hn : 1 < n) (hχ : χ.is_even) (hχ' : d ∣ χ.conductor) :
filter.tendsto (λ (x : ℕ), ↑((χ.mul (teichmuller_character_mod_p' p R ^ n))
(zmod.unit_of_coprime c (helper_19 p d R m χ c hn hd hc' hc))) *
↑c ^ n * U_def p d R m χ n x + V_h_def p d R m χ c n x) filter.at_top (nhds (((algebra_map ℚ R)
((↑n - 1) / ↑n) + (algebra_map ℚ R) (1 / ↑n) *
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
↑c ^ n) * ((1 - (asso_dirichlet_character (χ.mul
(teichmuller_character_mod_p' p R ^ n))) ↑p * ↑p ^ (n - 1)) *
general_bernoulli_number (χ.mul (teichmuller_character_mod_p' p R ^ n)) n))) :=
begin
conv { congr, skip, skip, congr,
rw ← add_sub_cancel' (↑((χ.mul (teichmuller_character_mod_p' p R ^ n))
(zmod.unit_of_coprime c (helper_19 p d R m χ c hn hd hc' hc))) *
↑c ^ n * ((1 - asso_dirichlet_character (dirichlet_character.mul χ
((teichmuller_character_mod_p' p R)^n)) (p) * p^(n - 1) ) *
(general_bernoulli_number (dirichlet_character.mul χ
((teichmuller_character_mod_p' p R)^n)) n))) (((algebra_map ℚ R) ((↑n - 1) / ↑n) +
(algebra_map ℚ R) (1 / ↑n) * (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
↑c ^ n) * ((1 - (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑p * ↑p ^ (n - 1)) *
general_bernoulli_number (χ.mul (teichmuller_character_mod_p' p R ^ n)) n)),
rw ← add_sub, },
apply tendsto.add,
{ apply tendsto.const_mul, apply U p d R m χ hd n hn hχ hχ' hp na, },
{ rw ← sub_mul, rw ← asso_dirichlet_character_eq_char,
rw zmod.coe_unit_of_coprime, --rw ← dirichlet_character.mul_eq_mul,
rw ← add_sub, rw mul_assoc ((algebra_map ℚ R) (1 / ↑n)) _ _, rw ← sub_one_mul,
rw ← ring_hom.map_one (algebra_map ℚ R), rw ← ring_hom.map_sub,-- rw add_comm (1 / ↑n) (1 : ℚ),
rw div_sub_one _,
{ rw ← neg_sub ↑n (1 : ℚ), rw neg_div, rw ring_hom.map_neg, rw neg_mul, rw ← sub_eq_add_neg,
rw ← mul_one_sub, rw ring_hom.map_one,
have h : (algebra_map ℚ R) (1 / (n : ℚ)) * (algebra_map ℚ R) (n : ℚ) = 1,
{ rw ← ring_hom.map_mul, rw one_div_mul_cancel, rw ring_hom.map_one,
{ norm_cast, apply ne_zero_of_lt hn, }, },
conv { congr, funext, rw ← one_mul (V_h_def p d R m χ c n x), rw ← h, rw mul_assoc,
skip, skip, rw div_eq_mul_one_div, rw mul_assoc, rw ring_hom.map_mul,
rw mul_comm _ ((algebra_map ℚ R) (1 / ↑n)), rw mul_assoc, },
apply tendsto.const_mul,
have := V_h2 p d R m χ c hd hc' hc hp na na' n hn hχ hχ',
conv at this { congr, skip, skip, congr, rw mul_assoc ((algebra_map ℚ R) (↑n - 1)) _ _, },
apply this, },
{ norm_cast, apply ne_zero_of_lt hn, }, },
end
lemma V [no_zero_divisors R] [algebra ℚ R] [norm_one_class R] (hd : d.coprime p) (hc' : c.coprime d)
(hc : c.coprime p) (hp : 2 < p) (hχ : χ.is_even) (hχ' : d ∣ χ.conductor)
(na : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥)
(na' : ∀ (n : ℕ) (f : ℕ → R), ∥∑ i in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(n : ℕ) (hn : 1 < n) :
filter.tendsto (λ j : ℕ, V_def p d R m χ c n j)
filter.at_top (nhds (( algebra_map ℚ R ((n - 1) / n) + (algebra_map ℚ R (1 / n)) *
asso_dirichlet_character (dirichlet_character.mul χ
(teichmuller_character_mod_p' p R^n)) (c) * c^n ) * ((1 -
asso_dirichlet_character (dirichlet_character.mul χ
(teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1) ) *
(general_bernoulli_number (dirichlet_character.mul χ
(teichmuller_character_mod_p' p R^n)) n))) ) :=
begin
conv { congr, funext, rw ← sub_add_cancel (V_def p d R m χ c n j)
(((((χ.mul (teichmuller_character_mod_p' p R^n)) (zmod.unit_of_coprime c
(helper_19 p d R m χ c hn hd hc' hc))
* (c : R)^n)) * U_def p d R m χ n j : R) + (V_h_def p d R m χ c n j)), skip, skip,
rw ← zero_add (((algebra_map ℚ R) ((↑n - 1) / ↑n) + (algebra_map ℚ R) (1 / ↑n) *
(asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑c *
↑c ^ n) * ((1 - (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑p *
↑p ^ (n - 1)) * general_bernoulli_number (χ.mul (teichmuller_character_mod_p' p R ^ n)) n)), },
apply filter.tendsto.add,
{ apply V_h1 p d R m χ c hd hc' hc na n hn, },
{ apply V_h3 p d R m χ c hd hc' hc hp na' na n hn hχ hχ', },
end |
import Mandelbrot
import Data.Complex (Complex((:+)))
import Data.Array.MArray
import Data.Array.Storable
import Data.Word (Word32)
import Control.Monad
import Foreign.Ptr
import Foreign.Storable
import Criterion.Measurement
import Criterion.Types (Benchmarkable(..))
import Data.Int (Int64)
mandelbrotI = mandelbrot 10
mandelbrotArray :: Int -> Int -> IO ()
mandelbrotArray height width = do
let widthF = fromIntegral width :: Double
heightF = fromIntegral height :: Double
array <- newArray_ (0, height*width-1) :: IO (StorableArray Int Word32)
withStorableArray array (\pixels ->
forM_ [0..height-1] (\y_ -> do
forM_ [0..width-1] (\x_ -> do
let x = 3/widthF * (fromIntegral x_) - 2
y = -2/heightF * (fromIntegral y_) + 1
mand = mandelbrotI (x :+ y)
color = if mand == 100 then 0 else 0xffffff
pokeElemOff pixels (x_ + y_*width) color)))
simpleBenchmark :: Benchmarkable
simpleBenchmark = Benchmarkable (\tries ->
forM_ [1..tries] (\_ ->
mandelbrotArray 100 100))
main :: IO ()
main = secs <$> snd <$> measure simpleBenchmark 1 >>= printLn
|
/-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
! This file was ported from Lean 3 source module category_theory.category.ulift
! leanprover-community/mathlib commit 32253a1a1071173b33dc7d6a218cf722c6feb514
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.CategoryTheory.Category.Basic
import Mathlib.CategoryTheory.Equivalence
import Mathlib.CategoryTheory.EqToHom
import Mathlib.Data.ULift
/-!
# Basic API for ULift
This file contains a very basic API for working with the categorical
instance on `ULift C` where `C` is a type with a category instance.
1. `category_theory.ULift.up` is the functorial version of the usual `ULift.up`.
2. `category_theory.ULift.down` is the functorial version of the usual `ULift.down`.
3. `category_theory.ULift.equivalence` is the categorical equivalence between
`C` and `ULift C`.
# ULiftHom
Given a type `C : Type u`, `ULiftHom.{w} C` is just an alias for `C`.
If we have `category.{v} C`, then `ULiftHom.{w} C` is endowed with a category instance
whose morphisms are obtained by applying `ULift.{w}` to the morphisms from `C`.
This is a category equivalent to `C`. The forward direction of the equivalence is `ULiftHom.up`,
the backward direction is `ULiftHom.donw` and the equivalence is `ULiftHom.equiv`.
# AsSmall
This file also contains a construction which takes a type `C : Type u` with a
category instance `category.{v} C` and makes a small category
`AsSmall.{w} C : Type (max w v u)` equivalent to `C`.
The forward direction of the equivalence, `C ⥤ AsSmall C`, is denoted `AsSmall.up`
and the backward direction is `AsSmall.down`. The equivalence itself is `AsSmall.equiv`.
-/
universe w₁ v₁ v₂ u₁ u₂
namespace CategoryTheory
variable {C : Type u₁} [Category.{v₁} C]
/-- The functorial version of `ULift.up`. -/
@[simps]
def ULift.upFunctor : C ⥤ ULift.{u₂} C where
obj := ULift.up
map f := f
#align category_theory.ulift.up_functor CategoryTheory.ULift.upFunctor
/-- The functorial version of `ULift.down`. -/
@[simps]
def ULift.downFunctor : ULift.{u₂} C ⥤ C where
obj := ULift.down
map f := f
#align category_theory.ulift.down_functor CategoryTheory.ULift.downFunctor
/-- The categorical equivalence between `C` and `ULift C`. -/
@[simps]
def ULift.equivalence : C ≌ ULift.{u₂} C where
functor := ULift.upFunctor
inverse := ULift.downFunctor
unitIso :=
{ hom := 𝟙 _
inv := 𝟙 _ }
counitIso :=
{ hom :=
{ app := fun X => 𝟙 _
naturality := fun X Y f => by
change f ≫ 𝟙 _ = 𝟙 _ ≫ f
simp }
inv :=
{ app := fun X => 𝟙 _
naturality := fun X Y f => by
change f ≫ 𝟙 _ = 𝟙 _ ≫ f
simp }
hom_inv_id := by
ext
change 𝟙 _ ≫ 𝟙 _ = 𝟙 _
simp
inv_hom_id := by
ext
change 𝟙 _ ≫ 𝟙 _ = 𝟙 _
simp }
functor_unitIso_comp X := by
change 𝟙 X ≫ 𝟙 X = 𝟙 X
simp
#align category_theory.ulift.equivalence CategoryTheory.ULift.equivalence
section ULiftHom
/- Porting note: obviously we don't want code that looks like this long term
the ability to turn off unused universe parameter error is desirable -/
/-- `ULiftHom.{w} C` is an alias for `C`, which is endowed with a category instance
whose morphisms are obtained by applying `ULift.{w}` to the morphisms from `C`.
-/
def ULiftHom.{w,u} (C : Type u) : Type u :=
let _ := ULift.{w} C
C
#align category_theory.ulift_hom CategoryTheory.ULiftHom
instance {C} [Inhabited C] : Inhabited (ULiftHom C) :=
⟨(default : C)⟩
/-- The obvious function `ULiftHom C → C`. -/
def ULiftHom.objDown {C} (A : ULiftHom C) : C :=
A
#align category_theory.ulift_hom.obj_down CategoryTheory.ULiftHom.objDown
/-- The obvious function `C → ULiftHom C`. -/
def ULiftHom.objUp {C} (A : C) : ULiftHom C :=
A
#align category_theory.ulift_hom.obj_up CategoryTheory.ULiftHom.objUp
@[simp]
theorem objDown_objUp {C} (A : C) : (ULiftHom.objUp A).objDown = A :=
rfl
#align category_theory.obj_down_obj_up CategoryTheory.objDown_objUp
@[simp]
theorem objUp_objDown {C} (A : ULiftHom C) : ULiftHom.objUp A.objDown = A :=
rfl
#align category_theory.obj_up_obj_down CategoryTheory.objUp_objDown
instance ULiftHom.category : Category.{max v₂ v₁} (ULiftHom.{v₂} C) where
Hom A B := ULift.{v₂} <| A.objDown ⟶ B.objDown
id A := ⟨𝟙 _⟩
comp f g := ⟨f.down ≫ g.down⟩
/-- One half of the quivalence between `C` and `ULiftHom C`. -/
@[simps]
def ULiftHom.up : C ⥤ ULiftHom C where
obj := ULiftHom.objUp
map f := ⟨f⟩
#align category_theory.ulift_hom.up CategoryTheory.ULiftHom.up
/-- One half of the quivalence between `C` and `ULiftHom C`. -/
@[simps]
def ULiftHom.down : ULiftHom C ⥤ C where
obj := ULiftHom.objDown
map f := f.down
#align category_theory.ulift_hom.down CategoryTheory.ULiftHom.down
/-- The equivalence between `C` and `ULiftHom C`. -/
def ULiftHom.equiv : C ≌ ULiftHom C where
functor := ULiftHom.up
inverse := ULiftHom.down
unitIso := NatIso.ofComponents (fun A => eqToIso rfl) (by aesop_cat)
counitIso := NatIso.ofComponents (fun A => eqToIso rfl) (by aesop_cat)
#align category_theory.ulift_hom.equiv CategoryTheory.ULiftHom.equiv
end ULiftHom
/- Porting note: we want to keep around the category instance on `D`
so Lean can figure out things further down. So `AsSmall` has been
nolinted. -/
/-- `AsSmall C` is a small category equivalent to `C`.
More specifically, if `C : Type u` is endowed with `Category.{v} C`, then
`AsSmall.{w} C : Type (max w v u)` is endowed with an instance of a small category.
The objects and morphisms of `AsSmall C` are defined by applying `ULift` to the
objects and morphisms of `C`.
Note: We require a category instance for this definition in order to have direct
access to the universe level `v`.
-/
@[nolint unusedArguments]
def AsSmall.{w, v, u} (D : Type u) [Category.{v} D] := ULift.{max w v} D
#align category_theory.as_small CategoryTheory.AsSmall
instance : SmallCategory (AsSmall.{w₁} C) where
Hom X Y := ULift.{max w₁ u₁} <| X.down ⟶ Y.down
id X := ⟨𝟙 _⟩
comp f g := ⟨f.down ≫ g.down⟩
/-- One half of the equivalence between `C` and `AsSmall C`. -/
@[simps]
def AsSmall.up : C ⥤ AsSmall C where
obj X := ⟨X⟩
map f := ⟨f⟩
#align category_theory.as_small.up CategoryTheory.AsSmall.up
/-- One half of the equivalence between `C` and `AsSmall C`. -/
@[simps]
def AsSmall.down : AsSmall C ⥤ C where
obj X := ULift.down X
map f := f.down
#align category_theory.as_small.down CategoryTheory.AsSmall.down
/-- The equivalence between `C` and `AsSmall C`. -/
@[simps]
def AsSmall.equiv : C ≌ AsSmall C where
functor := AsSmall.up
inverse := AsSmall.down
unitIso := NatIso.ofComponents (fun X => eqToIso rfl) (by aesop_cat)
counitIso :=
NatIso.ofComponents
(fun X =>
eqToIso <| by
apply ULift.ext
rfl)
(by aesop_cat)
#align category_theory.as_small.equiv CategoryTheory.AsSmall.equiv
instance [Inhabited C] : Inhabited (AsSmall C) :=
⟨⟨default⟩⟩
/-- The equivalence between `C` and `ULiftHom (ULift C)`. -/
def ULiftHomULiftCategory.equiv.{v', u', v, u} (C : Type u) [Category.{v} C] :
C ≌ ULiftHom.{v'} (ULift.{u'} C) :=
ULift.equivalence.trans ULiftHom.equiv
#align category_theory.ulift_hom_ulift_category.equiv CategoryTheory.ULiftHomULiftCategory.equiv
end CategoryTheory
|
module io
function guess_type(x)
try
return eval(parse(x))
catch
return x
end
end
function split(word::AbstractString, delimiter::AbstractString)
words = []
lastsearchpos = -1:0
while true
searchpos = search(word, delimiter, lastsearchpos[end]+1)
if searchpos==0:-1
push!(words, word[lastsearchpos[end]+1:end])
break
end
push!(words, word[lastsearchpos[end]+1:searchpos[1]-1])
lastsearchpos = searchpos
end
return words
end
function join(delimiter::AbstractString, words::Vector)
result = words[1]
for i=2:length(words)
result = result*delimiter*words[i]
end
return result
end
function dict2filename(d::Dict; extension=".dat")
pairs = ["$(key)=$(item)" for (key, item) in d]
return join(";", sort(pairs))*extension
end
function filename2dict(name::AbstractString; extension=".dat")
@assert endswith(name, extension)
items = split(name[1:end-length(extension)], ";")
D = Dict()
for item in items
array = split(item, "=")
key = array[1]
value = array[2]
D[key] = guess_type(value)
end
return D
end
end # module
|
Human <unk>
|
// Copyright 2010 Christophe Henry
// henry UNDERSCORE christophe AT hotmail DOT com
// This is an extended version of the state machine available in the boost::mpl library
// Distributed under the same license as the original.
// Copyright for the original version:
// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
// under 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)
#include <iostream>
// back-end
#include <boost/msm/back/state_machine.hpp>
//front-end
#include <boost/msm/front/state_machine_def.hpp>
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
namespace msm = boost::msm;
namespace mpl = boost::mpl;
namespace
{
// events
struct event1 {};
struct event2 {};
struct event3 {};
struct event4 {};
struct event5 {};
struct event6
{
event6(){}
template <class Event>
event6(Event const&){}
};
// front-end: define the FSM structure
struct Fsm_ : public msm::front::state_machine_def<Fsm_>
{
// The list of FSM states
struct State1 : public msm::front::state<>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct State2 : public msm::front::state<>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct SubFsm2_ : public msm::front::state_machine_def<SubFsm2_>
{
typedef msm::back::state_machine<SubFsm2_> SubFsm2;
unsigned int entry_action_counter;
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
struct SubState1 : public msm::front::state<>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct SubState1b : public msm::front::state<>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct SubState2 : public msm::front::state<> , public msm::front::explicit_entry<0>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct SubState2b : public msm::front::state<> , public msm::front::explicit_entry<1>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
// test with a pseudo entry
struct PseudoEntry1 : public msm::front::entry_pseudo_state<0>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct SubState3 : public msm::front::state<>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
struct PseudoExit1 : public msm::front::exit_pseudo_state<event6>
{
template <class Event,class FSM>
void on_entry(Event const&,FSM& ) {++entry_counter;}
template <class Event,class FSM>
void on_exit(Event const&,FSM& ) {++exit_counter;}
int entry_counter;
int exit_counter;
};
// action methods
void entry_action(event4 const&)
{
++entry_action_counter;
}
// the initial state. Must be defined
typedef mpl::vector<SubState1,SubState1b> initial_state;
typedef mpl::vector<SubState2b> explicit_creation;
// Transition table for SubFsm2
struct transition_table : mpl::vector<
// Start Event Next Action Guard
// +--------------+-------------+------------+------------------------+----------------------+
a_row < PseudoEntry1 , event4 , SubState3 ,&SubFsm2_::entry_action >,
_row < SubState2 , event6 , SubState1 >,
_row < SubState3 , event5 , PseudoExit1 >
// +--------------+-------------+------------+------------------------+----------------------+
> {};
// Replaces the default no-transition response.
template <class FSM,class Event>
void no_transition(Event const& e, FSM&,int state)
{
BOOST_FAIL("no_transition called!");
}
};
typedef msm::back::state_machine<SubFsm2_> SubFsm2;
// the initial state of the player SM. Must be defined
typedef State1 initial_state;
// transition actions
// guard conditions
// Transition table for Fsm
struct transition_table : mpl::vector<
// Start Event Next Action Guard
// +---------------------+--------+------------------------------------+-------+--------+
_row < State1 , event1 , SubFsm2 >,
_row < State1 , event2 , SubFsm2::direct<SubFsm2_::SubState2> >,
_row < State1 , event3 , mpl::vector<SubFsm2::direct<SubFsm2_::SubState2>,
SubFsm2::direct<SubFsm2_::SubState2b> > >,
_row < State1 , event4 , SubFsm2::entry_pt
<SubFsm2_::PseudoEntry1> >,
// +---------------------+--------+------------------------------------+-------+--------+
_row < SubFsm2 , event1 , State1 >,
_row < SubFsm2::exit_pt
<SubFsm2_::PseudoExit1>, event6 , State2 >
// +---------------------+--------+------------------------------------+-------+--------+
> {};
// Replaces the default no-transition response.
template <class FSM,class Event>
void no_transition(Event const& e, FSM&,int state)
{
BOOST_FAIL("no_transition called!");
}
// init counters
template <class Event,class FSM>
void on_entry(Event const&,FSM& fsm)
{
fsm.template get_state<Fsm_::State1&>().entry_counter=0;
fsm.template get_state<Fsm_::State1&>().exit_counter=0;
fsm.template get_state<Fsm_::State2&>().entry_counter=0;
fsm.template get_state<Fsm_::State2&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().entry_action_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState1&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState1&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState1b&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState1b&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState2&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState2&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState2b&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState2b&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState3&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::SubState3&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::PseudoEntry1&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::PseudoEntry1&>().exit_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::exit_pt<SubFsm2_::PseudoExit1>&>().entry_counter=0;
fsm.template get_state<Fsm_::SubFsm2&>().template get_state<Fsm_::SubFsm2::exit_pt<SubFsm2_::PseudoExit1>&>().exit_counter=0;
}
};
typedef msm::back::state_machine<Fsm_> Fsm;
// static char const* const state_names[] = { "State1", "SubFsm2","State2" };
BOOST_AUTO_TEST_CASE( my_test )
{
Fsm p;
p.start();
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().entry_counter == 1,"State1 entry not called correctly");
p.process_event(event1());
p.process_event(event1());
BOOST_CHECK_MESSAGE(p.current_state()[0] == 0,"State1 should be active");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().exit_counter == 1,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().entry_counter == 2,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().exit_counter == 1,"SubFsm2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().entry_counter == 1,"SubFsm2 entry not called correctly");
p.process_event(event2());
p.process_event(event6());
p.process_event(event1());
BOOST_CHECK_MESSAGE(p.current_state()[0] == 0,"State1 should be active");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().exit_counter == 2,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().entry_counter == 3,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().exit_counter == 2,"SubFsm2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().entry_counter == 2,"SubFsm2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState2&>().entry_counter == 1,
"SubFsm2::SubState2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState2&>().exit_counter == 1,
"SubFsm2::SubState2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState1&>().entry_counter == 2,
"SubFsm2::SubState1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState1&>().exit_counter == 2,
"SubFsm2::SubState1 exit not called correctly");
p.process_event(event3());
p.process_event(event1());
BOOST_CHECK_MESSAGE(p.current_state()[0] == 0,"State1 should be active");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().exit_counter == 3,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().entry_counter == 4,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().exit_counter == 3,"SubFsm2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().entry_counter == 3,"SubFsm2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState2&>().entry_counter == 2,
"SubFsm2::SubState2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState2&>().exit_counter == 2,
"SubFsm2::SubState2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState2b&>().entry_counter == 1,
"SubFsm2::SubState2b entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState2b&>().exit_counter == 1,
"SubFsm2::SubState2b exit not called correctly");
p.process_event(event4());
p.process_event(event5());
BOOST_CHECK_MESSAGE(p.current_state()[0] == 2,"State2 should be active");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State1&>().exit_counter == 4,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::State2&>().entry_counter == 1,"State2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().exit_counter == 4,"SubFsm2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().entry_counter == 4,"SubFsm2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::PseudoEntry1&>().entry_counter == 1,
"SubFsm2::PseudoEntry1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::PseudoEntry1&>().exit_counter == 1,
"SubFsm2::PseudoEntry1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState3&>().entry_counter == 1,
"SubFsm2::SubState3 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2_::SubState3&>().exit_counter == 1,
"SubFsm2::SubState3 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2::exit_pt<Fsm_::SubFsm2_::PseudoExit1>&>().entry_counter == 1,
"SubFsm2::PseudoExit1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().get_state<Fsm_::SubFsm2::exit_pt<Fsm_::SubFsm2_::PseudoExit1>&>().exit_counter == 1,
"SubFsm2::PseudoExit1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<Fsm_::SubFsm2&>().entry_action_counter == 1,"Action not called correctly");
}
}
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
Supplementary theorems about the `string` type.
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.list.basic
import Mathlib.data.char
import Mathlib.PostPort
namespace Mathlib
namespace string
def ltb : iterator → iterator → Bool := sorry
protected instance has_lt' : HasLess string :=
{ Less := fun (s₁ s₂ : string) => ↥(ltb (mk_iterator s₁) (mk_iterator s₂)) }
protected instance decidable_lt : DecidableRel Less :=
fun (a b : string) => bool.decidable_eq (ltb (mk_iterator a) (mk_iterator b)) tt
@[simp] theorem lt_iff_to_list_lt {s₁ : string} {s₂ : string} : s₁ < s₂ ↔ to_list s₁ < to_list s₂ :=
sorry
protected instance has_le : HasLessEq string := { LessEq := fun (s₁ s₂ : string) => ¬s₂ < s₁ }
protected instance decidable_le : DecidableRel LessEq :=
fun (a b : string) => ne.decidable (ltb (mk_iterator b) (mk_iterator a)) tt
@[simp] theorem le_iff_to_list_le {s₁ : string} {s₂ : string} : s₁ ≤ s₂ ↔ to_list s₁ ≤ to_list s₂ :=
iff.trans (not_congr lt_iff_to_list_lt) not_lt
theorem to_list_inj {s₁ : string} {s₂ : string} : to_list s₁ = to_list s₂ ↔ s₁ = s₂ := sorry
theorem nil_as_string_eq_empty : list.as_string [] = empty := rfl
@[simp] theorem to_list_empty : to_list empty = [] := rfl
theorem as_string_inv_to_list (s : string) : list.as_string (to_list s) = s :=
string_imp.cases_on s fun (s : List char) => Eq.refl (list.as_string (to_list (string_imp.mk s)))
@[simp] theorem to_list_singleton (c : char) : to_list (singleton c) = [c] := rfl
theorem to_list_nonempty {s : string} (h : s ≠ empty) : to_list s = head s :: to_list (popn s 1) :=
sorry
@[simp] theorem head_empty : head empty = Inhabited.default := rfl
@[simp] theorem popn_empty {n : ℕ} : popn empty n = empty := sorry
protected instance linear_order : linear_order string :=
linear_order.mk LessEq Less sorry sorry sorry sorry string.decidable_le
(fun (a b : string) => string.has_decidable_eq a b)
fun (a b : string) => string.decidable_lt a b
end string
theorem list.to_list_inv_as_string (l : List char) : string.to_list (list.as_string l) = l := sorry
@[simp] theorem list.as_string_inj {l : List char} {l' : List char} :
list.as_string l = list.as_string l' ↔ l = l' :=
sorry
theorem list.as_string_eq {l : List char} {s : string} :
list.as_string l = s ↔ l = string.to_list s :=
sorry
end Mathlib |
section\<open>Modelling the Adversary\<close>
theory Adversary imports Message begin
subsection\<open>Analysis\<close>
inductive_set
analz :: "msg set \<Rightarrow> msg set"
for H :: "msg set"
where
Inj [intro,simp] : "X \<in> H \<Longrightarrow> X \<in> analz H"
| Fst: "\<lbrace>X,Y\<rbrace> \<in> analz H \<Longrightarrow> X \<in> analz H"
| Snd: "\<lbrace>X,Y\<rbrace> \<in> analz H \<Longrightarrow> Y \<in> analz H"
| Decrypt [dest]:
"\<lbrakk>Crypt K X \<in> analz H; Key(invKey K) \<in> analz H\<rbrakk>
\<Longrightarrow> X \<in> analz H"
lemma analz_mono: "G\<subseteq>H \<Longrightarrow> analz(G) \<subseteq> analz(H)"
apply auto
apply (erule analz.induct)
apply (auto dest: analz.Fst analz.Snd)
done
lemma MPair_analz [elim!]: "\<lbrakk> \<lbrace>X,Y\<rbrace> \<in> analz H; \<lbrakk>X \<in> analz H; Y \<in> analz H \<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
by (blast dest: analz.Fst analz.Snd)
lemma analz_increasing: "H \<subseteq> analz(H)"
by blast
lemma analz_subset_parts: "analz H \<subseteq> parts H"
apply (rule subsetI)
apply (erule analz.induct, blast+)
done
lemmas analz_into_parts = analz_subset_parts [THEN subsetD]
lemmas not_parts_not_analz = analz_subset_parts [THEN contra_subsetD]
lemma parts_analz [simp]: "parts (analz H) = parts H"
apply (rule equalityI)
apply (rule analz_subset_parts [THEN parts_mono, THEN subset_trans], simp)
apply (blast intro: analz_increasing [THEN parts_mono, THEN subsetD])
done
lemma analz_parts [simp]: "analz (parts H) = parts H"
apply auto
apply (erule analz.induct, auto)
done
lemmas analz_insertI = subset_insertI [THEN analz_mono, THEN [2] rev_subsetD]
lemma analz_empty [simp]: "analz{} = {}"
apply safe
apply (erule analz.induct, blast+)
done
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)"
by (intro Un_least analz_mono Un_upper1 Un_upper2)
lemma analz_insert: "insert X (analz H) \<subseteq> analz(insert X H)"
by (blast intro: analz_mono [THEN [2] rev_subsetD])
lemmas analz_insert_eq_I = equalityI [OF subsetI analz_insert]
lemma analz_insert_Agent [simp]:
"analz (insert (Agent agt) H) = insert (Agent agt) (analz H)"
apply (rule analz_insert_eq_I)
apply (erule analz.induct, auto)
done
lemma analz_insert_Nonce [simp]:
"analz (insert (Nonce N) H) = insert (Nonce N) (analz H)"
apply (rule analz_insert_eq_I)
apply (erule analz.induct, auto)
done
lemma analz_insert_Key [simp]:
"K \<notin> keysFor (analz H) \<Longrightarrow>
analz (insert (Key K) H) = insert (Key K) (analz H)"
apply (unfold keysFor_def)
apply (rule analz_insert_eq_I)
apply (erule analz.induct, auto)
done
lemma analz_insert_MPair [simp]:
"analz (insert \<lbrace>X,Y\<rbrace> H) =
insert \<lbrace>X,Y\<rbrace> (analz (insert X (insert Y H)))"
apply (rule equalityI)
apply (rule subsetI)
apply (erule analz.induct, auto)
apply (erule analz.induct)
apply (blast intro: analz.Fst analz.Snd)+
done
lemma analz_insert_Crypt:
"Key (invKey K) \<notin> analz H
\<Longrightarrow> analz (insert (Crypt K X) H) = insert (Crypt K X) (analz H)"
apply (rule analz_insert_eq_I)
apply (erule analz.induct, auto)
done
lemma lemma1: "Key (invKey K) \<in> analz H \<Longrightarrow>
analz (insert (Crypt K X) H) \<subseteq>
insert (Crypt K X) (analz (insert X H))"
apply (rule subsetI)
apply (erule_tac x = x in analz.induct, auto)
done
lemma lemma2: "Key (invKey K) \<in> analz H \<Longrightarrow>
insert (Crypt K X) (analz (insert X H)) \<subseteq>
analz (insert (Crypt K X) H)"
apply auto
apply (erule_tac x = x in analz.induct, auto)
apply (blast intro: analz_insertI analz.Decrypt)
done
lemma analz_insert_Decrypt:
"Key (invKey K) \<in> analz H \<Longrightarrow>
analz (insert (Crypt K X) H) =
insert (Crypt K X) (analz (insert X H))"
by (intro equalityI lemma1 lemma2)
lemma analz_Crypt_if [simp]:
"analz (insert (Crypt K X) H) =
(if (Key (invKey K) \<in> analz H)
then insert (Crypt K X) (analz (insert X H))
else insert (Crypt K X) (analz H))"
by (simp add: analz_insert_Crypt analz_insert_Decrypt)
lemma analz_insert_Crypt_subset:
"analz (insert (Crypt K X) H) \<subseteq>
insert (Crypt K X) (analz (insert X H))"
apply (rule subsetI)
apply (erule analz.induct, auto)
done
lemma analz_image_Key [simp]: "analz (Key`N) = Key`N"
apply auto
apply (erule analz.induct, auto)
done
lemma analz_analzD [dest!]: "X\<in> analz (analz H) \<Longrightarrow> X\<in> analz H"
by (erule analz.induct, blast+)
lemma analz_idem [simp]: "analz (analz H) = analz H"
by blast
lemma analz_subset_iff [simp]: "(analz G \<subseteq> analz H) = (G \<subseteq> analz H)"
apply (rule iffI)
apply (iprover intro: subset_trans analz_increasing)
apply (frule analz_mono, simp)
done
lemma analz_trans: "\<lbrakk>X\<in> analz G; G \<subseteq> analz H \<rbrakk> \<Longrightarrow> X\<in> analz H"
by (drule analz_mono, blast)
lemma analz_cut: "\<lbrakk>Y\<in> analz (insert X H); X\<in> analz H \<rbrakk> \<Longrightarrow> Y\<in> analz H"
by (erule analz_trans, blast)
lemma analz_insert_eq: "X\<in> analz H \<Longrightarrow> analz (insert X H) = analz H"
by (blast intro: analz_cut analz_insertI)
lemma analz_subset_cong:
"\<lbrakk> analz G \<subseteq> analz G'; analz H \<subseteq> analz H'\<rbrakk>
\<Longrightarrow> analz (G \<union> H) \<subseteq> analz (G' \<union> H')"
apply simp
apply (iprover intro: conjI subset_trans analz_mono Un_upper1 Un_upper2)
done
lemma analz_cong:
"\<lbrakk>analz G = analz G'; analz H = analz H'\<rbrakk>
\<Longrightarrow> analz (G \<union> H) = analz (G' \<union> H')"
by (intro equalityI analz_subset_cong, simp_all)
lemma analz_insert_cong:
"analz H = analz H' \<Longrightarrow> analz(insert X H) = analz(insert X H')"
by (force simp only: insert_def intro!: analz_cong)
lemma analz_trivial:
"[| \<forall>X Y. \<lbrace>X,Y\<rbrace> \<notin> H; \<forall>X K. Crypt K X \<notin> H |] ==> analz H = H"
apply safe
apply (erule analz.induct, blast+)
done
lemma analz_UN_analz_lemma:
"X\<in> analz (\<Union>i\<in>A. analz (H i)) \<Longrightarrow> X\<in> analz (\<Union>i\<in>A. H i)"
apply (erule analz.induct)
apply (blast intro: analz_mono [THEN [2] rev_subsetD])+
done
lemma analz_UN_analz [simp]: "analz (\<Union>i\<in>A. analz (H i)) = analz (\<Union>i\<in>A. H i)"
by (blast intro: analz_UN_analz_lemma analz_mono [THEN [2] rev_subsetD])
lemma gen_analz_insert_eq [rule_format]:
"X \<in> analz H \<Longrightarrow> \<forall>G. H \<subseteq> G \<longrightarrow> analz (insert X G) = analz G"
by (blast intro: analz_cut analz_insertI analz_mono [THEN [2] rev_subsetD])
lemma analz_analz_Un [simp]: "analz (analz G \<union> H) = analz (G \<union> H)"
apply (intro equalityI analz_subset_cong)+
apply simp_all
done
subsubsection\<open>Combinations of parts and analz\<close>
lemma analz_conj_parts [simp]:
"(X \<in> analz H & X \<in> parts H) = (X \<in> analz H)"
by (blast intro: analz_subset_parts [THEN subsetD])
lemma analz_disj_parts [simp]:
"(X \<in> analz H | X \<in> parts H) = (X \<in> parts H)"
by (blast intro: analz_subset_parts [THEN subsetD])
subsection\<open>Synthesis\<close>
inductive_set
synth :: "msg set \<Rightarrow> msg set"
for H :: "msg set"
where
Inj [intro]: "X \<in> H \<Longrightarrow> X \<in> synth H"
| Agent [intro]: "Agent agt \<in> synth H"
| MPair [intro]:
"\<lbrakk>X \<in> synth H; Y \<in> synth H\<rbrakk> \<Longrightarrow> \<lbrace>X,Y\<rbrace> \<in> synth H"
| Crypt [intro]:
"\<lbrakk>X \<in> synth H; Key K \<in> H\<rbrakk> \<Longrightarrow> Crypt K X \<in> synth H"
lemma synth_mono: "G\<subseteq>H \<Longrightarrow> synth(G) \<subseteq> synth(H)"
by (auto, erule synth.induct, auto)
inductive_cases Key_synth [elim!]: "Key K \<in> synth H"
inductive_cases MPair_synth [elim!]: "\<lbrace>X,Y\<rbrace> \<in> synth H"
inductive_cases Crypt_synth [elim!]: "Crypt K X \<in> synth H"
inductive_cases Nonce_synth [elim!]: "Nonce n \<in> synth H"
lemma synth_increasing: "H \<subseteq> synth(H)"
by blast
lemma synth_Un: "synth(G) \<union> synth(H) \<subseteq> synth(G \<union> H)"
by (intro Un_least synth_mono Un_upper1 Un_upper2)
lemma synth_insert: "insert X (synth H) \<subseteq> synth(insert X H)"
by (blast intro: synth_mono [THEN [2] rev_subsetD])
lemma synth_synthD [dest!]: "X\<in> synth (synth H) \<Longrightarrow> X\<in> synth H"
by (erule synth.induct, blast+)
lemma synth_idem: "synth (synth H) = synth H"
by blast
lemma synth_subset_iff [simp]: "(synth G \<subseteq> synth H) = (G \<subseteq> synth H)"
apply (rule iffI)
apply (iprover intro: subset_trans synth_increasing)
apply (frule synth_mono, simp add: synth_idem)
done
lemma synth_trans: "\<lbrakk>X\<in> synth G; G \<subseteq> synth H\<rbrakk> \<Longrightarrow> X\<in> synth H"
by (drule synth_mono, blast)
lemma synth_cut: "\<lbrakk> Y\<in> synth (insert X H); X\<in> synth H \<rbrakk> \<Longrightarrow> Y\<in> synth H"
by (erule synth_trans, blast)
lemma Nonce_synth_eq [simp]: "(Nonce N \<in> synth H) = (Nonce N \<in> H)"
by blast
lemma Crypt_synth_eq [simp]:
"Key K \<notin> H \<Longrightarrow> (Crypt K X \<in> synth H) = (Crypt K X \<in> H)"
by blast
lemma keysFor_synth [simp]:
"keysFor (synth H) = keysFor H \<union> invKey`{K. Key K \<in> H}"
by (unfold keysFor_def, blast)
subsubsection\<open>Combinations of parts and synth\<close>
lemma parts_synth [simp]: "parts (synth H) = parts H \<union> synth H"
apply (rule equalityI)
apply (rule subsetI)
apply (erule parts.induct)
apply (blast intro: synth_increasing [THEN parts_mono, THEN subsetD]
parts.Fst parts.Snd parts.Body)+
done
lemma keysFor_parts_insert:
"[| K \<in> keysFor (parts (insert X G)); X \<in> synth (analz H) |]
==> K \<in> keysFor (parts (G \<union> H)) | Key (invKey K) \<in> parts H"
by (force
dest!: parts_insert_subset_Un [THEN keysFor_mono, THEN [2] rev_subsetD]
analz_subset_parts [THEN keysFor_mono, THEN [2] rev_subsetD]
intro: analz_subset_parts [THEN subsetD] parts_mono [THEN [2] rev_subsetD])
subsubsection\<open>Combinations of analz and synth\<close>
lemma analz_synth_Un [simp]: "analz (synth G \<union> H) = analz (G \<union> H) \<union> synth G"
apply (rule equalityI)
apply (rule subsetI)
apply (erule analz.induct)
prefer 5 apply (blast intro: analz_mono [THEN [2] rev_subsetD])
apply (blast intro: analz.Fst analz.Snd analz.Decrypt)+
done
lemma analz_synth [simp]: "analz (synth H) = analz H \<union> synth H"
apply (cut_tac H = "{}" in analz_synth_Un)
apply (simp (no_asm_use))
done
lemma Fake_analz_insert:
"X \<in> synth (analz G) \<Longrightarrow>
analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)"
apply (rule subsetI)
apply (subgoal_tac "x \<in> analz (synth (analz G) \<union> H) ")
prefer 2 apply (blast intro: analz_mono [THEN [2] rev_subsetD] analz_mono [THEN synth_mono, THEN [2] rev_subsetD])
apply (simp (no_asm_use))
apply blast
done
lemma MPair_synth_analz [iff]:
"(\<lbrace>X,Y\<rbrace> \<in> synth (analz H)) =
(X \<in> synth (analz H) & Y \<in> synth (analz H))"
by blast
lemma synth_analz_mono: "G\<subseteq>H \<Longrightarrow> synth (analz(G)) \<subseteq> synth (analz(H))"
by (iprover intro: synth_mono analz_mono)
lemma Fake_analz_eq [simp]:
"X \<in> synth(analz H) \<Longrightarrow> synth (analz (insert X H)) = synth (analz H)"
apply (drule Fake_analz_insert[of _ _ "H"])
apply (simp add: synth_increasing[THEN Un_absorb2])
apply (drule synth_mono)
apply (simp add: synth_idem)
apply (rule equalityI)
apply (simp add: )
apply (rule synth_analz_mono, blast)
done
lemma synth_analz_insert_eq [rule_format]:
"X \<in> synth (analz H)
\<Longrightarrow> \<forall>G. H \<subseteq> G \<longrightarrow> (Key K \<in> analz (insert X G)) = (Key K \<in> analz G)"
apply (erule synth.induct)
apply (simp_all add: gen_analz_insert_eq subset_trans [OF _ subset_insertI])
done
lemma synth_analz_idem [simp]: "synth (analz (synth (analz X)))=synth (analz X)"
by (simp add: sup_absorb2 synth_idem synth_increasing)
subsubsection\<open>Combinations of parts, analz, and synth\<close>
lemma Fake_parts_insert: "X \<in> synth (analz H) \<Longrightarrow> parts (insert X H) \<subseteq> synth (analz H) \<union> parts H"
apply (drule parts_insert_subset_Un)
apply (simp (no_asm_use))
apply blast
done
lemma Fake_parts_insert_in_Un:
"\<lbrakk>Z \<in> parts (insert X H); X \<in> synth (analz H)\<rbrakk>
\<Longrightarrow> Z \<in> synth (analz H) \<union> parts H"
by (blast dest: Fake_parts_insert [THEN subsetD])
lemma Crypt_synth_analz:
"\<lbrakk> Key K \<in> analz H; Key (invKey K) \<in> analz H \<rbrakk>
\<Longrightarrow> (Crypt K X \<in> synth (analz H)) = (X \<in> synth (analz H))"
by blast
lemma Fake_parts_sing:
"X \<in> synth (analz H) \<Longrightarrow> parts{X} \<subseteq> synth (analz H) \<union> parts H"
apply (rule subset_trans)
apply (erule_tac [2] Fake_parts_insert)
apply (rule parts_mono, blast)
done
lemmas Fake_parts_sing_imp_Un = Fake_parts_sing [THEN [2] rev_subsetD]
declare parts.Body [rule del]
end |
//
// detail/impl/socket_ops_ext.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (C) 2016-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_boost or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_DETAIL_SOCKET_OPS_EXT_IPP
#define BOOST_ASIO_DETAIL_SOCKET_OPS_EXT_IPP
#include <boost/asio/detail/impl/socket_ops.ipp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace detail {
namespace socket_ops {
signed_size_type recvfrom(socket_type s, buf* bufs, size_t count,
int flags, socket_addr_type* addr, std::size_t* addrlen,
boost::system::error_code& ec, boost::asio::ip::address& da)
{
clear_last_error();
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
GUID WSARecvMsg_GUID = WSAID_WSARECVMSG;
LPFN_WSARECVMSG WSARecvMsg;
DWORD NumberOfBytes;
error_wrapper(WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER,
&WSARecvMsg_GUID, sizeof WSARecvMsg_GUID,
&WSARecvMsg, sizeof WSARecvMsg,
&NumberOfBytes, NULL, NULL), ec);
if (ec.value() == SOCKET_ERROR) {
WSARecvMsg = NULL;
return 0;
}
WSABUF wsaBuf;
WSAMSG msg;
char controlBuffer[1024];
msg.name = addr;
msg.namelen = *addrlen;
wsaBuf.buf = bufs->buf;
wsaBuf.len = bufs->len;
msg.lpBuffers = &wsaBuf;
msg.dwBufferCount = count;
msg.Control.len = sizeof controlBuffer;
msg.Control.buf = controlBuffer;
msg.dwFlags = flags;
DWORD dwNumberOfBytesRecvd;
signed_size_type result = error_wrapper(WSARecvMsg(s, &msg, &dwNumberOfBytesRecvd, NULL, NULL), ec);
if (result >= 0) {
ec = boost::system::error_code();
// Find destination address
for (LPWSACMSGHDR cmsg = WSA_CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = WSA_CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
{
struct in_pktinfo *pi = (struct in_pktinfo *) WSA_CMSG_DATA(cmsg);
if (pi)
{
da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr));
}
} else
if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO)
{
struct in6_pktinfo *pi = (struct in6_pktinfo *) WSA_CMSG_DATA(cmsg);
if (pi)
{
boost::asio::ip::address_v6::bytes_type b;
memcpy(b.data(), pi->ipi6_addr.s6_addr, sizeof(pi->ipi6_addr.s6_addr));
da = boost::asio::ip::address_v6(b);
}
}
}
} else {
dwNumberOfBytesRecvd = -1;
}
return dwNumberOfBytesRecvd;
#else // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
char cmbuf[0x100];
msghdr msg = msghdr();
init_msghdr_msg_name(msg.msg_name, addr);
msg.msg_namelen = static_cast<int>(*addrlen);
msg.msg_iov = bufs;
msg.msg_iovlen = static_cast<int>(count);
msg.msg_control = cmbuf;
msg.msg_controllen = sizeof(cmbuf);
signed_size_type result = error_wrapper(::recvmsg(s, &msg, flags), ec);
*addrlen = msg.msg_namelen;
if (result >= 0) {
ec = boost::system::error_code();
// Find destination address
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
{
struct in_pktinfo *pi = (struct in_pktinfo *) CMSG_DATA(cmsg);
if (pi)
{
da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr));
}
} else
if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO)
{
struct in6_pktinfo *pi = (struct in6_pktinfo *) CMSG_DATA(cmsg);
if (pi)
{
boost::asio::ip::address_v6::bytes_type b;
memcpy(b.data(), pi->ipi6_addr.s6_addr, sizeof(pi->ipi6_addr.s6_addr));
da = boost::asio::ip::address_v6(b);
}
}
}
}
return result;
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
}
size_t sync_recvfrom(socket_type s, state_type state, buf* bufs,
size_t count, int flags, socket_addr_type* addr,
std::size_t* addrlen, boost::system::error_code& ec, boost::asio::ip::address& da)
{
if (s == invalid_socket)
{
ec = boost::asio::error::bad_descriptor;
return 0;
}
// Read some data.
for (;;)
{
// Try to complete the operation without blocking.
signed_size_type bytes = socket_ops::recvfrom(
s, bufs, count, flags, addr, addrlen, ec, da);
// Check if operation succeeded.
if (bytes >= 0)
return bytes;
// Operation failed.
if ((state & user_set_non_blocking)
|| (ec != boost::asio::error::would_block
&& ec != boost::asio::error::try_again))
return 0;
// Wait for socket to become ready.
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
return 0;
}
}
#if defined(BOOST_ASIO_HAS_IOCP)
void complete_iocp_recvfrom(
const weak_cancel_token_type& cancel_token,
boost::system::error_code& ec, boost::asio::ip::address& da)
{
// Map non-portable errors to their portable counterparts.
if (ec.value() == ERROR_NETNAME_DELETED)
{
if (cancel_token.expired())
ec = boost::asio::error::operation_aborted;
else
ec = boost::asio::error::connection_reset;
}
else if (ec.value() == ERROR_PORT_UNREACHABLE)
{
ec = boost::asio::error::connection_refused;
}
}
#else // defined(BOOST_ASIO_HAS_IOCP)
bool non_blocking_recvfrom(socket_type s,
buf* bufs, size_t count, int flags,
socket_addr_type* addr, std::size_t* addrlen,
boost::system::error_code& ec, size_t& bytes_transferred, boost::asio::ip::address& da)
{
for (;;)
{
// Read some data.
signed_size_type bytes = socket_ops::recvfrom(
s, bufs, count, flags, addr, addrlen, ec, da);
// Retry operation if interrupted by signal.
if (ec == boost::asio::error::interrupted)
continue;
// Check if we need to run the operation again.
if (ec == boost::asio::error::would_block
|| ec == boost::asio::error::try_again)
return false;
// Operation is complete.
if (bytes >= 0)
{
ec = boost::system::error_code();
bytes_transferred = bytes;
}
else
bytes_transferred = 0;
return true;
}
}
#endif // defined(BOOST_ASIO_HAS_IOCP)
} // namespace socket_ops
} // namespace detail
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_DETAIL_SOCKET_OPS_EXT_IPP
|
DGEBRD Example Program Results
Diagonal
3.6177 2.4161 -1.9213 -1.4265
Superdiagonal
1.2587 1.5262 -1.1895
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Abelian.Definition
open import Groups.Definition
open import Groups.Lemmas
open import Rings.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.EuclideanAlgorithm
open import Numbers.Primes.PrimeNumbers
module Rings.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} (R : Ring S _+_ _*_) where
abstract
open Setoid S
open Ring R
open Group additiveGroup
ringMinusExtracts : {x y : A} → (x * Group.inverse (Ring.additiveGroup R) y) ∼ (Group.inverse (Ring.additiveGroup R) (x * y))
ringMinusExtracts {x = x} {y} = transferToRight' additiveGroup (transitive (symmetric *DistributesOver+) (transitive (*WellDefined reflexive invLeft) (Ring.timesZero R)))
where
open Equivalence eq
ringMinusExtracts' : {x y : A} → ((inverse x) * y) ∼ inverse (x * y)
ringMinusExtracts' {x = x} {y} = transitive *Commutative (transitive ringMinusExtracts (inverseWellDefined additiveGroup *Commutative))
where
open Equivalence eq
twoNegativesTimes : {a b : A} → (inverse a) * (inverse b) ∼ a * b
twoNegativesTimes {a} {b} = transitive (ringMinusExtracts) (transitive (inverseWellDefined additiveGroup ringMinusExtracts') (invTwice additiveGroup (a * b)))
where
open Equivalence eq
groupLemmaMove0G : {a b : _} → {A : Set a} → {_·_ : A → A → A} → {S : Setoid {a} {b} A} → (G : Group S _·_) → {x : A} → (Setoid._∼_ S (Group.0G G) (Group.inverse G x)) → Setoid._∼_ S x (Group.0G G)
groupLemmaMove0G {S = S} G {x} pr = transitive (symmetric (invInv G)) (transitive (symmetric p) (invIdent G))
where
open Equivalence (Setoid.eq S)
p : Setoid._∼_ S (Group.inverse G (Group.0G G)) (Group.inverse G (Group.inverse G x))
p = inverseWellDefined G pr
groupLemmaMove0G' : {a b : _} → {A : Set a} → {_·_ : A → A → A} → {S : Setoid {a} {b} A} → (G : Group S _·_) → {x : A} → Setoid._∼_ S x (Group.0G G) → (Setoid._∼_ S (Group.0G G) (Group.inverse G x))
groupLemmaMove0G' {S = S} G {x} pr = transferToRight' G (Equivalence.transitive (Setoid.eq S) (Group.identLeft G) pr)
oneZeroImpliesAllZero : 0R ∼ 1R → {x : A} → x ∼ 0R
oneZeroImpliesAllZero 0=1 = Equivalence.transitive eq (Equivalence.symmetric eq identIsIdent) (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq 0=1) (Equivalence.reflexive eq)) (Equivalence.transitive eq *Commutative timesZero))
lemm3 : (a b : A) → 0G ∼ (a + b) → 0G ∼ a → 0G ∼ b
lemm3 a b pr1 pr2 with transferToRight' additiveGroup (Equivalence.symmetric eq pr1)
... | a=-b with Equivalence.transitive eq pr2 a=-b
... | 0=-b with inverseWellDefined additiveGroup 0=-b
... | -0=--b = Equivalence.transitive eq (Equivalence.symmetric eq (invIdent additiveGroup)) (Equivalence.transitive eq -0=--b (invTwice additiveGroup b))
charNot2ImpliesNontrivial : ((1R + 1R) ∼ 0R → False) → (0R ∼ 1R) → False
charNot2ImpliesNontrivial charNot2 0=1 = charNot2 (Equivalence.transitive eq (+WellDefined (Equivalence.symmetric eq 0=1) (Equivalence.symmetric eq 0=1)) identRight)
abelianUnderlyingGroup : AbelianGroup additiveGroup
abelianUnderlyingGroup = record { commutative = groupIsAbelian }
|
(*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*)
theory jiraver440
imports "../CTranslation"
begin
install_C_file "jiraver440.c"
context jiraver440
begin
thm f_body_def
thm g_body_def
lemma "f_body = g_body"
by (simp add: f_body_def g_body_def)
end
end
|
In these troubled times, dear reader, you have two options: you can turn away from the horrors of the world and embrace the fantasy that literature provides. Or, you can face the disasters head-on, with books that magnify the precipice of doom we stand on. Then again, you could also just enjoy your summer with a range of insightful and surprising new titles – all available through Overdrive! |
\documentclass{article}
\usepackage{comment}
\usepackage[final]{styles}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc} % use 8-bit T1 fonts
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref} % hyperlinks
\usepackage{url} % simple URL typesetting
\usepackage{booktabs} % professional-quality tables
\usepackage{amsfonts} % blackboard math symbols
\usepackage{nicefrac} % compact symbols for 1/2, etc.
\usepackage{microtype} % microtypography
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{csquotes}
\usepackage{float}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multicol}
\newcommand{\stoptocwriting}{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{-5}}}
\newcommand{\resumetocwriting}{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{\arabic{tocdepth}}}}
% \title{Harmonic Flows on Guage Equivariant Moduli Space of Connection }
% \title{Ergodic Flows on Guage Equivariant \\ Space of Connection }
% \title{Ergodic flow on Moduli\\ Space of Connections }
% \title{Attention and Energy Minimization \\ on Moduli Space of Connections }
\title{ Emergent Attention on
Yang-Mills \\Space of Connections}
% \title{Learning Energy Minimization on \\ Moduli Space of Connections }
% The \author macro works with any number of authors. There are two commands
% used to separate the names and addresses of multiple authors: \And and \AND.
%
% Using \And between authors leaves it to LaTeX to determine where to break the
% lines. Using \AND forces a line break at that point. So, if LaTeX puts 3 of 4
% authors names on the first line, and the last on the second line, try using
% \AND instead of \And before the third author name.
\author{%
L. J. Pereira \\
% \texttt{[email protected]} \\
% examples of more authors
% \And
% Coauthor \\
% Affiliation \\ consciousness
% Address \\
% \texttt{email} \\
% \AND
% Coauthor \\
% Affiliation \\
% Address \\
% \texttt{email} \\
% \And
% Coauthor \\
% Affiliation \\
% Address \\
% \texttt{email} \\
% \And
% Coauthor \\
% Affiliation \\
% Address \\
% \texttt{email} \\
}
\begin{document}
\setlength{\abovedisplayskip}{4pt}
\setlength{\belowdisplayskip}{4pt}
\vspace{-2cm}
\maketitle
% \vspace{-1.3cm}
% \stoptocwriting
% gauge Dynamics of moduli spaces
\renewcommand{\baselinestretch}{1.0}\normalsize
\section*{Abstract}
In this paper, a process similar to hierarchical agglomerative clustering and principal component analysis is described using the formal methods of differential geometry and gauge theory that are commonly used in physical theories of electromagnetism and the strong nuclear force.
It is proposed that information organization and clustering naturally emerges from an a priori gauge symmetry of the action on the space of connections together with the stationary-action principle. In a learning model, this is achieved through pretraining of diffeomorphic mappings of neural network activity onto Lie groups, i.e. manifolds of continuous symmetries, which are further projected onto a differentiable and conformally invariant 4-dimensional manifold of connections.
Constructing a Yang-Mills moduli space of connections allows us to cluster the vector activity of an ensemble of neural networks into islands of agreement forming a dynamic and unoriented part-whole hierarchy.
% It is claimed to be possible to avoid an a priori definition of a measure or metric on a specially organized latent space and moreover, that a lack of a well-defined metric can be used to prevent information redundancy using a conformal invariance property of the space. Instead,
We can think of the clustering process as an intrinsic geometric flow on the connection space, namely the Ricci Yang-Mills flow.
The wedge product of configurations of differential forms located at critical points of the Yang-Mills action functional are comparable to axes of a $p$-dimensional ellipsoid formed in principal component analysis. These volumetric structures similarly cluster and reduce information to its principal components based on covariance and can be used as a generalized attention mechanism when applied to an ensemble of learning models.
% The theoretical objects representing solutions of these flows are studied as quasiparticles and can be made physical in quantum materials or gasses. This geometric formulation of general intelligence is a naturally arising and biologically plausible model for quantum AI.
% Moreover, fusing physical field theories with neuroscience and ML may justify introspection into the Anthropic Principle and cosmological fine-tuning.
% \resumetocwriting
% \renewcommand{\baselinestretch}{0.65}\normalsize
\tableofcontents
% \renewcommand{\baselinestretch}{1.0}\normalsize
\newpage
\section{Overview}
These concepts will be described in later sections, this overview serves as a rough outline for those familiar with the relevant areas of mathematics and machine learning.
The moduli space of connections is constructed by quotienting the space of principal connections by a Lie structure group, generating a gauge equivariant parameter space.
In particular, the Yang-Mills moduli space, a subset of the total connection space made of flat and irreducible connections, can be constructed to be a smooth, compact, and oriented manifold in 4 dimensions with critical points known as Yang-Mills connections or instantons. These connections minimize curvature between fibers and, from an information geometric perspective, they minimize relative entropy or KL divergence between open sets of gauge equivariant manifolds.
This space can be used to cover the activity of a collection of neural networks, represented as trajectories on vector bundles.
% Dynamics of attention are computed by minimizing the energy functional of the connection space. Using instantons as sources of variational noise, we train an attention mechanism to minimize total energy of the moduli space. This process is comparable to finding stable solutions of an intrinsic flow on an undefined metric, namely a Ricci Yang-Mills flow with solutions akin to Ricci solitons that are real, non-volume preserving objects around invariant points. Stable solutions represent islands of agreement formed through consensus within a dynamic and unoriented part-whole hierarchy.
A top-down energy-based attention mechanism, referred to as the moduli attention, can be trained on this space using sampled activity of the trajectories of underlying networks through a composition of energies. Motivated by the stationary-action principle, dynamics of attention are computed by minimizing the action functional of the connection space. The Yang-Mills action functional serves as a cost function on which inference minimizes the total energy in search of a basis of instanton connections. The connections are described using proejctive measurement given by a weighted sum or integral over differential forms. In comparison to statistical learning, this real, non-volume preserving object in the 3-dimensional space can be compared to a p-dimensional ellipsoid as found in principal component analysis, with axes that are typically formed using eigenvectors of the covariance matrix of a dataset.
% Thus, the processes of this learning method are as follows:
% \begin{enumerate}
% \item Pretrain $model_1$ to learn diffeomorphic projective mappings of arbitrary neural network outputs onto open sets (i.e. sheaves) of continuous symmetry Lie group manifolds. This will later be used to sample activity of an ensemble of neural networks to project onto a Yang-Mills moduli space.
% \item Pretrain $model_2$ to construct diffeomorphic mappings of sheaves of Lie groups onto sheaves of a smooth and continuous 4 dimensional manifold of connections. This will form the Yang mills moduli space of connection on which the output of $model_1$ is projected onto and where attention emerges.
% \item Train an energy-based model, $model_3$ to find instanton connections with minimized curvature and maximized covariance by minimizing the Yang-Mills action functional given test data of various configurations of vector activity. This will later minimize vector activity projected by $model_2$.
% \item Periodically, $model_1$ projects the ensemble of neural networks onto the Yang-Mills moduli space constructed by $model_2$ as $model_3$ determines the optimal configuration of instanton connections to minimize total energy. The approximate variational inference of $model_3$ produces a generative effect on the underlying neural networks inputs being sampled.
% \end{enumerate}
% \section{Methods}
% \section{Experiments}
\section{Geometry of Latent Information}
\subsection{Manifolds, Vector Bundles, Connections}
A bundle serves as a useful mathematical object to analyse both the recursive construction of biological and artificial neurons and networks. It also provides descriptions of the geometry of latent information as manifolds that are used for information processing and statistical learning.
A fiber bundle formalizes the notion of one topological space (called a fiber) being parameterized by another topological space (called a base). The bundle is equipped with a group action on the fiber that represents different ways the fibers can be viewed as equivalent (Tao 2008). Bundles also have a property, known as local trivialization, allowing neighborhoods of the bundle to be computed as simple, oriented product spaces, despite the global space being unoriented or twisted.
A family of fibers associated to a base can be described by defining a template fiber from which all others are diffeomorphic to. This is formalized by defining a diffeomorphic mapping that takes positional data from the entirety of the space of fibers to a base, and implicitly from one fiber to another. When the template fiber is a vector space, we get a vector bundle.
%Similarly, a standard template connection between fibers, known as a principal Ehresmann connection, will also exist and can be understood as a covariant directional derivative on the tangent spaces of the manifolds.
A Lie group has a recursive property that results from the group being a differentiable manifold of a continuous symmetry. A useful phenomenon occurs when equipping a bundle with a Lie group action; the bundle structure can be used to represent both the original vector bundle as well as a higher-level collection of mappings between their tangent spaces, in what's known as a bundle of connections.
\subsection{A Priori Structure Groups}
% Hebbian learning is a form of activity-dependent synaptic plasticity where correlated activation of pre- and postsynaptic neurons leads to the strengthening of the connection between the two neurons. Another central theory of cognitive neuroscience is that different parts or modules of the brain perform different functions, known as functional localization.
% Recall, \textit{covariance} is a measure of the joint variability of two random variables and is increasingly positive when the variables tend to show similar behavior and grow increasingly negative when dissimilar. This conversion of physical synapses into a set of random variables can be described with Markov partitions and Bernoulli Schemes.
% At each step, the accuracy of the model naturally decrease as a result of merging imperfectly covariant random variables.
% However, some form of a priori covariance is necessary for maintaining information integrity through bilateral and hierarchical dynamics, i.e. to allow a connection to communicate in a general and equivariant way between modules and within their intrinsic substructures.
% \begin{wrapfigure}{r}{0.5\textwidth}
% \begin{center}
% \includegraphics[width=0.43\textwidth]{DTI-sagittal-fibers.jpg}
% % \caption{Fiber tracts that run through the mid-sagittal plane}
% \end{center}
% \end{wrapfigure}
A biological first principle of covariance arises naturally from analysis of neuronal activity, which favours functional localization and Hebbian learning.
Moreover, cognitive networks in the brain flow in connectome-specific diffusive waves along gyrification paths, which are theorized to be caused by differential tangential growth.
Recall, covariance is a measure of the joint variability of a pair random variables and is increasingly positive when the pair show similar behavior and is negative when dissimilar.
We can imagine a simple partition scheme by assigning a Bernoulli random variable to each synapse. Then, while ``zooming out" we merge random variables together based on their covariance and locality to build a course-grained model.
Moving from discrete random variables (i.e. synapses) to continuous fields and manifolds (i.e. EM fields), the covariant derivative between fibers of a bundle arises naturally as the principal Ehressmann connection.
A connection on a fiber bundle is a device that defines a notion of parallel transport on the bundle.
% Similar to the template fiber in a bundle, the principal Ehresmann always exists as the standard connection and can be understood as a covariant directional derivative on the tangent spaces of the manifolds.
It proves necessary to impose an a priori covariance principle to maintain integrity of information during parallel transportion in bilateral and hierarchical directions.
Yet for a standard learning model, covariance of functionality is an a posteriori feature because the joint variability is unknown until individual modules are trained.
Covariance of fibers can be achieved by imposing the structure group to be Lie groups, but can also be achieved by imposing restrictions on the projection map of Riemannian manifolds without explicitly defining the structure group beforehand (Gao 2021).
% \begin{figure}[h]
% \centering
% \includegraphics[width=5.5cm]{DTI-sagittal-fibers.jpg}
% % \caption{Fiber tracts that run through the mid-sagittal plane}
% \end{figure}
\vspace{-0.5cm}
\begin{figure}[h]
\centering
\includegraphics[width=7.5cm]{eeg-meg-neuron.png}
\\ Diffusive magnetic (left) and electric (right) current produced by neurons
\end{figure}
\subsection{Moduli Spaces and Instantons}
With covariance established on connections, it becomes possible to perform inference using higher levels of abstraction on gauge fields. This is done by constructing a gauge equivariant bundle of connections known as a moduli space of connections, which can be further reduced to a finite dimensional manifold known as a Yang-Mills moduli space. This reduced space has local and global minima being connections with minimized energy known as Yang-Mills connections or instantons which serve as a natural choice of connection on principal and vector bundles since they minimize their curvature. From an information geometric perspective, this can be thought of as minimizing relative entropy or KL divergence between sampled trajectories of gauge equivariant manifolds. The infinitesimal form of the the KL divergence is comparable to the Fisher information metric. The gauge field strength is the curvature $F_{A}$ of the connection $A$, and the energy of the gauge field is given by the Yang–Mills action functional $YM$. With the aim of having zero or vanishing curvature, we vary parameters in search of a connection with curvature as small as possible. The Yang–Mills action functional corresponds to the $L^{2}$-norm of the curvature, and its Euler–Lagrange equations describe the critical points of this functional, either the absolute local minima.
\begin{equation}
{\displaystyle \operatorname {YM} (A)=\int _{X}\|F_{A}\|^{2}\,d\mathrm {vol} _{g}.}
\end{equation}
\subsection{Instantons as Principal Components}
Principal Component Analysis (PCA) can serve as a motivating reference for the geometric methods proposed in this paper. PCA is commonly used to obtain lower-dimensional data while preserving as much of the data's variation as possible. The principal components of a collection of points in a real coordinate space are a sequence of $p$ unit vectors, where the $i$-th vector is the direction of a line that best fits the data while being orthogonal to the first $i-1$ vectors. It can be shown that the principal components are eigenvectors of the data's covariance matrix. PCA can be thought of as fitting a $p$-dimensional ellipsoid to the data, where each axis of the ellipsoid represents a principal component. If some axis of the ellipsoid is small, then the variance along that axis is also small. Similarly, a connection corresponds to the covariant directional derivitive and is considered a self-dual connection or an instanton if the curvature $2$-form is an eigenvector of the Hodge operator with eigenvalue $\pm 1$.
\subsection{Instantons as Islands in Part-Whole Hierarchies}
The GLOM model (Hinton 2021) represents part-whole hierarchies using clusters of matching vectors, known as islands of agreement, as nodes in parse tree representations within a neural network. A part-whole hierachy system consists of components that can themselves be further broken down into subcomponents. The model learns analogical reasoning by encoding parts that are not well defined or obscured. An emphasis is given on viewpoint and coordinate invariance, which allows for exchangeability within the network and is used to adapt to and generate novelty in a manner similar to creativity in humans. Comparisons can be drawn between the GLOM model and moduli attention, with vector encodings corresponding to dynamic trajectories on vector bundles, frame invariance corresponding to the gauge equivariant connection space, and islands of agreement corresponding to stable instanton solutions. Iterative consensus often does not converge in meaningful ways due to the difficulty of encoding prior understandings of desirable representations to be generated through agglomerative clustering. Using a geometric model we find that we are better able to converge to coherent clusters because of the use of an a priori structure group that imposes meaningful symmetry on the clusters and optimizes organization of information throughout the space.
\section{Dynamics of Latent Information}
\subsection{Intrinsic Geometric Flows}
\begin{wrapfigure}{r}{0.4\textwidth}
\vspace{0.3cm}
\centering
\includegraphics[scale=0.3]{ricci-flow.png}
% \caption{Ricci flow visualization (Rubinstein, 2005)}
\\ Ricci flow of a metric manifold (Rubinstein, 2005)
\end{wrapfigure}
We can interpret energy minimization as a geometric flow, either on the parameter space as an extrinsic flow through variational gradient descent, or on the moduli space as an intrinsic flow. A Ricci flow is an example of an intrinsic flow on the metric by which one can take an arbitrary manifold and smooth out the geometry to make it more symmetric, whereas a mean curvature flow (as found in soap films, with critical points as minimal surfaces) is an example of an extrinsic flow on an embedded manifold. The moduli attention mechanism can be understood as a mix of the two categories; manipulating both the embedded manifolds constructed from hierarchical neural networks and the moduli space of connections (or metric) itself. We can further classify it as both a variational and a curvature flow since it evolves to minimize the Yang-mills action functional which is the $L^2$ norm of curvatures.
% The Ricci flow, Calabi flow, and Yamabe flow all arise in similar ways.
Curvature flows may not necessarily preserve volume (the Calabi flow does, while the Ricci flow does not), meaning the flow may simply shrink or grow the manifold, rather than regularizing the metric. Instead of normalizing the flow by fixing the volume, we allow dissipative solutions to exist, forming a memory and compression mechanism.
\subsection{Ricci Yang-Mills Flow}
A Ricci flow is a differential equation on the space of Riemannian metrics on $M, \mathfrak{Met}$. We can picture the Ricci flow as moving a manifold around by internal symmetries (the family of diffeomorphisms) and a uniform-in-space scaling at each time. If one works in the moduli space of $\mathfrak{Met}/ \mathfrak{Diff}$, where $\mathfrak{Diff}$ is the group of diffeomorphisms on $M$, then one allows for a family of fixed points that are metrics that flow by scaling and diffeomorphism. i.e. $g(t) = \sigma (t) \phi (t) ^* g_0$,
where $\phi(t) :M \rightarrow M$ is a one parameter family of diffeomorphisms.
These are the Ricci soliton metrics.
In the standard quantum field theoretic interpretation of the Ricci flow in terms of the renormalization group, the parameter $t$ corresponds to length or energy rather than time.
One can show that Ricci soliton metrics satisfy the following equation: $Rc+\mathcal{L}_X g+
\frac{\epsilon}{2} g = 0$, where $X$ is the vector field generating the diffeomorphisms, and $\epsilon = -1,0,1$ corresponds to shrinking, steady, and expanding solitons respectively. If $X$ is the gradient of some function, i.e. $X=\triangledown f$, then a solution is said to be a gradient Ricci soliton.
Similarly, the Ricci Yang-Mills flow is a natural coupling of the Ricci flow and the Yang-Mills heat flow. It was discovered that the Ricci Yang-Mills flow is an ideal candidate for studying magnetic flows. Given a choice $h$ of metric on the Lie algebra $g$ of $G$, a one-parameter family of metrics $g_t$ on $\Sigma$ and principal connections $\mu_t$ satisfies the RYM flow if,
\begin{equation}
\frac{\partial}{\partial t} g = -2 Rc \ g + F^2_\mu, \ \ \ \ \ \ \ \ \ \ \ \ \
\frac{\partial}{\partial t}\mu = -d^*_gF_\mu .
\end{equation}
\subsection{Instantons as Invariant Points}
The stationary-action principle is a variational principle that, when applied to the action of a mechanical system, yields the equations of motion for that system. The principle states that the trajectories (i.e. the solutions of the equations of motion) are stationary points of the system's action functional.
Ricci solitons and Ricci Yang-Mills solitons can be naturally associated to invariant or stationary points in metric spaces using Geometric Invariant Theory (Jablonski 2013).
% The Ricci Yang-Mills flow is invariant under automorphisms of the principal bundle. The Ricci Yang-Mills flow preserves the set of left-invariant metrics on a Lie group.
% It can be shown that there exists many families of Lie groups that do not admit invariant Ricci soliton metrics but admit Ricci Yang-Mills solitons, making them more reliable (though weaker) candidates for invariant points.
Similarly, the Banach fixed-point theorem guarantees existence of a fixed point in certain metric spaces given a contractive mapping, and can be interpreted as solition solutions of a Ricci de Turck flow. A comparison can be made with the Invariant Point Attention (IPA) mechanism introduced in Alphafold 2 (Jumper 2021). The invariant point attention augments each of the standard attention queries, keys, and values with 3-D points produced in the local frame of each protein residue gas such that the final value is invariant to global rotations and translations.
After each attention operation and element-wise transition block, the module computes an update to the rotation and translation of each backbone frame.
The application of these updates within the local frame of each residue makes the overall attention and update block an equivariant operation on the residue gas.
% The Banach fixed-point theorem (also known as the contraction mapping theorem or contractive mapping theorem) is an important tool in the theory of metric spaces; it guarantees the existence and uniqueness of fixed points of certain self-maps of metric spaces, and provides a constructive method to find those fixed points.
% The 3-D queries and keys also impose a strong spatial/locality bias on the attention which is well-suited to iterative refinement of the protein structure.
\begin{comment}
\subsection{Variational Methods in Energy-Based Models}
\begin{figure}[H]
\centering
\includegraphics[width=13cm]{openai-ebm.png}
\vspace{-0.87cm}
\\ (Yilun, 2019)
% \caption{Fiber tracts that run through the mid-sagittal plane}
\end{figure}
As underlying neural networks perform inference, their latent trajectories pass through layers of a neural network in a bottom-up manner. At the same time, a top-down variational noise is produced around the instanton solutions that best minimize energy of the total activity on the moduli space of connections. Using an energy-based model (EBM) we sample the joint distribution as a sum of each latent trajectory, corresponding to a product of experts model. This forms an attention mechanism, which we refer to as the moduli attention, and is learned on the top-down manifold while having a generative effect on underlying networks through approximate inference. This has recently been implemented using Stein Variational Gradient Descent algorithm (Jaini 2021).
Recall, variational methods pick a family of distributions over the latent variables with their own variational parameters, $q(z_{1:m} | v)$, then attempt to find settings of the parameters that makes $q$ close to the posterior of interest. Closeness of the two distributions is measured with the KL divergence,
% $\displaystyle KL(q||p)= E_q\bigg[ \log \frac{ q(z)}{p(z | x)} \bigg].$
\begin{equation}
\displaystyle KL(q||p)= E_q\bigg[ \log \frac{ q(z)}{p(z | x)} \bigg].
\end{equation}
An energy function $E$ in an EBM can be thought of as an unnormalized negative log probability (LeCun 2020).
To convert an energy function to its equivalent probabilistic representation after normalization,
% Recall, marginalisation is a method that sums over the possible values of one variable to determine the marginal contribution of another.
$P(y \mid x)$, we apply the Gibbs-Boltzmann formula with latent variables $z$ being marginalized implicitly through integration, i.e. $P(y \mid x) = \int_z P(y,z | x)$. Then,
\begin{align*}
P(y \mid x) &= \frac{ \int_z \exp(-\beta E(x,y,z)) }{ \int_y \int_z \exp(-\beta E(x, y, z))}
\end{align*}
The derivation introduces a $\beta$ term which is the inverse of temperature $T$, so as $\beta \rightarrow \infty$ the temperature goes to zero, and we see that $\check{y} = \text{argmin}_{y} E(x,y)$. We can redefine our energy function as an equivalent function with free energy $F_\beta$,
\begin{align*}
F_{\infty} (x,y) &= \text{argmin}_z E(x,y,z)\\
F_{\beta} (x,y) &= -\frac{1}{\beta} \log \int_z \exp(-\beta E(x,y,z)).
\end{align*}
If we have a latent variable model and want to eliminate the latent variable $z$ in a probabilistically correct way, we just need to redefine the energy function in terms of $F_\beta$,
\begin{equation}
P(y \mid x) = \frac{ \exp(-\beta F_\beta(x,y,z)) }{ \int_y \exp(-\beta F_\beta(x, y, z))}.
\end{equation}
With variational methods, instead of only minimizing the energy function with respect to $z$ we must prevent the energy function from being 0 everywhere by constraining the flexibility of the latent variable $z$. The energy function is defined as sampling $z$ randomly according to a distribution whose logarithm is the cost that links it to $z$. This distribution is commonly chosen to be a Gaussian with mean $\bar z$ which results in Gaussian noise being added to $\bar z$. The reparameterization trick is often used to allow for backpropagation during training despite the random sampling.
\end{comment}
% \newpage
\subsection{Instantons and Self-Organized Criticality}
Neuronal avalanches are scale-invariant neuronal population activity patterns in the cortex that are proposed to be a mechanism of cortical information processing and storage. Theory and experiments suggest neuronal avalanches allow for the formation of local and system-wide spanning neuronal groups. The condensation of instantons can describe the noise-induced chaotic phase of SOC, which maximizes connection distance while minimizing energy. A generic SOC system can be formulated as a Witten-type topological field theory (W-TFT) with spontaneously broken Becchi-Rouet-Stora-Tyutin (BRST) symmetry. There must exist regions where the BRST-symmetry is spontaneously broken by instantons, which in the context of SOC are avalanches (Ovchinnikov 2011). Stochastic neural networks have demonstrated how spontaneously broken BRST symmetry can describe SOC (Jian 2021).
% \vspace{-0.3cm}
% \section{Intrinsic and Extrinsic Variational Flows}
% $ \ \ \displaystyle KL(q||p)= E_q\bigg[ \log \frac{ q(z)}{p(z | x)} \bigg].
% $
\subsection{Instantons and Boundaries}
\begin{wrapfigure}{r}{0.4\textwidth}
\vspace{-1.2cm}
\centering
\includegraphics[scale=0.2]{Donaldson's_Theorem_cobordism.png}
% \caption{Ricci flow visualization (Rubinstein, 2005)}
\\ Cobordism given by Yang–Mills moduli space in Donaldson's theorem
\end{wrapfigure}
% \begin{figure}[h]
% \centering
% \includegraphics[width=6cm]{Donaldson's_Theorem_cobordism.png}
% \\ Cobordism given by Yang–Mills moduli space in Donaldson's theorem
% \end{figure}
Moduli of Yang–Mills connections have been most studied when the dimension of the base manifold $X$ is four. Here the Yang–Mills equations admit a simplification from a second-order PDE to a first-order PDE, the anti-self-duality equations.
Donaldson's Theorem shows that it is possible to compactify the moduli space by cutting off cones at a reducible singularities and gluing in a copy of ${\displaystyle \mathbb {CP} ^{2}}$. Secondly, glue in a copy of $X$ itself at infinity. The resulting space is a cobordism between $X$ and a disjoint union of ${\displaystyle b_{2}(X)}$ copies of ${\displaystyle \mathbb {CP} ^{2}}$ with its orientation reversed, where $b_{2}(X)$ is the the $2$nd Betti number.
\clearpage
An instanton can be used to calculate the transition probability for a quantum mechanical particle tunneling through a potential barrier. One example of a system with an instanton effect is a particle in a double-well potential. In contrast to a classical particle, there is non-vanishing probability that it crosses a region of potential energy higher than its own energy.
\subsection{Instantons as Quasiparticles}
% \begin{comment}
% quasiparticles and collective excitations
% - Instantons and solitons
% - Ricci solitons
% https://math.stackexchange.com/questions/802933/ricci-soliton-geometric-meaning
% - RICCI YANG-MILLS SOLITONS
% https://arxiv.org/pdf/0907.1095.pdf
% https://arxiv.org/pdf/2102.09538.pdf
% \end{comment}
% The objects representing solutions of variational flows can be studied as quasiparticles and have been made physical in quantum materials or gasses. This geometric formulation of general intelligence is a naturally arising and biologically plausible model for quantum AI. Aside from providing a computational scheme, it's worth acknowledging the philosophical implications of associating physical unified field theories with neuroscience and machine learning theory. Namely, that it may justify further introspection into the Anthropic Principle and cosmological fine-tuning.
Quasiparticles or collective excitations are emergent phenomena that encapsulate macroscopic portions of a complicated microscopic system such that the behaviour of these encapsulated parts imitate behaviours of weakly interacting particles in a vacuum.
A soliton is a localized, non-dispersive solution of a nonlinear theory in Euclidean space and is a real object. Conversely, instantons are not real and only exist as solutions to the equations of motion of a quantum field theory after a Wick rotation, in which time is made imaginary. Thus, instantons are not observable, but are used to calculate and explain quantum mechanical effects that can be observed, such as tunneling. In quantum chromodynamics (QCD) instantons tunnel between the topologically different color vacua.
\textit{Work in Progress}
\section*{References}
\small
[1] Gao, Tingran. "The diffusion geometry of fibre bundles: Horizontal diffusion maps." Applied and Computational Harmonic Analysis 50 (2021): 147-215.
% https://arxiv.org/pdf/1602.02330.pdf
[2] Eckhard Meinrenken, "Principal bundles and connections", Lecture Notes.
% http://www.math.toronto.edu/mein/teaching/moduli.pdf
[3] Tao, T. "What is a gauge?" (2008) https://terrytao.wordpress.com/2008/09/27/what-is-a-gauge/
% https://terrytao.wordpress.com/2008/09/27/what-is-a-gauge/
[4] Du, Yilun, and Igor Mordatch. "Implicit generation and generalization in energy-based models." arXiv preprint arXiv:1903.08689 (2019).
% https://arxiv.org/abs/1903.08689
[5] Hinton, Geoffrey. "How to represent part-whole hierarchies in a neural network." arXiv preprint arXiv:2102.12627 (2021).
[6] Hinton, Geoffrey E. "Mapping part-whole hierarchies into connectionist networks." Artificial Intelligence 46.1-2 (1990): 47-75.
[7] Yann LeCun and Alfredo Canziani. "DEEP LEARNING". DS-GA 1008, SPRING 2020. NYU CENTER FOR DATA SCIENCE
[8] J. Hyam Rubinstein and Robert Sinclair. "Visualizing Ricci Flow of Manifolds of Revolution", Experimental Mathematics v. 14 n. 3, pp. 257–384
[9] Jaini, Priyank, Lars Holdijk, and Max Welling. "Learning Equivariant Energy Based Models with Equivariant Stein Variational Gradient Descent." arXiv preprint arXiv:2106.07832 (2021).
[10] I.V. Ovchinnikov. Self-organized criticality as Witten-type topological field theory with spontaneously
broken Becchi-Rouet-Stora-Tyutin symmetry. Physical Review E, 83,051129 (2011).
[11] Zhai, Jian, Chaojun Yu, and You Zhai. "Witten-type topological field theory of self-organized criticality for stochastic neural networks." arXiv preprint arXiv:2106.10851 (2021).
[12] Michael Jablonski and Andrea Young,Ricci Yang-Mills solitons on nilpotent Lie groups, J. Lie Theory23 (2013), no. 1, 177–202. MR 3060772
[13] Jumper, J., Evans, R., Pritzel, A. et al. Highly accurate protein structure prediction with AlphaFold. Nature (2021). https://doi.org/10.1038/s41586-021-03819-2
% [4] Wetzel, Sebastian J., and Manuel Scherzer. "Machine learning of explicit order parameters: From the Ising model to SU(2) lattice gauge theory." Physical Review B 96.18 (2017): 184410.
% https://arxiv.org/pdf/1705.05582.pdf
% [6] Blei, David M., Alp Kucukelbir, and Jon D. McAuliffe. "Variational inference: A review for statisticians." Journal of the American statistical Association 112.518 (2017): 859-877.
% [3] Paul, Arnab, and Suresh Venkatasubramanian. "Why does deep learning work?-a perspective from group theory." arXiv preprint arXiv:1412.6621 (2014).
% https://arxiv.org/pdf/1412.6621.pdf
% [10] Russo, Abigail A., et al. "Neural trajectories in the supplementary motor area and motor cortex exhibit distinct geometries, compatible with different classes of computation." Neuron 107.4 (2020): 745-758.
% [11] Farolfi, A., et al. "Observation of magnetic solitons in two-component Bose-Einstein condensates." Physical Review Letters 125.3 (2020): 030401.
% [12] Denschlag, J., et al. "Generating solitons by phase engineering of a Bose-Einstein condensate." Science 287.5450 (2000): 97-101.
% https://ncatlab.org/nlab/show/principal+bundle
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\end{document}
|
Suppose $f_n$ is a sequence of complex-valued functions defined on an open set $S$, and $f_n'$ is the derivative of $f_n$. Suppose that for each $n$, $f_n'$ is continuous on $S$. Suppose that for each $x \in S$, there exists a sequence $h_n$ of nonnegative real numbers such that $h_n$ converges to $0$ and $|f_n(y)| \leq h_n$ for all $y$ in some neighborhood of $x$. Then the series $\sum_{n=0}^\infty f_n(x)$ converges for all $x \in S$, and the derivative of the sum is $\sum_{n=0}^\infty f_n'(x)$. |
module Idris.REPL.FuzzySearch
import Core.AutoSearch
import Core.CaseTree
import Core.CompileExpr
import Core.Context
import Core.Context.Log
import Core.Env
import Core.InitPrimitives
import Core.LinearCheck
import Core.Metadata
import Core.Normalise
import Core.Options
import Core.Termination
import Core.TT
import Core.Unify
import Idris.Desugar
import Idris.Doc.String
import Idris.Error
import Idris.IDEMode.CaseSplit
import Idris.IDEMode.Commands
import Idris.IDEMode.MakeClause
import Idris.IDEMode.Holes
import Idris.ModTree
import Idris.Parser
import Idris.Pretty
import Idris.ProcessIdr
import Idris.Resugar
import Idris.Syntax
import Idris.Version
import public Idris.REPL.Common
import Data.List
import Data.List1
import Data.Maybe
import Libraries.Data.ANameMap
import Libraries.Data.NameMap
import Libraries.Data.PosMap
import Data.Stream
import Data.String
import Data.DPair
import Libraries.Data.String.Extra
import Libraries.Data.List.Extra
import Libraries.Text.PrettyPrint.Prettyprinter
import Libraries.Text.PrettyPrint.Prettyprinter.Util
import Libraries.Text.PrettyPrint.Prettyprinter.Render.Terminal
import Libraries.Utils.Path
import Libraries.System.Directory.Tree
import System
import System.File
import System.Directory
%default covering
export
fuzzySearch : {auto c : Ref Ctxt Defs}
-> {auto u : Ref UST UState}
-> {auto s : Ref Syn SyntaxInfo}
-> {auto m : Ref MD Metadata}
-> {auto o : Ref ROpts REPLOpts}
-> PTerm
-> Core REPLResult
fuzzySearch expr = do
let Just (neg, pos) = parseExpr expr
| _ => pure (REPLError (pretty "Bad expression, expected"
<++> code (pretty "B")
<++> pretty "or"
<++> code (pretty "_ -> B")
<++> pretty "or"
<++> code (pretty "A -> B")
<+> pretty ", where"
<++> code (pretty "A")
<++> pretty "and"
<++> code (pretty "B")
<++> pretty "are spines of global names"))
defs <- branch
let curr = currentNS defs
let ctxt = gamma defs
filteredDefs <-
do names <- allNames ctxt
defs <- traverse (flip lookupCtxtExact ctxt) names
let defs = flip mapMaybe defs $ \ md =>
do d <- md
guard (visibleIn curr (fullname d) (visibility d))
guard (isJust $ userNameRoot (fullname d))
pure d
allDefs <- traverse (resolved ctxt) defs
filterM (\def => fuzzyMatch neg pos def.type) allDefs
put Ctxt defs
doc <- traverse (docsOrSignature EmptyFC) $ fullname <$> filteredDefs
pure $ PrintedDoc $ vsep doc
where
data NameOrConst = AName Name
| AInt
| AInteger
| ABits8
| ABits16
| ABits32
| ABits64
| AString
| AChar
| ADouble
| AWorld
| AType
eqConst : (x, y : NameOrConst) -> Bool
eqConst AInt AInt = True
eqConst AInteger AInteger = True
eqConst ABits8 ABits8 = True
eqConst ABits16 ABits16 = True
eqConst ABits32 ABits32 = True
eqConst ABits64 ABits64 = True
eqConst AString AString = True
eqConst AChar AChar = True
eqConst ADouble ADouble = True
eqConst AWorld AWorld = True
eqConst AType AType = True
eqConst _ _ = False
parseNameOrConst : PTerm -> Maybe NameOrConst
parseNameOrConst (PRef _ n) = Just (AName n)
parseNameOrConst (PPrimVal _ IntType) = Just AInt
parseNameOrConst (PPrimVal _ IntegerType) = Just AInteger
parseNameOrConst (PPrimVal _ Bits8Type) = Just ABits8
parseNameOrConst (PPrimVal _ Bits16Type) = Just ABits16
parseNameOrConst (PPrimVal _ Bits32Type) = Just ABits32
parseNameOrConst (PPrimVal _ Bits64Type) = Just ABits64
parseNameOrConst (PPrimVal _ StringType) = Just AString
parseNameOrConst (PPrimVal _ CharType) = Just AChar
parseNameOrConst (PPrimVal _ DoubleType) = Just ADouble
parseNameOrConst (PPrimVal _ WorldType) = Just AWorld
parseNameOrConst (PType _) = Just AType
parseNameOrConst _ = Nothing
parseExpr' : PTerm -> Maybe (List NameOrConst)
parseExpr' (PApp _ f x) =
[| parseNameOrConst x :: parseExpr' f |]
parseExpr' x = (:: []) <$> parseNameOrConst x
parseExpr : PTerm -> Maybe (List NameOrConst, List NameOrConst)
parseExpr (PPi _ _ _ _ a (PImplicit _)) = do
a' <- parseExpr' a
pure (a', [])
parseExpr (PPi _ _ _ _ a b) = do
a' <- parseExpr' a
b' <- parseExpr' b
pure (a', b')
parseExpr b = do
b' <- parseExpr' b
pure ([], b')
isApproximationOf : (given : Name)
-> (candidate : Name)
-> Bool
isApproximationOf (NS ns n) (NS ns' n') =
n == n' && Namespace.isApproximationOf ns ns'
isApproximationOf (UN n) (NS ns' (UN n')) =
n == n'
isApproximationOf (NS ns n) _ =
False
isApproximationOf (UN n) (UN n') =
n == n'
isApproximationOf _ _ =
False
isApproximationOf' : (given : NameOrConst)
-> (candidate : NameOrConst)
-> Bool
isApproximationOf' (AName x) (AName y) =
isApproximationOf x y
isApproximationOf' a b = eqConst a b
||| Find all name and type literal occurrences.
export
doFind : List NameOrConst -> Term vars -> List NameOrConst
doFind ns (Local fc x idx y) = ns
doFind ns (Ref fc x name) = AName name :: ns
doFind ns (Meta fc n i xs)
= foldl doFind ns xs
doFind ns (Bind fc x (Let _ c val ty) scope)
= doFind (doFind (doFind ns val) ty) scope
doFind ns (Bind fc x b scope)
= doFind (doFind ns (binderType b)) scope
doFind ns (App fc fn arg)
= doFind (doFind ns fn) arg
doFind ns (As fc s as tm) = doFind ns tm
doFind ns (TDelayed fc x y) = doFind ns y
doFind ns (TDelay fc x t y)
= doFind (doFind ns t) y
doFind ns (TForce fc r x) = doFind ns x
doFind ns (PrimVal fc c) =
fromMaybe [] ((:: []) <$> parseNameOrConst (PPrimVal fc c)) ++ ns
doFind ns (Erased fc i) = ns
doFind ns (TType fc) = AType :: ns
toFullNames' : NameOrConst -> Core NameOrConst
toFullNames' (AName x) = AName <$> toFullNames x
toFullNames' x = pure x
fuzzyMatch : (neg : List NameOrConst)
-> (pos : List NameOrConst)
-> Term vars
-> Core Bool
fuzzyMatch neg pos (Bind _ _ b sc) = do
let refsB = doFind [] (binderType b)
refsB <- traverse toFullNames' refsB
let neg' = diffBy isApproximationOf' neg refsB
fuzzyMatch neg' pos sc
fuzzyMatch (_ :: _) pos tm = pure False
fuzzyMatch [] pos tm = do
let refsB = doFind [] tm
refsB <- traverse toFullNames' refsB
pure (isNil $ diffBy isApproximationOf' pos refsB)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.