text
stringlengths 0
3.34M
|
---|
module Test.Suite
import IdrTest.Test
import Test.Extra.ListTest
import Test.Extra.StringTest
suite : IO ()
suite = do
runSuites
[ Test.Extra.ListTest.suite
, Test.Extra.StringTest.suite
]
|
using MLStyle
Feature.@activate TypeLevel
@data 𝑀{𝑻} begin
ϵ{𝑻}
𝑪{𝑻}(𝒕 :: 𝑻)
end
@def (▷) begin
( ::ϵ{𝑻}, :: (𝑻 ⇒ 𝑀{𝑹})) => ϵ{𝑹}()
(𝑪(𝒕::𝑻), 𝝀 :: (𝑻 ⇒ 𝑀{𝑹})) => 𝜆{𝑅}(𝒕)
end
|
Alan Hornstein, owner and president of Lenox Metals, LLC, has more than 35 years of experience in the metals recycling industry. His experience and expertise in the field is one reason he was honored by the U.S. Small Business Administration as 2008 Small Business Exporter of the Year for the City and County of Honolulu.
Hornstein trained from the ground up at his family's recycling business in Connecticut, learning metal identification, packaging, buying, and marketing domestically and internationally, before joining GTE Corporation. There he was part of a task force responsible in identifying potential metals for recycling, and trained and graduated from GTE's Materials Management Associate Development Program.
He eventually transferred to GTE HawaiianTel, where, as Supply Management Manager, he developed and operated a metals recycling program that generated sales exceeding $2 million in one year. Later, he managed the telephone company's Supply Transportation Group; metals recycling, and waste management programs as well as its resale/reuse equipment program. He was selected to operate a start-up venture, buying and selling scrap metal as an adjunct business for HawaiianTel.
In 1988, he opened Lenox Metals to offer a range of cost-effective recycling services to the military and utility and construction companies in Hawaii and the Pacific Rim.
Hornstein is a member of Better Business Bureau-Hawaii, Business Industry Association, Steel Framing Alliance of Hawaii, Associated Builders and Contractors, and the National Association of Recyclers Institute. He donates a portion of his time to raise money for organizations such as Easter Seals and Autism Society of Hawaii.
Hornstein is a proud father of his son, David. He is a member of Temple Emanu-El. He is an avid golfer, enjoys kayaking and staying physically fit. |
lemma lift_trans_bigtheta': assumes "f \<in> L F (\<lambda>x. t x (g x))" assumes "g \<in> \<Theta>[F](h)" assumes "\<And>g h. g \<in> \<Theta>[F](h) \<Longrightarrow> (\<lambda>x. t x (g x)) \<in> \<Theta>[F](\<lambda>x. t x (h x))" shows "f \<in> L F (\<lambda>x. t x (h x))" |
[STATEMENT]
lemma wp_empty [simp]: "wp act {} = - (Domain act)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. wp act {} = - Domain act
[PROOF STEP]
by (force simp add: wp_def) |
Mesoamerican Voices and The United Families of Chiapas Seeking our Migrants Committee are helping families cope with the devastating disappearance of loved ones who have migrated or attempted to migrate. The project works in three fundamental axes: psycho-spiritual, political and legal.
Mayan temazcal (sweat lodge) ceremonies offer healing to strengthen the spirit, mind and heart of individuals, families and their communities in search of justice. This and other healing ceremonies can be both a balm for the pain of not finding a relative and a way to access spiritual strength.
The project also includes a community forum to publicize the work carried out by the Committee in the search for missing persons based on five fundamental rights in the face of disappearance: justice, truth, reparation, non-repetition and collective memory.
Spaces are provided for more than 50 Mayan families to gather and share their feelings and ways of coping, and to find mutual support that emerges from their worldview, including care of the spirit and heart.
Thanks to this project, families can strengthen their knowledge and skills to access justice, as well as equip themselves with psycho-emotional tools that allow them to manage the pain, fear, and illnesses they suffer in the quest to find missing relatives. They can also find the collective motivation to demand the right to truth and justice. |
From r-base:3.5.1
RUN R -e "install.packages('caret',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('ggfortify',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('ggplot2',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('dplyr',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('RSQLite',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('DBI',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('class',dependencies=TRUE,repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('randomForest',dependencies=TRUE,repos='http://cran.rstudio.com/')"
WORKDIR /group6/models/
# RUN Rscript final_model_output_script.R
CMD ["Rscript","final_model_output_script.R"] |
module Class.Map where
open import Class.Equality
open import Data.Maybe using (Maybe; just; nothing)
open import Data.List using (List; []; _∷_; [_])
record MapClass (K : Set) {{_ : EqB K}} (M : Set -> Set) : Set₁ where
field
insert : ∀ {V} -> K -> V -> M V -> M V
remove : ∀ {V} -> K -> M V -> M V
lookup : ∀ {V} -> K -> M V -> Maybe V
mapSnd : ∀ {V C} -> (V -> C) -> M V -> M C
emptyMap : ∀ {V} -> M V
open MapClass {{...}} public
mapFromList : ∀ {K V M} {{_ : EqB K}} {{_ : MapClass K M}} -> (V -> K) -> List V -> M (List V)
mapFromList f [] = emptyMap
mapFromList f (x ∷ l) with mapFromList f l
... | m with lookup (f x) m
... | just x₁ = insert (f x) (x ∷ x₁) m
... | nothing = insert (f x) [ x ] m
|
(* Default settings (from HsToCoq.Coq.Preamble) *)
Generalizable All Variables.
Unset Implicit Arguments.
Set Maximal Implicit Insertion.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Require Coq.Program.Tactics.
Require Coq.Program.Wf.
(* Preamble *)
(* Converted imports: *)
Require GHC.Base.
Require GHC.Prim.
Import GHC.Base.Notations.
(* Converted type declarations: *)
Record Category__Dict {k : Type} (cat : k -> k -> Type) :=
Category__Dict_Build {
id__ : forall {a : k}, cat a a ;
op_z2218U____ : forall {b : k},
forall {c : k}, forall {a : k}, cat b c -> cat a b -> cat a c }.
Definition Category {k : Type} (cat : k -> k -> Type) :=
forall r__, (Category__Dict cat -> r__) -> r__.
Existing Class Category.
Definition id `{g__0__ : Category k cat} : forall {a : k}, cat a a :=
g__0__ _ (id__ cat).
Definition op_z2218U__ `{g__0__ : Category k cat}
: forall {b : k},
forall {c : k}, forall {a : k}, cat b c -> cat a b -> cat a c :=
g__0__ _ (op_z2218U____ cat).
Notation "'_∘_'" := (op_z2218U__).
Infix "∘" := (_∘_) (left associativity, at level 40).
(* Converted value declarations: *)
Local Definition Category__arrow_id : forall {a : Type}, GHC.Prim.arrow a a :=
fun {a : Type} => GHC.Base.id.
Local Definition Category__arrow_op_z2218U__
: forall {b : Type},
forall {c : Type},
forall {a : Type},
GHC.Prim.arrow b c -> GHC.Prim.arrow a b -> GHC.Prim.arrow a c :=
fun {b : Type} {c : Type} {a : Type} => _GHC.Base.∘_.
Program Instance Category__arrow : Category GHC.Prim.arrow :=
fun _ k__ =>
k__ {| id__ := fun {a : Type} => Category__arrow_id ;
op_z2218U____ := fun {b : Type} {c : Type} {a : Type} =>
Category__arrow_op_z2218U__ |}.
(* Skipping instance `Control.Category.Category__op_ZCz7eUZC__' of class
`Control.Category.Category' *)
(* Skipping instance `Control.Category.Category__op_ZCz7eUz7eUZC__' of class
`Control.Category.Category' *)
(* Skipping instance `Control.Category.Category__Coercion' of class
`Control.Category.Category' *)
Definition op_zlzlzl__ {k : Type} {cat : k -> k -> Type} {b : k} {c : k} {a : k}
`{Category k cat}
: cat b c -> cat a b -> cat a c :=
_∘_.
Notation "'_<<<_'" := (op_zlzlzl__).
Infix "<<<" := (_<<<_) (at level 99).
Definition op_zgzgzg__ {k : Type} {cat : k -> k -> Type} {a : k} {b : k} {c : k}
`{Category k cat}
: cat a b -> cat b c -> cat a c :=
fun f g => g ∘ f.
Notation "'_>>>_'" := (op_zgzgzg__).
Infix ">>>" := (_>>>_) (at level 99).
Module Notations.
Notation "'_Control.Category.∘_'" := (op_z2218U__).
Infix "Control.Category.∘" := (_∘_) (left associativity, at level 40).
Notation "'_Control.Category.<<<_'" := (op_zlzlzl__).
Infix "Control.Category.<<<" := (_<<<_) (at level 99).
Notation "'_Control.Category.>>>_'" := (op_zgzgzg__).
Infix "Control.Category.>>>" := (_>>>_) (at level 99).
End Notations.
(* External variables:
Type GHC.Base.id GHC.Base.op_z2218U__ GHC.Prim.arrow
*)
|
applyDCMetadataTemplate {
msiApplyDCMetadataTemplate(*obj, *status);
writePosInt("stdout",*status);
writeLine("stdout","");
}
INPUT *obj="/pho27/home/rods/LICENSE.txt"
OUTPUT ruleExecOut |
open function
#print surjective
universes u v w
variables {α : Type u} {β : Type v} {γ : Type w}
open function
lemma surjective_comp {g : β → γ} {f : α → β}
(hg : surjective g) (hf : surjective f) :
surjective (g ∘ f) := (
assume c: γ,
let ⟨b, (hgb: g b = c)⟩ := hg c in
let ⟨a, (hfa: f a = b)⟩ := hf b in
have hc: (g ∘ f) a = c, by rsimp,
⟨a, hc⟩
). |
% PURPOSE: Gets the baseline (mean) value
%
%
% FORMAT:
%
% blv = blvalue2(datax, timex, blcorr)
%
% INPUT:
%
% datax - input data
% timex - time vector
% blcorr - time window for getting the mean value
%
% OUTPUT:
%
% blv - mean value from window "blcorr"
%
%
% Example
% Get the baseline value for a window of -200 to 0 ms, at bin 4, channel 23
%
% blv = blvalue(ERP.bindata(23,:,4), ERP.times, [-200 0])
%
%
% See also blvalue2.m geterpvalues.m
%
%
% *** This function is part of ERPLAB Toolbox ***
% Author: Javier Lopez-Calderon
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
% 2013
function blv = blvalue2(datax, timex, blcorr)
%
% Baseline assessment
%
if ischar(blcorr)
if ~strcmpi(blcorr,'no') && ~strcmpi(blcorr,'none')
if strcmpi(blcorr,'pre')
[bbxx bb] = closest(timex, 0); % zero-time locked
aa = 1;
elseif strcmpi(blcorr,'post')
bb = length(timex);
[aax aa] = closest(timex, 0);
elseif strcmpi(blcorr,'all') || strcmpi(blcorr,'whole')
bb = length(timex);
aa = 1;
else
blcnum = str2num(blcorr); % in ms
%
% Check & fix baseline range
%
if blcnum(1)<min(timex)
blcnum(1) = min(timex); %ms
end
if blcnum(2)>max(timex)
blcnum(2) = max(timex); %ms
end
[xxx, cindex] = closest(timex, blcnum); % 04/21/2011
aa = cindex(1); % ms to sample pos
bb = cindex(2); % ms to sample pos
end
blv = mean(datax(aa:bb));
else
blv = 0;
end
else
%
% Check & fix baseline range
%
if blcorr(1)<min(timex)
blcorr(1) = min(timex); %ms
end
if blcorr(2)>max(timex)
blcorr(2) = max(timex); %ms
end
[xxx, cindex] = closest(timex, blcorr); % 04/21/2011
aa = cindex(1); % ms to sample pos
bb = cindex(2); % ms to sample pos
blv = mean(datax(aa:bb));
end
|
theory prop_32
imports Main
"$HIPSTER_HOME/IsaHipster"
begin
datatype Nat = Z | S "Nat"
fun min2 :: "Nat => Nat => Nat" where
"min2 (Z) y = Z"
| "min2 (S z) (Z) = Z"
| "min2 (S z) (S y1) = S (min2 z y1)"
(*hipster min2 *)
theorem x0 :
"(min2 a b) = (min2 b a)"
by (hipster_induct_schemes Nat.exhaust min2.simps)
end
|
If $p$ is a non-zero polynomial, then the coefficient of the leading term of $p$ is equal to the coefficient of the leading term of $p$ times the leading term of $p$. |
function hyperball_monte_carlo_test02 ( )
%*****************************************************************************80
%
%% HYPERBALL_MONTE_CARLO_TEST02 uses HYPERBALL01_SAMPLE in 6D.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 05 January 2014
%
% Author:
%
% John Burkardt
%
m = 6;
e_test = [ ...
0, 0, 0, 0, 0, 0; ...
1, 0, 0, 0, 0, 0; ...
0, 2, 0, 0, 0, 0; ...
0, 2, 2, 0, 0, 0; ...
0, 0, 0, 4, 0, 0; ...
2, 0, 0, 0, 2, 2; ...
0, 0, 0, 0, 0, 6 ]';
fprintf ( 1, '\n' );
fprintf ( 1, 'TEST02\n' );
fprintf ( 1, ' Use the Monte Carlo method to estimate integrals \n' );
fprintf ( 1, ' over the interior of the unit hyperball in M dimensions.\n' );
fprintf ( 1, 'n' );
fprintf ( 1, ' Spatial dimension M = %d\n', m );
seed = 123456789;
fprintf ( 1, '\n' );
fprintf ( 1, ' N' );
fprintf ( 1, ' 1 ' );
fprintf ( 1, ' U ' );
fprintf ( 1, ' V^2 ' );
fprintf ( 1, ' V^2W^2' );
fprintf ( 1, ' X^4 ' );
fprintf ( 1, ' Y^2Z^2' );
fprintf ( 1, ' Z^6\n' );
fprintf ( 1, '\n' );
n = 1;
while ( n <= 65536 )
[ x, seed ] = hyperball01_sample ( m, n, seed );
fprintf ( 1, ' %8d', n );
for j = 1 : 7
e(1:m) = e_test(1:m,j);
value = monomial_value ( m, n, e, x );
result(j) = hyperball01_volume ( m ) * sum ( value(1:n) ) / n;
fprintf ( 1, ' %14.6g', result(j) );
end
fprintf ( 1, '\n' );
n = 2 * n;
end
fprintf ( 1, '\n' );
fprintf ( 1, ' Exact' );
for j = 1 : 7
e(1:m) = e_test(1:m,j);
result(j) = hyperball01_monomial_integral ( m, e );
fprintf ( 1, ' %14.6g', result(j) );
end
fprintf ( 1, '\n' );
return
end
|
{#
Copyright 2015 Andrew Dawson, Peter Dueben
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#}
PUBLIC :: {{ interface_name }}
INTERFACE {{ interface_name }}
{% for name in procedure_names %}
MODULE PROCEDURE {{ name }}
{% endfor %}
END INTERFACE {{ interface_name }}
|
(*
Copyright 2018
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
theory task_list_remove_task_opt_mem
imports tasks_opt
begin
text \<open>Up to two locales per function in the binary.\<close>
locale task_list_remove_task_function = tasks_opt_context +
fixes rsp\<^sub>0 rbp\<^sub>0 list task a task_list_remove_task_opt_ret :: \<open>64 word\<close>
and v\<^sub>0 :: \<open>8 word\<close>
and blocks :: \<open>(nat \<times> 64 word \<times> nat) set\<close>
assumes seps: \<open>seps blocks\<close>
and masters:
\<open>master blocks (a, 1) 0\<close>
\<open>master blocks (rsp\<^sub>0, 8) 1\<close>
\<open>master blocks (list, 8) 2\<close> \<comment> \<open>\texttt{list->first}\<close>
\<open>master blocks (list+8, 8) 3\<close> \<comment> \<open>\texttt{list->last}\<close>
\<open>master blocks (task+88, 8) 4\<close> \<comment> \<open>\texttt{task->prev}\<close>
\<open>master blocks (task+96, 8) 5\<close> \<comment> \<open>\texttt{task->next}\<close>
and ret_address: \<open>outside task_list_remove_task_opt_ret 3 59\<close> \<comment> \<open>Only works for non-recursive functions.\<close>
begin
text \<open>
The Floyd invariant expresses for some locations properties that are invariably true.
Simply expresses that a byte in the memory remains untouched.
\<close>
definition pp_\<Theta> :: \<open>_ \<Rightarrow> _ \<Rightarrow> floyd_invar\<close> where
\<open>pp_\<Theta> prev next \<equiv> [
\<comment> \<open>precondition\<close>
boffset+3 \<mapsto> \<lambda>\<sigma>. regs \<sigma> rsp = rsp\<^sub>0
\<and> regs \<sigma> rbp = rbp\<^sub>0
\<and> regs \<sigma> rdi = list
\<and> regs \<sigma> rsi = task
\<and> \<sigma> \<turnstile> *[task+88,8] = prev
\<and> \<sigma> \<turnstile> *[task+96,8] = (next::64 word)
\<and> \<sigma> \<turnstile> *[rsp\<^sub>0,8] = boffset+task_list_remove_task_opt_ret
\<and> \<sigma> \<turnstile> *[a,1] = v\<^sub>0,
boffset+24 \<mapsto> \<lambda>\<sigma>. regs \<sigma> rsp = rsp\<^sub>0
\<and> regs \<sigma> rbp = rbp\<^sub>0
\<and> regs \<sigma> rdi = list
\<and> regs \<sigma> rax = prev
\<and> \<sigma> \<turnstile> *[rsp\<^sub>0,8] = boffset+task_list_remove_task_opt_ret
\<and> \<sigma> \<turnstile> *[a,1] = v\<^sub>0,
boffset+33 \<mapsto> \<lambda>\<sigma>. regs \<sigma> rsp = rsp\<^sub>0
\<and> regs \<sigma> rbp = rbp\<^sub>0
\<and> regs \<sigma> rdi = list
\<and> \<sigma> \<turnstile> *[rsp\<^sub>0,8] = boffset+task_list_remove_task_opt_ret
\<and> \<sigma> \<turnstile> *[a,1] = v\<^sub>0,
boffset+39 \<mapsto> \<lambda>\<sigma>. regs \<sigma> rsp = rsp\<^sub>0
\<and> regs \<sigma> rbp = rbp\<^sub>0
\<and> regs \<sigma> rdi = list
\<and> \<sigma> \<turnstile> *[rsp\<^sub>0,8] = boffset+task_list_remove_task_opt_ret
\<and> \<sigma> \<turnstile> *[a,1] = v\<^sub>0,
\<comment> \<open>postcondition\<close>
boffset+task_list_remove_task_opt_ret \<mapsto> \<lambda>\<sigma>. \<sigma> \<turnstile> *[a,1] = v\<^sub>0
\<and> regs \<sigma> rsp = rsp\<^sub>0+8
\<and> regs \<sigma> rbp = rbp\<^sub>0
]\<close>
text \<open>Adding some rules to the simplifier to simplify proofs.\<close>
schematic_goal pp_\<Theta>_zero[simp]:
\<open>pp_\<Theta> prev next boffset = ?x\<close>
unfolding pp_\<Theta>_def
by simp
schematic_goal pp_\<Theta>_numeral_l[simp]:
\<open>pp_\<Theta> prev next (n + boffset) = ?x\<close>
unfolding pp_\<Theta>_def
by simp
schematic_goal pp_\<Theta>_numeral_r[simp]:
\<open>pp_\<Theta> prev next (boffset + n) = ?x\<close>
unfolding pp_\<Theta>_def
by simp
lemma rewrite_task_list_remove_task_opt_mem:
assumes
\<open>master blocks (prev+96, 8) 6\<close> \<comment> \<open>\texttt{task->prev->next}\<close>
\<open>master blocks (next+88, 8) 7\<close> \<comment> \<open>\texttt{task->next->prev}\<close>
shows \<open>is_std_invar task_list_remove_task_opt_ret (floyd.invar task_list_remove_task_opt_ret (pp_\<Theta> prev next))\<close>
proof -
note masters = masters assms
show ?thesis
text \<open>Boilerplate code to start the VCG\<close>
apply (rule floyd_invarI)
apply (rewrite at \<open>floyd_vcs task_list_remove_task_opt_ret \<hole> _\<close> pp_\<Theta>_def)
apply (intro floyd_vcsI)
text \<open>Subgoal for rip = boffset+3\<close>
subgoal premises prems for \<sigma>
text \<open>Insert relevant knowledge\<close>
apply (insert prems seps ret_address)
text \<open>Apply VCG/symb.\ execution\<close>
apply (restart_symbolic_execution?, (symbolic_execution masters: masters)+, (finish_symbolic_execution masters: masters)?)+
done
text \<open>Subgoal for rip = boffset+24\<close>
subgoal premises prems for \<sigma>
text \<open>Insert relevant knowledge\<close>
apply (insert prems seps ret_address)
text \<open>Apply VCG/symb.\ execution\<close>
apply (restart_symbolic_execution?, (symbolic_execution masters: masters)+, (finish_symbolic_execution masters: masters)?)+
done
text \<open>Subgoal for rip = boffset+33\<close>
subgoal premises prems for \<sigma>
text \<open>Insert relevant knowledge\<close>
apply (insert prems seps ret_address)
text \<open>Apply VCG/symb.\ execution\<close>
apply (symbolic_execution masters: masters)+
apply (finish_symbolic_execution masters: masters)
apply restart_symbolic_execution
done
text \<open>Subgoal for rip = boffset+39\<close>
subgoal premises prems for \<sigma>
text \<open>Insert relevant knowledge\<close>
apply (insert prems seps ret_address)
text \<open>Apply VCG/symb.\ execution\<close>
apply (restart_symbolic_execution?, (symbolic_execution masters: masters)+, (finish_symbolic_execution masters: masters)?)+
done
text \<open>Trivial ending subgoal.\<close>
subgoal
by simp
done
qed
end
end
|
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers, Manuel Candales
! This file was ported from Lean 3 source module geometry.euclidean.triangle
! leanprover-community/mathlib commit 46b633fd842bef9469441c0209906f6dddd2b4f5
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Geometry.Euclidean.Angle.Oriented.Affine
import Mathbin.Geometry.Euclidean.Angle.Unoriented.Affine
import Mathbin.Tactic.IntervalCases
/-!
# Triangles
This file proves basic geometrical results about distances and angles
in (possibly degenerate) triangles in real inner product spaces and
Euclidean affine spaces. More specialized results, and results
developed for simplices in general rather than just for triangles, are
in separate files. Definitions and results that make sense in more
general affine spaces rather than just in the Euclidean case go under
`linear_algebra.affine_space`.
## Implementation notes
Results in this file are generally given in a form with only those
non-degeneracy conditions needed for the particular result, rather
than requiring affine independence of the points of a triangle
unnecessarily.
## References
* https://en.wikipedia.org/wiki/Law_of_cosines
* https://en.wikipedia.org/wiki/Pons_asinorum
* https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle
-/
noncomputable section
open BigOperators
open Classical
open Real
open RealInnerProductSpace
namespace InnerProductGeometry
/-!
### Geometrical results on triangles in real inner product spaces
This section develops some results on (possibly degenerate) triangles
in real inner product spaces, where those definitions and results can
most conveniently be developed in terms of vectors and then used to
deduce corresponding results for Euclidean affine spaces.
-/
variable {V : Type _} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
/-- Law of cosines (cosine rule), vector angle form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (x y : V) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) := by
rw [show 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) = 2 * (Real.cos (angle x y) * (‖x‖ * ‖y‖)) by ring,
cos_angle_mul_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, ←
real_inner_self_eq_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, real_inner_sub_sub_self,
sub_add_eq_add_sub]
#align inner_product_geometry.norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle InnerProductGeometry.norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle
/-- Pons asinorum, vector angle form. -/
theorem angle_sub_eq_angle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) :
angle x (x - y) = angle y (y - x) :=
by
refine' Real.injOn_cos ⟨angle_nonneg _ _, angle_le_pi _ _⟩ ⟨angle_nonneg _ _, angle_le_pi _ _⟩ _
rw [cos_angle, cos_angle, h, ← neg_sub, norm_neg, neg_sub, inner_sub_right, inner_sub_right,
real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm, h, real_inner_comm x y]
#align inner_product_geometry.angle_sub_eq_angle_sub_rev_of_norm_eq InnerProductGeometry.angle_sub_eq_angle_sub_rev_of_norm_eq
/-- Converse of pons asinorum, vector angle form. -/
theorem norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi {x y : V}
(h : angle x (x - y) = angle y (y - x)) (hpi : angle x y ≠ π) : ‖x‖ = ‖y‖ :=
by
replace h :=
Real.arccos_injOn (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x (x - y)))
(abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one y (y - x))) h
by_cases hxy : x = y
· rw [hxy]
· rw [← norm_neg (y - x), neg_sub, mul_comm, mul_comm ‖y‖, div_eq_mul_inv, div_eq_mul_inv,
mul_inv_rev, mul_inv_rev, ← mul_assoc, ← mul_assoc] at h
replace h :=
mul_right_cancel₀ (inv_ne_zero fun hz => hxy (eq_of_sub_eq_zero (norm_eq_zero.1 hz))) h
rw [inner_sub_right, inner_sub_right, real_inner_comm x y, real_inner_self_eq_norm_mul_norm,
real_inner_self_eq_norm_mul_norm, mul_sub_right_distrib, mul_sub_right_distrib,
mul_self_mul_inv, mul_self_mul_inv, sub_eq_sub_iff_sub_eq_sub, ← mul_sub_left_distrib] at h
by_cases hx0 : x = 0
· rw [hx0, norm_zero, inner_zero_left, MulZeroClass.zero_mul, zero_sub, neg_eq_zero] at h
rw [hx0, norm_zero, h]
· by_cases hy0 : y = 0
· rw [hy0, norm_zero, inner_zero_right, MulZeroClass.zero_mul, sub_zero] at h
rw [hy0, norm_zero, h]
· rw [inv_sub_inv (fun hz => hx0 (norm_eq_zero.1 hz)) fun hz => hy0 (norm_eq_zero.1 hz), ←
neg_sub, ← mul_div_assoc, mul_comm, mul_div_assoc, ← mul_neg_one] at h
symm
by_contra hyx
replace h := (mul_left_cancel₀ (sub_ne_zero_of_ne hyx) h).symm
rw [real_inner_div_norm_mul_norm_eq_neg_one_iff, ← angle_eq_pi_iff] at h
exact hpi h
#align inner_product_geometry.norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi InnerProductGeometry.norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi
/-- The cosine of the sum of two angles in a possibly degenerate
triangle (where two given sides are nonzero), vector angle form. -/
theorem cos_angle_sub_add_angle_sub_rev_eq_neg_cos_angle {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
Real.cos (angle x (x - y) + angle y (y - x)) = -Real.cos (angle x y) :=
by
by_cases hxy : x = y
· rw [hxy, angle_self hy]
simp
· rw [Real.cos_add, cos_angle, cos_angle, cos_angle]
have hxn : ‖x‖ ≠ 0 := fun h => hx (norm_eq_zero.1 h)
have hyn : ‖y‖ ≠ 0 := fun h => hy (norm_eq_zero.1 h)
have hxyn : ‖x - y‖ ≠ 0 := fun h => hxy (eq_of_sub_eq_zero (norm_eq_zero.1 h))
apply mul_right_cancel₀ hxn
apply mul_right_cancel₀ hyn
apply mul_right_cancel₀ hxyn
apply mul_right_cancel₀ hxyn
have H1 :
Real.sin (angle x (x - y)) * Real.sin (angle y (y - x)) * ‖x‖ * ‖y‖ * ‖x - y‖ * ‖x - y‖ =
Real.sin (angle x (x - y)) * (‖x‖ * ‖x - y‖) *
(Real.sin (angle y (y - x)) * (‖y‖ * ‖x - y‖)) :=
by ring
have H2 :
⟪x, x⟫ * (⟪x, x⟫ - ⟪x, y⟫ - (⟪x, y⟫ - ⟪y, y⟫)) - (⟪x, x⟫ - ⟪x, y⟫) * (⟪x, x⟫ - ⟪x, y⟫) =
⟪x, x⟫ * ⟪y, y⟫ - ⟪x, y⟫ * ⟪x, y⟫ :=
by ring
have H3 :
⟪y, y⟫ * (⟪y, y⟫ - ⟪x, y⟫ - (⟪x, y⟫ - ⟪x, x⟫)) - (⟪y, y⟫ - ⟪x, y⟫) * (⟪y, y⟫ - ⟪x, y⟫) =
⟪x, x⟫ * ⟪y, y⟫ - ⟪x, y⟫ * ⟪x, y⟫ :=
by ring
rw [mul_sub_right_distrib, mul_sub_right_distrib, mul_sub_right_distrib, mul_sub_right_distrib,
H1, sin_angle_mul_norm_mul_norm, norm_sub_rev x y, sin_angle_mul_norm_mul_norm,
norm_sub_rev y x, inner_sub_left, inner_sub_left, inner_sub_right, inner_sub_right,
inner_sub_right, inner_sub_right, real_inner_comm x y, H2, H3,
Real.mul_self_sqrt (sub_nonneg_of_le (real_inner_mul_inner_self_le x y)),
real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm,
real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two]
field_simp [hxn, hyn, hxyn]
ring
#align inner_product_geometry.cos_angle_sub_add_angle_sub_rev_eq_neg_cos_angle InnerProductGeometry.cos_angle_sub_add_angle_sub_rev_eq_neg_cos_angle
/-- The sine of the sum of two angles in a possibly degenerate
triangle (where two given sides are nonzero), vector angle form. -/
theorem sin_angle_sub_add_angle_sub_rev_eq_sin_angle {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
Real.sin (angle x (x - y) + angle y (y - x)) = Real.sin (angle x y) :=
by
by_cases hxy : x = y
· rw [hxy, angle_self hy]
simp
· rw [Real.sin_add, cos_angle, cos_angle]
have hxn : ‖x‖ ≠ 0 := fun h => hx (norm_eq_zero.1 h)
have hyn : ‖y‖ ≠ 0 := fun h => hy (norm_eq_zero.1 h)
have hxyn : ‖x - y‖ ≠ 0 := fun h => hxy (eq_of_sub_eq_zero (norm_eq_zero.1 h))
apply mul_right_cancel₀ hxn
apply mul_right_cancel₀ hyn
apply mul_right_cancel₀ hxyn
apply mul_right_cancel₀ hxyn
have H1 :
Real.sin (angle x (x - y)) * (⟪y, y - x⟫ / (‖y‖ * ‖y - x‖)) * ‖x‖ * ‖y‖ * ‖x - y‖ =
Real.sin (angle x (x - y)) * (‖x‖ * ‖x - y‖) * (⟪y, y - x⟫ / (‖y‖ * ‖y - x‖)) * ‖y‖ :=
by ring
have H2 :
⟪x, x - y⟫ / (‖x‖ * ‖y - x‖) * Real.sin (angle y (y - x)) * ‖x‖ * ‖y‖ * ‖y - x‖ =
⟪x, x - y⟫ / (‖x‖ * ‖y - x‖) * (Real.sin (angle y (y - x)) * (‖y‖ * ‖y - x‖)) * ‖x‖ :=
by ring
have H3 :
⟪x, x⟫ * (⟪x, x⟫ - ⟪x, y⟫ - (⟪x, y⟫ - ⟪y, y⟫)) - (⟪x, x⟫ - ⟪x, y⟫) * (⟪x, x⟫ - ⟪x, y⟫) =
⟪x, x⟫ * ⟪y, y⟫ - ⟪x, y⟫ * ⟪x, y⟫ :=
by ring
have H4 :
⟪y, y⟫ * (⟪y, y⟫ - ⟪x, y⟫ - (⟪x, y⟫ - ⟪x, x⟫)) - (⟪y, y⟫ - ⟪x, y⟫) * (⟪y, y⟫ - ⟪x, y⟫) =
⟪x, x⟫ * ⟪y, y⟫ - ⟪x, y⟫ * ⟪x, y⟫ :=
by ring
rw [right_distrib, right_distrib, right_distrib, right_distrib, H1, sin_angle_mul_norm_mul_norm,
norm_sub_rev x y, H2, sin_angle_mul_norm_mul_norm, norm_sub_rev y x,
mul_assoc (Real.sin (angle x y)), sin_angle_mul_norm_mul_norm, inner_sub_left, inner_sub_left,
inner_sub_right, inner_sub_right, inner_sub_right, inner_sub_right, real_inner_comm x y, H3,
H4, real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm,
real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two]
field_simp [hxn, hyn, hxyn]
ring
#align inner_product_geometry.sin_angle_sub_add_angle_sub_rev_eq_sin_angle InnerProductGeometry.sin_angle_sub_add_angle_sub_rev_eq_sin_angle
/-- The cosine of the sum of the angles of a possibly degenerate
triangle (where two given sides are nonzero), vector angle form. -/
theorem cos_angle_add_angle_sub_add_angle_sub_eq_neg_one {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
Real.cos (angle x y + angle x (x - y) + angle y (y - x)) = -1 := by
rw [add_assoc, Real.cos_add, cos_angle_sub_add_angle_sub_rev_eq_neg_cos_angle hx hy,
sin_angle_sub_add_angle_sub_rev_eq_sin_angle hx hy, mul_neg, ← neg_add', add_comm, ← sq, ← sq,
Real.sin_sq_add_cos_sq]
#align inner_product_geometry.cos_angle_add_angle_sub_add_angle_sub_eq_neg_one InnerProductGeometry.cos_angle_add_angle_sub_add_angle_sub_eq_neg_one
/-- The sine of the sum of the angles of a possibly degenerate
triangle (where two given sides are nonzero), vector angle form. -/
theorem sin_angle_add_angle_sub_add_angle_sub_eq_zero {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
Real.sin (angle x y + angle x (x - y) + angle y (y - x)) = 0 :=
by
rw [add_assoc, Real.sin_add, cos_angle_sub_add_angle_sub_rev_eq_neg_cos_angle hx hy,
sin_angle_sub_add_angle_sub_rev_eq_sin_angle hx hy]
ring
#align inner_product_geometry.sin_angle_add_angle_sub_add_angle_sub_eq_zero InnerProductGeometry.sin_angle_add_angle_sub_add_angle_sub_eq_zero
/-- The sum of the angles of a possibly degenerate triangle (where the
two given sides are nonzero), vector angle form. -/
theorem angle_add_angle_sub_add_angle_sub_eq_pi {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
angle x y + angle x (x - y) + angle y (y - x) = π :=
by
have hcos := cos_angle_add_angle_sub_add_angle_sub_eq_neg_one hx hy
have hsin := sin_angle_add_angle_sub_add_angle_sub_eq_zero hx hy
rw [Real.sin_eq_zero_iff] at hsin
cases' hsin with n hn
symm at hn
have h0 : 0 ≤ angle x y + angle x (x - y) + angle y (y - x) :=
add_nonneg (add_nonneg (angle_nonneg _ _) (angle_nonneg _ _)) (angle_nonneg _ _)
have h3 : angle x y + angle x (x - y) + angle y (y - x) ≤ π + π + π :=
add_le_add (add_le_add (angle_le_pi _ _) (angle_le_pi _ _)) (angle_le_pi _ _)
have h3lt : angle x y + angle x (x - y) + angle y (y - x) < π + π + π :=
by
by_contra hnlt
have hxy : angle x y = π := by
by_contra hxy
exact
hnlt
(add_lt_add_of_lt_of_le
(add_lt_add_of_lt_of_le (lt_of_le_of_ne (angle_le_pi _ _) hxy) (angle_le_pi _ _))
(angle_le_pi _ _))
rw [hxy] at hnlt
rw [angle_eq_pi_iff] at hxy
rcases hxy with ⟨hx, ⟨r, ⟨hr, hxr⟩⟩⟩
rw [hxr, ← one_smul ℝ x, ← mul_smul, mul_one, ← sub_smul, one_smul, sub_eq_add_neg,
angle_smul_right_of_pos _ _ (add_pos zero_lt_one (neg_pos_of_neg hr)), angle_self hx,
add_zero] at hnlt
apply hnlt
rw [add_assoc]
exact add_lt_add_left (lt_of_le_of_lt (angle_le_pi _ _) (lt_add_of_pos_right π Real.pi_pos)) _
have hn0 : 0 ≤ n :=
by
rw [hn, mul_nonneg_iff_left_nonneg_of_pos Real.pi_pos] at h0
norm_cast at h0
exact h0
have hn3 : n < 3 := by
rw [hn, show π + π + π = 3 * π by ring] at h3lt
replace h3lt := lt_of_mul_lt_mul_right h3lt (le_of_lt Real.pi_pos)
norm_cast at h3lt
exact h3lt
interval_cases
· rw [hn] at hcos
simp at hcos
norm_num at hcos
· rw [hn]
norm_num
· rw [hn] at hcos
simp at hcos
norm_num at hcos
#align inner_product_geometry.angle_add_angle_sub_add_angle_sub_eq_pi InnerProductGeometry.angle_add_angle_sub_add_angle_sub_eq_pi
end InnerProductGeometry
namespace EuclideanGeometry
/-!
### Geometrical results on triangles in Euclidean affine spaces
This section develops some geometrical definitions and results on
(possible degenerate) triangles in Euclidean affine spaces.
-/
open InnerProductGeometry
open EuclideanGeometry
variable {V : Type _} {P : Type _} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
include V
/-- **Law of cosines** (cosine rule), angle-at-point form. -/
theorem dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle (p1 p2 p3 : P) :
dist p1 p3 * dist p1 p3 =
dist p1 p2 * dist p1 p2 + dist p3 p2 * dist p3 p2 -
2 * dist p1 p2 * dist p3 p2 * Real.cos (∠ p1 p2 p3) :=
by
rw [dist_eq_norm_vsub V p1 p3, dist_eq_norm_vsub V p1 p2, dist_eq_norm_vsub V p3 p2]
unfold angle
convert norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (p1 -ᵥ p2 : V)
(p3 -ᵥ p2 : V)
· exact (vsub_sub_vsub_cancel_right p1 p3 p2).symm
· exact (vsub_sub_vsub_cancel_right p1 p3 p2).symm
#align euclidean_geometry.dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle EuclideanGeometry.dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle
alias dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle ← law_cos
#align euclidean_geometry.law_cos EuclideanGeometry.law_cos
/-- **Isosceles Triangle Theorem**: Pons asinorum, angle-at-point form. -/
theorem angle_eq_angle_of_dist_eq {p1 p2 p3 : P} (h : dist p1 p2 = dist p1 p3) :
∠ p1 p2 p3 = ∠ p1 p3 p2 :=
by
rw [dist_eq_norm_vsub V p1 p2, dist_eq_norm_vsub V p1 p3] at h
unfold angle
convert angle_sub_eq_angle_sub_rev_of_norm_eq h
· exact (vsub_sub_vsub_cancel_left p3 p2 p1).symm
· exact (vsub_sub_vsub_cancel_left p2 p3 p1).symm
#align euclidean_geometry.angle_eq_angle_of_dist_eq EuclideanGeometry.angle_eq_angle_of_dist_eq
/-- Converse of pons asinorum, angle-at-point form. -/
theorem dist_eq_of_angle_eq_angle_of_angle_ne_pi {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = ∠ p1 p3 p2)
(hpi : ∠ p2 p1 p3 ≠ π) : dist p1 p2 = dist p1 p3 :=
by
unfold angle at h hpi
rw [dist_eq_norm_vsub V p1 p2, dist_eq_norm_vsub V p1 p3]
rw [← angle_neg_neg, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev] at hpi
rw [← vsub_sub_vsub_cancel_left p3 p2 p1, ← vsub_sub_vsub_cancel_left p2 p3 p1] at h
exact norm_eq_of_angle_sub_eq_angle_sub_rev_of_angle_ne_pi h hpi
#align euclidean_geometry.dist_eq_of_angle_eq_angle_of_angle_ne_pi EuclideanGeometry.dist_eq_of_angle_eq_angle_of_angle_ne_pi
/-- The **sum of the angles of a triangle** (possibly degenerate, where the
given vertex is distinct from the others), angle-at-point. -/
theorem angle_add_angle_add_angle_eq_pi {p1 p2 p3 : P} (h2 : p2 ≠ p1) (h3 : p3 ≠ p1) :
∠ p1 p2 p3 + ∠ p2 p3 p1 + ∠ p3 p1 p2 = π :=
by
rw [add_assoc, add_comm, add_comm (∠ p2 p3 p1), angle_comm p2 p3 p1]
unfold angle
rw [← angle_neg_neg (p1 -ᵥ p3), ← angle_neg_neg (p1 -ᵥ p2), neg_vsub_eq_vsub_rev,
neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev, ←
vsub_sub_vsub_cancel_right p3 p2 p1, ← vsub_sub_vsub_cancel_right p2 p3 p1]
exact
angle_add_angle_sub_add_angle_sub_eq_pi (fun he => h3 (vsub_eq_zero_iff_eq.1 he)) fun he =>
h2 (vsub_eq_zero_iff_eq.1 he)
#align euclidean_geometry.angle_add_angle_add_angle_eq_pi EuclideanGeometry.angle_add_angle_add_angle_eq_pi
/-- The **sum of the angles of a triangle** (possibly degenerate, where the triangle is a line),
oriented angles at point. -/
theorem oangle_add_oangle_add_oangle_eq_pi [Module.Oriented ℝ V (Fin 2)]
[Fact (FiniteDimensional.finrank ℝ V = 2)] {p1 p2 p3 : P} (h21 : p2 ≠ p1) (h32 : p3 ≠ p2)
(h13 : p1 ≠ p3) : ∡ p1 p2 p3 + ∡ p2 p3 p1 + ∡ p3 p1 p2 = π := by
simpa only [neg_vsub_eq_vsub_rev] using
positive_orientation.oangle_add_cyc3_neg_left (vsub_ne_zero.mpr h21) (vsub_ne_zero.mpr h32)
(vsub_ne_zero.mpr h13)
#align euclidean_geometry.oangle_add_oangle_add_oangle_eq_pi EuclideanGeometry.oangle_add_oangle_add_oangle_eq_pi
/-- **Stewart's Theorem**. -/
theorem dist_sq_mul_dist_add_dist_sq_mul_dist (a b c p : P) (h : ∠ b p c = π) :
dist a b ^ 2 * dist c p + dist a c ^ 2 * dist b p =
dist b c * (dist a p ^ 2 + dist b p * dist c p) :=
by
rw [pow_two, pow_two, law_cos a p b, law_cos a p c,
eq_sub_of_add_eq (angle_add_angle_eq_pi_of_angle_eq_pi a h), Real.cos_pi_sub,
dist_eq_add_dist_of_angle_eq_pi h]
ring
#align euclidean_geometry.dist_sq_mul_dist_add_dist_sq_mul_dist EuclideanGeometry.dist_sq_mul_dist_add_dist_sq_mul_dist
/-- **Apollonius's Theorem**. -/
theorem dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq (a b c : P) :
dist a b ^ 2 + dist a c ^ 2 = 2 * (dist a (midpoint ℝ b c) ^ 2 + (dist b c / 2) ^ 2) :=
by
by_cases hbc : b = c
· simp [hbc, midpoint_self, dist_self, two_mul]
· let m := midpoint ℝ b c
have : dist b c ≠ 0 := (dist_pos.mpr hbc).ne'
have hm := dist_sq_mul_dist_add_dist_sq_mul_dist a b c m (angle_midpoint_eq_pi b c hbc)
simp only [dist_left_midpoint, dist_right_midpoint, Real.norm_two] at hm
calc
dist a b ^ 2 + dist a c ^ 2 =
2 / dist b c * (dist a b ^ 2 * (2⁻¹ * dist b c) + dist a c ^ 2 * (2⁻¹ * dist b c)) :=
by
field_simp
ring
_ = 2 * (dist a (midpoint ℝ b c) ^ 2 + (dist b c / 2) ^ 2) :=
by
rw [hm]
field_simp
ring
#align euclidean_geometry.dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq EuclideanGeometry.dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq
theorem dist_mul_of_eq_angle_of_dist_mul (a b c a' b' c' : P) (r : ℝ) (h : ∠ a' b' c' = ∠ a b c)
(hab : dist a' b' = r * dist a b) (hcb : dist c' b' = r * dist c b) :
dist a' c' = r * dist a c :=
by
have h' : dist a' c' ^ 2 = (r * dist a c) ^ 2
calc
dist a' c' ^ 2 =
dist a' b' ^ 2 + dist c' b' ^ 2 - 2 * dist a' b' * dist c' b' * Real.cos (∠ a' b' c') :=
by simp [pow_two, law_cos a' b' c']
_ = r ^ 2 * (dist a b ^ 2 + dist c b ^ 2 - 2 * dist a b * dist c b * Real.cos (∠ a b c)) :=
by
rw [h, hab, hcb]
ring
_ = (r * dist a c) ^ 2 := by simp [pow_two, ← law_cos a b c, mul_pow]
by_cases hab₁ : a = b
· have hab'₁ : a' = b' := by
rw [← dist_eq_zero, hab, dist_eq_zero.mpr hab₁, MulZeroClass.mul_zero r]
rw [hab₁, hab'₁, dist_comm b' c', dist_comm b c, hcb]
· have h1 : 0 ≤ r * dist a b := by
rw [← hab]
exact dist_nonneg
have h2 : 0 ≤ r := nonneg_of_mul_nonneg_left h1 (dist_pos.mpr hab₁)
exact (sq_eq_sq dist_nonneg (mul_nonneg h2 dist_nonneg)).mp h'
#align euclidean_geometry.dist_mul_of_eq_angle_of_dist_mul EuclideanGeometry.dist_mul_of_eq_angle_of_dist_mul
end EuclideanGeometry
|
State Before: α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ prod l₁ = prod l₂ State After: α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (y : α), y ∈ l₁ → ∀ (z : α), z * x * y = z * y * x Tactic: refine h.foldl_eq' ?_ _ State Before: α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (y : α), y ∈ l₁ → ∀ (z : α), z * x * y = z * y * x State After: case H
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Symmetric fun x y => ∀ (z : α), z * x * y = z * y * x
case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (z : α), z * x * x = z * x * x
case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ Tactic: apply Pairwise.forall_of_forall State Before: case H
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Symmetric fun x y => ∀ (z : α), z * x * y = z * y * x
case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (z : α), z * x * x = z * x * x
case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ State After: case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (z : α), z * x * x = z * x * x
case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ Tactic: . intro x y h z
exact (h z).symm State Before: case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (z : α), z * x * x = z * x * x
case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ State After: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ Tactic: . intros; rfl State Before: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ State After: no goals Tactic: . apply hc.imp
intro a b h z
rw [mul_assoc z, mul_assoc z, h] State Before: case H
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Symmetric fun x y => ∀ (z : α), z * x * y = z * y * x State After: case H
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h✝ : l₁ ~ l₂
hc : Pairwise Commute l₁
x y : α
h : ∀ (z : α), z * x * y = z * y * x
z : α
⊢ z * y * x = z * x * y Tactic: intro x y h z State Before: case H
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h✝ : l₁ ~ l₂
hc : Pairwise Commute l₁
x y : α
h : ∀ (z : α), z * x * y = z * y * x
z : α
⊢ z * y * x = z * x * y State After: no goals Tactic: exact (h z).symm State Before: case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ (x : α), x ∈ l₁ → ∀ (z : α), z * x * x = z * x * x State After: case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
x✝ : α
a✝ : x✝ ∈ l₁
z✝ : α
⊢ z✝ * x✝ * x✝ = z✝ * x✝ * x✝ Tactic: intros State Before: case H₁
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
x✝ : α
a✝ : x✝ ∈ l₁
z✝ : α
⊢ z✝ * x✝ * x✝ = z✝ * x✝ * x✝ State After: no goals Tactic: rfl State Before: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ Pairwise (fun x y => ∀ (z : α), z * x * y = z * y * x) l₁ State After: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ {a b : α}, Commute a b → ∀ (z : α), z * a * b = z * b * a Tactic: apply hc.imp State Before: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h : l₁ ~ l₂
hc : Pairwise Commute l₁
⊢ ∀ {a b : α}, Commute a b → ∀ (z : α), z * a * b = z * b * a State After: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h✝ : l₁ ~ l₂
hc : Pairwise Commute l₁
a b : α
h : Commute a b
z : α
⊢ z * a * b = z * b * a Tactic: intro a b h z State Before: case H₂
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
M : Monoid α
l₁ l₂ : List α
h✝ : l₁ ~ l₂
hc : Pairwise Commute l₁
a b : α
h : Commute a b
z : α
⊢ z * a * b = z * b * a State After: no goals Tactic: rw [mul_assoc z, mul_assoc z, h] |
lemma collinear_empty [iff]: "collinear {}" |
module Bad1
data Bad = BadDCon (x : Nat)
|
```python
from sympy import *
x = var('X')
%matplotlib inline
```
```python
!pip install seaborn
import seaborn as sns
```
Requirement already satisfied: seaborn in ./anaconda3/lib/python3.7/site-packages (0.9.0)
Requirement already satisfied: numpy>=1.9.3 in ./anaconda3/lib/python3.7/site-packages (from seaborn) (1.15.4)
Requirement already satisfied: matplotlib>=1.4.3 in ./anaconda3/lib/python3.7/site-packages (from seaborn) (3.0.2)
Requirement already satisfied: scipy>=0.14.0 in ./anaconda3/lib/python3.7/site-packages (from seaborn) (1.1.0)
Requirement already satisfied: pandas>=0.15.2 in ./anaconda3/lib/python3.7/site-packages (from seaborn) (0.23.4)
Requirement already satisfied: cycler>=0.10 in ./anaconda3/lib/python3.7/site-packages (from matplotlib>=1.4.3->seaborn) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in ./anaconda3/lib/python3.7/site-packages (from matplotlib>=1.4.3->seaborn) (1.0.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in ./anaconda3/lib/python3.7/site-packages (from matplotlib>=1.4.3->seaborn) (2.3.0)
Requirement already satisfied: python-dateutil>=2.1 in ./anaconda3/lib/python3.7/site-packages (from matplotlib>=1.4.3->seaborn) (2.7.5)
Requirement already satisfied: pytz>=2011k in ./anaconda3/lib/python3.7/site-packages (from pandas>=0.15.2->seaborn) (2018.7)
Requirement already satisfied: six in ./anaconda3/lib/python3.7/site-packages (from cycler>=0.10->matplotlib>=1.4.3->seaborn) (1.12.0)
Requirement already satisfied: setuptools in ./anaconda3/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib>=1.4.3->seaborn) (40.6.3)
```python
sns.set(style='ticks',palette='Set2')
```
```python
frecuencias = np.array([0.1,0.2,0.5,0.6])
plt.figure(figsize=(7,4))
for f in frecuencias:
plt.plot(t,0.5 * np.cos(f*t) + 0.1 * np.sin(f*t),'o-',
label = '$\omega_0 = %s$'%f)
plt.xlabel('$t$',fontsize=16)
plt.ylabel('$x(t)$',fontsize=16)
plt.title('oscilaciones',fontsize=16)
plt.legend(loc='center left',bbox_to_anchor=(1.05,0.5),prop={'size':14})
plt.show
```
```python
from ipywidgets import *
```
```python
def masa_resorte(t=0):
fig=plt
```
|
this %should work.
%don't w%orry -- this won't cause a %segfault.
|
theory infinitePrimes
imports Main "HOL-Number_Theory.Number_Theory"
begin
definition primeNat :: "nat => bool"
where "primeNat p = (1 < p ∧ (∀m. m dvd p ⟶ m = 1 ∨ m = p))"
theorem infinite_primes: "~ finite {p::nat. primeNat p}"
proof cases
assume finitePrimes: "finite {p::nat. p ≥ 2 ∧ primeNat p}"
then have biggerThanPrimes:"∃ bigger. (ALL x: {(p::nat). primeNat p}. x <= bigger)"
by (metis (no_types, lifting) Collect_cong primeNat_def prime_ge_2_nat prime_nat_iff primes_infinite)
then obtain bigger :: nat where "ALL (x :: nat). primeNat x ⟶ x ≤ bigger"
using finite_nat_set_iff_bounded_le primes_infinite by blast
have False
by (metis (no_types, lifting) Collect_cong finitePrimes primeNat_def prime_ge_2_nat prime_nat_iff primes_infinite)
thus ?thesis by auto
next
assume "¬finite {p::nat. p ≥ 2 ∧ primeNat p}"
thus ?thesis by auto
qed
end
|
[STATEMENT]
lemma i_hcomplex_of_hypreal [simp]: "\<And>r. iii * hcomplex_of_hypreal r = HComplex 0 r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>r. iii * hcomplex_of_hypreal r = HComplex 0 r
[PROOF STEP]
by transfer (rule i_complex_of_real) |
{-
1. Input: Vect n elem
Output: Vect n elem
Operations: Cloning the Vect, replacing the elements of the Vect with random elements.
Input: Vect n elem
Output: Vect (n * 2) elem
Operations: Append a Vect with itself, inserting `n` random elements into the Vect.
Input: Vect (1 + n) elem
Output: Vect n elem
Operations: Popping an element from any position in the Vect.
Input: Bounded n, Vect n elem
Output: elem
Operations: Retrieving the element at index `Bounded n` in the Vect.
-} |
#== # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description
#
# This function computes the sunlight, penumbra, and umbra times of the
# satellite for one orbit every day in a year.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# References
#
# [1] Longo, C. R. O., Rickman, S. L (1995). Method for the Calculation of
# Spacecraft Umbra and Penumbra Shadow Terminator Points. NASA Technical
# Paper 3547.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ==#
export eclipse_time_summary
"""
function eclipse_time_summary(JD₀::Number, a::Number, e::Number, i::Number, RAAN::Number, w::Number, Δd::Integer, relative::Bool = false, Δt₀::AbstractFloat = -1.0)
Compute the eclipse time of an orbit with semi-major axis `a` [m], eccentricity
`e`, inclination `i` [rad], initial right ascension of the ascending node `RAAN`
[rad], and initial argument of perigee `w` [rad]. The orbit epoch, which is also
the day in which the analysis will begin, is `JD₀` [Julian Day]. The analysis
will be performed for each day during `Δd` days.
This function will compute the eclipse time of one orbit per day.
If the argument `relative` is `true`, then the computed times will be relative
to the nodal period [%]. Otherwise, they will be computed in seconds. By
default, `relative = false`.
The argument `Δt₀` can be used to select the time step in which the orbit will
be propagated. Notice that this algorithm performs a numerical search to find
the beginning of each section (sunlight, penumbra, and umbra) with millisecond
precision. Thus, selecting a high number for `Δt₀` will make the analysis
faster, but the accuracy is lost if a region time span is smalled than `Δt₀`. If
this parameter is omitted or if it is negative, then the time step will be
selected automatically to match a mean anomaly step of 5°.
All the analysis is performed using a J2 orbit propagator.
# Returns
The following table:
day | Sunlight Time | Penumbra Time | Umbra Time
-----+---------------+---------------+------------
"""
function eclipse_time_summary(JD₀::Number, a::Number, e::Number, i::Number,
RAAN::Number, w::Number, Δd::Integer,
relative::Bool = false, Δt₀::AbstractFloat = -1.0)
# Get the period of the orbit.
T = period(a, e, i, :J2)
# If the user did not specify the integration step, then compute based on
# a mean anomaly step.
if Δt₀ <= 0
# Step of the orbit propagation (mean anomaly) [rad].
Δm = 0.5*π/180
# Time step related to the desired mean anomaly step [s].
n = angvel(a, e, i, :J2)
Δt₀ = Δm/n
end
# Vector of the days in which the beta angle will be computed.
days = collect(0:1:Δd-1)
# Preallocate the output variables.
p_time = zeros(Δd) # Penumbra time.
u_time = zeros(Δd) # Umbra time.
s_time = zeros(Δd) # Sunlight time.
# Configure the orbit propagator.
orbp = init_orbit_propagator(Val{:J2}, JD₀, a, e, i, RAAN, w, 0)
# Lambda functions
# ==========================================================================
# Function to compute the lightning condition given an instant of the day
# `t`, the day from orbit epoch `d`, and the Sun vector `s_i`.
f(t,d,s_i)::Int = begin
~, r_i, ~ = propagate!(orbp, 86400d + t)
return satellite_lighting_condition(r_i, s_i)
end
# Return `true` if the lightning condition given an instant of the day `t`,
# the day from orbit epoch `d`, and the Sun vector `s_i` is equal `state`.
fb(t,d,s_i,state)::Bool = f(t,d,s_i) == state
# Accumulate the time step `Δt` according to the state `state`.
accum(Δt, state, ind, s, p, u)::Nothing = begin
@inbounds if state == SAT_LIGHTING_SUNLIGHT
s[ind] += Δt
elseif state == SAT_LIGHTING_PENUMBRA
p[ind] += Δt
elseif state == SAT_LIGHTING_UMBRA
u[ind] += Δt
end
return nothing
end
# Loop
# ==========================================================================
@inbounds for d in days
# Get the sun position represented in the Inertial coordinate frame.
s_i = sun_position_i(JD₀+d)
# Initial state.
state = f(0,d,s_i)
# Compute the eclipse time during one orbit.
Δt = Δt₀
k = Δt
while true
new_state = f(k,d,s_i)
# Check if the state has changed.
if new_state != state
# Refine to find the edge.
k₀ = k - Δt
k₁ = k
kc = find_crossing(fb, k₀, k₁, true, false, d, s_i, state)
# Times to be added in the previous and current states.
Δ₀ = kc - k₀
Δ₁ = k₁ - kc
accum(Δ₀, state, d+1, s_time, p_time, u_time)
accum(Δ₁, new_state, d+1, s_time, p_time, u_time)
# If not, just add the time step to the current state.
else
accum(Δt, state, d+1, s_time, p_time, u_time)
end
state = new_state
abs(k - T) < 1e-3 && break
# Make sure that the last interval will have the exact size so that
# the end of analysis is the end of the orbit.
(k + Δt > T) && (Δt = T - k)
k += Δt
end
end
if (!relative)
[days s_time p_time u_time]
else
total_time = s_time + p_time + u_time
[days s_time./total_time p_time./total_time u_time./total_time]
end
end
|
using Swagger, Test
function as_taskfailedexception(ex)
try
task = @async throw(ex)
wait(task)
catch ex
return ex
end
end
function test_longpoll_exception_check()
resp = Swagger.Downloads.Response("http", "http://localhost", 200, "no error", [])
reqerr1 = Swagger.Downloads.RequestError("http://localhost", 500, "not timeout error", resp)
reqerr2 = Swagger.Downloads.RequestError("http://localhost", 200, "Operation timed out after 300 milliseconds with 0 bytes received", resp) # timeout error
@test Swagger.is_longpoll_timeout("not an exception") == false
swaggerex1 = Swagger.ApiException(reqerr1)
@test Swagger.is_longpoll_timeout(swaggerex1) == false
@test Swagger.is_longpoll_timeout(as_taskfailedexception(swaggerex1)) == false
swaggerex2 = Swagger.ApiException(reqerr2)
@test Swagger.is_longpoll_timeout(swaggerex2)
@test Swagger.is_longpoll_timeout(as_taskfailedexception(swaggerex2))
@test Swagger.is_longpoll_timeout(CompositeException([swaggerex1, swaggerex2]))
@test Swagger.is_longpoll_timeout(CompositeException([swaggerex1, as_taskfailedexception(swaggerex2)]))
@test Swagger.is_longpoll_timeout(CompositeException([swaggerex1, as_taskfailedexception(swaggerex1)])) == false
end
|
(* bad interaction between keyword in custom entry and the coq parser.
* There is a zulip discussion from January 2021 about it
* https://coq.zulipchat.com/#narrow/stream/237977-Coq-users/topic/Bad.20interaction.20with.20notation.20and.20names
* might be fixed in the future
*)
Declare Custom Entry myentry.
Inductive list (A: Type) :=
| nil : list A
| cons : A -> list A -> list A.
Arguments nil {A}.
Arguments cons {A}.
(* TODO
* keywords in a custom entry still pollute the constr parser
* Workaround: call it list' in the notation *)
Notation " 'listF' ( head0 , .. , head1 ) " :=
(@cons nat head0 .. (@cons nat head1 nil) ..)
(in custom myentry, head0 constr, head1 constr).
Notation " {{ e }} " := (e) (e custom myentry).
Check {{ listF (1, 2, 3) }}.
Inductive myind :=
| myctor : list nat -> myind.
|
lemma norm_prod_le: "norm (prod f A) \<le> (\<Prod>a\<in>A. norm (f a :: 'a :: {real_normed_algebra_1,comm_monoid_mult}))" |
--
-- Copyright (c) 2009-2011, ERICSSON AB
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the ERICSSON AB nor the names of its contributors
-- may be used to endorse or promote products derived from this software
-- without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
module Feldspar.Core.Frontend.Floating where
import qualified Prelude
import Prelude (Float,Double)
import Data.Complex
import Feldspar.Core.Constructs
import Feldspar.Core.Constructs.Floating
import Feldspar.Core.Frontend.Fractional
-- Make new class, with "Data" in all the types
infixr 8 **
class (Fraction a, Prelude.Floating a) => Floating a where
pi :: Data a
pi = sugarSymF Pi
exp :: Data a -> Data a
exp = sugarSymF Exp
sqrt :: Data a -> Data a
sqrt = sugarSymF Sqrt
log :: Data a -> Data a
log = sugarSymF Log
(**) :: Data a -> Data a -> Data a
(**) = sugarSymF Pow
logBase :: Data a -> Data a -> Data a
logBase = sugarSymF LogBase
sin :: Data a -> Data a
sin = sugarSymF Sin
tan :: Data a -> Data a
tan = sugarSymF Tan
cos :: Data a -> Data a
cos = sugarSymF Cos
asin :: Data a -> Data a
asin = sugarSymF Asin
atan :: Data a -> Data a
atan = sugarSymF Atan
acos :: Data a -> Data a
acos = sugarSymF Acos
sinh :: Data a -> Data a
sinh = sugarSymF Sinh
tanh :: Data a -> Data a
tanh = sugarSymF Tanh
cosh :: Data a -> Data a
cosh = sugarSymF Cosh
asinh :: Data a -> Data a
asinh = sugarSymF Asinh
atanh :: Data a -> Data a
atanh = sugarSymF Atanh
acosh :: Data a -> Data a
acosh = sugarSymF Acosh
instance Floating Float
instance Floating Double
instance (Fraction a, Prelude.RealFloat a) => Floating (Complex a)
|
PRINT *, "Hello, World!"
END
|
Require Globalenvs.
Require Memimpl.
(* [CompCertX:test-compcert-param-memory] This file is required for those symbols of [Globalenvs] that will be
used by OCaml mode. They have to be instantiated with the concrete
memory model [Memimpl]. *)
Definition init_mem (F V: Type) := Globalenvs.Genv.init_mem (mem := Memimpl.mem) (F := F) (V := V).
|
module datastore_exercises
import DataStore
testStore : DataStore (SString .+. (SString .+. SInt))
testStore =
addToStore ("Mercury", "Mariner 10", 1974) $
addToStore ("Venus", "Venera", 1961) $
addToStore ("Uranus", "Voyager 2", 1986) $
addToStore ("Pluto", "New Horizons", 2015) $
empty
getValues : DataStore (SString .+. val_schema) -> List (SchemaType val_schema)
getValues store with (storeView store)
getValues empty | SNil = []
getValues (addToStore (_, value) store) | SAdd store' = value :: getValues store | store'
|
module DeMorgan where
open import Definitions
deMorgan : {A B : Set} → ¬ A ∧ ¬ B → ¬ (A ∨ B)
deMorgan = {!!}
|
using FunctionOperators, LinearAlgebra, Test, BenchmarkTools
data = [sin(i+j+k)^2 for i=1:300, j=1:300, k=1:50]
bOp₁ = FunctionOperator{Float64}(name="Op₁",
forw = (buffer, x) -> buffer .= x.^2,
backw = (buffer, x) -> broadcast!(sqrt, buffer, x),
inDims = (300, 300, 50), outDims = (300, 300, 50))
weights = [sin((i-j)*l) + 1 for i=1:300, j=1:300, k=1:50, l=1:10]
bOp₂ = FunctionOperator{Float64}(name="Op₂",
forw = (buffer,x) -> buffer .= reshape(x, 300, 300, 50, 1) .* weights,
backw = (buffer,x) -> dropdims(sum!(reshape(buffer, 300, 300, 50, 1), x ./ weights), dims=4),
inDims=(300, 300, 50), outDims=(300, 300, 50, 10))
combined = bOp₂ * (bOp₁ - 2.5*I) * bOp₁'
output = combined * data
function getAggregatedFunction()
weights = [sin((i-j)*l) + 1 for i=1:300, j=1:300, k=1:50, l=1:10]
buffer2 = Array{Float64}(undef, 300, 300, 50)
buffer3 = Array{Float64}(undef, 300, 300, 50)
buffer4 = Array{Float64}(undef, 300, 300, 50)
(buffer, x) -> begin
broadcast!(sqrt, buffer2, x) # Of course, this two lines can be optimized to
buffer3 .= buffer2 .^ 2 # (√x)^2 = |x|, but let's now avoid this fact
broadcast!(-, buffer3, buffer3, broadcast!(*, buffer4, 2.5, buffer2))
buffer .= reshape(buffer3, 300, 300, 50, 1) .* weights
end
end
aggrFun = getAggregatedFunction()
@testset "Performance" begin
t1 = @belapsed mul!(output, combined, data)
t2 = @belapsed aggrFun(output, data)
@test t1 / t2 ≈ 1 atol=0.05
end |
{-# OPTIONS --without-K #-}
{-
Ribbon is the explicit covering space construction.
This construction is given by Daniel Grayson, Favonia (me)
and Guillaume Brunerie together.
-}
open import Base
open import Homotopy.Pointed
-- A is the pointed base space.
-- Y is intended to be a (group-)set,
-- but can be an arbitrarily weird space.
module Homotopy.Cover.Ribbon {i} (A⋆ : pType i) {Y : Set i} where
open pType A⋆ renaming (∣_∣ to A ; ⋆ to a)
open import Homotopy.Truncation
open import Homotopy.PathTruncation
open import Homotopy.HomotopyGroups
open import Algebra.GroupSets (fundamental-group A⋆)
-- The HIT ribbon---reconstructed covering space
private
module Ribbon {act : action Y} where
open action act
private
data #ribbon (a₂ : A) : Set i where
#trace : Y → a ≡₀ a₂ → #ribbon a₂
ribbon : A → Set i
ribbon = #ribbon
-- A point in the fiber a₂.
{-
y is a point in the fiber a, and
p is a path to transport y to fiber a₂.
-}
trace : ∀ {a₂} → Y → a ≡₀ a₂ → ribbon a₂
trace = #trace
{-
A loop based at a can used as a group action
or for concatination. Both should be equivalent.
And after pasting, make the type fiberwise a set.
-}
postulate -- HIT
paste : ∀ {a₂} y loop (p : a ≡₀ a₂)
→ trace (y ∙ loop) p ≡ trace y (loop ∘₀ p)
ribbon-is-set : ∀ a₂ → is-set (ribbon a₂)
-- Standard dependent eliminator
ribbon-rec : ∀ a₂ {j} (P : ribbon a₂ → Set j)
⦃ P-is-set : ∀ r → is-set (P r) ⦄
(trace* : ∀ y p → P (trace y p))
(paste* : ∀ y loop p → transport P (paste y loop p) (trace* (y ∙ loop) p)
≡ trace* y (loop ∘₀ p))
→ (∀ r → P r)
ribbon-rec a₂ P trace* paste* (#trace y p) = trace* y p
-- Standard non-dependent eliminator
ribbon-rec-nondep : ∀ a₂ {j} (P : Set j)
⦃ P-is-set : is-set P ⦄
(trace* : ∀ (y : Y) (p : a ≡₀ a₂) → P)
(paste* : ∀ y (loop : a ≡₀ a) p → trace* (y ∙ loop) p ≡ trace* y (loop ∘₀ p))
→ (ribbon a₂ → P)
ribbon-rec-nondep a₂ P trace* paste* (#trace y p) = trace* y p
open Ribbon public hiding (ribbon)
module _ (act : action Y) where
ribbon : A → Set i
ribbon = Ribbon.ribbon {act}
trans-trace : ∀ {a₁ a₂} (q : a₁ ≡ a₂) y p
→ transport ribbon q (trace y p) ≡ trace y (p ∘₀ proj q)
trans-trace refl y p = ap (trace y) $ ! $ refl₀-right-unit p
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import data.dfinsupp.lex
import order.game_add
import order.antisymmetrization
import set_theory.ordinal.basic
/-!
# Well-foundedness of the lexicographic and product orders on `dfinsupp` and `pi`
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
The primary results are `dfinsupp.lex.well_founded` and the two variants that follow it,
which essentially say that if `(>)` is a well order on `ι`, `(<)` is well-founded on each
`α i`, and `0` is a bottom element in `α i`, then the lexicographic `(<)` is well-founded
on `Π₀ i, α i`. The proof is modelled on the proof of `well_founded.cut_expand`.
The results are used to prove `pi.lex.well_founded` and two variants, which say that if
`ι` is finite and equipped with a linear order and `(<)` is well-founded on each `α i`,
then the lexicographic `(<)` is well-founded on `Π i, α i`, and the same is true for
`Π₀ i, α i` (`dfinsupp.lex.well_founded_of_finite`), because `dfinsupp` is order-isomorphic
to `pi` when `ι` is finite.
Finally, we deduce `dfinsupp.well_founded_lt`, `pi.well_founded_lt`,
`dfinsupp.well_founded_lt_of_finite` and variants, which concern the product order
rather than the lexicographic one. An order on `ι` is not required in these results,
but we deduce them from the well-foundedness of the lexicographic order by choosing
a well order on `ι` so that the product order `(<)` becomes a subrelation
of the lexicographic `(<)`.
All results are provided in two forms whenever possible: a general form where the relations
can be arbitrary (not the `(<)` of a preorder, or not even transitive, etc.) and a specialized
form provided as `well_founded_lt` instances where the `(d)finsupp/pi` type (or their `lex`
type synonyms) carries a natural `(<)`.
Notice that the definition of `dfinsupp.lex` says that `x < y` according to `dfinsupp.lex r s`
iff there exists a coordinate `i : ι` such that `x i < y i` according to `s i`, and at all
`r`-smaller coordinates `j` (i.e. satisfying `r j i`), `x` remains unchanged relative to `y`;
in other words, coordinates `j` such that `¬ r j i` and `j ≠ i` are exactly where changes
can happen arbitrarily. This explains the appearance of `rᶜ ⊓ (≠)` in
`dfinsupp.acc_single` and `dfinsupp.well_founded`. When `r` is trichotomous (e.g. the `(<)`
of a linear order), `¬ r j i ∧ j ≠ i` implies `r i j`, so it suffices to require `r.swap`
to be well-founded.
-/
variables {ι : Type*} {α : ι → Type*}
namespace dfinsupp
variables [hz : Π i, has_zero (α i)] (r : ι → ι → Prop) (s : Π i, α i → α i → Prop)
include hz
open relation prod
/-- This key lemma says that if a finitely supported dependent function `x₀` is obtained by merging
two such functions `x₁` and `x₂`, and if we evolve `x₀` down the `dfinsupp.lex` relation one
step and get `x`, we can always evolve one of `x₁` and `x₂` down the `dfinsupp.lex` relation
one step while keeping the other unchanged, and merge them back (possibly in a different way)
to get back `x`. In other words, the two parts evolve essentially independently under
`dfinsupp.lex`. This is used to show that a function `x` is accessible if
`dfinsupp.single i (x i)` is accessible for each `i` in the (finite) support of `x`
(`dfinsupp.lex.acc_of_single`). -/
lemma lex_fibration [Π i (s : set ι), decidable (i ∈ s)] : fibration
(inv_image (game_add (dfinsupp.lex r s) (dfinsupp.lex r s)) snd)
(dfinsupp.lex r s)
(λ x, piecewise x.2.1 x.2.2 x.1) :=
begin
rintro ⟨p, x₁, x₂⟩ x ⟨i, hr, hs⟩,
simp_rw [piecewise_apply] at hs hr,
split_ifs at hs, classical,
work_on_goal 1
{ refine ⟨⟨{j | r j i → j ∈ p}, piecewise x₁ x {j | r j i}, x₂⟩, game_add.fst ⟨i, _⟩, _⟩ },
work_on_goal 3
{ refine ⟨⟨{j | r j i ∧ j ∈ p}, x₁, piecewise x₂ x {j | r j i}⟩, game_add.snd ⟨i, _⟩, _⟩ },
swap 3, iterate 2
{ simp_rw piecewise_apply,
refine ⟨λ j h, if_pos h, _⟩,
convert hs,
refine ite_eq_right_iff.2 (λ h', (hr i h').symm ▸ _),
rw if_neg h <|> rw if_pos h },
all_goals { ext j, simp_rw piecewise_apply, split_ifs with h₁ h₂ },
{ rw [hr j h₂, if_pos (h₁ h₂)] },
{ refl },
{ rw [set.mem_set_of, not_imp] at h₁, rw [hr j h₁.1, if_neg h₁.2] },
{ rw [hr j h₁.1, if_pos h₁.2] },
{ rw [hr j h₂, if_neg (λ h', h₁ ⟨h₂, h'⟩)] },
{ refl },
end
variables {r s}
lemma lex.acc_of_single_erase [decidable_eq ι] {x : Π₀ i, α i} (i : ι)
(hs : acc (dfinsupp.lex r s) $ single i (x i))
(hu : acc (dfinsupp.lex r s) $ x.erase i) : acc (dfinsupp.lex r s) x :=
begin
classical,
convert ← @acc.of_fibration _ _ _ _ _
(lex_fibration r s) ⟨{i}, _⟩ (inv_image.accessible snd $ hs.prod_game_add hu),
convert piecewise_single_erase x i,
end
variable (hbot : ∀ ⦃i a⦄, ¬ s i a 0)
include hbot
lemma lex.acc_zero : acc (dfinsupp.lex r s) 0 := acc.intro 0 $ λ x ⟨_, _, h⟩, (hbot h).elim
lemma lex.acc_of_single [decidable_eq ι] [Π i (x : α i), decidable (x ≠ 0)] (x : Π₀ i, α i) :
(∀ i ∈ x.support, acc (dfinsupp.lex r s) $ single i (x i)) → acc (dfinsupp.lex r s) x :=
begin
generalize ht : x.support = t, revert x, classical,
induction t using finset.induction with b t hb ih,
{ intros x ht, rw support_eq_empty.1 ht, exact λ _, lex.acc_zero hbot },
refine λ x ht h, lex.acc_of_single_erase b (h b $ t.mem_insert_self b) _,
refine ih _ (by rw [support_erase, ht, finset.erase_insert hb]) (λ a ha, _),
rw [erase_ne (ha.ne_of_not_mem hb)],
exact h a (finset.mem_insert_of_mem ha),
end
variable (hs : ∀ i, well_founded (s i))
include hs
lemma lex.acc_single [decidable_eq ι] {i : ι} (hi : acc (rᶜ ⊓ (≠)) i) :
∀ a, acc (dfinsupp.lex r s) (single i a) :=
begin
induction hi with i hi ih,
refine λ a, (hs i).induction a (λ a ha, _),
refine acc.intro _ (λ x, _),
rintro ⟨k, hr, hs⟩, classical,
rw single_apply at hs,
split_ifs at hs with hik,
swap, { exact (hbot hs).elim }, subst hik,
refine lex.acc_of_single hbot x (λ j hj, _),
obtain rfl | hij := eq_or_ne i j, { exact ha _ hs },
by_cases r j i,
{ rw [hr j h, single_eq_of_ne hij, single_zero], exact lex.acc_zero hbot },
{ exact ih _ ⟨h, hij.symm⟩ _ },
end
lemma lex.acc [decidable_eq ι] [Π i (x : α i), decidable (x ≠ 0)] (x : Π₀ i, α i)
(h : ∀ i ∈ x.support, acc (rᶜ ⊓ (≠)) i) : acc (dfinsupp.lex r s) x :=
lex.acc_of_single hbot x $ λ i hi, lex.acc_single hbot hs (h i hi) _
theorem lex.well_founded (hr : well_founded $ rᶜ ⊓ (≠)) : well_founded (dfinsupp.lex r s) :=
⟨λ x, by classical; exact lex.acc hbot hs x (λ i _, hr.apply i)⟩
theorem lex.well_founded' [is_trichotomous ι r]
(hr : well_founded r.swap) : well_founded (dfinsupp.lex r s) :=
lex.well_founded hbot hs $ subrelation.wf
(λ i j h, ((@is_trichotomous.trichotomous ι r _ i j).resolve_left h.1).resolve_left h.2) hr
omit hz hbot hs
instance lex.well_founded_lt [has_lt ι] [is_trichotomous ι (<)]
[hι : well_founded_gt ι] [Π i, canonically_ordered_add_monoid (α i)]
[hα : ∀ i, well_founded_lt (α i)] : well_founded_lt (lex (Π₀ i, α i)) :=
⟨lex.well_founded' (λ i a, (zero_le a).not_lt) (λ i, (hα i).wf) hι.wf⟩
end dfinsupp
open dfinsupp
variables (r : ι → ι → Prop) {s : Π i, α i → α i → Prop}
theorem pi.lex.well_founded [is_strict_total_order ι r] [finite ι]
(hs : ∀ i, well_founded (s i)) : well_founded (pi.lex r s) :=
begin
obtain h | ⟨⟨x⟩⟩ := is_empty_or_nonempty (Π i, α i),
{ convert empty_wf, ext1 x, exact (h.1 x).elim },
letI : Π i, has_zero (α i) := λ i, ⟨(hs i).min ⊤ ⟨x i, trivial⟩⟩,
haveI := is_trans.swap r, haveI := is_irrefl.swap r, haveI := fintype.of_finite ι,
refine inv_image.wf equiv_fun_on_fintype.symm (lex.well_founded' (λ i a, _) hs _),
exacts [(hs i).not_lt_min ⊤ _ trivial, finite.well_founded_of_trans_of_irrefl r.swap],
end
instance pi.lex.well_founded_lt [linear_order ι] [finite ι] [Π i, has_lt (α i)]
[hwf : ∀ i, well_founded_lt (α i)] : well_founded_lt (lex (Π i, α i)) :=
⟨pi.lex.well_founded (<) (λ i, (hwf i).1)⟩
instance function.lex.well_founded_lt {α} [linear_order ι] [finite ι] [has_lt α]
[well_founded_lt α] : well_founded_lt (lex (ι → α)) := pi.lex.well_founded_lt
theorem dfinsupp.lex.well_founded_of_finite [is_strict_total_order ι r] [finite ι]
[Π i, has_zero (α i)] (hs : ∀ i, well_founded (s i)) : well_founded (dfinsupp.lex r s) :=
have _ := fintype.of_finite ι,
by exactI inv_image.wf equiv_fun_on_fintype (pi.lex.well_founded r hs)
instance dfinsupp.lex.well_founded_lt_of_finite [linear_order ι] [finite ι] [Π i, has_zero (α i)]
[Π i, has_lt (α i)] [hwf : ∀ i, well_founded_lt (α i)] : well_founded_lt (lex (Π₀ i, α i)) :=
⟨dfinsupp.lex.well_founded_of_finite (<) $ λ i, (hwf i).1⟩
protected theorem dfinsupp.well_founded_lt [Π i, has_zero (α i)] [Π i, preorder (α i)]
[∀ i, well_founded_lt (α i)] (hbot : ∀ ⦃i⦄ ⦃a : α i⦄, ¬ a < 0) : well_founded_lt (Π₀ i, α i) :=
⟨begin
letI : Π i, has_zero (antisymmetrization (α i) (≤)) := λ i, ⟨to_antisymmetrization (≤) 0⟩,
let f := map_range (λ i, @to_antisymmetrization (α i) (≤) _) (λ i, rfl),
refine subrelation.wf (λ x y h, _) (inv_image.wf f $ lex.well_founded' _ (λ i, _) _),
{ exact well_ordering_rel.swap }, { exact λ i, (<) },
{ haveI := is_strict_order.swap (@well_ordering_rel ι),
obtain ⟨i, he, hl⟩ := lex_lt_of_lt_of_preorder well_ordering_rel.swap h,
exact ⟨i, λ j hj, quot.sound (he j hj), hl⟩ },
{ rintro i ⟨a⟩, apply hbot },
exacts [is_well_founded.wf, is_trichotomous.swap _, is_well_founded.wf],
end⟩
instance dfinsupp.well_founded_lt' [Π i, canonically_ordered_add_monoid (α i)]
[∀ i, well_founded_lt (α i)] : well_founded_lt (Π₀ i, α i) :=
dfinsupp.well_founded_lt $ λ i a, (zero_le a).not_lt
instance pi.well_founded_lt [finite ι] [Π i, preorder (α i)]
[hw : ∀ i, well_founded_lt (α i)] : well_founded_lt (Π i, α i) :=
⟨begin
obtain h | ⟨⟨x⟩⟩ := is_empty_or_nonempty (Π i, α i),
{ convert empty_wf, ext1 x, exact (h.1 x).elim },
letI : Π i, has_zero (α i) := λ i, ⟨(hw i).wf.min ⊤ ⟨x i, trivial⟩⟩,
haveI := fintype.of_finite ι,
refine inv_image.wf equiv_fun_on_fintype.symm (dfinsupp.well_founded_lt $ λ i a, _).wf,
exact (hw i).wf.not_lt_min ⊤ _ trivial,
end⟩
instance function.well_founded_lt {α} [finite ι] [preorder α]
[well_founded_lt α] : well_founded_lt (ι → α) := pi.well_founded_lt
instance dfinsupp.well_founded_lt_of_finite [finite ι] [Π i, has_zero (α i)] [Π i, preorder (α i)]
[∀ i, well_founded_lt (α i)] : well_founded_lt (Π₀ i, α i) :=
have _ := fintype.of_finite ι,
by exactI ⟨inv_image.wf equiv_fun_on_fintype pi.well_founded_lt.wf⟩
|
theory Reactive
imports Temporal Refinement
begin
section{*Reactive Systems*}
(*declare [[show_types]]*)
text{*
In this section we introduce reactive systems which are modeled as
monotonic property transformers where properties are predicates on
traces. We start with introducing some examples that uses LTL to
specify global behaviour on traces, and later we introduce property
transformers based on symbolic transition systems.
*}
definition "HAVOC = [:x \<leadsto> y . True:]"
definition "ASSERT_LIVE = {. \<box> \<diamondsuit> (\<lambda> x . x 0).}"
definition "GUARANTY_LIVE = [:x \<leadsto> y . \<box> \<diamondsuit> (\<lambda> y . y 0):]"
definition "AE = ASSERT_LIVE o HAVOC"
definition "SKIP = [:x \<leadsto> y . x = y:]"
definition "REQ_RESP = [: \<box>(\<lambda> xs ys . xs (0::nat) \<longrightarrow> (\<diamondsuit> (\<lambda> ys . ys (0::nat))) ys) :]"
definition "FAIL = \<bottom>"
lemma "HAVOC o ASSERT_LIVE = FAIL"
by (auto simp add: HAVOC_def AE_def FAIL_def ASSERT_LIVE_def fun_eq_iff assert_def demonic_def always_def at_fun_def le_fun_def eventually_def)
lemma "HAVOC o AE = FAIL"
by (auto simp add: HAVOC_def AE_def FAIL_def ASSERT_LIVE_def fun_eq_iff assert_def demonic_def always_def at_fun_def le_fun_def eventually_def)
lemma "HAVOC o ASSERT_LIVE = FAIL"
by (auto simp add: HAVOC_def AE_def FAIL_def ASSERT_LIVE_def fun_eq_iff assert_def demonic_def always_def at_fun_def eventually_def)
lemma "SKIP o AE = AE"
by simp
lemma "(REQ_RESP o AE) = AE"
proof (auto simp add: fun_eq_iff HAVOC_def AE_def FAIL_def REQ_RESP_def ASSERT_LIVE_def assert_def
demonic_def always_def le_fun_def eventually_def at_fun_def)
fix x :: "'a \<Rightarrow> bool"
fix xa :: "nat \<Rightarrow> bool"
fix xb :: nat
assume "\<forall>xb::nat \<Rightarrow> bool . (\<forall>x. xa x \<longrightarrow> Ex (xb[x ..])) \<longrightarrow> (\<forall>x. \<exists>a. xb (x + a)) \<and> All x"
then have "(\<forall>x. xa x \<longrightarrow> Ex (xa[x ..])) \<longrightarrow> (\<forall>x. \<exists>a. xa (x + a)) \<and> All x"
by auto
then show "\<exists>x. xa (xb + x)"
by (auto, rule_tac x = 0 in exI, simp)
next
fix x :: "'a \<Rightarrow> bool"
fix xa :: "nat \<Rightarrow> bool"
fix xb :: 'a
assume "\<forall>xb::nat \<Rightarrow> bool . (\<forall>x. xa x \<longrightarrow> Ex (xb[x ..])) \<longrightarrow> (\<forall>x. \<exists>a. xb (x + a)) \<and> All x"
from this show "x xb"
by (metis at_trace_def le0)
next
fix x :: "'a \<Rightarrow> bool" and xa :: "nat \<Rightarrow> bool" and xb :: "nat \<Rightarrow> bool" and xc :: nat
assume A: "\<forall>x. xa x \<longrightarrow> Ex (xb[x ..])"
assume B: "\<forall>x. \<exists>xb. xa (x + xb)"
have "\<exists>x1. xc \<le> AbsNat x1" by (metis (full_types) le_add2 plus_Nat_def)
thus "\<exists>x. xb (xc + x)" using A B by (metis AbsNat_plus add.commute at_trace_def le_Suc_ex trans_le_add2)
qed
subsection{*Symbolic transition systems*}
text{*
In this section we introduce property transformers basend on symbolic
transition systems. These are systems with local state. The execution
starts in some initial state, and with some input value the system computes
a new state and an output value. Then using the current state, and a
new input value the system computes a new state, and a new output, and
so on. The system may fail if at some point the input and the current
state do not statisfy a required predicate.
In the folowing definitions the variables $u$, $x$, $y$ stand for the
state of the system, the input, and the output respectively. The $init$
is the property that the initial state should satisfy. The predicate
$p$ is the precondition of the input and the current state, and the
relation $r$ gives the next state and the output based on the
input and the current state.
*}
definition "fail_sys init p r x = (\<exists> n u y . u \<in> init \<and> (\<forall> i < n . r (u i) (u (Suc i)) (x i) (y i)) \<and> (\<not> p (u n) (u (Suc n)) (x n)))"
definition "run r u x y = (\<forall> i . r (u i) (u (Suc i)) (x i) (y i))"
definition "LocalSystem init p r q x = (\<not> fail_sys init p r x \<and> (\<forall> u y . (u \<in> init \<and> run r u x y) \<longrightarrow> q y))"
lemma "fail (LocalSystem init p r) = fail_sys init p r"
by (simp add: fun_eq_iff LocalSystem_def fail_def fail_sys_def run_def)
definition "inpt_st r u u' x = (\<exists> y . r u u' x y)"
definition "lft_pred_st p u x = p (u (0::nat)) (u 1) (x (0::nat))"
definition "lft_pred_loc_st p u x = p (u (0::nat)) (x (0::nat))"
definition "lft_rel_st r u x y = r (u (0::nat)) (u 1) (x (0::nat)) (y (0::nat))"
definition "prec_st p r = -((lft_pred_st (inpt_st r)) until -(lft_pred_st p))"
lemma prec_st_simp: "prec_st p r u x = (\<forall> n . (\<forall> i < n . inpt_st r (u i) (u (Suc i)) (x i)) \<longrightarrow> p (u n) (u (Suc n)) (x n))"
by (simp add: prec_st_def until_def lft_pred_st_def inpt_st_def at_fun_def, metis)
definition "SymSystem init p r = [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . prec_st p r u x.} o
[:u, x \<leadsto> y . (\<box> (lft_rel_st r)) u x y :]"
lemma SymSystem_rel: "SymSystem init p r = {. x . \<forall>u. u \<in> init \<longrightarrow> prec_st p r u x .} \<circ>
[: x \<leadsto> y . \<exists> u . u \<in> init \<and> (\<box> lft_rel_st r) u x y :] "
proof -
have [simp]: "((\<lambda>z (u, x). u \<in> init \<and> z = x) OO (\<lambda>(x, y). (\<box> lft_rel_st r) x y)) = (\<lambda>x y. \<exists>u. u \<in> init \<and> (\<box> lft_rel_st r) u x y)"
by auto
show ?thesis by (simp add: SymSystem_def demonic_assert_comp comp_assoc demonic_demonic)
qed
theorem "SymSystem init p r q x = LocalSystem init p r q x"
proof
assume "SymSystem init p r q x"
then show "LocalSystem init p r q x"
apply (auto simp add: SymSystem_def LocalSystem_def assert_def
demonic_def prec_st_simp lft_rel_st_def lft_pred_st_def inpt_st_def
always_def le_fun_def fail_sys_def run_def at_fun_def)
by metis
next
assume "LocalSystem init p r q x"
then show "SymSystem init p r q x"
apply (auto simp add: SymSystem_def LocalSystem_def assert_def
demonic_def prec_st_simp lft_rel_st_def lft_pred_st_def inpt_st_def
always_def le_fun_def fail_sys_def run_def at_fun_def)
by metis
qed
definition "local_init init S = INFIMUM init S"
definition "zip_set A B = {u . ((fst o u) \<in> A) \<and> ((snd o u) \<in> B)}"
definition nzip:: "('x \<Rightarrow> 'a) \<Rightarrow> ('x \<Rightarrow> 'b) \<Rightarrow> 'x \<Rightarrow> ('a\<times>'b)" (infixl "||" 65) where "(xs || ys) i = (xs i, ys i)"
lemma [simp]: "fst \<circ> x || y = x"
by (simp add: fun_eq_iff nzip_def)
lemma [simp]: "snd \<circ> x || y = y"
by (simp add: fun_eq_iff nzip_def)
lemma [simp]: "x \<in> A \<Longrightarrow> y \<in> B \<Longrightarrow> (x || y) \<in> zip_set A B"
by (simp add: zip_set_def)
lemma local_demonic_init: "local_init init (\<lambda> u . {. x . p u x.} o [:x \<leadsto> y . r u x y :]) =
[:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . p u x.} o [:u, x \<leadsto> y . r u x y :]"
by (auto simp add: fun_eq_iff demonic_def assert_def local_init_def le_fun_def)
lemma local_init_comp: "u' \<in> init' \<Longrightarrow> (\<forall> u. sconjunctive (S u)) \<Longrightarrow> (local_init init S) o (local_init init' S')
= local_init (zip_set init init') (\<lambda> u . (S (fst o u)) o (S' (snd o u)))"
proof (subst fun_eq_iff, auto)
fix x :: 'f
assume A: "u' \<in> init'"
assume "\<forall> u . sconjunctive (S u)"
from this have [simp]: "\<And> u . sconjunctive (S u)" by simp
from A have [simp]: "\<And> y . S y (INF y' : init'. S' y' x) = (INF y' : init' . S y (S' y' x))"
by (simp add: sconjunctive_INF_simp)
have [simp]: "(INF y : init . (INF y' : init' . S y (S' y' x))) \<le> (INF u : zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x))"
proof (rule INF_greatest, auto simp add: zip_set_def)
fix u :: "'a \<Rightarrow> 'c \<times> 'b"
assume [simp]: "fst \<circ> u \<in> init"
assume [simp]: "snd \<circ> u \<in> init'"
have "(INF y : init. INF y' : init'. S y (S' y' x)) \<le> (INF y' : init'. S (fst o u) (S' y' x))"
by (rule INF_lower, simp)
also have "... \<le> S (fst o u) (S' (snd o u) x)"
by (rule INF_lower, simp)
finally show "(INF y : init. INF y' : init'. S y (S' y' x)) \<le> S (fst o u) (S' (snd o u) x)"
by simp
qed
have [simp]: "(INF u : zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x)) \<le> (INF y : init . (INF y' : init' . S y (S' y' x)))"
proof (rule INF_greatest, rule INF_greatest)
fix y :: "'a \<Rightarrow> 'c" and y':: "'a \<Rightarrow> 'b"
assume [simp]: "y \<in> init"
assume [simp]: "y' \<in> init'"
have "(INF u : zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x)) \<le> S (fst o (y || y')) (S' (snd o (y || y')) x)"
by (rule INF_lower, simp)
also have "... \<le> S y (S' y' x)"
by simp
finally show "(INF u\<Colon>'a \<Rightarrow> 'c \<times> 'b:zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x)) \<le> S y (S' y' x)"
by simp
qed
have "local_init init S (local_init init' S' x) = (INF y : init. S y (INF y' : init'. S' y' x)) "
by (simp add: local_init_def)
also have "... = (INF y : init . (INF y' : init' . S y (S' y' x)))"
by simp
also have "... = (INF u : zip_set init init'. S (fst \<circ> u) \<circ> S' (snd \<circ> u)) x"
by (rule antisym, auto)
also have "... = local_init (zip_set init init') (\<lambda> u . (S (fst o u)) o (S' (snd o u))) x"
by (simp add: local_init_def)
finally show "local_init init S (local_init init' S' x) = local_init (zip_set init init') (\<lambda>u\<Colon>'a \<Rightarrow> 'c \<times> 'b. S (fst \<circ> u) \<circ> S' (snd \<circ> u)) x"
by simp
qed
lemma init_state: "[:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . p u x.} o [:u, x \<leadsto> y . r u x y :]
= [:z \<leadsto> u, x . z = x:] o {.u, x . u \<in> init \<longrightarrow> p u x.} o [:u, x \<leadsto> y . u \<in> init \<and> r u x y :]"
by (auto simp add: fun_eq_iff demonic_def assert_def local_init_def le_fun_def)
lemma always_lft_rel_comp: "(\<box> lft_rel_st r) (fst \<circ> u) OO (\<box> lft_rel_st r') (snd \<circ> u)
= (\<box> lft_rel_st (\<lambda> (u, v) (u', v') . ((r u u') OO (r' v v')))) u"
proof (auto simp add: fun_eq_iff lft_rel_st_def always_def at_fun_def relcompp_exists)
fix x::"nat \<Rightarrow>'a" and
y::"nat \<Rightarrow> 'b" and
v::"nat \<Rightarrow> 'c" and
n:: nat
assume "\<forall>i . r (fst (u i)) (fst (u (Suc i))) (x i) (v i)"
and "\<forall>i . r' (snd (u i)) (snd (u (Suc i))) (v i) (y i)"
from this show "(case u n of (u, v) \<Rightarrow> \<lambda>(u', v'). r u u' OO r' v v') (u (Suc n)) (x n) (y n)"
by (metis (mono_tags, lifting) prod.case_eq_if relcompp.relcompI)
next
fix x::"nat \<Rightarrow>'a" and
z::"nat \<Rightarrow> 'b"
def A: a == "(\<lambda> n . SOME y . r (fst (u n)) (fst (u (Suc n))) (x n) y \<and> r' (snd (u n)) (snd (u (Suc n))) y (z n))"
assume "\<forall>i . (case u i of (u, v) \<Rightarrow> \<lambda>(u', v'). r u u' OO r' v v') (u (Suc i)) (x i) (z i)"
from this and A have "(\<forall>i :: nat. r (fst (u i)) (fst (u (Suc i))) (x i) (a i)) \<and> (\<forall>i :: nat. r' (snd (u i)) (snd (u (Suc i))) (a i) (z i))"
apply auto
apply (metis (mono_tags, lifting) pick_middlep prod.collapse split_conv tfl_some)
by (metis (mono_tags, lifting) pick_middlep prod.collapse split_conv tfl_some)
from this show "\<exists> a . (\<forall>i . r (fst (u i)) (fst (u (Suc i))) (x i) (a i)) \<and> (\<forall>i . r' (snd (u i)) (snd (u (Suc i))) (a i) (z i))"
by blast
qed
theorem SymSystem_comp: "u' \<in> init' \<Longrightarrow> SymSystem init p r o SymSystem init' p' r'
= [:z \<leadsto> u, x . fst o u \<in> init \<and> snd o u \<in> init' \<and> z = x:]
o {. u, x . prec_st p r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st p' r' (snd \<circ> u) y) .}
o [: u, x \<leadsto> y . (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u x y :]"
(is "?p \<Longrightarrow> ?S = ?T")
proof -
assume A: "?p"
have "?S =
[: z \<leadsto> (u, x) . u \<in> init \<and> z = x :] \<circ> {.x, y. prec_st p r x y.} \<circ>
[: id (\<lambda>(u, x). id ((\<box> lft_rel_st r) u x)) :] \<circ>
([: z \<leadsto> u, x . u \<in> init' \<and> z = x :] \<circ> {.x, y. prec_st p' r' x y.} \<circ>
[: id (\<lambda>(u, x). id ((\<box> lft_rel_st r') u x)) :])"
by (unfold SymSystem_def, simp)
also have "... = local_init init (\<lambda>u\<Colon>nat \<Rightarrow> 'e. {. id (prec_st p r u) .} \<circ> [: id (\<lambda>x. id ((\<box> lft_rel_st r) u x)) :]) \<circ>
local_init init' (\<lambda>u. {. id (prec_st p' r' u) .} \<circ> [: id (\<lambda>x\<Colon>nat \<Rightarrow> 'd. id ((\<box> lft_rel_st r') u x)) :])"
by (unfold local_demonic_init [THEN sym], simp)
also from A have "... = local_init (zip_set init init')
(\<lambda>u. {. prec_st p r (fst \<circ> u) .} \<circ> [: (\<box> lft_rel_st r) (fst \<circ> u) :] \<circ> ({. prec_st p' r' (snd \<circ> u) .} \<circ> [: (\<box> lft_rel_st r') (snd \<circ> u) :]))"
by (simp add: local_init_comp)
also have " ... = local_init (zip_set init init')
(\<lambda>u. {. prec_st p r (fst \<circ> u) .} \<circ> [: (\<box> lft_rel_st r) (fst \<circ> u) :] \<circ> {. prec_st p' r' (snd \<circ> u) .} \<circ> [: (\<box> lft_rel_st r') (snd \<circ> u) :])"
by (simp add: comp_assoc [THEN sym])
also have "... = local_init (zip_set init init')
(\<lambda>u.{. x . prec_st p r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st p' r' (snd \<circ> u) y) .} \<circ>
[: (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u :]) "
by (simp add: assert_demonic_comp always_lft_rel_comp)
also have "... = local_init (zip_set init init')
(\<lambda>u.{.x. prec_st p r (fst \<circ> u) x \<and> (\<forall>y\<Colon>nat \<Rightarrow> 'd. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st p' r' (snd \<circ> u) y).} \<circ>
[: id (\<lambda>x\<Colon>nat \<Rightarrow> 'c. id ((\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u x)) :])"
by simp
also have "... = ?T"
by (unfold local_demonic_init, simp add: zip_set_def)
finally show ?thesis by simp
qed
lemma always_lft_rel_comp_a: "(\<box> lft_rel_st r) u OO (\<box> lft_rel_st r') v
= (\<box> lft_rel_st (\<lambda> (u, v) (u', v') . ((r u u') OO (r' v v')))) (u || v)"
by (unfold always_lft_rel_comp [THEN sym], auto)
theorem SymSystem_comp_a: "u' \<in> init' \<Longrightarrow> SymSystem init p r o SymSystem init' p' r'
= {.x . \<forall> u v . u \<in> init \<and> v \<in> init' \<longrightarrow> (prec_st p r u x \<and> (\<forall>y. (\<box> lft_rel_st r) u x y \<longrightarrow> prec_st p' r' v y)) .}
o [: x \<leadsto> y . \<exists> u v . u \<in> init \<and> v \<in> init' \<and> (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) (u || v) x y :]"
(is "?p \<Longrightarrow> ?S = ?T")
proof -
assume A: "u' \<in> init'"
from A have [simp]: "(\<lambda>x. (\<forall>u. u \<in> init \<longrightarrow> prec_st p r u x) \<and> (\<forall>y. (\<exists>u. u \<in> init \<and> (\<box> lft_rel_st r) u x y) \<longrightarrow> (\<forall>u. u \<in> init' \<longrightarrow> prec_st p' r' u y)))
= (\<lambda>x. \<forall>u v. u \<in> init \<and> v \<in> init' \<longrightarrow> prec_st p r u x \<and> (\<forall>y. (\<box> lft_rel_st r) u x y \<longrightarrow> prec_st p' r' v y))"
by (auto simp add: fun_eq_iff)
have [simp]: "(\<lambda>x y. \<exists>u. u \<in> init \<and> (\<box> lft_rel_st r) u x y) OO (\<lambda>x y. \<exists>u. u \<in> init' \<and> (\<box> lft_rel_st r') u x y)
= (\<lambda> x y . \<exists> u v . u \<in> init \<and> v \<in> init' \<and> (((\<box> lft_rel_st r) u) OO ((\<box> lft_rel_st r') v)) x y)"
by (auto simp add: fun_eq_iff)
from A have "?S = {.x . \<forall>u . u \<in> init \<longrightarrow> prec_st p r u x.} \<circ>
[: x \<leadsto> y . \<exists>u\<Colon>nat \<Rightarrow> 'e. u \<in> init \<and> (\<box> lft_rel_st r) u x y :] \<circ>
({.x. \<forall>u . u \<in> init' \<longrightarrow> prec_st p' r' u x.} \<circ> [: x \<leadsto> y . \<exists>u . u \<in> init' \<and> (\<box> lft_rel_st r') u x y :])"
by (simp add: SymSystem_rel)
also have "... = {. \<lambda>x . \<forall>u . u \<in> init \<longrightarrow> prec_st p r u x .} \<circ> [: x \<leadsto> y . \<exists>u . u \<in> init \<and> (\<box> lft_rel_st r) u x y :] \<circ>
{. x . \<forall>u . u \<in> init' \<longrightarrow> prec_st p' r' u x .} \<circ> [: x \<leadsto> y . \<exists>u . u \<in> init' \<and> (\<box> lft_rel_st r') u x y :]"
by (simp add: comp_assoc [THEN sym])
also have "... = ?T"
by (simp add: assert_demonic_comp always_lft_rel_comp_a)
finally show ?thesis
by simp
qed
text{*We show next that the composition of two SymSystem $S$ and $S'$ is not equal to the SymSystem of the
compostion of local transitions of $S$ and $S'$*}
definition "initS = {u . fst (u (0::nat)) = (0::nat)}"
definition "localPrecS = (\<top>:: nat \<times> nat \<Rightarrow> nat \<times> nat \<Rightarrow> nat \<Rightarrow> bool)"
definition "localRelS = (\<lambda> (u::nat, v) (u', v'::nat) (x::nat) (y::nat) . u = 0 \<and> u' = 1 \<and> v = v')"
definition "initS' = (\<top>::(nat \<Rightarrow> (nat \<times> nat)) set)"
definition "localPrecS' = (\<bottom>:: nat \<times> nat \<Rightarrow> nat \<times> nat \<Rightarrow> nat \<Rightarrow> bool)"
definition "localRelS' = (\<lambda> (u::nat, v) (u', v'::nat) (x::nat) (y::nat) . u = u')"
definition "symbS = SymSystem initS localPrecS localRelS"
definition "symbS' = SymSystem initS' localPrecS' localRelS'"
definition "localPrecSS' = (\<lambda>(u::nat, v::nat) (u', v') (x::nat) . 0 < u)"
definition "localRelSS' = (\<lambda> (u, v::nat) (u'::nat, v'::nat) (x::nat) (z::nat) . (u::nat) = 0 \<and> u' = 1)"
lemma localSS'_aux: "( \<lambda>x. \<forall> (a::nat) (aa::nat) (b::nat). \<not> (case x of (x::nat, u::nat, v::nat) \<Rightarrow> \<lambda>ab. u = 0 \<and>
(case ab of (y, u', v') \<Rightarrow> u' = Suc 0 \<and> v = v')) (a, aa, b))
= (\<lambda> (x, u, v) . u > 0)"
by (auto simp add: fun_eq_iff)
lemma localSS'_aux_b: "((\<lambda>(x, u, v) ab. u = 0 \<and> (case ab of (y, u', v') \<Rightarrow> u' = Suc 0 \<and> v = v')) OO (\<lambda>(x, u, v) (y, u', v'). u = u'))
= (\<lambda> (x, u, v) (y, u', v') . u = 0 \<and> u' = 1)"
by (simp add: fun_eq_iff relcompp_exists)
lemma "{.x, (u, v) . localPrecS (u, v) (a,b) x.} o [:x, (u,v) \<leadsto> y, (u',v') . localRelS (u,v) (u',v') x y:] o
{.x, (u, v) . localPrecS' (u, v) (c, d) x.} o [:x, (u,v) \<leadsto> y, (u',v') . localRelS' (u,v) (u',v') x y:]
= {.x, (u, v) . localPrecSS' (u, v) (e, f) x.} o [:x, (u,v) \<leadsto> y, (u',v') . localRelSS' (u,v) (u',v') x y:]"
by (simp add: assert_demonic_comp localPrecS'_def localPrecS_def localRelS_def localRelS'_def
relcompp_exists localPrecSS'_def localRelSS'_def localSS'_aux localSS'_aux_b)
lemma [simp]: "[: \<bottom>::('a \<Rightarrow> 'b => ('c::boolean_algebra)) :] = \<top>"
by (simp add: fun_eq_iff demonic_def)
definition "symbSS' = SymSystem initS localPrecSS' localRelSS'"
lemma symbSS'_aux: "( \<lambda>x. \<forall>u. fst (u 0) = 0 \<longrightarrow>
(\<forall>n. (\<forall>i<n. Ex ((case u i of (u, v) \<Rightarrow> \<lambda>(u', v'::nat) x z. u = 0 \<and> u' = Suc 0) (u (Suc i)) (x i)))
\<longrightarrow> (case u n of (u, v) \<Rightarrow> \<lambda>(u', v') x. 0 < u) (u (Suc n)) (x n)) ) = \<bottom>"
apply (auto simp add: fun_eq_iff)
by (rule_tac x = "\<lambda> i . (i::nat, i)" in exI, simp)
lemma symbSS': "symbSS' = \<bottom>"
by (simp add: symbSS'_def SymSystem_rel initS_def localPrecSS'_def localRelSS'_def prec_st_simp inpt_st_def symbSS'_aux)
lemma symbS: "symbS = \<top>"
proof (simp add: symbS_def SymSystem_rel initS_def localPrecS_def localRelS_def)
have [simp]: "(\<lambda>x. \<forall>u. fst (u 0) = 0 \<longrightarrow> prec_st \<top> (\<lambda> (u, v) (u', v') x y . u = 0 \<and> u' = Suc 0 \<and> v = v') u x) = \<top>"
by (simp_all add: fun_eq_iff prec_st_def always_def lft_rel_st_def at_fun_def lft_pred_st_def inpt_st_def until_def)
have [simp]: "(\<lambda>x y. \<exists>u. fst (u 0) = 0 \<and> (\<box> lft_rel_st (\<lambda> (u, v) (u', v') (x) (y). u = 0 \<and> u' = Suc 0 \<and> v = v')) u x y) = \<bottom>"
proof (auto simp add: fun_eq_iff always_def lft_rel_st_def at_fun_def)
fix x::"nat \<Rightarrow> 'a" and xa :: "nat \<Rightarrow> 'b" and u::"nat \<Rightarrow> nat \<times> 'c"
assume A: "\<forall>a . (case u a of (e, f) \<Rightarrow> \<lambda>(u', v') x y. e = 0 \<and> u' = Suc 0 \<and> f = v') (u (Suc a)) (x a) (xa a)"
{fix n:: nat
from A have "fst (u n) = 0 \<and> fst (u (Suc n)) = Suc 0"
by (drule_tac x = n in spec, case_tac "u n", case_tac "u (Suc n)", auto)
}
note B = this
then have "fst (u (Suc 0)) = 0" by auto
moreover have "fst (u (Suc 0)) = Suc 0" by (cut_tac n2 = 0 in B, auto)
ultimately show "(0) < fst (u (0))" by auto
qed
show "{. \<lambda>x. \<forall>u. fst (u 0) = 0 \<longrightarrow> prec_st \<top> (\<lambda>(u, v) (u', v') x y. u = 0 \<and> u' = Suc 0 \<and> v = v') u x .} \<circ>
[: \<lambda> x y . \<exists>u . fst (u 0) = 0 \<and> (\<box> lft_rel_st (\<lambda>(u, v) (u', v') x y. u = 0 \<and> u' = Suc 0 \<and> v = v')) u x y :] =
\<top>"
by simp
qed
lemma "symbS o symbS' \<noteq> symbSS'"
by (simp add: symbSS' symbS fun_eq_iff)
lemma prec_st_inpt: "prec_st (inpt_st r) r = (\<box> (lft_pred_st (inpt_st r)))"
by (simp add: prec_st_def neg_until_always)
lemma "grd (SymSystem init p r) = SUPREMUM init (-prec_st p r \<squnion> (\<box> (lft_pred_st (inpt_st r))))"
proof (unfold fun_eq_iff, auto simp add: grd_def SymSystem_rel demonic_def assert_def)
fix x :: "nat \<Rightarrow> 'a" and xa :: "nat \<Rightarrow> 'b" and u :: "nat \<Rightarrow> 'c"
assume "\<forall>xa\<Colon>nat \<Rightarrow> 'c\<in>init. prec_st p r xa x \<and> \<not> (\<box> lft_pred_st (inpt_st r)) xa x"
and "u \<in> init"
and "(\<box> lft_rel_st r) u x xa"
then show "False"
by (auto simp add: always_def lft_pred_st_def inpt_st_def at_fun_def lft_rel_st_def)
next
fix x :: "nat \<Rightarrow> 'a" and xa :: "nat \<Rightarrow> 'c"
assume B: "xa \<in> init"
assume "(\<lambda>y . \<exists>u . u \<in> init \<and> (\<box> lft_rel_st r) u x y) \<le> \<bottom>"
then have A: "\<forall> y u . u \<notin> init \<or> \<not> (\<box> lft_rel_st r) u x y"
by auto
let ?y = "\<lambda> n . (SOME z . r (xa n) (xa (Suc n)) (x n) z)"
from B and A have "\<not> (\<box> lft_rel_st r) xa x ?y" by simp
moreover assume "(\<box> lft_pred_st (inpt_st r)) xa x"
ultimately show "False"
apply (simp add: always_def lft_pred_st_def inpt_st_def at_fun_def lft_rel_st_def)
by (metis (full_types) tfl_some)
qed
definition "guard S = {.((grd S)::'a\<Rightarrow>bool).} o S"
lemma "((grd (local_init init S))::'a\<Rightarrow>bool) = SUPREMUM init (grd o S)"
by (simp add: fun_eq_iff local_init_def assert_def grd_def)
lemma "u \<in> init \<Longrightarrow> guard ([:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . p u x.} o [:u, x \<leadsto> y . r u x y :])
= [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . u \<in> init \<and> (\<exists>a. a \<in> init \<and> (p a x \<longrightarrow> Ex (r a x))) \<and> p u x.} o [:u, x \<leadsto> y . ((r u x y)::bool) :]"
by (auto simp add: fun_eq_iff local_init_def guard_def grd_def assert_def demonic_def le_fun_def)
lemma inpt_str_comp_aux: "(\<forall>n. (\<forall>i<n. inpt_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow>
inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)) \<longrightarrow>
(\<forall> i < n . inpt_st r ((fst o u) i) ((fst o u) (Suc i)) (x i) \<and> (\<forall>y. r (fst (u i)) (fst (u (Suc i))) (x i) y \<longrightarrow> inpt_st r' (snd (u i)) (snd (u (Suc i))) y))"
(is "(\<forall> n . ?p n) \<longrightarrow> ?q n")
proof (induction n)
case 0
show ?case by auto
next
case (Suc n)
show ?case
proof auto
fix i::nat
assume B: "\<forall> n . ?p n"
then have A: "?p n" (is "?A \<longrightarrow> ?B")
by simp
from Suc and B have C: "?q n"
by simp
assume "i < Suc n"
then show "inpt_st r (fst (u i)) (fst (u (Suc i))) (x i)"
proof cases
assume "i < n"
then show ?thesis
by (metis Suc.IH B comp_apply)
next
assume "\<not> i < n"
from this and `i < Suc n` have [simp]: "i = n" by simp
show ?thesis
proof cases
assume "?A"
from this and A have D: "?B" by simp
from D show ?thesis
by (metis `i = n`)
next
assume "\<not> ?A"
then obtain j where "j < n \<and> \<not> inpt_st (\<lambda> (u, v) . \<lambda> (u', v') . r u u' OO r' v v') (u j) (u (Suc j)) (x j)"
by auto
moreover from this and C have "inpt_st r (fst (u j)) (fst (u (Suc j))) (x j) \<and> (\<forall>y. r (fst (u j)) (fst (u (Suc j))) (x j) y \<longrightarrow> inpt_st r' (snd (u j)) (snd (u (Suc j))) y)"
by auto
ultimately show ?thesis
apply (case_tac "u j")
apply (case_tac "u (Suc j)")
apply (simp add: inpt_st_def)
by (metis relcompp.relcompI)
qed
qed
next
fix i::nat fix y :: 'e
assume B: "\<forall> n . ?p n"
then have A: "?p n" (is "?A \<longrightarrow> ?B")
by simp
from Suc and B have C: "\<forall>i<n. inpt_st r (fst (u i)) (fst (u (Suc i))) (x i) \<and> (\<forall>y. r (fst (u i)) (fst (u (Suc i))) (x i) y \<longrightarrow> inpt_st r' (snd (u i)) (snd (u (Suc i))) y)"
by simp
assume E: "r (fst (u i)) (fst (u (Suc i))) (x i) y"
assume "i < Suc n"
then show "inpt_st r' (snd (u i)) (snd (u (Suc i))) y"
proof cases
assume "i < n"
from this and E and C show ?thesis
by simp
next
assume "\<not> i < n"
from this and `i < Suc n` have [simp]: "i = n" by simp
show ?thesis
proof cases
assume "?A"
from this and A have D: "?B" by simp
from D and E show ?thesis
by (metis `i = n`)
next
assume "\<not> ?A"
then obtain j where "j < n \<and> \<not> inpt_st (\<lambda> (u, v) . \<lambda> (u', v') . r u u' OO r' v v') (u j) (u (Suc j)) (x j)"
by auto
moreover from this and C have "inpt_st r (fst (u j)) (fst (u (Suc j))) (x j) \<and> (\<forall>y. r (fst (u j)) (fst (u (Suc j))) (x j) y \<longrightarrow> inpt_st r' (snd (u j)) (snd (u (Suc j))) y)"
by auto
ultimately show ?thesis
by (case_tac "u j", case_tac "u (Suc j)", simp add: inpt_st_def, metis relcompp.relcompI)
qed
qed
qed
qed
lemma inpt_str_comp_aux_a: "(\<forall>n. (\<forall>i<n. inpt_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow>
inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)) \<Longrightarrow>
inpt_st r ((fst o u) n) ((fst o u) (Suc n)) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)"
by (cut_tac n = "Suc n" and r = r and r' = r' and u = u and x = x in inpt_str_comp_aux, simp)
definition "rel_st r r' = (\<lambda> (u, v) (u', v') x z . inpt_st r u u' x \<and> (\<forall> y . r u u' x y \<longrightarrow> inpt_st r' v v' y) \<and> (r u u' OO r' v v') x z)"
lemma inpt_str_comp_a: "(prec_st (inpt_st r) r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st (inpt_st r') r' (snd \<circ> u) y)) =
prec_st (\<lambda> u u' x . inpt_st r (fst u) (fst u') x \<and> (\<forall> y . r (fst u) (fst u') x y \<longrightarrow> (inpt_st r' (snd u) (snd u') y))) (\<lambda>(u, v) (u', v'). r u u' OO r' v v') u x"
proof (auto simp add: prec_st_inpt prec_st_simp)
fix n:: nat
assume "(\<box> lft_pred_st (inpt_st r)) (fst \<circ> u) x"
then show "inpt_st r (fst (u n)) (fst (u (Suc n))) (x n)"
by (simp add: always_def lft_pred_st_def at_fun_def)
next
fix n:: nat and y :: 'c
assume A: "(\<box> lft_pred_st (inpt_st r)) (fst \<circ> u) x"
assume B: "r (fst (u n)) (fst (u (Suc n))) (x n) y"
assume C: "\<forall>i<n. inpt_st (\<lambda>(u\<Colon>'a, v\<Colon>'d) (u'\<Colon>'a, v'\<Colon>'d). r u u' OO r' v v') (u i) (u (Suc i)) (x i)"
let ?y = "\<lambda> i . (if i = n then y else (SOME y . r ((fst o u) i) ((fst o u) (Suc i)) (x i) y))"
assume "\<forall>y . (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> (\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) y"
then have D: "(\<box> lft_rel_st r) (fst \<circ> u) x ?y \<longrightarrow> (\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) ?y"
by simp
from A and B have E: "(\<box> lft_rel_st r) (fst \<circ> u) x ?y"
apply (auto simp add: always_def at_fun_def lft_rel_st_def lft_pred_st_def inpt_st_def)
by (metis tfl_some)
from D and E have "(\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) ?y" by simp
from A and E and this show "inpt_st r' (snd (u n)) (snd (u (Suc n))) y"
apply (simp add: always_def lft_pred_st_def at_fun_def)
apply (drule_tac x = n in spec)
apply (drule_tac x = n in spec)
by (drule_tac x = n in spec, simp)
next
assume "\<forall> n . (\<forall>i<n. inpt_st (\<lambda>(u\<Colon>'a, v\<Colon>'d) (u'\<Colon>'a, v'\<Colon>'d). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow>
inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y\<Colon>'c. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)"
then show "(\<box> lft_pred_st (inpt_st r)) (fst \<circ> u) x"
apply (auto simp add: always_def lft_pred_st_def at_fun_def)
apply (drule inpt_str_comp_aux_a)
by auto
next
fix y::"nat \<Rightarrow> 'c"
assume "\<forall> n . (\<forall>i<n. inpt_st (\<lambda>(u\<Colon>'a, v\<Colon>'d) (u'\<Colon>'a, v'\<Colon>'d). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow>
inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y\<Colon>'c. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)"
moreover assume " (\<box> lft_rel_st r) (fst \<circ> u) x y"
ultimately show "(\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) y"
apply (auto simp add: always_def lft_pred_st_def at_fun_def)
apply (drule inpt_str_comp_aux_a)
by (auto simp add: lft_rel_st_def)
qed
lemma inpt_str_comp_b: "prec_st (\<lambda> u u' x . inpt_st r (fst u) (fst u') x \<and>
(\<forall> y . r (fst u) (fst u') x y \<longrightarrow> (inpt_st r' (snd u) (snd u') y))) (\<lambda>(u, v) (u', v'). r u u' OO r' v v') u x
= (\<box> (lft_pred_st (inpt_st (rel_st r r')))) u x"
proof (auto simp add: prec_st_simp always_def lft_pred_st_def at_fun_def rel_st_def)
fix m::nat
assume A: "\<forall>n . (\<forall>i<n. inpt_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow>
inpt_st r (fst (u n)) (fst (u (Suc n))) (x n)
\<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)" (is "\<forall> n . ?p n \<longrightarrow> ?q n \<and> ?r n")
then have "?q m"
by (drule_tac n = m in inpt_str_comp_aux_a, simp)
then obtain y where B: "r ((fst \<circ> u) m) ((fst \<circ> u) (Suc m)) (x m) y" by (auto simp add: inpt_st_def)
from A have "?r m"
by (drule_tac n = m in inpt_str_comp_aux_a, simp)
from this B show "inpt_st (\<lambda>(u, v) (u', v') (x\<Colon>'c) z. inpt_st r u u' x \<and> (\<forall>y. r u u' x y
\<longrightarrow> inpt_st r' v v' y) \<and> (r u u' OO r' v v') x z) (u m) (u (Suc m)) (x m)"
apply (case_tac "u m")
apply (case_tac "u (Suc m)")
apply (simp add: inpt_st_def)
by (metis relcompp.relcompI)
next
fix m::nat
assume " \<forall> m. inpt_st (\<lambda>(u, v) (u', v') (x) z. inpt_st r u u' x \<and> (\<forall>y. r u u' x y \<longrightarrow> inpt_st r' v v' y)
\<and> (r u u' OO r' v v') x z) (u m) (u (Suc m)) (x m)" (is "\<forall> m . ?p m")
then have "?p m" by simp
then show " inpt_st r (fst (u m)) (fst (u (Suc m))) (x m)"
apply (simp add: inpt_st_def)
by (case_tac "u m", case_tac "u (Suc m)", simp)
next
fix m::nat and y :: 'e
assume " \<forall> m. inpt_st (\<lambda>(u, v) (u', v') (x) z. inpt_st r u u' x \<and> (\<forall>y. r u u' x y \<longrightarrow> inpt_st r' v v' y)
\<and> (r u u' OO r' v v') x z) (u m) (u (Suc m)) (x m)" (is "\<forall> m . ?p m")
then have "?p m" by simp
moreover assume "r (fst (u m)) (fst (u (Suc m))) (x m) y"
ultimately show " inpt_st r' (snd (u m)) (snd (u (Suc m))) y"
apply (simp add: inpt_st_def)
by (case_tac "u m", case_tac "u (Suc m)", simp)
qed
lemma inpt_str_comp: "(prec_st (inpt_st r) r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st (inpt_st r') r' (snd \<circ> u) y))
= (\<box> (lft_pred_st (inpt_st (rel_st r r')))) u x"
by (simp add: inpt_str_comp_a inpt_str_comp_b)
lemma RSysTmp_inpt_comp: "u' \<in> init' \<Longrightarrow> SymSystem init (inpt_st r) r o SymSystem init'(inpt_st r') r'
= SymSystem (zip_set init init') (inpt_st (rel_st r r')) (rel_st r r')"
proof -
assume A : "u' \<in> init'"
have [simp]: "( \<lambda>x y. (case x of (x, xa) \<Rightarrow> (\<box> lft_pred_st (inpt_st (rel_st r r'))) x xa) \<and>
(case x of (x, xa) \<Rightarrow> (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) x xa) y)
= (\<lambda>(x, y). (\<box> lft_rel_st (rel_st r r')) x y)" (is "?a = ?b")
proof (auto simp add: fun_eq_iff always_def at_fun_def lft_pred_st_def lft_rel_st_def rel_st_def inpt_st_def)
fix a :: "nat \<Rightarrow> 'e \<times> 'a" and b :: "nat \<Rightarrow> 'c" and x :: "nat \<Rightarrow> 'b" and xa :: nat
assume "\<forall>xa\<Colon>nat. (case a xa of (u\<Colon>'e, v\<Colon>'a) \<Rightarrow> \<lambda>(u'\<Colon>'e, v'\<Colon>'a). r u u' OO r' v v') (a (Suc xa)) (b xa) (x xa)" (is "\<forall> xa . ?P xa")
then have A: "?P xa" by simp
assume "\<forall>x . Ex ((case a x of (u, v) \<Rightarrow> \<lambda>(u', v') (x) z. Ex (r u u' x) \<and> (\<forall>y. r u u' x y \<longrightarrow> Ex (r' v v' y)) \<and> (r u u' OO r' v v') x z) (a (Suc x)) (b x))" (is "\<forall> xa . ?Q xa")
then have "?Q xa" by simp
from this and A show "(case a xa of (u, v) \<Rightarrow> \<lambda>(u', v') (x) z. Ex (r u u' x) \<and> (\<forall>y. r u u' x y \<longrightarrow> Ex (r' v v' y)) \<and> (r u u' OO r' v v') x z) (a (Suc xa)) (b xa) (x xa)"
by (case_tac "a xa", case_tac "a (Suc xa)", simp)
next
fix a :: "nat \<Rightarrow> 'e \<times> 'a" and b :: "nat \<Rightarrow> 'c" and x :: "nat \<Rightarrow> 'b" and xa :: nat
assume "\<forall>xa . (case a xa of (u\<Colon>'e, v\<Colon>'a) \<Rightarrow> \<lambda>(u'\<Colon>'e, v'\<Colon>'a) (x\<Colon>'c) z\<Colon>'b. Ex (r u u' x) \<and> (\<forall>y\<Colon>'d. r u u' x y \<longrightarrow> Ex (r' v v' y)) \<and> (r u u' OO r' v v') x z) (a (Suc xa)) (b xa) (x xa)" (is "\<forall> xa . ?Q xa")
then have "?Q xa" by simp
then show "(case a xa of (u\<Colon>'e, v\<Colon>'a) \<Rightarrow> \<lambda>(u'\<Colon>'e, v'\<Colon>'a). r u u' OO r' v v') (a (Suc xa)) (b xa) (x xa)"
by (case_tac "a xa", case_tac "a (Suc xa)", simp)
qed
from A have "SymSystem init (inpt_st r) r o SymSystem init'(inpt_st r') r' = [: z \<leadsto> u, x . fst \<circ> u \<in> init \<and> snd \<circ> u \<in> init' \<and> z = x :] \<circ>
({.u, x . prec_st (inpt_st r) r (fst \<circ> u) x \<and> (\<forall>y\<Colon>nat \<Rightarrow> 'd. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st (inpt_st r') r' (snd \<circ> u) y).} \<circ>
[: (\<lambda>(u, x). ((\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u x)) :])"
by (unfold SymSystem_comp, simp add: comp_assoc)
also have "... = [: z \<leadsto> u, x . fst \<circ> u \<in> init \<and> snd \<circ> u \<in> init' \<and> z = x :] \<circ> ({. x, y . (\<box> lft_pred_st (inpt_st (rel_st r r'))) x y .} \<circ> [: ?b :])"
by (subst assert_demonic, simp add: inpt_str_comp)
also have "... = SymSystem (zip_set init init') (inpt_st (rel_st r r')) (rel_st r r')"
by (simp add: SymSystem_def prec_st_inpt comp_assoc zip_set_def)
finally show ?thesis by simp
qed
definition "GrdSymSystem init r = [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o trs (\<lambda> (u, x) y . (\<box>(lft_rel_st r)) u x y)"
lemma inpt_always: "inpt (\<lambda>(x, y). (\<box> lft_rel_st r) x y) = (\<lambda>(x, y). (\<box> lft_pred_st (inpt_st r)) x y)"
proof (auto simp add: fun_eq_iff)
fix a :: "nat \<Rightarrow> 'a" and b :: "nat \<Rightarrow> 'b"
assume "inpt (\<lambda>(x, y).(\<box> lft_rel_st r) x y) (a, b)"
then show "(\<box> lft_pred_st (inpt_st r)) a b"
by (auto simp add: inpt_def lft_pred_st_def inpt_st_def always_def at_fun_def lft_rel_st_def)
next
fix a :: "nat \<Rightarrow> 'a" and b :: "nat \<Rightarrow> 'b"
let ?y = "\<lambda> n . (SOME y . r (a n) (a (Suc n)) (b n) y)"
assume "(\<box> lft_pred_st (inpt_st r)) a b"
then have "(\<box> lft_rel_st r) a b ?y"
apply (auto simp add: always_def at_fun_def lft_rel_st_def inpt_st_def lft_pred_st_def)
by (metis tfl_some)
then show "inpt (\<lambda>(x, y). (\<box> lft_rel_st r) x y) (a, b)"
by (auto simp add: inpt_def)
qed
lemma "GrdSymSystem init r = SymSystem init (inpt_st r) r"
by (simp add: GrdSymSystem_def SymSystem_def trs_def prec_st_inpt comp_assoc inpt_always)
subsection{*Example: COUNTER*}
text{*
In this section we introduce an example counter that counts how many times
the input variable $x$ is true. The input is a sequence of boolen values
and the output is a sequence of natural numbers. The output at some moment in
time is the number of true values seen so far in the input.
We defined the system counter in two different ways and we show that the
two definitions are equivalent. The first definition takes the entire
input sequence and it computes the corresponding output sequence. We introduce
the second version of the counter as a reactive system based on a symbolic
transition system. We use a local variable to record the number of true
values seen so far, and initially the local variable is zero. At every step
we increase the local variable if the input is true. The output of the
system at every step is equal to the local variable.
*}
primrec count :: "bool trace \<Rightarrow> nat trace" where
"count x 0 = (if x 0 then 1 else 0)" |
"count x (Suc n) = (if x (Suc n) then count x n + 1 else count x n)"
definition "Counter_global n = {.x . (\<forall> k . count x k \<le> n).} o [:x \<leadsto> y . y = count x:]"
definition "prec_count M u u' x = (u \<le> M)"
definition "rel_count u u' x y = ((x \<longrightarrow> u' = Suc u) \<and> (\<not> x \<longrightarrow> u' = u) \<and> y = u')"
lemma counter_a_aux: "u 0 = 0 \<Longrightarrow> \<forall>i < n. (x i \<longrightarrow> u (Suc i) = Suc (u i)) \<and> (\<not> x i \<longrightarrow> u (Suc i) = u i) \<Longrightarrow> (\<forall> i < n . count x i = u (Suc i))"
proof (induction n)
case 0
show ?case by simp
next
case (Suc n)
{fix j::nat
assume "\<forall>i<Suc n. (x i \<longrightarrow> u (Suc i) = Suc (u i)) \<and> (\<not> x i \<longrightarrow> u (Suc i) = u i)"
and "j < Suc n"
and "u (0\<Colon>nat) = (0\<Colon>nat)"
from this and Suc have "count x j = u (Suc j)"
by (case_tac j, auto)
}
from Suc and this show ?case
by auto
qed
lemma counter_b_aux: "u 0 = 0 \<Longrightarrow> \<forall>n. (xa n \<longrightarrow> u (Suc n) = Suc (u n)) \<and> (\<not> xa n \<longrightarrow> u (Suc n) = u n) \<and> xb n = u (Suc n)
\<Longrightarrow> count xa n = u (Suc n)"
by (induction n, simp_all)
definition "COUNTER M = SymSystem {u . u 0 = 0} (prec_count M) rel_count"
lemma "COUNTER = Counter_global"
proof -
have A:"(\<lambda>x y . \<exists>u\<Colon>nat \<Rightarrow> nat. u (0\<Colon>nat) = (0\<Colon>nat) \<and> (\<box> lft_rel_st rel_count) u x y)
= (\<lambda> x y . y = count x)"
proof (simp add: fun_eq_iff lft_rel_st_def rel_count_def always_def at_fun_def, safe)
fix x :: "nat \<Rightarrow> bool" and xa :: "nat \<Rightarrow> nat" and u:: "nat \<Rightarrow> nat" and xb :: nat
assume A: "u 0 = 0"
assume B: "\<forall>xb . (x xb \<longrightarrow> u (Suc xb) = Suc (u xb)) \<and> (\<not> x xb \<longrightarrow> u (Suc xb) = u xb) \<and> xa xb = u (Suc xb)"
from A and this have "count x xb = xa xb"
by (drule_tac counter_b_aux, auto)
then show "xa xb = count x xb" by simp
next
fix x::"nat \<Rightarrow> bool" and xa::"nat \<Rightarrow> nat"
def A: u == "\<lambda> i . if i = 0 then 0 else count x (i - 1)"
assume B: "\<forall>xb\<Colon>nat. xa xb = count x xb"
{fix xb::nat
from A and B have "u 0 = 0 \<and> ( (x xb \<longrightarrow> u (Suc xb) = Suc (u xb)) \<and> (\<not> x xb \<longrightarrow> u (Suc xb) = u xb) \<and> xa xb = u (Suc xb))"
by (case_tac xb, auto)
}
then show "\<exists>u\<Colon>nat \<Rightarrow> nat. u 0 = 0 \<and> (\<forall>xb. (x xb \<longrightarrow> u (Suc xb) = Suc (u xb)) \<and> (\<not> x xb \<longrightarrow> u (Suc xb) = u xb) \<and>
xa xb = u (Suc xb))"
by auto
qed
{fix x :: nat
have "(\<lambda>xa . \<forall>u . u (0\<Colon>nat) = (0\<Colon>nat) \<longrightarrow> prec_st (prec_count x) rel_count u xa) =
(\<lambda>xa\<Colon>nat \<Rightarrow> bool. \<forall>k\<Colon>nat. count xa k \<le> x)"
proof (simp add: fun_eq_iff lft_rel_st_def prec_st_def until_def
lft_pred_st_def prec_count_def at_fun_def inpt_st_def rel_count_def, safe)
fix xa::"nat \<Rightarrow> bool" and k:: nat
def A: uu == "\<lambda> i . if i = 0 then 0 else count xa (i - 1)"
assume "(\<forall>u . u 0 = 0 \<longrightarrow> (\<forall>xb . (\<exists>x<xb. xa x \<and> u (Suc x) \<noteq> Suc (u x) \<or> \<not> xa x \<and> u (Suc x) \<noteq> u x) \<or> u xb \<le> x))" (is "\<forall> u . ?s u")
then have "?s uu" (is "?p \<longrightarrow> (\<forall>xb . (\<exists> x < xb . ?q xb x) \<or> ?r xb)")
by auto
from this and A have "(\<forall>xb . (\<exists> x < xb . ?q xb x) \<or> ?r xb)"
by simp
then have "(\<exists> x < (Suc k) . ?q (Suc k) x) \<or> ?r (Suc k)"
by simp
then obtain xb where "xb < (Suc k) \<and> (?q (Suc k) xb \<or> ?r (Suc k))"
by auto
from this and A show "count xa k \<le> x"
by (case_tac xb, auto)
next
fix xa:: "nat \<Rightarrow> bool" and u::"nat \<Rightarrow> nat" and xaa::nat
assume C: "\<forall>k\<Colon>nat. count xa k \<le> x"
assume A: "u (0\<Colon>nat) = (0\<Colon>nat)"
assume B: "\<not> u xaa \<le> x"
from A and B have D: "xaa > 0"
by (metis le0 neq0_conv)
from this and B and C have "count xa (xaa - 1) \<noteq> u xaa"
by metis
from this and D have E: "\<exists>i < xaa. count xa i \<noteq> u (Suc i)"
by (metis One_nat_def Suc_diff_1 diff_Suc_less)
have "u 0 = 0 \<Longrightarrow> \<forall>i<xaa. (xa i \<longrightarrow> u (Suc i) = Suc (u i)) \<and> (\<not> xa i \<longrightarrow> u (Suc i) = u i) \<Longrightarrow> \<forall>i<xaa. count xa i = u (Suc i)"
by (rule counter_a_aux, simp)
from this and A and E show "(\<exists>x<xaa. xa x \<and> u (Suc x) \<noteq> Suc (u x) \<or> \<not> xa x \<and> u (Suc x) \<noteq> u x)"
by auto
qed
}
note B = this
show ?thesis
by (simp add: fun_eq_iff COUNTER_def SymSystem_rel Counter_global_def A B)
qed
subsection{*Example: LIVE*}
text{*
The last example of this formalization introduces a system which does some
local computation, and ensures some global liveness property.
We show that this example is the fusion of a symbolic transition system and a demonic
choice which ensures the liveness property of the output sequence.
We also show that asumming some liveness property for the input, we can refine
the example into an executable system that does not ensure the liveness
property of the output on its own, but relies on the liveness of the input.
*}
definition "rel_ex u u' x y = (((x \<and> u' = u + (1::int)) \<or> (\<not> x \<and> u' = u - 1) \<or> u' = 0) \<and> (y = (u' = 0)))"
definition "prec_ex u u' x = (-1 \<le> u \<and> u \<le> 3)"
definition "LIVE = [:x \<leadsto> u, x' . u (0::nat) = 0 \<and> x = x':] o {.u, x . prec_st prec_ex rel_ex u x.}
o [:u, x \<leadsto> y . (\<box>(\<lambda> u x y . rel_ex (u 0) (u 1) (x 0) (y 0))) u x y \<and> (\<box> (\<diamondsuit> (\<lambda> y . y 0))) y :]"
thm fusion_spec_local_a
lemma LIVE_fusion: "LIVE = (SymSystem {u . u 0 = 0} prec_ex rel_ex) \<parallel> [:x \<leadsto> y . (\<box> (\<diamondsuit> (\<lambda> y . y 0))) y:]"
proof -
def B: init == "{u . u (0::nat) = (0::int)}"
then have A: "(\<lambda> i::nat . 0::int) \<in> init"
by simp
then have "([: x \<leadsto> (u, y). u \<in> init \<and> x = y :] \<circ> {.(x, y). prec_st prec_ex rel_ex x y .} \<circ> [: \<lambda>(x, y). (\<box> lft_rel_st rel_ex) x y :]) \<parallel>
[: \<lambda>x. \<box> \<diamondsuit> (\<lambda>y. y 0) :] =
[: x \<leadsto> (u, y). u \<in> init \<and> x = y :] \<circ> {. (x, y). prec_st prec_ex rel_ex x y .} \<circ>
[: (u, x) \<leadsto> y. (\<box> lft_rel_st rel_ex) u x y \<and> (\<box> \<diamondsuit> (\<lambda>y. y 0)) y :]"
by (unfold fusion_spec_local_a, auto)
from B and this show ?thesis
apply (simp add: SymSystem_def)
by (auto simp add: LIVE_def lft_rel_st_def always_def at_fun_def)
qed
definition "preca_ex x = (x 1 = (\<not>x 0))"
lemma monotonic_SymSystem[simp]: "mono (SymSystem init p r)"
by (simp add: SymSystem_def)
lemma event_ex_aux_a: "a 0 = (0::int) \<Longrightarrow> \<forall>n. xa (Suc n) = (\<not> xa n) \<Longrightarrow>
\<forall>n. (xa n \<and> a (Suc n) = a n + 1 \<or> \<not> xa n \<and> a (Suc n) = a n - 1 \<or> a (Suc n) = 0) \<Longrightarrow>
(a n = -1 \<longrightarrow> xa n) \<and> (a n = 1 \<longrightarrow> \<not> xa n) \<and> -1 \<le> a n \<and> a n \<le> 1"
proof (induction n)
case 0
show ?case
by (metis "0.prems"(1) le_minus_one_simps(1) minus_zero zero_le_one zero_neq_neg_one)
next
case (Suc n)
{assume "a (Suc n) = - (1\<Colon>int)" from this and Suc have "xa (Suc n)"
by (metis add.commute add_le_same_cancel2 not_one_le_zero zero_neq_neg_one)}
note A = this
{assume "a (Suc n) = (1\<Colon>int)" and "xa (Suc n)" from this and Suc have "False"
by (metis eq_iff le_iff_diff_le_0 not_one_le_zero)}
note B = this
{assume "a n \<noteq> - (1\<Colon>int)" from this and Suc have " - (1\<Colon>int) \<le> a (Suc n)"
by (metis add.commute comm_monoid_add_class.add.left_neutral le_less not_le right_minus uminus_add_conv_diff zle_add1_eq_le)}
note C = this
{assume "a n = - (1\<Colon>int)" from this and Suc have " - (1\<Colon>int) \<le> a (Suc n)"
by (metis add.commute le_minus_one_simps(4) monoid_add_class.add.right_neutral not_le right_minus zle_add1_eq_le)}
note D = this
from C and D and Suc have E: " - (1\<Colon>int) \<le> a (Suc n)" by auto
from Suc have F: "a (Suc n) \<le> (1\<Colon>int)"
by (metis eq_iff int_one_le_iff_zero_less le_iff_diff_le_0 le_less not_le zle_add1_eq_le)
from A B E F show ?case by auto
qed
lemma event_ex_aux: "a 0 = (0::int) \<Longrightarrow> \<forall>n. xa (Suc n) = (\<not> xa n) \<Longrightarrow>
\<forall>n. (xa n \<and> a (Suc n) = a n + 1 \<or> \<not> xa n \<and> a (Suc n) = a n - 1 \<or> a (Suc n) = 0) \<Longrightarrow>
(\<forall> n . (a n = -1 \<longrightarrow> xa n) \<and> (a n = 1 \<longrightarrow> \<not> xa n) \<and> -1 \<le> a n \<and> a n \<le> 1)"
by (clarify, drule event_ex_aux_a, auto)
lemma "{.\<box> preca_ex.} o LIVE \<le> SymSystem {u . u 0 = 0} prec_ex rel_ex"
proof (unfold LIVE_fusion SymSystem_def, rule fusion_local_refinement, simp_all)
fix z::"nat \<Rightarrow> bool" and u :: "nat \<Rightarrow> int" and x::"nat \<Rightarrow> bool"
assume A: "u 0 = 0"
assume "(\<box> preca_ex) z"
then have B: "\<forall>x\<Colon>nat. z (Suc x) = (\<not> z x)"
by (auto simp add: preca_ex_def lft_rel_st_def rel_ex_def always_def at_fun_def)
assume "(\<box> lft_rel_st rel_ex) u z x"
then have C: "\<forall>xa . (z xa \<and> u (Suc xa) = u xa + 1 \<or> \<not> z xa \<and> u (Suc xa) = u xa - 1 \<or> u (Suc xa) = 0) \<and> x xa = (u (Suc xa) = 0)"
by (auto simp add: preca_ex_def lft_rel_st_def rel_ex_def always_def at_fun_def)
have D: "(\<forall> n . (u n = -1 \<longrightarrow> z n) \<and> (u n = 1 \<longrightarrow> \<not> z n) \<and> -1 \<le> u n \<and> u n \<le> 1)"
by (cut_tac A B C, rule event_ex_aux, auto)
{
fix a::nat
{assume "u (Suc a) = 0" from this A B C have "\<exists>b . u (Suc (a + b)) = 0"
by (metis monoid_add_class.add.right_neutral)}
note 1 = this
{assume "u (Suc a) = -1" from this A B C D have "\<exists>b . u (Suc (a + b)) = 0"
by (metis add_Suc_right diff_minus_eq_add diff_self monoid_add_class.add.right_neutral)}
note 2 = this
{assume "u (Suc a) = 1" from this A B C D have "\<exists>b . u (Suc (a + b)) = 0"
by (metis add_Suc_right diff_self monoid_add_class.add.right_neutral)}
note 3 = this
from 1 2 3 A B C D have "\<exists>b . x (a + b)"
by (simp, metis diff_0 int_one_le_iff_zero_less le_less not_le zle_diff1_eq)
}
then show "(\<box> \<diamondsuit> (\<lambda>y . y 0)) x"
by (simp add: always_def eventually_def preca_ex_def at_fun_def rel_ex_def lft_rel_st_def)
qed
end
|
[STATEMENT]
lemma merge_states_self_simp [code]:
"merge_states x y t = (if x = y then t else if x > y then merge_states_aux x y t else merge_states_aux y x t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. merge_states x y t = (if x = y then t else if y < x then merge_states_aux x y t else merge_states_aux y x t)
[PROOF STEP]
apply (simp add: merge_states_def merge_states_aux_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x = y \<longrightarrow> (\<lambda>(uid, (origin, dest), t). (uid, (origin, dest), t)) |`| t = t
[PROOF STEP]
by force |
State Before: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
⊢ p ^ (k + l + 1) ∣ natAbs m * natAbs n State After: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
⊢ p ^ (k + l + 1) ∣ natAbs (m * n) Tactic: rw [← Int.natAbs_mul] State Before: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
⊢ p ^ (k + l + 1) ∣ natAbs (m * n) State After: no goals Tactic: apply Int.coe_nat_dvd.1 <| Int.dvd_natAbs.2 hpmn State Before: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd1 : p ^ (k + 1) ∣ natAbs m
⊢ ↑(p ^ (k + 1)) ∣ m State After: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd1 : p ^ (k + 1) ∣ natAbs m
⊢ ↑(p ^ (k + 1)) ∣ ↑(natAbs m) Tactic: apply Int.dvd_natAbs.1 State Before: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd1 : p ^ (k + 1) ∣ natAbs m
⊢ ↑(p ^ (k + 1)) ∣ ↑(natAbs m) State After: no goals Tactic: apply Int.coe_nat_dvd.2 hsd1 State Before: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd2 : p ^ (l + 1) ∣ natAbs n
⊢ ↑(p ^ (l + 1)) ∣ n State After: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd2 : p ^ (l + 1) ∣ natAbs n
⊢ ↑(p ^ (l + 1)) ∣ ↑(natAbs n) Tactic: apply Int.dvd_natAbs.1 State Before: p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd2 : p ^ (l + 1) ∣ natAbs n
⊢ ↑(p ^ (l + 1)) ∣ ↑(natAbs n) State After: no goals Tactic: apply Int.coe_nat_dvd.2 hsd2 |
{-# OPTIONS --universe-polymorphism #-}
module Prelude.Stream where
-- open import Coinduction
-- Infinite streams.
open import Prelude.IO
open import Prelude.Nat
open import Prelude.Unit
data Level : Set where
zero : Level
suc : (i : Level) → Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO zero #-}
{-# BUILTIN LEVELSUC suc #-}
infixl 6 _⊔_
_⊔_ : Level → Level → Level
zero ⊔ j = j
suc i ⊔ zero = suc i
suc i ⊔ suc j = suc (i ⊔ j)
{-# BUILTIN LEVELMAX _⊔_ #-}
infix 1000 ♯_
postulate
∞ : ∀ {a} (A : Set a) → Set a
♯_ : ∀ {a} {A : Set a} → A → ∞ A
♭ : ∀ {a} {A : Set a} → ∞ A → A
{-# BUILTIN INFINITY ∞ #-}
{-# BUILTIN SHARP ♯_ #-}
{-# BUILTIN FLAT ♭ #-}
data Stream (A : Set) : Set where
_∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A
-- A stream processor SP A B consumes elements of A and produces
-- elements of B. It can only consume a finite number of A’s before
-- producing a B.
data SP (A B : Set) : Set where
get : (f : A → SP A B) → SP A B
put : (b : B) (sp : ∞ (SP A B)) → SP A B
-- The function eat is defined by an outer corecursion into Stream B
-- and an inner recursion on SP A B.
eat : ∀ {A B} → SP A B → Stream A → Stream B
eat (get f) (a ∷ as) = eat (f a) (♭ as)
eat (put b sp) as = b ∷ ♯ eat (♭ sp) as
-- Composition of stream processors.
_∘_ : ∀ {A B C} → SP B C → SP A B → SP A C
get f₁ ∘ put x sp₂ = f₁ x ∘ ♭ sp₂
put x sp₁ ∘ sp₂ = put x (♯ (♭ sp₁ ∘ sp₂))
sp₁ ∘ get f₂ = get (λ x → sp₁ ∘ f₂ x)
ones : Stream Nat
ones = 1 ∷ (♯ ones)
twos : Stream Nat
twos = 2 ∷ (♯ twos)
printStream : Nat -> Stream Nat -> IO Unit
printStream Z _ = return unit
printStream (S steps) (n ∷ ns) =
printNat n ,,
printStream steps (♭ ns)
main : IO Unit
main = printStream 100 twos
|
Activities of Daily Living (ADLs) are activities that adults do every day to carry out their lives. These include bathing, dressing, grooming, going to the bathroom, walking, eating and other basic activities. The vast majority of ADLs are provided by the paraprofessional in most health care settings. Because of this responsibility, it is important as caregivers to have a solid understanding of the appropriate techniques in providing personal care. The Personal Care Workers also needs to be able to correctly demonstrate the proper skills necessary to provide personal care. In addition to ADLs, it is important that the caregiver understand and practice the goals of proper skin care and the preventive measures necessary to avoid pressure ulcers.
Demonstrate the proper technique for giving a client a bed bath. |
As of October 18, 2009, the property at Silas Branch Rd, Silas, AL 36919 in Choctaw County with assessor's parcel #3303063001005005 was owned by W*** J*** L***.
Who Owns This Property Now?Search by address, owner name, or parcel number. Get up-to-date Property Reports on Silas Branch Rd, Silas, AL. Find Property Legal Description, Title History, Judgement Liens, and more.
Silas Branch Rd, Silas, AL property/ownership information is based on public records as of October 18, 2009 and is presented here for free public use. HomeInfoMax assumes no responsibility for the accuracy or validity of Silas, AL property records. |
lemma finite_measureI[Pure.intro!]: "emeasure M (space M) \<noteq> \<infinity> \<Longrightarrow> finite_measure M" |
#=
The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method.
Hint: The basic equation of a circle is x2 + y2 = r2
=#
using Test
include("Solutions/problem14_estimate_pi.jl")
@test abs(estimate_pi() - pi) <= 0.001
@test abs(estimate_pi(number_of_decimal = 5) - pi) <= 0.00001
|
{-# LANGUAGE TypeApplications #-}
module Section_4_5 where
import MNIST
import Numeric.LinearAlgebra
import Section_4_5.TwoLayer
main :: IO ()
main = do
putStrLn "Loading Labels..."
(Labels _ labels) <- getLabels @Training @OneHotLabel
putStrLn "Loading Images..."
(Images _ _ _ images) <- getImages @Training @FlattenImage True
putStrLn "Creating Initial Network..."
network <- initNetwork [784, 50, 10] [sigmoid, softmax]
putStrLn "Picking Learning Data..."
let label = vector $ map fromIntegral $ labels !! 10
image = vector $ images !! 10
putStrLn $ "Answer: " ++ show label
putStrLn $ "Prediction before learning: " ++ show (predict network image)
putStrLn "Learning Network..."
let nw = updateNetwork loss [image] [label] network
putStrLn $ "Prediction after learning: " ++ show (predict nw image)
|
(*
* 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 Sep_Select_Example
imports Sep_Select
begin
lemma sep_select: "(A \<and>* B \<and>* C \<and>* D) s \<Longrightarrow> (A \<and>* B \<and>* C \<and>* D) s"
apply (sep_select 2) (* moves the 2nd conjunct in the conclusions to the front *)
apply (sep_select 2 3 4 1) (* we can reorder multiple conjuncts at once *)
apply (sep_select 2 3 4) (* the list can be partial *)
apply (sep_select_asm 3 4) (* sep_select_asm works for the assumptions *)
oops
end
|
from cost_based_selection import cost_based_analysis
from cost_based_selection import cost_based_methods
from cost_based_selection import data_generation
from cost_based_selection import preprocessing_utils
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
def test_smoke():
"""
This test reproduces the README code.
"""
num_sims_per_model = 10
num_nodes = 20
# Generate data.
model_indices, summaries, is_discrete, times = \
data_generation.BA_ref_table(num_sims_per_model, num_nodes)
# Preprocess the data.
model_indices, summaries, is_discrete, times = \
preprocessing_utils.drop_redundant_features(model_indices, summaries, is_discrete, times)
noise_indices = preprocessing_utils.noise_position(summaries)
average_costs = preprocessing_utils.compute_avg_cost(times)
# Train test split for validation.
X = np.array(summaries)
y = model_indices.modIndex.tolist()
is_discrete = is_discrete.iloc[0, :].tolist()
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.5, stratify=y)
# Apply the JMI method over a grid.
result = pd.DataFrame({"cost_param": [0, 1, 2]})
rankings = [cost_based_methods.JMI(
X=X_train, y=y_train, is_disc=is_discrete, cost_vec=average_costs, cost_param=cost_param
)[0] for cost_param in result.cost_param]
result = pd.concat([result, pd.DataFrame(rankings, columns=1 + np.arange(X.shape[1]))], axis=1)
# Run cross validation for model classification.
num_statistics = 15
classifier = KNeighborsClassifier
kwargs = {'n_neighbors': 10}
avg_accuracy, std_accuracy, total_cost, prop_noise = \
cost_based_analysis.accuracy_classifier_plot(
dfPen_Ranking=result, X_val=X_val, y_val=y_val, cost_vec=average_costs,
noise_idx=noise_indices, subset_size=num_statistics, classifier_func=classifier,
args_classifier=kwargs, num_fold=3, save_name=None,
)
if __name__ == '__main__':
test_smoke()
|
/-
Copyright (c) 2020 Paul van Wamelen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Paul van Wamelen.
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.algebra.field
import Mathlib.ring_theory.int.basic
import Mathlib.algebra.group_with_zero.power
import Mathlib.tactic.ring
import Mathlib.tactic.ring_exp
import Mathlib.tactic.field_simp
import Mathlib.PostPort
universes u_1
namespace Mathlib
/-!
# Pythagorean Triples
The main result is the classification of pythagorean triples. The final result is for general
pythagorean triples. It follows from the more interesting relatively prime case. We use the
"rational parametrization of the circle" method for the proof. The parametrization maps the point
`(x / z, y / z)` to the slope of the line through `(-1 , 0)` and `(x / z, y / z)`. This quickly
shows that `(x / z, y / z) = (2 * m * n / (m ^ 2 + n ^ 2), (m ^ 2 - n ^ 2) / (m ^ 2 + n ^ 2))` where
`m / n` is the slope. In order to identify numerators and denominators we now need results showing
that these are coprime. This is easy except for the prime 2. In order to deal with that we have to
analyze the parity of `x`, `y`, `m` and `n` and eliminate all the impossible cases. This takes up
the bulk of the proof below.
-/
/-- Three integers `x`, `y`, and `z` form a Pythagorean triple if `x * x + y * y = z * z`. -/
def pythagorean_triple (x : ℤ) (y : ℤ) (z : ℤ) := x * x + y * y = z * z
/-- Pythagorean triples are interchangable, i.e `x * x + y * y = y * y + x * x = z * z`.
This comes from additive commutativity. -/
theorem pythagorean_triple_comm {x : ℤ} {y : ℤ} {z : ℤ} :
pythagorean_triple x y z ↔ pythagorean_triple y x z :=
id
(eq.mpr
(id
(Eq._oldrec (Eq.refl (x * x + y * y = z * z ↔ y * y + x * x = z * z))
(add_comm (x * x) (y * y))))
(iff.refl (y * y + x * x = z * z)))
/-- The zeroth Pythagorean triple is all zeros. -/
theorem pythagorean_triple.zero : pythagorean_triple 0 0 0 := sorry
namespace pythagorean_triple
theorem eq {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) : x * x + y * y = z * z := h
theorem symm {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) : pythagorean_triple y x z :=
eq.mpr (id (Eq._oldrec (Eq.refl (pythagorean_triple y x z)) (propext pythagorean_triple_comm))) h
/-- A triple is still a triple if you multiply `x`, `y` and `z`
by a constant `k`. -/
theorem mul {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) (k : ℤ) :
pythagorean_triple (k * x) (k * y) (k * z) :=
sorry
/-- `(k*x, k*y, k*z)` is a Pythagorean triple if and only if
`(x, y, z)` is also a triple. -/
theorem mul_iff {x : ℤ} {y : ℤ} {z : ℤ} (k : ℤ) (hk : k ≠ 0) :
pythagorean_triple (k * x) (k * y) (k * z) ↔ pythagorean_triple x y z :=
sorry
/-- A pythogorean triple `x, y, z` is “classified” if there exist integers `k, m, n` such that either
* `x = k * (m ^ 2 - n ^ 2)` and `y = k * (2 * m * n)`, or
* `x = k * (2 * m * n)` and `y = k * (m ^ 2 - n ^ 2)`. -/
def is_classified {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) :=
∃ (k : ℤ),
∃ (m : ℤ),
∃ (n : ℤ),
(x = k * (m ^ bit0 1 - n ^ bit0 1) ∧ y = k * (bit0 1 * m * n) ∨
x = k * (bit0 1 * m * n) ∧ y = k * (m ^ bit0 1 - n ^ bit0 1)) ∧
int.gcd m n = 1
/-- A primitive pythogorean triple `x, y, z` is a pythagorean triple with `x` and `y` coprime.
Such a triple is “primitively classified” if there exist coprime integers `m, n` such that either
* `x = m ^ 2 - n ^ 2` and `y = 2 * m * n`, or
* `x = 2 * m * n` and `y = m ^ 2 - n ^ 2`.
-/
def is_primitive_classified {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) :=
∃ (m : ℤ),
∃ (n : ℤ),
(x = m ^ bit0 1 - n ^ bit0 1 ∧ y = bit0 1 * m * n ∨
x = bit0 1 * m * n ∧ y = m ^ bit0 1 - n ^ bit0 1) ∧
int.gcd m n = 1 ∧ (m % bit0 1 = 0 ∧ n % bit0 1 = 1 ∨ m % bit0 1 = 1 ∧ n % bit0 1 = 0)
theorem mul_is_classified {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) (k : ℤ)
(hc : is_classified h) : is_classified (mul h k) :=
sorry
theorem even_odd_of_coprime {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z)
(hc : int.gcd x y = 1) : x % bit0 1 = 0 ∧ y % bit0 1 = 1 ∨ x % bit0 1 = 1 ∧ y % bit0 1 = 0 :=
sorry
theorem gcd_dvd {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) : ↑(int.gcd x y) ∣ z := sorry
theorem normalize {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) :
pythagorean_triple (x / ↑(int.gcd x y)) (y / ↑(int.gcd x y)) (z / ↑(int.gcd x y)) :=
sorry
theorem is_classified_of_is_primitive_classified {x : ℤ} {y : ℤ} {z : ℤ}
(h : pythagorean_triple x y z) (hp : is_primitive_classified h) : is_classified h :=
sorry
theorem is_classified_of_normalize_is_primitive_classified {x : ℤ} {y : ℤ} {z : ℤ}
(h : pythagorean_triple x y z) (hc : is_primitive_classified (normalize h)) : is_classified h :=
sorry
theorem ne_zero_of_coprime {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z)
(hc : int.gcd x y = 1) : z ≠ 0 :=
sorry
theorem is_primitive_classified_of_coprime_of_zero_left {x : ℤ} {y : ℤ} {z : ℤ}
(h : pythagorean_triple x y z) (hc : int.gcd x y = 1) (hx : x = 0) :
is_primitive_classified h :=
sorry
theorem coprime_of_coprime {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z)
(hc : int.gcd x y = 1) : int.gcd y z = 1 :=
sorry
end pythagorean_triple
/-!
### A parametrization of the unit circle
For the classification of pythogorean triples, we will use a parametrization of the unit circle.
-/
/-- A parameterization of the unit circle that is useful for classifying Pythagorean triples.
(To be applied in the case where `K = ℚ`.) -/
def circle_equiv_gen {K : Type u_1} [field K] (hk : ∀ (x : K), 1 + x ^ bit0 1 ≠ 0) :
K ≃
Subtype
fun (p : K × K) => prod.fst p ^ bit0 1 + prod.snd p ^ bit0 1 = 1 ∧ prod.snd p ≠ -1 :=
equiv.mk
(fun (x : K) =>
{ val := (bit0 1 * x / (1 + x ^ bit0 1), (1 - x ^ bit0 1) / (1 + x ^ bit0 1)),
property := sorry })
(fun
(p :
Subtype fun (p : K × K) => prod.fst p ^ bit0 1 + prod.snd p ^ bit0 1 = 1 ∧ prod.snd p ≠ -1) =>
prod.fst ↑p / (prod.snd ↑p + 1))
sorry sorry
@[simp] theorem circle_equiv_apply {K : Type u_1} [field K] (hk : ∀ (x : K), 1 + x ^ bit0 1 ≠ 0)
(x : K) :
↑(coe_fn (circle_equiv_gen hk) x) =
(bit0 1 * x / (1 + x ^ bit0 1), (1 - x ^ bit0 1) / (1 + x ^ bit0 1)) :=
rfl
@[simp] theorem circle_equiv_symm_apply {K : Type u_1} [field K]
(hk : ∀ (x : K), 1 + x ^ bit0 1 ≠ 0)
(v :
Subtype fun (p : K × K) => prod.fst p ^ bit0 1 + prod.snd p ^ bit0 1 = 1 ∧ prod.snd p ≠ -1) :
coe_fn (equiv.symm (circle_equiv_gen hk)) v = prod.fst ↑v / (prod.snd ↑v + 1) :=
rfl
namespace pythagorean_triple
theorem is_primitive_classified_aux {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z)
(hc : int.gcd x y = 1) (hzpos : 0 < z) {m : ℤ} {n : ℤ} (hm2n2 : 0 < m ^ bit0 1 + n ^ bit0 1)
(hv2 : ↑x / ↑z = bit0 1 * ↑m * ↑n / (↑m ^ bit0 1 + ↑n ^ bit0 1))
(hw2 : ↑y / ↑z = (↑m ^ bit0 1 - ↑n ^ bit0 1) / (↑m ^ bit0 1 + ↑n ^ bit0 1))
(H : int.gcd (m ^ bit0 1 - n ^ bit0 1) (m ^ bit0 1 + n ^ bit0 1) = 1) (co : int.gcd m n = 1)
(pp : m % bit0 1 = 0 ∧ n % bit0 1 = 1 ∨ m % bit0 1 = 1 ∧ n % bit0 1 = 0) :
is_primitive_classified h :=
sorry
theorem is_primitive_classified_of_coprime_of_odd_of_pos {x : ℤ} {y : ℤ} {z : ℤ}
(h : pythagorean_triple x y z) (hc : int.gcd x y = 1) (hyo : y % bit0 1 = 1) (hzpos : 0 < z) :
is_primitive_classified h :=
sorry
theorem is_primitive_classified_of_coprime_of_pos {x : ℤ} {y : ℤ} {z : ℤ}
(h : pythagorean_triple x y z) (hc : int.gcd x y = 1) (hzpos : 0 < z) :
is_primitive_classified h :=
sorry
theorem is_primitive_classified_of_coprime {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z)
(hc : int.gcd x y = 1) : is_primitive_classified h :=
sorry
theorem classified {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z) : is_classified h := sorry
theorem coprime_classification {x : ℤ} {y : ℤ} {z : ℤ} :
pythagorean_triple x y z ∧ int.gcd x y = 1 ↔
∃ (m : ℤ),
∃ (n : ℤ),
(x = m ^ bit0 1 - n ^ bit0 1 ∧ y = bit0 1 * m * n ∨
x = bit0 1 * m * n ∧ y = m ^ bit0 1 - n ^ bit0 1) ∧
(z = m ^ bit0 1 + n ^ bit0 1 ∨ z = -(m ^ bit0 1 + n ^ bit0 1)) ∧
int.gcd m n = 1 ∧
(m % bit0 1 = 0 ∧ n % bit0 1 = 1 ∨ m % bit0 1 = 1 ∧ n % bit0 1 = 0) :=
sorry
/-- by assuming `x` is odd and `z` is positive we get a slightly more precise classification of
the pythagorean triple `x ^ 2 + y ^ 2 = z ^ 2`-/
theorem coprime_classification' {x : ℤ} {y : ℤ} {z : ℤ} (h : pythagorean_triple x y z)
(h_coprime : int.gcd x y = 1) (h_parity : x % bit0 1 = 1) (h_pos : 0 < z) :
∃ (m : ℤ),
∃ (n : ℤ),
x = m ^ bit0 1 - n ^ bit0 1 ∧
y = bit0 1 * m * n ∧
z = m ^ bit0 1 + n ^ bit0 1 ∧
int.gcd m n = 1 ∧
(m % bit0 1 = 0 ∧ n % bit0 1 = 1 ∨ m % bit0 1 = 1 ∧ n % bit0 1 = 0) ∧ 0 ≤ m :=
sorry
theorem classification {x : ℤ} {y : ℤ} {z : ℤ} :
pythagorean_triple x y z ↔
∃ (k : ℤ),
∃ (m : ℤ),
∃ (n : ℤ),
(x = k * (m ^ bit0 1 - n ^ bit0 1) ∧ y = k * (bit0 1 * m * n) ∨
x = k * (bit0 1 * m * n) ∧ y = k * (m ^ bit0 1 - n ^ bit0 1)) ∧
(z = k * (m ^ bit0 1 + n ^ bit0 1) ∨ z = -k * (m ^ bit0 1 + n ^ bit0 1)) :=
sorry
end Mathlib |
But the Lone Star Quilt is not for the faint of heart - you must be able to piece accurately.
This is a 6 hour class for intermediate students.
It requires accurate strip piecing, and setting in of the triangles and corner squares.
Once your strips are sewn, you will audition them to choose which of your fabrics will be in the centre.
There will be time to get several if not all of the star points finished, and setting in of the triangles and squares will be done at home.
If you or a group wish to take this class during a retreat or at one of our local stores in Vancouver, British Columbia contact me for details and reservations.
Finished with the Lone Star Quilt? Return to "Classes I Teach" |
-- Basics about complex analytic (holomorphic) functions
import analysis.analytic.basic
import analysis.analytic.composition
import analysis.analytic.linear
import analysis.calculus.fderiv_analytic
import analysis.calculus.formal_multilinear_series
import analysis.complex.cauchy_integral
import data.complex.basic
import data.finset.basic
import data.real.basic
import data.real.ennreal
import data.real.nnreal
import data.real.pi.bounds
import data.set.basic
import topology.basic
import analytic
import bounds
import multilinear
import simple
import tactics
import topology
open complex (abs exp I log)
open filter (at_top)
open metric (ball closed_ball sphere)
open linear_order (min)
open_locale real nnreal ennreal topological_space
noncomputable theory
variables {E : Type} [normed_add_comm_group E] [normed_space ℂ E] [complete_space E]
variables {F : Type} [normed_add_comm_group F] [normed_space ℂ F] [complete_space F]
-- A function is entire iff it's differentiable everywhere
lemma differentiable.entire {f : ℂ → E} : differentiable ℂ f ↔ entire ℂ f :=
⟨differentiable.analytic_at, λ e z, analytic_at.differentiable_at (e z)⟩
-- A function is analytic at z iff it's differentiable on a surrounding open set
lemma differentiable_iff_analytic {f : ℂ → E} {s : set ℂ}
(o : is_open s) : differentiable_on ℂ f s ↔ analytic_on ℂ f s := begin
constructor, {
intros d z zs,
have n : s ∈ nhds z := is_open.mem_nhds o zs,
exact differentiable_on.analytic_at d n
}, {
exact analytic_on.differentiable_on
}
end
-- Constants are entire
theorem entire.const (a : E) : entire ℂ (λ _ : ℂ, a) := differentiable.entire.mp (differentiable_const a)
-- z^n is entire
theorem entire.monomial (n : ℕ) : entire ℂ (λ z : ℂ, z^n) := begin
rw ←differentiable.entire, apply differentiable.pow differentiable_id,
end
-- Products of analytic functions are analytic
theorem analytic.mul {f g : ℂ → ℂ} {s : set ℂ}
(o : is_open s) (hf : analytic_on ℂ f s) (hg : analytic_on ℂ g s) : analytic_on ℂ (f * g) s := begin
rw ←differentiable_iff_analytic o at hf hg ⊢,
exact differentiable_on.mul hf hg,
repeat { exact complete_of_proper },
end
-- Products of analytic functions are analytic, point version
theorem analytic_at.mul {f g : ℂ → ℂ} {z : ℂ}
(hf : analytic_at ℂ f z) (hg : analytic_at ℂ g z) : analytic_at ℂ (λ z, f z * g z) z := begin
rcases hf.ball with ⟨fr,frp,fb⟩,
rcases hg.ball with ⟨gr,grp,gb⟩,
have o : is_open (ball z (min fr gr)) := metric.is_open_ball,
exact analytic.mul o
(fb.mono (metric.ball_subset_ball (by bound)))
(gb.mono (metric.ball_subset_ball (by bound)))
z (metric.mem_ball_self (by bound)),
end
-- Finite products of analytic functions are analytic
theorem prod_analytic {f : ℕ → ℂ → ℂ} {s : set ℂ}
(o : is_open s) (h : ∀ n, analytic_on ℂ (f n) s) (N : finset ℕ)
: analytic_on ℂ (λ z, N.prod (λ n, f n z)) s := begin
induction N using finset.induction with a B aB hB, {
simp, intros z zs, exact entire.const 1 z
}, {
simp_rw finset.prod_insert aB,
exact analytic.mul o (h a) hB
}
end
-- exp is entire
theorem entire.exp : entire ℂ exp := begin
rw ←differentiable.entire, simp
end
-- log is analytic at positive re
theorem log_analytic_re_pos {f : ℂ → ℂ} {c : ℂ}
: analytic_at ℂ f c → (f c).re > 0 → analytic_at ℂ (λ z, log (f z)) c := begin
intros fa cp, refine analytic_at.comp _ fa,
have la : analytic_on ℂ log (ball (f c) (f c).re), {
rw ←differentiable_iff_analytic metric.is_open_ball,
apply differentiable_on.clog differentiable_on_id,
intros z zs, apply or.inl, simp [complex.dist_eq] at ⊢ zs,
flip_ineq,
calc z.re = (f c).re - ((f c).re - z.re) : by abel
... = (f c).re - (f c - z).re : by rw ←complex.sub_re
... ≥ (f c).re - abs (f c - z) : by bound [complex.re_le_abs]
... = (f c).re - abs (-(z - f c)) : by ring_nf
... = (f c).re - abs (z - f c) : by rw complex.abs_neg
... > 0 : by bound,
apply_instance,
},
exact la _ (metric.mem_ball_self cp),
end
-- log is analytic near 1
theorem log_analytic_near_one {f : ℂ → ℂ} {s : set ℂ}
: is_open s → analytic_on ℂ f s → (∀ z, z ∈ s → abs (f z - 1) < 1)
→ analytic_on ℂ (λ z, log (f z)) s := begin
intros o fa n,
rw ←differentiable_iff_analytic o,
refine differentiable_on.clog _ _,
rw differentiable_iff_analytic o, assumption, exact complete_of_proper,
intros z zs,
exact near_one_avoids_negative_reals (n z zs),
exact complete_of_proper
end
-- The principle branch of sqrt
def sqrt (z : ℂ) : ℂ := exp (log z / 2) |
section "Equivalence to the functional semantics"
theory Big_Step_Fun_Equiv
imports
Big_Step_Determ
Big_Step_Total
Evaluate_Clock
begin
locale eval =
fixes
eval :: "v sem_env \<Rightarrow> exp \<Rightarrow> 'a state \<Rightarrow> 'a state \<times> (v, v) result" and
eval_list :: "v sem_env \<Rightarrow> exp list \<Rightarrow> 'a state \<Rightarrow> 'a state \<times> (v list, v) result" and
eval_match :: "v sem_env \<Rightarrow> v \<Rightarrow> (pat \<times> exp) list \<Rightarrow> v \<Rightarrow> 'a state \<Rightarrow> 'a state \<times> (v, v) result"
assumes
valid_eval: "evaluate True env s e (eval env e s)" and
valid_eval_list: "evaluate_list True env s es (eval_list env es s)" and
valid_eval_match: "evaluate_match True env s v pes err_v (eval_match env v pes err_v s)"
begin
lemmas eval_all = valid_eval valid_eval_list valid_eval_match
lemma evaluate_iff:
"evaluate True env st e r \<longleftrightarrow> (r = eval env e st)"
"evaluate_list True env st es r' \<longleftrightarrow> (r' = eval_list env es st)"
"evaluate_match True env st v pes v' r \<longleftrightarrow> (r = eval_match env v pes v' st)"
by (metis eval_all evaluate_determ)+
lemma evaluate_iff_sym:
"evaluate True env st e r \<longleftrightarrow> (eval env e st = r)"
"evaluate_list True env st es r' \<longleftrightarrow> (eval_list env es st = r')"
"evaluate_match True env st v pes v' r \<longleftrightarrow> (eval_match env v pes v' st = r)"
by (auto simp: evaluate_iff)
lemma other_eval_eq:
assumes "Big_Step_Fun_Equiv.eval eval' eval_list' eval_match'"
shows "eval' = eval" "eval_list' = eval_list" "eval_match' = eval_match"
proof -
interpret other: Big_Step_Fun_Equiv.eval eval' eval_list' eval_match' by fact
show "eval' = eval"
apply (rule ext)+
using evaluate_iff other.evaluate_iff
by (metis evaluate_determ)
show "eval_list' = eval_list"
apply (rule ext)+
using evaluate_iff other.evaluate_iff
by (metis evaluate_determ)
show "eval_match' = eval_match"
apply (rule ext)+
using evaluate_iff other.evaluate_iff
by (metis evaluate_determ)
qed
lemma eval_list_singleton:
"eval_list env [e] st = map_prod id list_result (eval env e st)"
proof -
define res where "res = eval_list env [e] st"
then have e: "evaluate_list True env st [e] res"
by (metis evaluate_iff)
then obtain st' r where "res = (st', r)"
by (metis surj_pair)
then have "map_prod id list_result (eval env e st) = (st', r)"
proof (cases r)
case (Rval vs)
with e obtain v where "vs = [v]" "evaluate True env st e (st', Rval v)"
unfolding \<open>res = (st', r)\<close> by (metis evaluate_list_singleton_valE)
then have "eval env e st = (st', Rval v)"
by (metis evaluate_iff_sym)
then show ?thesis
unfolding \<open>r = _\<close> \<open>vs = _\<close> by auto
next
case (Rerr err)
with e have "evaluate True env st e (st', Rerr err)"
unfolding \<open>res = (st', r)\<close> by (metis evaluate_list_singleton_errD)
then have "eval env e st = (st', Rerr err)"
by (metis evaluate_iff_sym)
then show ?thesis
unfolding \<open>r = _\<close> by (cases err) auto
qed
then show ?thesis
using res_def \<open>res = (st', r)\<close>
by metis
qed
lemma eval_eqI:
assumes "\<And>r. evaluate True env st1 e1 r \<longleftrightarrow> evaluate True env st2 e2 r"
shows "eval env e1 st1 = eval env e2 st2"
using assms by (metis evaluate_iff)
lemma eval_match_eqI:
assumes "\<And>r. evaluate_match True env1 st1 v1 pes1 err_v1 r \<longleftrightarrow> evaluate_match True env2 st2 v2 pes2 err_v2 r"
shows "eval_match env1 v1 pes1 err_v1 st1 = eval_match env2 v2 pes2 err_v2 st2"
using assms by (metis evaluate_iff)
lemma eval_tannot[simp]: "eval env (Tannot e t1) st = eval env e st"
by (rule eval_eqI) (auto elim: evaluate.cases intro: evaluate_match_evaluate_list_evaluate.intros)
lemma eval_lannot[simp]: "eval env (Lannot e t1) st = eval env e st"
by (rule eval_eqI) (auto elim: evaluate.cases intro: evaluate_match_evaluate_list_evaluate.intros)
lemma eval_match[simp]:
"eval env (Mat e pes) st =
(case eval env e st of
(st', Rval v) \<Rightarrow> eval_match env v pes Bindv st'
| (st', Rerr err) \<Rightarrow> (st', Rerr err))"
apply (subst evaluate_iff_sym[symmetric])
apply (simp only: split!: prod.splits result.splits)
subgoal
apply (subst (asm) evaluate_iff_sym[symmetric])
apply (rule mat1, rule)
apply assumption
apply (subst Bindv_def)
apply (metis valid_eval_match)
done
subgoal
apply (subst (asm) evaluate_iff_sym[symmetric])
by (auto intro: evaluate_match_evaluate_list_evaluate.intros)
done
lemma eval_match_empty[simp]: "eval_match env v2 [] err_v st = (st, Rerr (Rraise err_v))"
by (subst evaluate_iff_sym[symmetric]) (auto intro: evaluate_match_evaluate_list_evaluate.intros)
end
lemma run_eval: "\<exists>run_eval. \<forall>env e s. evaluate True env s e (run_eval env e s)"
proof -
define f where "f env_e_s = (case env_e_s of (env, e, s::'a state) \<Rightarrow> evaluate True env s e)" for env_e_s
have "\<exists>g. \<forall>env_e_s. f env_e_s (g env_e_s)"
proof (rule choice, safe, unfold f_def prod.case)
fix env e
fix s :: "'a state"
obtain s' r where "evaluate True env s e (s', r)"
by (metis evaluate_total)
then show "\<exists>r. evaluate True env s e r"
by auto
qed
then show ?thesis
unfolding f_def
by force
qed
lemma run_eval_list: "\<exists>run_eval_list. \<forall>env es s. evaluate_list True env s es (run_eval_list env es s)"
proof -
define f where "f env_es_s = (case env_es_s of (env, es, s::'a state) \<Rightarrow> evaluate_list True env s es)" for env_es_s
have "\<exists>g. \<forall>env_es_s. f env_es_s (g env_es_s)"
proof (rule choice, safe, unfold f_def prod.case)
fix env es
fix s :: "'a state"
obtain s' r where "evaluate_list True env s es (s', r)"
by (metis evaluate_list_total)
then show "\<exists>r. evaluate_list True env s es r"
by auto
qed
then show ?thesis
unfolding f_def
by force
qed
lemma run_eval_match: "\<exists>run_eval_match. \<forall>env v pes err_v s. evaluate_match True env s v pes err_v (run_eval_match env v pes err_v s)"
proof -
define f where "f env_v_pes_err_v_s = (case env_v_pes_err_v_s of (env, v, pes, err_v, s::'a state) \<Rightarrow> evaluate_match True env s v pes err_v)" for env_v_pes_err_v_s
have "\<exists>g. \<forall>env_es_s. f env_es_s (g env_es_s)"
proof (rule choice, safe, unfold f_def prod.case)
fix env v pes err_v
fix s :: "'a state"
obtain s' r where "evaluate_match True env s v pes err_v (s', r)"
by (metis evaluate_match_total)
then show "\<exists>r. evaluate_match True env s v pes err_v r"
by auto
qed
then show ?thesis
unfolding f_def
by force
qed
global_interpretation run: eval
"SOME f. \<forall>env e s. evaluate True env s e (f env e s)"
"SOME f. \<forall>env es s. evaluate_list True env s es (f env es s)"
"SOME f. \<forall>env v pes err_v s. evaluate_match True env s v pes err_v (f env v pes err_v s)"
defines
run_eval = "SOME f. \<forall>env e s. evaluate True env s e (f env e s)" and
run_eval_list = "SOME f. \<forall>env es s. evaluate_list True env s es (f env es s)" and
run_eval_match = "SOME f. \<forall>env v pes err_v s. evaluate_match True env s v pes err_v (f env v pes err_v s)"
proof (standard, goal_cases)
case 1
show ?case
using someI_ex[OF run_eval, rule_format] .
next
case 2
show ?case
using someI_ex[OF run_eval_list, rule_format] .
next
case 3
show ?case
using someI_ex[OF run_eval_match, rule_format] .
qed
hide_fact run_eval
hide_fact run_eval_list
hide_fact run_eval_match
lemma fun_evaluate:
"evaluate_match True env s v pes err_v (map_prod id (map_result hd id) (fun_evaluate_match s env v pes err_v))"
"evaluate_list True env s es (fun_evaluate s env es)"
proof (induction rule: fun_evaluate_induct)
case (5 st env e pes)
from 5(1) show ?case
apply (rule evaluate_list_singleton_cases)
subgoal
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons1)
apply (intro conjI)
apply (rule handle1)
apply assumption
apply (rule evaluate_match_evaluate_list_evaluate.empty)
done
subgoal for s' err
apply (simp split!: error_result.splits)
subgoal for exn
apply (cases "fun_evaluate_match s' env exn pes exn" rule: prod_result_cases; simp only:)
subgoal premises prems
using prems(4)
apply (rule fun_evaluate_matchE)
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons1)
apply (intro conjI)
apply (rule handle2)
apply (intro conjI)
apply (rule prems)
using 5(2)[OF prems(1)[symmetric] refl refl, unfolded prems(4)]
apply simp
by (rule evaluate_match_evaluate_list_evaluate.empty)
subgoal premises prems
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
apply (rule handle2)
apply (intro conjI)
apply (rule prems)
supply error_result.map_ident[simp]
using 5(2)[OF prems(1)[symmetric] refl refl, unfolded prems(4), simplified] .
done
subgoal
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
apply (rule handle3)
by assumption
done
done
next
case (6 st env cn es)
show ?case
proof (cases "do_con_check (c env) cn (length es)")
case True
then show ?thesis
apply simp
apply (frule 6)
apply (cases "fun_evaluate st env (rev es)" rule: prod_result_cases; simp)
subgoal for _ vs
apply (frule do_con_check_build_conv[where vs = "rev vs"], auto split: option.splits)
apply (rule evaluate_match_evaluate_list_evaluate.cons1)
apply (intro conjI)
apply (rule con1)
apply (intro conjI)
apply assumption+
by (rule evaluate_match_evaluate_list_evaluate.empty)
subgoal
by (auto intro: evaluate_match_evaluate_list_evaluate.intros)
done
next
case False
then show ?thesis
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
apply (rule con2)
by assumption
qed
next
case (9 st env op es)
note do_app.simps[simp del]
show ?case
apply (cases "fun_evaluate st env (rev es)" rule: prod_result_cases; simp)
subgoal
apply (safe; simp split!: option.splits)
subgoal using 9 by (auto intro: evaluate_match_evaluate_list_evaluate.intros)
subgoal premises prems
apply (rule conjI)
using 9 prems apply (fastforce intro: evaluate_match_evaluate_list_evaluate.intros)
apply safe
using 9(2)[OF prems(1)[symmetric] refl prems(2) prems(3) refl]
apply (cases rule: evaluate_list_singleton_cases)
subgoal by simp
subgoal
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons1)
using 9 prems
by (auto intro: evaluate_match_evaluate_list_evaluate.intros simp: dec_clock_def)
subgoal
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
using 9 prems
by (auto intro: evaluate_match_evaluate_list_evaluate.intros simp: dec_clock_def)
done
subgoal using 9 by (auto intro: evaluate_match_evaluate_list_evaluate.intros)
subgoal
apply (rule evaluate_list_singletonI)
apply (rule app4)
apply (intro conjI)
using 9 by auto
done
subgoal
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
apply (rule app6)
using 9(1) by simp
done
next
case (12 st env e pes)
from 12(1) show ?case
apply (rule evaluate_list_singleton_cases)
subgoal for s' v
apply simp
apply (cases "fun_evaluate_match s' env v pes Bindv" rule: prod_result_cases; simp only:)
subgoal premises prems
using prems(3)
apply (rule fun_evaluate_matchE)
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons1)
apply (intro conjI)
apply (rule mat1)
apply (fold Bindv_def)
apply (intro conjI)
apply (rule prems)
supply error_result.map_ident[simp]
using 12(2)[OF prems(1)[symmetric] refl, simplified, unfolded prems(3), simplified]
apply simp
by (rule evaluate_match_evaluate_list_evaluate.empty)
subgoal premises prems
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
apply (rule mat1)
apply (fold Bindv_def)
apply (intro conjI)
apply (rule prems)
supply error_result.map_ident[simp]
using 12(2)[OF prems(1)[symmetric] refl, simplified, unfolded prems(3), simplified] .
done
subgoal
apply simp
apply (rule evaluate_match_evaluate_list_evaluate.cons2)
apply (rule mat2)
by assumption
done
next
case (14 st env funs e)
then show ?case
by (cases "allDistinct (map (\<lambda>(x, y, z). x) funs)")
(fastforce intro: evaluate_match_evaluate_list_evaluate.intros elim: evaluate_list_singleton_cases)+
next
case (18 st env v2 p e pes err_v)
show ?case
proof (cases "allDistinct (pat_bindings p [])")
case True
show ?thesis
proof (cases "pmatch (c env) (refs st) p v2 []")
case No_match
with True show ?thesis
apply (simp del: id_apply)
apply (rule mat_cons2)
apply (intro conjI)
apply assumption+
apply (rule 18)
apply assumption+
done
next
case Match_type_error
with True show ?thesis
apply simp
apply (rule mat_cons3)
apply assumption+
done
next
case Match
with True show ?thesis
apply (simp del: id_apply)
apply (rule mat_cons1)
apply (intro conjI)
apply assumption+
using 18(2)
apply (rule evaluate_list_singleton_cases)
apply assumption+
apply (auto simp: error_result.map_ident)
done
qed
next
case False
show ?thesis
using False by (auto intro: mat_cons4)
qed
qed (fastforce
intro: evaluate_match_evaluate_list_evaluate.intros
elim: evaluate_list_singleton_cases
split: option.splits prod.splits result.splits if_splits exp_or_val.splits)+
global_interpretation "fun": eval
"\<lambda>env e s. map_prod id (map_result hd id) (fun_evaluate s env [e])"
"\<lambda>env es s. fun_evaluate s env es"
"\<lambda>env v pes err_v s. map_prod id (map_result hd id) (fun_evaluate_match s env v pes err_v)"
proof (standard, goal_cases)
case (1 env s e)
have "evaluate_list True env s [e] (fun_evaluate s env [e])"
by (metis fun_evaluate)
then show ?case
by (rule evaluate_list_singleton_cases) (auto simp: error_result.map_id)
next
case (2 env s es)
show ?case
by (rule fun_evaluate)
next
case (3 env s v pes err_v)
show ?case
by (rule fun_evaluate)
qed
lemmas big_fun_equivalence =
fun.other_eval_eq[OF run.eval_axioms]
\<comment> \<open>@{thm [display] big_fun_equivalence}\<close>
end |
State Before: α : Type u
β : α → Type v
inst✝ : DecidableEq α
a a' : α
s✝ : Finmap β
s : AList β
⊢ a' ∈ erase a ⟦s⟧ ↔ a' ≠ a ∧ a' ∈ ⟦s⟧ State After: no goals Tactic: simp |
/-
Copyright (c) 2019 Kevin Kappelmann. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Kappelmann
-/
import algebra.continued_fractions.translations
/-!
# Recurrence Lemmas for the `continuants` Function of Continued Fractions.
## Summary
Given a generalized continued fraction `g`, for all `n ≥ 1`, we prove that the `continuants`
function indeed satisfies the following recurrences:
- `Aₙ = bₙ * Aₙ₋₁ + aₙ * Aₙ₋₂`, and
- `Bₙ = bₙ * Bₙ₋₁ + aₙ * Bₙ₋₂`.
-/
namespace generalized_continued_fraction
variables {K : Type*} {g : generalized_continued_fraction K} {n : ℕ} [division_ring K]
lemma continuants_aux_recurrence
{gp ppred pred : pair K} (nth_s_eq : g.s.nth n = some gp)
(nth_conts_aux_eq : g.continuants_aux n = ppred)
(succ_nth_conts_aux_eq : g.continuants_aux (n + 1) = pred) :
g.continuants_aux (n + 2) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩ :=
by simp [*, continuants_aux, next_continuants, next_denominator, next_numerator]
lemma continuants_recurrence_aux
{gp ppred pred : pair K} (nth_s_eq : g.s.nth n = some gp)
(nth_conts_aux_eq : g.continuants_aux n = ppred)
(succ_nth_conts_aux_eq : g.continuants_aux (n + 1) = pred) :
g.continuants (n + 1) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩ :=
by simp [nth_cont_eq_succ_nth_cont_aux,
(continuants_aux_recurrence nth_s_eq nth_conts_aux_eq succ_nth_conts_aux_eq)]
/-- Shows that `Aₙ = bₙ * Aₙ₋₁ + aₙ * Aₙ₋₂` and `Bₙ = bₙ * Bₙ₋₁ + aₙ * Bₙ₋₂`. -/
theorem continuants_recurrence
{gp ppred pred : pair K}
(succ_nth_s_eq : g.s.nth (n + 1) = some gp)
(nth_conts_eq : g.continuants n = ppred)
(succ_nth_conts_eq : g.continuants (n + 1) = pred) :
g.continuants (n + 2) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩ :=
begin
rw [nth_cont_eq_succ_nth_cont_aux] at nth_conts_eq succ_nth_conts_eq,
exact (continuants_recurrence_aux succ_nth_s_eq nth_conts_eq succ_nth_conts_eq)
end
/-- Shows that `Aₙ = bₙ * Aₙ₋₁ + aₙ * Aₙ₋₂`. -/
lemma numerators_recurrence {gp : pair K} {ppredA predA : K}
(succ_nth_s_eq : g.s.nth (n + 1) = some gp)
(nth_num_eq : g.numerators n = ppredA)
(succ_nth_num_eq : g.numerators (n + 1) = predA) :
g.numerators (n + 2) = gp.b * predA + gp.a * ppredA :=
begin
obtain ⟨ppredConts, nth_conts_eq, ⟨rfl⟩⟩ : ∃ conts, g.continuants n = conts ∧ conts.a = ppredA,
from exists_conts_a_of_num nth_num_eq,
obtain ⟨predConts, succ_nth_conts_eq, ⟨rfl⟩⟩ :
∃ conts, g.continuants (n + 1) = conts ∧ conts.a = predA, from
exists_conts_a_of_num succ_nth_num_eq,
rw [num_eq_conts_a, (continuants_recurrence succ_nth_s_eq nth_conts_eq succ_nth_conts_eq)]
end
/-- Shows that `Bₙ = bₙ * Bₙ₋₁ + aₙ * Bₙ₋₂`. -/
end generalized_continued_fraction
|
[STATEMENT]
lemma nfv_And_Not[simp]: "nfv (And_Not \<phi> \<psi>) = max (nfv \<phi>) (nfv \<psi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. nfv (And_Not \<phi> \<psi>) = max (nfv \<phi>) (nfv \<psi>)
[PROOF STEP]
unfolding nfv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Max (insert 0 (Suc ` fv (And_Not \<phi> \<psi>))) = max (Max (insert 0 (Suc ` fv \<phi>))) (Max (insert 0 (Suc ` fv \<psi>)))
[PROOF STEP]
by (simp add: fvi_And_Not image_Un Max_Un[symmetric]) |
[STATEMENT]
lemma size_inst_fm [simp]:
\<open>size_fm (p\<langle>t/m\<rangle>) = size_fm p\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. FOL_Axiomatic_Variant.size_fm (p\<langle>t/m\<rangle>) = FOL_Axiomatic_Variant.size_fm p
[PROOF STEP]
by (induct p arbitrary: m t) auto |
lemmas scaleR_left_commute = real_vector.scale_left_commute |
Why does Helaman (the book, or the person) focus so little on Priesthood or regulating the affairs of the church, etc.?
What about the timing of Amalickiah’s revolt? Did he wait until Alma was dead (the first non-king ruler) to make his move? And what is the connection between wanting to be a king and gathering against Helaman and his brethren? They weren’t the government rulers at the time, so why are they gathering against Helaman and not the chief judge?
What about the baptism and church of Mosiah/Alma is so different from that in 3rd Nephi/Moroni?
What does 4th Ne show us about the new order established by Christ?
Is there a connection between the chapters of Malachi quoted and the resulting 4th Nephi life?
Are the disciples in and after 3rd Nephi ever called priests?
What does Nephi think about priesthood itself?
Was Nephi a high priest and Jacob and Joseph were priests under him, like Alma and Alma the younger had priests under them? Or was Nephi the king without any spiritual, consecrated office?
Abinadi seems to be a prophet but not a priest. Was Nephi the same?
Is there really a change at all these steps: Nephi, Alma, Christ, Joseph Smith?
Is Alma in borrowing the language of the “holy order” from the small plates? Is he rethinking his own priesthood in Alma 5-15 and that’s why we get the sermon in chapter 13?
How is it possible to create a Zion city with so much internal political problems?
But, as Joe pointed out, all of those problems seem to stem from priesthood.
Alma’s smart. Very smart. I don’t think we should, as is sometimes done, take Alma’s argument as somehow proof we can use to convince someone. It is a specific argument with a specific person. I think what he does is to un-do what Korihor has said, so that the possibility of faith still remains.
So, it’s cool when I realize that something we often teach without the scriptures is actually talked about in the scriptures, and with greater force and clarity than our normal way of teaching it.
The more I thought about what I had said, the more I realized that this was actually not a bad usage of Alma’s words and his talk to his son in general. Corianton had “risked to commit sin.” And specifically, he had risked this, “upon those points of doctrine” (Alma 41:10). It begins to sound like Corianton is sinning by justifying his actions with a particular way of looking at some points of doctrine. He is rationalizing, just like we do. I love this line here, from Alma 42:1 “for ye do try to suppose that it is injustice that the sinner should be consigned to a state of misery.” Ye do try to suppose. In other words, Corianton didn’t really believe it, but he tried to believe that the sinner shouldn’t be punished. He lied to himself just enough to get by.
What he was lying to himself about, from looking at 41 and 42, is that because of restoration, there wasn’t any need for repentance, really. If Christ suffered for everyone and everyone was brought back to God, then how could God punish anyone? Thus Alma clarifies that “the word restoration more fully condemneth the sinner, and justifieth him not at all” (Alma 41:15).
Anyway, the point for this YW lesson is that here we have Alma talking about rationalization and self-justification, something we’ll likely talk about during this YW lesson without ever thinking to go to the scriptures to talk about it. I love finding passages that are thinking something I want to think through. The work’s been half done for me and from a very interesting perspective! And it’s scripture, which is a fantastic common ground.
” Yea, she did steal away the hearts of many; but this was no excuse for thee, my son. Thou shouldst have tended to the ministry wherewith thou wast entrusted” (Alma 39:4). This was no excuse, says Alma. Whether or not Mormon culture agrees with their point, the Book of Mormon does. And I wonder how many other times this might happen.
Alma 12-13 lay out a very simple (too simple?) view of the story of Adam and Eve and the connection with us.
2. Alma relates that Adam and Eve broke first commandments, therefore must die.
3. Didn’t eat tree of life in order to have a space of time to repent. But they are outside the garden.
6. This comes up in chapter 13, where Alma says that high priests were on the “same standing” as others, but they chose good. In other words, they lived up to the commandment of the angel. And now their job is to teach others, just as the angels did at first. Now high priests will teach as well. |
-----------------------------------------------------------------------------
-- |
-- Module : ForSyDe.Atom.Skel.Vector.DSP
-- Copyright : (c) George Ungureanu, KTH/EECS/ESY 2019-2020
-- License : BSD-style (see the file LICENSE)
--
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
-- This module exports a set of 'Vector' patterns commonly used in signal processing
-- designs.
-----------------------------------------------------------------------------
module ForSyDe.Atom.Skel.Vector.DSP where
import Data.Complex
import qualified Data.Number.FixedFunctions as F
import ForSyDe.Atom.MoC as MoC
import ForSyDe.Atom.Skel.Vector as V hiding (duals, unduals)
import ForSyDe.Atom.Skel.Vector.Matrix as M
import ForSyDe.Atom ((><))
-- | Return the Taylor window. The Taylor window allows for a selectable sidelobe
-- suppression with a minimum broadening. This window is commonly used in radar
-- processing [1]. Code inspired from a <https://github.com/scipy/scipy/pull/8032 pull request for SciPy>.
--
-- Reference:
--
-- #ref1# [1] W. Carrara, R. Goodman, and R. Majewski "Spotlight Synthetic Aperture
-- Radar: Signal Processing Algorithms" Pages 512-513, July 1995.
taylor :: (Eq a, Floating a)
=> Int
-- ^ number of points in the output window.
-> Int
-- ^ Number of nearly constant level sidelobes adjacent to the mainlobe
-> a
-- ^ Desired peak sidelobe level in decibels (db) relative to the mainlobe
-> Vector a
-- ^ The window, with the center value normalized to one (the value one appears
-- only if the number of samples is odd).
taylor n nbar level = V.farm11 (*scale) w
where
-- explicit conversions to floating
bN = fromIntegral n
nBar = fromIntegral nbar
ma = map fromIntegral [1 .. nbar-1]
-- calculate intermediate values
b = 10**((-level) / 20)
a = log(b + sqrt(b**2 - 1)) / pi
s2 = nBar ** 2 / (a**2 + (nBar - 0.5)**2)
-- functions for calculating coefficients
fmcalc m = let numer = (-1)**(m+1) * product[1.0 - m**2/s2/(a**2 + (j - 0.5)**2) | j <- ma]
denom = 2 * product[1 - m**2/j**2 | j <- ma, j /= m]
in numer / denom
ccalc m x = cos(2 * pi * x * (m - bN/2 + 1/2) / bN)
wcalc m = 2 * dotvv (vector $ map fmcalc ma) (vector $ map (ccalc m) ma) + 1
-- calculate window coefficients
w = vector $ map (wcalc . fromIntegral) [0..n-1]
-- normalize (Note that this is not described in the original text [1])
scale = 1 / wcalc (bN - 1) / 2
-- (*^*) :: (RealFrac a, RealFrac b) => a -> b -> a
-- x *^* y = realToFrac $ realToFrac x ** realToFrac y
-- | Returns a Taylor window with default arguments: 4 sidelobes, and peak sidelobe level of -30dB
taylor' n = taylor 4 (-30)
-- | Calculates the dot product between two vectors.
dotvv :: Num a => Vector a -> Vector a -> a
dotvv a b
| V.length a == V.length b = V.reduce (+) (V.farm21 (*) a b)
| otherwise = error "Vector sizes must match"
-- | Calculates the dot product between a vector and a matrix
dotvm :: Num a => Vector a -> Vector (Vector a) -> Vector a
dotvm = dotvm' (+) (*)
-- | Higher order version of 'dotvv'. Applies dot product on vectors of /structured/
-- /types/, e.g. 'Signal's. See 'dotvv'.
dotvv' :: Num a
=> ((a -> a -> a) -> f a -> f a -> f a)
-- ^ higher-order function that can wrap the (*) operation.
-> Vector (f a) -> Vector (f a) -> f a
dotvv' wrap a b
| V.length a == V.length b = V.reduce (wrap (+)) $ V.farm21 (wrap (*)) a b
| otherwise = error "Vector sizes must match"
-- | Higher order version of 'dotvm'. Implements the template for a dot operation
-- between a vector and a matrix.
--
-- >>> let mA = vector [vector[1,-1,1], vector[1,-1,-1], vector[1,1,-1], vector[1,1,1]]
-- >>> let y = vector[1,0,0,0]
-- >>> dotVecMat (+) (*) mA y
-- <1,1,1,1>
dotvm' :: (b -> b -> b) -- ^ kernel function for a row/column reduction, e.g. @(+)@ for dot product
-> (a -> b -> b) -- ^ binary operation for pair-wise elements, e.g. @(*)@ for dot product
-> Vector a -- ^ /length/ = @xa@
-> Vector (Vector b) -- ^ /size/ = @(xa,ya)@
-> Vector b -- ^ /length/ = @ya@
dotvm' f g vs = V.reduce (V.farm21 f) . V.farm21 (\x -> V.farm11 (g x)) vs
-- | Higher order pattern implementing the template for a dot operation between a
-- vector and a matrix.
--
-- >>> let mA = vector [vector[1,-1,1], vector[1,-1,-1], vector[1,1,-1], vector[1,1,1]]
-- >>> let y = vector[1,0,0,0]
-- >>> dotVecMat (+) (*) mA y
-- <1,1,1,1>
dotmv' :: (a -> a -> a)
-- ^ kernel function for a row/column reduction, e.g. @(+)@ for dot product
-> (b -> a -> a)
-- ^ binary operation for pair-wise elements, e.g. @(*)@ for dot product
-> Vector (Vector b) -- ^ /size/ = @(xa,ya)@
-> Vector a -- ^ /length/ = @xa@
-> Vector a -- ^ /length/ = @xa@
dotmv' f g mA y = V.farm11 (\x -> V.reduce f $ V.farm21 g x y) mA
-- | Compute a Hanning window.
--
-- Inspired from <https://hackage.haskell.org/package/sdr-0.1.0.6/src/hs_sources/SDR/FilterDesign.hs>
hanning :: (Floating n)
=> Int -- ^ The length of the window
-> Vector n
hanning size = V.farm11 func $ V.vector [0..size-1]
where
func idx = let i = fromIntegral idx
n = fromIntegral size
in 0.5 * (1 - cos((2 * pi * i) / (n - 1)))
-- | Compute a Hamming window.
--
-- Inspired from <https://hackage.haskell.org/package/sdr-0.1.0.6/src/hs_sources/SDR/FilterDesign.hs>
hamming :: (Floating n)
=> Int -- ^ The length of the window
-> Vector n
hamming size = V.farm11 func $ V.vector [0..size-1]
where
func idx = let i = fromIntegral idx
n = fromIntegral size
in 0.54 - 0.46 * cos((2 * pi * i) / (n - 1))
-- | Compute a Blackman window.
--
-- Inspired from <https://hackage.haskell.org/package/sdr-0.1.0.6/src/hs_sources/SDR/FilterDesign.hs>
blackman :: (Floating n)
=> Int -- ^ The length of the window
-> Vector n
blackman size = V.farm11 func $ V.vector [0..size-1]
where
func idx = let i = fromIntegral idx
n = fromIntegral size
in 0.42 - 0.5 * cos((2 * pi * i) / (n - 1)) + 0.08 * cos((4 * pi * i) / (n - 1))
-- | Moving average filter (FIR) on numbers, applied in reverse order (more
-- optimized).
--
-- >>> let v = vector [0,0,0,0,0,1]
-- >>> let c = vector [1,2,3]
-- >>> fir c
-- <0,0,0,3,2,1>
fir :: Num a
=> Vector a -- ^ vector of coefficients
-> Vector a -- ^ input vector of numbers; /size/ = @n@
-> Vector a -- ^ output vector of numbers; /size/ = @n@
fir coefs = V.reverse . V.farm11 applyFilter . tails . V.reverse
where
applyFilter = V.reduce (+) . V.farm21 (*) coefs
-- | Higher order version of 'fir'. Can create a systolic FIR process network. See
-- <ForSyDe-Atom.html#ungureanu20a [Ungureanu20a]> for a discussion on the relation
-- between 'fir' and 'fir''.
--
-- >>> let c = vector [1,2,3]
-- >>> let s = SY.signal [1,0,0,0,0,0,0,0]
-- >>> fir' (SY.comb21 (+)) (\c -> SY.comb11 (*c)) (SY.delay 0) c s
-- {3,2,1,0,0,0,0,0}
fir' :: (a -> a -> a) -- ^ process/operation replacing '+'
-> (c -> a -> a) -- ^ process/operation replacing '*'
-> (a -> a) -- ^ delay process
-> Vector c -- ^ vector of coefficients
-> a -- ^ input signal/structure
-> a -- ^ output signal/structure
fir' plus times delay coefs =
-- V.reduce plus . V.farm21 (\c -> times c) coefs . V.recur (V.fanoutn n delay <: id)
V.reduce plus . V.farm21 times coefs . V.recuri (V.fanoutn n delay)
where n = V.length coefs - 1
-- | generates the "twiddle" coefficients for a FFT network.
twiddles :: Floating a => Int -> V.Vector (Complex a)
twiddles bN = (bitrev . V.take (bN `div` 2)) (V.farm11 bW $ vector [0..])
where bW x = (cis . negate) (-2 * pi * fromIntegral x / fromIntegral bN)
-- | Radix-2 decimation-in-frequecy Fast Fourier Transform, applied on numbers. For
-- the difference between DIT- and DIF-FFT, see
-- <https://www.slideshare.net/chappidi_saritha/decimation-in-time-and-frequency>
fft :: RealFloat a
=> Int -- ^ number of FFT stages (@== log_2@ of /length/ of input vector)
-> V.Vector (Complex a) -> V.Vector (Complex a)
fft k vs | n == 2^k = V.reverse $ bitrev $ (stage `V.pipe1` V.iterate k (*2) 2) vs
| otherwise = error $ "n=" ++ show n ++ "; k=" ++ show k
where
stage w = V.concat . V.farm21 segment (twiddles n) . V.group w
segment t = (><) unduals . (><) (V.farm22 (butterfly t)) . duals
n = V.length vs -- length of input
-------------------------------------------------
butterfly w x0 x1 = let t = w * x1 in (x0 + t, x0 - t) -- kernel function
-- | Higher order version of 'fft'. Takes the "butterfly" function as argument.
--
-- > butterfly w x0 x1 = let t = w * x1 in (x0 + t, x0 - t)
-- > fft' butterfly === fft
fft' :: Floating a
=> (Complex a -> a -> a -> (a, a)) -- ^ "butterfly" function.
-> Int -- ^ number of FFT stages (@== log_2@ of /length/ of input vector)
-> V.Vector a -> V.Vector a
fft' butterfly k vs | n == 2^k = bitrev $ (stage `V.pipe1` (V.iterate k (*2) 2)) vs
where
stage w = V.concat . V.farm21 segment (twiddles n) . V.group w
segment t = (><) unduals . (><) (V.farm22 (butterfly t)) . duals
n = V.length vs -- length of input
-- | splits a vector in two equal parts.
--
-- >>> duals $ vector [1,2,3,4,5,6,7]
-- (<1,2,3>,<4,5,6>)
duals :: Vector a -> (Vector a, Vector a)
duals v = (V.take k v, V.drop k v)
where k = V.length v `div` 2
-- | concatenates a previously split vector. See also 'duals'
unduals :: Vector a -> Vector a -> Vector a
unduals x y = x <++> y
-- | performs a bit-reverse permutation.
--
-- <<fig/skel-vector-comm-bitrev.png>>
-- <<fig/skel-vector-comm-bitrev-net.png>>
--
-- >>> bitrev $ vector ["000","001","010","011","100","101","110","111"]
-- <"111","011","101","001","110","010","100","000">
bitrev (x:>Null) = V.unit x
bitrev xs = bitrev (evens xs) <++> bitrev (odds xs)
-- duals v = let k = length v `div` 2
-- in S.farm22 (,) (take k v) (drop k v)
-- unduals = (<++>)
-- fft n = V.vector . map (fmap realToFrac) . Sh.fromVector . ShDSP.fft (2^n) . Sh.vector . map (fmap realToFrac) . V.fromVector
|
def casesTFOn {motive : Prop → Sort _} (P) [inst : Decidable P] : (T : motive True) → (F : motive False) → motive P :=
λ ht hf => match inst with
| isTrue H => eq_true H ▸ ht
| isFalse H => eq_false H ▸ hf
example (P) [Decidable P] : ¬¬P → P := by
induction P using casesTFOn
admit
admit
|
(*****************************************************************
Copowers
We define the notion of copowers in the setting of enriched
category theory. In ordinary category theory, all colimits can be
constructed from so-called conical colimits (colimits of a
functor). However, this is not necessarily the case for enriched
category theory. Instead, a more general class of colimits is
studied, called weighted colimits.
One example of a weighted colimits that is not a conical colimit,
is the copower. Suppose that `V` is a symmetric monoidal closed
category and that `C` is enriched over `V`. Given two objects
`v : V` and `x : C`, the copower is defined by the following
natural isomorphism
C ⟦ v ⊙ x , y ⟧ ≅ v ⊸ C ⟦ x , y ⟧
where `⊸` denotes the internal hom of `V`.
If we were looking at categories enriched over sets, then the
copower of a set `X` with the object `x` would be the coproduct
consisting of a copy of `x` for every member of `X`.
Contents
1. Cocones of copowers
2. Copowers in an enriched category
3. Being a copower is a proposition
4. Accessors for copowers
5. Builders for copowers
6. Copowers are closed under iso
7. Enriched categories with copowers
*****************************************************************)
Require Import UniMath.Foundations.All.
Require Import UniMath.MoreFoundations.All.
Require Import UniMath.CategoryTheory.Core.Categories.
Require Import UniMath.CategoryTheory.Core.Isos.
Require Import UniMath.CategoryTheory.Core.Univalence.
Require Import UniMath.CategoryTheory.Core.Functors.
Require Import UniMath.CategoryTheory.Monoidal.Categories.
Require Import UniMath.CategoryTheory.Monoidal.Structure.Symmetric.
Require Import UniMath.CategoryTheory.Monoidal.Structure.Closed.
Require Import UniMath.CategoryTheory.EnrichedCats.Enrichment.
Import MonoidalNotations.
Local Open Scope cat.
Local Open Scope moncat.
Opaque sym_mon_braiding.
Section EnrichedCopowers.
Context {V : sym_mon_closed_cat}
{C : category}
(E : enrichment C V)
(v : V)
(x : C).
(**
1. Cocones of copowers
*)
Definition copower_cocone
: UU
:= ∑ (a : C), v --> E ⦃ x , a ⦄.
Coercion ob_copower_cocone
(a : copower_cocone)
: C
:= pr1 a.
Definition copower_cocone_mor
(a : copower_cocone)
: v --> E ⦃ x , a ⦄
:= pr2 a.
Definition make_copower_cocone
(a : C)
(f : v --> E ⦃ x , a ⦄)
: copower_cocone
:= a ,, f.
(**
2. Copowers in an enriched category
*)
Definition is_copower_enriched_map
(a : copower_cocone)
(w : C)
: E ⦃ a , w ⦄ --> v ⊸ (E ⦃ x , w ⦄)
:= internal_lam
(identity _ #⊗ copower_cocone_mor a
· enriched_comp E _ _ _).
Definition is_copower_enriched
(a : copower_cocone)
: UU
:= ∏ (w : C),
is_z_isomorphism (is_copower_enriched_map a w).
Definition is_copower_enriched_iso
{a : copower_cocone}
(Ha : is_copower_enriched a)
(w : C)
: z_iso (E ⦃ a , w ⦄) (v ⊸ (E ⦃ x , w ⦄))
:= _ ,, Ha w.
(**
3. Being a copower is a proposition
*)
Proposition isaprop_is_copower_enriched
(a : copower_cocone)
: isaprop (is_copower_enriched a).
Proof.
use impred ; intro.
apply isaprop_is_z_isomorphism.
Qed.
(**
4. Accessors for copowers
*)
Section Accessors.
Context {a : copower_cocone}
(Ha : is_copower_enriched a).
Definition mor_to_copower
{w : V}
{b : C}
(f : w --> v ⊸ (E ⦃ x , b ⦄))
: w --> E ⦃ a , b ⦄
:= f · inv_from_z_iso (is_copower_enriched_iso Ha b).
Proposition mor_to_copower_commutes
{w : V}
{b : C}
(f : w --> v ⊸ (E ⦃ x , b ⦄))
: mor_to_copower f · is_copower_enriched_map a b
=
f.
Proof.
unfold mor_to_copower.
rewrite !assoc'.
refine (_ @ id_right _).
apply maponpaths.
apply z_iso_after_z_iso_inv.
Qed.
Proposition mor_to_copower_eq
{w : V}
{b : C}
{f g : w --> E ⦃ a , b ⦄}
(p : f · is_copower_enriched_map a b
=
g · is_copower_enriched_map a b)
: f = g.
Proof.
use (cancel_z_iso _ _ (is_copower_enriched_iso Ha _)).
exact p.
Qed.
Definition arr_to_copower
{b : C}
(f : I_{V} --> v ⊸ (E ⦃ x , b ⦄))
: a --> b
:= enriched_to_arr E (mor_to_copower f).
Proposition arr_to_copower_commutes
{b : C}
(f : I_{V} --> v ⊸ (E ⦃ x , b ⦄))
: enriched_from_arr E (arr_to_copower f) · is_copower_enriched_map a b
=
f.
Proof.
unfold arr_to_copower.
rewrite enriched_from_to_arr.
apply mor_to_copower_commutes.
Qed.
Proposition arr_to_copower_eq
{b : C}
{f g : a --> b}
(p : enriched_from_arr E f · is_copower_enriched_map a b
=
enriched_from_arr E g · is_copower_enriched_map a b)
: f = g.
Proof.
refine (!(enriched_to_from_arr E _) @ _ @ enriched_to_from_arr E _).
apply maponpaths.
use mor_to_copower_eq.
exact p.
Qed.
End Accessors.
(**
5. Builders for copowers
*)
Definition make_is_copower_enriched
(a : copower_cocone)
(p_map : ∏ (w : C), v ⊸ (E ⦃ x , w ⦄) --> E ⦃ a , w ⦄)
(H₁ : ∏ (w : C), is_copower_enriched_map a w · p_map w = identity _)
(H₂ : ∏ (w : C), p_map w · is_copower_enriched_map a w = identity _)
: is_copower_enriched a.
Proof.
intro w.
use make_is_z_isomorphism.
- exact (p_map w).
- split.
+ exact (H₁ w).
+ exact (H₂ w).
Defined.
(**
6. Copowers are closed under iso
*)
Section CopowerIso.
Context (a : copower_cocone)
(Ha : is_copower_enriched a)
(b : C)
(f : z_iso a b).
Definition copower_cocone_from_iso
: copower_cocone.
Proof.
use make_copower_cocone.
- exact b.
- exact (copower_cocone_mor a · postcomp_arr E x f).
Defined.
Definition is_copower_enriched_from_iso
: is_copower_enriched copower_cocone_from_iso.
Proof.
intros w.
refine (transportf
is_z_isomorphism
_
(is_z_iso_comp_of_is_z_isos _ _ (precomp_arr_is_z_iso E w _ (pr2 f)) (Ha w))).
unfold precomp_arr, is_copower_enriched_map.
cbn.
use internal_funext.
intros z h.
rewrite !tensor_comp_r_id_r.
refine (!_).
etrans.
{
rewrite tensor_split.
apply idpath.
}
rewrite !assoc'.
rewrite !internal_beta.
refine (!_).
etrans.
{
do 2 apply maponpaths.
rewrite !assoc.
rewrite <- tensor_split'.
rewrite tensor_split.
rewrite !assoc'.
apply maponpaths.
rewrite enrichment_assoc.
apply idpath.
}
rewrite !assoc.
apply maponpaths_2.
etrans.
{
apply maponpaths_2.
rewrite <- tensor_id_id.
rewrite !assoc'.
rewrite tensor_lassociator.
rewrite !assoc.
apply maponpaths_2.
rewrite !assoc'.
rewrite tensor_lassociator.
rewrite !assoc.
apply maponpaths_2.
rewrite tensor_split.
rewrite !assoc'.
rewrite <- mon_inv_triangle.
apply idpath.
}
rewrite <- !tensor_comp_id_l.
apply maponpaths.
rewrite !assoc'.
apply maponpaths.
unfold postcomp_arr.
rewrite !assoc.
apply maponpaths_2.
rewrite tensor_linvunitor.
rewrite !assoc'.
apply maponpaths.
rewrite <- !tensor_split.
rewrite <- !tensor_split'.
apply idpath.
Qed.
End CopowerIso.
End EnrichedCopowers.
(**
7. Enriched categories with copowers
*)
Definition enrichment_copower
{V : sym_mon_closed_cat}
{C : category}
(E : enrichment C V)
: UU
:= ∏ (v : V) (x : C),
∑ (e : copower_cocone E v x),
is_copower_enriched E v x e.
Definition cat_with_enrichment_copower
(V : sym_mon_closed_cat)
: UU
:= ∑ (C : cat_with_enrichment V), enrichment_copower C.
Coercion cat_with_enrichment_copower_to_cat_with_enrichment
{V : sym_mon_closed_cat}
(C : cat_with_enrichment_copower V)
: cat_with_enrichment V
:= pr1 C.
Definition copowers_of_cat_with_enrichment
{V : sym_mon_closed_cat}
(C : cat_with_enrichment_copower V)
: enrichment_copower C
:= pr2 C.
|
Formal statement is: lemma norm_cauchy_schwarz_equal: "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow> collinear {0, x, y}" Informal statement is: The Cauchy-Schwarz inequality is an equality if and only if the vectors are collinear. |
#write notes to cache directory
saveNotes <- function(notes, ticker, cache_path) {
saveRDS(notes, file=paste(cache_path, ticker, "/notes.Rds",sep=""))
}
#read notes from cache directory
readNotes <- function(ticker, cache_path) {
if(file.exists(paste(cache_path, ticker, "/notes.Rds",sep=""))) {
notes <- readRDS(file=paste(cache_path, ticker, "/notes.Rds",sep=""))
return(notes)
}
return("Enter notes here....")
}
|
-- ASR (2016-02-15). In the Makefile in test/compiler founded in the
-- 2.4.2.3 tag, this test used the options `+RTS -H1G -M1.5G -RTS`.
module AllStdLib where
-- Ensure that the entire standard library is compiled.
import README
open import Data.Unit.Base
open import Data.String
open import IO
import IO.Primitive as Prim
main : Prim.IO ⊤
main = run (putStrLn "Hello World!")
|
[GOAL]
n : ℕ
⊢ pred n = Option.getD (ppred n) 0
[PROOFSTEP]
cases n
[GOAL]
case zero
⊢ pred zero = Option.getD (ppred zero) 0
[PROOFSTEP]
rfl
[GOAL]
case succ
n✝ : ℕ
⊢ pred (succ n✝) = Option.getD (ppred (succ n✝)) 0
[PROOFSTEP]
rfl
[GOAL]
m n : ℕ
⊢ Option.getD (ppred (m - n)) 0 = Option.getD (psub m (n + 1)) 0
[PROOFSTEP]
rw [sub_eq_psub m n, psub]
[GOAL]
m n : ℕ
⊢ Option.getD (ppred (Option.getD (psub m n) 0)) 0 = Option.getD (psub m n >>= ppred) 0
[PROOFSTEP]
cases psub m n
[GOAL]
case none
m n : ℕ
⊢ Option.getD (ppred (Option.getD none 0)) 0 = Option.getD (none >>= ppred) 0
[PROOFSTEP]
rfl
[GOAL]
case some
m n val✝ : ℕ
⊢ Option.getD (ppred (Option.getD (some val✝) 0)) 0 = Option.getD (some val✝ >>= ppred) 0
[PROOFSTEP]
rfl
[GOAL]
m : ℕ
⊢ ppred 0 = some m ↔ succ m = 0
[PROOFSTEP]
constructor
[GOAL]
case mp
m : ℕ
⊢ ppred 0 = some m → succ m = 0
[PROOFSTEP]
intro h
[GOAL]
case mpr
m : ℕ
⊢ succ m = 0 → ppred 0 = some m
[PROOFSTEP]
intro h
[GOAL]
case mp
m : ℕ
h : ppred 0 = some m
⊢ succ m = 0
[PROOFSTEP]
contradiction
[GOAL]
case mpr
m : ℕ
h : succ m = 0
⊢ ppred 0 = some m
[PROOFSTEP]
contradiction
[GOAL]
m n : ℕ
⊢ ppred (n + 1) = some m ↔ succ m = n + 1
[PROOFSTEP]
constructor
[GOAL]
case mp
m n : ℕ
⊢ ppred (n + 1) = some m → succ m = n + 1
[PROOFSTEP]
intro h
[GOAL]
case mpr
m n : ℕ
⊢ succ m = n + 1 → ppred (n + 1) = some m
[PROOFSTEP]
intro h
[GOAL]
case mp
m n : ℕ
h : ppred (n + 1) = some m
⊢ succ m = n + 1
[PROOFSTEP]
injection h
[GOAL]
case mpr
m n : ℕ
h : succ m = n + 1
⊢ ppred (n + 1) = some m
[PROOFSTEP]
injection h
[GOAL]
case mp
m n : ℕ
val_eq✝ : Nat.add n 0 = m
⊢ succ m = n + 1
[PROOFSTEP]
subst m
[GOAL]
case mpr
m n : ℕ
n_eq✝ : m = Nat.add n 0
⊢ ppred (n + 1) = some m
[PROOFSTEP]
subst m
[GOAL]
case mp
n : ℕ
⊢ succ (Nat.add n 0) = n + 1
[PROOFSTEP]
rfl
[GOAL]
case mpr
n : ℕ
⊢ ppred (n + 1) = some (Nat.add n 0)
[PROOFSTEP]
rfl
[GOAL]
⊢ ppred 0 = none ↔ 0 = 0
[PROOFSTEP]
simp
[GOAL]
n : ℕ
⊢ ppred (n + 1) = none ↔ n + 1 = 0
[PROOFSTEP]
constructor
[GOAL]
case mp
n : ℕ
⊢ ppred (n + 1) = none → n + 1 = 0
[PROOFSTEP]
intro
[GOAL]
case mpr
n : ℕ
⊢ n + 1 = 0 → ppred (n + 1) = none
[PROOFSTEP]
intro
[GOAL]
case mp
n : ℕ
a✝ : ppred (n + 1) = none
⊢ n + 1 = 0
[PROOFSTEP]
contradiction
[GOAL]
case mpr
n : ℕ
a✝ : n + 1 = 0
⊢ ppred (n + 1) = none
[PROOFSTEP]
contradiction
[GOAL]
m k : ℕ
⊢ psub m 0 = some k ↔ k + 0 = m
[PROOFSTEP]
simp [eq_comm]
[GOAL]
m n k : ℕ
⊢ psub m (n + 1) = some k ↔ k + (n + 1) = m
[PROOFSTEP]
apply Option.bind_eq_some.trans
[GOAL]
m n k : ℕ
⊢ (∃ a, psub m (Nat.add n 0) = some a ∧ ppred a = some k) ↔ k + (n + 1) = m
[PROOFSTEP]
simp only [psub_eq_some, ppred_eq_some]
[GOAL]
m n k : ℕ
⊢ (∃ a, a + Nat.add n 0 = m ∧ succ k = a) ↔ k + (n + 1) = m
[PROOFSTEP]
simp [add_comm, add_left_comm, Nat.succ_eq_add_one]
[GOAL]
m n : ℕ
⊢ psub m n = none ↔ m < n
[PROOFSTEP]
cases s : psub m n
[GOAL]
case none
m n : ℕ
s : psub m n = none
⊢ none = none ↔ m < n
[PROOFSTEP]
simp [eq_comm]
[GOAL]
case some
m n val✝ : ℕ
s : psub m n = some val✝
⊢ some val✝ = none ↔ m < n
[PROOFSTEP]
simp [eq_comm]
[GOAL]
case none
m n : ℕ
s : psub m n = none
⊢ m < n
[PROOFSTEP]
show m < n
[GOAL]
case none
m n : ℕ
s : psub m n = none
⊢ m < n
[PROOFSTEP]
refine' lt_of_not_ge fun h => _
[GOAL]
case none
m n : ℕ
s : psub m n = none
h : m ≥ n
⊢ False
[PROOFSTEP]
cases' le.dest h with k e
[GOAL]
case none.intro
m n : ℕ
s : psub m n = none
h : m ≥ n
k : ℕ
e : n + k = m
⊢ False
[PROOFSTEP]
injection s.symm.trans (psub_eq_some.2 <| (add_comm _ _).trans e)
[GOAL]
case some
m n val✝ : ℕ
s : psub m n = some val✝
⊢ n ≤ m
[PROOFSTEP]
show n ≤ m
[GOAL]
case some
m n val✝ : ℕ
s : psub m n = some val✝
⊢ n ≤ m
[PROOFSTEP]
rw [← psub_eq_some.1 s]
[GOAL]
case some
m n val✝ : ℕ
s : psub m n = some val✝
⊢ n ≤ val✝ + n
[PROOFSTEP]
apply Nat.le_add_left
[GOAL]
m n k : ℕ
⊢ psub m (n + k) = do
let __do_lift ← psub m n
psub __do_lift k
[PROOFSTEP]
induction k
[GOAL]
case zero
m n : ℕ
⊢ psub m (n + zero) = do
let __do_lift ← psub m n
psub __do_lift zero
case succ
m n n✝ : ℕ
n_ih✝ :
psub m (n + n✝) = do
let __do_lift ← psub m n
psub __do_lift n✝
⊢ psub m (n + succ n✝) = do
let __do_lift ← psub m n
psub __do_lift (succ n✝)
[PROOFSTEP]
simp [Option.bind_eq_bind, Option.bind_some]
[GOAL]
case succ
m n n✝ : ℕ
n_ih✝ :
psub m (n + n✝) = do
let __do_lift ← psub m n
psub __do_lift n✝
⊢ psub m (n + succ n✝) = do
let __do_lift ← psub m n
psub __do_lift (succ n✝)
[PROOFSTEP]
simp [*, Nat.add_succ]
[GOAL]
m n : ℕ
⊢ psub' m n = psub m n
[PROOFSTEP]
rw [psub']
[GOAL]
m n : ℕ
⊢ (if n ≤ m then some (m - n) else none) = psub m n
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
m n : ℕ
h : n ≤ m
⊢ some (m - n) = psub m n
case neg m n : ℕ h : ¬n ≤ m ⊢ none = psub m n
[PROOFSTEP]
exact (psub_eq_sub h).symm
[GOAL]
case neg
m n : ℕ
h : ¬n ≤ m
⊢ none = psub m n
[PROOFSTEP]
exact (psub_eq_none.2 (not_le.1 h)).symm
|
/-
Results about multivariate polynomials.
-/
import data.mv_polynomial.basic
import data.matrix.basic
import lib.psd
open mv_polynomial matrix
variables {γ : Type*} [fintype γ]
variables {μ : Type*} [fintype μ]
variables {R : Type*} [linear_ordered_comm_ring R]
namespace poly
instance {σ R} [comm_semiring R] [has_le R] : has_le (mv_polynomial σ R) :=
{ le := λ p q, ∀ v, eval v p ≤ eval v q }
-- 1. eval of dot product is dot product of eval.
lemma eval_dot_product (p q : γ → mv_polynomial ℕ R) (e : ℕ → R)
: eval e (dot_product p q) = dot_product (λ i, eval e (p i)) (λ i, eval e (q i)) :=
begin
simp [dot_product], rw [eval_sum], congr, ext i, rw [(eval e).map_mul],
end
lemma eval_mul_vec (p : γ → mv_polynomial ℕ R) (M : matrix γ γ (mv_polynomial ℕ R))
(e : ℕ → R) (i : γ)
: eval e (mul_vec M p i) = mul_vec (λ i j, eval e (M i j)) (λ i, eval e (p i)) i :=
begin
simp [mul_vec, dot_product], rw [eval_sum], congr, ext l, rw [(eval e).map_mul],
end
-- 2. thus dot product same of poly is bigger than zero.
lemma dot_product_self_nonneg (p : γ → mv_polynomial ℕ R)
: 0 ≤ dot_product p p :=
begin
intros e, rw [eval_dot_product p p e], simp [eval_C 0],
exact matrix.dot_product_self_nonneg _,
end
noncomputable def matrix.to_poly (Q : matrix γ γ R) : matrix γ γ (mv_polynomial ℕ R) :=
λ i j, C (Q i j)
-- 3. thus cholesky of polynomial means poly is nonneg.
lemma nonneg_of_cholesky
(p : mv_polynomial ℕ R)
(ms : γ → mv_polynomial ℕ R)
(Q : matrix γ γ R)
(hQ : symmetric Q)
(hp : p = dot_product ms (mul_vec (matrix.to_poly Q) ms))
(hcholesky : @cholesky_decomposition γ _ μ _ R _ Q hQ)
: C 0 ≤ p :=
begin
intros e, rw [hp, eval_dot_product _ _ e],
have : (λ i, (eval e) (mul_vec (λ i j, C (Q i j)) ms i)) =
λ i, mul_vec Q (λ i, eval e (ms i)) i,
{ funext i, rw eval_mul_vec ms _ e i, congr, ext l m, exact eval_C _, },
simp [eval_C 0, matrix.to_poly], rw this,
obtain ⟨L, hL⟩ := hcholesky,
rw hL,
rw dot_product_transpose,
exact matrix.dot_product_self_nonneg _,
end
end poly
|
using PLEXOSUtils
# TODO: Actually test things
function runtest(zippath::String)
PLEXOSSolutionDatasetSummary(zippath)
PLEXOSSolutionDataset(zippath)
end
testfolder = dirname(@__FILE__) * "/"
zipfiles = ["Model Base_8200 Solution.zip",
"Model DAY_AHEAD_NO_TX Solution.zip",
"Model DAY_AHEAD_ALL_TX Solution.zip",
"Model DA_h2hybrid_SCUC_select_lines_Test_1day Solution.zip",
"Model DAY_AHEAD_PRAS Solution.zip"]
for zipfile in zipfiles
println(zipfile)
runtest(testfolder * zipfile)
end
|
Displaying games similar to Displaying: 526 Related games!
We didn't find an exact match for 'Displaying: 526 Related' but we found some similar games!
Our selection of 526 games!
Play tons of awesome 526 games from our collection of 526 games and find tons of games related to 526 from our collection of free online flash games! |
This is an antique lamp made by PERKO, who have been making lamps since 1907. This one is probably 1950s era… the “as found condition was our indicator. It definitely saw sea time... judging by the heavy patina. We have restored it to almost original condition… the brass was polished, buffed and then sealed with a clear brass lacquer. We didn’t test it but all the parts are there and it appears fully functional. The lamp’s base is weighted and the gimbals work fine. We believe the globe is original. |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Definition
open import Numbers.Naturals.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Rings.Definition
open import Rings.EuclideanDomains.Definition
open import Fields.Fields
open import Fields.Lemmas
module Rings.EuclideanDomains.Examples where
polynomialField : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (F : Field R) → (Setoid._∼_ S (Ring.1R R) (Ring.0R R) → False) → EuclideanDomain R
EuclideanDomain.isIntegralDomain (polynomialField F 1!=0) = fieldIsIntDom F
EuclideanDomain.norm (polynomialField F _) a!=0 = zero
EuclideanDomain.normSize (polynomialField F _) a!=0 b!=0 c b=ac = inr refl
DivisionAlgorithmResult.quotient (EuclideanDomain.divisionAlg (polynomialField {_*_ = _*_} F _) {a = a} {b} a!=0 b!=0) with Field.allInvertible F b b!=0
... | bInv , prB = a * bInv
DivisionAlgorithmResult.rem (EuclideanDomain.divisionAlg (polynomialField F _) a!=0 b!=0) = Field.0F F
DivisionAlgorithmResult.remSmall (EuclideanDomain.divisionAlg (polynomialField {S = S} F _) a!=0 b!=0) = inl (Equivalence.reflexive (Setoid.eq S))
DivisionAlgorithmResult.divAlg (EuclideanDomain.divisionAlg (polynomialField {S = S} {R = R} F _) {a = a} {b = b} a!=0 b!=0) with Field.allInvertible F b b!=0
... | bInv , prB = transitive (transitive (transitive (symmetric identIsIdent) (transitive *Commutative (*WellDefined reflexive (symmetric prB)))) *Associative) (symmetric identRight)
where
open Setoid S
open Equivalence eq
open Ring R
open Group additiveGroup
|
InstallMethod(TotalDegree,
"TotalDegree of multivariable polynomial",
[IsPolynomial],
function(poly)
local result;
result:=ExtRepPolynomialRatFun(poly);
result:=result{2*[1..Length(result)/2]-1};
result:=Maximum(List(result,j->Sum(j{2*[1..Length(j)/2]})));
return result;
end);
InstallMethod(ValuePoly,
"Value of multivariable polynomial",
[IsPolynomial,IsList,IsList],
function(poly,vars,vals)
local result,ext_rep,ext_vars,
monom,pos,i,j;
ext_rep:=ExtRepPolynomialRatFun(poly);
ext_vars:=List(vars,i->ExtRepPolynomialRatFun(i));
ext_vars:=List(ext_vars,i->i[1][1]);
result:=Zero(poly);
for i in 2*[1..Length(ext_rep)/2]-1 do
monom:=One(poly);
for j in 2*[1..Length(ext_rep[i])/2]-1 do
pos:=Position(ext_vars,ext_rep[i][j]);
monom:=monom*vals[pos]^ext_rep[i][j+1];
od;
monom:=monom*((ext_rep[i+1]*One(poly)));
result:=result+monom;
od;
return result;
end);
pRadical:=function(poly,avars)
local result,
ext_rep,ext_avars,
p,deg,deg_max,p_div,monom,i,j;
#exterior reprezentation of polynomial and variables
ext_rep:=ExtRepPolynomialRatFun(poly);
ext_avars:=List(avars,i->ExtRepPolynomialRatFun(i));
ext_avars:=List(ext_avars,i->i[1][1]);
# degree of variables in monomials of poly
deg:=List(ext_rep{2*[1..Length(ext_rep)/2]-1},i->i{2*[1..Length(i)/2]});
# Adjustment: (poly)^p ---> poly
p:=Characteristic(poly);
if Concatenation(deg)=[] then return poly; fi;
deg_max:=LogInt(Maximum(Concatenation(deg)),p);
p_div:=Gcd(p^deg_max,Gcd(Concatenation(deg)));
if p_div>1 then
result:=Zero(poly);
for i in 2*[1..Length(ext_rep)/2]-1 do
monom:=One(poly);
for j in 2*[1..Length(ext_rep[i])/2]-1 do
monom:=monom*avars[Position(ext_avars,ext_rep[i][j])]^(ext_rep[i][j+1]/p_div);
od;
result:=result+ext_rep[i+1]*monom;
od;
return result;
fi;
return poly;
end;
Solve:=function(poly,avars)
local ext_rep,vars,ext_avars,p,
deg,tot_deg,poz1,pozm,xpoly,xall,x,
taboo;
# Adjustment: (poly)^p ---> poly
poly:=pRadical(poly,avars);
#exterior reprezentation of polynomial and variables
ext_rep:=ExtRepPolynomialRatFun(poly);
ext_avars:=List(avars,i->ExtRepPolynomialRatFun(i));
ext_avars:=List(ext_avars,i->i[1][1]);
# variables of poly
vars:=Concatenation(ext_rep{2*[1..Length(ext_rep)/2]-1});
vars:=vars{2*[1..Length(vars)/2]-1};
# degree of variables in monomials of poly
deg:=List(ext_rep{2*[1..Length(ext_rep)/2]-1},i->i{2*[1..Length(i)/2]});
tot_deg:=List(deg,i->Sum(i));
#ignor constants
tot_deg:=Filtered(tot_deg,i->i<>0);
# Restrict: x should not be deduced from x+x^p+y
taboo:=[];
if Length(Set(vars))>1 then
for x in Set(vars) do
xall:=ext_rep{2*[1..Length(ext_rep)/2]-1};
xall:=Filtered(xall,i->x in i);
xpoly:=Filtered(xall,i->Length(i)=2);
if Length(xpoly)>=2 then
# if xall=xpoly then
# return [Position(ext_avars,x),Zero(poly),avars[Position(ext_avars,x)]];
# fi;
Add(taboo,Positions(vars,x));
fi;
od;
taboo:=Concatenation(taboo);
fi;
p:=Characteristic(poly);
# if Length(vars)=1 then
# return [Position(ext_avars,vars[1]),RootsOfUPol(poly)[1],true];
# fi;
#Error("!");
if 1 in tot_deg then
# x^p+P(x)^p
if Length(Set(vars)) = 1 and Length(Set(tot_deg))>=2 then
# Print(poly,"\n");
return [Position(ext_avars,vars[1]),Zero(poly),avars[Position(ext_avars,vars[1])]];
# return fail;
fi;
## if Length(Set(vars)) = 1 and not Difference(tot_deg,[1])[1] mod p =0 then
# if Length(Set(vars)) = 1 and not Set(tot_deg)=[1,p] then
# Print(poly,"\n");
# return [Position(ext_avars,vars[1]),Zero(poly),avars[Position(ext_avars,vars[1])]];
## return fail;
# fi;
if Length(Set(vars)) = 1 and Maximum(tot_deg)>1 then return fail; fi; # such relations produce infinite loops
# position of variables among monomials of poly
poz1:=Positions(tot_deg,1);
poz1:=Difference(poz1,taboo);
# if all variables are taboo return fail
if Length(poz1)=0 then return fail; fi;
# else choose one which is not taboo
poz1:=poz1[1];
# position of monomial in ext_rep
pozm:=Position(ext_rep,[vars[poz1],1]);
return [Position(ext_avars,vars[poz1]),avars[Position(ext_avars,vars[poz1])]-(ext_rep[pozm+1]^(-1))*poly,true];
fi;
return fail;
end;
SolveWithTorsion:=function(poly,avars)
local ext_rep,vars,ext_avars,
deg,tot_deg,poz1,pozm,xpoly,x,
taboo;
# Adjustment: (poly)^p ---> poly
poly:=pRadical(poly,avars);
#exterior reprezentation of polynomial and variables
ext_rep:=ExtRepPolynomialRatFun(poly);
ext_avars:=List(avars,i->ExtRepPolynomialRatFun(i));
ext_avars:=List(ext_avars,i->i[1][1]);
# variables of poly
vars:=Concatenation(ext_rep{2*[1..Length(ext_rep)/2]-1});
vars:=vars{2*[1..Length(vars)/2]-1};
# degree of variables in monomials of poly
deg:=List(ext_rep{2*[1..Length(ext_rep)/2]-1},i->i{2*[1..Length(i)/2]});
tot_deg:=List(deg,i->Sum(i));
#ignor constants
tot_deg:=Filtered(tot_deg,i->i<>0);
# Restrict: x should not be deduced from x+x^p+y
taboo:=[];
if Length(Set(vars))>1 then
for x in Set(vars) do
xpoly:=ext_rep{2*[1..Length(ext_rep)/2]-1};
xpoly:=Filtered(xpoly,i->x in i);
xpoly:=Filtered(xpoly,i->Length(i)=2);
if Length(xpoly)>=2 then
Add(taboo,Positions(vars,x));
fi;
od;
taboo:=Concatenation(taboo);
fi;
# if Length(vars)=1 then
# return [Position(ext_avars,vars[1]),RootsOfUPol(poly)[1],true];
# fi;
#Error("!");
if 1 in tot_deg then
# x^p+P(x)^p
if Length(Set(vars)) = 1 and Length(Set(tot_deg))>=2 then
return [Position(ext_avars,vars[1]),Zero(poly),avars[Position(ext_avars,vars[1])]];
fi;
if Length(Set(vars)) = 1 and Maximum(tot_deg)>1 then return fail; fi; # such relations produce infinite loops
# position of variables among monomials of poly
poz1:=Positions(tot_deg,1);
poz1:=Difference(poz1,taboo);
# if all variables are taboo return fail
if Length(poz1)=0 then return fail; fi;
# else choose one which is not taboo
poz1:=poz1[1];
# position of monomial in ext_rep
pozm:=Position(ext_rep,[vars[poz1],1]);
return [Position(ext_avars,vars[poz1]),avars[Position(ext_avars,vars[poz1])]-(ext_rep[pozm+1]^(-1))*poly,true];
fi;
return fail;
end;
ReduceRelations:=function(relations,avars,values,APR)
local result,#relations,
relations_len,schimbare,Ring,torsion,GB,
index,sol,i,modulo;
result:=ShallowCopy(values);
relations:=List(relations,i->Value(i,avars,result)*One(APR));
relations:=Filtered(relations,i->i <> Zero(APR));
relations:=Set(relations);
# relations:=List(coefficients(u),i->i[2]);
relations_len:=Length(relations);
# i:=1;
# while i<relations_len do
# modulo:=Concatenation([1..i-1],[i+1..relations_len]);
# modulo:=relations{modulo};
# relations:=List(relations,i->PolynomialReducedRemainder(i,relations,MonomialLexOrdering()));
# relations:=Set(Filtered(relations,i->i <> Zero(APR)));
# if Length(relations)<relations_len then i:=1; fi;
# relations_len:=Length(relations);
# od;
# Error("!");
#Print("...relations: ",relations,"\n");
schimbare:=true;
while relations<>[] and schimbare do
#Print("@@@",relations_len," ");
# Print("..relations: ",relations,"\n");
# Print("--->result: ",result,"\n");
#GB:=GroebnerBasis(relations,MonomialLexOrdering()); ## ATENTIE AICI
result:=List(result,i->PolynomialReducedRemainder(i,relations,MonomialLexOrdering()));
#result:=List(result,i->PolynomialReducedRemainder(i,GB,MonomialLexOrdering()));
# Print("fresh result:",result,"\n");
schimbare:=false;
#Error("!!");
#refresh relations
#relations:=List(relations,i->Value(i,avars,result)*One(APR));
relations:=List(relations,i->ValuePoly(i,avars,result)*One(APR));
# Print("fresh rels:",relations,"\n");
relations:=Filtered(relations,i->i <> Zero(APR));
schimbare:=Length(relations)<relations_len;
relations_len:=Length(relations);
od;
#Error("!");
#Print(".relations: ",relations,"\n");
relations:=Filtered(relations,i->i <> Zero(APR));
return [result,relations];
end;
SolveRelations:=function(relations,avars,values,APR)
local result,#relations,
relations_len,schimbare,Ring,torsion,
index,sol,i;
result:=ShallowCopy(values);
relations:=List(relations,i->Value(i,avars,result)*One(APR));
relations:=Filtered(relations,i->i <> Zero(APR));
relations:=ReduceRelations(relations,avars,result,APR);
# #Error("!");
result:=relations[1];
relations:=relations[2];
# #relations:=List(coefficients(u),i->i[2]);
relations_len:=Length(relations);
# Print("...relations: ",relations,"\n");
Ring:=CoefficientsRing(APR);
schimbare:=true;
torsion:=[];
#Error("!");
while relations<>[] and schimbare do
##Print("len:=",Length(relations),"\n");
schimbare:=false;
index:=1;
while index<=relations_len do
#Print("len===",Length(relations),"\n","index===",index,"\n");
sol:=Solve(relations[index],avars);
#Print("solved ",relations[index],"\n");
#Error("!");
#sol:=fail;
if sol<>fail then
#change result
result[sol[1]]:=sol[2];
for i in [1..Length(result)] do
if not result[i] in Ring and result[i]<>avars[i] then
result[i]:=Value(result[i],avars,result)*One(APR);
fi;
od;
#refresh relations
relations:=List(relations,i->Value(i,avars,result)*One(APR));
relations:=Filtered(relations,i->i <> Zero(APR));
#relations:=ReduceRelations(relations,avars,result,APR);
#result:=relations[1];
#relations:=relations[2];
schimbare:=Length(relations)<relations_len or sol[2]=Zero(APR);
relations_len:=Length(relations);
if Length(sol)=3 and sol[3] in avars then Add(torsion,sol[3]); fi;
fi;
index:=index+1;
od;
od;
return [result,relations,torsion];
end;
|
example : ¬ true = false := by
simp [(¬ ·)]
example (h : y = 0) : x + y = x := by
simp [(.+.)] -- Expands `HAdd.hAdd
trace_state
simp [Add.add]
simp [h, Nat.add]
done
example (h : y = 0) : x + y = x := by
simp [.+.]
trace_state
simp [Add.add]
simp [h, Nat.add]
done
|
[STATEMENT]
lemma DotAnd:
"And (Mult p A) (Mult p B), \<Delta> \<equiv> Mult p (And A B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. And (Mult p A) (Mult p B), \<Delta> \<equiv> Mult p (And A B)
[PROOF STEP]
by (simp add: dot_and1 dot_and2 equivalent_def) |
\chapter{Conclusions}
%\chapter{Zusammenfassung}
%\chapter{Fazit}
\label{ch:conclusion}
{
More information is provided by other sources \cite{mittelbach2004latex, goossens1994latex}.
} |
[STATEMENT]
lemma exec_move_While2:
assumes pc: "pc < length (compE2 e')"
shows "exec_move ci P t (while (e) e') h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) ta
h' (stk', loc', (Suc (length (compE2 e) + pc')), xcp') =
exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')"
(is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp') = exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp') \<Longrightarrow> exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
2. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') \<Longrightarrow> exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
[PROOF STEP]
let ?E = "compE2 e @ [IfFalse (3 + int (length (compE2 e')))]"
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp') \<Longrightarrow> exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
2. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') \<Longrightarrow> exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
[PROOF STEP]
let ?E' = "[Pop, Goto (- int (length (compE2 e)) + (-2 - int (length (compE2 e')))), Push Unit]"
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp') \<Longrightarrow> exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
2. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') \<Longrightarrow> exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
goal (2 subgoals):
1. exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp') \<Longrightarrow> exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
2. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') \<Longrightarrow> exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
[PROOF STEP]
hence "exec_meth ci (compP2 P) ((?E @ compE2 e') @ ?E') (compxE2 e 0 0 @ shift (length ?E) (compxE2 e' 0 0)) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')"
[PROOF STATE]
proof (prove)
using this:
exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
goal (1 subgoal):
1. exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e') @ [Pop, Goto (- int (length (compE2 e)) + (- 2 - int (length (compE2 e')))), Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])) (compxE2 e' 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc', xcp')
[PROOF STEP]
by(simp add: exec_move_def shift_compxE2 algebra_simps uminus_minus_left_commute)
[PROOF STATE]
proof (state)
this:
exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e') @ [Pop, Goto (- int (length (compE2 e)) + (- 2 - int (length (compE2 e')))), Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])) (compxE2 e' 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc', xcp')
goal (2 subgoals):
1. exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp') \<Longrightarrow> exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
2. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') \<Longrightarrow> exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
[PROOF STEP]
thus ?rhs
[PROOF STATE]
proof (prove)
using this:
exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e') @ [Pop, Goto (- int (length (compE2 e)) + (- 2 - int (length (compE2 e')))), Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])) (compxE2 e' 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc', xcp')
goal (1 subgoal):
1. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
[PROOF STEP]
unfolding exec_move_def
[PROOF STATE]
proof (prove)
using this:
exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e') @ [Pop, Goto (- int (length (compE2 e)) + (- 2 - int (length (compE2 e')))), Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])) (compxE2 e' 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc', xcp')
goal (1 subgoal):
1. exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
[PROOF STEP]
using pc
[PROOF STATE]
proof (prove)
using this:
exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e') @ [Pop, Goto (- int (length (compE2 e)) + (- 2 - int (length (compE2 e')))), Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])) (compxE2 e' 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc', xcp')
pc < length (compE2 e')
goal (1 subgoal):
1. exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
[PROOF STEP]
by -(drule exec_meth_take, simp, drule exec_meth_drop_xt, auto)
[PROOF STATE]
proof (state)
this:
exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')
goal (1 subgoal):
1. exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') \<Longrightarrow> exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')
[PROOF STEP]
qed(rule exec_move_WhileI2) |
[GOAL]
⊢ {x | Liouville x} = ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b}
[PROOFSTEP]
ext x
[GOAL]
case h
x : ℝ
⊢ x ∈ {x | Liouville x} ↔ x ∈ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b}
[PROOFSTEP]
simp only [mem_iInter, mem_iUnion, Liouville, mem_setOf_eq, exists_prop, mem_diff, mem_singleton_iff, mem_ball,
Real.dist_eq, and_comm]
[GOAL]
⊢ IsGδ {x | Liouville x}
[PROOFSTEP]
rw [setOf_liouville_eq_iInter_iUnion]
[GOAL]
⊢ IsGδ (⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b})
[PROOFSTEP]
refine isGδ_iInter fun n => IsOpen.isGδ ?_
[GOAL]
n : ℕ
⊢ IsOpen (⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b})
[PROOFSTEP]
refine isOpen_iUnion fun a => isOpen_iUnion fun b => isOpen_iUnion fun _hb => ?_
[GOAL]
n : ℕ
a b : ℤ
_hb : 1 < b
⊢ IsOpen (ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b})
[PROOFSTEP]
exact isOpen_ball.inter isClosed_singleton.isOpen_compl
[GOAL]
⊢ {x | Liouville x} = {x | Irrational x} ∩ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
refine Subset.antisymm ?_ ?_
[GOAL]
case refine_1
⊢ {x | Liouville x} ⊆ {x | Irrational x} ∩ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
refine subset_inter (fun x hx => hx.irrational) ?_
[GOAL]
case refine_1
⊢ {x | Liouville x} ⊆ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
rw [setOf_liouville_eq_iInter_iUnion]
[GOAL]
case refine_1
⊢ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b} ⊆
⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
exact iInter_mono fun n => iUnion₂_mono fun a b => iUnion_mono fun _hb => diff_subset _ _
[GOAL]
case refine_2
⊢ {x | Irrational x} ∩ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) ⊆ {x | Liouville x}
[PROOFSTEP]
simp only [inter_iInter, inter_iUnion, setOf_liouville_eq_iInter_iUnion]
[GOAL]
case refine_2
⊢ ⋂ (i : ℕ), ⋃ (i_1 : ℤ) (i_2 : ℤ) (_ : 1 < i_2), {x | Irrational x} ∩ ball (↑i_1 / ↑i_2) (1 / ↑i_2 ^ i) ⊆
⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b}
[PROOFSTEP]
refine iInter_mono fun n => iUnion₂_mono fun a b => iUnion_mono fun hb => ?_
[GOAL]
case refine_2
n : ℕ
a b : ℤ
hb : 1 < b
⊢ {x | Irrational x} ∩ ball (↑a / ↑b) (1 / ↑b ^ n) ⊆ ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b}
[PROOFSTEP]
rw [inter_comm]
[GOAL]
case refine_2
n : ℕ
a b : ℤ
hb : 1 < b
⊢ ball (↑a / ↑b) (1 / ↑b ^ n) ∩ {x | Irrational x} ⊆ ball (↑a / ↑b) (1 / ↑b ^ n) \ {↑a / ↑b}
[PROOFSTEP]
exact diff_subset_diff Subset.rfl (singleton_subset_iff.2 ⟨a / b, by norm_cast⟩)
[GOAL]
n : ℕ
a b : ℤ
hb : 1 < b
⊢ ↑(↑a / ↑b) = ↑a / ↑b
[PROOFSTEP]
norm_cast
[GOAL]
⊢ ∀ᶠ (x : ℝ) in residual ℝ, Liouville x
[PROOFSTEP]
rw [Filter.Eventually, setOf_liouville_eq_irrational_inter_iInter_iUnion]
[GOAL]
⊢ {x | Irrational x} ∩ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n) ∈ residual ℝ
[PROOFSTEP]
refine eventually_residual_irrational.and ?_
[GOAL]
⊢ ∀ᶠ (x : ℝ) in residual ℝ, x ∈ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
refine eventually_residual.2 ⟨_, ?_, Rat.denseEmbedding_coe_real.dense.mono ?_, Subset.rfl⟩
[GOAL]
case refine_1
⊢ IsGδ (⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n))
[PROOFSTEP]
exact
isGδ_iInter fun n => IsOpen.isGδ <| isOpen_iUnion fun a => isOpen_iUnion fun b => isOpen_iUnion fun _hb => isOpen_ball
[GOAL]
case refine_2
⊢ range Rat.cast ⊆ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
rintro _ ⟨r, rfl⟩
[GOAL]
case refine_2.intro
r : ℚ
⊢ ↑r ∈ ⋂ (n : ℕ), ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball (↑a / ↑b) (1 / ↑b ^ n)
[PROOFSTEP]
simp only [mem_iInter, mem_iUnion]
[GOAL]
case refine_2.intro
r : ℚ
⊢ ∀ (i : ℕ), ∃ i_1 i_2 i_3, ↑r ∈ ball (↑i_1 / ↑i_2) (1 / ↑i_2 ^ i)
[PROOFSTEP]
refine fun n => ⟨r.num * 2, r.den * 2, ?_, ?_⟩
[GOAL]
case refine_2.intro.refine_1
r : ℚ
n : ℕ
⊢ 1 < ↑r.den * 2
[PROOFSTEP]
have := Int.ofNat_le.2 r.pos
[GOAL]
case refine_2.intro.refine_1
r : ℚ
n : ℕ
this : ↑(Nat.succ 0) ≤ ↑r.den
⊢ 1 < ↑r.den * 2
[PROOFSTEP]
rw [Int.ofNat_one] at this
[GOAL]
case refine_2.intro.refine_1
r : ℚ
n : ℕ
this : 1 ≤ ↑r.den
⊢ 1 < ↑r.den * 2
[PROOFSTEP]
linarith
[GOAL]
case refine_2.intro.refine_2
r : ℚ
n : ℕ
⊢ ↑r ∈ ball (↑(r.num * 2) / ↑(↑r.den * 2)) (1 / ↑(↑r.den * 2) ^ n)
[PROOFSTEP]
convert @mem_ball_self ℝ _ (r : ℝ) _ _
[GOAL]
case h.e'_5.h.e'_3
r : ℚ
n : ℕ
⊢ ↑(r.num * 2) / ↑(↑r.den * 2) = ↑r
[PROOFSTEP]
push_cast
[GOAL]
case h.e'_5.h.e'_3
r : ℚ
n : ℕ
⊢ ↑r.num * 2 / (↑r.den * 2) = ↑r
[PROOFSTEP]
norm_cast
[GOAL]
case h.e'_5.h.e'_3
r : ℚ
n : ℕ
⊢ Rat.divInt (r.num * 2) ↑(r.den * 2) = r
[PROOFSTEP]
simp [Rat.divInt_mul_right (two_ne_zero), Rat.mkRat_self]
[GOAL]
case refine_2.intro.refine_2.convert_2
r : ℚ
n : ℕ
⊢ 0 < 1 / ↑(↑r.den * 2) ^ n
[PROOFSTEP]
refine' one_div_pos.2 (pow_pos (Int.cast_pos.2 _) _)
[GOAL]
case refine_2.intro.refine_2.convert_2
r : ℚ
n : ℕ
⊢ 0 < ↑r.den * 2
[PROOFSTEP]
exact mul_pos (Int.coe_nat_pos.2 r.pos) zero_lt_two
|
import Smt
theorem symm (p q : Bool) : p == q → q == p := by
smt
cases p <;> cases q <;> simp_all
|
Formal statement is: lemma countable_Un_Int[measurable (raw)]: "(\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Union>i\<in>I. N i) \<in> sets M" "I \<noteq> {} \<Longrightarrow> (\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Inter>i\<in>I. N i) \<in> sets M" Informal statement is: If $I$ is a countable set and $N_i \in \mathcal{M}$ for all $i \in I$, then $\bigcup_{i \in I} N_i \in \mathcal{M}$ and $\bigcap_{i \in I} N_i \in \mathcal{M}$. |
!==============================================================================
! PROGRAM Main
!==============================================================================
PROGRAM Main
USE TEST_NUMERIC_MODULE
IMPLICIT NONE
INTEGER :: nSuccess, nFail
REAL(8) :: CPU_Start, CPU_Stop
CALL CPU_TIME( CPU_Start )
CALL test_Numeric( nSuccess, nFail )
CALL CPU_TIME( CPU_Stop )
WRITE(*,*)
WRITE(*,*) 'TEST ONEKA RESULTS'
WRITE(*,*) ' nSuccess = ', nSuccess
WRITE(*,*) ' nFail = ', nFail
WRITE(*,*)
WRITE(*,'(A15,F10.2,A8)') 'Elapsed time: ', CPU_Stop - CPU_Start, ' seconds'
WRITE(*,*)
END PROGRAM MAIN |
Corn crakes were first described by Linnaeus in his Systema Naturae in 1758 as Rallus crex , but was subsequently moved to the genus Crex , created by German naturalist and ornithologist Johann Matthäus Bechstein in 1803 , and named Crex pratensis . The earlier use of crex gives it priority over Bechstein 's specific name pratensis , and leads to the current name of Crex crex . The binomial name , Crex crex , from the Ancient Greek " <unk> " , is onomatopoeic , referring to the crake 's repetitive grating call . The common name was formerly spelt as a single word , " corncrake " , but the official version is now " corn crake " . The English names refer to the species habit of nesting in dry hay or cereal fields , rather than marshes used by most members of this family .
|
My research focuses on using massive coral species (Orbicella faveolata and Siderastraea siderea) to reconsturct paleo-climates and paleo-environments. Specifically, I analyze trace metal concentrations of three elements (Sr, Ca, and Mg) present in the calcium carbonate skeleton of these massive coral species.
Jennifer A. Flannery obtained a Bachelor of Science degree in Marine Science with a Biology Concentration from Eckerd College in St. Petersburg, Florida in 2005. She completed a Master of Science program at the College of Marine Science, University of South Florida, in August, 2008.
Thesis: A 1400 year multi-proxy record of hydrologic variability in the Gulf of Mexico: Exploring ocean-continent linkages during the Late Holocene.
Thesis: Records of oceanic and continental response to abrupt climate changes during the Late Holocene (2,000BP-present) from the Pigmy Basin, Gulf of Mexico.
Gravinese, Philip M.; Flannery, Jennifer A.; Toth, Lauren T.
Flannery, J.A., J.N. Richey, K. Thirumalai, R.Z. Poore, and K.L. DeLong, 2016, Multi-species coral Sr/Ca based sea-surface temperature reconstruction data using Orbicella faveolata and Siderastrea siderea from Dry Tortugas National Park, Florida: U.S. Geological Survey data release, http://dx.doi.org/10.5066/F7CC0XS9.
Busch, T.E., Flannery, J.A., Richey, J.N., and Stathakopoulos, Anastasios, 2015, The relationship between the ratio of strontium to calcium and sea-surface temperature in a modern Porites astreoides coral—Implications for using P. astreoides as a paleoclimate archive: U.S. Geological Survey Open-File Report 2015–1182, 10 p., http://dx.doi.org/10.3133/ofr20151182.
Flannery, Jennifer A.; Poore, Richard Z.
Sr/Ca proxy sea-surface temperature reconstructions from modern and holocene Montastraea faveolata specimens from the Dry Tortugas National Park; 2013; Article; Journal; Journal of Coastal Research; Flannery, Jennifer A.; Poore, Richard Z.
Muslic, Adis; Flannery, Jennifer A.; Reich, Christopher D.; Umberger, Daniel K.; Smoak, Joseph M.; Poore, Richard Z.
Linear extension rates of massive corals from the Dry Tortugas National Park (DRTO), Florida; 2013; OFR; 2013-1121; Muslic, Adis; Flannery, Jennifer A.; Reich, Christopher D.; Umberger, Daniel K.; Smoak, Joseph M.; Poore, Richard Z.
Reich, Christopher D.; Kuffner, Ilsa B.; Hickey, T. Don; Morrison, Jennifer M.; Flannery, Jennifer A.
Complexity of nearshore strontium-to-calcium ratio variability in a core sample of the massive coral Siderastrea siderea obtained in Coral Bay, St. John, U.S. Virgin Islands; 2013; OFR; 2013-1092; Reich, Christopher D.; Kuffner, Ilsa B.; Hickey, T. Don; Morrison, Jennifer M.; Flannery, Jennifer A. |
lemmas prime_imp_coprime_int = prime_imp_coprime[where ?'a = int] |
Formal statement is: lemma strip_while_not_0_Cons_eq [simp]: "strip_while (\<lambda>x. x = 0) (x # xs) = x ## strip_while (\<lambda>x. x = 0) xs" Informal statement is: If $x$ is not $0$, then the result of stripping $x$ from the list $x :: xs$ is $x$ followed by the result of stripping $x$ from $xs$. |
(*
* Copyright (c) 2020, CleanQ Project - Systems Group, ETH Zurich
* All rights reserved.
*
* 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" for details.
*
* SPDX-License-Identifier: BSD-2-Clause
*)
section \<open>RB Model Simpl proofs\<close>
text \<open>
Due to problems importing both SIMPL and COMPLX we split the files and have all the proofs
using SIMPL in this file
\<close>
theory CleanQ_RBModel_Simpl
(*<*)
imports Main
CleanQ_RB
CleanQ_RBModel
"../Simpl/Vcg"
(*>*)
begin
(* ==================================================================================== *)
subsection \<open>Integration in SIMPL\<close>
(* ==================================================================================== *)
lemma CleanQ_RB_enq_x_preserves_invariants :
"\<Gamma>\<turnstile> \<lbrace> rb' = \<acute>RingRB \<and> CleanQ_RB_Invariants K \<acute>RingRB \<and> b \<in> rSX \<acute>RingRB \<and>
CleanQ_RB_enq_x_possible \<acute>RingRB \<rbrace>
\<acute>RingRB :== (CleanQ_RB_enq_x b \<acute>RingRB)
\<lbrace> CleanQ_RB_Invariants K \<acute>RingRB \<rbrace>"
apply(vcg)
by (meson CleanQ_RB_enq_x_inv_all)
lemma CleanQ_RB_enq_y_preserves_invariants :
"\<Gamma>\<turnstile> \<lbrace> rb' = \<acute>RingRB \<and> CleanQ_RB_Invariants K \<acute>RingRB \<and> b \<in> rSY \<acute>RingRB \<and>
CleanQ_RB_enq_y_possible \<acute>RingRB \<rbrace>
\<acute>RingRB :== (CleanQ_RB_enq_y b \<acute>RingRB)
\<lbrace> CleanQ_RB_Invariants K \<acute>RingRB \<rbrace>"
apply(vcg)
by (meson CleanQ_RB_enq_y_inv_all)
lemma CleanQ_RB_deq_x_preserves_invariants :
"\<Gamma>\<turnstile> \<lbrace> rb' = \<acute>RingRB \<and> CleanQ_RB_Invariants K \<acute>RingRB \<and> CleanQ_RB_deq_x_possible \<acute>RingRB \<rbrace>
\<acute>RingRB :== (CleanQ_RB_deq_x \<acute>RingRB)
\<lbrace> CleanQ_RB_Invariants K \<acute>RingRB \<rbrace>"
apply(vcg)
using CleanQ_RB_deq_x_all_inv by blast
lemma CleanQ_RB_deq_y_preserves_invariants :
"\<Gamma>\<turnstile> \<lbrace> rb' = \<acute>RingRB \<and> CleanQ_RB_Invariants K \<acute>RingRB \<and> CleanQ_RB_deq_y_possible \<acute>RingRB \<rbrace>
\<acute>RingRB :== (CleanQ_RB_deq_y \<acute>RingRB)
\<lbrace> CleanQ_RB_Invariants K \<acute>RingRB \<rbrace>"
apply(vcg)
using CleanQ_RB_deq_y_all_inv by blast
end |
-- examples in "Type-Driven Development with Idris"
-- chapter 13, section 1, VendingMachine part
-- check that all functions are total
%default total
VendState : Type
VendState = (Nat, Nat)
data Input = COIN
| VEND
| CHANGE
| REFILL Nat
strToInput : String -> Maybe Input
strToInput "insert" = Just COIN
strToInput "vend" = Just VEND
strToInput "change" = Just CHANGE
strToInput x = if all isDigit (unpack x)
then Just (REFILL (cast x))
else Nothing
data MachineCmd : Type ->
VendState ->
VendState ->
Type where
InsertCoin : MachineCmd () (pounds, chocs) (S pounds, chocs)
Vend : MachineCmd () (S pounds, S chocs) ( pounds, chocs)
GetCoins : MachineCmd () ( pounds, chocs) ( Z, chocs)
Refill : (bars : Nat) ->
MachineCmd () ( Z, chocs) ( Z, bars + chocs)
Display : String ->
MachineCmd () s s
GetInput : MachineCmd (Maybe Input) s s
Pure : ty -> MachineCmd ty s s
(>>=) : MachineCmd a s1 s2 ->
(a -> MachineCmd b s2 s3) ->
MachineCmd b s1 s3
data MachineIO : VendState -> Type where
Do : MachineCmd a s1 s2 ->
(a -> Inf (MachineIO s2)) -> MachineIO s1
runMachine : MachineCmd ty inState outState -> IO ty
runMachine InsertCoin = putStrLn "Coin inserted"
runMachine Vend = putStrLn "Please take your chocolate"
runMachine {inState = (pounds, _)} GetCoins = putStrLn $ (show pounds) ++ " coins returned"
runMachine (Refill bars) = putStrLn $ "Chocolate remaining: " ++ (show bars)
runMachine (Display x) = putStrLn x
runMachine {inState = (pounds, bars)} GetInput
= do putStrLn $ "Coins: " ++ (show pounds) ++ "; " ++
"Stock: " ++ (show bars)
putStr "> "
x <- getLine
pure (strToInput x)
runMachine (Pure x) = pure x
runMachine (x >>= f) = do x' <- runMachine x
runMachine (f x')
data Fuel = Dry | More (Lazy Fuel)
partial
forever : Fuel
forever = More forever
run : Fuel -> MachineIO state -> IO ()
run (More fuel) (Do c f)
= do res <- runMachine c
run fuel (f res)
run Dry p = pure ()
namespace MachineDo
(>>=) : MachineCmd a s1 s2 ->
(a -> Inf (MachineIO s2)) -> MachineIO s1
(>>=) = Do
mutual
vend : MachineIO (pounds, chocs)
vend {pounds = Z} = do Display "Insert a coin"
machineLoop
vend {chocs = Z} = do Display "Out of stock"
machineLoop
vend {pounds = (S k)} {chocs = (S j)} = do Vend
Display "Enjoy!"
machineLoop
refill : (num : Nat) -> MachineIO (pounds, chocs)
refill {pounds = Z} num = do Refill num
machineLoop
refill {pounds = (S k)} num = do Display "Cannot refill: Coins in machine"
machineLoop
machineLoop : MachineIO (pounds, chocs)
machineLoop =
do Just x <- GetInput
| Nothing => do Display "Invalid input"
machineLoop
case x of
COIN => do InsertCoin
machineLoop
VEND => vend
CHANGE => do GetCoins
Display "Change returned"
machineLoop
REFILL num => refill num
partial
main : IO ()
main = run forever (machineLoop { pounds = 0 } { chocs = 1} )
|
[STATEMENT]
lemma primitive_root_unityD: assumes "primitive_root_unity k x"
shows "k \<noteq> 0" "x^k = 1" "k' \<noteq> 0 \<Longrightarrow> x^k' = 1 \<Longrightarrow> k \<le> k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. k \<noteq> 0 &&& x ^ k = (1::'a) &&& (\<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k')
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (3 subgoals):
1. k \<noteq> 0
2. x ^ k = (1::'a)
3. \<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
[PROOF STEP]
note * = assms[unfolded primitive_root_unity_def]
[PROOF STATE]
proof (state)
this:
k \<noteq> 0 \<and> x ^ k = (1::'a) \<and> (\<forall>k'<k. k' \<noteq> 0 \<longrightarrow> x ^ k' \<noteq> (1::'a))
goal (3 subgoals):
1. k \<noteq> 0
2. x ^ k = (1::'a)
3. \<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
[PROOF STEP]
from *
[PROOF STATE]
proof (chain)
picking this:
k \<noteq> 0 \<and> x ^ k = (1::'a) \<and> (\<forall>k'<k. k' \<noteq> 0 \<longrightarrow> x ^ k' \<noteq> (1::'a))
[PROOF STEP]
have **: "k' < k \<Longrightarrow> k' \<noteq> 0 \<Longrightarrow> x ^ k' \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0 \<and> x ^ k = (1::'a) \<and> (\<forall>k'<k. k' \<noteq> 0 \<longrightarrow> x ^ k' \<noteq> (1::'a))
goal (1 subgoal):
1. \<lbrakk>k' < k; k' \<noteq> 0\<rbrakk> \<Longrightarrow> x ^ k' \<noteq> (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>k' < k; k' \<noteq> 0\<rbrakk> \<Longrightarrow> x ^ k' \<noteq> (1::'a)
goal (3 subgoals):
1. k \<noteq> 0
2. x ^ k = (1::'a)
3. \<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
[PROOF STEP]
show "k \<noteq> 0" "x^k = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. k \<noteq> 0 &&& x ^ k = (1::'a)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0 \<and> x ^ k = (1::'a) \<and> (\<forall>k'<k. k' \<noteq> 0 \<longrightarrow> x ^ k' \<noteq> (1::'a))
goal (1 subgoal):
1. k \<noteq> 0 &&& x ^ k = (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<noteq> 0
x ^ k = (1::'a)
goal (1 subgoal):
1. \<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
[PROOF STEP]
show "k' \<noteq> 0 \<Longrightarrow> x^k' = 1 \<Longrightarrow> k \<le> k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
[PROOF STEP]
using **
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>k' < k; k' \<noteq> 0\<rbrakk> \<Longrightarrow> x ^ k' \<noteq> (1::'a)
goal (1 subgoal):
1. \<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<lbrakk>k' \<noteq> 0; x ^ k' = (1::'a)\<rbrakk> \<Longrightarrow> k \<le> k'
goal:
No subgoals!
[PROOF STEP]
qed |
State Before: C : Type u
inst✝ : Category C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
j : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).obj j = F.obj j State After: no goals Tactic: aesop |
module OfficialCrashCourse.PTypes
-- Primitive Types
clue: String
clue = "Codes, Life, Universe and Everything"
theAnswer: Int
theAnswer = 42
me: Char
me = 'u'
thisIsFalse: Bool
thisIsFalse = True |
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x✝ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
⊢ 1 • (m, s).snd • (m, s).fst = 1 • (m, s).snd • (m, s).fst
[PROOFSTEP]
rw [one_smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝¹ : r S M (m1, s1) (m2, s2)
m3 : M
s3 : { x // x ∈ S }
x✝ : r S M (m2, s2) (m3, s3)
u1 : { x // x ∈ S }
hu1 : u1 • (m2, s2).snd • (m1, s1).fst = u1 • (m1, s1).snd • (m2, s2).fst
u2 : { x // x ∈ S }
hu2 : u2 • (m3, s3).snd • (m2, s2).fst = u2 • (m2, s2).snd • (m3, s3).fst
⊢ r S M (m1, s1) (m3, s3)
[PROOFSTEP]
use u1 * u2 * s2
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝¹ : r S M (m1, s1) (m2, s2)
m3 : M
s3 : { x // x ∈ S }
x✝ : r S M (m2, s2) (m3, s3)
u1 : { x // x ∈ S }
hu1 : u1 • (m2, s2).snd • (m1, s1).fst = u1 • (m1, s1).snd • (m2, s2).fst
u2 : { x // x ∈ S }
hu2 : u2 • (m3, s3).snd • (m2, s2).fst = u2 • (m2, s2).snd • (m3, s3).fst
⊢ (u1 * u2 * s2) • (m3, s3).snd • (m1, s1).fst = (u1 * u2 * s2) • (m1, s1).snd • (m3, s3).fst
[PROOFSTEP]
have hu1' := congr_arg ((· • ·) (u2 * s3)) hu1.symm
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝¹ : r S M (m1, s1) (m2, s2)
m3 : M
s3 : { x // x ∈ S }
x✝ : r S M (m2, s2) (m3, s3)
u1 : { x // x ∈ S }
hu1 : u1 • (m2, s2).snd • (m1, s1).fst = u1 • (m1, s1).snd • (m2, s2).fst
u2 : { x // x ∈ S }
hu2 : u2 • (m3, s3).snd • (m2, s2).fst = u2 • (m2, s2).snd • (m3, s3).fst
hu1' :
(fun x x_1 => x • x_1) (u2 * s3) (u1 • (m1, s1).snd • (m2, s2).fst) =
(fun x x_1 => x • x_1) (u2 * s3) (u1 • (m2, s2).snd • (m1, s1).fst)
⊢ (u1 * u2 * s2) • (m3, s3).snd • (m1, s1).fst = (u1 * u2 * s2) • (m1, s1).snd • (m3, s3).fst
[PROOFSTEP]
have hu2' := congr_arg ((· • ·) (u1 * s1)) hu2.symm
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝¹ : r S M (m1, s1) (m2, s2)
m3 : M
s3 : { x // x ∈ S }
x✝ : r S M (m2, s2) (m3, s3)
u1 : { x // x ∈ S }
hu1 : u1 • (m2, s2).snd • (m1, s1).fst = u1 • (m1, s1).snd • (m2, s2).fst
u2 : { x // x ∈ S }
hu2 : u2 • (m3, s3).snd • (m2, s2).fst = u2 • (m2, s2).snd • (m3, s3).fst
hu1' :
(fun x x_1 => x • x_1) (u2 * s3) (u1 • (m1, s1).snd • (m2, s2).fst) =
(fun x x_1 => x • x_1) (u2 * s3) (u1 • (m2, s2).snd • (m1, s1).fst)
hu2' :
(fun x x_1 => x • x_1) (u1 * s1) (u2 • (m2, s2).snd • (m3, s3).fst) =
(fun x x_1 => x • x_1) (u1 * s1) (u2 • (m3, s3).snd • (m2, s2).fst)
⊢ (u1 * u2 * s2) • (m3, s3).snd • (m1, s1).fst = (u1 * u2 * s2) • (m1, s1).snd • (m3, s3).fst
[PROOFSTEP]
simp only [← mul_smul, smul_assoc, mul_assoc, mul_comm, mul_left_comm] at hu1' hu2' ⊢
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝¹ : r S M (m1, s1) (m2, s2)
m3 : M
s3 : { x // x ∈ S }
x✝ : r S M (m2, s2) (m3, s3)
u1 : { x // x ∈ S }
hu1 : u1 • (m2, s2).snd • (m1, s1).fst = u1 • (m1, s1).snd • (m2, s2).fst
u2 : { x // x ∈ S }
hu2 : u2 • (m3, s3).snd • (m2, s2).fst = u2 • (m2, s2).snd • (m3, s3).fst
hu1' : (s1 * (s3 * (u1 * u2))) • m2 = (s2 * (s3 * (u1 * u2))) • m1
hu2' : (s1 * (s2 * (u1 * u2))) • m3 = (s1 * (s3 * (u1 * u2))) • m2
⊢ (s2 * (s3 * (u1 * u2))) • m1 = (s1 * (s2 * (u1 * u2))) • m3
[PROOFSTEP]
rw [hu2', hu1']
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
β : LocalizedModule S M → Prop
h : ∀ (m : M) (s : { x // x ∈ S }), β (mk m s)
⊢ ∀ (x : LocalizedModule S M), β x
[PROOFSTEP]
rintro ⟨⟨m, s⟩⟩
[GOAL]
case mk.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
β : LocalizedModule S M → Prop
h : ∀ (m : M) (s : { x // x ∈ S }), β (mk m s)
x✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ β (Quot.mk Setoid.r (m, s))
[PROOFSTEP]
exact h m s
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
β : LocalizedModule S M → LocalizedModule S M → Prop
h : ∀ (m m' : M) (s s' : { x // x ∈ S }), β (mk m s) (mk m' s')
⊢ ∀ (x y : LocalizedModule S M), β x y
[PROOFSTEP]
rintro ⟨⟨m, s⟩⟩ ⟨⟨m', s'⟩⟩
[GOAL]
case mk.mk.mk.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
β : LocalizedModule S M → LocalizedModule S M → Prop
h : ∀ (m m' : M) (s s' : { x // x ∈ S }), β (mk m s) (mk m' s')
x✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
y✝ : LocalizedModule S M
m' : M
s' : { x // x ∈ S }
⊢ β (Quot.mk Setoid.r (m, s)) (Quot.mk Setoid.r (m', s'))
[PROOFSTEP]
exact h m m' s s'
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
α : Type u_1
f : M × { x // x ∈ S } → α
wd : ∀ (p p' : M × { x // x ∈ S }), p ≈ p' → f p = f p'
m : M
s : { x // x ∈ S }
⊢ liftOn (mk m s) f wd = f (m, s)
[PROOFSTEP]
convert Quotient.liftOn_mk f wd ⟨m, s⟩
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
α : Type u_1
f : M × { x // x ∈ S } → M × { x // x ∈ S } → α
wd : ∀ (p q p' q' : M × { x // x ∈ S }), p ≈ p' → q ≈ q' → f p q = f p' q'
m m' : M
s s' : { x // x ∈ S }
⊢ liftOn₂ (mk m s) (mk m' s') f wd = f (m, s) (m', s')
[PROOFSTEP]
convert Quotient.liftOn₂_mk f wd _ _
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
⊢ 1 • 1 • 0 = 1 • s • 0
[PROOFSTEP]
rw [one_smul, smul_zero, smul_zero, one_smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
p1 p2 : LocalizedModule S M
x✝⁵ x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
m1' : M
s1' : { x // x ∈ S }
x✝¹ : (m1, s1) ≈ (m1', s1')
m2' : M
s2' : { x // x ∈ S }
x✝ : (m2, s2) ≈ (m2', s2')
u1 : { x // x ∈ S }
hu1 : u1 • (m1', s1').snd • (m1, s1).fst = u1 • (m1, s1).snd • (m1', s1').fst
u2 : { x // x ∈ S }
hu2 : u2 • (m2', s2').snd • (m2, s2).fst = u2 • (m2, s2).snd • (m2', s2').fst
⊢ (u1 * u2) • ((m1', s1').snd * (m2', s2').snd) • ((m2, s2).snd • (m1, s1).fst + (m1, s1).snd • (m2, s2).fst) =
(u1 * u2) • ((m1, s1).snd * (m2, s2).snd) • ((m2', s2').snd • (m1', s1').fst + (m1', s1').snd • (m2', s2').fst)
[PROOFSTEP]
have hu1' := congr_arg ((· • ·) (u2 * s2 * s2')) hu1
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
p1 p2 : LocalizedModule S M
x✝⁵ x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
m1' : M
s1' : { x // x ∈ S }
x✝¹ : (m1, s1) ≈ (m1', s1')
m2' : M
s2' : { x // x ∈ S }
x✝ : (m2, s2) ≈ (m2', s2')
u1 : { x // x ∈ S }
hu1 : u1 • (m1', s1').snd • (m1, s1).fst = u1 • (m1, s1).snd • (m1', s1').fst
u2 : { x // x ∈ S }
hu2 : u2 • (m2', s2').snd • (m2, s2).fst = u2 • (m2, s2).snd • (m2', s2').fst
hu1' :
(fun x x_1 => x • x_1) (u2 * s2 * s2') (u1 • (m1', s1').snd • (m1, s1).fst) =
(fun x x_1 => x • x_1) (u2 * s2 * s2') (u1 • (m1, s1).snd • (m1', s1').fst)
⊢ (u1 * u2) • ((m1', s1').snd * (m2', s2').snd) • ((m2, s2).snd • (m1, s1).fst + (m1, s1).snd • (m2, s2).fst) =
(u1 * u2) • ((m1, s1).snd * (m2, s2).snd) • ((m2', s2').snd • (m1', s1').fst + (m1', s1').snd • (m2', s2').fst)
[PROOFSTEP]
have hu2' := congr_arg ((· • ·) (u1 * s1 * s1')) hu2
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
p1 p2 : LocalizedModule S M
x✝⁵ x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
m1' : M
s1' : { x // x ∈ S }
x✝¹ : (m1, s1) ≈ (m1', s1')
m2' : M
s2' : { x // x ∈ S }
x✝ : (m2, s2) ≈ (m2', s2')
u1 : { x // x ∈ S }
hu1 : u1 • (m1', s1').snd • (m1, s1).fst = u1 • (m1, s1).snd • (m1', s1').fst
u2 : { x // x ∈ S }
hu2 : u2 • (m2', s2').snd • (m2, s2).fst = u2 • (m2, s2).snd • (m2', s2').fst
hu1' :
(fun x x_1 => x • x_1) (u2 * s2 * s2') (u1 • (m1', s1').snd • (m1, s1).fst) =
(fun x x_1 => x • x_1) (u2 * s2 * s2') (u1 • (m1, s1).snd • (m1', s1').fst)
hu2' :
(fun x x_1 => x • x_1) (u1 * s1 * s1') (u2 • (m2', s2').snd • (m2, s2).fst) =
(fun x x_1 => x • x_1) (u1 * s1 * s1') (u2 • (m2, s2).snd • (m2', s2').fst)
⊢ (u1 * u2) • ((m1', s1').snd * (m2', s2').snd) • ((m2, s2).snd • (m1, s1).fst + (m1, s1).snd • (m2, s2).fst) =
(u1 * u2) • ((m1, s1).snd * (m2, s2).snd) • ((m2', s2').snd • (m1', s1').fst + (m1', s1').snd • (m2', s2').fst)
[PROOFSTEP]
simp only [smul_add, ← mul_smul, smul_assoc, mul_assoc, mul_comm, mul_left_comm] at hu1' hu2' ⊢
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
p1 p2 : LocalizedModule S M
x✝⁵ x✝⁴ x✝³ x✝² : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
m1' : M
s1' : { x // x ∈ S }
x✝¹ : (m1, s1) ≈ (m1', s1')
m2' : M
s2' : { x // x ∈ S }
x✝ : (m2, s2) ≈ (m2', s2')
u1 : { x // x ∈ S }
hu1 : u1 • (m1', s1').snd • (m1, s1).fst = u1 • (m1, s1).snd • (m1', s1').fst
u2 : { x // x ∈ S }
hu2 : u2 • (m2', s2').snd • (m2, s2).fst = u2 • (m2, s2).snd • (m2', s2').fst
hu1' : (s2 * (s1' * (s2' * (u1 * u2)))) • m1 = (s1 * (s2 * (s2' * (u1 * u2)))) • m1'
hu2' : (s1 * (s1' * (s2' * (u1 * u2)))) • m2 = (s1 * (s2 * (s1' * (u1 * u2)))) • m2'
⊢ (s2 * (s1' * (s2' * (u1 * u2)))) • m1 + (s1 * (s1' * (s2' * (u1 * u2)))) • m2 =
(s1 * (s2 * (s2' * (u1 * u2)))) • m1' + (s1 * (s2 * (s1' * (u1 * u2)))) • m2'
[PROOFSTEP]
rw [hu1', hu2']
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x y z : LocalizedModule S M
⊢ x + y + z = x + (y + z)
[PROOFSTEP]
induction' x using LocalizedModule.induction_on with mx sx
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
y z : LocalizedModule S M
mx : M
sx : { x // x ∈ S }
⊢ mk mx sx + y + z = mk mx sx + (y + z)
[PROOFSTEP]
induction' y using LocalizedModule.induction_on with my sy
[GOAL]
case h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
z : LocalizedModule S M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
⊢ mk mx sx + mk my sy + z = mk mx sx + (mk my sy + z)
[PROOFSTEP]
induction' z using LocalizedModule.induction_on with mz sz
[GOAL]
case h.h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
mz : M
sz : { x // x ∈ S }
⊢ mk mx sx + mk my sy + mk mz sz = mk mx sx + (mk my sy + mk mz sz)
[PROOFSTEP]
simp only [mk_add_mk, smul_add]
[GOAL]
case h.h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
mz : M
sz : { x // x ∈ S }
⊢ mk (sz • sy • mx + sz • sx • my + (sx * sy) • mz) (sx * sy * sz) =
mk ((sy * sz) • mx + (sx • sz • my + sx • sy • mz)) (sx * (sy * sz))
[PROOFSTEP]
refine' mk_eq.mpr ⟨1, _⟩
[GOAL]
case h.h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
mz : M
sz : { x // x ∈ S }
⊢ 1 • (sx * (sy * sz)) • (sz • sy • mx + sz • sx • my + (sx * sy) • mz) =
1 • (sx * sy * sz) • ((sy * sz) • mx + (sx • sz • my + sx • sy • mz))
[PROOFSTEP]
rw [one_smul, one_smul]
[GOAL]
case h.h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
mz : M
sz : { x // x ∈ S }
⊢ (sx * (sy * sz)) • (sz • sy • mx + sz • sx • my + (sx * sy) • mz) =
(sx * sy * sz) • ((sy * sz) • mx + (sx • sz • my + sx • sy • mz))
[PROOFSTEP]
congr 1
[GOAL]
case h.h.h.e_a
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
mz : M
sz : { x // x ∈ S }
⊢ sx * (sy * sz) = sx * sy * sz
[PROOFSTEP]
rw [mul_assoc]
[GOAL]
case h.h.h.e_a
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
mx : M
sx : { x // x ∈ S }
my : M
sy : { x // x ∈ S }
mz : M
sz : { x // x ∈ S }
⊢ sz • sy • mx + sz • sx • my + (sx * sy) • mz = (sy * sz) • mx + (sx • sz • my + sx • sy • mz)
[PROOFSTEP]
rw [eq_comm, mul_comm, add_assoc, mul_smul, mul_smul, ← mul_smul sx sz, mul_comm, mul_smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x y : LocalizedModule S M
m m' : M
s s' : { x // x ∈ S }
⊢ mk m s + mk m' s' = mk m' s' + mk m s
[PROOFSTEP]
rw [mk_add_mk, mk_add_mk, add_comm, mul_comm]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ 0 + mk m s = mk m s
[PROOFSTEP]
rw [← zero_mk s, mk_add_mk, smul_zero, zero_add, mk_eq]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ ∃ u, u • s • s • m = u • (s * s) • m
[PROOFSTEP]
exact ⟨1, by rw [one_smul, mul_smul, one_smul]⟩
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ 1 • s • s • m = 1 • (s * s) • m
[PROOFSTEP]
rw [one_smul, mul_smul, one_smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ mk m s + 0 = mk m s
[PROOFSTEP]
rw [← zero_mk s, mk_add_mk, smul_zero, add_zero, mk_eq]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ ∃ u, u • s • s • m = u • (s * s) • m
[PROOFSTEP]
exact ⟨1, by rw [one_smul, mul_smul, one_smul]⟩
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ 1 • s • s • m = 1 • (s * s) • m
[PROOFSTEP]
rw [one_smul, mul_smul, one_smul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
⊢ AddCommMonoid (LocalizedModule S M)
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
p : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝ : (m1, s1) ≈ (m2, s2)
u : { x // x ∈ S }
hu : u • (m2, s2).snd • (m1, s1).fst = u • (m1, s1).snd • (m2, s2).fst
⊢ (fun x => mk (-x.fst) x.snd) (m1, s1) = (fun x => mk (-x.fst) x.snd) (m2, s2)
[PROOFSTEP]
rw [mk_eq]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
p : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝ : (m1, s1) ≈ (m2, s2)
u : { x // x ∈ S }
hu : u • (m2, s2).snd • (m1, s1).fst = u • (m1, s1).snd • (m2, s2).fst
⊢ ∃ u, u • (m2, s2).snd • -(m1, s1).fst = u • (m1, s1).snd • -(m2, s2).fst
[PROOFSTEP]
exact ⟨u, by simpa⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
p : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝ : (m1, s1) ≈ (m2, s2)
u : { x // x ∈ S }
hu : u • (m2, s2).snd • (m1, s1).fst = u • (m1, s1).snd • (m2, s2).fst
⊢ u • (m2, s2).snd • -(m1, s1).fst = u • (m1, s1).snd • -(m2, s2).fst
[PROOFSTEP]
simpa
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
⊢ ∀ (a : LocalizedModule S M), -a + a = 0
[PROOFSTEP]
rintro ⟨m, s⟩
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ -Quot.mk Setoid.r (m, s) + Quot.mk Setoid.r (m, s) = 0
[PROOFSTEP]
change
(liftOn (mk m s) (fun x => mk (-x.1) x.2) fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨u, hu⟩ =>
by
rw [mk_eq]
exact ⟨u, by simpa⟩) +
mk m s =
0
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
x✝² x✝¹ : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝ : (m1, s1) ≈ (m2, s2)
u : { x // x ∈ S }
hu : u • (m2, s2).snd • (m1, s1).fst = u • (m1, s1).snd • (m2, s2).fst
⊢ (fun x => mk (-x.fst) x.snd) (m1, s1) = (fun x => mk (-x.fst) x.snd) (m2, s2)
[PROOFSTEP]
rw [mk_eq]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
x✝² x✝¹ : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝ : (m1, s1) ≈ (m2, s2)
u : { x // x ∈ S }
hu : u • (m2, s2).snd • (m1, s1).fst = u • (m1, s1).snd • (m2, s2).fst
⊢ ∃ u, u • (m2, s2).snd • -(m1, s1).fst = u • (m1, s1).snd • -(m2, s2).fst
[PROOFSTEP]
exact ⟨u, by simpa⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
x✝² x✝¹ : M × { x // x ∈ S }
m1 : M
s1 : { x // x ∈ S }
m2 : M
s2 : { x // x ∈ S }
x✝ : (m1, s1) ≈ (m2, s2)
u : { x // x ∈ S }
hu : u • (m2, s2).snd • (m1, s1).fst = u • (m1, s1).snd • (m2, s2).fst
⊢ u • (m2, s2).snd • -(m1, s1).fst = u • (m1, s1).snd • -(m2, s2).fst
[PROOFSTEP]
simpa
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ liftOn (mk m s) (fun x => mk (-x.fst) x.snd)
(_ :
∀ (x x_1 : M × { x // x ∈ S }), x ≈ x_1 → (fun x => mk (-x.fst) x.snd) x = (fun x => mk (-x.fst) x.snd) x_1) +
mk m s =
0
[PROOFSTEP]
rw [liftOn_mk, mk_add_mk]
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M✝ : Type v
inst✝³ : AddCommMonoid M✝
inst✝² : Module R M✝
M : Type u_1
inst✝¹ : AddCommGroup M
inst✝ : Module R M
src✝ : AddCommMonoid (LocalizedModule S M) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S M
m : M
s : { x // x ∈ S }
⊢ mk (s • -(m, s).fst + (m, s).snd • m) ((m, s).snd * s) = 0
[PROOFSTEP]
simp
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
⊢ AddCommMonoid (LocalizedModule S A)
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
⊢ ∀ (p q p' q' : A × { x // x ∈ S }),
p ≈ p' →
q ≈ q' →
(fun x₁ x₂ => mk (x₁.fst * x₂.fst) (x₁.snd * x₂.snd)) p q =
(fun x₁ x₂ => mk (x₁.fst * x₂.fst) (x₁.snd * x₂.snd)) p' q'
[PROOFSTEP]
rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨b₁, t₁⟩ ⟨b₂, t₂⟩ ⟨u₁, e₁⟩ ⟨u₂, e₂⟩
[GOAL]
case mk.mk.mk.mk.intro.intro
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • (b₁, t₁).snd • (a₁, s₁).fst = u₁ • (a₁, s₁).snd • (b₁, t₁).fst
u₂ : { x // x ∈ S }
e₂ : u₂ • (b₂, t₂).snd • (a₂, s₂).fst = u₂ • (a₂, s₂).snd • (b₂, t₂).fst
⊢ (fun x₁ x₂ => mk (x₁.fst * x₂.fst) (x₁.snd * x₂.snd)) (a₁, s₁) (a₂, s₂) =
(fun x₁ x₂ => mk (x₁.fst * x₂.fst) (x₁.snd * x₂.snd)) (b₁, t₁) (b₂, t₂)
[PROOFSTEP]
rw [mk_eq]
[GOAL]
case mk.mk.mk.mk.intro.intro
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • (b₁, t₁).snd • (a₁, s₁).fst = u₁ • (a₁, s₁).snd • (b₁, t₁).fst
u₂ : { x // x ∈ S }
e₂ : u₂ • (b₂, t₂).snd • (a₂, s₂).fst = u₂ • (a₂, s₂).snd • (b₂, t₂).fst
⊢ ∃ u,
u • ((b₁, t₁).snd * (b₂, t₂).snd) • ((a₁, s₁).fst * (a₂, s₂).fst) =
u • ((a₁, s₁).snd * (a₂, s₂).snd) • ((b₁, t₁).fst * (b₂, t₂).fst)
[PROOFSTEP]
use u₁ * u₂
[GOAL]
case h
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • (b₁, t₁).snd • (a₁, s₁).fst = u₁ • (a₁, s₁).snd • (b₁, t₁).fst
u₂ : { x // x ∈ S }
e₂ : u₂ • (b₂, t₂).snd • (a₂, s₂).fst = u₂ • (a₂, s₂).snd • (b₂, t₂).fst
⊢ (u₁ * u₂) • ((b₁, t₁).snd * (b₂, t₂).snd) • ((a₁, s₁).fst * (a₂, s₂).fst) =
(u₁ * u₂) • ((a₁, s₁).snd * (a₂, s₂).snd) • ((b₁, t₁).fst * (b₂, t₂).fst)
[PROOFSTEP]
dsimp only at e₁ e₂ ⊢
[GOAL]
case h
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂) = (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂)
[PROOFSTEP]
rw [eq_comm]
[GOAL]
case h
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂) = (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂)
[PROOFSTEP]
trans (u₁ • t₁ • a₁) • u₂ • t₂ • a₂
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂) = (u₁ • t₁ • a₁) • u₂ • t₂ • a₂
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ • t₁ • a₁) • u₂ • t₂ • a₂ = (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂)
[PROOFSTEP]
rw [e₁, e₂]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂) = (u₁ • s₁ • b₁) • u₂ • s₂ • b₂
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ • t₁ • a₁) • u₂ • t₂ • a₂ = (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂)
[PROOFSTEP]
swap
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ • t₁ • a₁) • u₂ • t₂ • a₂ = (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂)
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂) = (u₁ • s₁ • b₁) • u₂ • s₂ • b₂
[PROOFSTEP]
rw [eq_comm]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂) = (u₁ • t₁ • a₁) • u₂ • t₂ • a₂
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂) = (u₁ • s₁ • b₁) • u₂ • s₂ • b₂
[PROOFSTEP]
all_goals rw [smul_smul, mul_mul_mul_comm, ← smul_eq_mul, ← smul_eq_mul A, smul_smul_smul_comm, mul_smul, mul_smul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (t₁ * t₂) • (a₁ * a₂) = (u₁ • t₁ • a₁) • u₂ • t₂ • a₂
[PROOFSTEP]
rw [smul_smul, mul_mul_mul_comm, ← smul_eq_mul, ← smul_eq_mul A, smul_smul_smul_comm, mul_smul, mul_smul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
m₁ m₂ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
b₁ : A
t₁ : { x // x ∈ S }
b₂ : A
t₂ u₁ : { x // x ∈ S }
e₁ : u₁ • t₁ • a₁ = u₁ • s₁ • b₁
u₂ : { x // x ∈ S }
e₂ : u₂ • t₂ • a₂ = u₂ • s₂ • b₂
⊢ (u₁ * u₂) • (s₁ * s₂) • (b₁ * b₂) = (u₁ • s₁ • b₁) • u₂ • s₂ • b₂
[PROOFSTEP]
rw [smul_smul, mul_mul_mul_comm, ← smul_eq_mul, ← smul_eq_mul A, smul_smul_smul_comm, mul_smul, mul_smul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a b c : LocalizedModule S A), a * (b + c) = a * b + a * c
[PROOFSTEP]
rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨a₃, s₃⟩
[GOAL]
case mk.mk.mk.mk.mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ Quot.mk Setoid.r (a₁, s₁) * (Quot.mk Setoid.r (a₂, s₂) + Quot.mk Setoid.r (a₃, s₃)) =
Quot.mk Setoid.r (a₁, s₁) * Quot.mk Setoid.r (a₂, s₂) + Quot.mk Setoid.r (a₁, s₁) * Quot.mk Setoid.r (a₃, s₃)
[PROOFSTEP]
apply mk_eq.mpr _
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ ∃ u,
u •
(((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd *
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd) •
((a₁, s₁).fst *
((a₃, s₃).snd • (a₂, s₂).fst + (a₂, s₂).snd • (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).fst) =
u •
((a₁, s₁).snd * ((a₃, s₃).snd • (a₂, s₂).fst + (a₂, s₂).snd • (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd) •
(((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd •
((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).fst +
((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd •
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).fst)
[PROOFSTEP]
use 1
[GOAL]
case h
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ 1 •
(((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd *
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd) •
((a₁, s₁).fst * ((a₃, s₃).snd • (a₂, s₂).fst + (a₂, s₂).snd • (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).fst) =
1 •
((a₁, s₁).snd * ((a₃, s₃).snd • (a₂, s₂).fst + (a₂, s₂).snd • (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd) •
(((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd •
((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).fst +
((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd •
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).fst)
[PROOFSTEP]
simp only [one_mul, smul_add, mul_add, mul_smul_comm, smul_smul, ← mul_assoc, mul_right_comm]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a b c : LocalizedModule S A), (a + b) * c = a * c + b * c
[PROOFSTEP]
rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨a₃, s₃⟩
[GOAL]
case mk.mk.mk.mk.mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ (Quot.mk Setoid.r (a₁, s₁) + Quot.mk Setoid.r (a₂, s₂)) * Quot.mk Setoid.r (a₃, s₃) =
Quot.mk Setoid.r (a₁, s₁) * Quot.mk Setoid.r (a₃, s₃) + Quot.mk Setoid.r (a₂, s₂) * Quot.mk Setoid.r (a₃, s₃)
[PROOFSTEP]
apply mk_eq.mpr _
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ ∃ u,
u •
(((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd *
((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd) •
(((a₂, s₂).snd • (a₁, s₁).fst + (a₁, s₁).snd • (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).fst *
(a₃, s₃).fst) =
u •
(((a₂, s₂).snd • (a₁, s₁).fst + (a₁, s₁).snd • (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd * (a₃, s₃).snd) •
(((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd •
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).fst +
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd •
((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).fst)
[PROOFSTEP]
use 1
[GOAL]
case h
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ 1 •
(((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd *
((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd) •
(((a₂, s₂).snd • (a₁, s₁).fst + (a₁, s₁).snd • (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).fst * (a₃, s₃).fst) =
1 •
(((a₂, s₂).snd • (a₁, s₁).fst + (a₁, s₁).snd • (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd * (a₃, s₃).snd) •
(((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd •
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).fst +
((a₁, s₁).fst * (a₃, s₃).fst, (a₁, s₁).snd * (a₃, s₃).snd).snd •
((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).fst)
[PROOFSTEP]
simp only [one_mul, smul_add, add_mul, smul_smul, ← mul_assoc, smul_mul_assoc, mul_right_comm]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a : LocalizedModule S A), 0 * a = 0
[PROOFSTEP]
rintro ⟨a, s⟩
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ 0 * Quot.mk Setoid.r (a, s) = 0
[PROOFSTEP]
exact mk_eq.mpr ⟨1, by simp only [zero_mul, smul_zero]⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ 1 • 1 • ((0, 1).fst * (a, s).fst) = 1 • ((0, 1).snd * (a, s).snd) • 0
[PROOFSTEP]
simp only [zero_mul, smul_zero]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a : LocalizedModule S A), a * 0 = 0
[PROOFSTEP]
rintro ⟨a, s⟩
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ Quot.mk Setoid.r (a, s) * 0 = 0
[PROOFSTEP]
exact mk_eq.mpr ⟨1, by simp only [mul_zero, smul_zero]⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ 1 • 1 • ((a, s).fst * (0, 1).fst) = 1 • ((a, s).snd * (0, 1).snd) • 0
[PROOFSTEP]
simp only [mul_zero, smul_zero]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a b c : LocalizedModule S A), a * b * c = a * (b * c)
[PROOFSTEP]
rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨a₃, s₃⟩
[GOAL]
case mk.mk.mk.mk.mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ Quot.mk Setoid.r (a₁, s₁) * Quot.mk Setoid.r (a₂, s₂) * Quot.mk Setoid.r (a₃, s₃) =
Quot.mk Setoid.r (a₁, s₁) * (Quot.mk Setoid.r (a₂, s₂) * Quot.mk Setoid.r (a₃, s₃))
[PROOFSTEP]
apply mk_eq.mpr _
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ ∃ u,
u •
((a₁, s₁).snd * ((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd) •
(((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).fst * (a₃, s₃).fst) =
u •
(((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd * (a₃, s₃).snd) •
((a₁, s₁).fst * ((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).fst)
[PROOFSTEP]
use 1
[GOAL]
case h
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
c✝ : LocalizedModule S A
a₃ : A
s₃ : { x // x ∈ S }
⊢ 1 •
((a₁, s₁).snd * ((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).snd) •
(((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).fst * (a₃, s₃).fst) =
1 •
(((a₁, s₁).fst * (a₂, s₂).fst, (a₁, s₁).snd * (a₂, s₂).snd).snd * (a₃, s₃).snd) •
((a₁, s₁).fst * ((a₂, s₂).fst * (a₃, s₃).fst, (a₂, s₂).snd * (a₃, s₃).snd).fst)
[PROOFSTEP]
simp only [one_mul, smul_smul, ← mul_assoc, mul_right_comm]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a : LocalizedModule S A), 1 * a = a
[PROOFSTEP]
rintro ⟨a, s⟩
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ 1 * Quot.mk Setoid.r (a, s) = Quot.mk Setoid.r (a, s)
[PROOFSTEP]
exact mk_eq.mpr ⟨1, by simp only [one_mul, one_smul]⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ 1 • s • ((1, 1).fst * (a, s).fst) = 1 • ((1, 1).snd * (a, s).snd) • a
[PROOFSTEP]
simp only [one_mul, one_smul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a : LocalizedModule S A), a * 1 = a
[PROOFSTEP]
rintro ⟨a, s⟩
[GOAL]
case mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ Quot.mk Setoid.r (a, s) * 1 = Quot.mk Setoid.r (a, s)
[PROOFSTEP]
exact mk_eq.mpr ⟨1, by simp only [mul_one, one_smul]⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.132539
inst✝¹ : Semiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : AddCommMonoid (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a : A
s : { x // x ∈ S }
⊢ 1 • s • ((a, s).fst * (1, 1).fst) = 1 • ((a, s).snd * (1, 1).snd) • a
[PROOFSTEP]
simp only [mul_one, one_smul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : CommSemiring A
inst✝ : Algebra R A
S : Submonoid R
⊢ Semiring (LocalizedModule S A)
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : CommSemiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : Semiring (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a b : LocalizedModule S A), a * b = b * a
[PROOFSTEP]
rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩
[GOAL]
case mk.mk.mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : CommSemiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : Semiring (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
⊢ Quot.mk Setoid.r (a₁, s₁) * Quot.mk Setoid.r (a₂, s₂) = Quot.mk Setoid.r (a₂, s₂) * Quot.mk Setoid.r (a₁, s₁)
[PROOFSTEP]
exact mk_eq.mpr ⟨1, by simp only [one_smul, mul_comm]⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : CommSemiring A
inst✝ : Algebra R A
S : Submonoid R
src✝ : Semiring (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
⊢ 1 • ((a₂, s₂).snd * (a₁, s₁).snd) • ((a₁, s₁).fst * (a₂, s₂).fst) =
1 • ((a₁, s₁).snd * (a₂, s₂).snd) • ((a₂, s₂).fst * (a₁, s₁).fst)
[PROOFSTEP]
simp only [one_smul, mul_comm]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type ?u.187761
inst✝¹ : CommRing A
inst✝ : Algebra R A
S : Submonoid R
⊢ Ring (LocalizedModule S A)
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type
inst✝¹ : CommRing A
inst✝ : Algebra R A
S : Submonoid R
src✝ : Ring (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (a b : LocalizedModule S A), a * b = b * a
[PROOFSTEP]
rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩
[GOAL]
case mk.mk.mk.mk
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type
inst✝¹ : CommRing A
inst✝ : Algebra R A
S : Submonoid R
src✝ : Ring (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
⊢ Quot.mk Setoid.r (a₁, s₁) * Quot.mk Setoid.r (a₂, s₂) = Quot.mk Setoid.r (a₂, s₂) * Quot.mk Setoid.r (a₁, s₁)
[PROOFSTEP]
exact mk_eq.mpr ⟨1, by simp only [one_smul, mul_comm]⟩
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S✝ : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type
inst✝¹ : CommRing A
inst✝ : Algebra R A
S : Submonoid R
src✝ : Ring (LocalizedModule S A) :=
let_fun this := inferInstance;
this
a✝ : LocalizedModule S A
a₁ : A
s₁ : { x // x ∈ S }
b✝ : LocalizedModule S A
a₂ : A
s₂ : { x // x ∈ S }
⊢ 1 • ((a₂, s₂).snd * (a₁, s₁).snd) • ((a₁, s₁).fst * (a₂, s₂).fst) =
1 • ((a₁, s₁).snd * (a₂, s₂).snd) • ((a₂, s₂).fst * (a₁, s₁).fst)
[PROOFSTEP]
simp only [one_smul, mul_comm]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
x : LocalizedModule S M
r : R
s : { x // x ∈ S }
⊢ ∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'
[PROOFSTEP]
rintro ⟨m1, t1⟩ ⟨m2, t2⟩ ⟨u, h⟩
[GOAL]
case mk.mk.intro
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
x : LocalizedModule S M
r : R
s : { x // x ∈ S }
m1 : M
t1 : { x // x ∈ S }
m2 : M
t2 u : { x // x ∈ S }
h : u • (m2, t2).snd • (m1, t1).fst = u • (m1, t1).snd • (m2, t2).fst
⊢ (fun p => mk (r • p.fst) (s * p.snd)) (m1, t1) = (fun p => mk (r • p.fst) (s * p.snd)) (m2, t2)
[PROOFSTEP]
refine' mk_eq.mpr ⟨u, _⟩
[GOAL]
case mk.mk.intro
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
x : LocalizedModule S M
r : R
s : { x // x ∈ S }
m1 : M
t1 : { x // x ∈ S }
m2 : M
t2 u : { x // x ∈ S }
h : u • (m2, t2).snd • (m1, t1).fst = u • (m1, t1).snd • (m2, t2).fst
⊢ u • (s * (m2, t2).snd) • r • (m1, t1).fst = u • (s * (m1, t1).snd) • r • (m2, t2).fst
[PROOFSTEP]
have h' := congr_arg ((· • ·) (s • r)) h
[GOAL]
case mk.mk.intro
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
x : LocalizedModule S M
r : R
s : { x // x ∈ S }
m1 : M
t1 : { x // x ∈ S }
m2 : M
t2 u : { x // x ∈ S }
h : u • (m2, t2).snd • (m1, t1).fst = u • (m1, t1).snd • (m2, t2).fst
h' :
(fun x x_1 => x • x_1) (s • r) (u • (m2, t2).snd • (m1, t1).fst) =
(fun x x_1 => x • x_1) (s • r) (u • (m1, t1).snd • (m2, t2).fst)
⊢ u • (s * (m2, t2).snd) • r • (m1, t1).fst = u • (s * (m1, t1).snd) • r • (m2, t2).fst
[PROOFSTEP]
simp only [← mul_smul, smul_eq_mul, mul_comm, mul_left_comm, Submonoid.smul_def, Submonoid.coe_mul] at h' ⊢
[GOAL]
case mk.mk.intro
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
x : LocalizedModule S M
r : R
s : { x // x ∈ S }
m1 : M
t1 : { x // x ∈ S }
m2 : M
t2 u : { x // x ∈ S }
h : u • (m2, t2).snd • (m1, t1).fst = u • (m1, t1).snd • (m2, t2).fst
h' : (r * (↑s * (↑t2 * ↑u))) • m1 = (r * (↑s * (↑t1 * ↑u))) • m2
⊢ (r * (↑s * (↑t2 * ↑u))) • m1 = (r * (↑s * (↑t1 * ↑u))) • m2
[PROOFSTEP]
rw [h']
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
x : LocalizedModule S M
⊢ ∀ {a c : R} {b d : { x // x ∈ S }},
↑(Localization.r S) (a, b) (c, d) →
(fun r s =>
liftOn x (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
a b =
(fun r s =>
liftOn x (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
c d
[PROOFSTEP]
induction' x using LocalizedModule.induction_on with m t
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
⊢ ∀ {a c : R} {b d : { x // x ∈ S }},
↑(Localization.r S) (a, b) (c, d) →
(fun r s =>
liftOn (mk m t) (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
a b =
(fun r s =>
liftOn (mk m t) (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
c d
[PROOFSTEP]
rintro r r' s s' h
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
⊢ (fun r s =>
liftOn (mk m t) (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
r s =
(fun r s =>
liftOn (mk m t) (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
r' s'
[PROOFSTEP]
simp only [liftOn_mk, liftOn_mk, mk_eq]
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
⊢ ∃ u, u • (s' * t) • r • m = u • (s * t) • r' • m
[PROOFSTEP]
obtain ⟨u, eq1⟩ := Localization.r_iff_exists.mp h
[GOAL]
case h.intro
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
u : { x // x ∈ S }
eq1 : ↑u * (↑(r', s').snd * (r, s).fst) = ↑u * (↑(r, s).snd * (r', s').fst)
⊢ ∃ u, u • (s' * t) • r • m = u • (s * t) • r' • m
[PROOFSTEP]
use u
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
u : { x // x ∈ S }
eq1 : ↑u * (↑(r', s').snd * (r, s).fst) = ↑u * (↑(r, s).snd * (r', s').fst)
⊢ u • (s' * t) • r • m = u • (s * t) • r' • m
[PROOFSTEP]
have eq1' := congr_arg (· • t • m) eq1
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
u : { x // x ∈ S }
eq1 : ↑u * (↑(r', s').snd * (r, s).fst) = ↑u * (↑(r, s).snd * (r', s').fst)
eq1' :
(fun x => x • t • m) (↑u * (↑(r', s').snd * (r, s).fst)) = (fun x => x • t • m) (↑u * (↑(r, s).snd * (r', s').fst))
⊢ u • (s' * t) • r • m = u • (s * t) • r' • m
[PROOFSTEP]
simp only [← mul_smul, smul_assoc, Submonoid.smul_def, Submonoid.coe_mul] at eq1' ⊢
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
u : { x // x ∈ S }
eq1 : ↑u * (↑(r', s').snd * (r, s).fst) = ↑u * (↑(r, s).snd * (r', s').fst)
eq1' : (↑u * (↑s' * r) * ↑t) • m = (↑u * (↑s * r') * ↑t) • m
⊢ (↑u * (↑s' * ↑t * r)) • m = (↑u * (↑s * ↑t * r')) • m
[PROOFSTEP]
ring_nf at eq1' ⊢
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f : Localization S
m : M
t : { x // x ∈ S }
r r' : R
s s' : { x // x ∈ S }
h : ↑(Localization.r S) (r, s) (r', s')
u : { x // x ∈ S }
eq1 : ↑u * (↑(r', s').snd * (r, s).fst) = ↑u * (↑(r, s).snd * (r', s').fst)
eq1' : (↑u * ↑s' * r * ↑t) • m = (↑u * ↑t * ↑s * r') • m
⊢ (↑u * ↑s' * r * ↑t) • m = (↑u * ↑t * ↑s * r') • m
[PROOFSTEP]
rw [eq1']
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
m : M
s t : { x // x ∈ S }
⊢ Localization.mk r s • mk m t = mk (r • m) (s * t)
[PROOFSTEP]
dsimp only [HSMul.hSMul, SMul.smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
m : M
s t : { x // x ∈ S }
⊢ Localization.liftOn (Localization.mk r s)
(fun r s =>
liftOn (mk m t) (fun p => mk (SMul.smul r p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
(_ :
∀ {a c : R} {b d : { x // x ∈ S }},
↑(Localization.r S) (a, b) (c, d) →
(fun r s =>
liftOn (mk m t) (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
a b =
(fun r s =>
liftOn (mk m t) (fun p => mk (r • p.fst) (s * p.snd))
(_ :
∀ (p p' : M × { x // x ∈ S }),
p ≈ p' → (fun p => mk (r • p.fst) (s * p.snd)) p = (fun p => mk (r • p.fst) (s * p.snd)) p'))
c d) =
mk (SMul.smul r m) (s * t)
[PROOFSTEP]
rw [Localization.liftOn_mk, liftOn_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : LocalizedModule S M
⊢ 1 • m = m
[PROOFSTEP]
induction' m using LocalizedModule.induction_on with m s
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
s : { x // x ∈ S }
⊢ 1 • mk m s = mk m s
[PROOFSTEP]
rw [← Localization.mk_one, mk_smul_mk, one_smul, one_mul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x y : Localization S
m : LocalizedModule S M
⊢ (x * y) • m = x • y • m
[PROOFSTEP]
induction' x using Localization.induction_on with data
[GOAL]
case H
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
y : Localization S
m : LocalizedModule S M
data : R × { x // x ∈ S }
⊢ (Localization.mk data.fst data.snd * y) • m = Localization.mk data.fst data.snd • y • m
[PROOFSTEP]
induction' y using Localization.induction_on with data'
[GOAL]
case H.H
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : LocalizedModule S M
data data' : R × { x // x ∈ S }
⊢ (Localization.mk data.fst data.snd * Localization.mk data'.fst data'.snd) • m =
Localization.mk data.fst data.snd • Localization.mk data'.fst data'.snd • m
[PROOFSTEP]
rcases data, data' with ⟨⟨r, s⟩, ⟨r', s'⟩⟩
[GOAL]
case H.H.mk.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : LocalizedModule S M
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
⊢ (Localization.mk (r, s).fst (r, s).snd * Localization.mk (r', s').fst (r', s').snd) • m =
Localization.mk (r, s).fst (r, s).snd • Localization.mk (r', s').fst (r', s').snd • m
[PROOFSTEP]
induction' m using LocalizedModule.induction_on with m t
[GOAL]
case H.H.mk.mk.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
m : M
t : { x // x ∈ S }
⊢ (Localization.mk (r, s).fst (r, s).snd * Localization.mk (r', s').fst (r', s').snd) • mk m t =
Localization.mk (r, s).fst (r, s).snd • Localization.mk (r', s').fst (r', s').snd • mk m t
[PROOFSTEP]
rw [Localization.mk_mul, mk_smul_mk, mk_smul_mk, mk_smul_mk, mul_smul, mul_assoc]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : Localization S
y z : LocalizedModule S M
⊢ x • (y + z) = x • y + x • z
[PROOFSTEP]
induction' x using Localization.induction_on with data
[GOAL]
case H
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
y z : LocalizedModule S M
data : R × { x // x ∈ S }
⊢ Localization.mk data.fst data.snd • (y + z) =
Localization.mk data.fst data.snd • y + Localization.mk data.fst data.snd • z
[PROOFSTEP]
rcases data with ⟨r, u⟩
[GOAL]
case H.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
y z : LocalizedModule S M
r : R
u : { x // x ∈ S }
⊢ Localization.mk (r, u).fst (r, u).snd • (y + z) =
Localization.mk (r, u).fst (r, u).snd • y + Localization.mk (r, u).fst (r, u).snd • z
[PROOFSTEP]
induction' y using LocalizedModule.induction_on with m s
[GOAL]
case H.mk.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
z : LocalizedModule S M
r : R
u : { x // x ∈ S }
m : M
s : { x // x ∈ S }
⊢ Localization.mk (r, u).fst (r, u).snd • (mk m s + z) =
Localization.mk (r, u).fst (r, u).snd • mk m s + Localization.mk (r, u).fst (r, u).snd • z
[PROOFSTEP]
induction' z using LocalizedModule.induction_on with n t
[GOAL]
case H.mk.h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
u : { x // x ∈ S }
m : M
s : { x // x ∈ S }
n : M
t : { x // x ∈ S }
⊢ Localization.mk (r, u).fst (r, u).snd • (mk m s + mk n t) =
Localization.mk (r, u).fst (r, u).snd • mk m s + Localization.mk (r, u).fst (r, u).snd • mk n t
[PROOFSTEP]
rw [mk_smul_mk, mk_smul_mk, mk_add_mk, mk_smul_mk, mk_add_mk, mk_eq]
[GOAL]
case H.mk.h.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
u : { x // x ∈ S }
m : M
s : { x // x ∈ S }
n : M
t : { x // x ∈ S }
⊢ ∃ u_1,
u_1 • ((r, u).snd * s * ((r, u).snd * t)) • (r, u).fst • (t • m + s • n) =
u_1 • ((r, u).snd * (s * t)) • (((r, u).snd * t) • (r, u).fst • m + ((r, u).snd * s) • (r, u).fst • n)
[PROOFSTEP]
use 1
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
u : { x // x ∈ S }
m : M
s : { x // x ∈ S }
n : M
t : { x // x ∈ S }
⊢ 1 • ((r, u).snd * s * ((r, u).snd * t)) • (r, u).fst • (t • m + s • n) =
1 • ((r, u).snd * (s * t)) • (((r, u).snd * t) • (r, u).fst • m + ((r, u).snd * s) • (r, u).fst • n)
[PROOFSTEP]
simp only [one_smul, smul_add, ← mul_smul, Submonoid.smul_def, Submonoid.coe_mul]
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
u : { x // x ∈ S }
m : M
s : { x // x ∈ S }
n : M
t : { x // x ∈ S }
⊢ (↑u * ↑s * (↑u * ↑t) * (r * ↑t)) • m + (↑u * ↑s * (↑u * ↑t) * (r * ↑s)) • n =
(↑u * (↑s * ↑t) * (↑u * ↑t * r)) • m + (↑u * (↑s * ↑t) * (↑u * ↑s * r)) • n
[PROOFSTEP]
ring_nf
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : Localization S
⊢ x • 0 = 0
[PROOFSTEP]
induction' x using Localization.induction_on with data
[GOAL]
case H
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
data : R × { x // x ∈ S }
⊢ Localization.mk data.fst data.snd • 0 = 0
[PROOFSTEP]
rcases data with ⟨r, s⟩
[GOAL]
case H.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
s : { x // x ∈ S }
⊢ Localization.mk (r, s).fst (r, s).snd • 0 = 0
[PROOFSTEP]
rw [← zero_mk s, mk_smul_mk, smul_zero, zero_mk, zero_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x y : Localization S
z : LocalizedModule S M
⊢ (x + y) • z = x • z + y • z
[PROOFSTEP]
induction' x using Localization.induction_on with datax
[GOAL]
case H
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
y : Localization S
z : LocalizedModule S M
datax : R × { x // x ∈ S }
⊢ (Localization.mk datax.fst datax.snd + y) • z = Localization.mk datax.fst datax.snd • z + y • z
[PROOFSTEP]
induction' y using Localization.induction_on with datay
[GOAL]
case H.H
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
z : LocalizedModule S M
datax datay : R × { x // x ∈ S }
⊢ (Localization.mk datax.fst datax.snd + Localization.mk datay.fst datay.snd) • z =
Localization.mk datax.fst datax.snd • z + Localization.mk datay.fst datay.snd • z
[PROOFSTEP]
induction' z using LocalizedModule.induction_on with m t
[GOAL]
case H.H.h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
datax datay : R × { x // x ∈ S }
m : M
t : { x // x ∈ S }
⊢ (Localization.mk datax.fst datax.snd + Localization.mk datay.fst datay.snd) • mk m t =
Localization.mk datax.fst datax.snd • mk m t + Localization.mk datay.fst datay.snd • mk m t
[PROOFSTEP]
rcases datax, datay with ⟨⟨r, s⟩, ⟨r', s'⟩⟩
[GOAL]
case H.H.h.mk.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
t : { x // x ∈ S }
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
⊢ (Localization.mk (r, s).fst (r, s).snd + Localization.mk (r', s').fst (r', s').snd) • mk m t =
Localization.mk (r, s).fst (r, s).snd • mk m t + Localization.mk (r', s').fst (r', s').snd • mk m t
[PROOFSTEP]
rw [Localization.add_mk, mk_smul_mk, mk_smul_mk, mk_smul_mk, mk_add_mk, mk_eq]
[GOAL]
case H.H.h.mk.mk
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
t : { x // x ∈ S }
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
⊢ ∃ u,
u • ((r, s).snd * t * ((r', s').snd * t)) • (↑(r, s).snd * (r', s').fst + ↑(r', s').snd * (r, s).fst) • m =
u • ((r, s).snd * (r', s').snd * t) • (((r', s').snd * t) • (r, s).fst • m + ((r, s).snd * t) • (r', s').fst • m)
[PROOFSTEP]
use 1
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
t : { x // x ∈ S }
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
⊢ 1 • ((r, s).snd * t * ((r', s').snd * t)) • (↑(r, s).snd * (r', s').fst + ↑(r', s').snd * (r, s).fst) • m =
1 • ((r, s).snd * (r', s').snd * t) • (((r', s').snd * t) • (r, s).fst • m + ((r, s).snd * t) • (r', s').fst • m)
[PROOFSTEP]
simp only [one_smul, add_smul, smul_add, ← mul_smul, Submonoid.smul_def, Submonoid.coe_mul, Submonoid.coe_one]
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
t : { x // x ∈ S }
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
⊢ (↑s * ↑t * (↑s' * ↑t) * (↑s * r')) • m + (↑s * ↑t * (↑s' * ↑t) * (↑s' * r)) • m =
(↑s * ↑s' * ↑t * (↑s' * ↑t * r)) • m + (↑s * ↑s' * ↑t * (↑s * ↑t * r')) • m
[PROOFSTEP]
rw [add_comm]
-- Commutativity of addition in the module is not applied by `Ring`.
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
t : { x // x ∈ S }
r : R
s : { x // x ∈ S }
r' : R
s' : { x // x ∈ S }
⊢ (↑s * ↑t * (↑s' * ↑t) * (↑s' * r)) • m + (↑s * ↑t * (↑s' * ↑t) * (↑s * r')) • m =
(↑s * ↑s' * ↑t * (↑s' * ↑t * r)) • m + (↑s * ↑s' * ↑t * (↑s * ↑t * r')) • m
[PROOFSTEP]
ring_nf
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x : LocalizedModule S M
⊢ 0 • x = 0
[PROOFSTEP]
induction' x using LocalizedModule.induction_on with m s
[GOAL]
case h
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
m : M
s : { x // x ∈ S }
⊢ 0 • mk m s = 0
[PROOFSTEP]
rw [← Localization.mk_zero s, mk_smul_mk, zero_smul, zero_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s' s : { x // x ∈ S }
m : M
⊢ 1 • s • s' • m = 1 • (s' * s) • m
[PROOFSTEP]
simp only [mul_smul, one_smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s' s : { x // x ∈ S }
m : M
⊢ s • s' • m = s' • s • m
[PROOFSTEP]
rw [smul_comm]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
m : M
⊢ 1 • 1 • s • m = 1 • s • m
[PROOFSTEP]
simp
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s s' : { x // x ∈ S }
m : M
⊢ 1 • s • s' • m = 1 • (s * s') • m
[PROOFSTEP]
simp [mul_smul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r : R
s : { x // x ∈ S }
m : M
⊢ r • mk m s = mk (r • m) s
[PROOFSTEP]
erw [mk_smul_mk r m 1 s, one_mul]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
⊢ ∀ (r : Localization S) (x y : LocalizedModule S A), r • x * y = r • (x * y)
[PROOFSTEP]
intro r x₁ x₂
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
r : Localization S
x₁ x₂ : LocalizedModule S A
⊢ r • x₁ * x₂ = r • (x₁ * x₂)
[PROOFSTEP]
obtain ⟨y, s, rfl : IsLocalization.mk' _ y s = r⟩ := IsLocalization.mk'_surjective S r
[GOAL]
case intro.intro
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
x₁ x₂ : LocalizedModule S A
y : R
s : { x // x ∈ S }
⊢ IsLocalization.mk' (Localization S) y s • x₁ * x₂ = IsLocalization.mk' (Localization S) y s • (x₁ * x₂)
[PROOFSTEP]
obtain ⟨⟨a₁, s₁⟩, rfl : mk a₁ s₁ = x₁⟩ := Quotient.exists_rep x₁
[GOAL]
case intro.intro.intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
x₂ : LocalizedModule S A
y : R
s : { x // x ∈ S }
a₁ : A
s₁ : { x // x ∈ S }
⊢ IsLocalization.mk' (Localization S) y s • mk a₁ s₁ * x₂ = IsLocalization.mk' (Localization S) y s • (mk a₁ s₁ * x₂)
[PROOFSTEP]
obtain ⟨⟨a₂, s₂⟩, rfl : mk a₂ s₂ = x₂⟩ := Quotient.exists_rep x₂
[GOAL]
case intro.intro.intro.mk.intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
y : R
s : { x // x ∈ S }
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
⊢ IsLocalization.mk' (Localization S) y s • mk a₁ s₁ * mk a₂ s₂ =
IsLocalization.mk' (Localization S) y s • (mk a₁ s₁ * mk a₂ s₂)
[PROOFSTEP]
rw [mk_mul_mk, ← Localization.mk_eq_mk', mk_smul_mk, mk_smul_mk, mk_mul_mk, mul_assoc, smul_mul_assoc]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
⊢ ∀ (r : Localization S) (x y : LocalizedModule S A), x * r • y = r • (x * y)
[PROOFSTEP]
intro r x₁ x₂
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
r : Localization S
x₁ x₂ : LocalizedModule S A
⊢ x₁ * r • x₂ = r • (x₁ * x₂)
[PROOFSTEP]
obtain ⟨y, s, rfl : IsLocalization.mk' _ y s = r⟩ := IsLocalization.mk'_surjective S r
[GOAL]
case intro.intro
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
x₁ x₂ : LocalizedModule S A
y : R
s : { x // x ∈ S }
⊢ x₁ * IsLocalization.mk' (Localization S) y s • x₂ = IsLocalization.mk' (Localization S) y s • (x₁ * x₂)
[PROOFSTEP]
obtain ⟨⟨a₁, s₁⟩, rfl : mk a₁ s₁ = x₁⟩ := Quotient.exists_rep x₁
[GOAL]
case intro.intro.intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
x₂ : LocalizedModule S A
y : R
s : { x // x ∈ S }
a₁ : A
s₁ : { x // x ∈ S }
⊢ mk a₁ s₁ * IsLocalization.mk' (Localization S) y s • x₂ = IsLocalization.mk' (Localization S) y s • (mk a₁ s₁ * x₂)
[PROOFSTEP]
obtain ⟨⟨a₂, s₂⟩, rfl : mk a₂ s₂ = x₂⟩ := Quotient.exists_rep x₂
[GOAL]
case intro.intro.intro.mk.intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
y : R
s : { x // x ∈ S }
a₁ : A
s₁ : { x // x ∈ S }
a₂ : A
s₂ : { x // x ∈ S }
⊢ mk a₁ s₁ * IsLocalization.mk' (Localization S) y s • mk a₂ s₂ =
IsLocalization.mk' (Localization S) y s • (mk a₁ s₁ * mk a₂ s₂)
[PROOFSTEP]
rw [mk_mul_mk, ← Localization.mk_eq_mk', mk_smul_mk, mk_smul_mk, mk_mul_mk, mul_left_comm, mul_smul_comm]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : R
s : { x // x ∈ S }
⊢ ↑(algebraMap (Localization S) (LocalizedModule S ((fun x => A) a))) (Localization.mk a s) = mk (↑(algebraMap R A) a) s
[PROOFSTEP]
rw [Algebra.algebraMap_eq_smul_one]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : R
s : { x // x ∈ S }
⊢ Localization.mk a s • 1 = mk (↑(algebraMap R A) a) s
[PROOFSTEP]
change _ • mk _ _ = _
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : R
s : { x // x ∈ S }
⊢ Localization.mk a s • mk 1 1 = mk (↑(algebraMap R A) a) s
[PROOFSTEP]
rw [mk_smul_mk, Algebra.algebraMap_eq_smul_one, mul_one]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
⊢ Module R (LocalizedModule S A)
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (r : R) (x : (fun x => LocalizedModule S A) r),
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ :
∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r *
x =
x *
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ :
∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r
[PROOFSTEP]
intro r x
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
r : R
x : LocalizedModule S A
⊢ ↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ : ∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r *
x =
x *
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ : ∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r
[PROOFSTEP]
obtain ⟨⟨a, s⟩, rfl : mk a s = x⟩ := Quotient.exists_rep x
[GOAL]
case intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
r : R
a : A
s : { x // x ∈ S }
⊢ ↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ : ∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r *
mk a s =
mk a s *
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ : ∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r
[PROOFSTEP]
dsimp
[GOAL]
case intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
r : R
a : A
s : { x // x ∈ S }
⊢ ↑(algebraMap (Localization S) (LocalizedModule S A)) (↑(algebraMap R (Localization S)) r) * mk a s =
mk a s * ↑(algebraMap (Localization S) (LocalizedModule S A)) (↑(algebraMap R (Localization S)) r)
[PROOFSTEP]
rw [← Localization.mk_one_eq_algebraMap, algebraMap_mk, mk_mul_mk, mk_mul_mk, mul_comm, Algebra.commutes]
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
⊢ ∀ (r : R) (x : (fun x => LocalizedModule S A) r),
r • x =
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ :
∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r *
x
[PROOFSTEP]
intro r x
[GOAL]
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
r : R
x : LocalizedModule S A
⊢ r • x =
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ : ∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r *
x
[PROOFSTEP]
obtain ⟨⟨a, s⟩, rfl : mk a s = x⟩ := Quotient.exists_rep x
[GOAL]
case intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
r : R
a : A
s : { x // x ∈ S }
⊢ r • mk a s =
↑{ toMonoidHom := ↑src✝¹, map_zero' := (_ : OneHom.toFun (↑↑src✝¹) 0 = 0),
map_add' :=
(_ : ∀ (x y : R), OneHom.toFun (↑↑src✝¹) (x + y) = OneHom.toFun (↑↑src✝¹) x + OneHom.toFun (↑↑src✝¹) y) }
r *
mk a s
[PROOFSTEP]
dsimp
[GOAL]
case intro.mk
R : Type u
inst✝⁴ : CommSemiring R
S : Submonoid R
M : Type v
inst✝³ : AddCommMonoid M
inst✝² : Module R M
A : Type u_1
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝¹ : R →+* LocalizedModule S A :=
RingHom.comp (algebraMap (Localization S) (LocalizedModule S A)) (algebraMap R (Localization S))
src✝ : Module R (LocalizedModule S A) :=
let_fun this := inferInstance;
this
r : R
a : A
s : { x // x ∈ S }
⊢ r • mk a s = ↑(algebraMap (Localization S) (LocalizedModule S A)) (↑(algebraMap R (Localization S)) r) * mk a s
[PROOFSTEP]
rw [← Localization.mk_one_eq_algebraMap, algebraMap_mk, mk_mul_mk, smul'_mk, Algebra.smul_def, one_mul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
x y : M
⊢ (fun m => mk m 1) (x + y) = (fun m => mk m 1) x + (fun m => mk m 1) y
[PROOFSTEP]
simp [mk_add_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
a : M
b : { x // x ∈ S }
a' : M
b' : { x // x ∈ S }
x✝ : (a, b) ≈ (a', b')
c : { x // x ∈ S }
eq1 : c • (a', b').snd • (a, b).fst = c • (a, b).snd • (a', b').fst
⊢ c • (s * (a', b').snd) • (a, b).fst = c • (s * (a, b).snd) • (a', b').fst
[PROOFSTEP]
rw [mul_smul, mul_smul, smul_comm c, eq1, smul_comm s]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
x y : LocalizedModule S M
⊢ ∀ (m m' : M) (s_1 s' : { x // x ∈ S }),
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(mk m s_1 + mk m' s') =
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(mk m s_1) +
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(mk m' s')
[PROOFSTEP]
intro m₁ m₂ t₁ t₂
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
x y : LocalizedModule S M
m₁ m₂ : M
t₁ t₂ : { x // x ∈ S }
⊢ (fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(mk m₁ t₁ + mk m₂ t₂) =
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(mk m₁ t₁) +
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(mk m₂ t₂)
[PROOFSTEP]
simp only [mk_add_mk, LocalizedModule.liftOn_mk, mul_smul, ← smul_add, mul_assoc, mk_cancel_common_left s]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
x y : LocalizedModule S M
m₁ m₂ : M
t₁ t₂ : { x // x ∈ S }
⊢ mk (t₂ • m₁ + t₁ • m₂) (s * (t₁ * t₂)) = mk (t₂ • m₁ + t₁ • m₂) (t₁ * (s * t₂))
[PROOFSTEP]
rw [show s * (t₁ * t₂) = t₁ * (s * t₂) by
ext
simp only [Submonoid.coe_mul]
ring]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
x y : LocalizedModule S M
m₁ m₂ : M
t₁ t₂ : { x // x ∈ S }
⊢ s * (t₁ * t₂) = t₁ * (s * t₂)
[PROOFSTEP]
ext
[GOAL]
case a
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
x y : LocalizedModule S M
m₁ m₂ : M
t₁ t₂ : { x // x ∈ S }
⊢ ↑(s * (t₁ * t₂)) = ↑(t₁ * (s * t₂))
[PROOFSTEP]
simp only [Submonoid.coe_mul]
[GOAL]
case a
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
x y : LocalizedModule S M
m₁ m₂ : M
t₁ t₂ : { x // x ∈ S }
⊢ ↑s * (↑t₁ * ↑t₂) = ↑t₁ * (↑s * ↑t₂)
[PROOFSTEP]
ring
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
r : R
x : LocalizedModule S M
⊢ ∀ (a : M × { x // x ∈ S }),
AddHom.toFun
{
toFun := fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1),
map_add' :=
(_ :
∀ (x y : LocalizedModule S M),
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(x + y) =
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
x +
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
y) }
(r • Quotient.mk (r.setoid S M) a) =
↑(RingHom.id R) r •
AddHom.toFun
{
toFun := fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1),
map_add' :=
(_ :
∀ (x y : LocalizedModule S M),
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(x + y) =
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
x +
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
y) }
(Quotient.mk (r.setoid S M) a)
[PROOFSTEP]
intro
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
r : R
x : LocalizedModule S M
a✝ : M × { x // x ∈ S }
⊢ AddHom.toFun
{
toFun := fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1),
map_add' :=
(_ :
∀ (x y : LocalizedModule S M),
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(x + y) =
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
x +
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
y) }
(r • Quotient.mk (r.setoid S M) a✝) =
↑(RingHom.id R) r •
AddHom.toFun
{
toFun := fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1),
map_add' :=
(_ :
∀ (x y : LocalizedModule S M),
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
(x + y) =
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
x +
(fun p =>
liftOn p (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1))
y) }
(Quotient.mk (r.setoid S M) a✝)
[PROOFSTEP]
dsimp only
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
r : R
x : LocalizedModule S M
a✝ : M × { x // x ∈ S }
⊢ liftOn (r • Quotient.mk (r.setoid S M) a✝) (fun p => mk p.fst (s * p.snd))
(_ : ∀ (x x_1 : M × { x // x ∈ S }), x ≈ x_1 → mk x.fst (s * x.snd) = mk x_1.fst (s * x_1.snd)) =
↑(RingHom.id R) r •
liftOn (Quotient.mk (r.setoid S M) a✝) (fun p => mk p.fst (s * p.snd))
(_ : ∀ (x x_1 : M × { x // x ∈ S }), x ≈ x_1 → mk x.fst (s * x.snd) = mk x_1.fst (s * x_1.snd))
[PROOFSTEP]
change liftOn (mk _ _) _ _ = r • (liftOn (mk _ _) _ _)
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
r : R
x : LocalizedModule S M
a✝ : M × { x // x ∈ S }
⊢ liftOn (mk ((↑(algebraMap R R) r, 1).fst • a✝.fst) ((↑(algebraMap R R) r, 1).snd * a✝.snd))
(fun p => mk p.fst (s * p.snd))
(_ : ∀ (x x_1 : M × { x // x ∈ S }), x ≈ x_1 → mk x.fst (s * x.snd) = mk x_1.fst (s * x_1.snd)) =
r •
liftOn (mk a✝.fst a✝.snd) (fun p => mk p.fst (s * p.snd))
(_ : ∀ (x x_1 : M × { x // x ∈ S }), x ≈ x_1 → mk x.fst (s * x.snd) = mk x_1.fst (s * x_1.snd))
[PROOFSTEP]
simp [LocalizedModule.liftOn_mk, smul'_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
⊢ ∀ (a : M × { x // x ∈ S }),
↑(divBy s) (↑(↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s) (Quotient.mk (r.setoid S M) a)) =
Quotient.mk (r.setoid S M) a
[PROOFSTEP]
intro ⟨m, t⟩
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ ↑(divBy s) (↑(↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s) (Quotient.mk (r.setoid S M) (m, t))) =
Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
simp only [Module.algebraMap_end_apply, smul'_mk, divBy_apply]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ liftOn (↑s • Quotient.mk (r.setoid S M) (m, t)) (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1) =
Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
erw [LocalizedModule.liftOn_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ mk ((↑(algebraMap R R) ↑s, 1).fst • (m, t).fst, (↑(algebraMap R R) ↑s, 1).snd * (m, t).snd).fst
(s * ((↑(algebraMap R R) ↑s, 1).fst • (m, t).fst, (↑(algebraMap R R) ↑s, 1).snd * (m, t).snd).snd) =
Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
simp only [one_mul]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ mk (↑(algebraMap R R) ↑s • m) (s * t) = Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
change mk (s • m) (s * t) = mk m t
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ mk (s • m) (s * t) = mk m t
[PROOFSTEP]
rw [mk_cancel_common_left s t]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
⊢ ∀ (a : M × { x // x ∈ S }),
↑(↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s) (↑(divBy s) (Quotient.mk (r.setoid S M) a)) =
Quotient.mk (r.setoid S M) a
[PROOFSTEP]
intro ⟨m, t⟩
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ ↑(↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s) (↑(divBy s) (Quotient.mk (r.setoid S M) (m, t))) =
Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
simp only [LocalizedModule.liftOn_mk, divBy_apply, Module.algebraMap_end_apply, smul'_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ ↑s •
liftOn (Quotient.mk (r.setoid S M) (m, t)) (fun p => mk p.fst (s * p.snd))
(_ :
∀ (x x_1 : M × { x // x ∈ S }),
x ≈ x_1 → (fun p => mk p.fst (s * p.snd)) x = (fun p => mk p.fst (s * p.snd)) x_1) =
Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
erw [LocalizedModule.liftOn_mk, smul'_mk]
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ mk (↑s • (m, t).fst) (s * (m, t).snd) = Quotient.mk (r.setoid S M) (m, t)
[PROOFSTEP]
change mk (s • m) (s * t) = mk m t
[GOAL]
R : Type u
inst✝² : CommSemiring R
S : Submonoid R
M : Type v
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
s : { x // x ∈ S }
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ mk (s • m) (s * t) = mk m t
[PROOFSTEP]
rw [mk_cancel_common_left s t]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ (fun p => ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑p.snd)))⁻¹ (↑g p.fst)) (m, s) =
(fun p => ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑p.snd)))⁻¹ (↑g p.fst)) (m', s')
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← map_smul]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ ↑g (m, s).fst =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑(m', s').snd)))⁻¹ (↑(m, s).snd • ↑g (m', s').fst)
[PROOFSTEP]
symm
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑(m', s').snd)))⁻¹ (↑(m, s).snd • ↑g (m', s').fst) =
↑g (m, s).fst
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ ↑(m, s).snd • ↑g (m', s').fst = ↑(m', s').snd • ↑g (m, s).fst
[PROOFSTEP]
dsimp
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ ↑s • ↑g m' = ↑s' • ↑g m
[PROOFSTEP]
have : c • s • g m' = c • s' • g m :=
by
erw [← g.map_smul, ← g.map_smul, ← g.map_smul, ← g.map_smul, eq1]
rfl
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ c • s • ↑g m' = c • s' • ↑g m
[PROOFSTEP]
erw [← g.map_smul, ← g.map_smul, ← g.map_smul, ← g.map_smul, eq1]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
⊢ ↑g (↑(Submonoid.subtype S) c • ↑(Submonoid.subtype S) s • m') = ↑g (c • (m, s).snd • (m', s').fst)
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this : c • s • ↑g m' = c • s' • ↑g m
⊢ ↑s • ↑g m' = ↑s' • ↑g m
[PROOFSTEP]
have : Function.Injective (h c).unit.inv :=
by
rw [Function.injective_iff_hasLeftInverse]
refine' ⟨(h c).unit, _⟩
intro x
change ((h c).unit.1 * (h c).unit.inv) x = x
simp only [Units.inv_eq_val_inv, IsUnit.mul_val_inv, LinearMap.one_apply]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this : c • s • ↑g m' = c • s' • ↑g m
⊢ Function.Injective ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
[PROOFSTEP]
rw [Function.injective_iff_hasLeftInverse]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this : c • s • ↑g m' = c • s' • ↑g m
⊢ Function.HasLeftInverse ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
[PROOFSTEP]
refine' ⟨(h c).unit, _⟩
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this : c • s • ↑g m' = c • s' • ↑g m
⊢ Function.LeftInverse ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c)))
↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
[PROOFSTEP]
intro x
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this : c • s • ↑g m' = c • s' • ↑g m
x : M''
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c)))
(↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv x) =
x
[PROOFSTEP]
change ((h c).unit.1 * (h c).unit.inv) x = x
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this : c • s • ↑g m' = c • s' • ↑g m
x : M''
⊢ ↑(↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))) *
(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv)
x =
x
[PROOFSTEP]
simp only [Units.inv_eq_val_inv, IsUnit.mul_val_inv, LinearMap.one_apply]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this✝ : c • s • ↑g m' = c • s' • ↑g m
this : Function.Injective ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
⊢ ↑s • ↑g m' = ↑s' • ↑g m
[PROOFSTEP]
apply_fun (h c).unit.inv
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this✝ : c • s • ↑g m' = c • s' • ↑g m
this : Function.Injective ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
⊢ ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv (↑s • ↑g m') =
↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv (↑s' • ↑g m)
[PROOFSTEP]
erw [Units.inv_eq_val_inv, Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← (h c).unit⁻¹.val.map_smul]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this✝ : c • s • ↑g m' = c • s' • ↑g m
this : Function.Injective ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
⊢ ↑s • ↑g m' = ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c)))⁻¹ (↑c • ↑s' • ↑g m)
[PROOFSTEP]
symm
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this✝ : c • s • ↑g m' = c • s' • ↑g m
this : Function.Injective ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c)))⁻¹ (↑c • ↑s' • ↑g m) = ↑s • ↑g m'
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← g.map_smul, ← g.map_smul, ← g.map_smul, ← g.map_smul, eq1]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
m✝ : LocalizedModule S M
x✝² x✝¹ : M × { x // x ∈ S }
m : M
s : { x // x ∈ S }
m' : M
s' : { x // x ∈ S }
x✝ : (m, s) ≈ (m', s')
c : { x // x ∈ S }
eq1 : c • (m', s').snd • (m, s).fst = c • (m, s).snd • (m', s').fst
this✝ : c • s • ↑g m' = c • s' • ↑g m
this : Function.Injective ↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑c))).inv
⊢ ↑g (c • (m, s).snd • (m', s').fst) = ↑g (↑c • ↑s • m')
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
⊢ ∀ (m m' : M) (s s' : { x // x ∈ S }), lift' S g h (mk m s + mk m' s') = lift' S g h (mk m s) + lift' S g h (mk m' s')
[PROOFSTEP]
intro a a' b b'
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ lift' S g h (mk a b + mk a' b') = lift' S g h (mk a b) + lift' S g h (mk a' b')
[PROOFSTEP]
erw [LocalizedModule.lift'_mk, LocalizedModule.lift'_mk, LocalizedModule.lift'_mk]
-- Porting note: We remove `generalize_proofs h1 h2 h3`. This only generalize `h1`.
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑((a, b).snd * (a', b').snd))))⁻¹
(↑g ((a', b').snd • (a, b).fst + (a, b).snd • (a', b').fst)) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b)))⁻¹ (↑g a) +
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b')))⁻¹ (↑g a')
[PROOFSTEP]
erw [map_add, Module.End_algebraMap_isUnit_inv_apply_eq_iff, smul_add, ← map_smul, ← map_smul, ← map_smul]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑g ((a', b').snd • (a, b).fst) + ↑g ((a, b).snd • (a', b').fst) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b)))⁻¹ (↑g (↑((a, b).snd * (a', b').snd) • a)) +
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b')))⁻¹ (↑((a, b).snd * (a', b').snd) • ↑g a')
[PROOFSTEP]
congr 1
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑g ((a', b').snd • (a, b).fst) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b)))⁻¹ (↑g (↑((a, b).snd * (a', b').snd) • a))
[PROOFSTEP]
symm
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑g ((a, b).snd • (a', b').fst) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b')))⁻¹ (↑((a, b).snd * (a', b').snd) • ↑g a')
[PROOFSTEP]
symm
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b)))⁻¹ (↑g (↑((a, b).snd * (a', b').snd) • a)) =
↑g ((a', b').snd • (a, b).fst)
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, mul_smul, ← map_smul]
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑g (↑(a, b).snd • ↑(a', b').snd • a) = ↑g (↑b • (a', b').snd • (a, b).fst)
[PROOFSTEP]
rfl
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b')))⁻¹ (↑((a, b).snd * (a', b').snd) • ↑g a') =
↑g ((a, b).snd • (a', b').fst)
[PROOFSTEP]
dsimp
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b')))⁻¹ ((↑b * ↑b') • ↑g a') = ↑g (b • a')
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, mul_comm, mul_smul, ← map_smul]
[GOAL]
case e_a
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑b' • ↑g (↑b • a') = ↑b' • ↑g (b • a')
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
r : R
m : LocalizedModule S M
⊢ ∀ (a : M × { x // x ∈ S }),
r • lift' S g h (Quotient.mk (r.setoid S M) a) = lift' S g h (r • Quotient.mk (r.setoid S M) a)
[PROOFSTEP]
intro ⟨a, b⟩
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
r : R
m : LocalizedModule S M
a : M
b : { x // x ∈ S }
⊢ r • lift' S g h (Quotient.mk (r.setoid S M) (a, b)) = lift' S g h (r • Quotient.mk (r.setoid S M) (a, b))
[PROOFSTEP]
erw [LocalizedModule.lift'_mk, LocalizedModule.smul'_mk, LocalizedModule.lift'_mk]
-- Porting note: We remove `generalize_proofs h1 h2`. This does nothing here.
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
r : R
m : LocalizedModule S M
a : M
b : { x // x ∈ S }
⊢ r • ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b)))⁻¹ (↑g a) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑b)))⁻¹ (↑g (r • a))
[PROOFSTEP]
erw [← map_smul, ← g.map_smul]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
r : R
x : LocalizedModule S M
⊢ AddHom.toFun
{ toFun := lift' S g h,
map_add' := (_ : ∀ (x y : LocalizedModule S M), lift' S g h (x + y) = lift' S g h x + lift' S g h y) }
(r • x) =
↑(RingHom.id R) r •
AddHom.toFun
{ toFun := lift' S g h,
map_add' := (_ : ∀ (x y : LocalizedModule S M), lift' S g h (x + y) = lift' S g h x + lift' S g h y) }
x
[PROOFSTEP]
rw [LocalizedModule.lift'_smul, RingHom.id_apply]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
⊢ LinearMap.comp (lift S g h) (mkLinearMap S M) = g
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x : M
⊢ ↑(LinearMap.comp (lift S g h) (mkLinearMap S M)) x = ↑g x
[PROOFSTEP]
dsimp
[GOAL]
case h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x : M
⊢ ↑(lift S g h) (mk x 1) = ↑g x
[PROOFSTEP]
rw [LocalizedModule.lift_mk]
[GOAL]
case h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
x : M
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑1)))⁻¹ (↑g x) = ↑g x
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, one_smul]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
⊢ lift S g h = l
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
x : LocalizedModule S M
⊢ ↑(lift S g h) x = ↑l x
[PROOFSTEP]
induction' x using LocalizedModule.induction_on with m s
[GOAL]
case h.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ ↑(lift S g h) (mk m s) = ↑l (mk m s)
[PROOFSTEP]
rw [LocalizedModule.lift_mk]
[GOAL]
case h.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M'')) ↑s)))⁻¹ (↑g m) = ↑l (mk m s)
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← hl, LinearMap.coe_comp, Function.comp_apply,
LocalizedModule.mkLinearMap_apply, ← l.map_smul, LocalizedModule.smul'_mk]
[GOAL]
case h.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ ↑l (mk m 1) = ↑l (mk (↑s • m) s)
[PROOFSTEP]
congr 1
[GOAL]
case h.h.h.e_6.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ mk m 1 = mk (↑s • m) s
[PROOFSTEP]
rw [LocalizedModule.mk_eq]
[GOAL]
case h.h.h.e_6.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ ∃ u, u • s • m = u • 1 • ↑s • m
[PROOFSTEP]
refine' ⟨1, _⟩
[GOAL]
case h.h.h.e_6.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ 1 • s • m = 1 • 1 • ↑s • m
[PROOFSTEP]
simp only [one_smul]
[GOAL]
case h.h.h.e_6.h
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g✝ g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : LocalizedModule S M →ₗ[R] M''
hl : LinearMap.comp l (mkLinearMap S M) = g
m : M
s : { x // x ∈ S }
⊢ s • m = ↑s • m
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
s : { x // x ∈ S }
p : LocalizedModule S M
⊢ ∀ (a : M × { x // x ∈ S }),
↑↑{ val := ↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s, inv := LocalizedModule.divBy s,
val_inv := (_ : ↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s * LocalizedModule.divBy s = 1),
inv_val := (_ : LocalizedModule.divBy s * ↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s = 1) }
(Quotient.mk (LocalizedModule.r.setoid S M) a) =
↑(↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s) (Quotient.mk (LocalizedModule.r.setoid S M) a)
[PROOFSTEP]
intros
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
s : { x // x ∈ S }
p : LocalizedModule S M
a✝ : M × { x // x ∈ S }
⊢ ↑↑{ val := ↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s, inv := LocalizedModule.divBy s,
val_inv := (_ : ↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s * LocalizedModule.divBy s = 1),
inv_val := (_ : LocalizedModule.divBy s * ↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s = 1) }
(Quotient.mk (LocalizedModule.r.setoid S M) a✝) =
↑(↑(algebraMap R (Module.End R (LocalizedModule S M))) ↑s) (Quotient.mk (LocalizedModule.r.setoid S M) a✝)
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
p : LocalizedModule S M
⊢ ∀ (a : M × { x // x ∈ S }),
∃ x, x.snd • Quotient.mk (LocalizedModule.r.setoid S M) a = ↑(LocalizedModule.mkLinearMap S M) x.fst
[PROOFSTEP]
intro ⟨m, t⟩
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ ∃ x, x.snd • Quotient.mk (LocalizedModule.r.setoid S M) (m, t) = ↑(LocalizedModule.mkLinearMap S M) x.fst
[PROOFSTEP]
refine' ⟨⟨m, t⟩, _⟩
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
p : LocalizedModule S M
m : M
t : { x // x ∈ S }
⊢ (m, t).snd • Quotient.mk (LocalizedModule.r.setoid S M) (m, t) = ↑(LocalizedModule.mkLinearMap S M) (m, t).fst
[PROOFSTEP]
erw [LocalizedModule.smul'_mk, LocalizedModule.mkLinearMap_apply, Submonoid.coe_subtype, LocalizedModule.mk_cancel t]
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
x₁✝ x₂✝ : M
eq1 : ↑(LocalizedModule.mkLinearMap S M) x₁✝ = ↑(LocalizedModule.mkLinearMap S M) x₂✝
⊢ ∃ c, c • x₂✝ = c • x₁✝
[PROOFSTEP]
simpa only [eq_comm, one_smul] using LocalizedModule.mk_eq.mp eq1
[GOAL]
R : Type u_1
inst✝⁶ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁵ : AddCommMonoid M
inst✝⁴ : AddCommMonoid M'
inst✝³ : AddCommMonoid M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
x₁✝ x₂✝ : M
x✝ : ∃ c, c • x₂✝ = c • x₁✝
c : { x // x ∈ S }
eq1 : c • x₂✝ = c • x₁✝
⊢ c • 1 • x₁✝ = c • 1 • x₂✝
[PROOFSTEP]
simpa only [eq_comm, one_smul] using eq1
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
p : LocalizedModule S M
⊢ ∀ (p p' : M × { x // x ∈ S }),
p ≈ p' →
(fun x => ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑x.snd)))⁻¹ (↑f x.fst)) p =
(fun x => ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑x.snd)))⁻¹ (↑f x.fst)) p'
[PROOFSTEP]
rintro ⟨a, b⟩ ⟨a', b'⟩ ⟨c, eq1⟩
[GOAL]
case mk.mk.intro
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
p : LocalizedModule S M
a : M
b : { x // x ∈ S }
a' : M
b' c : { x // x ∈ S }
eq1 : c • (a', b').snd • (a, b).fst = c • (a, b).snd • (a', b').fst
⊢ (fun x => ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑x.snd)))⁻¹ (↑f x.fst)) (a, b) =
(fun x => ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑x.snd)))⁻¹ (↑f x.fst)) (a', b')
[PROOFSTEP]
dsimp
-- Porting note: We remove `generalize_proofs h1 h2`.
[GOAL]
case mk.mk.intro
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
p : LocalizedModule S M
a : M
b : { x // x ∈ S }
a' : M
b' c : { x // x ∈ S }
eq1 : c • (a', b').snd • (a, b).fst = c • (a, b).snd • (a', b').fst
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f a) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b')))⁻¹ (↑f a')
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← map_smul, ← map_smul,
Module.End_algebraMap_isUnit_inv_apply_eq_iff', ← map_smul]
[GOAL]
case mk.mk.intro
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
p : LocalizedModule S M
a : M
b : { x // x ∈ S }
a' : M
b' c : { x // x ∈ S }
eq1 : c • (a', b').snd • (a, b).fst = c • (a, b).snd • (a', b').fst
⊢ ↑f (↑b • a') = ↑f (↑b' • a)
[PROOFSTEP]
exact (IsLocalizedModule.eq_iff_exists S f).mpr ⟨c, eq1⟩
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
⊢ ∀ (m m' : M) (s s' : { x // x ∈ S }),
fromLocalizedModule' S f (LocalizedModule.mk m s + LocalizedModule.mk m' s') =
fromLocalizedModule' S f (LocalizedModule.mk m s) + fromLocalizedModule' S f (LocalizedModule.mk m' s')
[PROOFSTEP]
intro a a' b b'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ fromLocalizedModule' S f (LocalizedModule.mk a b + LocalizedModule.mk a' b') =
fromLocalizedModule' S f (LocalizedModule.mk a b) + fromLocalizedModule' S f (LocalizedModule.mk a' b')
[PROOFSTEP]
simp only [LocalizedModule.mk_add_mk, fromLocalizedModule'_mk]
-- Porting note: We remove `generalize_proofs h1 h2 h3`.
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑(b * b'))))⁻¹ (↑f (b' • a + b • a')) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f a) +
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b')))⁻¹ (↑f a')
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, smul_add, ← map_smul, ← map_smul, ← map_smul, map_add]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑f (b' • a) + ↑f (b • a') =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f (↑(b * b') • a)) +
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b')))⁻¹ (↑(b * b') • ↑f a')
[PROOFSTEP]
congr 1
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑f (b' • a) = ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f (↑(b * b') • a))
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑f (b • a') = ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b')))⁻¹ (↑(b * b') • ↑f a')
[PROOFSTEP]
all_goals erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff']
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑f (b' • a) = ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f (↑(b * b') • a))
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff']
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑f (b • a') = ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b')))⁻¹ (↑(b * b') • ↑f a')
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff']
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑f (↑(b * b') • a) = ↑b • ↑f (b' • a)
[PROOFSTEP]
erw [mul_smul, f.map_smul]
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑b • ↑f (↑b' • a) = ↑b • ↑f (b' • a)
[PROOFSTEP]
rfl
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑(b * b') • ↑f a' = ↑b' • ↑f (b • a')
[PROOFSTEP]
erw [mul_comm, f.map_smul, mul_smul]
[GOAL]
case e_a
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
a a' : M
b b' : { x // x ∈ S }
⊢ ↑b' • ↑b • ↑f a' = ↑b' • ↑(Submonoid.subtype S) b • ↑f a'
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
r : R
x : LocalizedModule S M
⊢ ∀ (m : M) (s : { x // x ∈ S }),
r • fromLocalizedModule' S f (LocalizedModule.mk m s) = fromLocalizedModule' S f (r • LocalizedModule.mk m s)
[PROOFSTEP]
intro a b
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
r : R
x : LocalizedModule S M
a : M
b : { x // x ∈ S }
⊢ r • fromLocalizedModule' S f (LocalizedModule.mk a b) = fromLocalizedModule' S f (r • LocalizedModule.mk a b)
[PROOFSTEP]
rw [fromLocalizedModule'_mk, LocalizedModule.smul'_mk, fromLocalizedModule'_mk]
-- Porting note: We remove `generalize_proofs h1`.
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
r : R
x : LocalizedModule S M
a : M
b : { x // x ∈ S }
⊢ r • ↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f a) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f (r • a))
[PROOFSTEP]
rw [f.map_smul, map_smul]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
r : R
x : LocalizedModule S M
⊢ AddHom.toFun
{ toFun := fromLocalizedModule' S f,
map_add' :=
(_ :
∀ (x y : LocalizedModule S M),
fromLocalizedModule' S f (x + y) = fromLocalizedModule' S f x + fromLocalizedModule' S f y) }
(r • x) =
↑(RingHom.id R) r •
AddHom.toFun
{ toFun := fromLocalizedModule' S f,
map_add' :=
(_ :
∀ (x y : LocalizedModule S M),
fromLocalizedModule' S f (x + y) = fromLocalizedModule' S f x + fromLocalizedModule' S f y) }
x
[PROOFSTEP]
rw [fromLocalizedModule'_smul, RingHom.id_apply]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
eq1 : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) y
⊢ x = y
[PROOFSTEP]
induction' x using LocalizedModule.induction_on with a b
[GOAL]
case h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
eq1✝ : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) y
a : M
b : { x // x ∈ S }
eq1 : ↑(fromLocalizedModule S f) (LocalizedModule.mk a b) = ↑(fromLocalizedModule S f) y
⊢ LocalizedModule.mk a b = y
[PROOFSTEP]
induction' y using LocalizedModule.induction_on with a' b'
[GOAL]
case h.h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
eq1✝² : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) y
a : M
b : { x // x ∈ S }
eq1✝¹ : ↑(fromLocalizedModule S f) (LocalizedModule.mk a b) = ↑(fromLocalizedModule S f) y
a' : M
b' : { x // x ∈ S }
eq1✝ : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) (LocalizedModule.mk a' b')
eq1 : ↑(fromLocalizedModule S f) (LocalizedModule.mk a b) = ↑(fromLocalizedModule S f) (LocalizedModule.mk a' b')
⊢ LocalizedModule.mk a b = LocalizedModule.mk a' b'
[PROOFSTEP]
simp only [fromLocalizedModule_mk] at eq1
[GOAL]
case h.h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
eq1✝² : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) y
a : M
b : { x // x ∈ S }
eq1✝¹ : ↑(fromLocalizedModule S f) (LocalizedModule.mk a b) = ↑(fromLocalizedModule S f) y
a' : M
b' : { x // x ∈ S }
eq1✝ : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) (LocalizedModule.mk a' b')
eq1 :
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b)))⁻¹ (↑f a) =
↑↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R (Module.End R M')) ↑b')))⁻¹ (↑f a')
⊢ LocalizedModule.mk a b = LocalizedModule.mk a' b'
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← LinearMap.map_smul,
Module.End_algebraMap_isUnit_inv_apply_eq_iff'] at eq1
[GOAL]
case h.h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
eq1✝² : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) y
a : M
b : { x // x ∈ S }
eq1✝¹ : ↑(fromLocalizedModule S f) (LocalizedModule.mk a b) = ↑(fromLocalizedModule S f) y
a' : M
b' : { x // x ∈ S }
eq1✝ : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) (LocalizedModule.mk a' b')
eq1 : ↑b • ↑f a' = ↑b' • ↑f a
⊢ LocalizedModule.mk a b = LocalizedModule.mk a' b'
[PROOFSTEP]
erw [LocalizedModule.mk_eq, ← IsLocalizedModule.eq_iff_exists S f, f.map_smul, f.map_smul, eq1]
[GOAL]
case h.h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x y : LocalizedModule S M
eq1✝² : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) y
a : M
b : { x // x ∈ S }
eq1✝¹ : ↑(fromLocalizedModule S f) (LocalizedModule.mk a b) = ↑(fromLocalizedModule S f) y
a' : M
b' : { x // x ∈ S }
eq1✝ : ↑(fromLocalizedModule S f) x = ↑(fromLocalizedModule S f) (LocalizedModule.mk a' b')
eq1 : ↑b • ↑f a' = ↑b' • ↑f a
⊢ ↑b' • ↑f a = ↑(Submonoid.subtype S) b' • ↑f a
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x : M'
m : M
s : { x // x ∈ S }
eq1 : (m, s).snd • x = ↑f (m, s).fst
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk m s) = x
[PROOFSTEP]
rw [fromLocalizedModule_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← eq1]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x : M'
m : M
s : { x // x ∈ S }
eq1 : (m, s).snd • x = ↑f (m, s).fst
⊢ (m, s).snd • x = ↑s • x
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M'
⊢ ↑(LinearEquiv.symm (iso S f)) m =
LocalizedModule.mk (Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).fst
(Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).snd
[PROOFSTEP]
apply_fun iso S f using LinearEquiv.injective (iso S f)
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M'
⊢ ↑(iso S f) (↑(LinearEquiv.symm (iso S f)) m) =
↑(iso S f)
(LocalizedModule.mk (Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).fst
(Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).snd)
[PROOFSTEP]
rw [LinearEquiv.apply_symm_apply]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M'
⊢ m =
↑(iso S f)
(LocalizedModule.mk (Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).fst
(Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).snd)
[PROOFSTEP]
simp only [iso_apply, LinearMap.toFun_eq_coe, fromLocalizedModule_mk]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M'
⊢ m =
fromLocalizedModule' S f
(LocalizedModule.mk (Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).fst
(Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).snd)
[PROOFSTEP]
erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff', (surj' _).choose_spec]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M'
a : M
b : { x // x ∈ S }
eq1 : b • m = ↑f a
⊢ ∃ u,
u • b • (Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).fst =
u • (Exists.choose (_ : ∃ x, x.snd • m = ↑f x.fst)).snd • a
[PROOFSTEP]
erw [← IsLocalizedModule.eq_iff_exists S f, f.map_smul, f.map_smul, ← (surj' _).choose_spec, ← mul_smul, mul_comm,
mul_smul, eq1]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
⊢ LinearMap.comp (↑(LinearEquiv.symm (iso S f))) f = LocalizedModule.mkLinearMap S M
[PROOFSTEP]
ext m
[GOAL]
case h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
⊢ ↑(LinearMap.comp (↑(LinearEquiv.symm (iso S f))) f) m = ↑(LocalizedModule.mkLinearMap S M) m
[PROOFSTEP]
rw [LinearMap.comp_apply, LocalizedModule.mkLinearMap_apply]
[GOAL]
case h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
⊢ ↑↑(LinearEquiv.symm (iso S f)) (↑f m) = LocalizedModule.mk m 1
[PROOFSTEP]
change (iso S f).symm _ = _
[GOAL]
case h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
⊢ ↑(LinearEquiv.symm (iso S f)) (↑f m) = LocalizedModule.mk m 1
[PROOFSTEP]
rw [iso_symm_apply']
[GOAL]
case h.eq1
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
⊢ 1 • ↑f m = ↑f m
[PROOFSTEP]
exact one_smul _ _
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
⊢ LinearMap.comp (lift S f g h) f = g
[PROOFSTEP]
dsimp only [IsLocalizedModule.lift]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
⊢ LinearMap.comp (LinearMap.comp (LocalizedModule.lift S g h) ↑(LinearEquiv.symm (iso S f))) f = g
[PROOFSTEP]
rw [LinearMap.comp_assoc]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
⊢ LinearMap.comp (LocalizedModule.lift S g h) (LinearMap.comp (↑(LinearEquiv.symm (iso S f))) f) = g
[PROOFSTEP]
convert LocalizedModule.lift_comp S g h
[GOAL]
case h.e'_2.h.e'_21
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
⊢ LinearMap.comp (↑(LinearEquiv.symm (iso S f))) f = LocalizedModule.mkLinearMap S M
[PROOFSTEP]
exact iso_symm_comp _ _
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
⊢ lift S f g h = l
[PROOFSTEP]
dsimp only [IsLocalizedModule.lift]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
⊢ LinearMap.comp (LocalizedModule.lift S g h) ↑(LinearEquiv.symm (iso S f)) = l
[PROOFSTEP]
rw [LocalizedModule.lift_unique S g h (l.comp (iso S f).toLinearMap), LinearMap.comp_assoc,
show (iso S f).toLinearMap.comp (iso S f).symm.toLinearMap = LinearMap.id from _, LinearMap.comp_id]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
⊢ LinearMap.comp ↑(iso S f) ↑(LinearEquiv.symm (iso S f)) = LinearMap.id
[PROOFSTEP]
rw [LinearEquiv.comp_toLinearMap_symm_eq, LinearMap.id_comp]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
⊢ LinearMap.comp (LinearMap.comp l ↑(iso S f)) (LocalizedModule.mkLinearMap S M) = g
[PROOFSTEP]
rw [LinearMap.comp_assoc, ← hl]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
⊢ LinearMap.comp l (LinearMap.comp (↑(iso S f)) (LocalizedModule.mkLinearMap S M)) = LinearMap.comp l f
[PROOFSTEP]
congr 1
[GOAL]
case e_g
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
⊢ LinearMap.comp (↑(iso S f)) (LocalizedModule.mkLinearMap S M) = f
[PROOFSTEP]
ext x
[GOAL]
case e_g.h
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
g : M →ₗ[R] M''
h : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
l : M' →ₗ[R] M''
hl : LinearMap.comp l f = g
x : M
⊢ ↑(LinearMap.comp (↑(iso S f)) (LocalizedModule.mkLinearMap S M)) x = ↑f x
[PROOFSTEP]
erw [fromLocalizedModule_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, one_smul]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
map_unit : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
j k : M' →ₗ[R] M''
h : LinearMap.comp j f = LinearMap.comp k f
⊢ j = k
[PROOFSTEP]
rw [← lift_unique S f (k.comp f) map_unit j h, lift_unique]
[GOAL]
case hl
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
map_unit : ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R M'')) ↑x)
j k : M' →ₗ[R] M''
h : LinearMap.comp j f = LinearMap.comp k f
⊢ LinearMap.comp k f = LinearMap.comp k f
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
r : R
m : M
s : { x // x ∈ S }
⊢ mk' f (r • m) s = r • mk' f m s
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
r : R
m : M
s : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk (r • m) s) = r • ↑(fromLocalizedModule S f) (LocalizedModule.mk m s)
[PROOFSTEP]
rw [← LocalizedModule.smul'_mk, LinearMap.map_smul]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f m₁ s₁ + mk' f m₂ s₂ = mk' f (s₂ • m₁ + s₁ • m₂) (s₁ * s₂)
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk m₁ s₁) + ↑(fromLocalizedModule S f) (LocalizedModule.mk m₂ s₂) =
↑(fromLocalizedModule S f) (LocalizedModule.mk (s₂ • m₁ + s₁ • m₂) (s₁ * s₂))
[PROOFSTEP]
rw [← map_add, LocalizedModule.mk_add_mk]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
s : { x // x ∈ S }
⊢ mk' f 0 s = 0
[PROOFSTEP]
rw [← zero_smul R (0 : M), mk'_smul, zero_smul]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
⊢ mk' f m 1 = ↑f m
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk m 1) = ↑f m
[PROOFSTEP]
rw [fromLocalizedModule_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, Submonoid.coe_one, one_smul]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ mk' f (s • m) s = ↑f m
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk (s • m) s) = ↑f m
[PROOFSTEP]
rw [LocalizedModule.mk_cancel, ← mk'_one S f]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk m 1) = mk' f m 1
[PROOFSTEP]
rfl
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ s • mk' f m s = ↑f m
[PROOFSTEP]
rw [Submonoid.smul_def, ← mk'_smul, ← Submonoid.smul_def, mk'_cancel]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f (s₁ • m) (s₁ * s₂) = mk' f m s₂
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk (s₁ • m) (s₁ * s₂)) =
↑(fromLocalizedModule S f) (LocalizedModule.mk m s₂)
[PROOFSTEP]
rw [LocalizedModule.mk_cancel_common_left]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f (s₂ • m) (s₁ * s₂) = mk' f m s₁
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk (s₂ • m) (s₁ * s₂)) =
↑(fromLocalizedModule S f) (LocalizedModule.mk m s₁)
[PROOFSTEP]
rw [LocalizedModule.mk_cancel_common_right]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s : { x // x ∈ S }
⊢ mk' f (m₁ + m₂) s = mk' f m₁ s + mk' f m₂ s
[PROOFSTEP]
rw [mk'_add_mk', ← smul_add, mk'_cancel_left]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f m₁ s₁ = mk' f m₂ s₂ ↔ ∃ s, s • s₁ • m₂ = s • s₂ • m₁
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk m₁ s₁) = ↑(fromLocalizedModule S f) (LocalizedModule.mk m₂ s₂) ↔
∃ s, s • s₁ • m₂ = s • s₂ • m₁
[PROOFSTEP]
rw [(fromLocalizedModule.inj S f).eq_iff, LocalizedModule.mk_eq]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ (∃ u, u • s₂ • m₁ = u • s₁ • m₂) ↔ ∃ s, s • s₁ • m₂ = s • s₂ • m₁
[PROOFSTEP]
simp_rw [eq_comm]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup M'
inst✝² : Module R M
inst✝¹ : Module R M'
f : M →ₗ[R] M'
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ mk' f (-m) s = -mk' f m s
[PROOFSTEP]
delta mk'
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup M'
inst✝² : Module R M
inst✝¹ : Module R M'
f : M →ₗ[R] M'
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ ↑(fromLocalizedModule S f) (LocalizedModule.mk (-m) s) = -↑(fromLocalizedModule S f) (LocalizedModule.mk m s)
[PROOFSTEP]
rw [LocalizedModule.mk_neg, map_neg]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup M'
inst✝² : Module R M
inst✝¹ : Module R M'
f : M →ₗ[R] M'
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s : { x // x ∈ S }
⊢ mk' f (m₁ - m₂) s = mk' f m₁ s - mk' f m₂ s
[PROOFSTEP]
rw [sub_eq_add_neg, sub_eq_add_neg, mk'_add, mk'_neg]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup M'
inst✝² : Module R M
inst✝¹ : Module R M'
f : M →ₗ[R] M'
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f m₁ s₁ - mk' f m₂ s₂ = mk' f (s₂ • m₁ - s₁ • m₂) (s₁ * s₂)
[PROOFSTEP]
rw [sub_eq_add_neg, ← mk'_neg, mk'_add_mk', smul_neg, ← sub_eq_add_neg]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : Semiring M
inst✝³ : Semiring M'
inst✝² : Module R M
inst✝¹ : Algebra R M'
f : M →ₗ[R] M'
hf : ∀ (m₁ m₂ : M), ↑f (m₁ * m₂) = ↑f m₁ * ↑f m₂
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f m₁ s₁ * mk' f m₂ s₂ = mk' f (m₁ * m₂) (s₁ * s₂)
[PROOFSTEP]
symm
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : Semiring M
inst✝³ : Semiring M'
inst✝² : Module R M
inst✝¹ : Algebra R M'
f : M →ₗ[R] M'
hf : ∀ (m₁ m₂ : M), ↑f (m₁ * m₂) = ↑f m₁ * ↑f m₂
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ mk' f (m₁ * m₂) (s₁ * s₂) = mk' f m₁ s₁ * mk' f m₂ s₂
[PROOFSTEP]
apply (Module.End_algebraMap_isUnit_inv_apply_eq_iff _ _ _ _).mpr
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : Semiring M
inst✝³ : Semiring M'
inst✝² : Module R M
inst✝¹ : Algebra R M'
f : M →ₗ[R] M'
hf : ∀ (m₁ m₂ : M), ↑f (m₁ * m₂) = ↑f m₁ * ↑f m₂
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑f (m₁ * m₂, s₁ * s₂).fst = ↑(m₁ * m₂, s₁ * s₂).snd • (mk' f m₁ s₁ * mk' f m₂ s₂)
[PROOFSTEP]
simp_rw [Submonoid.coe_mul, ← smul_eq_mul]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : Semiring M
inst✝³ : Semiring M'
inst✝² : Module R M
inst✝¹ : Algebra R M'
f : M →ₗ[R] M'
hf : ∀ (m₁ m₂ : M), ↑f (m₁ * m₂) = ↑f m₁ * ↑f m₂
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑f (m₁ • m₂) = (↑s₁ • ↑s₂) • mk' f m₁ s₁ • mk' f m₂ s₂
[PROOFSTEP]
rw [smul_smul_smul_comm, ← mk'_smul, ← mk'_smul]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M✝ : Type u_2
M'✝ : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'✝
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M✝
inst✝⁷ : Module R M'✝
inst✝⁶ : Module R M''
f✝ : M✝ →ₗ[R] M'✝
g : M✝ →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f✝
M : Type u_5
M' : Type u_6
inst✝⁴ : Semiring M
inst✝³ : Semiring M'
inst✝² : Module R M
inst✝¹ : Algebra R M'
f : M →ₗ[R] M'
hf : ∀ (m₁ m₂ : M), ↑f (m₁ * m₂) = ↑f m₁ * ↑f m₂
inst✝ : IsLocalizedModule S f
m₁ m₂ : M
s₁ s₂ : { x // x ∈ S }
⊢ ↑f (m₁ • m₂) = mk' f (↑s₁ • m₁) s₁ • mk' f (↑s₂ • m₂) s₂
[PROOFSTEP]
simp_rw [← Submonoid.smul_def, mk'_cancel, smul_eq_mul, hf]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
m' : M'
⊢ mk' f m s = m' ↔ ↑f m = s • m'
[PROOFSTEP]
rw [← smul_inj f s, Submonoid.smul_def, ← mk'_smul, ← Submonoid.smul_def, mk'_cancel]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ mk' f m s = 0 ↔ ↑f m = 0
[PROOFSTEP]
rw [mk'_eq_iff, smul_zero]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
m : M
s : { x // x ∈ S }
⊢ mk' f m s = 0 ↔ ∃ s', s' • m = 0
[PROOFSTEP]
simp_rw [← mk'_zero f (1 : S), mk'_eq_mk'_iff, smul_zero, one_smul, eq_comm]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
s : { x // x ∈ S }
m : M
⊢ LocalizedModule.mk m s = mk' (LocalizedModule.mkLinearMap S M) m s
[PROOFSTEP]
rw [eq_comm, mk'_eq_iff, Submonoid.smul_def, LocalizedModule.smul'_mk, ← Submonoid.smul_def, LocalizedModule.mk_cancel,
LocalizedModule.mkLinearMap_apply]
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
⊢ Function.Surjective (Function.uncurry (mk' f))
[PROOFSTEP]
intro x
[GOAL]
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x : M'
⊢ ∃ a, Function.uncurry (mk' f) a = x
[PROOFSTEP]
obtain ⟨⟨m, s⟩, e : s • x = f m⟩ := IsLocalizedModule.surj S f x
[GOAL]
case intro.mk
R : Type u_1
inst✝⁷ : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝⁶ : AddCommMonoid M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : AddCommMonoid M''
inst✝³ : Module R M
inst✝² : Module R M'
inst✝¹ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝ : IsLocalizedModule S f
x : M'
m : M
s : { x // x ∈ S }
e : s • x = ↑f m
⊢ ∃ a, Function.uncurry (mk' f) a = x
[PROOFSTEP]
exact ⟨⟨m, s⟩, mk'_eq_iff.mpr e.symm⟩
[GOAL]
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 → ∃ m, m • x = 0
⊢ IsLocalizedModule M (AlgHom.toLinearMap f)
[PROOFSTEP]
replace h₃ := fun x =>
Iff.intro (h₃ x) fun ⟨⟨m, hm⟩, e⟩ =>
(h₁ m hm).mul_left_cancel <| by
rw [← Algebra.smul_def]
simpa [Submonoid.smul_def] using f.congr_arg e
[GOAL]
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 → ∃ m, m • x = 0
x : S
x✝ : ∃ m, m • x = 0
m : R
hm : m ∈ M
e : { val := m, property := hm } • x = 0
⊢ ↑(algebraMap R S') m * ↑f x = ↑(algebraMap R S') m * 0
[PROOFSTEP]
rw [← Algebra.smul_def]
[GOAL]
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 → ∃ m, m • x = 0
x : S
x✝ : ∃ m, m • x = 0
m : R
hm : m ∈ M
e : { val := m, property := hm } • x = 0
⊢ m • ↑f x = ↑(algebraMap R S') m * 0
[PROOFSTEP]
simpa [Submonoid.smul_def] using f.congr_arg e
[GOAL]
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
⊢ IsLocalizedModule M (AlgHom.toLinearMap f)
[PROOFSTEP]
constructor
[GOAL]
case map_units
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
⊢ ∀ (x : { x // x ∈ M }), IsUnit (↑(algebraMap R (Module.End R S')) ↑x)
[PROOFSTEP]
intro x
[GOAL]
case map_units
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
⊢ IsUnit (↑(algebraMap R (Module.End R S')) ↑x)
[PROOFSTEP]
rw [Module.End_isUnit_iff]
[GOAL]
case map_units
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
⊢ Function.Bijective ↑(↑(algebraMap R (Module.End R S')) ↑x)
[PROOFSTEP]
constructor
[GOAL]
case map_units.left
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
⊢ Function.Injective ↑(↑(algebraMap R (Module.End R S')) ↑x)
[PROOFSTEP]
rintro a b (e : x • a = x • b)
[GOAL]
case map_units.left
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
a b : S'
e : x • a = x • b
⊢ a = b
[PROOFSTEP]
simp_rw [Submonoid.smul_def, Algebra.smul_def] at e
[GOAL]
case map_units.left
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
a b : S'
e : ↑(algebraMap R S') ↑x * a = ↑(algebraMap R S') ↑x * b
⊢ a = b
[PROOFSTEP]
exact (h₁ x x.2).mul_left_cancel e
[GOAL]
case map_units.right
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
⊢ Function.Surjective ↑(↑(algebraMap R (Module.End R S')) ↑x)
[PROOFSTEP]
intro a
[GOAL]
case map_units.right
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
a : S'
⊢ ∃ a_1, ↑(↑(algebraMap R (Module.End R S')) ↑x) a_1 = a
[PROOFSTEP]
refine' ⟨((h₁ x x.2).unit⁻¹ : _) * a, _⟩
[GOAL]
case map_units.right
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
a : S'
⊢ ↑(↑(algebraMap R (Module.End R S')) ↑x) (↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R S') ↑x)))⁻¹ * a) = a
[PROOFSTEP]
change (x : R) • (_ * a) = _
[GOAL]
case map_units.right
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x : { x // x ∈ M }
a : S'
⊢ ↑x • (↑(IsUnit.unit (_ : IsUnit (↑(algebraMap R S') ↑x)))⁻¹ * a) = a
[PROOFSTEP]
rw [Algebra.smul_def, ← mul_assoc, IsUnit.mul_val_inv, one_mul]
[GOAL]
case surj'
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
⊢ ∀ (y : S'), ∃ x, x.snd • y = ↑(AlgHom.toLinearMap f) x.fst
[PROOFSTEP]
exact h₂
[GOAL]
case eq_iff_exists'
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
⊢ ∀ {x₁ x₂ : S}, ↑(AlgHom.toLinearMap f) x₁ = ↑(AlgHom.toLinearMap f) x₂ ↔ ∃ c, c • x₂ = c • x₁
[PROOFSTEP]
intros
[GOAL]
case eq_iff_exists'
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x₁✝ x₂✝ : S
⊢ ↑(AlgHom.toLinearMap f) x₁✝ = ↑(AlgHom.toLinearMap f) x₂✝ ↔ ∃ c, c • x₂✝ = c • x₁✝
[PROOFSTEP]
dsimp only [AlgHom.toLinearMap_apply]
[GOAL]
case eq_iff_exists'
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x₁✝ x₂✝ : S
⊢ ↑f x₁✝ = ↑f x₂✝ ↔ ∃ c, c • x₂✝ = c • x₁✝
[PROOFSTEP]
rw [eq_comm, ← sub_eq_zero, ← map_sub, h₃]
[GOAL]
case eq_iff_exists'
R✝ : Type u_1
inst✝¹² : CommRing R✝
S✝ : Submonoid R✝
M✝ : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M✝
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ M'
inst✝⁶ : Module R✝ M''
f✝ : M✝ →ₗ[R✝] M'
g : M✝ →ₗ[R✝] M''
inst✝⁵ : IsLocalizedModule S✝ f✝
R : Type u_5
S : Type u_6
S' : Type u_7
inst✝⁴ : CommRing R
inst✝³ : CommRing S
inst✝² : CommRing S'
inst✝¹ : Algebra R S
inst✝ : Algebra R S'
M : Submonoid R
f : S →ₐ[R] S'
h₁ : ∀ (x : R), x ∈ M → IsUnit (↑(algebraMap R S') x)
h₂ : ∀ (y : S'), ∃ x, x.snd • y = ↑f x.fst
h₃ : ∀ (x : S), ↑f x = 0 ↔ ∃ m, m • x = 0
x₁✝ x₂✝ : S
⊢ (∃ m, m • (x₂✝ - x₁✝) = 0) ↔ ∃ c, c • x₂✝ = c • x₁✝
[PROOFSTEP]
simp_rw [smul_sub, sub_eq_zero]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
⊢ IsBaseChange A f
[PROOFSTEP]
refine' IsBaseChange.of_lift_unique _ (fun Q _ _ _ _ g ↦ _)
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
⊢ ∃! g', LinearMap.comp (↑R g') f = g
[PROOFSTEP]
have :=
IsLocalizedModule.is_universal S f g <| by
intro s
simp_rw [Module.End_isUnit_iff, Function.bijective_iff_existsUnique, Module.algebraMap_end_apply]
intro q
refine' ⟨(IsLocalization.mk' _ 1 s : A) • q, _, _⟩
· simp only [← smul_assoc, IsLocalization.smul_mk'_self, map_one, one_smul]
· rintro q rfl
simp only [smul_comm _ (s : R), ← smul_assoc, IsLocalization.smul_mk'_self, map_one, one_smul]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
⊢ ∀ (x : { x // x ∈ S }), IsUnit (↑(algebraMap R (Module.End R Q)) ↑x)
[PROOFSTEP]
intro s
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
s : { x // x ∈ S }
⊢ IsUnit (↑(algebraMap R (Module.End R Q)) ↑s)
[PROOFSTEP]
simp_rw [Module.End_isUnit_iff, Function.bijective_iff_existsUnique, Module.algebraMap_end_apply]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
s : { x // x ∈ S }
⊢ ∀ (b : Q), ∃! a, ↑s • a = b
[PROOFSTEP]
intro q
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
s : { x // x ∈ S }
q : Q
⊢ ∃! a, ↑s • a = q
[PROOFSTEP]
refine' ⟨(IsLocalization.mk' _ 1 s : A) • q, _, _⟩
[GOAL]
case refine'_1
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
s : { x // x ∈ S }
q : Q
⊢ (fun a => ↑s • a = q) (IsLocalization.mk' A 1 s • q)
[PROOFSTEP]
simp only [← smul_assoc, IsLocalization.smul_mk'_self, map_one, one_smul]
[GOAL]
case refine'_2
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
s : { x // x ∈ S }
q : Q
⊢ ∀ (y : Q), (fun a => ↑s • a = q) y → y = IsLocalization.mk' A 1 s • q
[PROOFSTEP]
rintro q rfl
[GOAL]
case refine'_2
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
s : { x // x ∈ S }
q : Q
⊢ q = IsLocalization.mk' A 1 s • ↑s • q
[PROOFSTEP]
simp only [smul_comm _ (s : R), ← smul_assoc, IsLocalization.smul_mk'_self, map_one, one_smul]
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g✝ : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
g : M →ₗ[R] Q
this : ∃! l, LinearMap.comp l f = g
⊢ ∃! g', LinearMap.comp (↑R g') f = g
[PROOFSTEP]
rcases this with ⟨ℓ, rfl, h₂⟩
[GOAL]
case intro.intro
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
ℓ : M' →ₗ[R] Q
h₂ : ∀ (y : M' →ₗ[R] Q), (fun l => LinearMap.comp l f = LinearMap.comp ℓ f) y → y = ℓ
⊢ ∃! g', LinearMap.comp (↑R g') f = LinearMap.comp ℓ f
[PROOFSTEP]
refine' ⟨ℓ.extendScalarsOfIsLocalization S A, by simp, fun g'' h ↦ _⟩
[GOAL]
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
ℓ : M' →ₗ[R] Q
h₂ : ∀ (y : M' →ₗ[R] Q), (fun l => LinearMap.comp l f = LinearMap.comp ℓ f) y → y = ℓ
⊢ (fun g' => LinearMap.comp (↑R g') f = LinearMap.comp ℓ f) (LinearMap.extendScalarsOfIsLocalization S A ℓ)
[PROOFSTEP]
simp
[GOAL]
case intro.intro
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
ℓ : M' →ₗ[R] Q
h₂ : ∀ (y : M' →ₗ[R] Q), (fun l => LinearMap.comp l f = LinearMap.comp ℓ f) y → y = ℓ
g'' : M' →ₗ[A] Q
h : (fun g' => LinearMap.comp (↑R g') f = LinearMap.comp ℓ f) g''
⊢ g'' = LinearMap.extendScalarsOfIsLocalization S A ℓ
[PROOFSTEP]
ext x
[GOAL]
case intro.intro.h
R : Type u_1
inst✝¹² : CommRing R
S : Submonoid R
M : Type u_2
M' : Type u_3
M'' : Type u_4
inst✝¹¹ : AddCommMonoid M
inst✝¹⁰ : AddCommMonoid M'
inst✝⁹ : AddCommMonoid M''
inst✝⁸ : Module R M
inst✝⁷ : Module R M'
inst✝⁶ : Module R M''
f : M →ₗ[R] M'
g : M →ₗ[R] M''
inst✝⁵ : IsLocalizedModule S f
A : Type u_5
inst✝⁴ : CommRing A
inst✝³ : Algebra R A
inst✝² : Module A M'
inst✝¹ : IsScalarTower R A M'
inst✝ : IsLocalization S A
Q : Type (max u_2 u_3 u_5)
x✝³ : AddCommMonoid Q
x✝² : Module R Q
x✝¹ : Module A Q
x✝ : IsScalarTower R A Q
ℓ : M' →ₗ[R] Q
h₂ : ∀ (y : M' →ₗ[R] Q), (fun l => LinearMap.comp l f = LinearMap.comp ℓ f) y → y = ℓ
g'' : M' →ₗ[A] Q
h : (fun g' => LinearMap.comp (↑R g') f = LinearMap.comp ℓ f) g''
x : M'
⊢ ↑g'' x = ↑(LinearMap.extendScalarsOfIsLocalization S A ℓ) x
[PROOFSTEP]
simp [← h₂ (LinearMap.restrictScalars R g'') h]
|
[STATEMENT]
lemma lm122:
"set ([n. n \<leftarrow> [0..<size l], P (l!n)]) \<subseteq> {0..<size l}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. set (concat (map (\<lambda>n. if P (l ! n) then [n] else []) [0..<length l])) \<subseteq> {0..<length l}
[PROOF STEP]
by force |
Formal statement is: lemma if_0_minus_poly_rev_list: "(if a = 0 then x else minus_poly_rev_list x (map ((*) a) y)) = minus_poly_rev_list x (map ((*) a) y)" for a :: "'a::ring" Informal statement is: If $a = 0$, then $x$ is equal to $x$ minus the list $y$ multiplied by $a$. |
proposition\<^marker>\<open>tag unimportant\<close> homeomorphism_grouping_points_exists_gen: fixes S :: "'a::euclidean_space set" assumes opeU: "openin (top_of_set S) U" and opeS: "openin (top_of_set (affine hull S)) S" and "U \<noteq> {}" "finite K" "K \<subseteq> S" and S: "S \<subseteq> T" "T \<subseteq> affine hull S" "connected S" obtains f g where "homeomorphism T T f g" "{x. (\<not> (f x = x \<and> g x = x))} \<subseteq> S" "bounded {x. (\<not> (f x = x \<and> g x = x))}" "\<And>x. x \<in> K \<Longrightarrow> f x \<in> U" |
[STATEMENT]
lemma put_M\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t_tag_name_type_wf_preserved [simp]:
"h \<turnstile> put_M element_ptr tag_name_update v \<rightarrow>\<^sub>h h' \<Longrightarrow> type_wf h = type_wf h'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. h \<turnstile> put_M element_ptr tag_name_update v \<rightarrow>\<^sub>h h' \<Longrightarrow> ElementClass.type_wf h = ElementClass.type_wf h'
[PROOF STEP]
apply(auto simp add: type_wf_defs NodeClass.type_wf_defs ObjectClass.type_wf_defs
Let_def put_M_defs get_M_defs put\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t_def put\<^sub>N\<^sub>o\<^sub>d\<^sub>e_def put\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t_def
get\<^sub>E\<^sub>l\<^sub>e\<^sub>m\<^sub>e\<^sub>n\<^sub>t_def get\<^sub>N\<^sub>o\<^sub>d\<^sub>e_def get\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t_def
split: prod.splits option.splits Option.bind_splits elim!: bind_returns_heap_E)[1]
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<And>x2 node_ptr va. \<lbrakk>h' = Heap (fmupd (cast (cast element_ptr)) (cast (cast (x2\<lparr>tag_name := v\<rparr>))) (the_heap h)); fmlookup (the_heap h) (cast (cast element_ptr)) = Some (cast (cast x2)); \<forall>node_ptr\<in>fset (node_ptr_kinds h). (fmlookup (the_heap h) (cast node_ptr) = None \<longrightarrow> cast element_ptr = node_ptr) \<and> (\<forall>v. fmlookup (the_heap h) (cast node_ptr) = Some v \<longrightarrow> cast element_ptr \<noteq> node_ptr \<longrightarrow> (\<exists>y. cast y = v)); \<forall>element_ptra\<in>fset (element_ptr_kinds h). (fmlookup (the_heap h) (cast (cast element_ptra)) = None \<longrightarrow> element_ptr = element_ptra) \<and> (\<forall>v. ((\<forall>node. cast node \<noteq> v) \<longrightarrow> fmlookup (the_heap h) (cast (cast element_ptra)) = Some v \<longrightarrow> element_ptr = element_ptra) \<and> (\<forall>va. cast va = v \<longrightarrow> fmlookup (the_heap h) (cast (cast element_ptra)) = Some v \<longrightarrow> element_ptr \<noteq> element_ptra \<longrightarrow> (\<exists>y. cast y = va))); node_ptr |\<in>| node_ptr_kinds h; fmlookup (the_heap h) (cast node_ptr) = Some va\<rbrakk> \<Longrightarrow> \<exists>y. cast y = va
2. \<And>x2 element_ptra va. \<lbrakk>h' = Heap (fmupd (cast (cast element_ptr)) (cast (cast (x2\<lparr>tag_name := v\<rparr>))) (the_heap h)); fmlookup (the_heap h) (cast (cast element_ptr)) = Some (cast (cast x2)); \<forall>node_ptr\<in>fset (node_ptr_kinds h). (fmlookup (the_heap h) (cast node_ptr) = None \<longrightarrow> cast element_ptr = node_ptr) \<and> (\<forall>v. fmlookup (the_heap h) (cast node_ptr) = Some v \<longrightarrow> cast element_ptr \<noteq> node_ptr \<longrightarrow> (\<exists>y. cast y = v)); \<forall>element_ptra\<in>fset (element_ptr_kinds h). (fmlookup (the_heap h) (cast (cast element_ptra)) = None \<longrightarrow> element_ptr = element_ptra) \<and> (\<forall>v. ((\<forall>node. cast node \<noteq> v) \<longrightarrow> fmlookup (the_heap h) (cast (cast element_ptra)) = Some v \<longrightarrow> element_ptr = element_ptra) \<and> (\<forall>va. cast va = v \<longrightarrow> fmlookup (the_heap h) (cast (cast element_ptra)) = Some v \<longrightarrow> element_ptr \<noteq> element_ptra \<longrightarrow> (\<exists>y. cast y = va))); element_ptra |\<in>| element_ptr_kinds h; fmlookup (the_heap h) (cast (cast element_ptra)) = Some (cast va)\<rbrakk> \<Longrightarrow> \<exists>y. cast y = va
[PROOF STEP]
apply (metis finite_set_in option.inject)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>x2 element_ptra va. \<lbrakk>h' = Heap (fmupd (cast (cast element_ptr)) (cast (cast (x2\<lparr>tag_name := v\<rparr>))) (the_heap h)); fmlookup (the_heap h) (cast (cast element_ptr)) = Some (cast (cast x2)); \<forall>node_ptr\<in>fset (node_ptr_kinds h). (fmlookup (the_heap h) (cast node_ptr) = None \<longrightarrow> cast element_ptr = node_ptr) \<and> (\<forall>v. fmlookup (the_heap h) (cast node_ptr) = Some v \<longrightarrow> cast element_ptr \<noteq> node_ptr \<longrightarrow> (\<exists>y. cast y = v)); \<forall>element_ptra\<in>fset (element_ptr_kinds h). (fmlookup (the_heap h) (cast (cast element_ptra)) = None \<longrightarrow> element_ptr = element_ptra) \<and> (\<forall>v. ((\<forall>node. cast node \<noteq> v) \<longrightarrow> fmlookup (the_heap h) (cast (cast element_ptra)) = Some v \<longrightarrow> element_ptr = element_ptra) \<and> (\<forall>va. cast va = v \<longrightarrow> fmlookup (the_heap h) (cast (cast element_ptra)) = Some v \<longrightarrow> element_ptr \<noteq> element_ptra \<longrightarrow> (\<exists>y. cast y = va))); element_ptra |\<in>| element_ptr_kinds h; fmlookup (the_heap h) (cast (cast element_ptra)) = Some (cast va)\<rbrakk> \<Longrightarrow> \<exists>y. cast y = va
[PROOF STEP]
apply (metis cast\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t\<^sub>2\<^sub>N\<^sub>o\<^sub>d\<^sub>e_inv finite_set_in option.sel)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
import game.world9.level3 -- hide
namespace mynat -- hide
/-
# Advanced Multiplication World
## Level 4: `mul_left_cancel`
This is the last of the bonus multiplication levels.
`mul_left_cancel` will be useful in inequality world.
People find this level hard. I have probably had more questions about this
level than all the other levels put together, in fact. Many levels in this
game can just be solved by "running at it" -- do induction on one of the
variables, keep your head, and you're done. In fact, if you like a challenge,
it might be instructive if you stop reading after the end of this paragraph and try solving this level now by induction,
seeing the trouble you run into, and reading the rest of these comments afterwards. This level
has a sting in the tail. If you are a competent mathematician, try
and figure out what is going on. Write down a maths proof of the
theorem in this level. Exactly what statement do you want to prove
by induction? It is subtle.
Ok so here are some spoilers. The problem with naively running at it, is that if you try induction on,
say, $c$, then you are imagining a and b as fixed, and your inductive
hypothesis $P(c)$ is $ab=ac \implies b=c$. So for your inductive step
you will be able to assume $ab=ad \implies b=d$ and your goal will
be to show $ab=a(d+1) \implies b=d+1$. When you also assume $ab=a(d+1)$
you will realise that your inductive hypothesis is *useless*, because
$ab=ad$ is not true! The statement $P(c)$ (with $a$ and $b$ regarded
as constants) is not provable by induction.
What you *can* prove by induction is the following *stronger* statement.
Imagine $a\not=0$ as fixed, and then prove "for all $b$, if $ab=ac$ then $b=c$"
by induction on $c$. This gives us the extra flexibility we require.
Note that we are quantifying over all $b$ in the inductive hypothesis -- it
is essential that $b$ is not fixed.
You can do this in two ways in Lean -- before you start the induction
you can write `revert b,`. The `revert` tactic is the opposite of the `intro`
tactic; it replaces the `b` in the hypotheses with "for all $b$" in the goal.
Alternatively, you can write `induction c with d hd
generalizing b` as the first line of the proof.
If you do not modify your technique in this way, then this level seems
to be impossible (judging by the comments I've had about it!)
-/
/- Theorem
If $a \neq 0$, $b$ and $c$ are natural numbers such that
$ ab = ac, $
then $b = c$.
-/
theorem mul_left_cancel (a b c : mynat) (ha : a ≠ 0) : a * b = a * c → b = c :=
begin [nat_num_game]
induction c with d hd generalizing b,
{ rw mul_zero,
intro h,
cases (eq_zero_or_eq_zero_of_mul_eq_zero _ _ h) with h1 h2,
exfalso,
apply ha,
assumption,
assumption
},
{ intro hb,
cases b with c,
{ rw mul_zero at hb,
exfalso,
apply ha,
symmetry at hb,
cases (eq_zero_or_eq_zero_of_mul_eq_zero _ _ hb) with h h,
exact h,
exfalso,
exact succ_ne_zero _ h,
},
{ have h : c = d,
apply hd,
rw mul_succ at hb,
rw mul_succ at hb,
apply add_right_cancel _ _ _ hb,
rw h,
refl,
}
}
end
end mynat -- hide
/-
You should now be ready for inequality world.
-/
/- Tactic : revert
## Summary
`revert x` is the opposite to `intro x`.
## Details
If the tactic state looks like this
```
P Q : Prop,
h : P
⊢ Q
```
then `revert h` will change it to
```
P Q : Prop
⊢ P → Q
```
`revert` also works with things like natural numbers: if
the tactic state looks like this
```
m : mynat
⊢ m + 1 = succ m
```
then `revert m` will turn it into
```
⊢ ∀ (m : mynat), m + 1 = mynat.succ m
```
-/
|
{-# OPTIONS --cubical #-}
module _ where
module _ where
open import Agda.Primitive.Cubical public
postulate
Path' : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ
PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ
{-# BUILTIN PATH Path' #-}
{-# BUILTIN PATHP PathP #-}
infix 4 _≡_
_≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ
_≡_ {A = A} = PathP (λ _ → A)
Path = _≡_
refl : ∀ {a} {A : Set a} {x : A} → x ≡ x
refl {x = x} = \ _ → x
-- Here there's no solution for H, pattern unification will try
-- H := \ i -> b, but the equality constraints from
-- H : Path b a should rule out that assignment.
testPath : ∀ {A : Set} {b a : A} (let H : Path b a; H = _) → ∀ i → H i ≡ b
testPath i = refl
|
(** * Finite types *)
(* [fin n : Type] is a type with [n] inhabitants. It is isomorphic to
[Coq.Vector.Fin.t] from the standard library, but we found this formulation
easier to reason about. *)
(* In this compiler, we use [fin n] as the type of "block labels" in [Asm]
programs (program locations that can be jumped to). In an earlier version, labels
could be any type, but this restriction makes [Asm] programs easier to introspect
for defining optimizations (though the current development doesn't make use of it).
*)
(* The instances at the end derive categorical operations for the subcategories of
[Fun] and [ktree] on finite types (instead of arbitrary types). *)
(* begin hide *)
From Coq Require Import
Arith
Lia.
Import PeanoNat.Nat EqNotations.
From ITree Require Import
ITree
ITreeFacts
Basics.Category
Basics.CategorySub.
From TinyRAM.Utils Require Import
Arith.
(* end hide *)
(* Type with [n] inhabitants. *)
Definition fin (n : nat) : Type := { x : nat | x < n }.
(* Hide proof terms. *)
(* N.B.: [x < n] unfolds to [S x < n], which is why we don't make the first
field more precise. *)
Notation fi' i := (exist (fun j : nat => _) i _).
Program Definition f0 {n} : fin (S n) := fi' 0.
Next Obligation. lia. Defined.
Lemma unique_fin : forall n (i j : fin n),
proj1_sig i = proj1_sig j -> i = j.
Proof.
intros ? [] [] w. simpl in w; destruct w. f_equal; apply le_unique.
Qed.
Lemma unique_f0 : forall (a : fin 1), a = f0.
Proof.
destruct a. apply unique_fin; simpl. lia.
Qed.
Program Definition fS {n} : fin n -> fin (S n) :=
fun i => fi' (S (proj1_sig i)).
Next Obligation.
destruct i; simpl; lia.
Defined.
Lemma fin_0 {A} : fin 0 -> A.
Proof.
intros [].
apply PeanoNat.Nat.nlt_0_r in l.
contradiction.
Qed.
Instance FinInitial {E} : Initial (sub (ktree E) fin) 0 := fun _ => fin_0.
Lemma split_fin_helper:
forall n m x : nat, x < n + m -> ~ x < n -> x - n < m.
Proof.
intros n m x l n0.
lia.
Defined.
Program Definition split_fin_sum (n m : nat)
: fin (n + m) -> (fin n) + (fin m) := fun x =>
match lt_dec (proj1_sig x) n with
| left _ => inl (fi' (proj1_sig x))
| right _ => inr (fi' (proj1_sig x - n))
end.
Next Obligation.
apply split_fin_helper. eapply proj2_sig. assumption.
Defined.
Program Definition L {n} (m : nat) (a : fin n) : fin (n + m) := _.
Next Obligation.
destruct a.
exists x. apply PeanoNat.Nat.lt_lt_add_r. assumption.
Defined.
Program Definition R {m} (n:nat) (a:fin m) : fin (n + m) := _.
Next Obligation.
destruct a.
exists (n + x). lia.
Defined.
Lemma R_0_a : forall (n:nat) (a : fin n), R 0 a = a.
Proof.
intros; destruct a; apply unique_fin; reflexivity.
Qed.
Lemma R_1_a : forall (n:nat) (a : fin n), R 1 a = fS a.
Proof.
intros; destruct a; apply unique_fin; reflexivity.
Qed.
Lemma split_fin_sum_0_a : forall m (a : fin (0 + m)),
(@split_fin_sum 0 m a) = inr a.
Proof.
intros.
unfold split_fin_sum, split_fin_sum_obligation_1.
destruct (Compare_dec.lt_dec _ 0) as [H | H].
- inversion H.
- f_equal. destruct a; apply unique_fin. simpl; lia.
Qed.
Lemma split_fin_sum_FS_inr :
(@split_fin_sum (S O) (S O) (fS f0) = inr f0).
Proof.
cbn; f_equal; apply unique_f0.
Qed.
Lemma split_fin_sum_f1_inl :
(@split_fin_sum 1 1 (@f0 1)) = inl f0.
Proof.
cbn; f_equal; apply unique_f0.
Qed.
Lemma L_1_f1 : (L 1 (@f0 0)) = f0.
Proof.
apply unique_fin; reflexivity.
Qed.
Lemma split_fin_sum_L_L_f1 :
(@split_fin_sum _ _ (L 1 (L 1 (@f0 0)))) = inl f0.
Proof.
cbn; f_equal; apply unique_fin; reflexivity.
Qed.
Lemma split_fin_sum_R_2 : split_fin_sum 2 1 (R 2 (@f0 0)) = inr f0.
Proof.
cbn; f_equal; apply unique_fin; reflexivity.
Qed.
Lemma split_fin_sum_R n m (x : fin m) : split_fin_sum n m (R n x) = inr x.
Proof.
destruct x; simpl. unfold split_fin_sum; simpl.
destruct lt_dec.
- exfalso. lia.
- f_equal. apply unique_fin; simpl; lia.
Qed.
Lemma split_fin_sum_L n m (x : fin n) : split_fin_sum n m (L m x) = inl x.
Proof.
destruct x; simpl. unfold split_fin_sum; simpl.
destruct lt_dec.
- f_equal. apply unique_fin; simpl; lia.
- exfalso. lia.
Qed.
Definition merge_fin_sum (n m: nat) : fin n + fin m -> fin (n + m) :=
fun v =>
match v with
| inl v => L m v
| inr v => R n v
end.
Lemma merge_fin_sum_inr : (merge_fin_sum 1 1 (inr f0)) = (fS f0).
Proof.
apply unique_fin; reflexivity.
Qed.
Lemma merge_fin_sum_inl_1 f : (merge_fin_sum 1 1 (inl f)) = f0.
Proof.
rewrite (unique_f0 f); apply unique_fin; reflexivity.
Qed.
Lemma merge_split:
forall (n m : nat) (a : fin (n + m)), merge_fin_sum n m (split_fin_sum n m a) = a.
Proof.
intros n m []. unfold split_fin_sum; simpl.
destruct (lt_dec x n); apply unique_fin; simpl; reflexivity + lia.
Qed.
Lemma split_merge:
forall (n m : nat) (a : fin n + fin m), split_fin_sum n m (merge_fin_sum n m a) = a.
Proof.
intros n m [[] | []]; unfold split_fin_sum; simpl; destruct lt_dec; simpl;
try (f_equal; apply unique_fin; simpl; reflexivity + lia);
try contradiction + exfalso; lia.
Qed.
Definition fin_mod : forall n m,
n <> 0 -> fin (m * n) -> fin n.
intros n m meq f.
destruct f as [f fprp].
exists (f mod n).
apply mod_upper_bound.
assumption.
Defined.
Instance ToBifunctor_ktree_fin {E} : ToBifunctor (ktree E) fin sum Nat.add :=
fun n m y => Ret (split_fin_sum n m y).
Instance FromBifunctor_ktree_fin {E} : FromBifunctor (ktree E) fin sum Nat.add :=
fun n m y => Ret (merge_fin_sum n m y).
Instance IsoBif_ktree_fin {E}
: forall a b, Iso (ktree E) (a := fin (Nat.add a b)) to_bif from_bif.
Proof.
unfold to_bif, ToBifunctor_ktree_fin, from_bif, FromBifunctor_ktree_fin.
constructor; intros x.
- unfold cat, Cat_sub, Cat_Kleisli. cbn. rewrite bind_ret_l.
apply eqit_Ret, merge_split.
- unfold cat, Cat_sub, Cat_Kleisli. cbn. rewrite bind_ret_l.
apply eqit_Ret, split_merge.
Qed.
Instance ToBifunctor_Fun_fin : ToBifunctor Fun fin sum Nat.add :=
fun n m y => split_fin_sum n m y.
Instance FromBifunctor_Fun_fin : FromBifunctor Fun fin sum Nat.add :=
fun n m y => merge_fin_sum n m y.
Instance IsoBif_Fun_fin
: forall a b, Iso Fun (a := fin (Nat.add a b)) to_bif from_bif.
Proof.
constructor; intros x.
- apply merge_split.
- apply split_merge.
Qed.
Instance InitialObject_ktree_fin {E} : InitialObject (sub (ktree E) fin) 0.
Proof.
intros n f x; apply fin_0; auto.
Qed.
Definition fin_add : forall {n m} (f1 : fin n) (f2 : fin m), fin (n + m - 1).
intros n m [f1 f1P] [f2 f2P].
exists (f1 + f2).
destruct n. { lia. }
destruct m. { lia. }
lia.
Defined.
Definition fin_cast : forall {n m}, (n <= m) -> fin n -> fin m.
intros n m le [f fP].
exists f.
lia.
Defined.
Theorem fin_mul_lem : forall {n m},
(n - 1) * (m - 1) <= S (n * m - m - n).
Proof.
intros n m.
rewrite mul_sub_distr_l.
repeat rewrite mul_sub_distr_r.
rewrite mul_1_r, mul_1_l; simpl.
destruct n. { simpl; lia. }
destruct m. { rewrite <- mult_n_O; simpl; lia. }
destruct n. { simpl; rewrite add_0_r, sub_diag; lia. }
destruct m. { simpl; rewrite mul_1_r, sub_diag; lia. }
rewrite add_sub_distr. 2: { lia. }
2: { apply le_add_le_sub_r, add_le_mul; lia. }
rewrite add_1_r; apply le_n.
Qed.
Definition fin_mul : forall {n m} (f1 : fin n) (f2 : fin m),
fin (S (S (n * m - m - n))).
intros n m [f1 f1P] [f2 f2P].
exists (f1 * f2).
apply (le_lt_trans _ ((n - 1) * (m - 1))).
+ apply mul_le_mono.
- rewrite <- lt_succ_r.
replace (S (n - 1)) with n. { assumption. }
lia.
- rewrite <- lt_succ_r.
replace (S (m - 1)) with m. { assumption. }
lia.
+ apply (le_lt_trans _ (S (n * m - m - n))).
- apply fin_mul_lem.
- lia.
Defined.
Definition fin_max : forall n, fin (S n).
intro n; exists n; lia.
Defined.
Theorem proj1_fin_cast : forall {n m} (f : fin n) (eq : n <= m),
proj1_sig (fin_cast eq f) = proj1_sig f.
Proof. destruct f; reflexivity. Qed.
Theorem proj1_fin_add : forall {n m} (f : fin n) (g : fin m),
proj1_sig (fin_add f g) = proj1_sig f + proj1_sig g.
Proof. destruct f, g; reflexivity. Qed.
Theorem proj1_fin_mul : forall {n m} (f : fin n) (g : fin m),
proj1_sig (fin_mul f g) = proj1_sig f * proj1_sig g.
Proof. destruct f, g; reflexivity. Qed.
Theorem proj1_fin_max : forall {n},
proj1_sig (fin_max n) = n.
Proof. reflexivity. Qed.
Theorem fin_rew : forall {n m o} (eq : n = m) (H : o < n),
(rew eq in (exist (fun x => x < n) o H : fin n)) =
exist (fun x => x < m) o (rew eq in H).
Proof. intros n m o eq; destruct eq; reflexivity. Qed.
Definition mk_fin {m} : forall n, n < m -> fin m.
intros; exists n; assumption. Defined.
|
#' @param query Query term(s) for full text search.
#' @param rank CLASS, CULTIVAR, CULTIVAR_GROUP, DOMAIN, FAMILY, FORM, GENUS,
#' INFORMAL, INFRAGENERIC_NAME, INFRAORDER, INFRASPECIFIC_NAME,
#' INFRASUBSPECIFIC_NAME, KINGDOM, ORDER, PHYLUM, SECTION, SERIES, SPECIES,
#' STRAIN, SUBCLASS, SUBFAMILY, SUBFORM, SUBGENUS, SUBKINGDOM, SUBORDER,
#' SUBPHYLUM, SUBSECTION, SUBSERIES, SUBSPECIES, SUBTRIBE, SUBVARIETY,
#' SUPERCLASS, SUPERFAMILY, SUPERORDER, SUPERPHYLUM, SUPRAGENERIC_NAME,
#' TRIBE, UNRANKED, VARIETY
#' @param higherTaxonKey Filters by any of the higher Linnean rank keys. Note
#' this is within the respective checklist and not searching nub keys
#' across all checklists. This parameter accepts many inputs in a vector (
#' passed in the same request).
#' @param status Filters by the taxonomic status as one of:
#' \itemize{
#' \item ACCEPTED
#' \item DETERMINATION_SYNONYM Used for unknown child taxa referred to via
#' spec, ssp, ...
#' \item DOUBTFUL Treated as accepted, but doubtful whether this is correct.
#' \item HETEROTYPIC_SYNONYM More specific subclass of SYNONYM.
#' \item HOMOTYPIC_SYNONYM More specific subclass of SYNONYM.
#' \item INTERMEDIATE_RANK_SYNONYM Used in nub only.
#' \item MISAPPLIED More specific subclass of SYNONYM.
#' \item PROPARTE_SYNONYM More specific subclass of SYNONYM.
#' \item SYNONYM A general synonym, the exact type is unknown.
#' }
#' @param isExtinct (logical) Filters by extinction status (e.g.
#' \code{isExtinct=TRUE})
#' @param habitat (character) Filters by habitat. One of: marine, freshwater,
#' or terrestrial
#' @param nameType Filters by the name type as one of:
#' \itemize{
#' \item BLACKLISTED surely not a scientific name.
#' \item CANDIDATUS Candidatus is a component of the taxonomic name for a
#' bacterium that cannot be maintained in a Bacteriology Culture Collection.
#' \item CULTIVAR a cultivated plant name.
#' \item DOUBTFUL doubtful whether this is a scientific name at all.
#' \item HYBRID a hybrid formula (not a hybrid name).
#' \item INFORMAL a scientific name with some informal addition like "cf." or
#' indetermined like Abies spec.
#' \item SCINAME a scientific name which is not well formed.
#' \item VIRUS a virus name.
#' \item WELLFORMED a well formed scientific name according to present
#' nomenclatural rules.
#' }
#' @param datasetKey Filters by the dataset's key (a uuid)
#' @param origin (character) Filters by origin. One of:
#' \itemize{
#' \item SOURCE
#' \item DENORMED_CLASSIFICATION
#' \item VERBATIM_ACCEPTED
#' \item EX_AUTHOR_SYNONYM
#' \item AUTONYM
#' \item BASIONYM_PLACEHOLDER
#' \item MISSING_ACCEPTED
#' \item IMPLICIT_NAME
#' \item PROPARTE
#' \item VERBATIM_BASIONYM
#' }
#' @param nomenclaturalStatus Not yet implemented, but will eventually allow
#' for filtering by a nomenclatural status enum.
#' @param facet A vector/list of facet names used to retrieve the 100 most
#' frequent values for a field. Allowed facets are: datasetKey, higherTaxonKey,
#' rank, status, isExtinct, habitat, and nameType. Additionally threat and
#' nomenclaturalStatus are legal values but not yet implemented, so data will
#' not yet be returned for them.
#' @param facetMincount Used in combination with the facet parameter. Set
#' facetMincount={#} to exclude facets with a count less than {#}, e.g.
#' http://bit.ly/2osAUQB only shows the type values 'CHECKLIST' and 'OCCURRENCE'
#' because the other types have counts less than 10000
#' @param facetMultiselect (logical) Used in combination with the facet
#' parameter. Set \code{facetMultiselect=TRUE} to still return counts for
#' values that are not currently filtered, e.g. http://bit.ly/2JAymaC still
#' shows all type values even though type is being filtered
#' by \code{type=CHECKLIST}.
#' @param type Type of name. One of occurrence, checklist, or metadata.
#' @param hl (logical) Set \code{hl=TRUE} to highlight terms matching the query
#' when in fulltext search fields. The highlight will be an emphasis tag of
#' class \code{gbifH1} e.g. \code{query='plant', hl=TRUE}. Fulltext search
#' fields include: title, keyword, country, publishing country, publishing
#' organization title, hosting organization title, and description. One
#' additional full text field is searched which includes information from
#' metadata documents, but the text of this field is not returned in the
#' response.
#' @param issue Filters by issue. Issue has to be related to names. Type
#' \code{gbif_issues()} to get complete list of issues.
#' @param limit Number of records to return.
#' Hard maximum limit set by GBIF API: 99999.
#' @param start Record number to start at. Default: 0.
#' @param verbose (logical) If \code{TRUE}, all data is returned as a list for each
#' element. If \code{FALSE} (default) a subset of the data that is thought to be most
#' essential is organized into a data.frame.
#'
#' @param return Defunct. All components are returned; index to the
#' one(s) you want
#'
#' @return An object of class gbif, which is a S3 class list, with slots for
#' metadata (\code{meta}), the data itself (\code{data}), the taxonomic
#' hierarchy data (\code{hierarchies}), and vernacular names (\code{names}).
#' In addition, the object has attributes listing the user supplied arguments
#' and type of search, which is, differently from occurrence data, always
#' equals to 'single' even if multiple values for some parameters are given.
#' \code{meta} is a list of length four with offset, limit, endOfRecords and
#' count fields. \code{data} is a tibble (aka data.frame) containing all
#' information about the found taxa. \code{hierarchies} is a list of
#' data.frame's, one per GBIF key (taxon), containing its taxonomic
#' classification. Each data.frame contains two columns: \code{rankkey} and
#' \code{name}. \code{names} returns a list of data.frame's, one per GBIF key
#' (taxon), containing all vernacular names. Each data.frame contains two
#' columns: \code{vernacularName} and \code{language}.
#'
#' @return A list of length five:
#' \itemize{
#' \item \strong{metadata}
#' \item \strong{data}: either a data.frame (\code{verbose=FALSE}, default) or a list (\code{verbose=TRUE}).
#' \item \strong{facets}
#' \item \strong{hierarchies}
#' \item \strong{names}
#' }
#'
#' @description
#' This service uses fuzzy lookup so that you can put in partial names and
#' you should get back those things that match. See examples below.
#'
#' Faceting: If \code{facet=FALSE} or left to the default (NULL), no faceting
#' is done. And therefore, all parameters with facet in their name are
#' ignored (facetOnly, facetMincount, facetMultiselect).
#'
#' @section Repeat parameter inputs:
#' Some parameters can take many inputs, and treated as 'OR' (e.g., a or b or
#' c). The following take many inputs:
#' \itemize{
#' \item \strong{rank}
#' \item \strong{higherTaxonKey}
#' \item \strong{status}
#' \item \strong{habitat}
#' \item \strong{nameType}
#' \item \strong{datasetKey}
#' \item \strong{origin}
#' }
#'
#' see also \code{\link{many-values}}
|
/-
Copyright (c) 2015 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis
-/
import algebra.invertible
import data.int.cast
/-!
# Lemmas about power operations on monoids and groups
This file contains lemmas about `monoid.pow`, `group.pow`, `nsmul`, `zsmul`
which require additional imports besides those available in `algebra.group_power.basic`.
-/
universes u v w x y z u₁ u₂
variables {M : Type u} {N : Type v} {G : Type w} {H : Type x} {A : Type y} {B : Type z}
{R : Type u₁} {S : Type u₂}
/-!
### (Additive) monoid
-/
section monoid
variables [monoid M] [monoid N] [add_monoid A] [add_monoid B]
@[simp] theorem nsmul_one [has_one A] : ∀ n : ℕ, n • (1 : A) = n :=
begin
refine eq_nat_cast' (⟨_, _, _⟩ : ℕ →+ A) _,
{ simp [zero_nsmul] },
{ simp [add_nsmul] },
{ simp }
end
instance invertible_pow (m : M) [invertible m] (n : ℕ) : invertible (m ^ n) :=
{ inv_of := ⅟ m ^ n,
inv_of_mul_self := by rw [← (commute_inv_of m).symm.mul_pow, inv_of_mul_self, one_pow],
mul_inv_of_self := by rw [← (commute_inv_of m).mul_pow, mul_inv_of_self, one_pow] }
lemma inv_of_pow (m : M) [invertible m] (n : ℕ) [invertible (m ^ n)] :
⅟(m ^ n) = ⅟m ^ n :=
@invertible_unique M _ (m ^ n) (m ^ n) rfl ‹_› (invertible_pow m n)
lemma is_unit.pow {m : M} (n : ℕ) : is_unit m → is_unit (m ^ n) :=
λ ⟨u, hu⟩, ⟨u ^ n, by simp *⟩
@[simp] lemma is_unit_pow_succ_iff {m : M} {n : ℕ} :
is_unit (m ^ (n + 1)) ↔ is_unit m :=
begin
refine ⟨_, λ h, h.pow _⟩,
rw [pow_succ, ((commute.refl _).pow_right _).is_unit_mul_iff],
exact and.left
end
lemma is_unit_pos_pow_iff {m : M} :
∀ {n : ℕ} (h : 0 < n), is_unit (m ^ n) ↔ is_unit m
| (n + 1) _ := is_unit_pow_succ_iff
/-- If `x ^ n.succ = 1` then `x` has an inverse, `x^n`. -/
def invertible_of_pow_succ_eq_one (x : M) (n : ℕ) (hx : x ^ n.succ = 1) :
invertible x :=
⟨x ^ n, (pow_succ' x n).symm.trans hx, (pow_succ x n).symm.trans hx⟩
/-- If `x ^ n = 1` then `x` has an inverse, `x^(n - 1)`. -/
def invertible_of_pow_eq_one (x : M) (n : ℕ) (hx : x ^ n = 1) (hn : 0 < n) :
invertible x :=
begin
apply invertible_of_pow_succ_eq_one x (n - 1),
convert hx,
exact tsub_add_cancel_of_le (nat.succ_le_of_lt hn),
end
lemma is_unit_of_pow_eq_one (x : M) (n : ℕ) (hx : x ^ n = 1) (hn : 0 < n) :
is_unit x :=
begin
haveI := invertible_of_pow_eq_one x n hx hn,
exact is_unit_of_invertible x
end
lemma smul_pow [mul_action M N] [is_scalar_tower M N N] [smul_comm_class M N N]
(k : M) (x : N) (p : ℕ) :
(k • x) ^ p = k ^ p • x ^ p :=
begin
induction p with p IH,
{ simp },
{ rw [pow_succ', IH, smul_mul_smul, ←pow_succ', ←pow_succ'] }
end
@[simp] lemma smul_pow' [mul_distrib_mul_action M N] (x : M) (m : N) (n : ℕ) :
x • m ^ n = (x • m) ^ n :=
begin
induction n with n ih,
{ rw [pow_zero, pow_zero], exact smul_one x },
{ rw [pow_succ, pow_succ], exact (smul_mul' x m (m ^ n)).trans (congr_arg _ ih) }
end
end monoid
section group
variables [group G] [group H] [add_group A] [add_group B]
open int
local attribute [ematch] le_of_lt
open nat
theorem zsmul_one [has_one A] (n : ℤ) : n • (1 : A) = n :=
by cases n; simp
@[to_additive add_one_zsmul]
lemma zpow_add_one (a : G) : ∀ n : ℤ, a ^ (n + 1) = a ^ n * a
| (of_nat n) := by simp [← int.coe_nat_succ, pow_succ']
| -[1+0] := by simp [int.neg_succ_of_nat_eq]
| -[1+(n+1)] := by rw [int.neg_succ_of_nat_eq, zpow_neg, neg_add, neg_add_cancel_right, zpow_neg,
← int.coe_nat_succ, zpow_coe_nat, zpow_coe_nat, pow_succ _ (n + 1), mul_inv_rev,
inv_mul_cancel_right]
@[to_additive zsmul_sub_one]
lemma zpow_sub_one (a : G) (n : ℤ) : a ^ (n - 1) = a ^ n * a⁻¹ :=
calc a ^ (n - 1) = a ^ (n - 1) * a * a⁻¹ : (mul_inv_cancel_right _ _).symm
... = a^n * a⁻¹ : by rw [← zpow_add_one, sub_add_cancel]
@[to_additive add_zsmul]
lemma zpow_add (a : G) (m n : ℤ) : a ^ (m + n) = a ^ m * a ^ n :=
begin
induction n using int.induction_on with n ihn n ihn,
case hz : { simp },
{ simp only [← add_assoc, zpow_add_one, ihn, mul_assoc] },
{ rw [zpow_sub_one, ← mul_assoc, ← ihn, ← zpow_sub_one, add_sub_assoc] }
end
@[to_additive add_zsmul_self]
lemma mul_self_zpow (b : G) (m : ℤ) : b*b^m = b^(m+1) :=
by { conv_lhs {congr, rw ← zpow_one b }, rw [← zpow_add, add_comm] }
@[to_additive add_self_zsmul]
lemma mul_zpow_self (b : G) (m : ℤ) : b^m*b = b^(m+1) :=
by { conv_lhs {congr, skip, rw ← zpow_one b }, rw [← zpow_add, add_comm] }
@[to_additive sub_zsmul]
lemma zpow_sub (a : G) (m n : ℤ) : a ^ (m - n) = a ^ m * (a ^ n)⁻¹ :=
by rw [sub_eq_add_neg, zpow_add, zpow_neg]
@[to_additive one_add_zsmul]
theorem zpow_one_add (a : G) (i : ℤ) : a ^ (1 + i) = a * a ^ i :=
by rw [zpow_add, zpow_one]
@[to_additive]
theorem zpow_mul_comm (a : G) (i j : ℤ) : a ^ i * a ^ j = a ^ j * a ^ i :=
by rw [← zpow_add, ← zpow_add, add_comm]
-- note that `mul_zsmul` and `zpow_mul` have the primes swapped since their argument order
-- and therefore the more "natural" choice of lemma is reversed.
@[to_additive mul_zsmul']
theorem zpow_mul (a : G) (m n : ℤ) : a ^ (m * n) = (a ^ m) ^ n :=
int.induction_on n (by simp) (λ n ihn, by simp [mul_add, zpow_add, ihn])
(λ n ihn, by simp only [mul_sub, zpow_sub, ihn, mul_one, zpow_one])
@[to_additive mul_zsmul]
theorem zpow_mul' (a : G) (m n : ℤ) : a ^ (m * n) = (a ^ n) ^ m :=
by rw [mul_comm, zpow_mul]
@[to_additive bit0_zsmul]
theorem zpow_bit0 (a : G) (n : ℤ) : a ^ bit0 n = a ^ n * a ^ n := zpow_add _ _ _
@[to_additive bit1_zsmul]
theorem zpow_bit1 (a : G) (n : ℤ) : a ^ bit1 n = a ^ n * a ^ n * a :=
by rw [bit1, zpow_add, zpow_bit0, zpow_one]
end group
section ordered_add_comm_group
variables [ordered_add_comm_group A]
/-! Lemmas about `zsmul` under ordering, placed here (rather than in `algebra.group_power.order`
with their friends) because they require facts from `data.int.basic`-/
open int
lemma zsmul_pos {a : A} (ha : 0 < a) {k : ℤ} (hk : (0:ℤ) < k) : 0 < k • a :=
begin
lift k to ℕ using int.le_of_lt hk,
rw coe_nat_zsmul,
apply nsmul_pos ha,
exact (coe_nat_pos.mp hk).ne',
end
theorem zsmul_strict_mono_left {a : A} (ha : 0 < a) : strict_mono (λ n : ℤ, n • a) :=
λ n m h,
calc n • a = n • a + 0 : (add_zero _).symm
... < n • a + (m - n) • a : add_lt_add_left (zsmul_pos ha (sub_pos.mpr h)) _
... = m • a : by { rw [← add_zsmul], simp }
theorem zsmul_mono_left {a : A} (ha : 0 ≤ a) : monotone (λ n : ℤ, n • a) :=
λ n m h,
calc n • a = n • a + 0 : (add_zero _).symm
... ≤ n • a + (m - n) • a : add_le_add_left (zsmul_nonneg ha (sub_nonneg.mpr h)) _
... = m • a : by { rw [← add_zsmul], simp }
theorem zsmul_le_zsmul {a : A} {n m : ℤ} (ha : 0 ≤ a) (h : n ≤ m) : n • a ≤ m • a :=
zsmul_mono_left ha h
theorem zsmul_lt_zsmul {a : A} {n m : ℤ} (ha : 0 < a) (h : n < m) : n • a < m • a :=
zsmul_strict_mono_left ha h
theorem zsmul_le_zsmul_iff {a : A} {n m : ℤ} (ha : 0 < a) : n • a ≤ m • a ↔ n ≤ m :=
(zsmul_strict_mono_left ha).le_iff_le
theorem zsmul_lt_zsmul_iff {a : A} {n m : ℤ} (ha : 0 < a) : n • a < m • a ↔ n < m :=
(zsmul_strict_mono_left ha).lt_iff_lt
variables (A)
lemma zsmul_strict_mono_right {n : ℤ} (hn : 0 < n) :
strict_mono ((•) n : A → A) :=
λ a b hab, begin
rw ← sub_pos at hab,
rw [← sub_pos, ← zsmul_sub],
exact zsmul_pos hab hn,
end
lemma zsmul_mono_right {n : ℤ} (hn : 0 ≤ n) :
monotone ((•) n : A → A) :=
λ a b hab, begin
rw ← sub_nonneg at hab,
rw [← sub_nonneg, ← zsmul_sub],
exact zsmul_nonneg hab hn,
end
variables {A}
theorem zsmul_le_zsmul' {n : ℤ} (hn : 0 ≤ n) {a₁ a₂ : A} (h : a₁ ≤ a₂) : n • a₁ ≤ n • a₂ :=
zsmul_mono_right A hn h
theorem zsmul_lt_zsmul' {n : ℤ} (hn : 0 < n) {a₁ a₂ : A} (h : a₁ < a₂) : n • a₁ < n • a₂ :=
zsmul_strict_mono_right A hn h
lemma abs_nsmul {α : Type*} [linear_ordered_add_comm_group α] (n : ℕ) (a : α) :
|n • a| = n • |a| :=
begin
cases le_total a 0 with hneg hpos,
{ rw [abs_of_nonpos hneg, ← abs_neg, ← neg_nsmul, abs_of_nonneg],
exact nsmul_nonneg (neg_nonneg.mpr hneg) n },
{ rw [abs_of_nonneg hpos, abs_of_nonneg],
exact nsmul_nonneg hpos n }
end
lemma abs_zsmul {α : Type*} [linear_ordered_add_comm_group α] (n : ℤ) (a : α) :
|n • a| = |n| • |a| :=
begin
by_cases n0 : 0 ≤ n,
{ lift n to ℕ using n0,
simp only [abs_nsmul, coe_nat_abs, coe_nat_zsmul] },
{ lift (- n) to ℕ using int.le_of_lt (neg_pos.mpr (not_le.mp n0)) with m h,
rw [← abs_neg (n • a), ← neg_zsmul, ← abs_neg n, ← h, coe_nat_zsmul, coe_nat_abs,
coe_nat_zsmul],
exact abs_nsmul m _ },
end
lemma abs_add_eq_add_abs_le {α : Type*} [linear_ordered_add_comm_group α] {a b : α} (hle : a ≤ b) :
|a + b| = |a| + |b| ↔ (0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0) :=
begin
by_cases a0 : 0 ≤ a; by_cases b0 : 0 ≤ b,
{ simp [a0, b0, abs_of_nonneg, add_nonneg a0 b0] },
{ exact (lt_irrefl (0 : α) (a0.trans_lt (hle.trans_lt (not_le.mp b0)))).elim },
any_goals { simp [(not_le.mp a0).le, (not_le.mp b0).le, abs_of_nonpos, add_nonpos, add_comm] },
obtain F := (not_le.mp a0),
have : (|a + b| = -a + b ↔ b ≤ 0) ↔ (|a + b| =
|a| + |b| ↔ 0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0),
{ simp [a0, b0, abs_of_neg, abs_of_nonneg, F, F.le] },
refine this.mp ⟨λ h, _, λ h, by simp only [le_antisymm h b0, abs_of_neg F, add_zero]⟩,
by_cases ba : a + b ≤ 0,
{ refine le_of_eq (eq_zero_of_neg_eq _),
rwa [abs_of_nonpos ba, neg_add_rev, add_comm, add_right_inj] at h },
{ refine (lt_irrefl (0 : α) _).elim,
rw [abs_of_pos (not_le.mp ba), add_left_inj] at h,
rwa eq_zero_of_neg_eq h.symm at F }
end
lemma abs_add_eq_add_abs_iff {α : Type*} [linear_ordered_add_comm_group α] (a b : α) :
|a + b| = |a| + |b| ↔ (0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0) :=
begin
by_cases ab : a ≤ b,
{ exact abs_add_eq_add_abs_le ab },
{ rw [add_comm a, add_comm (abs _), abs_add_eq_add_abs_le ((not_le.mp ab).le), and.comm,
@and.comm (b ≤ 0 ) _] }
end
end ordered_add_comm_group
section linear_ordered_add_comm_group
variable [linear_ordered_add_comm_group A]
theorem zsmul_le_zsmul_iff' {n : ℤ} (hn : 0 < n) {a₁ a₂ : A} : n • a₁ ≤ n • a₂ ↔ a₁ ≤ a₂ :=
(zsmul_strict_mono_right A hn).le_iff_le
theorem zsmul_lt_zsmul_iff' {n : ℤ} (hn : 0 < n) {a₁ a₂ : A} : n • a₁ < n • a₂ ↔ a₁ < a₂ :=
(zsmul_strict_mono_right A hn).lt_iff_lt
theorem nsmul_le_nsmul_iff {a : A} {n m : ℕ} (ha : 0 < a) : n • a ≤ m • a ↔ n ≤ m :=
begin
refine ⟨λ h, _, nsmul_le_nsmul $ le_of_lt ha⟩,
by_contra H,
exact lt_irrefl _ (lt_of_lt_of_le (nsmul_lt_nsmul ha (not_le.mp H)) h)
end
theorem nsmul_lt_nsmul_iff {a : A} {n m : ℕ} (ha : 0 < a) : n • a < m • a ↔ n < m :=
begin
refine ⟨λ h, _, nsmul_lt_nsmul ha⟩,
by_contra H,
exact lt_irrefl _ (lt_of_le_of_lt (nsmul_le_nsmul (le_of_lt ha) $ not_lt.mp H) h)
end
/-- See also `smul_right_injective`. TODO: provide a `no_zero_smul_divisors` instance. We can't
do that here because importing that definition would create import cycles. -/
lemma zsmul_right_injective {m : ℤ} (hm : m ≠ 0) : function.injective ((•) m : A → A) :=
begin
cases hm.symm.lt_or_lt,
{ exact (zsmul_strict_mono_right A h).injective, },
{ intros a b hab,
refine (zsmul_strict_mono_right A (neg_pos.mpr h)).injective _,
rw [neg_zsmul, neg_zsmul, hab], },
end
lemma zsmul_right_inj {a b : A} {m : ℤ} (hm : m ≠ 0) : m • a = m • b ↔ a = b :=
(zsmul_right_injective hm).eq_iff
/-- Alias of `zsmul_right_inj`, for ease of discovery alongside `zsmul_le_zsmul_iff'` and
`zsmul_lt_zsmul_iff'`. -/
lemma zsmul_eq_zsmul_iff' {a b : A} {m : ℤ} (hm : m ≠ 0) : m • a = m • b ↔ a = b :=
zsmul_right_inj hm
end linear_ordered_add_comm_group
@[simp] lemma with_bot.coe_nsmul [add_monoid A] (a : A) (n : ℕ) :
((n • a : A) : with_bot A) = n • a :=
add_monoid_hom.map_nsmul ⟨(coe : A → with_bot A), with_bot.coe_zero, with_bot.coe_add⟩ a n
theorem nsmul_eq_mul' [non_assoc_semiring R] (a : R) (n : ℕ) : n • a = a * n :=
by induction n with n ih; [rw [zero_nsmul, nat.cast_zero, mul_zero],
rw [succ_nsmul', ih, nat.cast_succ, mul_add, mul_one]]
@[simp] theorem nsmul_eq_mul [non_assoc_semiring R] (n : ℕ) (a : R) : n • a = n * a :=
by rw [nsmul_eq_mul', (n.cast_commute a).eq]
/-- Note that `add_comm_monoid.nat_smul_comm_class` requires stronger assumptions on `R`. -/
instance non_unital_non_assoc_semiring.nat_smul_comm_class [non_unital_non_assoc_semiring R] :
smul_comm_class ℕ R R :=
⟨λ n x y, match n with
| 0 := by simp_rw [zero_nsmul, smul_eq_mul, mul_zero]
| (n + 1) := by simp_rw [succ_nsmul, smul_eq_mul, mul_add, ←smul_eq_mul, _match n]
end⟩
/-- Note that `add_comm_monoid.nat_is_scalar_tower` requires stronger assumptions on `R`. -/
instance non_unital_non_assoc_semiring.nat_is_scalar_tower [non_unital_non_assoc_semiring R] :
is_scalar_tower ℕ R R :=
⟨λ n x y, match n with
| 0 := by simp_rw [zero_nsmul, smul_eq_mul, zero_mul]
| (n + 1) := by simp_rw [succ_nsmul, ←_match n, smul_eq_mul, add_mul]
end⟩
@[simp, norm_cast] theorem nat.cast_pow [semiring R] (n m : ℕ) : (↑(n ^ m) : R) = ↑n ^ m :=
begin
induction m with m ih,
{ rw [pow_zero, pow_zero], exact nat.cast_one },
{ rw [pow_succ', pow_succ', nat.cast_mul, ih] }
end
@[simp, norm_cast] theorem int.coe_nat_pow (n m : ℕ) : ((n ^ m : ℕ) : ℤ) = n ^ m :=
by induction m with m ih; [exact int.coe_nat_one, rw [pow_succ', pow_succ', int.coe_nat_mul, ih]]
theorem int.nat_abs_pow (n : ℤ) (k : ℕ) : int.nat_abs (n ^ k) = (int.nat_abs n) ^ k :=
by induction k with k ih; [refl, rw [pow_succ', int.nat_abs_mul, pow_succ', ih]]
-- The next four lemmas allow us to replace multiplication by a numeral with a `zsmul` expression.
-- They are used by the `noncomm_ring` tactic, to normalise expressions before passing to `abel`.
lemma bit0_mul [non_unital_non_assoc_ring R] {n r : R} : bit0 n * r = (2 : ℤ) • (n * r) :=
by { dsimp [bit0], rw [add_mul, add_zsmul, one_zsmul], }
lemma mul_bit0 [non_unital_non_assoc_ring R] {n r : R} : r * bit0 n = (2 : ℤ) • (r * n) :=
by { dsimp [bit0], rw [mul_add, add_zsmul, one_zsmul], }
lemma bit1_mul [non_assoc_ring R] {n r : R} : bit1 n * r = (2 : ℤ) • (n * r) + r :=
by { dsimp [bit1], rw [add_mul, bit0_mul, one_mul], }
lemma mul_bit1 [non_assoc_ring R] {n r : R} : r * bit1 n = (2 : ℤ) • (r * n) + r :=
by { dsimp [bit1], rw [mul_add, mul_bit0, mul_one], }
@[simp] theorem zsmul_eq_mul [non_assoc_ring R] (a : R) : ∀ (n : ℤ), n • a = n * a
| (n : ℕ) := by { rw [coe_nat_zsmul, nsmul_eq_mul], refl }
| -[1+ n] := by simp [nat.cast_succ, neg_add_rev, int.cast_neg_succ_of_nat, add_mul]
theorem zsmul_eq_mul' [ring R] (a : R) (n : ℤ) : n • a = a * n :=
by rw [zsmul_eq_mul, (n.cast_commute a).eq]
/-- Note that `add_comm_group.int_smul_comm_class` requires stronger assumptions on `R`. -/
instance non_unital_non_assoc_ring.int_smul_comm_class [non_unital_non_assoc_ring R] :
smul_comm_class ℤ R R :=
⟨λ n x y, match n with
| (n : ℕ) := by simp_rw [coe_nat_zsmul, smul_comm]
| -[1+n] := by simp_rw [zsmul_neg_succ_of_nat, smul_eq_mul, mul_neg, mul_smul_comm]
end⟩
/-- Note that `add_comm_group.int_is_scalar_tower` requires stronger assumptions on `R`. -/
instance non_unital_non_assoc_ring.int_is_scalar_tower [non_unital_non_assoc_ring R] :
is_scalar_tower ℤ R R :=
⟨λ n x y, match n with
| (n : ℕ) := by simp_rw [coe_nat_zsmul, smul_assoc]
| -[1+n] := by simp_rw [zsmul_neg_succ_of_nat, smul_eq_mul, neg_mul, smul_mul_assoc]
end⟩
lemma zsmul_int_int (a b : ℤ) : a • b = a * b := by simp
lemma zsmul_int_one (n : ℤ) : n • 1 = n := by simp
@[simp, norm_cast] theorem int.cast_pow [ring R] (n : ℤ) (m : ℕ) : (↑(n ^ m) : R) = ↑n ^ m :=
begin
induction m with m ih,
{ rw [pow_zero, pow_zero, int.cast_one] },
{ rw [pow_succ, pow_succ, int.cast_mul, ih] }
end
lemma neg_one_pow_eq_pow_mod_two [ring R] {n : ℕ} : (-1 : R) ^ n = (-1) ^ (n % 2) :=
by rw [← nat.mod_add_div n 2, pow_add, pow_mul]; simp [sq]
section ordered_semiring
variables [ordered_semiring R] {a : R}
/-- Bernoulli's inequality. This version works for semirings but requires
additional hypotheses `0 ≤ a * a` and `0 ≤ (1 + a) * (1 + a)`. -/
theorem one_add_mul_le_pow' (Hsq : 0 ≤ a * a) (Hsq' : 0 ≤ (1 + a) * (1 + a))
(H : 0 ≤ 2 + a) :
∀ (n : ℕ), 1 + (n : R) * a ≤ (1 + a) ^ n
| 0 := by simp
| 1 := by simp
| (n+2) :=
have 0 ≤ (n : R) * (a * a * (2 + a)) + a * a,
from add_nonneg (mul_nonneg n.cast_nonneg (mul_nonneg Hsq H)) Hsq,
calc 1 + (↑(n + 2) : R) * a ≤ 1 + ↑(n + 2) * a + (n * (a * a * (2 + a)) + a * a) :
(le_add_iff_nonneg_right _).2 this
... = (1 + a) * (1 + a) * (1 + n * a) :
by { simp [add_mul, mul_add, bit0, mul_assoc, (n.cast_commute (_ : R)).left_comm],
ac_refl }
... ≤ (1 + a) * (1 + a) * (1 + a)^n :
mul_le_mul_of_nonneg_left (one_add_mul_le_pow' n) Hsq'
... = (1 + a)^(n + 2) : by simp only [pow_succ, mul_assoc]
private lemma pow_le_pow_of_le_one_aux (h : 0 ≤ a) (ha : a ≤ 1) (i : ℕ) :
∀ k : ℕ, a ^ (i + k) ≤ a ^ i
| 0 := by simp
| (k+1) := by { rw [←add_assoc, ←one_mul (a^i), pow_succ],
exact mul_le_mul ha (pow_le_pow_of_le_one_aux _) (pow_nonneg h _) zero_le_one }
lemma pow_le_pow_of_le_one (h : 0 ≤ a) (ha : a ≤ 1) {i j : ℕ} (hij : i ≤ j) :
a ^ j ≤ a ^ i :=
let ⟨k, hk⟩ := nat.exists_eq_add_of_le hij in
by rw hk; exact pow_le_pow_of_le_one_aux h ha _ _
lemma pow_le_of_le_one (h₀ : 0 ≤ a) (h₁ : a ≤ 1) {n : ℕ} (hn : n ≠ 0) : a ^ n ≤ a :=
(pow_one a).subst (pow_le_pow_of_le_one h₀ h₁ (nat.pos_of_ne_zero hn))
lemma sq_le (h₀ : 0 ≤ a) (h₁ : a ≤ 1) : a ^ 2 ≤ a := pow_le_of_le_one h₀ h₁ two_ne_zero
end ordered_semiring
section linear_ordered_semiring
variables [linear_ordered_semiring R]
lemma sign_cases_of_C_mul_pow_nonneg {C r : R} (h : ∀ n : ℕ, 0 ≤ C * r ^ n) :
C = 0 ∨ (0 < C ∧ 0 ≤ r) :=
begin
have : 0 ≤ C, by simpa only [pow_zero, mul_one] using h 0,
refine this.eq_or_lt.elim (λ h, or.inl h.symm) (λ hC, or.inr ⟨hC, _⟩),
refine nonneg_of_mul_nonneg_left _ hC,
simpa only [pow_one] using h 1
end
end linear_ordered_semiring
section linear_ordered_ring
variables [linear_ordered_ring R] {a : R} {n : ℕ}
@[simp] lemma abs_pow (a : R) (n : ℕ) : |a ^ n| = |a| ^ n :=
(pow_abs a n).symm
@[simp] theorem pow_bit1_neg_iff : a ^ bit1 n < 0 ↔ a < 0 :=
⟨λ h, not_le.1 $ λ h', not_le.2 h $ pow_nonneg h' _, λ ha, pow_bit1_neg ha n⟩
@[simp] theorem pow_bit1_nonneg_iff : 0 ≤ a ^ bit1 n ↔ 0 ≤ a :=
le_iff_le_iff_lt_iff_lt.2 pow_bit1_neg_iff
@[simp] theorem pow_bit1_nonpos_iff : a ^ bit1 n ≤ 0 ↔ a ≤ 0 :=
by simp only [le_iff_lt_or_eq, pow_bit1_neg_iff, pow_eq_zero_iff (bit1_pos (zero_le n))]
@[simp] theorem pow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=
lt_iff_lt_of_le_iff_le pow_bit1_nonpos_iff
lemma strict_mono_pow_bit1 (n : ℕ) : strict_mono (λ a : R, a ^ bit1 n) :=
begin
intros a b hab,
cases le_total a 0 with ha ha,
{ cases le_or_lt b 0 with hb hb,
{ rw [← neg_lt_neg_iff, ← neg_pow_bit1, ← neg_pow_bit1],
exact pow_lt_pow_of_lt_left (neg_lt_neg hab) (neg_nonneg.2 hb) (bit1_pos (zero_le n)) },
{ exact (pow_bit1_nonpos_iff.2 ha).trans_lt (pow_bit1_pos_iff.2 hb) } },
{ exact pow_lt_pow_of_lt_left hab ha (bit1_pos (zero_le n)) }
end
/-- Bernoulli's inequality for `n : ℕ`, `-2 ≤ a`. -/
theorem one_add_mul_le_pow (H : -2 ≤ a) (n : ℕ) : 1 + (n : R) * a ≤ (1 + a) ^ n :=
one_add_mul_le_pow' (mul_self_nonneg _) (mul_self_nonneg _) (neg_le_iff_add_nonneg'.1 H) _
/-- Bernoulli's inequality reformulated to estimate `a^n`. -/
theorem one_add_mul_sub_le_pow (H : -1 ≤ a) (n : ℕ) : 1 + (n : R) * (a - 1) ≤ a ^ n :=
have -2 ≤ a - 1, by rwa [bit0, neg_add, ← sub_eq_add_neg, sub_le_sub_iff_right],
by simpa only [add_sub_cancel'_right] using one_add_mul_le_pow this n
end linear_ordered_ring
/-- Bernoulli's inequality reformulated to estimate `(n : K)`. -/
theorem nat.cast_le_pow_sub_div_sub {K : Type*} [linear_ordered_field K] {a : K} (H : 1 < a)
(n : ℕ) :
(n : K) ≤ (a ^ n - 1) / (a - 1) :=
(le_div_iff (sub_pos.2 H)).2 $ le_sub_left_of_add_le $
one_add_mul_sub_le_pow ((neg_le_self $ @zero_le_one K _).trans H.le) _
/-- For any `a > 1` and a natural `n` we have `n ≤ a ^ n / (a - 1)`. See also
`nat.cast_le_pow_sub_div_sub` for a stronger inequality with `a ^ n - 1` in the numerator. -/
theorem nat.cast_le_pow_div_sub {K : Type*} [linear_ordered_field K] {a : K} (H : 1 < a) (n : ℕ) :
(n : K) ≤ a ^ n / (a - 1) :=
(n.cast_le_pow_sub_div_sub H).trans $ div_le_div_of_le (sub_nonneg.2 H.le)
(sub_le_self _ zero_le_one)
namespace int
lemma units_sq (u : ℤˣ) : u ^ 2 = 1 :=
(sq u).symm ▸ units_mul_self u
alias int.units_sq ← int.units_pow_two
lemma units_pow_eq_pow_mod_two (u : ℤˣ) (n : ℕ) : u ^ n = u ^ (n % 2) :=
by conv {to_lhs, rw ← nat.mod_add_div n 2}; rw [pow_add, pow_mul, units_sq, one_pow, mul_one]
@[simp] lemma nat_abs_sq (x : ℤ) : (x.nat_abs ^ 2 : ℤ) = x ^ 2 :=
by rw [sq, int.nat_abs_mul_self', sq]
alias int.nat_abs_sq ← int.nat_abs_pow_two
lemma abs_le_self_sq (a : ℤ) : (int.nat_abs a : ℤ) ≤ a ^ 2 :=
by { rw [← int.nat_abs_sq a, sq], norm_cast, apply nat.le_mul_self }
alias int.abs_le_self_sq ← int.abs_le_self_pow_two
lemma le_self_sq (b : ℤ) : b ≤ b ^ 2 := le_trans (le_nat_abs) (abs_le_self_sq _)
alias int.le_self_sq ← int.le_self_pow_two
lemma pow_right_injective {x : ℤ} (h : 1 < x.nat_abs) : function.injective ((^) x : ℕ → ℤ) :=
begin
suffices : function.injective (nat_abs ∘ ((^) x : ℕ → ℤ)),
{ exact function.injective.of_comp this },
convert nat.pow_right_injective h,
ext n,
rw [function.comp_app, nat_abs_pow]
end
end int
variables (M G A)
/-- Monoid homomorphisms from `multiplicative ℕ` are defined by the image
of `multiplicative.of_add 1`. -/
def powers_hom [monoid M] : M ≃ (multiplicative ℕ →* M) :=
{ to_fun := λ x, ⟨λ n, x ^ n.to_add, by { convert pow_zero x, exact to_add_one },
λ m n, pow_add x m n⟩,
inv_fun := λ f, f (multiplicative.of_add 1),
left_inv := pow_one,
right_inv := λ f, monoid_hom.ext $ λ n, by { simp [← f.map_pow, ← of_add_nsmul] } }
/-- Monoid homomorphisms from `multiplicative ℤ` are defined by the image
of `multiplicative.of_add 1`. -/
def zpowers_hom [group G] : G ≃ (multiplicative ℤ →* G) :=
{ to_fun := λ x, ⟨λ n, x ^ n.to_add, zpow_zero x, λ m n, zpow_add x m n⟩,
inv_fun := λ f, f (multiplicative.of_add 1),
left_inv := zpow_one,
right_inv := λ f, monoid_hom.ext $ λ n, by { simp [← f.map_zpow, ← of_add_zsmul ] } }
/-- Additive homomorphisms from `ℕ` are defined by the image of `1`. -/
def multiples_hom [add_monoid A] : A ≃ (ℕ →+ A) :=
{ to_fun := λ x, ⟨λ n, n • x, zero_nsmul x, λ m n, add_nsmul _ _ _⟩,
inv_fun := λ f, f 1,
left_inv := one_nsmul,
right_inv := λ f, add_monoid_hom.ext_nat $ one_nsmul (f 1) }
/-- Additive homomorphisms from `ℤ` are defined by the image of `1`. -/
def zmultiples_hom [add_group A] : A ≃ (ℤ →+ A) :=
{ to_fun := λ x, ⟨λ n, n • x, zero_zsmul x, λ m n, add_zsmul _ _ _⟩,
inv_fun := λ f, f 1,
left_inv := one_zsmul,
right_inv := λ f, add_monoid_hom.ext_int $ one_zsmul (f 1) }
attribute [to_additive multiples_hom] powers_hom
attribute [to_additive zmultiples_hom] zpowers_hom
variables {M G A}
@[simp] lemma powers_hom_apply [monoid M] (x : M) (n : multiplicative ℕ) :
powers_hom M x n = x ^ n.to_add := rfl
@[simp] lemma powers_hom_symm_apply [monoid M] (f : multiplicative ℕ →* M) :
(powers_hom M).symm f = f (multiplicative.of_add 1) := rfl
@[simp] lemma zpowers_hom_apply [group G] (x : G) (n : multiplicative ℤ) :
zpowers_hom G x n = x ^ n.to_add := rfl
@[simp] lemma zpowers_hom_symm_apply [group G] (f : multiplicative ℤ →* G) :
(zpowers_hom G).symm f = f (multiplicative.of_add 1) := rfl
@[simp] lemma multiples_hom_apply [add_monoid A] (x : A) (n : ℕ) :
multiples_hom A x n = n • x := rfl
attribute [to_additive multiples_hom_apply] powers_hom_apply
@[simp] lemma multiples_hom_symm_apply [add_monoid A] (f : ℕ →+ A) :
(multiples_hom A).symm f = f 1 := rfl
attribute [to_additive multiples_hom_symm_apply] powers_hom_symm_apply
@[simp] lemma zmultiples_hom_apply [add_group A] (x : A) (n : ℤ) :
zmultiples_hom A x n = n • x := rfl
attribute [to_additive zmultiples_hom_apply] zpowers_hom_apply
@[simp] lemma zmultiples_hom_symm_apply [add_group A] (f : ℤ →+ A) :
(zmultiples_hom A).symm f = f 1 := rfl
attribute [to_additive zmultiples_hom_symm_apply] zpowers_hom_symm_apply
-- TODO use to_additive in the rest of this file
lemma monoid_hom.apply_mnat [monoid M] (f : multiplicative ℕ →* M) (n : multiplicative ℕ) :
f n = (f (multiplicative.of_add 1)) ^ n.to_add :=
by rw [← powers_hom_symm_apply, ← powers_hom_apply, equiv.apply_symm_apply]
@[ext] lemma monoid_hom.ext_mnat [monoid M] ⦃f g : multiplicative ℕ →* M⦄
(h : f (multiplicative.of_add 1) = g (multiplicative.of_add 1)) : f = g :=
monoid_hom.ext $ λ n, by rw [f.apply_mnat, g.apply_mnat, h]
lemma monoid_hom.apply_mint [group M] (f : multiplicative ℤ →* M) (n : multiplicative ℤ) :
f n = (f (multiplicative.of_add 1)) ^ n.to_add :=
by rw [← zpowers_hom_symm_apply, ← zpowers_hom_apply, equiv.apply_symm_apply]
/-! `monoid_hom.ext_mint` is defined in `data.int.cast` -/
lemma add_monoid_hom.apply_nat [add_monoid M] (f : ℕ →+ M) (n : ℕ) :
f n = n • (f 1) :=
by rw [← multiples_hom_symm_apply, ← multiples_hom_apply, equiv.apply_symm_apply]
/-! `add_monoid_hom.ext_nat` is defined in `data.nat.cast` -/
lemma add_monoid_hom.apply_int [add_group M] (f : ℤ →+ M) (n : ℤ) :
f n = n • (f 1) :=
by rw [← zmultiples_hom_symm_apply, ← zmultiples_hom_apply, equiv.apply_symm_apply]
/-! `add_monoid_hom.ext_int` is defined in `data.int.cast` -/
variables (M G A)
/-- If `M` is commutative, `powers_hom` is a multiplicative equivalence. -/
def powers_mul_hom [comm_monoid M] : M ≃* (multiplicative ℕ →* M) :=
{ map_mul' := λ a b, monoid_hom.ext $ by simp [mul_pow],
..powers_hom M}
/-- If `M` is commutative, `zpowers_hom` is a multiplicative equivalence. -/
def zpowers_mul_hom [comm_group G] : G ≃* (multiplicative ℤ →* G) :=
{ map_mul' := λ a b, monoid_hom.ext $ by simp [mul_zpow],
..zpowers_hom G}
/-- If `M` is commutative, `multiples_hom` is an additive equivalence. -/
def multiples_add_hom [add_comm_monoid A] : A ≃+ (ℕ →+ A) :=
{ map_add' := λ a b, add_monoid_hom.ext $ by simp [nsmul_add],
..multiples_hom A}
/-- If `M` is commutative, `zmultiples_hom` is an additive equivalence. -/
def zmultiples_add_hom [add_comm_group A] : A ≃+ (ℤ →+ A) :=
{ map_add' := λ a b, add_monoid_hom.ext $ by simp [zsmul_add],
..zmultiples_hom A}
variables {M G A}
@[simp] lemma powers_mul_hom_apply [comm_monoid M] (x : M) (n : multiplicative ℕ) :
powers_mul_hom M x n = x ^ n.to_add := rfl
@[simp] lemma powers_mul_hom_symm_apply [comm_monoid M] (f : multiplicative ℕ →* M) :
(powers_mul_hom M).symm f = f (multiplicative.of_add 1) := rfl
@[simp] lemma zpowers_mul_hom_apply [comm_group G] (x : G) (n : multiplicative ℤ) :
zpowers_mul_hom G x n = x ^ n.to_add := rfl
@[simp] lemma zpowers_mul_hom_symm_apply [comm_group G] (f : multiplicative ℤ →* G) :
(zpowers_mul_hom G).symm f = f (multiplicative.of_add 1) := rfl
@[simp] lemma multiples_add_hom_apply [add_comm_monoid A] (x : A) (n : ℕ) :
multiples_add_hom A x n = n • x := rfl
@[simp] lemma multiples_add_hom_symm_apply [add_comm_monoid A] (f : ℕ →+ A) :
(multiples_add_hom A).symm f = f 1 := rfl
@[simp] lemma zmultiples_add_hom_apply [add_comm_group A] (x : A) (n : ℤ) :
zmultiples_add_hom A x n = n • x := rfl
@[simp] lemma zmultiples_add_hom_symm_apply [add_comm_group A] (f : ℤ →+ A) :
(zmultiples_add_hom A).symm f = f 1 := rfl
/-!
### Commutativity (again)
Facts about `semiconj_by` and `commute` that require `zpow` or `zsmul`, or the fact that integer
multiplication equals semiring multiplication.
-/
namespace semiconj_by
section
variables [semiring R] {a x y : R}
@[simp] lemma cast_nat_mul_right (h : semiconj_by a x y) (n : ℕ) :
semiconj_by a ((n : R) * x) (n * y) :=
semiconj_by.mul_right (nat.commute_cast _ _) h
@[simp] lemma cast_nat_mul_left (h : semiconj_by a x y) (n : ℕ) : semiconj_by ((n : R) * a) x y :=
semiconj_by.mul_left (nat.cast_commute _ _) h
@[simp] lemma cast_nat_mul_cast_nat_mul (h : semiconj_by a x y) (m n : ℕ) :
semiconj_by ((m : R) * a) (n * x) (n * y) :=
(h.cast_nat_mul_left m).cast_nat_mul_right n
end
variables [monoid M] [group G] [ring R]
@[simp, to_additive] lemma units_zpow_right {a : M} {x y : Mˣ} (h : semiconj_by a x y) :
∀ m : ℤ, semiconj_by a (↑(x^m)) (↑(y^m))
| (n : ℕ) := by simp only [zpow_coe_nat, units.coe_pow, h, pow_right]
| -[1+n] := by simp only [zpow_neg_succ_of_nat, units.coe_pow, units_inv_right, h, pow_right]
variables {a b x y x' y' : R}
@[simp] lemma cast_int_mul_right (h : semiconj_by a x y) (m : ℤ) :
semiconj_by a ((m : ℤ) * x) (m * y) :=
semiconj_by.mul_right (int.commute_cast _ _) h
@[simp] lemma cast_int_mul_left (h : semiconj_by a x y) (m : ℤ) : semiconj_by ((m : R) * a) x y :=
semiconj_by.mul_left (int.cast_commute _ _) h
@[simp] lemma cast_int_mul_cast_int_mul (h : semiconj_by a x y) (m n : ℤ) :
semiconj_by ((m : R) * a) (n * x) (n * y) :=
(h.cast_int_mul_left m).cast_int_mul_right n
end semiconj_by
namespace commute
section
variables [semiring R] {a b : R}
@[simp] theorem cast_nat_mul_right (h : commute a b) (n : ℕ) : commute a ((n : R) * b) :=
h.cast_nat_mul_right n
@[simp] theorem cast_nat_mul_left (h : commute a b) (n : ℕ) : commute ((n : R) * a) b :=
h.cast_nat_mul_left n
@[simp] theorem cast_nat_mul_cast_nat_mul (h : commute a b) (m n : ℕ) :
commute ((m : R) * a) (n * b) :=
h.cast_nat_mul_cast_nat_mul m n
@[simp] theorem self_cast_nat_mul (n : ℕ) : commute a (n * a) :=
(commute.refl a).cast_nat_mul_right n
@[simp] theorem cast_nat_mul_self (n : ℕ) : commute ((n : R) * a) a :=
(commute.refl a).cast_nat_mul_left n
@[simp] theorem self_cast_nat_mul_cast_nat_mul (m n : ℕ) : commute ((m : R) * a) (n * a) :=
(commute.refl a).cast_nat_mul_cast_nat_mul m n
end
variables [monoid M] [group G] [ring R]
@[simp, to_additive] lemma units_zpow_right {a : M} {u : Mˣ} (h : commute a u) (m : ℤ) :
commute a (↑(u^m)) :=
h.units_zpow_right m
@[simp, to_additive] lemma units_zpow_left {u : Mˣ} {a : M} (h : commute ↑u a) (m : ℤ) :
commute (↑(u^m)) a :=
(h.symm.units_zpow_right m).symm
variables {a b : R}
@[simp] lemma cast_int_mul_right (h : commute a b) (m : ℤ) : commute a (m * b) :=
h.cast_int_mul_right m
@[simp] lemma cast_int_mul_left (h : commute a b) (m : ℤ) : commute ((m : R) * a) b :=
h.cast_int_mul_left m
lemma cast_int_mul_cast_int_mul (h : commute a b) (m n : ℤ) : commute ((m : R) * a) (n * b) :=
h.cast_int_mul_cast_int_mul m n
variables (a) (m n : ℤ)
@[simp] lemma cast_int_left : commute (m : R) a :=
by { rw [← mul_one (m : R)], exact (one_left a).cast_int_mul_left m }
@[simp] lemma cast_int_right : commute a m :=
by { rw [← mul_one (m : R)], exact (one_right a).cast_int_mul_right m }
@[simp] theorem self_cast_int_mul : commute a (n * a) := (commute.refl a).cast_int_mul_right n
@[simp] theorem cast_int_mul_self : commute ((n : R) * a) a := (commute.refl a).cast_int_mul_left n
theorem self_cast_int_mul_cast_int_mul : commute ((m : R) * a) (n * a) :=
(commute.refl a).cast_int_mul_cast_int_mul m n
end commute
section multiplicative
open multiplicative
@[simp] lemma nat.to_add_pow (a : multiplicative ℕ) (b : ℕ) : to_add (a ^ b) = to_add a * b :=
begin
induction b with b ih,
{ erw [pow_zero, to_add_one, mul_zero] },
{ simp [*, pow_succ, add_comm, nat.mul_succ] }
end
@[simp] lemma nat.of_add_mul (a b : ℕ) : of_add (a * b) = of_add a ^ b :=
(nat.to_add_pow _ _).symm
@[simp] lemma int.to_add_pow (a : multiplicative ℤ) (b : ℕ) : to_add (a ^ b) = to_add a * b :=
by induction b; simp [*, mul_add, pow_succ, add_comm]
@[simp] lemma int.to_add_zpow (a : multiplicative ℤ) (b : ℤ) : to_add (a ^ b) = to_add a * b :=
int.induction_on b (by simp)
(by simp [zpow_add, mul_add] {contextual := tt})
(by simp [zpow_add, mul_add, sub_eq_add_neg, -int.add_neg_one] {contextual := tt})
@[simp] lemma int.of_add_mul (a b : ℤ) : of_add (a * b) = of_add a ^ b :=
(int.to_add_zpow _ _).symm
end multiplicative
namespace units
variables [monoid M]
lemma conj_pow (u : Mˣ) (x : M) (n : ℕ) : (↑u * x * ↑(u⁻¹))^n = u * x^n * ↑(u⁻¹) :=
(divp_eq_iff_mul_eq.2 ((u.mk_semiconj_by x).pow_right n).eq.symm).symm
lemma conj_pow' (u : Mˣ) (x : M) (n : ℕ) : (↑(u⁻¹) * x * u)^n = ↑(u⁻¹) * x^n * u:=
(u⁻¹).conj_pow x n
end units
namespace mul_opposite
/-- Moving to the opposite monoid commutes with taking powers. -/
@[simp] lemma op_pow [monoid M] (x : M) (n : ℕ) : op (x ^ n) = (op x) ^ n := rfl
@[simp] lemma unop_pow [monoid M] (x : Mᵐᵒᵖ) (n : ℕ) : unop (x ^ n) = (unop x) ^ n := rfl
/-- Moving to the opposite group or group_with_zero commutes with taking powers. -/
@[simp] lemma op_zpow [div_inv_monoid M] (x : M) (z : ℤ) : op (x ^ z) = (op x) ^ z := rfl
@[simp] lemma unop_zpow [div_inv_monoid M] (x : Mᵐᵒᵖ) (z : ℤ) : unop (x ^ z) = (unop x) ^ z := rfl
end mul_opposite
|
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
! This file was ported from Lean 3 source module category_theory.category.Kleisli
! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.CategoryTheory.Category.Basic
/-!
# The Kleisli construction on the Type category
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
Define the Kleisli category for (control) monads.
`category_theory/monad/kleisli` defines the general version for a monad on `C`, and demonstrates
the equivalence between the two.
## TODO
Generalise this to work with category_theory.monad
-/
universe u v
namespace CategoryTheory
#print CategoryTheory.KleisliCat /-
/-- The Kleisli category on the (type-)monad `m`. Note that the monad is not assumed to be lawful
yet. -/
@[nolint unused_arguments]
def KleisliCat (m : Type u → Type v) :=
Type u
#align category_theory.Kleisli CategoryTheory.KleisliCat
-/
#print CategoryTheory.KleisliCat.mk /-
/-- Construct an object of the Kleisli category from a type. -/
def KleisliCat.mk (m) (α : Type u) : KleisliCat m :=
α
#align category_theory.Kleisli.mk CategoryTheory.KleisliCat.mk
-/
#print CategoryTheory.KleisliCat.categoryStruct /-
instance KleisliCat.categoryStruct {m} [Monad.{u, v} m] : CategoryStruct (KleisliCat m)
where
Hom α β := α → m β
id α x := pure x
comp X Y Z f g := f >=> g
#align category_theory.Kleisli.category_struct CategoryTheory.KleisliCat.categoryStruct
-/
#print CategoryTheory.KleisliCat.category /-
instance KleisliCat.category {m} [Monad.{u, v} m] [LawfulMonad m] : Category (KleisliCat m) := by
refine' { id_comp' := _
comp_id' := _
assoc' := _ } <;> intros <;> ext <;> unfold_projs <;>
simp only [(· >=> ·), functor_norm]
#align category_theory.Kleisli.category CategoryTheory.KleisliCat.category
-/
/- warning: category_theory.Kleisli.id_def -> CategoryTheory.KleisliCat.id_def is a dubious translation:
lean 3 declaration is
forall {m : Type.{u1} -> Type.{u2}} [_inst_1 : Monad.{u1, u2} m] (α : CategoryTheory.KleisliCat.{u1, u2} m), Eq.{succ (max u1 u2)} (Quiver.Hom.{succ (max u1 u2), succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.KleisliCat.categoryStruct.{u1, u2} m _inst_1)) α α) (CategoryTheory.CategoryStruct.id.{max u1 u2, succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.KleisliCat.categoryStruct.{u1, u2} m _inst_1) α) (Pure.pure.{u1, u2} m (Applicative.toHasPure.{u1, u2} m (Monad.toApplicative.{u1, u2} m _inst_1)) α)
but is expected to have type
forall {m : Type.{u2} -> Type.{u1}} [_inst_1 : Monad.{u2, u1} m] (α : CategoryTheory.KleisliCat.{u2, u1} m), Eq.{max (succ u1) (succ u2)} (Quiver.Hom.{succ (max u1 u2), succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.KleisliCat.categoryStruct.{u2, u1} m _inst_1)) α α) (CategoryTheory.CategoryStruct.id.{max u1 u2, succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.KleisliCat.categoryStruct.{u2, u1} m _inst_1) α) (Pure.pure.{u2, u1} m (Applicative.toPure.{u2, u1} m (Monad.toApplicative.{u2, u1} m _inst_1)) α)
Case conversion may be inaccurate. Consider using '#align category_theory.Kleisli.id_def CategoryTheory.KleisliCat.id_defₓ'. -/
@[simp]
theorem KleisliCat.id_def {m} [Monad m] (α : KleisliCat m) : 𝟙 α = @pure m _ α :=
rfl
#align category_theory.Kleisli.id_def CategoryTheory.KleisliCat.id_def
/- warning: category_theory.Kleisli.comp_def -> CategoryTheory.KleisliCat.comp_def is a dubious translation:
lean 3 declaration is
forall {m : Type.{u1} -> Type.{u2}} [_inst_1 : Monad.{u1, u2} m] (α : CategoryTheory.KleisliCat.{u1, u2} m) (β : CategoryTheory.KleisliCat.{u1, u2} m) (γ : CategoryTheory.KleisliCat.{u1, u2} m) (xs : Quiver.Hom.{succ (max u1 u2), succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.KleisliCat.categoryStruct.{u1, u2} m _inst_1)) α β) (ys : Quiver.Hom.{succ (max u1 u2), succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.KleisliCat.categoryStruct.{u1, u2} m _inst_1)) β γ) (a : α), Eq.{succ u2} (m γ) (CategoryTheory.CategoryStruct.comp.{max u1 u2, succ u1} (CategoryTheory.KleisliCat.{u1, u2} m) (CategoryTheory.KleisliCat.categoryStruct.{u1, u2} m _inst_1) α β γ xs ys a) (Bind.bind.{u1, u2} m (Monad.toHasBind.{u1, u2} m _inst_1) β γ (xs a) ys)
but is expected to have type
forall {m : Type.{u2} -> Type.{u1}} [_inst_1 : Monad.{u2, u1} m] (α : CategoryTheory.KleisliCat.{u2, u1} m) (β : CategoryTheory.KleisliCat.{u2, u1} m) (γ : CategoryTheory.KleisliCat.{u2, u1} m) (xs : Quiver.Hom.{max (succ u1) (succ u2), succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.KleisliCat.categoryStruct.{u2, u1} m _inst_1)) α β) (ys : Quiver.Hom.{max (succ u1) (succ u2), succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.KleisliCat.categoryStruct.{u2, u1} m _inst_1)) β γ) (a : α), Eq.{succ u1} (m γ) (CategoryTheory.CategoryStruct.comp.{max u1 u2, succ u2} (CategoryTheory.KleisliCat.{u2, u1} m) (CategoryTheory.KleisliCat.categoryStruct.{u2, u1} m _inst_1) α β γ xs ys a) (Bind.bind.{u2, u1} m (Monad.toBind.{u2, u1} m _inst_1) β γ (xs a) ys)
Case conversion may be inaccurate. Consider using '#align category_theory.Kleisli.comp_def CategoryTheory.KleisliCat.comp_defₓ'. -/
theorem KleisliCat.comp_def {m} [Monad m] (α β γ : KleisliCat m) (xs : α ⟶ β) (ys : β ⟶ γ) (a : α) :
(xs ≫ ys) a = xs a >>= ys :=
rfl
#align category_theory.Kleisli.comp_def CategoryTheory.KleisliCat.comp_def
instance : Inhabited (KleisliCat id) :=
⟨PUnit⟩
instance {α : Type u} [Inhabited α] : Inhabited (KleisliCat.mk id α) :=
⟨show α from default⟩
end CategoryTheory
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.