text
stringlengths 0
3.34M
|
---|
(*
This is the definition of formal syntax for Dan Grossman's Thesis,
"SAFE PROGRAMMING AT THE C LEVEL OF ABSTRACTION".
Defining type safety, page 67.
*)
Require Export LanguageModuleDef.
Require Export StaticSemantics.
Require Export DynamicSemanticsHeapObjects.
Require Export TacticNotations.
(* Bug, Miswrote theorem. I like the forall quantified version although
I can naturally express this with exists. *)
(* This is not the right induction just whacking a length on it. *)
(* I need to induct on path extension, perhaps reverse paths? *)
Functional Scheme rev_ind := Induction for rev Sort Prop.
Lemma A_11_Heap_Object_Safety_1:
forall (v1 : E),
forall (p : Path) (v2 : E) (v3 : E),
get v1 p v2 ->
get v1 p v3 ->
v2 = v3.
Proof.
intros v1.
induction v1;
try (intros p v2 v3 getv1pv2 getv1pv3;
inversion getv1pv2;
inversion getv1pv3;
try reflexivity;
crush).
(* 1,2 should invert on getv1pv* why didn't it? *)
specialize (IHv1_1 p0 v3 v2).
apply IHv1_1 in H14.
crush.
assumption.
specialize (IHv1_2 p0 v3 v2).
apply IHv1_2 in H14.
crush.
assumption.
specialize (IHv1 p0 v2 v3).
apply IHv1 in H6.
crush.
assumption.
Qed.
Lemma A_11_Heap_Object_Safety_2:
forall (v0 : E) (p1 : Path) (v1 : E),
Value v0 ->
Value v1 ->
get v0 p1 v1 ->
forall (p2 : Path) (v2 : E),
Value v2 ->
get v0 (p1 ++ p2) v2 ->
get v1 p2 v2.
Proof.
(* Try induction on the values. *)
intros v0.
(* Try to learn to get rid of silly goals. *)
induction v0;
try (
intros p1 v1 val0 val1 getv0p1v1;
inversion getv0p1v1;
intros p2 v2 valv2;
intros get;
inversion get;
crush).
intros p1;
induction p1 as [| pe1 p1'].
Case "pair and p1=[]".
intros v1 valpair valv1 getcpair p2 v2 valv2 getcpairnil.
inversion getcpair.
crush.
(* A pair and a pack, nice strong induction hypotheses. *)
Case "pair and pe1::p1".
SCase "pe1= i which won't work".
intros v1 valpair valv1 getcpair p2 v2 valv2 getcpairnil.
destruct pe1; try destruct i.
SSCase "pe1=zero_pe".
inversion valpair; inversion getcpair; inversion getcpairnil; crush.
specialize (IHv0_1 p1' v1 H1 H6 H10 p2 v2 H14 H18).
assumption.
SSCase "pe1=one_pe".
inversion valpair.
inversion getcpair.
inversion getcpairnil.
crush.
specialize (IHv0_2 p1' v1 H2 H6 H10 p2 v2 H14 H18).
assumption.
SSCase "pe1=u_pe".
inversion getcpair.
Case "v0 is pack".
intros p1 v1 valpack valv1.
destruct p1.
SCase "p1 is []".
intros getpack p2 v2 valv2 getpackp2.
rewrite app_nil_l in getpackp2.
inversion valpack; inversion getpack; inversion getpackp2; crush.
SCase "p1 is ".
destruct p.
intros integerpath.
inversion integerpath.
inversion valpack.
intros getpacku p2 v2 valv2 step.
inversion getpacku.
crush.
inversion step.
crush.
apply IHv0 with (p1:= p1); try assumption.
Qed.
Lemma A_11_Heap_Object_Safety_3:
forall (h : Heap) (u : Upsilon) (g : Gamma)
(x : EVar) (vhx v1 : E) (t1 t2: Tau)
(p1 p2 : Path),
Value v1 ->
refp h u ->
htyp u g h g ->
H.map h x = Some vhx ->
get vhx p1 v1 ->
rtyp D.empty u g v1 t1 ->
gettype u x p1 t1 p2 t2 ->
(exists (v2 : E),
get vhx (p1 ++ p2) v2 /\
rtyp D.empty u g v2 t2) /\
(forall (v2' : E),
Value v2' ->
(exists (v1' : E),
Value v1' ->
set v1 p2 v2' v1')).
Proof.
intros h u g x vhx v1 t1 t2 p1 p2.
intros valv1 refpder htypder getHder getder rtypder gettypeder.
split.
(* Try induction v1, p.
induction v1; induction p2. 24 uncrushable goals. *)
(* Try functional induction on get type, 12/24.*)
gettype_ind_cases (induction gettypeder) Case;
try inversion gettypeder; (* 12/24 *)
try (rewrite app_nil_r;
apply ex_intro with (x:=v1);
split;
assumption;
inversion gettypeder;
assumption). (* 8/12 *)
(* Well I chopped the goals down, but now is it actually provable? *)
(* Scotch whisky society, 10.76, bunnahbin distilery,
like smoking a hookah over oyster shells. *)
crush.
(* Why can I not clear the bad goals with an inversion on rtypder? *)
(* destruct v1. *)
(* induction v1 *)
(* induction rtypder ? *)
(* Have to get more in the context and then destruct v1. *)
(* But it's an existential. *)
(* assert (A: get v1 (i_pe zero_pe) v2). *)
admit.
admit.
admit.
admit.
admit.
admit.
admit.
Admitted.
Lemma gettype_nil_path:
forall (u : Upsilon) (x : EVar) (p : Path) (t1 t2 : Tau),
gettype u x p t1 [] t2 ->
t1 = t2.
Proof.
intros u x p t1 t2.
induction t1.
crush.
crush.
crush.
crush.
crush.
crush.
intros.
Admitted.
(*
destruct p0.
compute in H.
crush.
compute in H.
crush.
Qed.
*)
Lemma A_11_Heap_Object_Safety_3_induction_tests:
forall (h : Heap) (u : Upsilon) (g : Gamma)
(x : EVar) (vhx v1 : E) (t1 t2: Tau)
(p1 p2 : Path),
refp h u ->
htyp u g h g ->
H.map h x = Some vhx ->
Value v1 ->
get vhx p1 v1 ->
rtyp D.empty u g v1 t1 ->
gettype u x p1 t1 p2 t2 ->
(exists (v2 : E),
get vhx (p1 ++ p2) v2 /\
rtyp D.empty u g v2 t2) /\
(forall (v2' : E),
Value v2' ->
(exists (v1' : E),
Value v1' ->
set v1 p2 v2' v1')).
Proof.
Admitted.
(*
intros h u g x vhx v1 t1 t2 p1 p2.
intros refpder htypder valv1 H.mapder getder rtypder.
induction p2; try destruct a; try destruct i.
Case "p2=[]".
intros gettypeder.
apply gettype_nil_path in gettypeder.
crush.
apply ex_intro with (x:=v1).
split.
SCase "get".
rewrite app_nil_r.
assumption.
assumption.
SCase "set".
apply ex_intro with (x:=v1).
intros.
assert (E: v1 = v2').
admit. (* TODO apply both halves of the theorem in this goal. *)
rewrite E.
constructor.
assumption.
assumption.
Case "p = zero_pe :: p2".
intros gettypeder.
destruct t1.
(* Have to sequentially invert as this is unfolding some things we don't want.*)
(* Just clearing meaningless goals. *)
inversion gettypeder.
inversion gettypeder.
Focus 2.
inversion gettypeder.
Focus 2.
inversion gettypeder.
Focus 2.
inversion gettypeder.
(* Dan's one inversion is really three. *)
destruct v1; inversion H.mapder; inversion rtypder.
(* And crush is unfolding a gettypeder. *)
apply A_10_Path_Extension_1_A with (v0:=v1_1 ) (v1:=v1_2) in getder.
admit.
admit.
constructor; assumption.
reflexivity.
Case "p = one_pe :: p2".
admit.
Case "p = u_pe :: p2".
admit.
Admitted.
Check A_11_Heap_Object_Safety_3.
*)
Lemma A_11_Heap_Object_Safety_3_Corollary :
forall (h : Heap) (u : Upsilon) (g : Gamma)
(x : EVar) (v1 : E) (t1 t2: Tau)
(p2 : Path),
Value v1 ->
refp h u ->
htyp u g h g ->
H.map h x = Some v1 ->
get v1 [] v1 ->
rtyp D.empty u g v1 t1 ->
gettype u x [] t1 p2 t2 ->
(exists (v2 : E),
get v1 ([] ++ p2) v2 /\
rtyp D.empty u g v2 t2) /\
(forall (v2' : E),
Value v2' ->
(exists (v1' : E),
Value v1' ->
set v1 p2 v2' v1')).
Proof.
intros h u g x v1 t1 t2 p2.
intros valv1 refpder htypder getHmapder getder rtypder gettypeder.
apply A_11_Heap_Object_Safety_3 with (h:=h) (x:=x) (t1:=t1);
try assumption;
try constructor;
try assumption.
Qed.
(*
Lemma A_11_Heap_Object_Safety_4:
forall (h : Heap) (u : Upsilon) (g : Gamma)
(x : EVar) (vhx v1 : E) (t1 t2: Tau)
(p1 p2 : Path),
Value v1 ->
refp h u ->
htyp u g h g ->
H.map h x = Some vhx ->
get vhx p1 v1 ->
rtyp D.empty u g v1 t1 ->
gettype u x p1 t1 p2 t2 ->
(exists (v2 : E),
get vhx (p1 ++ p2) v2 /\
rtyp D.empty u g v2 t2) /\
(forall (v2' : E),
Value v2' ->
(exists (v1' : E),
Value v1' ->
set v1 p2 v2' v1')) ->
ASGN [] t2 ->
forall (p':P),
getU u x (p1++p2++p') = None.
Proof.
(* By lemmas and case analysis on t2. *)
intros h u g x vhx v1 t1 t2 p1 p2.
intros valv1 refpder htypder H.mapder getder rtypder gettypeder.
intros big.
intros asgnder.
intros p'.
induction t2.
Case "t2 = tvar t".
inversion asgnder.
assert (H1': getD [] t = None).
apply getD_from_nil_None.
rewrite H1 in H1'.
inversion H1'.
Case "t2 = cint".
admit.
Case "t2 = cross".
admit.
Case "t2 = arrow".
admit.
Case "t2 = ptype".
admit.
Case "t2 = utype".
admit.
Case "t2 = etype".
admit.
Admitted.
(* TODO
Lemma A_11_Heap_Object_Safety_5.
Admitted.
Lemma A_11_Heap_Object_Safety_5_Corollary.
Admitted.
*)
*) |
(* Title: Doc/Functions/Functions.thy
Author: Alexander Krauss, TU Muenchen
Tutorial for function definitions with the new "function" package.
*)
theory Functions
imports Main
begin
section \<open>Function Definitions for Dummies\<close>
text \<open>
In most cases, defining a recursive function is just as simple as other definitions:
\<close>
fun fib :: "nat \<Rightarrow> nat"
where
"fib 0 = 1"
| "fib (Suc 0) = 1"
| "fib (Suc (Suc n)) = fib n + fib (Suc n)"
text \<open>
The syntax is rather self-explanatory: We introduce a function by
giving its name, its type,
and a set of defining recursive equations.
If we leave out the type, the most general type will be
inferred, which can sometimes lead to surprises: Since both @{term
"1::nat"} and @{text "+"} are overloaded, we would end up
with @{text "fib :: nat \<Rightarrow> 'a::{one,plus}"}.
\<close>
text \<open>
The function always terminates, since its argument gets smaller in
every recursive call.
Since HOL is a logic of total functions, termination is a
fundamental requirement to prevent inconsistencies\footnote{From the
\qt{definition} @{text "f(n) = f(n) + 1"} we could prove
@{text "0 = 1"} by subtracting @{text "f(n)"} on both sides.}.
Isabelle tries to prove termination automatically when a definition
is made. In \S\ref{termination}, we will look at cases where this
fails and see what to do then.
\<close>
subsection \<open>Pattern matching\<close>
text \<open>\label{patmatch}
Like in functional programming, we can use pattern matching to
define functions. At the moment we will only consider \emph{constructor
patterns}, which only consist of datatype constructors and
variables. Furthermore, patterns must be linear, i.e.\ all variables
on the left hand side of an equation must be distinct. In
\S\ref{genpats} we discuss more general pattern matching.
If patterns overlap, the order of the equations is taken into
account. The following function inserts a fixed element between any
two elements of a list:
\<close>
fun sep :: "'a \<Rightarrow> 'a list \<Rightarrow> 'a list"
where
"sep a (x#y#xs) = x # a # sep a (y # xs)"
| "sep a xs = xs"
text \<open>
Overlapping patterns are interpreted as \qt{increments} to what is
already there: The second equation is only meant for the cases where
the first one does not match. Consequently, Isabelle replaces it
internally by the remaining cases, making the patterns disjoint:
\<close>
thm sep.simps
text \<open>@{thm [display] sep.simps[no_vars]}\<close>
text \<open>
\noindent The equations from function definitions are automatically used in
simplification:
\<close>
lemma "sep 0 [1, 2, 3] = [1, 0, 2, 0, 3]"
by simp
subsection \<open>Induction\<close>
text \<open>
Isabelle provides customized induction rules for recursive
functions. These rules follow the recursive structure of the
definition. Here is the rule @{thm [source] sep.induct} arising from the
above definition of @{const sep}:
@{thm [display] sep.induct}
We have a step case for list with at least two elements, and two
base cases for the zero- and the one-element list. Here is a simple
proof about @{const sep} and @{const map}
\<close>
lemma "map f (sep x ys) = sep (f x) (map f ys)"
apply (induct x ys rule: sep.induct)
text \<open>
We get three cases, like in the definition.
@{subgoals [display]}
\<close>
apply auto
done
text \<open>
With the \cmd{fun} command, you can define about 80\% of the
functions that occur in practice. The rest of this tutorial explains
the remaining 20\%.
\<close>
section \<open>fun vs.\ function\<close>
text \<open>
The \cmd{fun} command provides a
convenient shorthand notation for simple function definitions. In
this mode, Isabelle tries to solve all the necessary proof obligations
automatically. If any proof fails, the definition is
rejected. This can either mean that the definition is indeed faulty,
or that the default proof procedures are just not smart enough (or
rather: not designed) to handle the definition.
By expanding the abbreviation to the more verbose \cmd{function} command, these proof obligations become visible and can be analyzed or
solved manually. The expansion from \cmd{fun} to \cmd{function} is as follows:
\end{isamarkuptext}
\[\left[\;\begin{minipage}{0.25\textwidth}\vspace{6pt}
\cmd{fun} @{text "f :: \<tau>"}\\%
\cmd{where}\\%
\hspace*{2ex}{\it equations}\\%
\hspace*{2ex}\vdots\vspace*{6pt}
\end{minipage}\right]
\quad\equiv\quad
\left[\;\begin{minipage}{0.48\textwidth}\vspace{6pt}
\cmd{function} @{text "("}\cmd{sequential}@{text ") f :: \<tau>"}\\%
\cmd{where}\\%
\hspace*{2ex}{\it equations}\\%
\hspace*{2ex}\vdots\\%
\cmd{by} @{text "pat_completeness auto"}\\%
\cmd{termination by} @{text "lexicographic_order"}\vspace{6pt}
\end{minipage}
\right]\]
\begin{isamarkuptext}
\vspace*{1em}
\noindent Some details have now become explicit:
\begin{enumerate}
\item The \cmd{sequential} option enables the preprocessing of
pattern overlaps which we already saw. Without this option, the equations
must already be disjoint and complete. The automatic completion only
works with constructor patterns.
\item A function definition produces a proof obligation which
expresses completeness and compatibility of patterns (we talk about
this later). The combination of the methods @{text "pat_completeness"} and
@{text "auto"} is used to solve this proof obligation.
\item A termination proof follows the definition, started by the
\cmd{termination} command. This will be explained in \S\ref{termination}.
\end{enumerate}
Whenever a \cmd{fun} command fails, it is usually a good idea to
expand the syntax to the more verbose \cmd{function} form, to see
what is actually going on.
\<close>
section \<open>Termination\<close>
text \<open>\label{termination}
The method @{text "lexicographic_order"} is the default method for
termination proofs. It can prove termination of a
certain class of functions by searching for a suitable lexicographic
combination of size measures. Of course, not all functions have such
a simple termination argument. For them, we can specify the termination
relation manually.
\<close>
subsection \<open>The {\tt relation} method\<close>
text\<open>
Consider the following function, which sums up natural numbers up to
@{text "N"}, using a counter @{text "i"}:
\<close>
function sum :: "nat \<Rightarrow> nat \<Rightarrow> nat"
where
"sum i N = (if i > N then 0 else i + sum (Suc i) N)"
by pat_completeness auto
text \<open>
\noindent The @{text "lexicographic_order"} method fails on this example, because none of the
arguments decreases in the recursive call, with respect to the standard size ordering.
To prove termination manually, we must provide a custom wellfounded relation.
The termination argument for @{text "sum"} is based on the fact that
the \emph{difference} between @{text "i"} and @{text "N"} gets
smaller in every step, and that the recursion stops when @{text "i"}
is greater than @{text "N"}. Phrased differently, the expression
@{text "N + 1 - i"} always decreases.
We can use this expression as a measure function suitable to prove termination.
\<close>
termination sum
apply (relation "measure (\<lambda>(i,N). N + 1 - i)")
text \<open>
The \cmd{termination} command sets up the termination goal for the
specified function @{text "sum"}. If the function name is omitted, it
implicitly refers to the last function definition.
The @{text relation} method takes a relation of
type @{typ "('a \<times> 'a) set"}, where @{typ "'a"} is the argument type of
the function. If the function has multiple curried arguments, then
these are packed together into a tuple, as it happened in the above
example.
The predefined function @{term[source] "measure :: ('a \<Rightarrow> nat) \<Rightarrow> ('a \<times> 'a) set"} constructs a
wellfounded relation from a mapping into the natural numbers (a
\emph{measure function}).
After the invocation of @{text "relation"}, we must prove that (a)
the relation we supplied is wellfounded, and (b) that the arguments
of recursive calls indeed decrease with respect to the
relation:
@{subgoals[display,indent=0]}
These goals are all solved by @{text "auto"}:
\<close>
apply auto
done
text \<open>
Let us complicate the function a little, by adding some more
recursive calls:
\<close>
function foo :: "nat \<Rightarrow> nat \<Rightarrow> nat"
where
"foo i N = (if i > N
then (if N = 0 then 0 else foo 0 (N - 1))
else i + foo (Suc i) N)"
by pat_completeness auto
text \<open>
When @{text "i"} has reached @{text "N"}, it starts at zero again
and @{text "N"} is decremented.
This corresponds to a nested
loop where one index counts up and the other down. Termination can
be proved using a lexicographic combination of two measures, namely
the value of @{text "N"} and the above difference. The @{const
"measures"} combinator generalizes @{text "measure"} by taking a
list of measure functions.
\<close>
termination
by (relation "measures [\<lambda>(i, N). N, \<lambda>(i,N). N + 1 - i]") auto
subsection \<open>How @{text "lexicographic_order"} works\<close>
(*fun fails :: "nat \<Rightarrow> nat list \<Rightarrow> nat"
where
"fails a [] = a"
| "fails a (x#xs) = fails (x + a) (x # xs)"
*)
text \<open>
To see how the automatic termination proofs work, let's look at an
example where it fails\footnote{For a detailed discussion of the
termination prover, see @{cite bulwahnKN07}}:
\end{isamarkuptext}
\cmd{fun} @{text "fails :: \"nat \<Rightarrow> nat list \<Rightarrow> nat\""}\\%
\cmd{where}\\%
\hspace*{2ex}@{text "\"fails a [] = a\""}\\%
|\hspace*{1.5ex}@{text "\"fails a (x#xs) = fails (x + a) (x#xs)\""}\\
\begin{isamarkuptext}
\noindent Isabelle responds with the following error:
\begin{isabelle}
*** Unfinished subgoals:\newline
*** (a, 1, <):\newline
*** \ 1.~@{text "\<And>x. x = 0"}\newline
*** (a, 1, <=):\newline
*** \ 1.~False\newline
*** (a, 2, <):\newline
*** \ 1.~False\newline
*** Calls:\newline
*** a) @{text "(a, x # xs) -->> (x + a, x # xs)"}\newline
*** Measures:\newline
*** 1) @{text "\<lambda>x. size (fst x)"}\newline
*** 2) @{text "\<lambda>x. size (snd x)"}\newline
*** Result matrix:\newline
*** \ \ \ \ 1\ \ 2 \newline
*** a: ? <= \newline
*** Could not find lexicographic termination order.\newline
*** At command "fun".\newline
\end{isabelle}
\<close>
text \<open>
The key to this error message is the matrix at the bottom. The rows
of that matrix correspond to the different recursive calls (In our
case, there is just one). The columns are the function's arguments
(expressed through different measure functions, which map the
argument tuple to a natural number).
The contents of the matrix summarize what is known about argument
descents: The second argument has a weak descent (@{text "<="}) at the
recursive call, and for the first argument nothing could be proved,
which is expressed by @{text "?"}. In general, there are the values
@{text "<"}, @{text "<="} and @{text "?"}.
For the failed proof attempts, the unfinished subgoals are also
printed. Looking at these will often point to a missing lemma.
\<close>
subsection \<open>The @{text size_change} method\<close>
text \<open>
Some termination goals that are beyond the powers of
@{text lexicographic_order} can be solved automatically by the
more powerful @{text size_change} method, which uses a variant of
the size-change principle, together with some other
techniques. While the details are discussed
elsewhere @{cite krauss_phd},
here are a few typical situations where
@{text lexicographic_order} has difficulties and @{text size_change}
may be worth a try:
\begin{itemize}
\item Arguments are permuted in a recursive call.
\item Several mutually recursive functions with multiple arguments.
\item Unusual control flow (e.g., when some recursive calls cannot
occur in sequence).
\end{itemize}
Loading the theory @{text Multiset} makes the @{text size_change}
method a bit stronger: it can then use multiset orders internally.
\<close>
section \<open>Mutual Recursion\<close>
text \<open>
If two or more functions call one another mutually, they have to be defined
in one step. Here are @{text "even"} and @{text "odd"}:
\<close>
function even :: "nat \<Rightarrow> bool"
and odd :: "nat \<Rightarrow> bool"
where
"even 0 = True"
| "odd 0 = False"
| "even (Suc n) = odd n"
| "odd (Suc n) = even n"
by pat_completeness auto
text \<open>
To eliminate the mutual dependencies, Isabelle internally
creates a single function operating on the sum
type @{typ "nat + nat"}. Then, @{const even} and @{const odd} are
defined as projections. Consequently, termination has to be proved
simultaneously for both functions, by specifying a measure on the
sum type:
\<close>
termination
by (relation "measure (\<lambda>x. case x of Inl n \<Rightarrow> n | Inr n \<Rightarrow> n)") auto
text \<open>
We could also have used @{text lexicographic_order}, which
supports mutual recursive termination proofs to a certain extent.
\<close>
subsection \<open>Induction for mutual recursion\<close>
text \<open>
When functions are mutually recursive, proving properties about them
generally requires simultaneous induction. The induction rule @{thm [source] "even_odd.induct"}
generated from the above definition reflects this.
Let us prove something about @{const even} and @{const odd}:
\<close>
lemma even_odd_mod2:
"even n = (n mod 2 = 0)"
"odd n = (n mod 2 = 1)"
text \<open>
We apply simultaneous induction, specifying the induction variable
for both goals, separated by \cmd{and}:\<close>
apply (induct n and n rule: even_odd.induct)
text \<open>
We get four subgoals, which correspond to the clauses in the
definition of @{const even} and @{const odd}:
@{subgoals[display,indent=0]}
Simplification solves the first two goals, leaving us with two
statements about the @{text "mod"} operation to prove:
\<close>
apply simp_all
text \<open>
@{subgoals[display,indent=0]}
\noindent These can be handled by Isabelle's arithmetic decision procedures.
\<close>
apply arith
apply arith
done
text \<open>
In proofs like this, the simultaneous induction is really essential:
Even if we are just interested in one of the results, the other
one is necessary to strengthen the induction hypothesis. If we leave
out the statement about @{const odd} and just write @{term True} instead,
the same proof fails:
\<close>
lemma failed_attempt:
"even n = (n mod 2 = 0)"
"True"
apply (induct n rule: even_odd.induct)
text \<open>
\noindent Now the third subgoal is a dead end, since we have no
useful induction hypothesis available:
@{subgoals[display,indent=0]}
\<close>
oops
section \<open>Elimination\<close>
text \<open>
A definition of function @{text f} gives rise to two kinds of elimination rules. Rule @{text f.cases}
simply describes case analysis according to the patterns used in the definition:
\<close>
fun list_to_option :: "'a list \<Rightarrow> 'a option"
where
"list_to_option [x] = Some x"
| "list_to_option _ = None"
thm list_to_option.cases
text \<open>
@{thm[display] list_to_option.cases}
Note that this rule does not mention the function at all, but only describes the cases used for
defining it. In contrast, the rule @{thm[source] list_to_option.elims} also tell us what the function
value will be in each case:
\<close>
thm list_to_option.elims
text \<open>
@{thm[display] list_to_option.elims}
\noindent
This lets us eliminate an assumption of the form @{prop "list_to_option xs = y"} and replace it
with the two cases, e.g.:
\<close>
lemma "list_to_option xs = y \<Longrightarrow> P"
proof (erule list_to_option.elims)
fix x assume "xs = [x]" "y = Some x" thus P sorry
next
assume "xs = []" "y = None" thus P sorry
next
fix a b xs' assume "xs = a # b # xs'" "y = None" thus P sorry
qed
text \<open>
Sometimes it is convenient to derive specialized versions of the @{text elim} rules above and
keep them around as facts explicitly. For example, it is natural to show that if
@{prop "list_to_option xs = Some y"}, then @{term xs} must be a singleton. The command
\cmd{fun\_cases} derives such facts automatically, by instantiating and simplifying the general
elimination rules given some pattern:
\<close>
fun_cases list_to_option_SomeE[elim]: "list_to_option xs = Some y"
thm list_to_option_SomeE
text \<open>
@{thm[display] list_to_option_SomeE}
\<close>
section \<open>General pattern matching\<close>
text\<open>\label{genpats}\<close>
subsection \<open>Avoiding automatic pattern splitting\<close>
text \<open>
Up to now, we used pattern matching only on datatypes, and the
patterns were always disjoint and complete, and if they weren't,
they were made disjoint automatically like in the definition of
@{const "sep"} in \S\ref{patmatch}.
This automatic splitting can significantly increase the number of
equations involved, and this is not always desirable. The following
example shows the problem:
Suppose we are modeling incomplete knowledge about the world by a
three-valued datatype, which has values @{term "T"}, @{term "F"}
and @{term "X"} for true, false and uncertain propositions, respectively.
\<close>
datatype P3 = T | F | X
text \<open>\noindent Then the conjunction of such values can be defined as follows:\<close>
fun And :: "P3 \<Rightarrow> P3 \<Rightarrow> P3"
where
"And T p = p"
| "And p T = p"
| "And p F = F"
| "And F p = F"
| "And X X = X"
text \<open>
This definition is useful, because the equations can directly be used
as simplification rules. But the patterns overlap: For example,
the expression @{term "And T T"} is matched by both the first and
the second equation. By default, Isabelle makes the patterns disjoint by
splitting them up, producing instances:
\<close>
thm And.simps
text \<open>
@{thm[indent=4] And.simps}
\vspace*{1em}
\noindent There are several problems with this:
\begin{enumerate}
\item If the datatype has many constructors, there can be an
explosion of equations. For @{const "And"}, we get seven instead of
five equations, which can be tolerated, but this is just a small
example.
\item Since splitting makes the equations \qt{less general}, they
do not always match in rewriting. While the term @{term "And x F"}
can be simplified to @{term "F"} with the original equations, a
(manual) case split on @{term "x"} is now necessary.
\item The splitting also concerns the induction rule @{thm [source]
"And.induct"}. Instead of five premises it now has seven, which
means that our induction proofs will have more cases.
\item In general, it increases clarity if we get the same definition
back which we put in.
\end{enumerate}
If we do not want the automatic splitting, we can switch it off by
leaving out the \cmd{sequential} option. However, we will have to
prove that our pattern matching is consistent\footnote{This prevents
us from defining something like @{term "f x = True"} and @{term "f x
= False"} simultaneously.}:
\<close>
function And2 :: "P3 \<Rightarrow> P3 \<Rightarrow> P3"
where
"And2 T p = p"
| "And2 p T = p"
| "And2 p F = F"
| "And2 F p = F"
| "And2 X X = X"
text \<open>
\noindent Now let's look at the proof obligations generated by a
function definition. In this case, they are:
@{subgoals[display,indent=0]}\vspace{-1.2em}\hspace{3cm}\vdots\vspace{1.2em}
The first subgoal expresses the completeness of the patterns. It has
the form of an elimination rule and states that every @{term x} of
the function's input type must match at least one of the patterns\footnote{Completeness could
be equivalently stated as a disjunction of existential statements:
@{term "(\<exists>p. x = (T, p)) \<or> (\<exists>p. x = (p, T)) \<or> (\<exists>p. x = (p, F)) \<or>
(\<exists>p. x = (F, p)) \<or> (x = (X, X))"}, and you can use the method @{text atomize_elim} to get that form instead.}. If the patterns just involve
datatypes, we can solve it with the @{text "pat_completeness"}
method:
\<close>
apply pat_completeness
text \<open>
The remaining subgoals express \emph{pattern compatibility}. We do
allow that an input value matches multiple patterns, but in this
case, the result (i.e.~the right hand sides of the equations) must
also be equal. For each pair of two patterns, there is one such
subgoal. Usually this needs injectivity of the constructors, which
is used automatically by @{text "auto"}.
\<close>
by auto
termination by (relation "{}") simp
subsection \<open>Non-constructor patterns\<close>
text \<open>
Most of Isabelle's basic types take the form of inductive datatypes,
and usually pattern matching works on the constructors of such types.
However, this need not be always the case, and the \cmd{function}
command handles other kind of patterns, too.
One well-known instance of non-constructor patterns are
so-called \emph{$n+k$-patterns}, which are a little controversial in
the functional programming world. Here is the initial fibonacci
example with $n+k$-patterns:
\<close>
function fib2 :: "nat \<Rightarrow> nat"
where
"fib2 0 = 1"
| "fib2 1 = 1"
| "fib2 (n + 2) = fib2 n + fib2 (Suc n)"
text \<open>
This kind of matching is again justified by the proof of pattern
completeness and compatibility.
The proof obligation for pattern completeness states that every natural number is
either @{term "0::nat"}, @{term "1::nat"} or @{term "n +
(2::nat)"}:
@{subgoals[display,indent=0,goals_limit=1]}
This is an arithmetic triviality, but unfortunately the
@{text arith} method cannot handle this specific form of an
elimination rule. However, we can use the method @{text
"atomize_elim"} to do an ad-hoc conversion to a disjunction of
existentials, which can then be solved by the arithmetic decision procedure.
Pattern compatibility and termination are automatic as usual.
\<close>
apply atomize_elim
apply arith
apply auto
done
termination by lexicographic_order
text \<open>
We can stretch the notion of pattern matching even more. The
following function is not a sensible functional program, but a
perfectly valid mathematical definition:
\<close>
function ev :: "nat \<Rightarrow> bool"
where
"ev (2 * n) = True"
| "ev (2 * n + 1) = False"
apply atomize_elim
by arith+
termination by (relation "{}") simp
text \<open>
This general notion of pattern matching gives you a certain freedom
in writing down specifications. However, as always, such freedom should
be used with care:
If we leave the area of constructor
patterns, we have effectively departed from the world of functional
programming. This means that it is no longer possible to use the
code generator, and expect it to generate ML code for our
definitions. Also, such a specification might not work very well together with
simplification. Your mileage may vary.
\<close>
subsection \<open>Conditional equations\<close>
text \<open>
The function package also supports conditional equations, which are
similar to guards in a language like Haskell. Here is Euclid's
algorithm written with conditional patterns\footnote{Note that the
patterns are also overlapping in the base case}:
\<close>
function gcd :: "nat \<Rightarrow> nat \<Rightarrow> nat"
where
"gcd x 0 = x"
| "gcd 0 y = y"
| "x < y \<Longrightarrow> gcd (Suc x) (Suc y) = gcd (Suc x) (y - x)"
| "\<not> x < y \<Longrightarrow> gcd (Suc x) (Suc y) = gcd (x - y) (Suc y)"
by (atomize_elim, auto, arith)
termination by lexicographic_order
text \<open>
By now, you can probably guess what the proof obligations for the
pattern completeness and compatibility look like.
Again, functions with conditional patterns are not supported by the
code generator.
\<close>
subsection \<open>Pattern matching on strings\<close>
text \<open>
As strings (as lists of characters) are normal datatypes, pattern
matching on them is possible, but somewhat problematic. Consider the
following definition:
\end{isamarkuptext}
\noindent\cmd{fun} @{text "check :: \"string \<Rightarrow> bool\""}\\%
\cmd{where}\\%
\hspace*{2ex}@{text "\"check (''good'') = True\""}\\%
@{text "| \"check s = False\""}
\begin{isamarkuptext}
\noindent An invocation of the above \cmd{fun} command does not
terminate. What is the problem? Strings are lists of characters, and
characters are a datatype with a lot of constructors. Splitting the
catch-all pattern thus leads to an explosion of cases, which cannot
be handled by Isabelle.
There are two things we can do here. Either we write an explicit
@{text "if"} on the right hand side, or we can use conditional patterns:
\<close>
function check :: "string \<Rightarrow> bool"
where
"check (''good'') = True"
| "s \<noteq> ''good'' \<Longrightarrow> check s = False"
by auto
termination by (relation "{}") simp
section \<open>Partiality\<close>
text \<open>
In HOL, all functions are total. A function @{term "f"} applied to
@{term "x"} always has the value @{term "f x"}, and there is no notion
of undefinedness.
This is why we have to do termination
proofs when defining functions: The proof justifies that the
function can be defined by wellfounded recursion.
However, the \cmd{function} package does support partiality to a
certain extent. Let's look at the following function which looks
for a zero of a given function f.
\<close>
function (*<*)(domintros)(*>*)findzero :: "(nat \<Rightarrow> nat) \<Rightarrow> nat \<Rightarrow> nat"
where
"findzero f n = (if f n = 0 then n else findzero f (Suc n))"
by pat_completeness auto
text \<open>
\noindent Clearly, any attempt of a termination proof must fail. And without
that, we do not get the usual rules @{text "findzero.simps"} and
@{text "findzero.induct"}. So what was the definition good for at all?
\<close>
subsection \<open>Domain predicates\<close>
text \<open>
The trick is that Isabelle has not only defined the function @{const findzero}, but also
a predicate @{term "findzero_dom"} that characterizes the values where the function
terminates: the \emph{domain} of the function. If we treat a
partial function just as a total function with an additional domain
predicate, we can derive simplification and
induction rules as we do for total functions. They are guarded
by domain conditions and are called @{text psimps} and @{text
pinduct}:
\<close>
text \<open>
\noindent\begin{minipage}{0.79\textwidth}@{thm[display,margin=85] findzero.psimps}\end{minipage}
\hfill(@{thm [source] "findzero.psimps"})
\vspace{1em}
\noindent\begin{minipage}{0.79\textwidth}@{thm[display,margin=85] findzero.pinduct}\end{minipage}
\hfill(@{thm [source] "findzero.pinduct"})
\<close>
text \<open>
Remember that all we
are doing here is use some tricks to make a total function appear
as if it was partial. We can still write the term @{term "findzero
(\<lambda>x. 1) 0"} and like any other term of type @{typ nat} it is equal
to some natural number, although we might not be able to find out
which one. The function is \emph{underdefined}.
But it is defined enough to prove something interesting about it. We
can prove that if @{term "findzero f n"}
terminates, it indeed returns a zero of @{term f}:
\<close>
lemma findzero_zero: "findzero_dom (f, n) \<Longrightarrow> f (findzero f n) = 0"
text \<open>\noindent We apply induction as usual, but using the partial induction
rule:\<close>
apply (induct f n rule: findzero.pinduct)
text \<open>\noindent This gives the following subgoals:
@{subgoals[display,indent=0]}
\noindent The hypothesis in our lemma was used to satisfy the first premise in
the induction rule. However, we also get @{term
"findzero_dom (f, n)"} as a local assumption in the induction step. This
allows unfolding @{term "findzero f n"} using the @{text psimps}
rule, and the rest is trivial.
\<close>
apply (simp add: findzero.psimps)
done
text \<open>
Proofs about partial functions are often not harder than for total
functions. Fig.~\ref{findzero_isar} shows a slightly more
complicated proof written in Isar. It is verbose enough to show how
partiality comes into play: From the partial induction, we get an
additional domain condition hypothesis. Observe how this condition
is applied when calls to @{term findzero} are unfolded.
\<close>
text_raw \<open>
\begin{figure}
\hrule\vspace{6pt}
\begin{minipage}{0.8\textwidth}
\isabellestyle{it}
\isastyle\isamarkuptrue
\<close>
lemma "\<lbrakk>findzero_dom (f, n); x \<in> {n ..< findzero f n}\<rbrakk> \<Longrightarrow> f x \<noteq> 0"
proof (induct rule: findzero.pinduct)
fix f n assume dom: "findzero_dom (f, n)"
and IH: "\<lbrakk>f n \<noteq> 0; x \<in> {Suc n ..< findzero f (Suc n)}\<rbrakk> \<Longrightarrow> f x \<noteq> 0"
and x_range: "x \<in> {n ..< findzero f n}"
have "f n \<noteq> 0"
proof
assume "f n = 0"
with dom have "findzero f n = n" by (simp add: findzero.psimps)
with x_range show False by auto
qed
from x_range have "x = n \<or> x \<in> {Suc n ..< findzero f n}" by auto
thus "f x \<noteq> 0"
proof
assume "x = n"
with \<open>f n \<noteq> 0\<close> show ?thesis by simp
next
assume "x \<in> {Suc n ..< findzero f n}"
with dom and \<open>f n \<noteq> 0\<close> have "x \<in> {Suc n ..< findzero f (Suc n)}" by (simp add: findzero.psimps)
with IH and \<open>f n \<noteq> 0\<close>
show ?thesis by simp
qed
qed
text_raw \<open>
\isamarkupfalse\isabellestyle{tt}
\end{minipage}\vspace{6pt}\hrule
\caption{A proof about a partial function}\label{findzero_isar}
\end{figure}
\<close>
subsection \<open>Partial termination proofs\<close>
text \<open>
Now that we have proved some interesting properties about our
function, we should turn to the domain predicate and see if it is
actually true for some values. Otherwise we would have just proved
lemmas with @{term False} as a premise.
Essentially, we need some introduction rules for @{text
findzero_dom}. The function package can prove such domain
introduction rules automatically. But since they are not used very
often (they are almost never needed if the function is total), this
functionality is disabled by default for efficiency reasons. So we have to go
back and ask for them explicitly by passing the @{text
"(domintros)"} option to the function package:
\vspace{1ex}
\noindent\cmd{function} @{text "(domintros) findzero :: \"(nat \<Rightarrow> nat) \<Rightarrow> nat \<Rightarrow> nat\""}\\%
\cmd{where}\isanewline%
\ \ \ldots\\
\noindent Now the package has proved an introduction rule for @{text findzero_dom}:
\<close>
thm findzero.domintros
text \<open>
@{thm[display] findzero.domintros}
Domain introduction rules allow to show that a given value lies in the
domain of a function, if the arguments of all recursive calls
are in the domain as well. They allow to do a \qt{single step} in a
termination proof. Usually, you want to combine them with a suitable
induction principle.
Since our function increases its argument at recursive calls, we
need an induction principle which works \qt{backwards}. We will use
@{thm [source] inc_induct}, which allows to do induction from a fixed number
\qt{downwards}:
\begin{center}@{thm inc_induct}\hfill(@{thm [source] "inc_induct"})\end{center}
Figure \ref{findzero_term} gives a detailed Isar proof of the fact
that @{text findzero} terminates if there is a zero which is greater
or equal to @{term n}. First we derive two useful rules which will
solve the base case and the step case of the induction. The
induction is then straightforward, except for the unusual induction
principle.
\<close>
text_raw \<open>
\begin{figure}
\hrule\vspace{6pt}
\begin{minipage}{0.8\textwidth}
\isabellestyle{it}
\isastyle\isamarkuptrue
\<close>
lemma findzero_termination:
assumes "x \<ge> n" and "f x = 0"
shows "findzero_dom (f, n)"
proof -
have base: "findzero_dom (f, x)"
by (rule findzero.domintros) (simp add:\<open>f x = 0\<close>)
have step: "\<And>i. findzero_dom (f, Suc i)
\<Longrightarrow> findzero_dom (f, i)"
by (rule findzero.domintros) simp
from \<open>x \<ge> n\<close> show ?thesis
proof (induct rule:inc_induct)
show "findzero_dom (f, x)" by (rule base)
next
fix i assume "findzero_dom (f, Suc i)"
thus "findzero_dom (f, i)" by (rule step)
qed
qed
text_raw \<open>
\isamarkupfalse\isabellestyle{tt}
\end{minipage}\vspace{6pt}\hrule
\caption{Termination proof for @{text findzero}}\label{findzero_term}
\end{figure}
\<close>
text \<open>
Again, the proof given in Fig.~\ref{findzero_term} has a lot of
detail in order to explain the principles. Using more automation, we
can also have a short proof:
\<close>
lemma findzero_termination_short:
assumes zero: "x >= n"
assumes [simp]: "f x = 0"
shows "findzero_dom (f, n)"
using zero
by (induct rule:inc_induct) (auto intro: findzero.domintros)
text \<open>
\noindent It is simple to combine the partial correctness result with the
termination lemma:
\<close>
lemma findzero_total_correctness:
"f x = 0 \<Longrightarrow> f (findzero f 0) = 0"
by (blast intro: findzero_zero findzero_termination)
subsection \<open>Definition of the domain predicate\<close>
text \<open>
Sometimes it is useful to know what the definition of the domain
predicate looks like. Actually, @{text findzero_dom} is just an
abbreviation:
@{abbrev[display] findzero_dom}
The domain predicate is the \emph{accessible part} of a relation @{const
findzero_rel}, which was also created internally by the function
package. @{const findzero_rel} is just a normal
inductive predicate, so we can inspect its definition by
looking at the introduction rules @{thm [source] findzero_rel.intros}.
In our case there is just a single rule:
@{thm[display] findzero_rel.intros}
The predicate @{const findzero_rel}
describes the \emph{recursion relation} of the function
definition. The recursion relation is a binary relation on
the arguments of the function that relates each argument to its
recursive calls. In general, there is one introduction rule for each
recursive call.
The predicate @{term "Wellfounded.accp findzero_rel"} is the accessible part of
that relation. An argument belongs to the accessible part, if it can
be reached in a finite number of steps (cf.~its definition in @{text
"Wellfounded.thy"}).
Since the domain predicate is just an abbreviation, you can use
lemmas for @{const Wellfounded.accp} and @{const findzero_rel} directly. Some
lemmas which are occasionally useful are @{thm [source] accpI}, @{thm [source]
accp_downward}, and of course the introduction and elimination rules
for the recursion relation @{thm [source] "findzero_rel.intros"} and @{thm
[source] "findzero_rel.cases"}.
\<close>
section \<open>Nested recursion\<close>
text \<open>
Recursive calls which are nested in one another frequently cause
complications, since their termination proof can depend on a partial
correctness property of the function itself.
As a small example, we define the \qt{nested zero} function:
\<close>
function nz :: "nat \<Rightarrow> nat"
where
"nz 0 = 0"
| "nz (Suc n) = nz (nz n)"
by pat_completeness auto
text \<open>
If we attempt to prove termination using the identity measure on
naturals, this fails:
\<close>
termination
apply (relation "measure (\<lambda>n. n)")
apply auto
text \<open>
We get stuck with the subgoal
@{subgoals[display]}
Of course this statement is true, since we know that @{const nz} is
the zero function. And in fact we have no problem proving this
property by induction.
\<close>
(*<*)oops(*>*)
lemma nz_is_zero: "nz_dom n \<Longrightarrow> nz n = 0"
by (induct rule:nz.pinduct) (auto simp: nz.psimps)
text \<open>
We formulate this as a partial correctness lemma with the condition
@{term "nz_dom n"}. This allows us to prove it with the @{text
pinduct} rule before we have proved termination. With this lemma,
the termination proof works as expected:
\<close>
termination
by (relation "measure (\<lambda>n. n)") (auto simp: nz_is_zero)
text \<open>
As a general strategy, one should prove the statements needed for
termination as a partial property first. Then they can be used to do
the termination proof. This also works for less trivial
examples. Figure \ref{f91} defines the 91-function, a well-known
challenge problem due to John McCarthy, and proves its termination.
\<close>
text_raw \<open>
\begin{figure}
\hrule\vspace{6pt}
\begin{minipage}{0.8\textwidth}
\isabellestyle{it}
\isastyle\isamarkuptrue
\<close>
function f91 :: "nat \<Rightarrow> nat"
where
"f91 n = (if 100 < n then n - 10 else f91 (f91 (n + 11)))"
by pat_completeness auto
lemma f91_estimate:
assumes trm: "f91_dom n"
shows "n < f91 n + 11"
using trm by induct (auto simp: f91.psimps)
termination
proof
let ?R = "measure (\<lambda>x. 101 - x)"
show "wf ?R" ..
fix n :: nat assume "\<not> 100 < n" -- "Assumptions for both calls"
thus "(n + 11, n) \<in> ?R" by simp -- "Inner call"
assume inner_trm: "f91_dom (n + 11)" -- "Outer call"
with f91_estimate have "n + 11 < f91 (n + 11) + 11" .
with \<open>\<not> 100 < n\<close> show "(f91 (n + 11), n) \<in> ?R" by simp
qed
text_raw \<open>
\isamarkupfalse\isabellestyle{tt}
\end{minipage}
\vspace{6pt}\hrule
\caption{McCarthy's 91-function}\label{f91}
\end{figure}
\<close>
section \<open>Higher-Order Recursion\<close>
text \<open>
Higher-order recursion occurs when recursive calls
are passed as arguments to higher-order combinators such as @{const
map}, @{term filter} etc.
As an example, imagine a datatype of n-ary trees:
\<close>
datatype 'a tree =
Leaf 'a
| Branch "'a tree list"
text \<open>\noindent We can define a function which swaps the left and right subtrees recursively, using the
list functions @{const rev} and @{const map}:\<close>
fun mirror :: "'a tree \<Rightarrow> 'a tree"
where
"mirror (Leaf n) = Leaf n"
| "mirror (Branch l) = Branch (rev (map mirror l))"
text \<open>
Although the definition is accepted without problems, let us look at the termination proof:
\<close>
termination proof
text \<open>
As usual, we have to give a wellfounded relation, such that the
arguments of the recursive calls get smaller. But what exactly are
the arguments of the recursive calls when mirror is given as an
argument to @{const map}? Isabelle gives us the
subgoals
@{subgoals[display,indent=0]}
So the system seems to know that @{const map} only
applies the recursive call @{term "mirror"} to elements
of @{term "l"}, which is essential for the termination proof.
This knowledge about @{const map} is encoded in so-called congruence rules,
which are special theorems known to the \cmd{function} command. The
rule for @{const map} is
@{thm[display] map_cong}
You can read this in the following way: Two applications of @{const
map} are equal, if the list arguments are equal and the functions
coincide on the elements of the list. This means that for the value
@{term "map f l"} we only have to know how @{term f} behaves on
the elements of @{term l}.
Usually, one such congruence rule is
needed for each higher-order construct that is used when defining
new functions. In fact, even basic functions like @{const
If} and @{const Let} are handled by this mechanism. The congruence
rule for @{const If} states that the @{text then} branch is only
relevant if the condition is true, and the @{text else} branch only if it
is false:
@{thm[display] if_cong}
Congruence rules can be added to the
function package by giving them the @{term fundef_cong} attribute.
The constructs that are predefined in Isabelle, usually
come with the respective congruence rules.
But if you define your own higher-order functions, you may have to
state and prove the required congruence rules yourself, if you want to use your
functions in recursive definitions.
\<close>
(*<*)oops(*>*)
subsection \<open>Congruence Rules and Evaluation Order\<close>
text \<open>
Higher order logic differs from functional programming languages in
that it has no built-in notion of evaluation order. A program is
just a set of equations, and it is not specified how they must be
evaluated.
However for the purpose of function definition, we must talk about
evaluation order implicitly, when we reason about termination.
Congruence rules express that a certain evaluation order is
consistent with the logical definition.
Consider the following function.
\<close>
function f :: "nat \<Rightarrow> bool"
where
"f n = (n = 0 \<or> f (n - 1))"
(*<*)by pat_completeness auto(*>*)
text \<open>
For this definition, the termination proof fails. The default configuration
specifies no congruence rule for disjunction. We have to add a
congruence rule that specifies left-to-right evaluation order:
\vspace{1ex}
\noindent @{thm disj_cong}\hfill(@{thm [source] "disj_cong"})
\vspace{1ex}
Now the definition works without problems. Note how the termination
proof depends on the extra condition that we get from the congruence
rule.
However, as evaluation is not a hard-wired concept, we
could just turn everything around by declaring a different
congruence rule. Then we can make the reverse definition:
\<close>
lemma disj_cong2[fundef_cong]:
"(\<not> Q' \<Longrightarrow> P = P') \<Longrightarrow> (Q = Q') \<Longrightarrow> (P \<or> Q) = (P' \<or> Q')"
by blast
fun f' :: "nat \<Rightarrow> bool"
where
"f' n = (f' (n - 1) \<or> n = 0)"
text \<open>
\noindent These examples show that, in general, there is no \qt{best} set of
congruence rules.
However, such tweaking should rarely be necessary in
practice, as most of the time, the default set of congruence rules
works well.
\<close>
end
|
"It was in the distillation of lavender, mixed with the peppery and nutmeg scent of burnt wood, that I recognised the land of Provence, its ruggedness and its mystery." - Oliver Baussan, Founder of L'OCCITANE. Discover our L'Occitan Body & Bath collection for men. |
For the Ronbrock method, we need to solve a linear system of the form
$$
M_{ij}x_{j}=b_{i} \;,
$$
with M a square matrix (repeated indecies imply summation).
Such systems are soved by (among other methods) the so-called LU factorization (or decomposition),
where you decompose $M_{ij}=L_{ik}U_{kj}$ with $L_{i, j>i}=0$, $L_{i, j=i}=1$, $U_{i,j<i}=0$.
That is if $M$ is $N \times N$ matrix, L,U are defined as
\begin{align}
&L=\left( \begin{matrix}
1 & 0 & 0 & 0 & \dots &0 & 0 \\
L_{2,1} & 1 & 0 & 0 & \dots &0 & 0\\
L_{3,1} & L_{3,2} & 1 & 0 & \dots &0 & 0 \\
\vdots & \vdots & \vdots & \ddots & \dots & \vdots & \vdots \\
L_{N-1, 1} & L_{N-1, 2} & L_{N-1, 3} & L_{N-1, 4} & \dots & 1 & 0 \\
L_{N, 1} & L_{N, 2} & L_{N, 3} & L_{N, 4} & \dots & L_{N, N-1} & 1 \\
\end{matrix}\right) \;, \\
%
&U=\left( \begin{matrix}
U_{1,1} & U_{1,2} & U_{1,3} & U_{1,4} & \dots & U_{1,N-1} & U_{1,N} \\
0 & U_{2,2} & U_{2,3} & U_{2,4} & \dots & U_{2,N-1} & U_{2,N}\\
0 & 0 & U_{3,3} & U_{3,4} & \dots & U_{3,N-1} & U_{3,N} \\
\vdots & \vdots & \vdots & \ddots & \dots & \vdots & \vdots \\
0 & 0 & 0 &0 & \dots & U_{N-1,N-1} & U_{N-1,N} \\
0 & 0 & 0& 0 & \dots & 0 &U_{N,N} \\
\end{matrix}\right)
%
\end{align}
Then we have in general $M_{i, j} = \sum_{k=1}^{i}L_{i,k}U_{k,j}$. Since
$L_{i, k \geq i}=0$ and $U_{k>j,j}=0$, the sum runs up to $j$ if $i \geq j$ and
$i$ if $i \leq j$ (for $i=j$ then both are correct). That is
$$
M_{i, j \geq i} = \sum_{k=1}^{i-1}L_{i,k}U_{k,j}+ U_{i,j} \Rightarrow
U_{i,j }=M_{i,j } - \sum_{k=1}^{i-1}L_{i,k}U_{k,j }\; , \;\;\; j \geq i \\[0.5cm]
M_{i, j \leq i} = \sum_{k=1}^{j-1}L_{i,k}U_{k,j} +L_{i,j}U_{j,j} \Rightarrow
L_{i,j}=\left( M_{i,j} - \sum_{k=1}^{j-1}L_{i,k}U_{k,j} \right) U_{jj}^{-1} , \;\;\; j \leq i
$$
Since $U$ and $L$ are triangular matrices, we can solve these two systems sequentially
$$
L_{i,k}y_{k}=b_{k} \\
U_{k,j}x_{j}=y_{k},
$$
since
$$
y_1 = b_{1} \\
L_{2,1}y_{1}+y_{2}=b_{2} \Rightarrow y_{2}=b_{2}-L_{2,1}y_{1} \\
\vdots \\
y_{i}=b_{i} - \sum_{j=1}^{i-1}L_{i,j}y_{j}
$$
and
$$
U_{N,N}x_{N}=y_{N} \Rightarrow x_{N}=y_{N}/U_{N,N}\\
U_{N-1,N}x_{N}+U_{N-1,N-1}x_{N-1}=y_{N-1} \Rightarrow x_{N-1}=\left(y_{N-1} -U_{N-1,N}x_{N} \right)/U_{N-1,N-1} \\
\vdots \\
x_{i}=\dfrac{y_{i} -\displaystyle\sum_{j=i+1}^{N} U_{i,j}x_{j} }{U_{i,i}}
$$
Since $U_{i,i}$ appears to denominator, if the diagonal terms of $U$ are small (or god forbid they vanish), we would have a problem.
To solve this problem we do $LUP$ decomposition, where $L \; U=P \; M$ with $P$ a permutation matrix so that the diagonal of $U$ has the dominant components in each row.
Then solving $M x =b$ is equavalent to solving $\left( P \; M \right) x =P \; b$ with LU decomposition of
$P \; M$. That is x solves both systems (no need to permute x).
There is a clever way to make the docomposition faster. This is by initializing
$L=1_{N \times N}$ and $U=M$. Then we have the follwing algorithm for LU decomposition without
pivoting:
```bash
Input: M, N
#M: matrix
#N: size of M
#initialize U
U=M
#initialize L
L=Unit(N,N)
for k in [2,...,N] do
for i in [k,...,N] do
L[i][k-1]=U[i][k-1]/U[k-1][k-1]
for j in [k-1,...,N] do
U[i][j]=U[i][j]-L[i][k-1]*U[k-1][j]
done
done
done
```
I will not write the algorithm including pivoting, as the code in python will not be different.
```python
import numpy as np
```
```python
def ind_max(row,N):
'''
Find the index of the maximum of a list (row) of lentgth N.
'''
_in=0
_max=row[0]
i=0
while i<N:#the end of the row should be included (convension in how I use LUP..)
if row[i]>_max:
_max=row[i]
_in=i
i+=1
return _in
def row_swap(A,index_1,index_2,N):
'''
row_swap takes a N*N array and interchanges
row index_1 with row index_2.
'''
for i in range(N):
tmp=A[index_1][i]
A[index_1][i]=A[index_2][i]
A[index_2][i]=tmp
```
```python
#This is the same as in the main notebook, but here I use permutation matrix instead of a permutation vector.
#The actual algorithm does not change, as you don't realy care about the definition of the permutation matrix
#or vector.
def LUP(M,N,_tiny=1e-20):
U=[ [ M[i][j] for j in range(N)] for i in range(N) ]
L=[ [ 0 if i!=j else 1 for j in range(N)] for i in range(N) ]
P=[ [ 0 if i!=j else 1 for j in range(N)] for i in range(N) ]
for k in range(1,N):
for i in range(k,N):
#find the index of the maximum in column
_col=[np.abs(U[_r][k-1]) for _r in range(k-1,N)]
#find the index of the maximum of _col
# notice that the length of _col is N-(k-1)
len_col=N-(k-1)
pivot=ind_max( _col ,len_col) + k - 1 #convert the index of _col (it has a length of len_col) to the index of a row of U
##################################################
#this was in LU_julia (instead of "<_tiny" it had "== 0").
#if you remove it, then you get a lot of infinities
#it has to do with the fact that if U[pivot][k-1] <_tiny , then U[k-1][k-1] will be a zero,
#L[i][k-1] explodes.
#You are allowed to skip this i, then, because if U[pivot][k-1] <_tiny , then all U[i][k-1] are small!
#Check that this is true by uncommenting print(_col)
if np.abs(U[pivot][k-1]) < _tiny :
#print(_col)
break
###################################################
#if the maximum is not at k-1, swap!
if pivot != k-1 :
# Permute rows k-1 and pivot in U
row_swap(P,k-1,pivot,N)
tmpU=[U[k-1][_r] for _r in range(k-1,N)]
#print(U)
for _r in range(k-1,N):
U[k-1][_r]=U[pivot][_r]
#print(U)
for _r in range(k-1,N):
U[pivot][_r]=tmpU[_r-(k-1)]#again we have to convert the index of tmpU
#print(U)
#print("=========================")
tmpL=[L[k-1][_r] for _r in range(k-1)]
#print(L)
for _r in range(k-1):
L[k-1][_r]=L[pivot][_r]
#print(L)
for _r in range(k-1):
L[pivot][_r]=tmpL[_r]
#print(L)
#print("========================")
L[i][k-1]=U[i][k-1]/U[k-1][k-1]
for j in range(k-1,N):
U[i][j]=U[i][j]-L[i][k-1]*U[k-1][j]
return L,U,P
```
```python
def Dot(M,x,N):
'''
Product of N*N matrix M with vector x.
'''
c=[0 for i in range(N) ]
for i in range(N):
for j in range(N):
c[i]+=M[i][j]*x[j]
return c
def Sum(List,N):
'''
Calculates the sum of a List of size N
'''
s=0
for i in range(N):
s+=List[i]
return s
```
```python
def Solve_LU(L,U,P,b,N):
'''
This solves P*M*x=P*b (x is also the solution to M*x=b)
Input:
L,U,P= LUP decomposition of M. with P*M=L*U
b=the right hand side of the equation
N=the number of equations
'''
b=Dot(P,b,N)
d=[0 for i in range(N) ]
x=[0 for i in range(N) ]
d[0]=b[0]
for i in range(1,N):
d[i]=b[i]-Sum( [L[i][j]*d[j] for j in range(i)],i )
x[N-1] = d[N-1]/U[N-1][N-1]
for i in range(N-2,-1,-1):
x[i]=(d[i]-Sum( [U[i][j]*x[j] for j in range(i+1,N)],N-(i+1) ))/U[i][i]
return x
```
## tests
```python
```
```python
#check if Solve_LU works
if True:
NT=500#NT tests
N=4#N*N matrices
testSol=[0 for i in range(NT)]
for i in range(NT):
#M=np.random.randint(-3,3,size=[N,N])
b=np.random.rand(N)*13.-6.5
M=np.random.rand(N,N)*4-2
L,U,P=LUP(M,N)
x=Solve_LU(L,U,P,b,N)
testSol[i]=np.array(Dot(M,x,N))-np.array(b)
print(np.max(testSol))
```
3.268496584496461e-13
```python
from scipy.linalg import lu_factor,lu_solve,lu
```
```python
#check LUP against numpy.
#in test I will have the maximum difference between my L,U with what np.lu returns,
#and the difference between my L*U-P*M. So, test should be an array with small numbers!
#even when I get difference with numpy it is not important, because the decomposition is still correct
#(no nan or inf)!!!!
#change to True to run tests
if True:
NT=500#NT tests
N=10#N*N matrices
testL=[0 for i in range(NT)]
testU=[0 for i in range(NT)]
testM=[0 for i in range(NT)]
for i in range(NT):
#M=np.random.randint(-3,3,size=[N,N])
M=np.random.rand(N,N)*4-2
L,U,P=LUP(M,N)
Ps,Ls,Us=lu(M)
testU[i]=np.max(np.array(U)-Us)
testL[i]=np.max(np.array(L)-Ls)
testM[i]=np.max(np.dot(L,U)-np.dot( P,M) )
if testL[i] > 1e-5:
#print(np.array(L))
#print(Ls)
#print([U[_t][_t] for _t in range(N)])
print(testM[i])
pass
print(np.max(testU) , np.max(testL) , np.max(testM))
```
1.865174681370263e-14 6.38378239159465e-15 1.7763568394002505e-15
```python
```
```python
```
|
\subsection{Vector Autoregression (VAR)}
We consider a vector of observables, not just one
Autoregressive (AR) model for a vector.
VAR(p) looks \(p\) back.
The AR(\(p\)) model is:
\(y_t=\alpha + \sum_{i=1}^p\beta y_{t-i}+\epsilon_t\)
VAR(\(p\)) generalises this to where \(y_t\) is a vector. We define VAR(\(p\)) as:
\(y_t\)
\(y_t=c + \sum_{i=1}^pA_i y_{t-i}+\epsilon_t\)
|
module Prelude
( module P
) where
import Data.Tuple as P (fst,snd)
import Data.String as P (String)
import GHC.Show as P (Show(..))
import Data.Int as P (Int)
import Data.Bool as P (Bool(..),not)
import Data.Monoid as P (Monoid(..))
import Data.Semigroup as P (Semigroup(..))
import Data.Complex as P (Complex(..))
import Data.Functor as P (Functor(..))
import Data.Semiring as P (Semiring(..), Ring(..), (+), (*), (-))
import Control.Monad as P (Monad(..), (=<<))
import Control.Applicative as P (Applicative(..))
import Data.Eq as P (Eq(..))
import Data.Ord as P (Ord(..))
import GHC.Base as P (Double)
import Data.Function as P (($),(.),(&),id,flip)
import Data.Map as P (Map)
import GHC.Float as P (Floating(..))
import GHC.Real as P (fromIntegral, (/))
|
theory Basics
imports
HOL.Set_Interval
HOL.Semiring_Normalization
HOL.Real_Vector_Spaces
HOL.Power
HOL.Complex
Jordan_Normal_Form.Jordan_Normal_Form
begin
section \<open>Basic Set-Theoretic Results\<close>
lemma set_2_atLeast0 [simp]: "{0..<2::nat} = {0,1}" by auto
lemma set_2: "{..<2::nat} = {0,1}" by auto
lemma set_4_atLeast0 [simp]:"{0..<4::nat} = {0,1,2,3}" by auto
lemma set_4: "{..<4::nat} = {0,1,2,3}" by auto
lemma set_4_disj [simp]:
fixes i:: nat
assumes "i < 4"
shows "i = 0 \<or> i = 1 \<or> i = 2 \<or> i = 3"
using assms by auto
lemma set_8_atLeast0 [simp]: "{0..<8::nat} = {0,1,2,3,4,5,6,7}" by auto
lemma index_is_2 [simp]: "\<forall>i::nat. i \<noteq> Suc 0 \<longrightarrow> i \<noteq> 3 \<longrightarrow> 0 < i \<longrightarrow> i < 4 \<longrightarrow> i = 2" by simp
lemma index_sl_four [simp]: "\<forall>i::nat. i < 4 \<longrightarrow> i = 0 \<or> i = 1 \<or> i = 2 \<or> i = 3" by auto
section \<open>Basic Arithmetic Results\<close>
lemma index_div_eq [simp]:
fixes i::nat
shows "i\<in>{a*b..<(a+1)*b} \<Longrightarrow> i div b = a"
proof-
fix i::nat
assume a:"i\<in>{a*b..<(a+1)*b}"
then have "i div b \<ge> a"
by (metis Suc_eq_plus1 atLeastLessThan_iff le_refl semiring_normalization_rules(7) split_div')
moreover have "i div b < a+1"
using a by (simp add: less_mult_imp_div_less)
ultimately show "i div b = a" by simp
qed
lemma index_mod_eq [simp]:
fixes i::nat
shows "i\<in>{a*b..<(a+1)*b} \<Longrightarrow> i mod b = i-a*b"
by (simp add: modulo_nat_def)
lemma sqr_of_cmod_of_prod:
shows "(cmod (z1 * z2))\<^sup>2 = (cmod z1)\<^sup>2 * (cmod z2)\<^sup>2"
by (simp add: norm_mult power_mult_distrib)
lemma less_power_add_imp_div_less [simp]:
fixes i m n:: nat
assumes "i < 2^(m+n)"
shows "i div 2^n < 2^m"
using assms by (simp add: less_mult_imp_div_less power_add)
lemma div_mult_mod_eq_minus:
fixes i j:: nat
shows "(i div 2^n) * 2^n + i mod 2^n - (j div 2^n) * 2^n - j mod 2^n = i - j"
by (simp add: div_mult_mod_eq algebra_simps)
lemma neq_imp_neq_div_or_mod:
fixes i j:: nat
assumes "i \<noteq> j"
shows "i div 2^n \<noteq> j div 2^n \<or> i mod 2^n \<noteq> j mod 2^n"
using assms div_mult_mod_eq_minus
by (metis add.right_neutral cancel_div_mod_rules(2))
lemma index_one_mat_div_mod:
assumes "i < 2^(m+n)" and "j < 2^(m+n)"
shows "((1\<^sub>m(2^m) $$ (i div 2^n, j div 2^n))::complex) * 1\<^sub>m(2^n) $$ (i mod 2^n, j mod 2^n) = 1\<^sub>m(2^(m+n)) $$ (i, j)"
proof (cases "i = j")
case True
then show ?thesis by(simp add: assms)
next
case c1:False
have "i div 2^n \<noteq> j div 2^n \<or> i mod 2^n \<noteq> j mod 2^n"
using c1 neq_imp_neq_div_or_mod by simp
then have "1\<^sub>m (2^m) $$ (i div 2^n, j div 2^n) = 0 \<or> 1\<^sub>m (2^n) $$ (i mod 2^n, j mod 2^n) = 0"
using assms by simp
then show ?thesis
using assms by (simp add: c1)
qed
lemma sqr_of_sqrt_2 [simp]:
fixes z:: "complex"
shows "z * 2 / (complex_of_real (sqrt 2) * complex_of_real (sqrt 2)) = z"
by(metis nonzero_mult_div_cancel_right norm_numeral of_real_numeral of_real_power power2_eq_square
real_norm_def real_sqrt_abs real_sqrt_power zero_neq_numeral)
lemma two_div_sqrt_two [simp]:
shows "2 * complex_of_real (sqrt (1/2)) = complex_of_real (sqrt 2)"
apply(auto simp add: real_sqrt_divide algebra_simps)
by (metis divide_eq_0_iff nonzero_mult_div_cancel_left sqr_of_sqrt_2)
lemma two_div_two [simp]:
shows "2 div Suc (Suc 0) = 1" by simp
lemma two_mod_two [simp]:
shows "2 mod Suc (Suc 0) = 0" by (simp add: numeral_2_eq_2)
lemma three_div_two [simp]:
shows "3 div Suc (Suc 0) = 1" by (simp add: numeral_3_eq_3)
lemma three_mod_two [simp]:
shows "3 mod Suc (Suc 0) = 1" by (simp add: mod_Suc numeral_3_eq_3)
section \<open>Basic Results on Matrices\<close>
lemma index_matrix_prod [simp]:
assumes "i < dim_row A" and "j < dim_col B" and "dim_col A = dim_row B"
shows "(A * B) $$ (i,j) = (\<Sum>k<dim_row B. (A $$ (i,k)) * (B $$ (k,j)))"
using assms apply(simp add: scalar_prod_def atLeast0LessThan).
section \<open>Basic Results on Sums\<close>
lemma sum_insert [simp]:
assumes "x \<notin> F" and "finite F"
shows "(\<Sum>y\<in>insert x F. P y) = (\<Sum>y\<in>F. P y) + P x"
using assms insert_def by(simp add: add.commute)
lemma sum_of_index_diff [simp]:
fixes f:: "nat \<Rightarrow> 'a::comm_monoid_add"
shows "(\<Sum>i\<in>{a..<a+b}. f(i-a)) = (\<Sum>i\<in>{..<b}. f(i))"
proof (induction b)
case 0
then show ?case by simp
next
case (Suc b)
then show ?case by simp
qed
section \<open>Basic Results Involving the Exponential Function.\<close>
lemma exp_of_real_cnj:
fixes x ::real
shows "cnj (exp (\<i> * x)) = exp (-(\<i> * x))"
proof
show "Re (cnj (exp (\<i> * x))) = Re (exp (-(\<i> * x)))"
using Re_exp by simp
show "Im (cnj (exp (\<i> * x))) = Im (exp (-(\<i> * x)))"
using Im_exp by simp
qed
lemma exp_of_real_cnj2:
fixes x ::real
shows "cnj (exp (-(\<i> * x))) = exp (\<i> * x)"
proof
show "Re (cnj (exp (-(\<i> * x)))) = Re (exp (\<i> * x))"
using Re_exp by simp
show "Im (cnj (exp (-(\<i> * x)))) = Im (exp (\<i> * x))"
using Im_exp by simp
qed
lemma exp_of_half_pi:
fixes x:: real
assumes "x = pi/2"
shows "exp (\<i> * complex_of_real x) = \<i>"
using assms cis_conv_exp cis_pi_half by fastforce
lemma exp_of_minus_half_pi:
fixes x:: real
assumes "x = pi/2"
shows "exp (-(\<i> * complex_of_real x)) = -\<i>"
using assms cis_conv_exp cis_minus_pi_half by fastforce
lemma exp_of_real:
fixes x:: real
shows "exp (\<i> * x) = cos x + \<i> * (sin x)"
proof
show "Re (exp (\<i> * x)) = Re ((cos x) + \<i> * (sin x))"
using Re_exp by simp
show "Im (exp (\<i> * x)) = Im ((cos x) + \<i> * (sin x))"
using Im_exp by simp
qed
lemma exp_of_real_inv:
fixes x:: real
shows "exp (-(\<i> * x)) = cos x - \<i> * (sin x)"
proof
show "Re (exp (-(\<i> * x))) = Re ((cos x) - \<i> * (sin x))"
using Re_exp by simp
show "Im (exp (-(\<i> * x))) = Im ((cos x) - \<i> * (sin x))"
using Im_exp by simp
qed
section \<open>Basic Results with Trigonometric Functions.\<close>
subsection \<open>Basic Inequalities\<close>
lemma sin_squared_le_one:
fixes x:: real
shows "(sin x)\<^sup>2 \<le> 1"
using abs_sin_le_one abs_square_le_1 by blast
lemma cos_squared_le_one:
fixes x:: real
shows "(cos x)\<^sup>2 \<le> 1"
using abs_cos_le_one abs_square_le_1 by blast
subsection \<open>Basic Equalities\<close>
lemma sin_of_quarter_pi:
fixes x:: real
assumes "x = pi/2"
shows "sin (x/2) = (sqrt 2)/2"
by (auto simp add: assms sin_45)
lemma cos_of_quarter_pi:
fixes x:: real
assumes "x = pi/2"
shows "cos (x/2) = (sqrt 2)/2"
by (auto simp add: assms cos_45)
end |
Require Import
CertifiedExtraction.Extraction.External.Core
CertifiedExtraction.Extraction.External.GenericMethods.
Require Import Coq.Lists.List.
Lemma CompileCallFacadeImplementationWW:
forall {av} {env} fWW,
forall fpointer varg (arg: W) tenv,
GLabelMap.MapsTo fpointer (Axiomatic (FacadeImplementationWW av fWW)) env ->
forall vret ext,
vret ∉ ext ->
NotInTelescope vret tenv ->
StringMap.MapsTo varg (wrap arg) ext ->
{{ tenv }}
Call vret fpointer (varg :: nil)
{{ [[ `vret ->> (fWW arg) as _]]:: tenv }} ∪ {{ ext }} // env.
Proof.
repeat match goal with
| _ => SameValues_Facade_t_step
| _ => facade_cleanup_call
end; facade_eauto.
Qed.
Lemma CompileCallFacadeImplementationWW_full:
forall {av} {env} fWW,
forall fpointer varg (arg: W) tenv,
GLabelMap.MapsTo fpointer (Axiomatic (FacadeImplementationWW av fWW)) env ->
forall vret ext p,
vret ∉ ext ->
varg ∉ ext ->
NotInTelescope vret tenv ->
NotInTelescope varg tenv ->
vret <> varg ->
{{ tenv }}
p
{{ [[ `varg ->> arg as _]]:: tenv }} ∪ {{ ext }} // env ->
{{ tenv }}
Seq p (Call vret fpointer (varg :: nil))
{{ [[ `vret ->> (fWW arg) as _]]:: tenv }} ∪ {{ ext }} // env.
Proof.
repeat hoare.
repeat match goal with
| _ => SameValues_Facade_t_step
| _ => facade_cleanup_call
end; facade_eauto.
Qed.
|
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
⊢ RepresentablyFlat (𝟭 C)
[PROOFSTEP]
constructor
[GOAL]
case cofiltered
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
⊢ ∀ (X : C), IsCofiltered (StructuredArrow X (𝟭 C))
[PROOFSTEP]
intro X
[GOAL]
case cofiltered
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
⊢ IsCofiltered (StructuredArrow X (𝟭 C))
[PROOFSTEP]
haveI : Nonempty (StructuredArrow X (𝟭 C)) := ⟨StructuredArrow.mk (𝟙 _)⟩
[GOAL]
case cofiltered
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
⊢ IsCofiltered (StructuredArrow X (𝟭 C))
[PROOFSTEP]
suffices : IsCofilteredOrEmpty (StructuredArrow X (𝟭 C))
[GOAL]
case cofiltered
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this✝ : Nonempty (StructuredArrow X (𝟭 C))
this : IsCofilteredOrEmpty (StructuredArrow X (𝟭 C))
⊢ IsCofiltered (StructuredArrow X (𝟭 C))
[PROOFSTEP]
constructor
[GOAL]
case this
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
⊢ IsCofilteredOrEmpty (StructuredArrow X (𝟭 C))
[PROOFSTEP]
constructor
[GOAL]
case this.cone_objs
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
⊢ ∀ (X_1 Y : StructuredArrow X (𝟭 C)), ∃ W x x, True
[PROOFSTEP]
intro Y Z
[GOAL]
case this.cone_objs
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
⊢ ∃ W x x, True
[PROOFSTEP]
use StructuredArrow.mk (𝟙 _)
[GOAL]
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
⊢ ∃ x x, True
[PROOFSTEP]
use StructuredArrow.homMk Y.hom (by erw [Functor.id_map, Category.id_comp])
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
⊢ (StructuredArrow.mk (𝟙 X)).hom ≫ (𝟭 C).map Y.hom = Y.hom
[PROOFSTEP]
erw [Functor.id_map, Category.id_comp]
[GOAL]
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
⊢ ∃ x, True
[PROOFSTEP]
use StructuredArrow.homMk Z.hom (by erw [Functor.id_map, Category.id_comp])
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
⊢ (StructuredArrow.mk (𝟙 X)).hom ≫ (𝟭 C).map Z.hom = Z.hom
[PROOFSTEP]
erw [Functor.id_map, Category.id_comp]
[GOAL]
case this.cone_maps
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
⊢ ∀ ⦃X_1 Y : StructuredArrow X (𝟭 C)⦄ (f g : X_1 ⟶ Y), ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
intro Y Z f g
[GOAL]
case this.cone_maps
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
use StructuredArrow.mk (𝟙 _)
[GOAL]
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ ∃ h, h ≫ f = h ≫ g
[PROOFSTEP]
use StructuredArrow.homMk Y.hom (by erw [Functor.id_map, Category.id_comp])
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ (StructuredArrow.mk (𝟙 X)).hom ≫ (𝟭 C).map Y.hom = Y.hom
[PROOFSTEP]
erw [Functor.id_map, Category.id_comp]
[GOAL]
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ StructuredArrow.homMk Y.hom ≫ f = StructuredArrow.homMk Y.hom ≫ g
[PROOFSTEP]
ext
[GOAL]
case h.h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ (StructuredArrow.homMk Y.hom ≫ f).right = (StructuredArrow.homMk Y.hom ≫ g).right
[PROOFSTEP]
trans Z.hom
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ (StructuredArrow.homMk Y.hom ≫ f).right = Z.hom
[PROOFSTEP]
simp
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₂, u₂} D
E : Type u₃
inst✝ : Category.{v₃, u₃} E
X : C
this : Nonempty (StructuredArrow X (𝟭 C))
Y Z : StructuredArrow X (𝟭 C)
f g : Y ⟶ Z
⊢ Z.hom = (StructuredArrow.homMk Y.hom ≫ g).right
[PROOFSTEP]
simp
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
⊢ RepresentablyFlat (F ⋙ G)
[PROOFSTEP]
constructor
[GOAL]
case cofiltered
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
⊢ ∀ (X : E), IsCofiltered (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
intro X
[GOAL]
case cofiltered
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
⊢ IsCofiltered (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
have : Nonempty (StructuredArrow X (F ⋙ G)) :=
by
have f₁ : StructuredArrow X G := Nonempty.some inferInstance
have f₂ : StructuredArrow f₁.right F := Nonempty.some inferInstance
exact ⟨StructuredArrow.mk (f₁.hom ≫ G.map f₂.hom)⟩
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
⊢ Nonempty (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
have f₁ : StructuredArrow X G := Nonempty.some inferInstance
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
f₁ : StructuredArrow X G
⊢ Nonempty (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
have f₂ : StructuredArrow f₁.right F := Nonempty.some inferInstance
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
f₁ : StructuredArrow X G
f₂ : StructuredArrow f₁.right F
⊢ Nonempty (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
exact ⟨StructuredArrow.mk (f₁.hom ≫ G.map f₂.hom)⟩
[GOAL]
case cofiltered
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
⊢ IsCofiltered (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
suffices : IsCofilteredOrEmpty (StructuredArrow X (F ⋙ G))
[GOAL]
case cofiltered
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this✝ : Nonempty (StructuredArrow X (F ⋙ G))
this : IsCofilteredOrEmpty (StructuredArrow X (F ⋙ G))
⊢ IsCofiltered (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
constructor
[GOAL]
case this
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
⊢ IsCofilteredOrEmpty (StructuredArrow X (F ⋙ G))
[PROOFSTEP]
constructor
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
⊢ ∀ (X_1 Y : StructuredArrow X (F ⋙ G)), ∃ W x x, True
[PROOFSTEP]
intro Y Z
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
⊢ ∃ W x x, True
[PROOFSTEP]
let W := @IsCofiltered.min (StructuredArrow X G) _ _ (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
⊢ ∃ W x x, True
[PROOFSTEP]
let Y' : W ⟶ _ := IsCofiltered.minToLeft _ _
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
⊢ ∃ W x x, True
[PROOFSTEP]
let Z' : W ⟶ _ := IsCofiltered.minToRight _ _
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
⊢ ∃ W x x, True
[PROOFSTEP]
let W' := @IsCofiltered.min (StructuredArrow W.right F) _ _ (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ ∃ W x x, True
[PROOFSTEP]
let Y'' : W' ⟶ _ := IsCofiltered.minToLeft _ _
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Y'' : W' ⟶ StructuredArrow.mk Y'.right :=
IsCofiltered.minToLeft (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ ∃ W x x, True
[PROOFSTEP]
let Z'' : W' ⟶ _ := IsCofiltered.minToRight _ _
[GOAL]
case this.cone_objs
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Y'' : W' ⟶ StructuredArrow.mk Y'.right :=
IsCofiltered.minToLeft (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Z'' : W' ⟶ StructuredArrow.mk Z'.right :=
IsCofiltered.minToRight (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ ∃ W x x, True
[PROOFSTEP]
use StructuredArrow.mk (W.hom ≫ G.map W'.hom)
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Y'' : W' ⟶ StructuredArrow.mk Y'.right :=
IsCofiltered.minToLeft (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Z'' : W' ⟶ StructuredArrow.mk Z'.right :=
IsCofiltered.minToRight (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ ∃ x x, True
[PROOFSTEP]
use StructuredArrow.homMk Y''.right (by simp [← G.map_comp])
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Y'' : W' ⟶ StructuredArrow.mk Y'.right :=
IsCofiltered.minToLeft (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Z'' : W' ⟶ StructuredArrow.mk Z'.right :=
IsCofiltered.minToRight (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ (StructuredArrow.mk (W.hom ≫ G.map W'.hom)).hom ≫ (F ⋙ G).map Y''.right = Y.hom
[PROOFSTEP]
simp [← G.map_comp]
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Y'' : W' ⟶ StructuredArrow.mk Y'.right :=
IsCofiltered.minToLeft (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Z'' : W' ⟶ StructuredArrow.mk Z'.right :=
IsCofiltered.minToRight (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ ∃ x, True
[PROOFSTEP]
use StructuredArrow.homMk Z''.right (by simp [← G.map_comp])
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
W : StructuredArrow X G := IsCofiltered.min (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Y' : W ⟶ StructuredArrow.mk Y.hom := IsCofiltered.minToLeft (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
Z' : W ⟶ StructuredArrow.mk Z.hom := IsCofiltered.minToRight (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
W' : StructuredArrow W.right F := IsCofiltered.min (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Y'' : W' ⟶ StructuredArrow.mk Y'.right :=
IsCofiltered.minToLeft (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
Z'' : W' ⟶ StructuredArrow.mk Z'.right :=
IsCofiltered.minToRight (StructuredArrow.mk Y'.right) (StructuredArrow.mk Z'.right)
⊢ (StructuredArrow.mk (W.hom ≫ G.map W'.hom)).hom ≫ (F ⋙ G).map Z''.right = Z.hom
[PROOFSTEP]
simp [← G.map_comp]
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
⊢ ∀ ⦃X_1 Y : StructuredArrow X (F ⋙ G)⦄ (f g : X_1 ⟶ Y), ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
intro Y Z f g
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
let W :=
@IsCofiltered.eq (StructuredArrow X G) _ _ (StructuredArrow.mk Y.hom) (StructuredArrow.mk Z.hom)
(StructuredArrow.homMk (F.map f.right) (StructuredArrow.w f))
(StructuredArrow.homMk (F.map g.right) (StructuredArrow.w g))
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
let h : W ⟶ _ := IsCofiltered.eqHom _ _
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
let h_cond : h ≫ _ = h ≫ _ := IsCofiltered.eq_condition _ _
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
let W' :=
@IsCofiltered.eq (StructuredArrow W.right F) _ _ (StructuredArrow.mk h.right)
(StructuredArrow.mk (h.right ≫ F.map f.right)) (StructuredArrow.homMk f.right rfl)
(StructuredArrow.homMk g.right (congr_arg CommaMorphism.right h_cond).symm)
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
let h' : W' ⟶ _ := IsCofiltered.eqHom _ _
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h' : W' ⟶ StructuredArrow.mk h.right :=
IsCofiltered.eqHom (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
let h'_cond : h' ≫ _ = h' ≫ _ := IsCofiltered.eq_condition _ _
[GOAL]
case this.cone_maps
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h' : W' ⟶ StructuredArrow.mk h.right :=
IsCofiltered.eqHom (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h'_cond : h' ≫ StructuredArrow.homMk f.right = h' ≫ StructuredArrow.homMk g.right :=
IsCofiltered.eq_condition (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ ∃ W h, h ≫ f = h ≫ g
[PROOFSTEP]
use StructuredArrow.mk (W.hom ≫ G.map W'.hom)
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h' : W' ⟶ StructuredArrow.mk h.right :=
IsCofiltered.eqHom (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h'_cond : h' ≫ StructuredArrow.homMk f.right = h' ≫ StructuredArrow.homMk g.right :=
IsCofiltered.eq_condition (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ ∃ h, h ≫ f = h ≫ g
[PROOFSTEP]
use StructuredArrow.homMk h'.right (by simp [← G.map_comp])
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h' : W' ⟶ StructuredArrow.mk h.right :=
IsCofiltered.eqHom (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h'_cond : h' ≫ StructuredArrow.homMk f.right = h' ≫ StructuredArrow.homMk g.right :=
IsCofiltered.eq_condition (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ (StructuredArrow.mk (W.hom ≫ G.map W'.hom)).hom ≫ (F ⋙ G).map h'.right = Y.hom
[PROOFSTEP]
simp [← G.map_comp]
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h' : W' ⟶ StructuredArrow.mk h.right :=
IsCofiltered.eqHom (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h'_cond : h' ≫ StructuredArrow.homMk f.right = h' ≫ StructuredArrow.homMk g.right :=
IsCofiltered.eq_condition (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ StructuredArrow.homMk h'.right ≫ f = StructuredArrow.homMk h'.right ≫ g
[PROOFSTEP]
ext
[GOAL]
case h.h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₂, u₂} D
E : Type u₃
inst✝² : Category.{v₃, u₃} E
F : C ⥤ D
G : D ⥤ E
inst✝¹ : RepresentablyFlat F
inst✝ : RepresentablyFlat G
X : E
this : Nonempty (StructuredArrow X (F ⋙ G))
Y Z : StructuredArrow X (F ⋙ G)
f g : Y ⟶ Z
W : StructuredArrow X G :=
IsCofiltered.eq (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h : W ⟶ StructuredArrow.mk Y.hom :=
IsCofiltered.eqHom (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
h_cond : h ≫ StructuredArrow.homMk (F.map f.right) = h ≫ StructuredArrow.homMk (F.map g.right) :=
IsCofiltered.eq_condition (StructuredArrow.homMk (F.map f.right)) (StructuredArrow.homMk (F.map g.right))
W' : StructuredArrow W.right F := IsCofiltered.eq (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h' : W' ⟶ StructuredArrow.mk h.right :=
IsCofiltered.eqHom (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
h'_cond : h' ≫ StructuredArrow.homMk f.right = h' ≫ StructuredArrow.homMk g.right :=
IsCofiltered.eq_condition (StructuredArrow.homMk f.right) (StructuredArrow.homMk g.right)
⊢ (StructuredArrow.homMk h'.right ≫ f).right = (StructuredArrow.homMk h'.right ≫ g).right
[PROOFSTEP]
exact (congr_arg CommaMorphism.right h'_cond : _)
[GOAL]
C : Type u₁
inst✝³ : Category.{v₁, u₁} C
D : Type u₂
inst✝² : Category.{v₁, u₂} D
inst✝¹ : HasFiniteLimits C
F : C ⥤ D
inst✝ : PreservesFiniteLimits F
X : D
⊢ HasFiniteLimits (StructuredArrow X F)
[PROOFSTEP]
apply hasFiniteLimits_of_hasFiniteLimits_of_size.{v₁} (StructuredArrow X F)
[GOAL]
C : Type u₁
inst✝³ : Category.{v₁, u₁} C
D : Type u₂
inst✝² : Category.{v₁, u₂} D
inst✝¹ : HasFiniteLimits C
F : C ⥤ D
inst✝ : PreservesFiniteLimits F
X : D
⊢ ∀ (J : Type v₁) {𝒥 : SmallCategory J}, FinCategory J → HasLimitsOfShape J (StructuredArrow X F)
[PROOFSTEP]
intro J sJ fJ
[GOAL]
C : Type u₁
inst✝³ : Category.{v₁, u₁} C
D : Type u₂
inst✝² : Category.{v₁, u₂} D
inst✝¹ : HasFiniteLimits C
F : C ⥤ D
inst✝ : PreservesFiniteLimits F
X : D
J : Type v₁
sJ : SmallCategory J
fJ : FinCategory J
⊢ HasLimitsOfShape J (StructuredArrow X F)
[PROOFSTEP]
constructor
-- porting note: instance was inferred automatically in Lean 3
[GOAL]
case has_limit
C : Type u₁
inst✝³ : Category.{v₁, u₁} C
D : Type u₂
inst✝² : Category.{v₁, u₂} D
inst✝¹ : HasFiniteLimits C
F : C ⥤ D
inst✝ : PreservesFiniteLimits F
X : D
J : Type v₁
sJ : SmallCategory J
fJ : FinCategory J
⊢ autoParam (∀ (F_1 : J ⥤ StructuredArrow X F), HasLimit F_1) _auto✝
[PROOFSTEP]
infer_instance
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
x : J
⊢ lift F hc s ≫ NatTrans.app (F.mapCone c).π x = NatTrans.app s.π x
[PROOFSTEP]
simp [lift, ← Functor.map_comp]
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
⊢ f₁ = f₂
[PROOFSTEP]
let α₁ : (F.mapCone c).toStructuredArrow ⋙ map f₁ ⟶ s.toStructuredArrow :=
{ app := fun X => eqToHom (by simp [← h₁])
naturality := fun j₁ j₂ φ =>
by
ext
-- porting note: Lean 3 proof was `simp` but `Comma.eqToHom_right`
-- isn't firing for some reason
-- Asked here https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/simp.20not.20using.20a.20simp.20lemma/near/353943416
-- I'm now doing `simp, rw [Comma.eqToHom_right, Comma.eqToHom_right], simp` but
-- I squeezed the first `simp`.
simp only [Functor.mapCone_pt, Functor.comp_obj, Cone.toStructuredArrow_obj, Functor.mapCone_π_app, map_mk,
mk_right, Functor.comp_map, Cone.toStructuredArrow_map, comp_right, map_map_right, homMk_right]
rw [Comma.eqToHom_right, Comma.eqToHom_right]
-- this is a `simp` lemma
simp }
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
X : J
⊢ (Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁).obj X = (Cone.toStructuredArrow s).obj X
[PROOFSTEP]
simp [← h₁]
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
j₁ j₂ : J
φ : j₁ ⟶ j₂
⊢ (Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁).map φ ≫
(fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
j₂ =
(fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
j₁ ≫
(Cone.toStructuredArrow s).map φ
[PROOFSTEP]
ext
-- porting note: Lean 3 proof was `simp` but `Comma.eqToHom_right`
-- isn't firing for some reason
-- Asked here https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/simp.20not.20using.20a.20simp.20lemma/near/353943416
-- I'm now doing `simp, rw [Comma.eqToHom_right, Comma.eqToHom_right], simp` but
-- I squeezed the first `simp`.
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
j₁ j₂ : J
φ : j₁ ⟶ j₂
⊢ ((Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁).map φ ≫
(fun X =>
eqToHom
(_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
j₂).right =
((fun X =>
eqToHom
(_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
j₁ ≫
(Cone.toStructuredArrow s).map φ).right
[PROOFSTEP]
simp only [Functor.mapCone_pt, Functor.comp_obj, Cone.toStructuredArrow_obj, Functor.mapCone_π_app, map_mk, mk_right,
Functor.comp_map, Cone.toStructuredArrow_map, comp_right, map_map_right, homMk_right]
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
j₁ j₂ : J
φ : j₁ ⟶ j₂
⊢ φ ≫
(eqToHom
(_ :
StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π j₂)) = StructuredArrow.mk (NatTrans.app s.π j₂))).right =
(eqToHom
(_ :
StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π j₁)) = StructuredArrow.mk (NatTrans.app s.π j₁))).right ≫
φ
[PROOFSTEP]
rw [Comma.eqToHom_right, Comma.eqToHom_right]
-- this is a `simp` lemma
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
j₁ j₂ : J
φ : j₁ ⟶ j₂
⊢ φ ≫
eqToHom
(_ :
(StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π j₂))).right =
(StructuredArrow.mk (NatTrans.app s.π j₂)).right) =
eqToHom
(_ :
(StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π j₁))).right =
(StructuredArrow.mk (NatTrans.app s.π j₁)).right) ≫
φ
[PROOFSTEP]
simp
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
⊢ f₁ = f₂
[PROOFSTEP]
let α₂ : (F.mapCone c).toStructuredArrow ⋙ map f₂ ⟶ s.toStructuredArrow :=
{ app := fun X => eqToHom (by simp [← h₂])
naturality := fun _ _ _ =>
by
ext
-- porting note: see comments above. `simp` should close this goal (and did in Lean 3)
simp only [Functor.mapCone_pt, Functor.comp_obj, Cone.toStructuredArrow_obj, Functor.mapCone_π_app, map_mk,
mk_right, Functor.comp_map, Cone.toStructuredArrow_map, comp_right, map_map_right, homMk_right]
rw [Comma.eqToHom_right, Comma.eqToHom_right]
-- this is a `simp` lemma
simp }
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
X : J
⊢ (Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂).obj X = (Cone.toStructuredArrow s).obj X
[PROOFSTEP]
simp [← h₂]
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
x✝² x✝¹ : J
x✝ : x✝² ⟶ x✝¹
⊢ (Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂).map x✝ ≫
(fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
x✝¹ =
(fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
x✝² ≫
(Cone.toStructuredArrow s).map x✝
[PROOFSTEP]
ext
-- porting note: see comments above. `simp` should close this goal (and did in Lean 3)
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
x✝² x✝¹ : J
x✝ : x✝² ⟶ x✝¹
⊢ ((Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂).map x✝ ≫
(fun X =>
eqToHom
(_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
x✝¹).right =
((fun X =>
eqToHom
(_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X)))
x✝² ≫
(Cone.toStructuredArrow s).map x✝).right
[PROOFSTEP]
simp only [Functor.mapCone_pt, Functor.comp_obj, Cone.toStructuredArrow_obj, Functor.mapCone_π_app, map_mk, mk_right,
Functor.comp_map, Cone.toStructuredArrow_map, comp_right, map_map_right, homMk_right]
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
x✝² x✝¹ : J
x✝ : x✝² ⟶ x✝¹
⊢ x✝ ≫
(eqToHom
(_ :
StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π x✝¹)) = StructuredArrow.mk (NatTrans.app s.π x✝¹))).right =
(eqToHom
(_ :
StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π x✝²)) = StructuredArrow.mk (NatTrans.app s.π x✝²))).right ≫
x✝
[PROOFSTEP]
rw [Comma.eqToHom_right, Comma.eqToHom_right]
-- this is a `simp` lemma
[GOAL]
case h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
x✝² x✝¹ : J
x✝ : x✝² ⟶ x✝¹
⊢ x✝ ≫
eqToHom
(_ :
(StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π x✝¹))).right =
(StructuredArrow.mk (NatTrans.app s.π x✝¹)).right) =
eqToHom
(_ :
(StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π x✝²))).right =
(StructuredArrow.mk (NatTrans.app s.π x✝²)).right) ≫
x✝
[PROOFSTEP]
simp
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
⊢ f₁ = f₂
[PROOFSTEP]
let c₁ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₁)
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
⊢ f₁ = f₂
[PROOFSTEP]
let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F) : _)).obj
(c.toStructuredArrowCone F f₂)
-- The two cones can then be combined and we may obtain a cone over the two cones since
-- `StructuredArrow s.pt F` is cofiltered.
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
⊢ f₁ = f₂
[PROOFSTEP]
let c₀ := IsCofiltered.cone (biconeMk _ c₁ c₂)
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
⊢ f₁ = f₂
[PROOFSTEP]
let g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
⊢ f₁ = f₂
[PROOFSTEP]
let g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
⊢ f₁ = f₂
[PROOFSTEP]
have : ∀ j : J, g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j :=
by
intro j
injection c₀.π.naturality (BiconeHom.left j) with _ e₁
injection c₀.π.naturality (BiconeHom.right j) with _ e₂
have e₃ := e₁.symm.trans e₂
simp (config := { zeta := false }) at e₃
rw [Comma.eqToHom_right, Comma.eqToHom_right] at e₃
simpa (config := { zeta := false }) using e₃
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
⊢ ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
intro j
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
j : J
⊢ g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
injection c₀.π.naturality (BiconeHom.left j) with _ e₁
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
j : J
left_eq✝ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.left).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).left
e₁ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).right ≫ (NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.left).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).right
⊢ g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
injection c₀.π.naturality (BiconeHom.right j) with _ e₂
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
j : J
left_eq✝¹ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.left).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).left
e₁ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).right ≫ (NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.left).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).right
left_eq✝ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.right).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).left
e₂ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).right ≫
(NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.right).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).right
⊢ g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
have e₃ := e₁.symm.trans e₂
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
j : J
left_eq✝¹ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.left).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).left
e₁ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).right ≫ (NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.left).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).right
left_eq✝ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.right).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).left
e₂ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).right ≫
(NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.right).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).right
e₃ :
(NatTrans.app c₀.π Bicone.left).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).right =
(NatTrans.app c₀.π Bicone.right).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).right
⊢ g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
simp (config := { zeta := false }) at e₃
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
j : J
left_eq✝¹ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.left).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).left
e₁ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).right ≫ (NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.left).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).right
left_eq✝ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.right).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).left
e₂ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).right ≫
(NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.right).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).right
e₃ :
(NatTrans.app c₀.π Bicone.left).right ≫
NatTrans.app c.π j ≫
(eqToHom
(_ :
(pre s.pt K F).obj (StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π j))) =
(pre s.pt K F).obj (StructuredArrow.mk (NatTrans.app s.π j)))).right =
(NatTrans.app c₀.π Bicone.right).right ≫
NatTrans.app c.π j ≫
(eqToHom
(_ :
(pre s.pt K F).obj (StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π j))) =
(pre s.pt K F).obj (StructuredArrow.mk (NatTrans.app s.π j)))).right
⊢ g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
rw [Comma.eqToHom_right, Comma.eqToHom_right] at e₃
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
j : J
left_eq✝¹ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.left).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).left
e₁ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.left j)).right ≫ (NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.left).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.left j)).right
left_eq✝ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).left ≫ (NatTrans.app c₀.π (Bicone.diagram j)).left =
(NatTrans.app c₀.π Bicone.right).left ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).left
e₂ :
(((Functor.const (Bicone J)).obj c₀.pt).map (BiconeHom.right j)).right ≫
(NatTrans.app c₀.π (Bicone.diagram j)).right =
(NatTrans.app c₀.π Bicone.right).right ≫ ((biconeMk J c₁ c₂).map (BiconeHom.right j)).right
e₃ :
(NatTrans.app c₀.π Bicone.left).right ≫
NatTrans.app c.π j ≫
eqToHom
(_ :
((pre s.pt K F).obj (StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π j)))).right =
((pre s.pt K F).obj (StructuredArrow.mk (NatTrans.app s.π j))).right) =
(NatTrans.app c₀.π Bicone.right).right ≫
NatTrans.app c.π j ≫
eqToHom
(_ :
((pre s.pt K F).obj (StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π j)))).right =
((pre s.pt K F).obj (StructuredArrow.mk (NatTrans.app s.π j))).right)
⊢ g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
[PROOFSTEP]
simpa (config := { zeta := false }) using e₃
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
⊢ f₁ = f₂
[PROOFSTEP]
have : c.extend g₁.right = c.extend g₂.right := by
unfold Cone.extend
congr 1
ext x
apply this
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
⊢ Cone.extend c g₁.right = Cone.extend c g₂.right
[PROOFSTEP]
unfold Cone.extend
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
⊢ { pt := c₀.pt.right, π := NatTrans.app (Cone.extensions c) (op c₀.pt.right) { down := g₁.right } } =
{ pt := c₀.pt.right, π := NatTrans.app (Cone.extensions c) (op c₀.pt.right) { down := g₂.right } }
[PROOFSTEP]
congr 1
[GOAL]
case e_π
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
⊢ NatTrans.app (Cone.extensions c) (op c₀.pt.right) { down := g₁.right } =
NatTrans.app (Cone.extensions c) (op c₀.pt.right) { down := g₂.right }
[PROOFSTEP]
ext x
[GOAL]
case e_π.w.h
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
x : J
⊢ NatTrans.app (NatTrans.app (Cone.extensions c) (op c₀.pt.right) { down := g₁.right }) x =
NatTrans.app (NatTrans.app (Cone.extensions c) (op c₀.pt.right) { down := g₂.right }) x
[PROOFSTEP]
apply this
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ f₁ = f₂
[PROOFSTEP]
have : g₁.right = g₂.right
[GOAL]
case this
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ g₁.right = g₂.right
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝¹ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this✝ : Cone.extend c g₁.right = Cone.extend c g₂.right
this : g₁.right = g₂.right
⊢ f₁ = f₂
[PROOFSTEP]
calc
g₁.right = hc.lift (c.extend g₁.right) :=
by
apply
hc.uniq
(c.extend _)
-- Porting note: was `by tidy`, but `aesop` only works if max heartbeats
-- is increased, so we replace it by the output of `tidy?`
intro j; rfl
_ = hc.lift (c.extend g₂.right) := by congr
_ = g₂.right := by
symm
apply
hc.uniq
(c.extend _)
-- Porting note: was `by tidy`, but `aesop` only works if max heartbeats
-- is increased, so we replace it by the output of `tidy?`
intro _;
rfl
-- Finally, since `fᵢ` factors through `F(gᵢ)`, the result follows.
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ g₁.right = IsLimit.lift hc (Cone.extend c g₁.right)
[PROOFSTEP]
apply
hc.uniq
(c.extend _)
-- Porting note: was `by tidy`, but `aesop` only works if max heartbeats
-- is increased, so we replace it by the output of `tidy?`
[GOAL]
case x
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = NatTrans.app (Cone.extend c g₁.right).π j
[PROOFSTEP]
intro j
[GOAL]
case x
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
j : J
⊢ g₁.right ≫ NatTrans.app c.π j = NatTrans.app (Cone.extend c g₁.right).π j
[PROOFSTEP]
rfl
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ IsLimit.lift hc (Cone.extend c g₁.right) = IsLimit.lift hc (Cone.extend c g₂.right)
[PROOFSTEP]
congr
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ IsLimit.lift hc (Cone.extend c g₂.right) = g₂.right
[PROOFSTEP]
symm
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ g₂.right = IsLimit.lift hc (Cone.extend c g₂.right)
[PROOFSTEP]
apply
hc.uniq
(c.extend _)
-- Porting note: was `by tidy`, but `aesop` only works if max heartbeats
-- is increased, so we replace it by the output of `tidy?`
[GOAL]
case x
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
⊢ ∀ (j : J), g₂.right ≫ NatTrans.app c.π j = NatTrans.app (Cone.extend c g₂.right).π j
[PROOFSTEP]
intro _
[GOAL]
case x
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this : Cone.extend c g₁.right = Cone.extend c g₂.right
j✝ : J
⊢ g₂.right ≫ NatTrans.app c.π j✝ = NatTrans.app (Cone.extend c g₂.right).π j✝
[PROOFSTEP]
rfl
-- Finally, since `fᵢ` factors through `F(gᵢ)`, the result follows.
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝¹ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this✝ : Cone.extend c g₁.right = Cone.extend c g₂.right
this : g₁.right = g₂.right
⊢ f₁ = f₂
[PROOFSTEP]
calc
f₁ = 𝟙 _ ≫ f₁ := by simp
_ = c₀.pt.hom ≫ F.map g₁.right := g₁.w
_ = c₀.pt.hom ≫ F.map g₂.right := by rw [this]
_ = 𝟙 _ ≫ f₂ := g₂.w.symm
_ = f₂ := by simp
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝¹ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this✝ : Cone.extend c g₁.right = Cone.extend c g₂.right
this : g₁.right = g₂.right
⊢ f₁ = 𝟙 s.pt ≫ f₁
[PROOFSTEP]
simp
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝¹ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this✝ : Cone.extend c g₁.right = Cone.extend c g₂.right
this : g₁.right = g₂.right
⊢ c₀.pt.hom ≫ F.map g₁.right = c₀.pt.hom ≫ F.map g₂.right
[PROOFSTEP]
rw [this]
[GOAL]
C : Type u₁
inst✝⁴ : Category.{v₁, u₁} C
D : Type u₂
inst✝³ : Category.{v₁, u₂} D
J : Type v₁
inst✝² : SmallCategory J
inst✝¹ : FinCategory J
K✝ : J ⥤ C
F : C ⥤ D
inst✝ : RepresentablyFlat F
c✝ : Cone K✝
hc✝ : IsLimit c✝
s✝ : Cone (K✝ ⋙ F)
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
f₁ f₂ : s.pt ⟶ F.obj c.pt
h₁ : ∀ (j : J), f₁ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
h₂ : ∀ (j : J), f₂ ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
α₁ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₁ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₁ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
α₂ : Cone.toStructuredArrow (F.mapCone c) ⋙ map f₂ ⟶ Cone.toStructuredArrow s :=
NatTrans.mk fun X =>
eqToHom (_ : StructuredArrow.mk (f₂ ≫ F.map (NatTrans.app c.π X)) = StructuredArrow.mk (NatTrans.app s.π X))
c₁ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₁ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₁)
c₂ : Cone (Cone.toStructuredArrow s ⋙ pre s.pt K F) :=
(Cones.postcompose (whiskerRight α₂ (pre s.pt K F))).obj (Cone.toStructuredArrowCone c F f₂)
c₀ : Cone (biconeMk J c₁ c₂) := IsCofiltered.cone (biconeMk J c₁ c₂)
g₁ : c₀.pt ⟶ c₁.pt := NatTrans.app c₀.π Bicone.left
g₂ : c₀.pt ⟶ c₂.pt := NatTrans.app c₀.π Bicone.right
this✝¹ : ∀ (j : J), g₁.right ≫ NatTrans.app c.π j = g₂.right ≫ NatTrans.app c.π j
this✝ : Cone.extend c g₁.right = Cone.extend c g₂.right
this : g₁.right = g₂.right
⊢ 𝟙 s.pt ≫ f₂ = f₂
[PROOFSTEP]
simp
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
⊢ PreservesFiniteLimits F
[PROOFSTEP]
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
[GOAL]
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
⊢ (J : Type ?u.100310) → {𝒥 : SmallCategory J} → FinCategory J → PreservesLimitsOfShape J F
[PROOFSTEP]
intro J _ _
[GOAL]
case h
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.100310
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ PreservesLimitsOfShape J F
[PROOFSTEP]
constructor
[GOAL]
case h.preservesLimit
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.100310
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ autoParam ({K : J ⥤ C} → PreservesLimit K F) _auto✝
[PROOFSTEP]
intro K
[GOAL]
case h.preservesLimit
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.100310
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
⊢ PreservesLimit K F
[PROOFSTEP]
constructor
[GOAL]
case h.preservesLimit.preserves
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.100310
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
⊢ {c : Cone K} → IsLimit c → IsLimit (F.mapCone c)
[PROOFSTEP]
intro c hc
[GOAL]
case h.preservesLimit.preserves
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type ?u.100310
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
⊢ IsLimit (F.mapCone c)
[PROOFSTEP]
exact
{ lift := PreservesFiniteLimitsOfFlat.lift F hc
fac := PreservesFiniteLimitsOfFlat.fac F hc
uniq := fun s m h => by
apply PreservesFiniteLimitsOfFlat.uniq F hc
exact h
exact PreservesFiniteLimitsOfFlat.fac F hc s }
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
⊢ m = PreservesFiniteLimitsOfFlat.lift F hc s
[PROOFSTEP]
apply PreservesFiniteLimitsOfFlat.uniq F hc
[GOAL]
case h₁
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
⊢ ∀ (j : J), m ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
case h₂
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
⊢ ∀ (j : J), PreservesFiniteLimitsOfFlat.lift F hc s ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
[PROOFSTEP]
exact h
[GOAL]
case h₂
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type v₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : J ⥤ C
c : Cone K
hc : IsLimit c
s : Cone (K ⋙ F)
m : s.pt ⟶ (F.mapCone c).pt
h : ∀ (j : J), m ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
⊢ ∀ (j : J), PreservesFiniteLimitsOfFlat.lift F hc s ≫ NatTrans.app (F.mapCone c).π j = NatTrans.app s.π j
[PROOFSTEP]
exact PreservesFiniteLimitsOfFlat.fac F hc s
[GOAL]
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits F
⊢ (fun x => preservesFiniteLimitsOfFlat F) (_ : RepresentablyFlat F) = x
[PROOFSTEP]
cases x
[GOAL]
case mk
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ (fun x => preservesFiniteLimitsOfFlat F) (_ : RepresentablyFlat F) = PreservesFiniteLimits.mk
[PROOFSTEP]
unfold preservesFiniteLimitsOfFlat
[GOAL]
case mk
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ (fun x => preservesFiniteLimitsOfPreservesFiniteLimitsOfSize F fun J {𝒥} x_1 => PreservesLimitsOfShape.mk)
(_ : RepresentablyFlat F) =
PreservesFiniteLimits.mk
[PROOFSTEP]
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
[GOAL]
case mk
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ PreservesFiniteLimits.mk = PreservesFiniteLimits.mk
[PROOFSTEP]
congr
-- porting note: this next line wasn't needed in lean 3
[GOAL]
case mk.e_preservesFiniteLimits
C : Type u₁
inst✝² : Category.{v₁, u₁} C
D : Type u₂
inst✝¹ : Category.{v₁, u₂} D
inst✝ : HasFiniteLimits C
F : C ⥤ D
preservesFiniteLimits✝ : (J : Type) → [inst : SmallCategory J] → [inst_1 : FinCategory J] → PreservesLimitsOfShape J F
⊢ (fun J x x_1 => preservesLimitsOfShapeOfEquiv (Equivalence.symm (ULiftHomULiftCategory.equiv J)) F) =
preservesFiniteLimits✝
[PROOFSTEP]
apply Subsingleton.elim
[GOAL]
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
⊢ ∀ {X_1 Y : C ⥤ E} (f : X_1 ⟶ Y),
(lan F ⋙ (evaluation D E).obj X).map f ≫ ((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) Y).hom =
((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) X_1).hom ≫
((whiskeringLeft (CostructuredArrow F X) C E).obj (CostructuredArrow.proj F X) ⋙ colim).map f
[PROOFSTEP]
intro G H i
[GOAL]
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
⊢ (lan F ⋙ (evaluation D E).obj X).map i ≫ ((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) H).hom =
((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) G).hom ≫
((whiskeringLeft (CostructuredArrow F X) C E).obj (CostructuredArrow.proj F X) ⋙ colim).map i
[PROOFSTEP]
apply colimit.hom_ext
[GOAL]
case w
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
⊢ ∀ (j : CostructuredArrow F X),
colimit.ι (Lan.diagram F G X) j ≫
(lan F ⋙ (evaluation D E).obj X).map i ≫ ((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) H).hom =
colimit.ι (Lan.diagram F G X) j ≫
((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) G).hom ≫
((whiskeringLeft (CostructuredArrow F X) C E).obj (CostructuredArrow.proj F X) ⋙ colim).map i
[PROOFSTEP]
intro j
[GOAL]
case w
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j : CostructuredArrow F X
⊢ colimit.ι (Lan.diagram F G X) j ≫
(lan F ⋙ (evaluation D E).obj X).map i ≫ ((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) H).hom =
colimit.ι (Lan.diagram F G X) j ≫
((fun G => colim.mapIso (Iso.refl (Lan.diagram F G X))) G).hom ≫
((whiskeringLeft (CostructuredArrow F X) C E).obj (CostructuredArrow.proj F X) ⋙ colim).map i
[PROOFSTEP]
simp only [Functor.comp_map, Functor.mapIso_refl, evaluation_obj_map, whiskeringLeft_obj_map, lan_map_app,
colimit.ι_desc_assoc, Category.comp_id, Category.assoc]
-- porting note: this deals with the fact that the type of `lan_map_app` has changed
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/change.20in.20behaviour.20with.20.60simps.60/near/354350606
[GOAL]
case w
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j : CostructuredArrow F X
⊢ NatTrans.app i j.left ≫
NatTrans.app (↑(Lan.equiv F H (Lan.loc F H)) (𝟙 (Lan.loc F H))) j.left ≫
colimit.pre (Lan.diagram F H X) (CostructuredArrow.map j.hom) ≫ (Iso.refl (colim.obj (Lan.diagram F H X))).hom =
colimit.ι (Lan.diagram F G X) j ≫
(Iso.refl (colim.obj (Lan.diagram F G X))).hom ≫ colim.map (whiskerLeft (CostructuredArrow.proj F X) i)
[PROOFSTEP]
erw [show
((Lan.equiv F H (Lan.loc F H)) (𝟙 (Lan.loc F H))).app j.left =
colimit.ι (Lan.diagram F H (F.obj j.left)) (CostructuredArrow.mk (𝟙 (F.obj j.left)))
by apply Category.comp_id]
[GOAL]
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j : CostructuredArrow F X
⊢ NatTrans.app (↑(Lan.equiv F H (Lan.loc F H)) (𝟙 (Lan.loc F H))) j.left =
colimit.ι (Lan.diagram F H (F.obj j.left)) (CostructuredArrow.mk (𝟙 (F.obj j.left)))
[PROOFSTEP]
apply Category.comp_id
[GOAL]
case w
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j : CostructuredArrow F X
⊢ NatTrans.app i j.left ≫
colimit.ι (Lan.diagram F H (F.obj j.left)) (CostructuredArrow.mk (𝟙 (F.obj j.left))) ≫
colimit.pre (Lan.diagram F H X) (CostructuredArrow.map j.hom) ≫ (Iso.refl (colim.obj (Lan.diagram F H X))).hom =
colimit.ι (Lan.diagram F G X) j ≫
(Iso.refl (colim.obj (Lan.diagram F G X))).hom ≫ colim.map (whiskerLeft (CostructuredArrow.proj F X) i)
[PROOFSTEP]
erw [colimit.ι_pre_assoc (Lan.diagram F H X) (CostructuredArrow.map j.hom), Category.id_comp, Category.comp_id,
colimit.ι_map]
[GOAL]
case w
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j : CostructuredArrow F X
⊢ NatTrans.app i j.left ≫
colimit.ι (Lan.diagram F H X) ((CostructuredArrow.map j.hom).obj (CostructuredArrow.mk (𝟙 (F.obj j.left)))) =
NatTrans.app (whiskerLeft (CostructuredArrow.proj F X) i) j ≫
colimit.ι (((whiskeringLeft (CostructuredArrow F X) C E).obj (CostructuredArrow.proj F X)).obj H) j
[PROOFSTEP]
rcases j with ⟨j_left, ⟨⟨⟩⟩, j_hom⟩
[GOAL]
case w.mk.mk.unit
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j_left : C
j_hom : F.obj j_left ⟶ (Functor.fromPUnit X).obj { as := PUnit.unit }
⊢ NatTrans.app i { left := j_left, right := { as := PUnit.unit }, hom := j_hom }.left ≫
colimit.ι (Lan.diagram F H X)
((CostructuredArrow.map { left := j_left, right := { as := PUnit.unit }, hom := j_hom }.hom).obj
(CostructuredArrow.mk (𝟙 (F.obj { left := j_left, right := { as := PUnit.unit }, hom := j_hom }.left)))) =
NatTrans.app (whiskerLeft (CostructuredArrow.proj F X) i)
{ left := j_left, right := { as := PUnit.unit }, hom := j_hom } ≫
colimit.ι (((whiskeringLeft (CostructuredArrow F X) C E).obj (CostructuredArrow.proj F X)).obj H)
{ left := j_left, right := { as := PUnit.unit }, hom := j_hom }
[PROOFSTEP]
congr
[GOAL]
case w.mk.mk.unit.e_a.h.e_7.h
C D : Type u₁
inst✝³ : SmallCategory C
inst✝² : SmallCategory D
E : Type u₂
inst✝¹ : Category.{u₁, u₂} E
F : C ⥤ D
X : D
inst✝ : ∀ (X : D), HasColimitsOfShape (CostructuredArrow F X) E
G H : C ⥤ E
i : G ⟶ H
j_left : C
j_hom : F.obj j_left ⟶ (Functor.fromPUnit X).obj { as := PUnit.unit }
⊢ (CostructuredArrow.map { left := j_left, right := { as := PUnit.unit }, hom := j_hom }.hom).obj
(CostructuredArrow.mk (𝟙 (F.obj { left := j_left, right := { as := PUnit.unit }, hom := j_hom }.left))) =
{ left := j_left, right := { as := PUnit.unit }, hom := j_hom }
[PROOFSTEP]
rw [CostructuredArrow.map_mk, Category.id_comp, CostructuredArrow.mk]
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
⊢ PreservesFiniteLimits (lan F.op)
[PROOFSTEP]
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
⊢ (J : Type u₁) → {𝒥 : SmallCategory J} → FinCategory J → PreservesLimitsOfShape J (lan F.op)
[PROOFSTEP]
intro J _ _
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type u₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ PreservesLimitsOfShape J (lan F.op)
[PROOFSTEP]
skip
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type u₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ PreservesLimitsOfShape J (lan F.op)
[PROOFSTEP]
apply preservesLimitsOfShapeOfEvaluation (lan F.op : (Cᵒᵖ ⥤ E) ⥤ Dᵒᵖ ⥤ E) J
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type u₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
⊢ (k : Dᵒᵖ) → PreservesLimitsOfShape J (lan F.op ⋙ (evaluation Dᵒᵖ E).obj k)
[PROOFSTEP]
intro K
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type u₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : Dᵒᵖ
⊢ PreservesLimitsOfShape J (lan F.op ⋙ (evaluation Dᵒᵖ E).obj K)
[PROOFSTEP]
haveI : IsFiltered (CostructuredArrow F.op K) := IsFiltered.of_equivalence (structuredArrowOpEquivalence F (unop K))
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
F : C ⥤ D
inst✝ : RepresentablyFlat F
J : Type u₁
𝒥✝ : SmallCategory J
x✝ : FinCategory J
K : Dᵒᵖ
this : IsFiltered (CostructuredArrow F.op K)
⊢ PreservesLimitsOfShape J (lan F.op ⋙ (evaluation Dᵒᵖ E).obj K)
[PROOFSTEP]
exact preservesLimitsOfShapeOfNatIso (lanEvaluationIsoColim _ _ _).symm
[GOAL]
C D : Type u₁
inst✝¹⁰ : SmallCategory C
inst✝⁹ : SmallCategory D
E : Type u₂
inst✝⁸ : Category.{u₁, u₂} E
inst✝⁷ : ConcreteCategory E
inst✝⁶ : HasLimits E
inst✝⁵ : HasColimits E
inst✝⁴ : ReflectsLimits (forget E)
inst✝³ : PreservesFilteredColimits (forget E)
inst✝² : PreservesLimits (forget E)
inst✝¹ : HasFiniteLimits C
F : C ⥤ D
inst✝ : PreservesFiniteLimits F
⊢ PreservesFiniteLimits (lan F.op)
[PROOFSTEP]
haveI := flat_of_preservesFiniteLimits F
[GOAL]
C D : Type u₁
inst✝¹⁰ : SmallCategory C
inst✝⁹ : SmallCategory D
E : Type u₂
inst✝⁸ : Category.{u₁, u₂} E
inst✝⁷ : ConcreteCategory E
inst✝⁶ : HasLimits E
inst✝⁵ : HasColimits E
inst✝⁴ : ReflectsLimits (forget E)
inst✝³ : PreservesFilteredColimits (forget E)
inst✝² : PreservesLimits (forget E)
inst✝¹ : HasFiniteLimits C
F : C ⥤ D
inst✝ : PreservesFiniteLimits F
this : RepresentablyFlat F
⊢ PreservesFiniteLimits (lan F.op)
[PROOFSTEP]
infer_instance
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
⊢ RepresentablyFlat F
[PROOFSTEP]
skip
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
⊢ RepresentablyFlat F
[PROOFSTEP]
haveI := preservesFiniteLimitsOfFlat (lan F.op : _ ⥤ Dᵒᵖ ⥤ Type u₁)
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
this : PreservesFiniteLimits (lan F.op)
⊢ RepresentablyFlat F
[PROOFSTEP]
haveI : PreservesFiniteLimits F :=
by
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
intros; skip; apply preservesLimitOfLanPreservesLimit
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
this : PreservesFiniteLimits (lan F.op)
⊢ PreservesFiniteLimits F
[PROOFSTEP]
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
this : PreservesFiniteLimits (lan F.op)
⊢ (J : Type u₁) → {𝒥 : SmallCategory J} → FinCategory J → PreservesLimitsOfShape J F
[PROOFSTEP]
intros
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
this : PreservesFiniteLimits (lan F.op)
J✝ : Type u₁
𝒥✝ : SmallCategory J✝
x✝ : FinCategory J✝
⊢ PreservesLimitsOfShape J✝ F
[PROOFSTEP]
skip
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
this : PreservesFiniteLimits (lan F.op)
J✝ : Type u₁
𝒥✝ : SmallCategory J✝
x✝ : FinCategory J✝
⊢ PreservesLimitsOfShape J✝ F
[PROOFSTEP]
apply preservesLimitOfLanPreservesLimit
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
H : RepresentablyFlat (lan F.op)
this✝ : PreservesFiniteLimits (lan F.op)
this : PreservesFiniteLimits F
⊢ RepresentablyFlat F
[PROOFSTEP]
apply flat_of_preservesFiniteLimits
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x✝ : PreservesFiniteLimits (lan F.op)
⊢ PreservesFiniteLimits F
[PROOFSTEP]
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x✝ : PreservesFiniteLimits (lan F.op)
⊢ (J : Type u₁) → {𝒥 : SmallCategory J} → FinCategory J → PreservesLimitsOfShape J F
[PROOFSTEP]
intros
[GOAL]
case h
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x✝¹ : PreservesFiniteLimits (lan F.op)
J✝ : Type u₁
𝒥✝ : SmallCategory J✝
x✝ : FinCategory J✝
⊢ PreservesLimitsOfShape J✝ F
[PROOFSTEP]
apply preservesLimitOfLanPreservesLimit
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits F
⊢ (fun x => preservesFiniteLimitsOfPreservesFiniteLimitsOfSize F fun J {𝒥} x_1 => preservesLimitOfLanPreservesLimit F J)
((fun x => inferInstance) x) =
x
[PROOFSTEP]
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits F
⊢ PreservesFiniteLimits.mk = x
[PROOFSTEP]
congr
-- porting note: next line wasn't necessary in lean 3
[GOAL]
case e_preservesFiniteLimits
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits F
⊢ (fun J x_1 x_2 => preservesLimitsOfShapeOfEquiv (Equivalence.symm (ULiftHomULiftCategory.equiv J)) F) =
PreservesFiniteLimits.preservesFiniteLimits
[PROOFSTEP]
apply Subsingleton.elim
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits (lan F.op)
⊢ (fun x => inferInstance)
((fun x =>
preservesFiniteLimitsOfPreservesFiniteLimitsOfSize F fun J {𝒥} x_1 => preservesLimitOfLanPreservesLimit F J)
x) =
x
[PROOFSTEP]
dsimp only [lanPreservesFiniteLimitsOfPreservesFiniteLimits, lanPreservesFiniteLimitsOfFlat,
preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
[GOAL]
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits (lan F.op)
⊢ inferInstance = x
[PROOFSTEP]
congr
-- porting note: next line wasn't necessary in lean 3
[GOAL]
case h.e_2.h.h.e_2.h.e_preservesFiniteLimits
C D : Type u₁
inst✝⁹ : SmallCategory C
inst✝⁸ : SmallCategory D
E : Type u₂
inst✝⁷ : Category.{u₁, u₂} E
inst✝⁶ : ConcreteCategory E
inst✝⁵ : HasLimits E
inst✝⁴ : HasColimits E
inst✝³ : ReflectsLimits (forget E)
inst✝² : PreservesFilteredColimits (forget E)
inst✝¹ : PreservesLimits (forget E)
inst✝ : HasFiniteLimits C
F : C ⥤ D
x : PreservesFiniteLimits (lan F.op)
⊢ (fun J x_1 x_2 => preservesLimitsOfShapeOfEquiv (Equivalence.symm (ULiftHomULiftCategory.equiv J)) (lan F.op)) =
PreservesFiniteLimits.preservesFiniteLimits
[PROOFSTEP]
apply Subsingleton.elim
|
lemma cone_iff: assumes "S \<noteq> {}" shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ((*\<^sub>R) c) ` S = S)" |
The corn crake is a difficult bird to see in its breeding sites , usually being hidden by vegetation , but will sometimes emerge into the open . Occasionally , individuals may become very trusting ; for five consecutive summers , an individual crake on the Scottish island of Tiree entered a kitchen to feed on scraps , and , in 1999 , a wintering Barra bird would come for poultry feed once the chickens had finished . In Africa , it is more secretive than the African crake , and , unlike its relative , it is rarely seen in the open , although it occasionally feeds on tracks or road sides . The corn crake is most active early and late in the day , after heavy rain and during light rain . Its typical flight is weak and fluttering , although less so than that of the African crake . For longer flights , such as migration , it has a steadier , stronger action with legs drawn up . It walks with a high @-@ stepping action , and can run swiftly through grass with its body held horizontal and laterally flattened . It will swim if essential . When flushed by a dog , it will fly less than 50 m ( 160 ft ) , frequently landing behind a bush or thicket , and then crouch on landing . If disturbed in the open , this crake will often run in a crouch for a short distance , with its neck stretched forward , then stand upright to watch the intruder . When captured it may feign death , recovering at once if it sees a way out .
|
# ESRB Ratings
# 2013-07-02 via http://www.esrb.org/ratings/search.jsp
ESRBRatingsAges <- c(3, 6, 10, 13, 17, 18)
ESRBRatings <- c(289, 20437, 2260, 6017, 1898, 32)
ESRBRatingsT <- c(0,0,0,289,0,0,20437,0,0,0,2260,0,0,6017,0,0,0,1898,32)
# PEGI Ratings
# 2013-07-02 via http://www.pegi.info/en/index/id/509
PEGIRatingsAges <- c(3, 7, 12, 16, 18)
PEGIRatings <- c(9448, 2861, 4535, 2561, 1271)
PEGIRatingsT <- c(0,0,0,9448,0,0,0,2861,0,0,0,0,4535,0,0,0,2561,0,1271)
# USK Ratings
# 2013-07-02 via http://www.usk.de/titelsuche/titelsuche/
# absolute not not available via that frontend, so they had to be estimated
USKRatingsAges <- c(0,6,12,16,18)
USKRatings <- c(1409,461,613,342,114)*10
USKRatingsT <- c(1409,0,0,0,0,0,461,0,0,0,0,0,613,0,0,0,342,0,114)*10
# BPjM Ratings
# 2013-07-02 via http://bundespruefstelle.de/bpjm/Jugendmedienschutz/statistik,did=39254.html
BPjMRatingsAges <- c(18)
BPjMRatings <- c(658)
BPjMRatingsU <- c(0,0,0,0,658)
BPjMRatingsT <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,658)
AgeRange = 0:18
svg('age-rating-distribution.svg', height=6, width=12)
plot(ESRBRatingsAges,ESRBRatings,col="red",xlim=c(0,18),ylim=c(0,20000),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
title(main = "Number of Game Age Ratings as Function of Age", sub = "ESRB (red), PEGI (green), USK (blue), BPjM (black)", xlab = "Rated Age", ylab = "Number of Ratings")
axis(1,0:18)
axis(2,0:20*1000)
par(new=TRUE)
plot(PEGIRatingsAges,PEGIRatings,col="green",xlim=c(0,18),ylim=c(0,20000),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
par(new=TRUE)
plot(USKRatingsAges,USKRatings,col="blue",xlim=c(0,18),ylim=c(0,20000),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
par(new=TRUE)
plot(BPjMRatingsAges,BPjMRatings,col="black",xlim=c(0,18),ylim=c(0,20000),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
dev.off()
svg('age-rating-distribution-1.svg', height=6, width=12)
plot(0:18,cumsum(ESRBRatingsT)/sum(ESRBRatingsT),col="red",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
title(main = "Relative Number of Game Age Ratings as Function of Age", sub = "ESRB (red), PEGI (green), USK (blue), USK+BPjM (pink)", xlab = "Rated Age", ylab = "% of Games Available at Given Age")
axis(1,0:18)
axis(2,c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1))
par(new=TRUE)
plot(0:18,cumsum(PEGIRatingsT)/sum(PEGIRatingsT),col="green",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
par(new=TRUE)
plot(0:18,cumsum(USKRatingsT)/sum(USKRatingsT),col="blue",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
par(new=TRUE)
plot(0:18,cumsum(USKRatingsT+BPjMRatingsT)/sum(USKRatingsT+BPjMRatingsT),col="pink",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
dev.off()
svg('age-rating-distribution-2.svg', height=6, width=12)
plot(ESRBRatingsAges,cumsum(ESRBRatings)/sum(ESRBRatings),col="red",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
title(main = "Relative Number of Game Age Ratings as Function of Age", sub = "ESRB (red), PEGI (green), USK (blue), USK+BPjM (pink)", xlab = "Rated Age", ylab = "% of Games Available at Given Age")
axis(1,0:18)
axis(2,c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1))
par(new=TRUE)
plot(PEGIRatingsAges,cumsum(PEGIRatings)/sum(PEGIRatings),col="green",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
par(new=TRUE)
plot(USKRatingsAges,cumsum(USKRatings)/sum(USKRatings),col="blue",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
par(new=TRUE)
plot(USKRatingsAges,cumsum(USKRatings+BPjMRatingsU)/sum(USKRatings+BPjMRatingsU),col="pink",xlim=c(0,18),ylim=c(0,1),xaxt="n",yaxt="n",xlab="",ylab="",type="b")
dev.off()
|
If $S$ is closed and $T$ is compact, then the set $\{x + y : x \in S, y \in T\}$ is closed. |
\section{Standard Module \sectcode{shelve}}
\stmodindex{shelve}
\stmodindex{pickle}
\bimodindex{dbm}
\bimodindex{gdbm}
A ``shelf'' is a persistent, dictionary-like object. The difference
with ``dbm'' databases is that the values (not the keys!) in a shelf
can be essentially arbitrary Python objects --- anything that the
\code{pickle} module can handle. This includes most class instances,
recursive data types, and objects containing lots of shared
sub-objects. The keys are ordinary strings.
To summarize the interface (\code{key} is a string, \code{data} is an
arbitrary object):
\begin{verbatim}
import shelve
d = shelve.open(filename) # open, with (g)dbm filename -- no suffix
d[key] = data # store data at key (overwrites old data if
# using an existing key)
data = d[key] # retrieve data at key (raise KeyError if no
# such key)
del d[key] # delete data stored at key (raises KeyError
# if no such key)
flag = d.has_key(key) # true if the key exists
list = d.keys() # a list of all existing keys (slow!)
d.close() # close it
\end{verbatim}
Restrictions:
\begin{itemize}
\item
The choice of which database package will be used (e.g. dbm or gdbm)
depends on which interface is available. Therefore it isn't safe to
open the database directly using dbm. The database is also
(unfortunately) subject to the limitations of dbm, if it is used ---
this means that (the pickled representation of) the objects stored in
the database should be fairly small, and in rare cases key collisions
may cause the database to refuse updates.
\item
Dependent on the implementation, closing a persistent dictionary may
or may not be necessary to flush changes to disk.
\item
The \code{shelve} module does not support {\em concurrent} read/write
access to shelved objects. (Multiple simultaneous read accesses are
safe.) When a program has a shelf open for writing, no other program
should have it open for reading or writing. \UNIX{} file locking can
be used to solve this, but this differs across \UNIX{} versions and
requires knowledge about the database implementation used.
\end{itemize}
|
(*
Author: Mike Stannett
Date: 27 April 2016
[email protected]
*)
theory SomeFunc
imports Main
begin
fun someFunc :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b" where
"someFunc P x = (SOME y. (P x y))"
lemma lemSomeFunc:
assumes "\<exists>y . P x y"
and "f = someFunc P"
shows "P x (f x)"
proof -
have "f x = (SOME y. (P x y))"
using assms(2) by simp
thus ?thesis using assms(1)
by (simp add: someI_ex)
qed
end
|
#include <stdio.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_roots.h>
#include <gsl/gsl_math.h>
#include "zero_crossing.h"
/* \fn double zero_crossing(double (*model)(double, void *), void *params, double *x_lo, double *x_hi)
* \brief Find a zero crossing of the supplied model. */
double zero_crossing(double (*model)(double, void *), void *params, double *x_lo, double *x_hi)
{
int status;
int iter=0;
int max_iter = 100;
double x; //root
const gsl_root_fsolver_type *T;
gsl_root_fsolver *s;
gsl_function F;
F.function = model;
F.params = params;
T = gsl_root_fsolver_brent;
s = gsl_root_fsolver_alloc(T);
gsl_root_fsolver_set(s,&F, *x_lo, *x_hi);
do{
iter++;
status = gsl_root_fsolver_iterate(s);
x = gsl_root_fsolver_root(s);
*x_lo = gsl_root_fsolver_x_lower(s);
*x_hi = gsl_root_fsolver_x_upper(s);
status = gsl_root_test_interval(*x_lo, *x_hi,0,0.001);
//printf("iter %d x_lo %e x %e x_hi %e\n",iter,*x_lo,x,*x_hi);
}while((status==GSL_CONTINUE)&&(iter<max_iter));
gsl_root_fsolver_free(s);
return x;
}
|
(*
Copyright 2014 Cornell University
Copyright 2015 Cornell University
Copyright 2016 Cornell University
Copyright 2017 Cornell University
This file is part of VPrl (the Verified Nuprl project).
VPrl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
VPrl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VPrl. If not, see <http://www.gnu.org/licenses/>.
Websites: http://nuprl.org/html/verification/
http://nuprl.org/html/Nuprl2Coq
https://github.com/vrahli/NuprlInCoq
Authors: Vincent Rahli
Mark Bickford
*)
Require Export csubst3.
Require Export computation_apply.
Require Export per_props_cequiv.
Require Export per_props_union.
Require Export continuity_defs_ceq.
(*Require Export per_props3.*)
Require Export per_props_nat.
Require Export cequiv_bind.
Require Export per_props_uni.
Lemma type_mkc_cequiv {o} :
forall lib (a b : @CTerm o),
type lib (mkc_cequiv a b).
Proof.
introv.
apply tequality_mkc_cequiv; tcsp.
Qed.
Hint Resolve type_mkc_cequiv : slow.
Lemma type_mkc_approx {o} :
forall lib (a b : @CTerm o),
type lib (mkc_approx a b).
Proof.
introv.
apply tequality_mkc_approx; tcsp.
Qed.
Hint Resolve type_mkc_approx : slow.
Lemma implies_approx_islambda {p} :
forall lib a1 b1 c1 a2 b2 c2,
@approx p lib a1 a2
-> approx lib b1 b2
-> approx lib c1 c2
-> approx lib (mk_islambda a1 b1 c1) (mk_islambda a2 b2 c2).
Proof.
introv apa apb apc.
applydup @approx_relates_only_progs in apa.
applydup @approx_relates_only_progs in apb.
applydup @approx_relates_only_progs in apc.
repnd.
unfold mk_islambda, mk_can_test.
repeat prove_approx; sp.
Qed.
Lemma implies_approx_isint {p} :
forall lib a1 b1 c1 a2 b2 c2,
@approx p lib a1 a2
-> approx lib b1 b2
-> approx lib c1 c2
-> approx lib (mk_isint a1 b1 c1) (mk_isint a2 b2 c2).
Proof.
introv apa apb apc.
applydup @approx_relates_only_progs in apa.
applydup @approx_relates_only_progs in apb.
applydup @approx_relates_only_progs in apc.
repnd.
unfold mk_isint, mk_can_test.
repeat prove_approx; sp.
Qed.
Lemma implies_cequivc_islambda {p} :
forall lib a1 b1 c1 a2 b2 c2,
cequivc lib a1 a2
-> cequivc lib b1 b2
-> @cequivc p lib c1 c2
-> cequivc lib (mkc_islambda a1 b1 c1) (mkc_islambda a2 b2 c2).
Proof.
unfold cequivc.
introv ceqa ceqb ceqc.
destruct_cterms.
allsimpl.
allrw @isprog_eq.
repnud ceqa.
repnud ceqb.
repnud ceqc.
split; apply implies_approx_islambda; auto.
Qed.
Lemma implies_cequivc_isint {p} :
forall lib a1 b1 c1 a2 b2 c2,
cequivc lib a1 a2
-> cequivc lib b1 b2
-> @cequivc p lib c1 c2
-> cequivc lib (mkc_isint a1 b1 c1) (mkc_isint a2 b2 c2).
Proof.
unfold cequivc.
introv ceqa ceqb ceqc.
destruct_cterms.
allsimpl.
allrw @isprog_eq.
repnud ceqa.
repnud ceqb.
repnud ceqc.
split; apply implies_approx_isint; auto.
Qed.
Lemma implies_cequiv_isint {p} :
forall lib a1 b1 c1 a2 b2 c2,
cequiv lib a1 a2
-> cequiv lib b1 b2
-> @cequiv p lib c1 c2
-> cequiv lib (mk_isint a1 b1 c1) (mk_isint a2 b2 c2).
Proof.
introv ceqa ceqb ceqc.
allrw @isprog_eq.
repnud ceqa.
repnud ceqb.
repnud ceqc.
split; apply implies_approx_isint; auto.
Qed.
Definition mk_cnterm {o} (t : @NTerm o) (p : isprog_nout t) :=
exist isprog_nout t p.
Lemma hasvaluec_mkc_apply2 {q} :
forall lib (t a : @CTerm q),
hasvaluec lib (mkc_apply t a)
-> {v : NVar $ {b : CVTerm [v] $ computes_to_valc lib t (mkc_lam v b)}}
[+] {n : nseq $ computes_to_valc lib t (mkc_nseq n)}
[+] {n : ntseqc $ computes_to_valc lib t (mkc_ntseq n)}.
Proof.
introv hv.
apply hasvaluec_mkc_apply in hv; repndors; exrepnd.
- left.
unfold computes_to_valuec in hv1.
applydup @computes_to_value_preserves_program in hv1; auto.
apply isprogram_eq in hv0; apply isprog_lam_iff in hv0.
exists v (mk_cvterm [v] b hv0).
unfold computes_to_valc; simpl; auto.
- right; left.
exists n; auto.
- right; right.
unfold computes_to_seqnc in hv0.
unfold computes_to_seq in hv0.
applydup @reduces_to_preserves_program in hv0; auto.
rw @isprogram_mk_ntseq in hv1.
assert (forall x, isprog_nout (n x)) as nout.
{ introv.
pose proof (hv1 x) as h; clear hv1; repnd.
destruct h0 as [cl wf].
apply isprog_nout_iff; dands; auto. }
exists (fun x => mk_cnterm (n x) (nout x)).
unfold computes_to_valc, computes_to_value; simpl; auto.
unfold ntseqc2seq; simpl; dands; auto.
split; simpl; auto.
apply nt_wf_sterm_implies_isprogram.
apply nt_wf_sterm_iff; introv.
pose proof (nout n0) as h.
apply isprog_nout_iff in h; sp.
Qed.
Lemma cequivc_mkc_islambda_mkc_lam {o} :
forall lib v (b : @CVTerm o [v]) t1 t2,
cequivc lib (mkc_islambda (mkc_lam v b) t1 t2) t1.
Proof.
introv.
apply reduces_toc_implies_cequivc.
destruct_cterms.
unfold reduces_toc; simpl.
apply reduces_to_if_step; csunf; simpl; auto.
Qed.
Lemma cequivc_mkc_islambda_mkc_nseq {o} :
forall lib s (t1 t2 : @CTerm o),
cequivc lib (mkc_islambda (mkc_nseq s) t1 t2) t2.
Proof.
introv.
apply reduces_toc_implies_cequivc.
destruct_cterms.
unfold reduces_toc; simpl.
apply reduces_to_if_step; csunf; simpl; auto.
Qed.
Lemma cequivc_mkc_islambda_mkc_ntseq {o} :
forall lib s (t1 t2 : @CTerm o),
cequivc lib (mkc_islambda (mkc_ntseq s) t1 t2) t2.
Proof.
introv.
apply reduces_toc_implies_cequivc.
destruct_cterms.
unfold reduces_toc; simpl.
apply reduces_to_if_step; csunf; simpl; auto.
Qed.
Lemma member_mkc_or_inl {p} :
forall lib a (A B : @CTerm p),
member lib (mkc_inl a) (mkc_or A B)
<=> (type lib A
# type lib B
# member lib a A).
Proof.
introv.
rw @equality_mkc_or; split; intro h; repnd; repndors; exrepnd; spcast; dands; auto;
computes_to_value_isvalue.
left.
exists a a; dands; spcast; auto;
apply computes_to_valc_refl; eauto 3 with slow.
Qed.
Lemma member_mkc_or_inr {p} :
forall lib b (A B : @CTerm p),
member lib (mkc_inr b) (mkc_or A B)
<=> (type lib A
# type lib B
# member lib b B).
Proof.
introv.
rw @equality_mkc_or; split; intro h; repnd; repndors; exrepnd; spcast; dands; auto;
computes_to_value_isvalue.
right.
exists b b; dands; spcast; auto;
apply computes_to_valc_refl; eauto 3 with slow.
Qed.
Lemma nt_wf_int_iff {p} :
forall (bs : list (@BTerm p)) z,
nt_wf (oterm (Can (Nint z)) bs)
<=> bs = [].
Proof.
introv; split; intro k.
- inversion k as [|?|? ? imp e]; clear k; subst.
allsimpl.
repeat (destruct bs; allsimpl; ginv).
- exrepnd; subst.
repeat constructor.
introv i; allsimpl; repndors; subst; tcsp.
Qed.
Lemma dec_can_int {o} :
forall (op : @CanonicalOp o),
decidable {z : Z & op = Nint z}.
Proof.
introv; unfold decidable.
destruct op; try (complete (right; sp; ginv)).
left; exists z; auto.
Qed.
Lemma hasvaluec_implies_cequivc_mkc_isint {o} :
forall lib (a b c : @CTerm o),
hasvaluec lib a
-> (cequivc lib (mkc_isint a b c) b [+] cequivc lib (mkc_isint a b c) c).
Proof.
introv hv.
destruct_cterms; allsimpl.
unfold hasvaluec in hv; allsimpl.
unfold cequivc; simpl.
unfold hasvalue in hv; exrepnd.
unfold computes_to_value in hv0; repnd.
inversion hv0 as [v isp isc]; subst; clear hv0.
destruct t' as [v|f|op bs]; allsimpl; tcsp; GC.
- right.
eapply cequiv_trans;
[apply implies_cequiv_isint;
[apply reduces_to_implies_cequiv; eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow]
|].
apply reduces_to_implies_cequiv; eauto 3 with slow.
apply isprogram_isint; eauto 3 with slow.
- dopid op as [can|ncan|exc|abs] Case; tcsp; GC;[].
destruct (dec_can_int can) as [d|d]; exrepnd; subst.
+ left.
eapply cequiv_trans;
[apply implies_cequiv_isint;
[apply reduces_to_implies_cequiv; eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow]
|].
inversion isp as [cl wf].
apply nt_wf_int_iff in wf; subst; fold_terms.
apply reduces_to_implies_cequiv; eauto 3 with slow.
apply isprogram_isint; eauto 3 with slow.
+ right.
eapply cequiv_trans;
[apply implies_cequiv_isint;
[apply reduces_to_implies_cequiv; eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow]
|].
apply reduces_to_implies_cequiv; eauto 3 with slow.
{ apply isprogram_isint; eauto 3 with slow. }
apply reduces_to_if_step.
csunf; simpl.
destruct can; simpl; auto.
destruct d; eexists; eauto.
Qed.
Definition isintegerc {o} (t : @CTerm o) := isinteger (get_cterm t).
Lemma hasvaluec_implies_cequivc_mkc_isint2 {o} :
forall lib (a b c : @CTerm o),
hasvaluec lib a
-> {z : Z
& computes_to_valc lib a (mkc_integer z)
# cequivc lib (mkc_isint a b c) b}
[+]
{v : CTerm
& computes_to_valc lib a v
# !isintegerc v
# cequivc lib (mkc_isint a b c) c}.
Proof.
introv hv.
destruct_cterms; allsimpl.
unfold hasvaluec in hv; allsimpl.
unfold cequivc, computes_to_valc, isintegerc; simpl.
unfold hasvalue in hv; exrepnd.
unfold computes_to_value in hv0; repnd.
inversion hv0 as [v isp isc]; subst; clear hv0.
destruct t' as [v|f|op bs]; allsimpl; tcsp; GC.
- right.
exists (mk_cterm (sterm f) isp); simpl.
dands.
+ unfold computes_to_value; dands; eauto 3 with slow.
+ unfold isinteger; intro h; exrepnd; ginv.
+ eapply cequiv_trans;
[apply implies_cequiv_isint;
[apply reduces_to_implies_cequiv; eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow]
|].
apply reduces_to_implies_cequiv; eauto 3 with slow.
apply isprogram_isint; eauto 3 with slow.
- dopid op as [can|ncan|exc|abs] Case; tcsp; GC;[].
destruct (dec_can_int can) as [d|d]; exrepnd; subst.
+ left.
inversion isp as [cl wf].
apply nt_wf_int_iff in wf; subst; fold_terms.
exists z; dands; auto.
* unfold computes_to_value; dands; eauto 3 with slow.
* eapply cequiv_trans;
[apply implies_cequiv_isint;
[apply reduces_to_implies_cequiv; eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow]
|].
apply reduces_to_implies_cequiv; eauto 3 with slow.
apply isprogram_isint; eauto 3 with slow.
+ right.
exists (mk_cterm (oterm (Can can) bs) isp); simpl.
dands; auto.
* unfold computes_to_value; dands; eauto 3 with slow.
* intro h; unfold isinteger, mk_integer in h; exrepnd; ginv.
destruct d; eexists; eauto.
* eapply cequiv_trans;
[apply implies_cequiv_isint;
[apply reduces_to_implies_cequiv; eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow
|apply cequiv_refl;eauto 3 with slow]
|].
apply reduces_to_implies_cequiv; eauto 3 with slow.
{ apply isprogram_isint; eauto 3 with slow. }
apply reduces_to_if_step.
csunf; simpl.
destruct can; simpl; auto.
destruct d; eexists; eauto.
Qed.
Lemma implies_cequivc_halts {o} :
forall lib (a b : @CTerm o),
cequivc lib a b
-> cequivc lib (mkc_halts a) (mkc_halts b).
Proof.
introv imp.
allrw <- @fold_mkc_halts.
apply cequivc_decomp_approx; dands; eauto 3 with slow.
apply simpl_cequivc_mkc_cbv; auto.
Qed.
Lemma hasvalue_likec_apply_nseq_implies_integer {o} :
forall lib s (v : @CTerm o),
iscvalue v
-> hasvalue_likec lib (mkc_apply (mkc_nseq s) v)
-> isintegerc v.
Proof.
introv isv hv.
destruct_cterms.
unfold iscvalue in isv.
unfold hasvalue_likec in hv.
unfold isintegerc; allsimpl.
unfold hasvalue_like in hv; exrepnd.
apply isvalue_implies in isv; repnd.
apply reduces_to_split2 in hv1; repndors; subst.
- unfold isvalue_like in hv0; allsimpl; tcsp.
- exrepnd.
csunf hv1; allsimpl; ginv.
apply reduces_to_split2 in hv2; repndors; subst.
+ unfold isvalue_like in hv0; allsimpl; tcsp.
+ exrepnd.
csunf hv2; allsimpl; dcwf xx; allsimpl.
apply iscan_implies in isv0; repndors; exrepnd; subst; ginv.
destruct c; allsimpl; ginv.
destruct bterms; allsimpl; ginv.
boolvar; ginv; fold_terms; eauto 3 with slow.
Qed.
Lemma hasvalue_likec_apply_ntseq_implies_integer {o} :
forall lib s (v : @CTerm o),
iscvalue v
-> hasvalue_likec lib (mkc_apply (mkc_ntseq s) v)
-> isintegerc v.
Proof.
introv isv hv.
destruct_cterms.
unfold iscvalue in isv.
unfold hasvalue_likec in hv.
unfold isintegerc; allsimpl.
unfold hasvalue_like in hv; exrepnd.
apply isvalue_implies in isv; repnd.
apply reduces_to_split2 in hv1; repndors; subst.
- unfold isvalue_like in hv0; allsimpl; tcsp.
- exrepnd.
csunf hv1; allsimpl; ginv.
apply reduces_to_split2 in hv2; repndors; subst.
+ unfold isvalue_like in hv0; allsimpl; tcsp.
+ exrepnd.
csunf hv2; allsimpl.
apply iscan_implies in isv0; repndors; exrepnd; subst; ginv.
apply compute_step_eapply_success in hv2; exrepnd.
destruct l; allsimpl; ginv.
repndors; exrepnd; subst; GC; allsimpl; tcsp.
* destruct c; ginv.
destruct bterms; allsimpl; ginv.
exists z; auto.
* unfold isnoncan_like in hv5; allsimpl; tcsp.
Qed.
Lemma type_base {o} : forall lib, @type o lib mkc_base.
Proof.
introv; apply tequality_base.
Qed.
Hint Resolve type_base : slow.
Hint Rewrite @lsubstc_mk_true : slow.
Hint Resolve tnat_type : slow.
Hint Resolve type_mkc_true : slow.
Lemma apply_pair_not_valuelike {o} :
forall lib (a b c : @NTerm o),
!hasvalue_like lib (mk_apply (mk_pair a b) c).
Proof. introv hv. destruct hv as [v hv]. destruct hv as [red val]. destruct red as [k red].
revert red. induction k; introv red.
- apply reduces_in_atmost_k_steps_0 in red; subst. destruct val as [x | y].
+ inversion x.
+ inversion y.
- apply reduces_in_atmost_k_steps_S in red; exrepnd.
apply compute_step_apply_can_success in red1. repndors; exrepnd.
+ inversion red2.
+ inversion red1.
Qed.
Lemma apply_inl_not_valuelike {o} :
forall lib (a b : @NTerm o),
!hasvalue_like lib (mk_apply (mk_inl a) b).
Proof. introv hv. destruct hv as [v hv]. destruct hv as [red val]. destruct red as [k red].
revert red. induction k; introv red.
- apply reduces_in_atmost_k_steps_0 in red; subst. destruct val as [x | y].
+ inversion x.
+ inversion y.
- apply reduces_in_atmost_k_steps_S in red; exrepnd.
apply compute_step_apply_can_success in red1. repndors; exrepnd.
+ inversion red2.
+ inversion red1.
Qed.
Lemma apply_inr_not_valuelike {o} :
forall lib (a b : @NTerm o),
!hasvalue_like lib (mk_apply (mk_inr a) b).
Proof. introv hv. destruct hv as [v hv]. destruct hv as [red val]. destruct red as [k red].
revert red. induction k; introv red.
- apply reduces_in_atmost_k_steps_0 in red; subst. destruct val as [x | y].
+ inversion x.
+ inversion y.
- apply reduces_in_atmost_k_steps_S in red; exrepnd.
apply compute_step_apply_can_success in red1. repndors; exrepnd.
+ inversion red2.
+ inversion red1.
Qed.
Lemma apply_int_not_valuelike {o} :
forall lib (a b : @NTerm o),
isprogram a
-> isprogram b
-> {n : Z $ reduces_to lib a (mk_integer n)}
-> !hasvalue_like lib (mk_apply a b).
Proof.
introv ispa ispb red hv.
destruct hv as [v c].
destruct c as [red2 val].
assert (isprogram v) as ispv.
{ eauto 3 with slow. }
exrepnd.
apply @reduces_to_implies_cequiv in red0; auto.
apply @reduces_to_implies_cequiv in red2; try apply isprogram_apply; auto.
assert (cequiv lib (mk_apply (mk_integer n) b) (mk_apply a b)) as ceq1.
{repeat (prove_cequiv). apply cequiv_sym; auto. destruct ispb; auto. }
assert (cequiv lib (mk_apply (mk_integer n) b) v) as ceq2.
{ eapply cequiv_trans; [exact ceq1 | auto]. }
destruct val; destruct v as [v|f|op bs]; allsimpl; auto;
try (destruct op; allsimpl; auto).
- assert (cequiv lib mk_bottom (sterm f)) as ceq3.
{ eapply cequiv_trans;[|exact ceq2].
split;[apply bottom_approx_any|]; eauto 3 with slow.
apply approx_assume_hasvalue; eauto 3 with slow.
introv hv; provefalse.
unfold hasvalue_like in hv; exrepnd.
apply reduces_to_split2 in hv1; repndors; exrepnd; subst; ginv.
unfold isvalue_like in hv0; allsimpl; tcsp. }
destruct ceq3 as [ap1 ap2].
apply hasvalue_approx in ap2;
[apply not_hasvalue_bot in ap2; tcsp|].
apply hasvalue_sterm; auto.
- pose proof (cequiv_canonical_form
lib
(oterm (Can c) bs)
(mk_apply (mk_integer n) b) c bs) as xx.
repeat (autodimp xx hyp; eauto 3 with slow); exrepnd.
destruct xx1 as [r v].
destruct r as [k r].
revert r.
induction k; introv red.
{ rw @reduces_in_atmost_k_steps_0 in red. inversion red. }
{ apply @reduces_in_atmost_k_steps_S in red. exrepnd.
apply compute_step_apply_can_success in red3. repndors; exrepnd. inversion red4.
inversion red3.
}
- dup red2 as red3. apply cequiv_isprogram in red3. destruct red3. sp.
apply isprogram_exception_implies in i1. exrepnd. subst.
assert (oterm Exc [bterm [] a0, bterm [] t] =e>( a0, lib)t) as yy.
+ exists 0. apply reduces_in_atmost_k_steps_0. refl.
+ pose proof (cequiv_exception_weak
lib
(oterm Exc [bterm [] a0, bterm [] t]) a0 t
(mk_apply (mk_integer n) b) yy
) as xx. dimp xx.
{ eapply @cequiv_trans; apply @cequiv_sym. exact red2. auto. }
{ exrepnd. destruct hyp1 as [k r]. revert r. induction k; introv red.
{ rw @reduces_in_atmost_k_steps_0 in red. inversion red. }
{ apply @reduces_in_atmost_k_steps_S in red. exrepnd.
apply compute_step_apply_can_success in red3. repndors; exrepnd. inversion red4.
inversion red3.
}
}
Qed.
Lemma implies_approx_mk_le {o} :
forall lib (a1 a2 b1 b2 : @NTerm o),
approx lib a1 a2
-> approx lib b1 b2
-> approx lib (mk_le a1 b1) (mk_le a2 b2).
Proof.
introv apra aprb.
applydup @approx_isprog in apra.
applydup @approx_isprog in aprb.
repnd.
apply approx_open_approx; allrw @isprogram_eq; try (apply isprog_le_implies); auto.
apply approx_open_mk_le; apply approx_implies_approx_open; auto.
Qed.
Lemma implies_cequiv_mk_le {o} :
forall lib (a1 a2 b1 b2 : @NTerm o),
cequiv lib a1 a2
-> cequiv lib b1 b2
-> cequiv lib (mk_le a1 b1) (mk_le a2 b2).
Proof.
introv ceqa ceqb.
allunfold @cequiv; allsimpl; repnd; dands; apply implies_approx_mk_le; auto.
Qed.
Lemma implies_cequivc_mkc_le {o} :
forall lib (a1 a2 b1 b2 : @CTerm o),
cequivc lib a1 a2
-> cequivc lib b1 b2
-> cequivc lib (mkc_le a1 b1) (mkc_le a2 b2).
Proof.
introv ceqa ceqb.
destruct_cterms.
allunfold @cequivc; allsimpl.
apply implies_cequiv_mk_le; auto.
Qed.
Definition isNat {o} (t : @NTerm o) : NTerm := mk_le mk_zero t.
Definition diverges {o} (t: @NTerm o) : NTerm := mk_approx t mk_bot.
(*
isect (x : Base) (z : halts(x)). isint(x;if x < 0 then diverges(f(x)) else isNat(f(x));diverges(f(x)))
*)
Definition isChoiceSeq {o} (x z : NVar) (f : @NTerm o) : NTerm :=
mk_isect
mk_base
x
(mk_isect
(mk_halts (mk_var x))
z
(mk_isint
(mk_var x)
(mk_less
(mk_var x)
mk_zero
(diverges (mk_apply f (mk_var x)))
(isNat (mk_apply f (mk_var x)))
)
(diverges (mk_apply f (mk_var x)))
)
).
Lemma hasvaluec_approxc_lam_implies_cequivc {o} :
forall lib (f : @CTerm o) x y a,
approxc lib f (mkc_lam y a)
-> hasvaluec lib f
-> cequivc lib f (mkc_lam x (mkcv_apply [x] (mk_cv [x] f) (mkc_var x))).
Proof.
introv apr hv.
apply cequivc_iff_approxc; dands; auto; destruct_cterms;
allunfold @approxc; allunfold @hasvaluec; allunfold @cequivc; allsimpl;
rename x1 into a; rename x0 into f.
- unfold hasvalue in hv; exrepnd.
unfold computes_to_value in hv0; repnd.
apply isvalue_iff in hv0; repnd.
eapply approx_trans;
[apply reduces_to_implies_approx2;eauto 3 with slow|].
apply (approx_trans _ _ (mk_lam x (mk_apply t' (mk_var x)))).
+ inversion apr as [cl]; clear apr.
unfold close_comput in cl; repnd; GC.
apply iscan_implies in hv2; repndors; exrepnd; subst.
* unfold close_compute_val in cl2.
pose proof (cl2 c bterms) as h.
clear cl2 cl3 cl4.
autodimp h hyp.
{ unfold computes_to_value; dands; auto. }
exrepnd.
apply computes_to_value_isvalue_eq in h1; eauto 3 with slow;
try (apply isvalue_iff; dands; simpl; auto).
unfold mk_lam in h1; ginv.
dup hv0 as isp.
destruct hv0 as [c wf].
apply nt_wf_lambda_iff in wf; exrepnd; subst; fold_terms.
apply implies_approx_lam2.
{ apply implies_isprogram_bt_lam in isp.
allrw <- @isprog_vars_iff_isprogram_bt; auto. }
{ apply isprog_vars_apply_implies; eauto 3 with slow. }
introv ispu.
applydup @closed_if_isprog in ispu.
unfold subst.
repeat (rw @cl_lsubst_lsubst_aux;[|eauto 3 with slow]); simpl; fold_terms.
autorewrite with slow in *.
apply cequiv_sym.
eapply cequiv_trans.
{ apply reduces_to_implies_cequiv.
- apply isprogram_apply; boolvar; eauto 2 with slow.
{ rw @lsubst_aux_nil; auto. }
{ apply isprogram_lam.
rw <- @cl_lsubst_lsubst_aux;[|eauto 3 with slow].
apply isprog_vars_lsubst_prog_sub; simpl; eauto 3 with slow.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
eapply isprog_vars_subvars;[|eauto].
rw subvars_prop; simpl; tcsp. }
- apply reduces_to_if_step; csunf; simpl; eauto. }
unfold apply_bterm; simpl.
boolvar; try (rw @lsubst_aux_nil).
{ rw <- @cl_lsubst_lsubst_aux;[|eauto 3 with slow].
apply cequiv_refl.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
apply isprogram_lsubst_if_isprog_sub; simpl; eauto 3 with slow.
apply isprog_vars_eq in isp; repnd.
rw @subvars_eq in isp0; auto. }
rw (lsubst_aux_trivial_cl b [(x,u)]); simpl; eauto 3 with slow.
{ rw <- @cl_lsubst_lsubst_aux;[|eauto 3 with slow].
apply cequiv_refl.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
apply isprogram_lsubst_if_isprog_sub; simpl; eauto 3 with slow.
apply isprog_vars_eq in isp; repnd.
rw @subvars_eq in isp0; auto. }
apply disjoint_singleton_l; intro xx.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
apply isprog_vars_eq in isp; repnd.
rw @subvars_eq in isp0; auto.
apply isp0 in xx; allsimpl; tcsp.
* apply cl4 in hv1; clear cl2 cl3 cl4.
exrepnd.
apply reduces_to_if_value in hv1; ginv;
try (apply isvalue_iff; dands; simpl; auto).
+ apply implies_approx_lam2; try (apply isprog_vars_apply_implies);
eauto 3 with slow.
introv ispu.
unfold subst.
repeat (rw @cl_lsubst_lsubst_aux;[|eauto 3 with slow]); simpl.
boolvar; tcsp; fold_terms.
repeat (rw @lsubst_aux_trivial_cl_term2; eauto 3 with slow).
apply sp_implies_cequiv_apply; eauto 2 with slow.
apply cequiv_sym.
apply reduces_to_implies_cequiv; eauto 2 with slow.
- unfold hasvalue in hv; exrepnd.
unfold computes_to_value in hv0; repnd.
apply isvalue_iff in hv0; repnd.
eapply approx_trans;
[|apply reduces_to_implies_approx1;eauto 3 with slow].
apply (approx_trans _ _ (mk_lam x (mk_apply t' (mk_var x)))).
+ apply implies_approx_lam2; try (apply isprog_vars_apply_implies);
eauto 3 with slow.
introv ispu.
unfold subst.
repeat (rw @cl_lsubst_lsubst_aux;[|eauto 3 with slow]); simpl.
boolvar; tcsp; fold_terms.
repeat (rw @lsubst_aux_trivial_cl_term2; eauto 3 with slow).
apply sp_implies_cequiv_apply; eauto 2 with slow.
apply reduces_to_implies_cequiv; eauto 2 with slow.
+ inversion apr as [cl]; clear apr.
unfold close_comput in cl; repnd; GC.
apply iscan_implies in hv2; repndors; exrepnd; subst.
* unfold close_compute_val in cl2.
pose proof (cl2 c bterms) as h.
clear cl2 cl3 cl4.
autodimp h hyp.
{ unfold computes_to_value; dands; auto. }
exrepnd.
apply computes_to_value_isvalue_eq in h1; eauto 3 with slow;
try (apply isvalue_iff; dands; simpl; auto).
unfold mk_lam in h1; ginv.
dup hv0 as isp.
destruct hv0 as [c wf].
apply nt_wf_lambda_iff in wf; exrepnd; subst; fold_terms.
apply implies_approx_lam2.
{ apply isprog_vars_apply_implies; eauto 3 with slow. }
{ apply implies_isprogram_bt_lam in isp.
allrw <- @isprog_vars_iff_isprogram_bt; auto. }
introv ispu.
applydup @closed_if_isprog in ispu.
unfold subst.
repeat (rw @cl_lsubst_lsubst_aux;[|eauto 3 with slow]); simpl; fold_terms.
autorewrite with slow in *.
eapply cequiv_trans.
{ apply reduces_to_implies_cequiv.
- apply isprogram_apply; boolvar; eauto 2 with slow.
{ rw @lsubst_aux_nil; auto. }
{ apply isprogram_lam.
rw <- @cl_lsubst_lsubst_aux;[|eauto 3 with slow].
apply isprog_vars_lsubst_prog_sub; simpl; eauto 3 with slow.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
eapply isprog_vars_subvars;[|eauto].
rw subvars_prop; simpl; tcsp. }
- apply reduces_to_if_step; csunf; simpl; eauto. }
unfold apply_bterm; simpl.
boolvar; try (rw @lsubst_aux_nil).
{ rw <- @cl_lsubst_lsubst_aux;[|eauto 3 with slow].
apply cequiv_refl.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
apply isprogram_lsubst_if_isprog_sub; simpl; eauto 3 with slow.
apply isprog_vars_eq in isp; repnd.
rw @subvars_eq in isp0; auto. }
rw (lsubst_aux_trivial_cl b [(x,u)]); simpl; eauto 3 with slow.
{ rw <- @cl_lsubst_lsubst_aux;[|eauto 3 with slow].
apply cequiv_refl.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
apply isprogram_lsubst_if_isprog_sub; simpl; eauto 3 with slow.
apply isprog_vars_eq in isp; repnd.
rw @subvars_eq in isp0; auto. }
apply disjoint_singleton_l; intro xx.
apply implies_isprogram_bt_lam in isp.
apply isprog_vars_iff_isprogram_bt in isp.
apply isprog_vars_eq in isp; repnd.
rw @subvars_eq in isp0; auto.
apply isp0 in xx; allsimpl; tcsp.
* apply cl4 in hv1; clear cl2 cl3 cl4.
exrepnd.
apply reduces_to_if_value in hv1; ginv;
try (apply isvalue_iff; dands; simpl; auto).
Qed.
Lemma mkc_cv_app_r_mkc_var {o} :
forall x, mk_cv_app_r [] [x] (mkc_var x) = @mkc_var o x.
Proof.
introv.
apply cvterm_eq; simpl; auto.
Qed.
Hint Rewrite @mkc_cv_app_r_mkc_var : slow.
Lemma if_raises_exceptionc_apply2 {o} :
forall lib (t a: @CTerm o),
raises_exceptionc lib (mkc_apply t a)
-> raises_exceptionc lib t
[+] {v : NVar $ {b : CVTerm [v] $ computes_to_valc lib t (mkc_lam v b)}}
[+] {n: nseq $ computes_to_valc lib t (mkc_nseq n)}
[+] {n: ntseqc $ computes_to_valc lib t (mkc_ntseq n)}.
Proof.
introv hv.
apply if_raises_exceptionc_apply in hv; repndors; exrepnd; tcsp.
- right; left.
unfold computes_to_valuec in hv1.
applydup @computes_to_value_preserves_program in hv1; auto.
apply isprogram_eq in hv0; apply isprog_lam_iff in hv0.
exists v (mk_cvterm [v] b hv0).
unfold computes_to_valc; simpl; auto.
- right; right; left.
exists n; auto.
- right; right; right.
unfold computes_to_seqnc in hv0.
unfold computes_to_seq in hv0.
applydup @reduces_to_preserves_program in hv0; auto.
rw @isprogram_mk_ntseq in hv1.
assert (forall x, isprog_nout (n x)) as nout.
{ introv.
pose proof (hv1 x) as h; clear hv1; repnd.
destruct h0 as [cl wf].
apply isprog_nout_iff; dands; auto. }
exists (fun x => mk_cnterm (n x) (nout x)).
unfold computes_to_valc, computes_to_value; simpl; auto.
unfold ntseqc2seq; simpl; dands; auto.
split; simpl; auto.
apply nt_wf_sterm_implies_isprogram.
apply nt_wf_sterm_iff; introv.
pose proof (nout n0) as h.
apply isprog_nout_iff in h; sp.
Qed.
Lemma inhabited_type_or {o} :
forall lib (a b : @CTerm o),
inhabited_type lib (mkc_or a b)
<=> ((inhabited_type lib a # type lib b)
{+} (inhabited_type lib b # type lib a)).
Proof.
introv; split; intro h.
- unfold inhabited_type in h; exrepnd.
apply equality_mkc_or in h0; repnd; repndors; exrepnd.
+ left; dands; auto.
exists a1.
apply equality_refl in h0; auto.
+ right; dands; auto.
exists b1.
apply equality_refl in h0; auto.
- repndors; unfold inhabited_type in h; exrepnd.
+ exists (mkc_inl t).
apply member_mkc_or_inl; dands; auto.
apply inhabited_implies_tequality in h1; auto.
+ exists (mkc_inr t).
apply member_mkc_or_inr; dands; auto.
apply inhabited_implies_tequality in h1; auto.
Qed.
Lemma base_in_uni {p} :
forall lib i, @member p lib mkc_base (mkc_uni i).
Proof.
introv.
unfold member, equality.
exists (fun A A' => {eqa : per , close lib (univi lib i) A A' eqa}).
unfold nuprl.
dands.
{ apply mkc_uni_in_nuprl. }
{ exists (fun t t' => t ~=~(lib) t').
apply CL_base.
unfold per_base; dands; spcast; auto;
apply computes_to_valc_refl; eauto 3 with slow. }
Qed.
|
State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
⊢ ∀ (b : β), b ∈ t → ∃ a ha, b = f a ha State After: no goals Tactic: classical
intro b hb
have h : (s.attach.image fun a : { a // a ∈ s } => f a a.prop).card = s.card :=
@card_attach _ s ▸
card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h
have h' : image (fun a : { a // a ∈ s } => f a a.prop) s.attach = t :=
eq_of_subset_of_card_le
(fun b h =>
let ⟨a, _, ha₂⟩ := mem_image.1 h
ha₂ ▸ hf _ _)
(by simp [hst, h])
rw [← h'] at hb
obtain ⟨a, _, ha₂⟩ := mem_image.1 hb
exact ⟨a, a.2, ha₂.symm⟩ State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
⊢ ∀ (b : β), b ∈ t → ∃ a ha, b = f a ha State After: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
⊢ ∃ a ha, b = f a ha Tactic: intro b hb State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
⊢ ∃ a ha, b = f a ha State After: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
⊢ ∃ a ha, b = f a ha Tactic: have h : (s.attach.image fun a : { a // a ∈ s } => f a a.prop).card = s.card :=
@card_attach _ s ▸
card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
⊢ ∃ a ha, b = f a ha State After: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
h' : image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s) = t
⊢ ∃ a ha, b = f a ha Tactic: have h' : image (fun a : { a // a ∈ s } => f a a.prop) s.attach = t :=
eq_of_subset_of_card_le
(fun b h =>
let ⟨a, _, ha₂⟩ := mem_image.1 h
ha₂ ▸ hf _ _)
(by simp [hst, h]) State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
h' : image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s) = t
⊢ ∃ a ha, b = f a ha State After: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
h' : image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s) = t
⊢ ∃ a ha, b = f a ha Tactic: rw [← h'] at hb State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
h' : image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s) = t
⊢ ∃ a ha, b = f a ha State After: case intro.intro
α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
h' : image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s) = t
a : { a // a ∈ s }
left✝ : a ∈ attach s
ha₂ : f ↑a (_ : ↑a ∈ s) = b
⊢ ∃ a ha, b = f a ha Tactic: obtain ⟨a, _, ha₂⟩ := mem_image.1 hb State Before: case intro.intro
α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
h' : image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s) = t
a : { a // a ∈ s }
left✝ : a ∈ attach s
ha₂ : f ↑a (_ : ↑a ∈ s) = b
⊢ ∃ a ha, b = f a ha State After: no goals Tactic: exact ⟨a, a.2, ha₂.symm⟩ State Before: α : Type u_2
β : Type u_1
s t✝ : Finset α
f✝ : α → β
n : ℕ
t : Finset β
f : (a : α) → a ∈ s → β
hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t
hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂
hst : card t ≤ card s
b : β
hb : b ∈ t
h : card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) = card s
⊢ card t ≤ card (image (fun a => f ↑a (_ : ↑a ∈ s)) (attach s)) State After: no goals Tactic: simp [hst, h] |
My first week on the job as First Lite’s sales intern was definitely a whirlwind. Moving from PA to ID meant a lot of changes and one of the most exciting involved hunting. I was fortunate enough to get my hands on an elk tag which meant I would be going on my first spot stalk style hunt! We wasted no time and within the first few days of being in Idaho, I set out to find some elk.
pack out meat if we were successful in our hunt. We climbed and climbed quickly (working a 9-5 job only allows for so much week day hunting). Panting, sweating, and legs burning we reached the top of a ridge and began to glass. We scanned the mountains up and down, left to right, trying to spot a big brown elk. Glassing was more difficult than I had expected. The focus it requires, especially when recovering from the huffing and puffing of the climb, is another bullet point to the list of reasons why hunting is tough. To my surprise, I saw the brown blob I was looking for. It was the first elk I had seen in person and even though she was over a mile away, my excitement was uncontrollable. We watched for a minute or two longer and spotted what looked to be 2-4 other cows and possibly a bull. My first elk hunt was in full swing.
Move fast. That was all I could think while we hurried down the mountain. Daylight was against us, which added to the pressure to move quickly. We jumped back into the truck and drove about a mile to a portion of the road where we were better able to put a stalk on the elk. We were back to climbing straight up a mountain, but this time I was even more focused on staying quiet, avoiding stomping on sticks, and keeping my eyes up, ears alert. We reached the portion of the mountain where we thought we had last seen the herd. I had read it can be extremely difficult to relocate game after spotting them, and now I understood why. We paused for a second to try and determine where we saw them last when I heard ‘crunch, crunch, crunch.’ A quick hand signal and a turn of my head toward the direction of the noise and we simultaneously stopped and lowered our bodies to the ground. Here is where the classic hunting adrenaline rush ran through my body. Crouching as still as possible, eyes wide and ears intently listening, I waited while my heart pounded through chest. We continued to hear the elk crunching just 40-50 yards below us, but I still did not have eyes on them. I nocked an arrow and readied my release. There was a patch of brush blocking a portion of my view, but between a few branches, I saw her. She was about 35 yards from me, staring right into my eyes. I did not move (I don’t even think I took a breath). With her nostrils flaring and ears wiggling back and forth, I was sure she would spook off, but eventually she dropped her head and slowly moved back down the mountain. I would have taken a shot right there, but the brush was too thick and stopped me from drawing back my bow. The three of us looked at each other with a sort of “hell yeah, here we go” head nod then turned our attention back toward the action. All elk were out of sight, but we could still hear them, so I decided I would make a move toward the brush as a safe place to set up for a shot (we initially crouched down in a place with no cover) and to see if there was in fact a bull in the herd. As I began to crawl, we heard a big blow through the nose of what I like to imagine was a large bull. There must have been eyes on me that I did not see before I began to move. They knew we were there and not a second later the stampede of elk ran down the mountain. The sound of this elk herd running was louder than anything I could have imagined. I could literally feel the sounds and vibrations through my body. With that, I knew the hunt was over. I collapsed over my pack, dropped by bow, and felt the strangest sensation of exhilaration and heart break all in one moment. I was so overwhelmed with happiness to have had such an experience for my first elk hunt, and crushed with defeat because I had spooked the herd off. It was such a beautiful, raw moment that I will surely never forget. |
#' card class
#'
#' Storage and methods for GPU card data.
#'
#' @details
#' Data is held in an external pointer.
#'
#' @rdname gpu-card-class
#' @name gpu-card-class
cardR6 = R6::R6Class("card",
public = list(
#' @details
#' Class initializer.
#' @param id GPU id number.
#' @useDynLib fmlr R_card_init
initialize = function(id=0)
{
id = as.integer(id)
private$c_ptr = .Call(R_card_init, id)
},
#' @details
#' Set card to a different GPU.
#' @param id GPU id number.
#' @useDynLib fmlr R_card_set
set = function(id)
{
id = as.integer(id)
.Call(R_card_set, private$c_ptr, id)
invisible(self)
},
#' @details
#' Synchronizes the GPU, i.e. blocks further GPU execution until the device
#' completes all previously executed kernels.
#' @useDynLib fmlr R_card_synch
synch = function()
{
.Call(R_card_synch, private$c_ptr)
invisible(self)
},
#' @details
#' Print one-line information about the object.
#' @useDynLib fmlr R_card_info
info = function()
{
.Call(R_card_info, private$c_ptr)
invisible(self)
},
#' @details
#' Print one-line information about the object.
print = function()
{
self$info()
invisible(self)
},
#' @details
#' Returns GPU id number.
#' @useDynLib fmlr R_card_get_id
get_id = function() .Call(R_card_get_id, private$c_ptr),
#' @details
#' Returns whether or not the card object is valid.
#' @useDynLib fmlr R_card_valid_card
valid_card = function() .Call(R_card_valid_card, private$c_ptr),
#' @details
#' Returns the external pointer data. For developers only.
data_ptr = function() private$c_ptr
),
private = list(
c_ptr = NULL
)
)
#' card
#'
#' Constructor for GPU card objects.
#'
#' @details
#' Data is held in an external pointer.
#'
#' @param id GPU id number.
#' @return A card class object.
#'
#' @export
card = function(id=0)
{
cardR6$new(id=id)
}
|
# using LinearAlgebra; LinearAlgebra.BLAS.set_num_threads(16)
using Dates
using SqState
using JLD2
using MAT
function gen_data(prefix::String, gen_func, is_mat=false)
@time for i in 1:101
@show i
@time begin
if !is_mat
file_name="$(prefix)_$(replace(string(now()), ':'=>'_'))"
points, 𝛒s, args, σs = gen_func(n_data=10000)
data_path = mkpath(joinpath(SqState.training_data_path(), prefix))
jldsave(joinpath(data_path, "$file_name.jld2"); points, 𝛒s, args, σs)
else
data_path = mkpath("training_data_mat/$prefix")
file = matopen(joinpath(data_path, "$file_name.mat"), "w")
write(file, "points", points); write(file, "dms", 𝛒s); write(file, "args", args); write(file, "stds", σs)
close(file)
end
end
end
end
gen_data("sqth", gen_data_sqth)
gen_data("sqth_th", gen_data_sqth_th)
|
\documentclass[11pt]{article}
%\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
%\usepackage{ebgaramond}
%\usepackage[bitstream-charter]{mathdesign}
\usepackage[british]{babel}
\usepackage{libertine}
\usepackage{amsmath}
\usepackage{microtype}
\title{Optimal Lobotomy}
\author{Clement Lee '17\\\emph{advised by Jianxiong Xiao}}
\date{}
\begin{document}
%Title. Include your name, class, project title, and advisor.
\maketitle
%Motivation and Goal. Give a high-level introduction to your topic area and state specifically what problem you will be addressing. You should clearly state the goal of your project with a sentence beginning “The goal of my project is …”. Explain why that goal is important and/or interesting, perhaps with a description of applications or people enabled by achieving it.
\section{\textbf Motivation and Goal}
The recent and astronomical rise of deep learning algorithms applied to a variety of datasets has been built on the foundation of significant boosts to computational power, especially with the advent of GPGPU techniques.
These developments have proceeded at a much faster rate than the speed of hardware-based technological advancements, and as such algorithms to efficiently utilize existing hardware are critically important.
The goal of this project is thus to produce an algorithm and implementation which will aid in the automatic parallelization of deep neural networks across multiple GPUs.
Our proposed algorithm would potentially greatly speed up any deep learning problem of contemporary nontrivial size, as it intends to automatically solve the many difficulties of properly creating parallelism within models with high degress of connectivity and interdependence.
This would also be beneficial for deep learning problems where the learning parameter space and architectures are not studied extensively, as it could be applied as a general self-learning mechanism.
%Problem Background and Related Work. Place your project in context of prior work. Give some background of what has been done before to achieve your stated goal. Include citations to closely related academic papers and/or list commercial products targeted at the same goal. Finish this section with a brief explanation of the problem unsolved by previous work that will be addressed by your project.
\section{Problem Background and Related Work}
Of primary importance to this project is the paper \emph{Optimal Brain Damage} \cite{lecun1989optimal} which describes an algorithm to reduce the size of a feedforward neural network by removing elements which contribute little to its classification ability.
It defines the concept of \emph{saliency} which is the effective importance of a weight in a network.
This should generally allow an algorithm to reduce the dimensionality of the network with minimal impact on its performance, which is a cornerstone of our algorithm.
An extensive amount of work exists in the literature regarding distributed deep learning, as it is generally a problem that resists parallelization.
Especially in increasingly distributed systems, attaining sublinear results in scaling is itself an extremely difficult problem, which is described in more detail in \emph{Large Scale Distributed Deep Networks} \cite{dean2012large}.
This gives a description of the overarching challenges of parallelization, and creates a framework for parallel learning.
Multiple forms of parallelism exist, as are described in \emph{On Model Parallelization and Scheduling Strategies for Distributed Machine Learning} \cite{lee2014model}.
This paper lays out the differences between model and data parallelism, and discusses the difficulties of applying both in varying degrees to deep learning.
It develops a language for efficient partitioning of training and updating parameters, particularly regarding scheduling of gradient calculations across a distributed network of participating servers.
In general, we aim to build on its usage of \emph{model parallelism}: that is, the splitting of model parameters across multiple computing devices.
The benefits of parallelism are further put into practice in \emph{Reducing the Training Time of Neural Networks by Partitioning} \cite{miranda2015reducing}.
This constructs a set of pretraining models which provide a natural partitioning of the parameters when they are later merged.
This allows for better usage of GPUs especially when they are not utilized to their full capacity.
A partitioning as utilized by this text is important, though it focuses on a slightly different formulation than what we intend to perform.
At the same time, much of the methodology is broadly applicable to our problem space.
A key limitation is that most current work focuses on the training phase, and is reliant on careful parameter tuning on the part of the researchers.
We aim to overcome the limitations of significant human involvement in training of deep learning, and utilize computer-based optimization procedures to determine architectural decisions of the network.
We also want to work on networks that are already pretrained and developed, and focus on efficient partitionings that allow for model parallelism with minimal loss in classification performance.
%Approach. Provide a concise description of the key idea underlying your approach to achieving the stated goal. Provide an argument of why your approach is a good idea – i.e., why it can achieve the stated goal where others have not.
\section{Approach}
To begin, we will be taking the previously defined concept of saliency and extending it to remove significant numbers of weights from a pre-existing and trained network.
We want to gradually remove weights (or clusters of weights) with low saliency while repeatedly retraining the network.
We expect that the performance of the network will decrease with fewer weights, so an acceptable error range will be established.
Furthermore, we want to develop a metric for connectivity that we aim to generally minimize, in order to get a better partitioning of the network.
At the same time, it is not the intention of this project to produce a complete partitioning of the network into two separate networks, as the result of this is not one network but rather a boosted set of networks.
Instead, our approach is to maintain some level of communication between the nodes, and to use this interconnectivity to establish a self-optimizing network that will spread across GPUs.
As we are performing our experiments on GPUs all located within a single machine, moving data between nodes is a considerable cost but not largely unsurmountable unlike in distributed systems.
Very few papers have been published on self-optimizing runtimes of networks, as it has largely been the realm of deep learning human experts.
We believe that our proposed work represents a novel direction in the literature, and it remains a topic which deserves more investigation than it has received in the past.
%Plan. Describe the steps you plan to take and/or the issues you plan to address during the execution of your project. What data sets will you have to acquire? What algorithms will you have to develop? What theorems will you have to prove? etc. For the steps that are non-trivial, provide a brief description of the issue, options, and planned approach. Please indicate any particularly risky aspects of the project and discuss contingencies in case they do not go as planned.
\section{Plan}
This project is divisible into smaller relatively-contained modules which will be developed in sequence.
Firstly, we want to test the performance of the Optimal Brain Damage algorithm on the scale of modern day networks.
This concerns the application of the algorithm under different conditions than it was originally developed and tested; it is likely that modifications will have to be made to ensure the feasibility of the algorithm.
Once we have a good understanding of the basic algorithm, we will move on to developing the automatic partitioning.
This will depend on a subalgorithm to choose which weights which generally are optimal to remove when considering a splitting of the model.
The tradeoff between simply picking the least salient features and the least connected features to remove will be considered in depth, and we aim to use this in order to produce the first iteration of the algorithm.
If this is accomplished, we would also like to explore the possibility of constructing the network rather than simply trimming a preconstructed one.
The first step to accomplishing this is to experiment with an algorithm that also allows gradually adding weights in tandem with the partitioning.
This would allow us to achieve a more aggressive trimming if inter-partition connections could be established on the fly as necessary.
This could later progress towards a network that starts out in a minimal state and gradually develops its own optimal architecture to spread over the GPUs available.
As we are aiming more towards an algorithmic problem, we aim to test on a dataset that is more commonly used.
In the forefront here is MNIST, a large publicly available dataset of handwritten digits that represents a common benchmark for image classification.
We plan to take a relatively standard ConvNet architecture, and apply our algorithm to perform modifications automatically.
At the same time, MNIST is comparatively an extremely small dataset with very low resolution, so it may be necessary to perform experiments on larger networks to achieve better parallelization results.
We intend to do development on MNIST due to physical constraints, but we would like to explore larger datasets, time permitting.
\subsection{Important Milestones}
In general, we aim to fulfill the rough schedule outlined below.
The dates are approximate and are chosen according to either formal deadlines or seminar meeting times.
This also represents a relatively ambitious timeline; ample time is left towards the latter half of the schedule to allow for corrections.
\begin{description}
\item[1 Mar] Complete implementation of Optimal Brain Damage algorithm
\item[8 Mar] Investigate feasibility of removing large sets of weights and test out weight-picking heuristic
\item[15 Mar] Figure out MNIST dataset and current network architectures for handling it
\item[22 Mar] Checkpoint -- have a working prototype of the algorithm and be apply it to the MNIST dataset
\item[29 Mar] Test on larger datasets and structures, such as ImageNet
\item[15 Apr] Investigate feasibility of constructively rather than destructively generating partitions
\item[29 Apr] Finish final report and polish remaining code
\end{description}
%Evaluation. Describe the methodology you plan to use to evaluate how well your project has achieved the stated goal. Be specific. What data will you use? What test will you run? What quantitative metric will you use to measure success? etc. This is a very important and often over-looked aspect of a project plan – please think about it before finalizing your project selection.
\section{Evaluation}
The benchmarks on which this algorithm will be evaluated are more generally well-established.
The classification performance of modern techniques on the MNIST dataset are documented in depth, so we will aim to remain in the same general accuracy as the networks we start with.
The actual speed of running the dataset is also easily testable, so as a key component of the algorithm is creating parallelism, we will want to run it against the initial network, and see the kinds of gains we can get from varying numbers of GPUs.
As noted prior, sublinear increases in performance are significant, and we aim to approach linear scaling by better parallelization.
This step will be critical as the development of our algorithm will necessarily be informed and guided by the benchmarks and performance data that we collect.
\bibliographystyle{acm}
\bibliography{ref}
\end{document}
|
{-# LANGUAGE BangPatterns #-}
module ML.Sample (Sample(..)) where
import Numeric.LinearAlgebra (R, Vector)
-- | A training sample.
data Sample = Sample
{ sampleInput :: {-# UNPACK #-} !(Vector R)
, sampleExpectedOutput :: {-# UNPACK #-} !(Vector R)
} deriving (Read, Show)
|
lemma monom_Suc: "monom a (Suc n) = pCons 0 (monom a n)" |
[STATEMENT]
lemma rbtreeify_f_simps:
"rbtreeify_f 0 kvs = (Empty, kvs)"
"rbtreeify_f (Suc 0) ((k, v) # kvs) =
(Branch R Empty k v Empty, kvs)"
"0 < n \<Longrightarrow> rbtreeify_f (2 * n) kvs =
(case rbtreeify_f n kvs of (t1, (k, v) # kvs') \<Rightarrow>
apfst (Branch B t1 k v) (rbtreeify_g n kvs'))"
"0 < n \<Longrightarrow> rbtreeify_f (Suc (2 * n)) kvs =
(case rbtreeify_f n kvs of (t1, (k, v) # kvs') \<Rightarrow>
apfst (Branch B t1 k v) (rbtreeify_f n kvs'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (rbtreeify_f 0 kvs = (Empty, kvs) &&& rbtreeify_f (Suc 0) ((k, v) # kvs) = (Branch R Empty k v Empty, kvs)) &&& (0 < n \<Longrightarrow> rbtreeify_f (2 * n) kvs = (case rbtreeify_f n kvs of (t1, (k, v) # kvs') \<Rightarrow> apfst (Branch B t1 k v) (rbtreeify_g n kvs'))) &&& (0 < n \<Longrightarrow> rbtreeify_f (Suc (2 * n)) kvs = (case rbtreeify_f n kvs of (t1, (k, v) # kvs') \<Rightarrow> apfst (Branch B t1 k v) (rbtreeify_f n kvs')))
[PROOF STEP]
by(subst (1) rbtreeify_f.simps, simp add: Suc_double_half)+ |
Require Import Program.
Require Import SpecCert.Address.
Require Import SpecCert.Cache.
Require Import SpecCert.Formalism.
Require Import SpecCert.Interval.
Require Import SpecCert.Memory.
Require Import SpecCert.Smm.Delta.Behavior.
Require Import SpecCert.Smm.Delta.Invariant.
Require Import SpecCert.Smm.Delta.Preserve.Architecture.
Require Import SpecCert.Smm.Software.
Require Import SpecCert.x86.
Lemma nextinstr_smramc_inv
(pa: PhysicalAddress)
: preserve (NextInstruction pa) smramc_inv.
Proof.
intros_preserve.
unfold nextinstr_post in Hpost.
unfold smramc_inv.
apply update_proc_changes_only_proc in Hpost as [Hmemc _].
rewrite <- Hmemc.
apply Hsmramc.
Qed.
Lemma nextinstr_smram_code_inv
(pa: PhysicalAddress)
: preserve (NextInstruction pa) smram_code_inv.
Proof.
intros_preserve.
unfold nextinstr_post in Hpost.
unfold smram_code_inv, find_memory_content.
apply update_proc_changes_only_proc in Hpost as [_ [Hmem _]].
rewrite <- Hmem.
apply Hsmram.
Qed.
Lemma nextinstr_smrr_inv
(pa: PhysicalAddress)
: preserve (NextInstruction pa) smrr_inv.
Proof.
intros_preserve.
unfold nextinstr_post in Hpost.
rewrite Hpost.
unfold smrr_inv, find_memory_content.
simpl.
apply Hsmrr.
Qed.
Lemma nextinstr_cache_clean_inv
(pa: PhysicalAddress)
: preserve (NextInstruction pa) cache_clean_inv.
Proof.
intros_preserve.
unfold nextinstr_post in Hpost.
rewrite Hpost.
apply Hclean.
Qed.
Program Lemma nextinstr_ip_inv
(pa: PhysicalAddress)
: software_preserve (NextInstruction' pa) ip_inv.
Proof.
intros_soft_preserve.
unfold nextinstr_post in Hpost.
rewrite Hpost.
unfold ip_inv.
intro Hcont.
apply Hsmm in Hcont.
simpl in Hcont.
unfold nextinstr_behavior in Hcont.
exact Hcont.
Qed.
Lemma nextinstr_smbase_inv
(pa: PhysicalAddress)
: preserve (NextInstruction pa) smbase_inv.
Proof.
intros_preserve.
unfold nextinstr_post in Hpost.
rewrite Hpost.
apply Hsmbase.
Qed.
Lemma nextinstr_inv
(pa: PhysicalAddress)
: software_preserve (NextInstruction' pa) inv.
Proof.
unfold software_preserve.
intros a a' Hinv Hsmm Hpre Hpost.
split; [| split; [| split; [| split; [| split]]]].
* apply (nextinstr_smramc_inv pa a a' Hinv Hpre Hpost).
* apply (nextinstr_smram_code_inv pa a a' Hinv Hpre Hpost).
* apply (nextinstr_smrr_inv pa a a' Hinv Hpre Hpost).
* apply (nextinstr_cache_clean_inv pa a a' Hinv Hpre Hpost).
* apply (nextinstr_ip_inv pa a a' Hinv Hsmm Hpre Hpost).
* apply (nextinstr_smbase_inv pa a a' Hinv Hpre Hpost).
Qed. |
\chapter{Introduction}
\label{chap:intro}
\input{sections/Motivation}
\chapter{DSMC and SINATRA}
\label{chap:dsmc}
\input{sections/DSMC}
\input{sections/SINATRA}
\chapter{Systems Engineering}
\label{chap:systems}
All large aerospace projects can be viewed a group of integrated systems. The systems must be designed and managed in order to provide a reliable and efficient final product. Systems Engineering is the discipline which covers this area. SINATRA is a complex project and program which needs a smooth integration of the various program and sub-systems. This chapter will explain the various systems engineering implementations in SINATRA including documentation, workflow, and user interfaces.
\input{sections/Documentation}
\input{sections/WorkFlow}
\input{sections/UserInterfaces}
\chapter{Charged Particles}
A DSMC simulation has many applications in aerospace engineering. However, it does not capture the full picture when gasses are composes of ions and electrons. Plasma, which is composed of charged particles, needs the electrostatics to be taken into account in the simulation in order to create an accurate model. This chapter will explain how to simulate charged particles with the particle-in-cell method, how that method was implemented in SINATRA, and how the implementation was validated.
\label{chap:charge}
\input{sections/ParticleInCell}
\input{sections/Implimentation}
\input{sections/TestCases}
\chapter{Conclusions}
\label{chap:conclusions}
\input{sections/Conclusions}
\input{sections/FutureWork} |
def create_thumbnails( rule_args, callback, rei ):
import sys, os
#sys.path.insert(0,'/var/lib/irods')
#import compute.common as common
callback.writeLine ('serverLog', 'calling from PYTHON rule')
#create_thumbnails {
# *src_obj_path="/tempZone/home/rods/stickers.jpg"
# *dst_phy_dir="/tmp/irods/thumbnails"
# *err = errormsg(create_thumbnail_collection(*src_obj_path, *dst_phy_dir), *msg)
# if(0 != *err) {
# writeLine( "stdout", "FAIL: [*err] [*msg]")
# }
#}
INPUT null
OUTPUT ruleExecOut
|
open import Nat
open import Prelude
open import List
open import contexts
open import core
open import lemmas-env
module preservation where
preservation : ∀{⛽ Δ Σ' Γ E e r k τ} →
Δ , Σ' , Γ ⊢ E →
Δ , Σ' , Γ ⊢ e :: τ →
E ⊢ e ⌊ ⛽ ⌋⇒ r ⊣ k →
Δ , Σ' ⊢ r ·: τ
preservation ctxcons ta EFix = TAFix ctxcons ta
preservation ctxcons (TAVar tah) (EVar h) with env-all-Γ ctxcons tah
... | π3 , π4 , π5 rewrite ctxunicity h π4 = π5
preservation ctxcons (TAHole h) EHole = TAHole h ctxcons
preservation ctxcons TAUnit EUnit = TAUnit
preservation ctxcons (TAPair _ ta1 ta2) (EPair eval1 eval2)
= TAPair (preservation ctxcons ta1 eval1 ) (preservation ctxcons ta2 eval2)
preservation ctxcons (TACtor h1 h2 ta) (ECtor eval) = TACtor h1 h2 (preservation ctxcons ta eval)
preservation ctxcons (TAApp _ ta-f ta-arg) (EAppFix _ h eval1 eval2 eval-ef)
rewrite h
with preservation ctxcons ta-f eval1
... | TAFix ctxcons-Ef (TAFix ta-ef) =
preservation (EnvInd (EnvInd ctxcons-Ef (preservation ctxcons ta-f eval1)) (preservation ctxcons ta-arg eval2)) ta-ef eval-ef
preservation ctxcons (TAApp _ ta1 ta2) (EAppUnfinished eval1 _ eval2) =
TAApp (preservation ctxcons ta1 eval1) (preservation ctxcons ta2 eval2)
preservation ctxcons (TAFst ta) (EFst eval)
with preservation ctxcons ta eval
... | TAPair ta1 ta2 = ta1
preservation ctxcons (TAFst ta) (EFstUnfinished eval x)
= TAFst (preservation ctxcons ta eval)
preservation ctxcons (TASnd ta) (ESnd eval)
with preservation ctxcons ta eval
... | TAPair ta1 ta2 = ta2
preservation ctxcons (TASnd ta) (ESndUnfinished eval x)
= TASnd (preservation ctxcons ta eval)
preservation {Σ' = Σ'} ctxcons (TACase d∈Σ' ta h1 h2) (EMatch _ form eval-e eval-ec) with h2 form
... | _ , _ , _ , c∈cctx2 , ta-ec with preservation ctxcons ta eval-e
... | TACtor {cctx = cctx} d∈Σ'2 c∈cctx ta' with ctxunicity {Γ = π1 Σ'} d∈Σ' d∈Σ'2
... | refl with ctxunicity {Γ = cctx} c∈cctx c∈cctx2
... | refl = preservation (EnvInd ctxcons ta') ta-ec eval-ec
preservation ctxcons (TACase d∈Σ' ta h1 h2) (EMatchUnfinished eval h) =
TACase d∈Σ' ctxcons (preservation ctxcons ta eval) h1 λ form' →
let _ , _ , _ , p2 , p3 = h2 form' in
_ , p2 , p3
preservation ctxcons (TAAsrt _ ta1 ta2) (EAsrt eval1 eval2 _) = TAUnit
|
\chapter{Numerical Test-Bed} \label{sec:test-bed}
Some more foil stuff \cite{Abbott1959}.
\nomenclature[aA]{$y^+$}{Length in viscous units}
...
...
...
|
[GOAL]
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ LawfulBitraversable Prod
[PROOFSTEP]
constructor
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {α β : Type ?u.941} (x : α × β), bitraverse pure pure x = pure x
[PROOFSTEP]
intros
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {F G : Type ?u.941 → Type ?u.941} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type ?u.941} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : α × α'),
bitraverse (Functor.Comp.mk ∘ Functor.map f ∘ g) (Functor.Comp.mk ∘ Functor.map f' ∘ g') x =
Functor.Comp.mk (bitraverse f f' <$> bitraverse g g' x)
[PROOFSTEP]
intros
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {α α' β β' : Type ?u.941} (f : α → β) (f' : α' → β') (x : α × α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
[PROOFSTEP]
intros
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {F G : Type ?u.941 → Type ?u.941} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type ?u.941} (f : α → F β)
(f' : α' → F β') (x : α × α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
[PROOFSTEP]
intros
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.941
x✝ : α✝ × β✝
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
casesm _ × _
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.941 → Type ?u.941
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.941
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : α✝ × α'✝
⊢ bitraverse (Functor.Comp.mk ∘ Functor.map f✝ ∘ g✝) (Functor.Comp.mk ∘ Functor.map f'✝ ∘ g'✝) x✝ =
Functor.Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
casesm _ × _
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.941
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : α✝ × α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
casesm _ × _
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.941 → Type ?u.941
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.941
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : α✝ × α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
casesm _ × _
[GOAL]
case id_bitraverse.mk
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.941
fst✝ : α✝
snd✝ : β✝
⊢ bitraverse pure pure (fst✝, snd✝) = pure (fst✝, snd✝)
[PROOFSTEP]
simp [bitraverse, Prod.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_bitraverse.mk
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.941 → Type ?u.941
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.941
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
fst✝ : α✝
snd✝ : α'✝
⊢ bitraverse (Functor.Comp.mk ∘ Functor.map f✝ ∘ g✝) (Functor.Comp.mk ∘ Functor.map f'✝ ∘ g'✝) (fst✝, snd✝) =
Functor.Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ (fst✝, snd✝))
[PROOFSTEP]
simp [bitraverse, Prod.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id.mk
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.941
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
fst✝ : α✝
snd✝ : α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) (fst✝, snd✝) = pure (bimap f✝ f'✝ (fst✝, snd✝))
[PROOFSTEP]
simp [bitraverse, Prod.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case binaturality.mk
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.941 → Type ?u.941
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.941
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
fst✝ : α✝
snd✝ : α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ (fst✝, snd✝)) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) (fst✝, snd✝)
[PROOFSTEP]
simp [bitraverse, Prod.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case id_bitraverse.mk
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.941
fst✝ : α✝
snd✝ : β✝
⊢ (Seq.seq (Prod.mk fst✝) fun x => snd✝) = (fst✝, snd✝)
[PROOFSTEP]
rfl
[GOAL]
case comp_bitraverse.mk
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.941 → Type ?u.941
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.941
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
fst✝ : α✝
snd✝ : α'✝
⊢ Functor.Comp.mk
(Seq.seq
(((fun x => x ∘ f'✝) ∘ (fun x x_1 => Seq.seq x fun x => x_1) ∘ (fun x => Prod.mk <$> x) ∘ f✝) <$> g✝ fst✝)
fun x => g'✝ snd✝) =
Functor.Comp.mk
(Seq.seq (((fun x => (fun x => Seq.seq (Prod.mk <$> f✝ x.fst) fun x_1 => f'✝ x.snd) ∘ x) ∘ Prod.mk) <$> g✝ fst✝)
fun x => g'✝ snd✝)
[PROOFSTEP]
rfl
[GOAL]
case bitraverse_eq_bimap_id.mk
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.941
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
fst✝ : α✝
snd✝ : α'✝
⊢ (Seq.seq (Prod.mk (f✝ fst✝)) fun x => f'✝ snd✝) = bimap f✝ f'✝ (fst✝, snd✝)
[PROOFSTEP]
rfl
[GOAL]
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ LawfulBitraversable Sum
[PROOFSTEP]
constructor
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {α β : Type ?u.14627} (x : α ⊕ β), bitraverse pure pure x = pure x
[PROOFSTEP]
intros
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {F G : Type ?u.14627 → Type ?u.14627} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type ?u.14627} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : α ⊕ α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
[PROOFSTEP]
intros
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {α α' β β' : Type ?u.14627} (f : α → β) (f' : α' → β') (x : α ⊕ α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
[PROOFSTEP]
intros
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {F G : Type ?u.14627 → Type ?u.14627} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type ?u.14627} (f : α → F β)
(f' : α' → F β') (x : α ⊕ α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
[PROOFSTEP]
intros
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.14627
x✝ : α✝ ⊕ β✝
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
casesm _ ⊕ _
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.14627
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : α✝ ⊕ α'✝
⊢ bitraverse (Comp.mk ∘ map f✝ ∘ g✝) (Comp.mk ∘ map f'✝ ∘ g'✝) x✝ = Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
casesm _ ⊕ _
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : α✝ ⊕ α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
casesm _ ⊕ _
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : α✝ ⊕ α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
casesm _ ⊕ _
[GOAL]
case id_bitraverse.inl
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.14627
val✝ : α✝
⊢ bitraverse pure pure (Sum.inl val✝) = pure (Sum.inl val✝)
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case id_bitraverse.inr
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.14627
val✝ : β✝
⊢ bitraverse pure pure (Sum.inr val✝) = pure (Sum.inr val✝)
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_bitraverse.inl
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.14627
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
val✝ : α✝
⊢ bitraverse (Comp.mk ∘ map f✝ ∘ g✝) (Comp.mk ∘ map f'✝ ∘ g'✝) (Sum.inl val✝) =
Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ (Sum.inl val✝))
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_bitraverse.inr
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.14627
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
val✝ : α'✝
⊢ bitraverse (Comp.mk ∘ map f✝ ∘ g✝) (Comp.mk ∘ map f'✝ ∘ g'✝) (Sum.inr val✝) =
Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ (Sum.inr val✝))
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id.inl
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
val✝ : α✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) (Sum.inl val✝) = pure (bimap f✝ f'✝ (Sum.inl val✝))
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id.inr
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
val✝ : α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) (Sum.inr val✝) = pure (bimap f✝ f'✝ (Sum.inr val✝))
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case binaturality.inl
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
val✝ : α✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ (Sum.inl val✝)) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) (Sum.inl val✝)
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case binaturality.inr
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
val✝ : α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ (Sum.inr val✝)) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) (Sum.inr val✝)
[PROOFSTEP]
simp [bitraverse, Sum.bitraverse, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_bitraverse.inl
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.14627
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
val✝ : α✝
⊢ Comp.mk (((fun x => Sum.inl <$> x) ∘ f✝) <$> g✝ val✝) =
Comp.mk
(((fun x =>
match x with
| Sum.inl x => Sum.inl <$> f✝ x
| Sum.inr x => Sum.inr <$> f'✝ x) ∘
Sum.inl) <$>
g✝ val✝)
[PROOFSTEP]
rfl
[GOAL]
case comp_bitraverse.inr
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.14627 → Type ?u.14627
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.14627
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
val✝ : α'✝
⊢ Comp.mk (((fun x => Sum.inr <$> x) ∘ f'✝) <$> g'✝ val✝) =
Comp.mk
(((fun x =>
match x with
| Sum.inl x => Sum.inl <$> f✝ x
| Sum.inr x => Sum.inr <$> f'✝ x) ∘
Sum.inr) <$>
g'✝ val✝)
[PROOFSTEP]
rfl
[GOAL]
case bitraverse_eq_bimap_id.inl
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
val✝ : α✝
⊢ Sum.inl (f✝ val✝) = bimap f✝ f'✝ (Sum.inl val✝)
[PROOFSTEP]
rfl
[GOAL]
case bitraverse_eq_bimap_id.inr
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.14627
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
val✝ : α'✝
⊢ Sum.inr (f'✝ val✝) = bimap f✝ f'✝ (Sum.inr val✝)
[PROOFSTEP]
rfl
[GOAL]
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ LawfulBitraversable Const
[PROOFSTEP]
constructor
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {α β : Type ?u.21603} (x : Const α β), bitraverse pure pure x = pure x
[PROOFSTEP]
intros
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {F G : Type ?u.21603 → Type ?u.21603} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type ?u.21603} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : Const α α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
[PROOFSTEP]
intros
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {α α' β β' : Type ?u.21603} (f : α → β) (f' : α' → β') (x : Const α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
[PROOFSTEP]
intros
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
⊢ ∀ {F G : Type ?u.21603 → Type ?u.21603} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type ?u.21603} (f : α → F β)
(f' : α' → F β') (x : Const α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
[PROOFSTEP]
intros
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type ?u.21603
x✝ : Const α✝ β✝
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
simp [bitraverse, Const.bitraverse, functor_norm]
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.21603 → Type ?u.21603
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type ?u.21603
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : Const α✝ α'✝
⊢ bitraverse (Comp.mk ∘ map f✝ ∘ g✝) (Comp.mk ∘ map f'✝ ∘ g'✝) x✝ = Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
simp [bitraverse, Const.bitraverse, functor_norm]
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.21603
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : Const α✝ α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
simp [bitraverse, Const.bitraverse, functor_norm]
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.21603 → Type ?u.21603
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.21603
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : Const α✝ α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
simp [bitraverse, Const.bitraverse, functor_norm]
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type ?u.21603
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : Const α✝ α'✝
⊢ f✝ x✝ = bimap f✝ f'✝ x✝
[PROOFSTEP]
rfl
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type ?u.21603 → Type ?u.21603
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type ?u.21603
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : Const α✝ α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (f✝ x✝) = (fun {α} => ApplicativeTransformation.app η✝ α) (f✝ x✝)
[PROOFSTEP]
rfl
[GOAL]
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
⊢ LawfulBitraversable (_root_.flip t)
[PROOFSTEP]
constructor
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
⊢ ∀ {α β : Type u} (x : _root_.flip t α β), bitraverse pure pure x = pure x
[PROOFSTEP]
intros
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
⊢ ∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : _root_.flip t α α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
[PROOFSTEP]
intros
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
⊢ ∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : _root_.flip t α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
[PROOFSTEP]
intros
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
⊢ ∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type u} (f : α → F β)
(f' : α' → F β') (x : _root_.flip t α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
[PROOFSTEP]
intros
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α✝ β✝ : Type u
x✝ : _root_.flip t α✝ β✝
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
casesm LawfulBitraversable t
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁶ : Bitraversable t
F : Type u → Type u
inst✝⁵ : Applicative F
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type u
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : _root_.flip t α✝ α'✝
⊢ bitraverse (Comp.mk ∘ map f✝ ∘ g✝) (Comp.mk ∘ map f'✝ ∘ g'✝) x✝ = Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
casesm LawfulBitraversable t
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : _root_.flip t α✝ α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
casesm LawfulBitraversable t
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁶ : Bitraversable t
F : Type u → Type u
inst✝⁵ : Applicative F
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : _root_.flip t α✝ α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
casesm LawfulBitraversable t
[GOAL]
case id_bitraverse.mk
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ β✝ : Type u
x✝ : _root_.flip t α✝ β✝
toLawfulBifunctor✝ : LawfulBifunctor t
id_bitraverse✝ : ∀ {α β : Type u} (x : t α β), bitraverse pure pure x = pure x
comp_bitraverse✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : t α α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
bitraverse_eq_bimap_id✝ :
∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : t α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
binaturality✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type u} (f : α → F β)
(f' : α' → F β') (x : t α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
apply_assumption only [*]
[GOAL]
case comp_bitraverse.mk
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type u
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : _root_.flip t α✝ α'✝
toLawfulBifunctor✝ : LawfulBifunctor t
id_bitraverse✝ : ∀ {α β : Type u} (x : t α β), bitraverse pure pure x = pure x
comp_bitraverse✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : t α α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
bitraverse_eq_bimap_id✝ :
∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : t α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
binaturality✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type u} (f : α → F β)
(f' : α' → F β') (x : t α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
⊢ bitraverse (Comp.mk ∘ map f✝ ∘ g✝) (Comp.mk ∘ map f'✝ ∘ g'✝) x✝ = Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
apply_assumption only [*]
[GOAL]
case bitraverse_eq_bimap_id.mk
t : Type u → Type u → Type u
inst✝¹ : Bitraversable t
F : Type u → Type u
inst✝ : Applicative F
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : _root_.flip t α✝ α'✝
toLawfulBifunctor✝ : LawfulBifunctor t
id_bitraverse✝ : ∀ {α β : Type u} (x : t α β), bitraverse pure pure x = pure x
comp_bitraverse✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : t α α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
bitraverse_eq_bimap_id✝ :
∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : t α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
binaturality✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type u} (f : α → F β)
(f' : α' → F β') (x : t α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
apply_assumption only [*]
[GOAL]
case binaturality.mk
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F : Type u → Type u
inst✝⁴ : Applicative F
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : _root_.flip t α✝ α'✝
toLawfulBifunctor✝ : LawfulBifunctor t
id_bitraverse✝ : ∀ {α β : Type u} (x : t α β), bitraverse pure pure x = pure x
comp_bitraverse✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F γ) (f' : β' → F γ') (g : α → G β)
(g' : α' → G β') (x : t α α'),
bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x = Comp.mk (bitraverse f f' <$> bitraverse g g' x)
bitraverse_eq_bimap_id✝ :
∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : t α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
binaturality✝ :
∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type u} (f : α → F β)
(f' : α' → F β') (x : t α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
apply_assumption only [*]
[GOAL]
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α : Type u
⊢ LawfulTraversable (t α)
[PROOFSTEP]
constructor
[GOAL]
case id_traverse
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α : Type u
⊢ ∀ {α_1 : Type u} (x : t α α_1), traverse pure x = x
[PROOFSTEP]
intros
[GOAL]
case comp_traverse
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α : Type u
⊢ ∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] {α_1 β γ : Type u} (f : β → F γ) (g : α_1 → G β) (x : t α α_1),
traverse (Comp.mk ∘ map f ∘ g) x = Comp.mk (traverse f <$> traverse g x)
[PROOFSTEP]
intros
[GOAL]
case traverse_eq_map_id
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α : Type u
⊢ ∀ {α_1 β : Type u} (f : α_1 → β) (x : t α α_1), traverse (pure ∘ f) x = id.mk (f <$> x)
[PROOFSTEP]
intros
[GOAL]
case naturality
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α : Type u
⊢ ∀ {F G : Type u → Type u} [inst : Applicative F] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F G) {α_1 β : Type u} (f : α_1 → F β) (x : t α α_1),
(fun {α} => ApplicativeTransformation.app η α) (traverse f x) =
traverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f) x
[PROOFSTEP]
intros
[GOAL]
case id_traverse
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α α✝ : Type u
x✝ : t α α✝
⊢ traverse pure x✝ = x✝
[PROOFSTEP]
simp [traverse, comp_tsnd, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_traverse
t : Type u → Type u → Type u
inst✝⁶ : Bitraversable t
F : Type u → Type u
inst✝⁵ : Applicative F
inst✝⁴ : LawfulBitraversable t
α : Type u
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ β✝ γ✝ : Type u
f✝ : β✝ → F✝ γ✝
g✝ : α✝ → G✝ β✝
x✝ : t α α✝
⊢ traverse (Comp.mk ∘ map f✝ ∘ g✝) x✝ = Comp.mk (traverse f✝ <$> traverse g✝ x✝)
[PROOFSTEP]
simp [traverse, comp_tsnd, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case traverse_eq_map_id
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α α✝ β✝ : Type u
f✝ : α✝ → β✝
x✝ : t α α✝
⊢ traverse (pure ∘ f✝) x✝ = id.mk (f✝ <$> x✝)
[PROOFSTEP]
simp [traverse, comp_tsnd, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case naturality
t : Type u → Type u → Type u
inst✝⁶ : Bitraversable t
F : Type u → Type u
inst✝⁵ : Applicative F
inst✝⁴ : LawfulBitraversable t
α : Type u
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ β✝ : Type u
f✝ : α✝ → F✝ β✝
x✝ : t α α✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (traverse f✝ x✝) =
traverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝) x✝
[PROOFSTEP]
simp [traverse, comp_tsnd, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case traverse_eq_map_id
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α α✝ β✝ : Type u
f✝ : α✝ → β✝
x✝ : t α α✝
⊢ tsnd (pure ∘ f✝) x✝ = id.mk (f✝ <$> x✝)
[PROOFSTEP]
simp [tsnd_eq_snd_id]
[GOAL]
case traverse_eq_map_id
t : Type u → Type u → Type u
inst✝² : Bitraversable t
F : Type u → Type u
inst✝¹ : Applicative F
inst✝ : LawfulBitraversable t
α α✝ β✝ : Type u
f✝ : α✝ → β✝
x✝ : t α α✝
⊢ Bifunctor.snd f✝ x✝ = id.mk (f✝ <$> x✝)
[PROOFSTEP]
rfl
[GOAL]
case naturality
t : Type u → Type u → Type u
inst✝⁶ : Bitraversable t
F : Type u → Type u
inst✝⁵ : Applicative F
inst✝⁴ : LawfulBitraversable t
α : Type u
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ β✝ : Type u
f✝ : α✝ → F✝ β✝
x✝ : t α α✝
⊢ ApplicativeTransformation.app η✝ (t α β✝) (tsnd f✝ x✝) = tsnd (ApplicativeTransformation.app η✝ β✝ ∘ f✝) x✝
[PROOFSTEP]
simp [tsnd, binaturality, Function.comp, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
⊢ LawfulBitraversable (bicompl t F G)
[PROOFSTEP]
constructor
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
⊢ ∀ {α β : Type u} (x : bicompl t F G α β), bitraverse pure pure x = pure x
[PROOFSTEP]
intros
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
⊢ ∀ {F_1 G_1 : Type u → Type u} [inst : Applicative F_1] [inst_1 : Applicative G_1] [inst_2 : LawfulApplicative F_1]
[inst_3 : LawfulApplicative G_1] {α α' β β' γ γ' : Type u} (f : β → F_1 γ) (f' : β' → F_1 γ') (g : α → G_1 β)
(g' : α' → G_1 β') (x : bicompl t F G α α'),
bitraverse (Functor.Comp.mk ∘ Functor.map f ∘ g) (Functor.Comp.mk ∘ Functor.map f' ∘ g') x =
Functor.Comp.mk (bitraverse f f' <$> bitraverse g g' x)
[PROOFSTEP]
intros
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
⊢ ∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : bicompl t F G α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
[PROOFSTEP]
intros
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
⊢ ∀ {F_1 G_1 : Type u → Type u} [inst : Applicative F_1] [inst_1 : Applicative G_1] [inst_2 : LawfulApplicative F_1]
[inst_3 : LawfulApplicative G_1] (η : ApplicativeTransformation F_1 G_1) {α α' β β' : Type u} (f : α → F_1 β)
(f' : α' → F_1 β') (x : bicompl t F G α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
[PROOFSTEP]
intros
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
α✝ β✝ : Type u
x✝ : bicompl t F G α✝ β✝
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
simp [bitraverse, Bicompl.bitraverse, bimap, traverse_id, bitraverse_id_id, comp_bitraverse, functor_norm,
-ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁹ : Bitraversable t
F G : Type u → Type u
inst✝⁸ : Traversable F
inst✝⁷ : Traversable G
inst✝⁶ : LawfulTraversable F
inst✝⁵ : LawfulTraversable G
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type u
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : bicompl t F G α✝ α'✝
⊢ bitraverse (Functor.Comp.mk ∘ Functor.map f✝ ∘ g✝) (Functor.Comp.mk ∘ Functor.map f'✝ ∘ g'✝) x✝ =
Functor.Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
simp [bitraverse, Bicompl.bitraverse, bimap, traverse_id, bitraverse_id_id, comp_bitraverse, functor_norm,
-ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : bicompl t F G α✝ α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
simp [bitraverse, Bicompl.bitraverse, bimap, traverse_id, bitraverse_id_id, comp_bitraverse, functor_norm,
-ApplicativeTransformation.app_eq_coe]
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁹ : Bitraversable t
F G : Type u → Type u
inst✝⁸ : Traversable F
inst✝⁷ : Traversable G
inst✝⁶ : LawfulTraversable F
inst✝⁵ : LawfulTraversable G
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : bicompl t F G α✝ α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
simp [bitraverse, Bicompl.bitraverse, bimap, traverse_id, bitraverse_id_id, comp_bitraverse, functor_norm,
-ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝⁵ : Bitraversable t
F G : Type u → Type u
inst✝⁴ : Traversable F
inst✝³ : Traversable G
inst✝² : LawfulTraversable F
inst✝¹ : LawfulTraversable G
inst✝ : LawfulBitraversable t
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : bicompl t F G α✝ α'✝
⊢ bitraverse (traverse (pure ∘ f✝)) (traverse (pure ∘ f'✝)) x✝ = bimap (Functor.map f✝) (Functor.map f'✝) x✝
[PROOFSTEP]
simp [traverse_eq_map_id', bitraverse_eq_bimap_id]
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁹ : Bitraversable t
F G : Type u → Type u
inst✝⁸ : Traversable F
inst✝⁷ : Traversable G
inst✝⁶ : LawfulTraversable F
inst✝⁵ : LawfulTraversable G
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : bicompl t F G α✝ α'✝
⊢ ApplicativeTransformation.app η✝ (bicompl t F G β✝ β'✝) (bitraverse (traverse f✝) (traverse f'✝) x✝) =
bitraverse (traverse (ApplicativeTransformation.app η✝ β✝ ∘ f✝))
(traverse (ApplicativeTransformation.app η✝ β'✝ ∘ f'✝)) x✝
[PROOFSTEP]
dsimp only [bicompl]
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁹ : Bitraversable t
F G : Type u → Type u
inst✝⁸ : Traversable F
inst✝⁷ : Traversable G
inst✝⁶ : LawfulTraversable F
inst✝⁵ : LawfulTraversable G
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : bicompl t F G α✝ α'✝
⊢ ApplicativeTransformation.app η✝ (t (F β✝) (G β'✝)) (bitraverse (traverse f✝) (traverse f'✝) x✝) =
bitraverse (traverse (ApplicativeTransformation.app η✝ β✝ ∘ f✝))
(traverse (ApplicativeTransformation.app η✝ β'✝ ∘ f'✝)) x✝
[PROOFSTEP]
simp [binaturality, naturality_pf]
[GOAL]
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
⊢ LawfulBitraversable (bicompr F t)
[PROOFSTEP]
constructor
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
⊢ ∀ {α β : Type u} (x : bicompr F t α β), bitraverse pure pure x = pure x
[PROOFSTEP]
intros
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
⊢ ∀ {F_1 G : Type u → Type u} [inst : Applicative F_1] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F_1]
[inst_3 : LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F_1 γ) (f' : β' → F_1 γ') (g : α → G β)
(g' : α' → G β') (x : bicompr F t α α'),
bitraverse (Functor.Comp.mk ∘ Functor.map f ∘ g) (Functor.Comp.mk ∘ Functor.map f' ∘ g') x =
Functor.Comp.mk (bitraverse f f' <$> bitraverse g g' x)
[PROOFSTEP]
intros
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
⊢ ∀ {α α' β β' : Type u} (f : α → β) (f' : α' → β') (x : bicompr F t α α'),
bitraverse (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)
[PROOFSTEP]
intros
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
⊢ ∀ {F_1 G : Type u → Type u} [inst : Applicative F_1] [inst_1 : Applicative G] [inst_2 : LawfulApplicative F_1]
[inst_3 : LawfulApplicative G] (η : ApplicativeTransformation F_1 G) {α α' β β' : Type u} (f : α → F_1 β)
(f' : α' → F_1 β') (x : bicompr F t α α'),
(fun {α} => ApplicativeTransformation.app η α) (bitraverse f f' x) =
bitraverse ((fun {α} => ApplicativeTransformation.app η α) ∘ f)
((fun {α} => ApplicativeTransformation.app η α) ∘ f') x
[PROOFSTEP]
intros
[GOAL]
case id_bitraverse
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
α✝ β✝ : Type u
x✝ : bicompr F t α✝ β✝
⊢ bitraverse pure pure x✝ = pure x✝
[PROOFSTEP]
simp [bitraverse, Bicompr.bitraverse, bitraverse_id_id, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case comp_bitraverse
t : Type u → Type u → Type u
inst✝⁷ : Bitraversable t
F : Type u → Type u
inst✝⁶ : Traversable F
inst✝⁵ : LawfulTraversable F
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
α✝ α'✝ β✝ β'✝ γ✝ γ'✝ : Type u
f✝ : β✝ → F✝ γ✝
f'✝ : β'✝ → F✝ γ'✝
g✝ : α✝ → G✝ β✝
g'✝ : α'✝ → G✝ β'✝
x✝ : bicompr F t α✝ α'✝
⊢ bitraverse (Functor.Comp.mk ∘ Functor.map f✝ ∘ g✝) (Functor.Comp.mk ∘ Functor.map f'✝ ∘ g'✝) x✝ =
Functor.Comp.mk (bitraverse f✝ f'✝ <$> bitraverse g✝ g'✝ x✝)
[PROOFSTEP]
simp [bitraverse, Bicompr.bitraverse, bitraverse_id_id, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : bicompr F t α✝ α'✝
⊢ bitraverse (pure ∘ f✝) (pure ∘ f'✝) x✝ = pure (bimap f✝ f'✝ x✝)
[PROOFSTEP]
simp [bitraverse, Bicompr.bitraverse, bitraverse_id_id, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁷ : Bitraversable t
F : Type u → Type u
inst✝⁶ : Traversable F
inst✝⁵ : LawfulTraversable F
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : bicompr F t α✝ α'✝
⊢ (fun {α} => ApplicativeTransformation.app η✝ α) (bitraverse f✝ f'✝ x✝) =
bitraverse ((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f✝)
((fun {α} => ApplicativeTransformation.app η✝ α) ∘ f'✝) x✝
[PROOFSTEP]
simp [bitraverse, Bicompr.bitraverse, bitraverse_id_id, functor_norm, -ApplicativeTransformation.app_eq_coe]
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : bicompr F t α✝ α'✝
⊢ traverse (bitraverse (pure ∘ f✝) (pure ∘ f'✝)) x✝ = bimap f✝ f'✝ x✝
[PROOFSTEP]
simp [bitraverse_eq_bimap_id', traverse_eq_map_id']
[GOAL]
case bitraverse_eq_bimap_id
t : Type u → Type u → Type u
inst✝³ : Bitraversable t
F : Type u → Type u
inst✝² : Traversable F
inst✝¹ : LawfulTraversable F
inst✝ : LawfulBitraversable t
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → β✝
f'✝ : α'✝ → β'✝
x✝ : bicompr F t α✝ α'✝
⊢ bimap f✝ f'✝ <$> x✝ = bimap f✝ f'✝ x✝
[PROOFSTEP]
rfl
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁷ : Bitraversable t
F : Type u → Type u
inst✝⁶ : Traversable F
inst✝⁵ : LawfulTraversable F
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : bicompr F t α✝ α'✝
⊢ ApplicativeTransformation.app η✝ (bicompr F t β✝ β'✝) (traverse (bitraverse f✝ f'✝) x✝) =
traverse (bitraverse (ApplicativeTransformation.app η✝ β✝ ∘ f✝) (ApplicativeTransformation.app η✝ β'✝ ∘ f'✝)) x✝
[PROOFSTEP]
dsimp only [bicompr]
[GOAL]
case binaturality
t : Type u → Type u → Type u
inst✝⁷ : Bitraversable t
F : Type u → Type u
inst✝⁶ : Traversable F
inst✝⁵ : LawfulTraversable F
inst✝⁴ : LawfulBitraversable t
F✝ G✝ : Type u → Type u
inst✝³ : Applicative F✝
inst✝² : Applicative G✝
inst✝¹ : LawfulApplicative F✝
inst✝ : LawfulApplicative G✝
η✝ : ApplicativeTransformation F✝ G✝
α✝ α'✝ β✝ β'✝ : Type u
f✝ : α✝ → F✝ β✝
f'✝ : α'✝ → F✝ β'✝
x✝ : bicompr F t α✝ α'✝
⊢ ApplicativeTransformation.app η✝ (F (t β✝ β'✝)) (traverse (bitraverse f✝ f'✝) x✝) =
traverse (bitraverse (ApplicativeTransformation.app η✝ β✝ ∘ f✝) (ApplicativeTransformation.app η✝ β'✝ ∘ f'✝)) x✝
[PROOFSTEP]
simp [naturality, binaturality']
|
(******************************************************************************)
(** * Events of the Power memory model *)
(******************************************************************************)
Require Import Hahn.
Require Import Basic Events.
Require Export Events.
Set Implicit Arguments.
Remove Hints plus_n_O.
Inductive label :=
| Aload (l: location) (v: value)
| Astore (l: location) (v: value)
| Afence_lwsync
| Afence_sync.
Definition init_label l := (Astore l 0).
Section Labels.
Variable lab : event -> label.
Definition loc a :=
match lab a with
| Aload l _
| Astore l _ => Some l
| _ => None
end.
Definition val a :=
match lab a with
| Aload _ v
| Astore _ v => Some v
| _ => None
end.
Definition is_r a :=
match lab a with
| Aload _ _ => True
| _ => False
end.
Definition is_w a :=
match lab a with
| Astore _ _ => True
| _ => False
end.
Definition is_f_sync a :=
match lab a with
| Afence_sync => True
| _ => False
end.
Definition is_f_lwsync a :=
match lab a with
| Afence_lwsync => True
| _ => False
end.
End Labels.
Lemma eq_dec_labels :
forall x y : label, {x = y} + {x <> y}.
Proof.
repeat decide equality.
Qed. |
The perfect 3 step strategy that turns losing FB campaigns into high quality leads… and convert leads into high paying customers.
Discover the complete guide to dominate FB marketing.
Discover how to leverage video and get more eyeballs to your offer.
Discover how FB will do all the work for you saving you time and money.
Discover how to skyrocket your ROI on every Facebook ads campaign. |
import Lean4Axiomatic.AbstractAlgebra.Commutative
import Lean4Axiomatic.AbstractAlgebra.Core
namespace Lean4Axiomatic.AA
open Relation.Equivalence (EqvOp)
/-!
# (Generalized) substitution and related properties
Generalized substitution allows the equalities of the ordinary substitution
property to be replaced by arbitrary binary relations.
## Substitution
### Definitions
-/
/--
Class for types and operations that satisfy the unary generalized substitution
property.
For more information see `Substitutive₁.subst₁`.
**Named parameters**
- `α`: the argument type of the unary operation `f`.
- `β`: the result type of the unary operation `f`.
- `f`: the unary operation that obeys the generalized substitution property.
- `rα`: a binary relation over `f`'s argument type `α`.
- `rβ`: a binary relation over `f`'s result type `β`.
-/
class Substitutive₁
{α : Sort u} {β : Sort v}
(f : α → β) (rα : outParam (α → α → Prop)) (rβ : β → β → Prop)
:=
/--
The generalized substitution property of an unary operation `f`.
An `f` that satisfies this property must map values of type `α` that are
related by `rα` to values of type `β` that are related by `rβ`.
Often `α` and `β` will be the same type, and `rα` and `rβ` will be the same
relation. The canonical example is the ordinary
[substitution property of equality](https://w.wiki/4vEu): if we have `x = y`
for any values `x` and `y`, then we know `f x = f y`.
**Named parameters**
- see `Substitutive₁` for the class parameters.
- `x₁` and `x₂`: the arguments to `f`, related by `rα`.
-/
subst₁ {x₁ x₂ : α} : rα x₁ x₂ → rβ (f x₁) (f x₂)
export Substitutive₁ (subst₁)
/--
Convenience function for the unary generalized substitution property, for a
predicate `f`.
Type inference for `subst₁` gets stuck when the output relation is `(· → ·)`;
this helper works around that issue by hardcoding the argument.
See `subst₁` for further documentation.
**Named parameters**
- `α`: The `Sort` of `f`'s input parameter.
- `f`: The unary predicate that obeys the generalized substitution property.
- `rα`: A binary relation on `f`'s input values.
- See `subst₁` for documentation on the remaining parameters.
-/
abbrev substFn {α : Sort u} {f : α → Prop} {rα : α → α → Prop} :=
@subst₁ α (β := Prop) f rα (rβ := (· → ·))
/--
Class for types and operations that satisfy the unary generalized injective
property.
For more information see `Injective.inject`.
**Named parameters**
- `α`: the argument type of the unary operation `f`.
- `β`: the result type of the unary operation `f`.
- `f`: the unary operation that obeys the generalized injective property.
- `rα`: a binary relation over `f`'s argument type `α`.
- `rβ`: a binary relation over `f`'s result type `β`.
-/
class Injective
{α : Sort u} {β : Sort v}
(f : outParam (α → β)) (rα : outParam (α → α → Prop)) (rβ : β → β → Prop)
:=
/--
The generalized injective property of an unary operation `f`.
Operations `f` that have this property can be traced backward in some sense.
It is the converse of the substitution property. In other words, if we know
that the results of two operations, `f x₁` and `f x₂`, are related by `rβ`,
then we can conclude that the inputs `x₁` and `x₂` are related by `rα`.
Often `α` and `β` will be the same type, and `rα` and `rβ` will be the same
relation. The canonical example is the ordinary
[injective property of functions](https://w.wiki/4vTb): if we have
`f x = f y` for any values `x` and `y`, then we know `x = y`.
**Named parameters**
- see `Injective` for the class parameters.
- `x₁` and `x₂`: the arguments to `f`.
-/
inject {x₁ x₂ : α} : rβ (f x₁) (f x₂) → rα x₁ x₂
export Injective (inject)
section neqv
variable {α : Sort u} {β : Sort v} [EqvOp α] [EqvOp β] {f : α → β}
/--
A function is substitutive over non-equivalence if it's injective over
equivalence.
**Property and proof intuition**: It's the contrapositive of the injective
property.
-/
theorem subst_neqv
{x₁ x₂ : α} [Injective f (· ≃ ·) (· ≃ ·)] : x₁ ≄ x₂ → f x₁ ≄ f x₂
:= by
intro (_ : x₁ ≃ x₂ → False) (_ : f x₁ ≃ f x₂)
show False
apply ‹x₁ ≃ x₂ → False›
show x₁ ≃ x₂
exact inject ‹f x₁ ≃ f x₂›
instance substitutive_neqv_from_injective_eqv
[Injective f (· ≃ ·) (· ≃ ·)] : Substitutive₁ f (· ≄ ·) (· ≄ ·)
:= {
subst₁ := subst_neqv
}
/--
A function is injective over non-equivalence if it's substitutive over
equivalence.
**Property and proof intuition**: It's the contrapositive of the substitutive
property.
-/
theorem inject_neqv
{x₁ x₂ : α} [Substitutive₁ f (· ≃ ·) (· ≃ ·)] : f x₁ ≄ f x₂ → x₁ ≄ x₂
:= by
intro (_ : f x₁ ≃ f x₂ → False) (_ : x₁ ≃ x₂)
show False
apply ‹f x₁ ≃ f x₂ → False›
show f x₁ ≃ f x₂
exact subst₁ ‹x₁ ≃ x₂›
instance injective_neqv_from_substitutive_eqv
[Substitutive₁ f (· ≃ ·) (· ≃ ·)] : Injective f (· ≄ ·) (· ≄ ·)
:= {
inject := inject_neqv
}
end neqv
/--
Class for types and operations that satisfy either the left- or right-handed
heterogeneous binary generalized substitution property.
For more information see `SubstitutiveOn.subst₂`.
**Named parameters**
- `hand`:
Indicates whether the property is left- or right-handed.
- `α`:
The `Sort` of `f`'s left-hand parameter.
- `β`:
The `Sort` of `f`'s right-hand parameter.
- `γ`:
The `Sort` of `f`'s result.
- `f`:
The heterogeneous binary operation that obeys the generalized substitution
property.
- `C`:
A constraint that the non-`hand` argument to `f` must meet.
- `inputRel`:
A binary relation on values of `α` or `β`, whichever is selected by `hand`.
- `outputRel`:
A binary relation on values of `γ`.
-/
class SubstitutiveOn
(hand : Hand) {α β : Sort u} {γ : Sort v} (f : α → β → γ)
(C : outParam (hand.pick β α → Prop))
(inputRel : outParam (hand.pick α β → hand.pick α β → Prop))
(outputRel : γ → γ → Prop)
:=
/--
The left- or right-handed generalized substitution property of a
heterogeneous binary operation `f`.
An `f` that satisfies this property must map values of one of its input sorts
(either `α` or `β`) that are related by `inputRel` to values of sort `γ` that
are related by `outputRel`. If `hand` is `Hand.L`, then the input sort is `α`
because that's the one for `f`'s left-hand parameter. Similarly, `Hand.R`
picks `β` for the input sort.
Often `α`, `β`, and `γ` will be the same sort, and `inputRel` and `outputRel`
will be the same relation. A simple example is addition on natural numbers:
if we know `n₁ ≃ n₂`, then we can conclude that `n₁ + m ≃ n₂ + m`, or that
`m + n₁ ≃ m + n₂`.
More advanced applications may require a nontrivial constraint `C` on `y`; an
example is that `x₁ < x₂` implies `x₁ * y < x₂ * y` only for positive `y`.
**Named parameters**
- See `SubstitutiveOn` for the class parameters.
- `x₁` and `x₂`:
The arguments to `f`, related by `inputRel`; the `hand` parameter
indicates which side of `f` they are given on.
- `y`:
The other argument to `f`; goes on the side opposite `hand`.
- `cy`:
Evidence that the constraint on `y` is satisfied.
-/
subst₂
{x₁ x₂ : hand.pick α β} {y : hand.pick β α} (cy : C y)
: inputRel x₁ x₂ → outputRel (hand.hAlign f x₁ y) (hand.hAlign f x₂ y)
export SubstitutiveOn (subst₂)
/--
Convenience function for the left-handed binary generalized substitution
property, for a homogeneous `f` without a constraint on `y`.
Can often resolve cases where type inference gets stuck when using the more
general `subst₂` function.
See `SubstitutiveOn.subst₂` for detailed documentation.
**Named parameters**
- `α`:
The `Sort` of `f`'s input parameters.
- `β`:
The `Sort` of `f`'s result.
- `f`:
The homogeneous binary operation that obeys the left-handed generalized
substitution property.
- `rα`:
A binary relation on `f`'s input values.
- `rβ`:
A binary relation on `f`'s output values.
- `x₁`, `x₂`:
The left-hand arguments to `f`, related by `rα`.
- `y`:
The right-hand argument to `f`.
-/
abbrev substL
{α : Sort u} {β : Sort v} {f : α → α → β} {rα : α → α → Prop}
{rβ : β → β → Prop} [self : SubstitutiveOn Hand.L f tc rα rβ] {x₁ x₂ y : α}
:=
@subst₂ Hand.L α α β f tc rα rβ self x₁ x₂ y True.intro
/--
Convenience function for the right-handed binary generalized substitution
property, for a homogeneous `f` without a constraint on `y`.
Can often resolve cases where type inference gets stuck when using the more
general `subst₂` function.
See `SubstitutiveOn.subst₂` for detailed documentation.
**Named parameters**
- `α`:
The `Sort` of `f`'s input parameters.
- `β`:
The `Sort` of `f`'s result.
- `f`:
The homogeneous binary operation that obeys the right-handed generalized
substitution property.
- `rα`:
A binary relation on `f`'s input values.
- `rβ`:
A binary relation on `f`'s output values.
- `x₁`, `x₂`:
The right-hand arguments to `f`, related by `rα`.
- `y`:
The left-hand argument to `f`.
-/
abbrev substR
{α : Sort u} {β : Sort v} {f : α → α → β} {rα : α → α → Prop}
{rβ : β → β → Prop} [self : SubstitutiveOn Hand.R f tc rα rβ] {x₁ x₂ y : α}
:=
@subst₂ Hand.R α α β f tc rα rβ self x₁ x₂ y True.intro
/--
Convenience function for the left-handed binary generalized substitution
property, for a homogeneous predicate `f` without a constraint on `y`.
Type inference for `substL` gets stuck when the output relation is `(· → ·)`;
this helper works around that issue by hardcoding the argument.
See `substL` for further documentation.
**Named parameters**
- `α`:
The `Sort` of `f`'s input parameters.
- `f`:
The homogeneous binary predicate that obeys the left-handed generalized
substitution property.
- `rα`:
A binary relation on `f`'s input values.
- See `substL` for documentation on the remaining parameters.
-/
abbrev substLFn {α : Sort u} {f : α → α → Prop} {rα : α → α → Prop} :=
@substL α (β := Prop) f rα (rβ := (· → ·))
/--
Convenience function for the right-handed binary generalized substitution
property, for a homogeneous predicate `f` without a constraint on `y`.
Type inference for `substR` gets stuck when the output relation is `(· → ·)`;
this helper works around that issue by hardcoding the argument.
See `substR` for further documentation.
**Named parameters**
- `α`:
The `Sort` of `f`'s input parameters.
- `f`:
The homogeneous binary predicate that obeys the right-handed generalized
substitution property.
- `rα`:
A binary relation on `f`'s input values.
- See `substR` for documentation on the remaining parameters.
-/
abbrev substRFn {α : Sort u} {f : α → α → Prop} {rα : α → α → Prop} :=
@substR α (β := Prop) f rα (rβ := (· → ·))
/--
Convenience function for the left-handed binary generalized substitution
property, with an explicit argument for the constraint on `y`.
Can often resolve cases where type inference gets stuck when using the more
general `subst₂` function.
See `SubstitutiveOn.subst₂` for detailed documentation.
-/
abbrev substLC := @subst₂ Hand.L
/--
Convenience function for the right-handed binary generalized substitution
property, with an explicit argument for the constraint on `y`.
Can often resolve cases where type inference gets stuck when using the more
general `subst₂` function.
See `SubstitutiveOn.subst₂` for detailed documentation.
-/
abbrev substRC := @subst₂ Hand.R
/--
Convenience class for types and heterogeneous operations that satisfy the full
(left- **and** right-handed) binary generalized substitution property.
See `SubstitutiveOn` for detailed documentation.
**Named parameters**
- `α`:
The `Sort` of `f`'s left-hand parameter.
- `β`:
The `Sort` of `f`'s right-hand parameter.
- `γ`:
The `Sort` of `f`'s result.
- `f`:
The heterogeneous binary operation that obeys the left- and right-handed
generalized substitution property.
- `CL`:
A constraint that the right-hand argument to `f` must meet for left-handed
substitution.
- `CR`:
A constraint that the left-hand argument to `f` must meet for right-handed
substitution.
- `inputRelL`:
A binary relation on input values of sort `α`, used for left-handed
substitution.
- `inputRelR`:
A binary relation on input values of sort `β`, used for right-handed
substitution.
- `outputRel`:
A binary relation on values of `γ`.
-/
class HSubstitutive₂
{α β : Sort u} {γ : Sort v} (f : α → β → γ) (CL : β → Prop) (CR : α → Prop)
(inputRelL : α → α → Prop) (inputRelR : β → β → Prop)
(outputRel : γ → γ → Prop)
:=
substitutiveL : SubstitutiveOn Hand.L f CL inputRelL outputRel
substitutiveR : SubstitutiveOn Hand.R f CR inputRelR outputRel
attribute [instance] HSubstitutive₂.substitutiveL
attribute [instance] HSubstitutive₂.substitutiveR
/--
Simplified type constructor for the very common case of _homogeneous_
operations that satisfy the full (left- **and** right-handed) binary
generalized substitution property.
See `HSubstitutive₂` for the more general type constructor that supports
heterogeneous operations.
**Named parameters**
- `α`:
The `Sort` of `f`'s input parameters.
- `β`:
The `Sort` of `f`'s result.
- `f`:
The homogeneous binary operation that obeys the left- and right-handed
generalized substitution property.
- `C`:
A constraint that the argument to `f` (on the side opposite the substituted
argument) must meet.
- `inputRel`:
A binary relation on the input values to `f` that are being substituted.
-/
abbrev Substitutive₂
{α : Sort u} {β : Sort v}
(f : α → α → β) (C : α → Prop) (inputRel : α → α → Prop)
:=
@HSubstitutive₂ α α β f C C inputRel inputRel
/-! ### Properties -/
/--
If two properties are logically equivalent, one can be substituted for the
other as the assumption (i.e. antecedent) of an implication.
**Proof intuition**: assume one of the properties, then convert it to the other
using the equivalence, and obtain the implication's conclusion.
**Named parameters**:
- `p₁`: one of the two equivalent properties.
- `p₂`: the other equivalent property.
- `q`: the conclusion of the implication.
-/
def iff_substL {p₁ p₂ q : Prop} : (p₁ ↔ p₂) → (p₁ → q) → (p₂ → q) := by
intro ⟨(_ : p₁ → p₂), (_ : p₂ → p₁)⟩ (_ : p₁ → q) (_ : p₂)
show q
have : p₁ := ‹p₂ → p₁› ‹p₂›
have : q := ‹p₁ → q› ‹p₁›
exact ‹q›
/--
If two properties are logically equivalent, one can be substituted for the
other as the conclusion (i.e. consequent) of an implication.
**Proof intuition**: obtain one of the properties from the given implication
and common assumption, then convert it to the other using the equivalence.
**Named parameters**:
- `p₁`: one of the two equivalent properties.
- `p₂`: the other equivalent property.
- `q`: the assumption of the implication.
-/
def iff_substR {p₁ p₂ q : Prop} : (p₁ ↔ p₂) → (q → p₁) → (q → p₂) := by
intro ⟨(_ : p₁ → p₂), (_ : p₂ → p₁)⟩ (_ : q → p₁) (_ : q)
show p₂
have : p₁ := ‹q → p₁› ‹q›
have : p₂ := ‹p₁ → p₂› ‹p₁›
exact ‹p₂›
/--
Logically equivalent properties can be substituted on both sides of an
implication.
-/
instance iff_substitutive : Substitutive₂ (· → ·) tc (· ↔ ·) (· → ·) where
substitutiveL := SubstitutiveOn.mk λ (_ : True) => iff_substL
substitutiveR := SubstitutiveOn.mk λ (_ : True) => iff_substR
/--
Convenience definition that converts instances of `Commutative` into instances
of `Swappable`.
The `Swappable` class is a generalization of the commutative and symmetric
properties, and is used in very abstract, general definitions. This instance
makes it easy for those definitions to apply to commutative functions.
**Named parameters**
- `α`: the argument type of the commutative function `f`.
- `β`: the result type of the commutative function `f`.
- `f`: the commutative function to produce a `Swappable` instance for.
- `R`: the binary relation that connects the two sides of the `swap` operation.
**Class parameters**
- `EqvOp β`:
required by `Commutative f`.
- `Commutative f`:
the property to translate into a `Swappable` instance.
- `Relation.Reflexive R`:
provides a starting point for substitution.
- `SubstitutitveOn Hand.R R tc (· ≃ ·) (· → ·)`:
necessary for transfering commutativity from `EqvOp β` to `R`.
-/
instance swappable_from_commutative
{α : Type u} {β : Type v} {f : α → α → β} {R : β → β → Prop}
[EqvOp β] [inst : SubstitutiveOn Hand.R R tc (· ≃ ·) (· → ·)]
[Relation.Reflexive R] [Commutative f] : Fn.Swappable f R
:= {
swap := by
intro x y
show R (f x y) (f y x)
have : R (f x y) (f x y) := Rel.refl
exact substR (self := inst) comm ‹R (f x y) (f x y)›
}
/--
Derives the right-handed binary generalized substitution property from its
left-handed counterpart, provided that the arguments to the operation `f` can
be swapped in an appropriate way.
There are many binary operations that have a symmetry between their left- and
right-handed arguments. This convenience function is a general-purpose way to
leverage that symmetry to avoid having to write a redundant proof of
right-handed substitution.
**Proof intuition**: apply left-handed substitution, then swap the arguments to
both invocations of `f`.
**Named parameters**
- `α`: the argument type of the binary operation `f`.
- `β`: the result type of the binary operation `f`.
- `f`: the binary operation that obeys the generalized substitution property.
- `C`: a constraint that the opposite-handed argument to `f` must meet.
- `rα`: how the substitutable arguments to `f` are related.
- `rβ`: how the invocations of `f` pre- and post-substitution are related.
- `rS`: how an invocation of `f` is related to its swapped-argument version.
**Class parameters**
- `Fn.Swappable f rS`:
The arguments of `f` need to be swappable to go from left-handed to right-
handed substitution.
- `Substitutive₂ rβ tc rS (· → ·)`:
Allows the result of left-handed substitution, which is an instance of the
relation `rβ`, to be converted into the right-handed result. Both the left
and right sides of `rβ` are invocations of `f`, and can be replaced by
their swapped-argument versions due to how `rS` is used here and in
`Fn.Swappable f rS`.
-/
def substR_from_substL_swap
{α : Sort u} {β : Sort v}
{f : α → α → β} {C : α → Prop} {rα : α → α → Prop} {rβ rS : β → β → Prop}
[Fn.Swappable f rS] [Substitutive₂ rβ tc rS (· → ·)]
: SubstitutiveOn Hand.L f C rα rβ → SubstitutiveOn Hand.R f C rα rβ := by
intro _ -- Make left-substitution available for instance search
apply SubstitutiveOn.mk
intro x₁ x₂ y (_ : C y) (_ : rα x₁ x₂)
show rβ (f y x₁) (f y x₂)
have : rβ (f x₁ y) (f x₂ y) := AA.substLC ‹C y› ‹rα x₁ x₂›
have : rβ (f y x₁) (f x₂ y) := AA.substLFn Fn.swap this
have : rβ (f y x₁) (f y x₂) := AA.substRFn Fn.swap this
exact this
/--
The left-hand side of an equivalence can be replaced by an equivalent value.
**Intuition**: This is a somewhat trivial case of binary substitution,
essentially just transivity expressed in a slightly different way.
-/
theorem eqv_substL
{α : Sort u} [EqvOp α] {x₁ x₂ y : α} : x₁ ≃ x₂ → x₁ ≃ y → x₂ ≃ y
:= by
intro (_ : x₁ ≃ x₂) (_ : x₁ ≃ y)
show x₂ ≃ y
exact Rel.trans (Rel.symm ‹x₁ ≃ x₂›) ‹x₁ ≃ y›
/--
The right-hand side of an equivalence can be replaced by an equivalent value.
**Intuition**: This is a somewhat trivial case of binary substitution,
essentially just transivity expressed in a slightly different way.
-/
theorem eqv_substR
{α : Sort u} [EqvOp α] {x₁ x₂ y : α} : x₁ ≃ x₂ → y ≃ x₁ → y ≃ x₂
:= by
intro (_ : x₁ ≃ x₂) (_ : y ≃ x₁)
show y ≃ x₂
exact Rel.trans ‹y ≃ x₁› ‹x₁ ≃ x₂›
instance eqv_substitutive
{α : Sort u} [EqvOp α]
: Substitutive₂ (α := α) (· ≃ ·) tc (· ≃ ·) (· → ·)
:= {
substitutiveL := { subst₂ := λ (_ : True) => eqv_substL }
substitutiveR := { subst₂ := λ (_ : True) => eqv_substR }
}
/--
The left-hand side of a negated equivalence can be replaced by an equivalent
value.
**Intuition**: if we know two terms are unequal, and replace the left-hand one
with an equivalent term, the right-hand term should still be unequal to the new
term.
-/
theorem neqv_substL
{α : Sort u} [EqvOp α] {x₁ x₂ y : α} : x₁ ≃ x₂ → x₁ ≄ y → x₂ ≄ y
:= by
intro (_ : x₁ ≃ x₂) (_ : x₁ ≄ y) (_ : x₂ ≃ y)
show False
have : x₁ ≃ y := Rel.trans ‹x₁ ≃ x₂› ‹x₂ ≃ y›
exact absurd ‹x₁ ≃ y› ‹x₁ ≄ y›
/--
The right-hand side of a negated equivalence can be replaced by an equivalent
value.
**Intuition**: if we know two terms are unequal, and replace the right-hand one
with an equivalent term, the left-hand term should still be unequal to the new
term.
-/
theorem neqv_substR
{α : Sort u} [EqvOp α] {x₁ x₂ y : α} : x₁ ≃ x₂ → y ≄ x₁ → y ≄ x₂
:= by
intro (_ : x₁ ≃ x₂) (_ : y ≄ x₁) (_ : y ≃ x₂)
show False
have : y ≃ x₁ := Rel.trans ‹y ≃ x₂› (Rel.symm ‹x₁ ≃ x₂›)
exact absurd ‹y ≃ x₁› ‹y ≄ x₁›
instance neqv_substitutive
{α : Sort u} [EqvOp α]
: Substitutive₂ (α := α) (· ≄ ·) tc (· ≃ ·) (· → ·)
:= {
substitutiveL := { subst₂ := λ (_ : True) => neqv_substL }
substitutiveR := { subst₂ := λ (_ : True) => neqv_substR }
}
namespace Prod
/-! ### Products (i.e. ordered pairs) -/
open Relation.Equivalence.Impl.Prod (eqv_defn)
variable {α β : Type}
variable [EqvOp α]
variable [EqvOp β]
/--
Substitution of equivalent values in the left component of ordered pairs.
**Intuition**: This follows directly from the definition of equivalence for
ordered pairs. The left components must be equivalent for the pairs to be
equivalent.
**Named parameters**
- `α`: The type of the pairs' left components.
- `β`: The type of the pairs' right components.
- `x₁`, `x₂`: The equivalent left component values to substitute.
- `y`: The right component value.
**Class parameters**
- `EqvOp α`, `EqvOp β`: Needed for equivalence between pairs.
-/
theorem substL {x₁ x₂ : α} {y : β} : x₁ ≃ x₂ → (x₁, y) ≃ (x₂, y) := by
intro (_ : x₁ ≃ x₂)
apply eqv_defn.mpr
show x₁ ≃ x₂ ∧ y ≃ y
exact And.intro ‹x₁ ≃ x₂› Rel.refl
def substitutiveL
: SubstitutiveOn Hand.L (α := α) (β := β) (·,·) tc (· ≃ ·) (· ≃ ·)
:= {
subst₂ := λ (_ : True) => substL
}
/--
Substitution of equivalent values in the right component of ordered pairs.
**Intuition**: This follows directly from the definition of equivalence for
ordered pairs. The right components must be equivalent for the pairs to be
equivalent.
**Named parameters**
- `α`: The type of the pairs' left components.
- `β`: The type of the pairs' right components.
- `x₁`, `x₂`: The equivalent right component values to substitute.
- `y`: The left component value.
**Class parameters**
- `EqvOp α`, `EqvOp β`: Needed for equivalence between pairs.
-/
theorem substR {x₁ x₂ : β} {y : α} : x₁ ≃ x₂ → (y, x₁) ≃ (y, x₂) := by
intro (_ : x₁ ≃ x₂)
apply eqv_defn.mpr
show y ≃ y ∧ x₁ ≃ x₂
exact And.intro Rel.refl ‹x₁ ≃ x₂›
def substitutiveR
: SubstitutiveOn Hand.R (α := α) (β := β) (·,·) tc (· ≃ ·) (· ≃ ·)
:= {
subst₂ := λ (_ : True) => substR
}
instance substitutive
: HSubstitutive₂ (α := α) (β := β) (·,·) tc tc (· ≃ ·) (· ≃ ·) (· ≃ ·)
:= {
substitutiveL := substitutiveL
substitutiveR := substitutiveR
}
end Prod
/-!
## Cancellation
### Definitions
-/
/--
Class for types and operations that satisfy either the left- or right-handed
generalized cancellation property.
For more information see `CancellativeOn.cancel`.
**Named parameters**
- `hand`: indicates whether the property is left- or right-handed.
- `α`: the argument type of the binary operation `f`.
- `β`: the result type of the binary operation `f`.
- `f`: the binary operation that obeys the generalized cancellation property.
- `C`: a constraint that the argument on the `hand` side of `f` must meet.
- `rα`: a binary relation over `f`'s argument type `α`.
- `rβ`: a binary relation over `f`'s result type `β`.
-/
class CancellativeOn
(hand : Hand) {α : Sort u} {β : Sort v}
(f : α → α → β) (C : outParam (α → Prop))
(rα : outParam (α → α → Prop)) (rβ : β → β → Prop)
:=
/--
The left- or right-handed generalized cancellation property of a binary
operation `f`.
This property is in some sense the converse of the generalized substitution
property; see `SubstitutiveOn.subst₂`. It says: knowing that the results of
two invocations of `f` satisfy the relation `rβ` tells us that the two left-
or right-handed arguments to `f` satisfy the relation `rα`.
Often `α` and `β` will be the same type, and `rα` and `rβ` will be the same
relation. A simple example is of addition on natural numbers: if we know that
`n₁ + m ≃ n₂ + m`, or that `m + n₁ ≃ m + n₂`, then we can conclude that
`n₁ ≃ n₂`.
More advanced applications may require a nontrivial constraint `C` on `x`; an
example is that `x * y₁ ≃ x * y₂` implies `y₁ ≃ y₂` only for nonzero `x`.
**Named parameters**
- see `CancellativeOn` for the class parameters.
- `x`: the "cancelled" argument to `f`; the `hand` parameter
indicates which side of `f` it appears on.
- `y₁` and `y₂`: the other arguments to `f`; appearing on the side opposite
`hand`. They are related by `rα` in the result.
- `cx`: evidence that the constraint on `x` is satisfied.
-/
cancel
{x y₁ y₂ : α} (cx : C x)
: rβ (hand.align f x y₁) (hand.align f x y₂) → rα y₁ y₂
export CancellativeOn (cancel)
/--
Convenience function for the left-handed generalized cancellation property,
without a constraint on `x`.
Can often resolve cases where type inference gets stuck when using the more
general `cancel` function.
See `CancellativeOn.cancel` for detailed documentation.
-/
abbrev cancelL
{α : Sort u} {β : Sort v} {f : α → α → β} {rα : α → α → Prop}
{rβ : β → β → Prop} [self : CancellativeOn Hand.L f tc rα rβ]
{x y₁ y₂ : α} :=
@cancel Hand.L α β f tc rα rβ self x y₁ y₂ True.intro
/--
Convenience function for the right-handed generalized cancellation property,
without a constraint on `x`.
Can often resolve cases where type inference gets stuck when using the more
general `cancel` function.
See `CancellativeOn.cancel` for detailed documentation.
-/
abbrev cancelR
{α : Sort u} {β : Sort v} {f : α → α → β} {rα : α → α → Prop}
{rβ : β → β → Prop} [self : CancellativeOn Hand.R f tc rα rβ]
{x y₁ y₂ : α} :=
@cancel Hand.R α β f tc rα rβ self x y₁ y₂ True.intro
/--
Convenience function for the left-handed generalized cancellation property,
with an explicit argument for the constraint on `x`.
Can often resolve cases where type inference gets stuck when using the more
general `cancel` function.
See `CancellativeOn.cancel` for detailed documentation.
-/
abbrev cancelLC := @cancel Hand.L
/--
Convenience function for the right-handed generalized cancellation property,
with an explicit argument for the constraint on `x`.
Can often resolve cases where type inference gets stuck when using the more
general `cancel` function.
See `CancellativeOn.cancel` for detailed documentation.
-/
abbrev cancelRC := @cancel Hand.R
/--
Convenience class for types and operations that satisfy the full (left- **and**
right-handed) generalized cancellation property.
See `CancellativeOn` for detailed documentation.
-/
class Cancellative
{α : Sort u} {β : Sort v} (f : α → α → β) (C : outParam (α → Prop))
(rα : outParam (α → α → Prop)) (rβ : β → β → Prop)
:=
cancellativeL : CancellativeOn Hand.L f C rα rβ
cancellativeR : CancellativeOn Hand.R f C rα rβ
attribute [instance] Cancellative.cancellativeL
attribute [instance] Cancellative.cancellativeR
/-! ### Properties -/
/--
Derives the right-handed generalized cancellation property from its left-handed
counterpart, provided that the types and operations involved obey some
restrictions.
**Intuition**: if `f` is commutative and `rβ` supports substitution, then the
arguments to `f` can be swapped so that left-handed cancellation can be used.
**Named parameters**
- `α`: the argument type of the binary operation `f`.
- `β`: the result type of the binary operation `f`.
- `f`: the binary operation that obeys the generalized cancellation property.
- `C`: a constraint that the argument on the cancellation-hand side of `f` must
meet.
- `rα`: a binary relation over `f`'s argument type `α`.
- `rβ`: a binary relation over `f`'s result type `β`.
**Class parameters**
- `EqvOp β`: needed for both the `Commutative` and `Substitutive₂` parameters
- `Commutative f`: needed for swapping the arguments to `f`.
- `Substitutive₂ rβ (· ≃ ·) (· → ·)`: needed to update the right-handed
hypothesis involving `rβ` to a left-handed hypothesis.
-/
def cancelR_from_cancelL
{α : Sort u} {β : Sort v}
{f : α → α → β} {C : α → Prop} {rα : α → α → Prop} {rβ : β → β → Prop}
[EqvOp β] [Commutative f] [Substitutive₂ rβ tc (· ≃ ·) (· → ·)]
: CancellativeOn Hand.L f C rα rβ → CancellativeOn Hand.R f C rα rβ := by
intro
constructor
intro x y₁ y₂ (_ : C x) (_ : rβ (f y₁ x) (f y₂ x))
show rα y₁ y₂
have : rβ (f x y₁) (f y₂ x) := AA.substLFn AA.comm ‹rβ (f y₁ x) (f y₂ x)›
have : rβ (f x y₁) (f x y₂) := AA.substRFn AA.comm ‹rβ (f x y₁) (f y₂ x)›
exact AA.cancelLC ‹C x› ‹rβ (f x y₁) (f x y₂)›
end Lean4Axiomatic.AA
|
# $\text{sinc}(x)$ and Its Derivatives
\begin{align}
\text{sinc}(x) &= \begin{cases}
\frac{x^4}{120}-\frac{x^2}{6}+1 & |x| \leq \epsilon \\
\frac{\sin(x)}{x} & \text{otherwise}
\end{cases}\\
\end{align}
```python
import sys
import numpy
from sympy import *
from sympy.plotting import plot
x = Symbol("x")
x0 = Symbol("x_0")
```
```python
def taylor_series(f, n=5):
dfs = [f]
for i in range(n):
dfs.append(dfs[i].diff())
return sum([
dfs[i].subs({"x": x0}) / factorial(i) * (x - x0)**i
for i in range(len(dfs))
])
```
```python
sinc = sin(x) / x
display(sinc)
```
$\displaystyle \frac{\sin{\left(x \right)}}{x}$
```python
sinc_ts = taylor_series(sinc)
display(limit(sinc_ts, x0, 0))
```
$\displaystyle \frac{x^{4}}{120} - \frac{x^{2}}{6} + 1$
```python
x1 = 1e-3
print(1.0 - x1**2 / 6)
print(1.0 - x1**2 * (1 / 6 + x1**2 / 120))
x1 = sys.float_info.epsilon
print(N(x1, 50))
print(f"{N(sqrt(x1), 35):e}")
print(f"{N(sqrt(sqrt(x1)), 25):e}")
```
0.9999998333333333
0.999999833333325
2.2204460492503130808472633361816406250000000000000e-16
1.4901161193847656250000000000000000e-8
1.220703125000000000000000e-4
## $\frac{d}{dx} \text{sinc}(x)$
\begin{align}
\text{sinc}'(x) &= \begin{cases}
0 & x = 0 \\
\frac{x\cos(x) - \sin(x)}{x^2} & \text{otherwise}
\end{cases}\\
\end{align}
```python
dsinc = simplify(sinc.diff(x))
display(dsinc)
```
$\displaystyle \frac{x \cos{\left(x \right)} - \sin{\left(x \right)}}{x^{2}}$
```python
dsinc_ts = taylor_series(dsinc)
display(limit(dsinc_ts, x0, 0))
```
$\displaystyle - \frac{x^{5}}{840} + \frac{x^{3}}{30} - \frac{x}{3}$
## $\frac{d^2}{dx^2} \text{sinc}(x)$
\begin{align}
\text{sinc}''(x) &= \begin{cases}
\frac{-1}{3} & x = 0 \\
\frac{-x^2\sin(x) - 2x\cos(x) + 2\sin(x)}{x^3} & \text{otherwise}
\end{cases}\\
\end{align}
```python
ddsinc = simplify(dsinc.diff(x))
display(ddsinc)
```
$\displaystyle \frac{- x^{2} \sin{\left(x \right)} - 2 x \cos{\left(x \right)} + 2 \sin{\left(x \right)}}{x^{3}}$
```python
ddsinc_ts = taylor_series(ddsinc)
display(limit(ddsinc_ts, x0, 0))
```
$\displaystyle - \frac{x^{4}}{168} + \frac{x^{2}}{10} - \frac{1}{3}$
## Derivatives of $sinc(\|x\|)$
```python
def norm(x):
return sqrt(sum(x**2))
```
```python
X = numpy.array(symbols("x y z"))
sinc_normx = sinc.subs({"x": norm(X)})
display(sinc_normx)
```
$\displaystyle \frac{\sin{\left(\sqrt{x^{2} + y^{2} + z^{2}} \right)}}{\sqrt{x^{2} + y^{2} + z^{2}}}$
## Gradient of $\text{sinc}(\|x\|)$
\begin{align}
\nabla \text{sinc}(\|x\|) &= \frac{\text{sinc}'(\|x\|)}{\|x\|}x \\
\frac{\text{sinc}'(x)}{x} &= \begin{cases}
-\frac{x^4}{840} + \frac{x^2}{30} - \frac{1}{3}& |x| \leq \epsilon\\
\frac{x\cos(x)-\sin(x)}{x^3} & \text{otherwise}
\end{cases}
\end{align}
where $\epsilon = 10^{-4}$.
```python
dsinc_normx = numpy.array(sinc_normx.diff(X))
my_dsinc_normx = dsinc.subs({"x": norm(X)}) / norm(X) * X
for i in range(3):
assert (simplify((dsinc_normx - my_dsinc_normx)[i]) == 0)
```
```python
dsinc_x = dsinc / x
display(dsinc_x)
```
$\displaystyle \frac{x \cos{\left(x \right)} - \sin{\left(x \right)}}{x^{3}}$
```python
dsinc_x_ts = taylor_series(dsinc_x)
display(limit(dsinc_x_ts, x0, 0))
```
$\displaystyle - \frac{x^{4}}{840} + \frac{x^{2}}{30} - \frac{1}{3}$
## Hessian of $\text{sinc}(\|x\|)$
\begin{align}
\nabla^2 \text{sinc}(\|x\|) &= \left(\frac{\text{sinc}''(\|x\|)}{\|x\|^2} - \frac{\text{sinc}'(\|x\|)}{\|x\|^3}\right)xx^T + \frac{\text{sinc}'(\|x\|)}{\|x\|}I \\
\frac{\text{sinc}''(\|x\|)}{\|x\|^2} - \frac{\text{sinc}'(\|x\|)}{\|x\|^3} &= \begin{cases}
\frac{x^{4}}{7560}-\frac{x^{2}}{210}+\frac{1}{15} & |x| \leq \epsilon \\
\frac{-x^{2} \sin (x)-3 x \cos (x)+3 \sin (x)}{x^{5}} & \text{otherwise}
\end{cases}
\end{align}
where $\epsilon = 0.1$.
```python
ddsinc_normx = numpy.array(Matrix(Matrix(dsinc_normx).diff(X)))
my_ddsinc_normx = ((ddsinc.subs({"x": norm(X)}) / norm(X)**2 -
dsinc.subs({"x": norm(X)}) / norm(X)**3) *
X.reshape(3, 1) @ X.reshape(1, 3) +
dsinc.subs({"x": norm(X)}) / norm(X) * numpy.eye(3))
for i in range(3):
for j in range(3):
assert (simplify(ddsinc_normx[i, j][0] - my_ddsinc_normx[i, j]) == 0)
```
```python
ddsinc_x = simplify(ddsinc.subs({"x": x}) / x**2 - dsinc.subs({"x": x}) / x**3)
display(ddsinc_x)
```
$\displaystyle \frac{- x^{2} \sin{\left(x \right)} - 3 x \cos{\left(x \right)} + 3 \sin{\left(x \right)}}{x^{5}}$
```python
ddsinc_x_ts = taylor_series(ddsinc_x)
display(limit(ddsinc_x_ts, x0, 0.0))
```
$\displaystyle \frac{x^{4}}{7560} - \frac{x^{2}}{210} + \frac{1}{15}$
|
[STATEMENT]
lemma sum_mset_distrib_left:
"c * (\<Sum>x \<in># M. f x) = (\<Sum>x \<in># M. c * f(x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. c * \<Sum>\<^sub># (image_mset f M) = (\<Sum>x\<in>#M. c * f x)
[PROOF STEP]
by (induction M) (simp_all add: algebra_simps) |
State Before: m k : ℕ+
h : k ∣ m
⊢ k * divExact m k = m State After: case a
m k : ℕ+
h : k ∣ m
⊢ ↑(k * divExact m k) = ↑m Tactic: apply PNat.eq State Before: case a
m k : ℕ+
h : k ∣ m
⊢ ↑(k * divExact m k) = ↑m State After: case a
m k : ℕ+
h : k ∣ m
⊢ ↑k * ↑(divExact m k) = ↑m Tactic: rw [mul_coe] State Before: case a
m k : ℕ+
h : k ∣ m
⊢ ↑k * ↑(divExact m k) = ↑m State After: case a
m k : ℕ+
h : k ∣ m
⊢ ↑k * succ (div m k) = ↑m Tactic: change (k : ℕ) * (div m k).succ = m State Before: case a
m k : ℕ+
h : k ∣ m
⊢ ↑k * succ (div m k) = ↑m State After: no goals Tactic: rw [← div_add_mod m k, dvd_iff'.mp h, Nat.mul_succ] |
(** * Every parse tree has a corresponding minimal parse tree *)
Require Import Coq.Strings.String Coq.Lists.List Coq.Program.Program Coq.Classes.RelationClasses Coq.Classes.Morphisms Coq.Setoids.Setoid Coq.Arith.Compare_dec.
Require Import Coq.Program.Wf Coq.Arith.Wf_nat.
Require Import Parsers.ContextFreeGrammar Parsers.ContextFreeGrammarProperties Parsers.WellFoundedParse.
Require Export Parsers.MinimalParse.
Require Import Common Common.Wf.
Set Implicit Arguments.
Local Open Scope string_like_scope.
Local Notation "f ∘ g" := (fun x => f (g x)).
Section cfg.
Context CharType (String : string_like CharType) (G : grammar CharType).
Context (names_listT : Type)
(initial_names_data : names_listT)
(is_valid_name : names_listT -> string -> bool)
(remove_name : names_listT -> string -> names_listT)
(names_listT_R : names_listT -> names_listT -> Prop)
(remove_name_dec : forall ls name,
is_valid_name ls name = true
-> names_listT_R (remove_name ls name) ls)
(remove_name_1
: forall ls ps ps',
is_valid_name (remove_name ls ps) ps' = true
-> is_valid_name ls ps' = true)
(remove_name_2
: forall ls ps ps',
is_valid_name (remove_name ls ps) ps' = false
<-> is_valid_name ls ps' = false \/ ps = ps')
(ntl_wf : well_founded names_listT_R).
Context (names_listT_R_respectful : forall x y,
sub_names_listT is_valid_name x y
-> x <> y
-> names_listT_R x y).
Local Notation minimal_parse_of_production := (@minimal_parse_of_production CharType String G names_listT initial_names_data is_valid_name remove_name).
Local Notation minimal_parse_of := (@minimal_parse_of CharType String G names_listT initial_names_data is_valid_name remove_name).
Local Notation minimal_parse_of_name := (@minimal_parse_of_name CharType String G names_listT initial_names_data is_valid_name remove_name).
Local Notation minimal_parse_of_item := (@minimal_parse_of_item CharType String G names_listT initial_names_data is_valid_name remove_name).
Lemma strle_from_min_parse_of_production {str0 valid strs pats}
(p1 : minimal_parse_of_production str0 valid strs pats)
: strs ≤s str0.
Proof.
destruct p1; trivial; [].
destruct (stringlike_dec str0 (Empty _)) as [|n];
subst; [ reflexivity | left ].
rewrite Length_Empty.
case_eq (Length str0); intro H; [ exfalso | ];
eauto using Empty_Length with arith.
Qed.
Definition parse_of_item_name__of__minimal_parse_of_name'
(parse_of__of__minimal_parse_of
: forall str0 valid str prods,
@minimal_parse_of str0 valid str prods -> parse_of String G str prods)
{str0 valid str name} (p : @minimal_parse_of_name str0 valid str name)
: parse_of_item String G str (NonTerminal _ name)
:= ParseNonTerminal
name
(@parse_of__of__minimal_parse_of
_ _ _ _
(match p as p in (@MinimalParse.minimal_parse_of_name _ _ _ _ _ _ _ str0 valid str name)
return minimal_parse_of (match p with
| MinParseNonTerminalStrLt _ _ _ _ _ _ => _
| MinParseNonTerminalStrEq _ _ _ _ _ => _
end)
(match p with
| MinParseNonTerminalStrLt _ _ _ _ _ _ => _
| MinParseNonTerminalStrEq _ _ _ _ _ => _
end)
str (Lookup G name) with
| MinParseNonTerminalStrLt str0 valid name str pf p' => p'
| MinParseNonTerminalStrEq str valid name H p' => p'
end)).
Definition parse_of_item__of__minimal_parse_of_item'
(parse_of__of__minimal_parse_of
: forall str0 valid str prods,
@minimal_parse_of str0 valid str prods -> parse_of String G str prods)
{str0 valid str it} (p : @minimal_parse_of_item str0 valid str it)
: parse_of_item String G str it
:= match p in (@MinimalParse.minimal_parse_of_item _ _ _ _ _ _ _ str0 valid str it) return parse_of_item String G str it with
| MinParseTerminal str0 valid x
=> ParseTerminal String G x
| MinParseNonTerminal str0 valid _ _ p'
=> @parse_of_item_name__of__minimal_parse_of_name' (@parse_of__of__minimal_parse_of) _ _ _ _ p'
end.
Fixpoint parse_of__of__minimal_parse_of {str0 valid str pats} (p : @minimal_parse_of str0 valid str pats)
: parse_of String G str pats
:= match p with
| MinParseHead str0 valid str pat pats p'
=> ParseHead pats (parse_of_production__of__minimal_parse_of_production p')
| MinParseTail str0 valid str pat pats p'
=> ParseTail pat (parse_of__of__minimal_parse_of p')
end
with parse_of_production__of__minimal_parse_of_production {str0 valid str pat} (p : @minimal_parse_of_production str0 valid str pat)
: parse_of_production String G str pat
:= match p with
| MinParseProductionNil str0 valid
=> ParseProductionNil _ _
| MinParseProductionCons str0 valid str strs pat pats pf p' p''
=> ParseProductionCons
(parse_of_item__of__minimal_parse_of_item' (@parse_of__of__minimal_parse_of) p')
(parse_of_production__of__minimal_parse_of_production p'')
end.
Definition parse_of_item_name__of__minimal_parse_of_name
: forall {str0 valid str name} (p : @minimal_parse_of_name str0 valid str name),
parse_of_item String G str (NonTerminal _ name)
:= @parse_of_item_name__of__minimal_parse_of_name' (@parse_of__of__minimal_parse_of).
Definition parse_of_item__of__minimal_parse_of_item
: forall {str0 valid str it},
@minimal_parse_of_item str0 valid str it
-> parse_of_item String G str it
:= @parse_of_item__of__minimal_parse_of_item' (@parse_of__of__minimal_parse_of).
Section contract.
Local Hint Constructors MinimalParse.minimal_parse_of_name.
Definition contract_minimal_parse_of_name_lt
{str0 str valid valid' name}
(Hlt : Length str < Length str0)
(p : @minimal_parse_of_name str0 valid str name)
: @minimal_parse_of_name str0 valid' str name.
Proof.
destruct p.
{ constructor (assumption). }
{ exfalso; clear -Hlt; omega. }
Defined.
Definition contract_minimal_parse_of_item_lt
{str0 str valid valid' it}
(Hlt : Length str < Length str0)
(p : @minimal_parse_of_item str0 valid str it)
: @minimal_parse_of_item str0 valid' str it.
Proof.
destruct p as [p|p].
{ constructor. }
{ constructor (eapply contract_minimal_parse_of_name_lt; eassumption). }
Defined.
Definition contract_minimal_parse_of_production_lt
{str0 str valid valid' pat}
(Hlt : Length str < Length str0)
(p : @minimal_parse_of_production str0 valid str pat)
: @minimal_parse_of_production str0 valid' str pat.
Proof.
induction p.
{ constructor. }
{ constructor;
try first [ eapply contract_minimal_parse_of_item_lt; try eassumption
| eapply IHp; try eassumption
| assumption ];
clear -Hlt;
abstract (
rewrite <- Length_correct in Hlt;
eauto using le_S, Lt.le_lt_trans, Plus.le_plus_l, Plus.le_plus_r with nocore
). }
Defined.
Definition contract_minimal_parse_of_lt
{str0 str valid valid' pats}
(Hlt : Length str < Length str0)
(p : @minimal_parse_of str0 valid str pats)
: @minimal_parse_of str0 valid' str pats.
Proof.
induction p.
{ constructor (eapply contract_minimal_parse_of_production_lt; eassumption). }
{ constructor (eapply IHp; assumption). }
Defined.
Section contract_eq.
Lemma parse_of_contract_minimal_parse_of_item_lt
{str0 str : String} {valid valid' : names_listT}
{Hlt : Length str < Length str0}
{it}
(p : @minimal_parse_of_item str0 valid str it)
: parse_of_item__of__minimal_parse_of_item
(contract_minimal_parse_of_item_lt (valid' := valid') Hlt p)
= parse_of_item__of__minimal_parse_of_item p.
Proof.
destruct_head MinimalParse.minimal_parse_of_item; simpl; try reflexivity.
destruct_head MinimalParse.minimal_parse_of_name; try reflexivity.
unfold False_rect.
match goal with
| [ |- appcontext[match ?e with end] ] => destruct e
end.
Qed.
Lemma parse_of_contract_minimal_parse_of_production_lt
{str0 str : String} {valid valid' : names_listT}
{Hlt : Length str < Length str0}
{pat}
(p : @minimal_parse_of_production str0 valid str pat)
: parse_of_production__of__minimal_parse_of_production
(contract_minimal_parse_of_production_lt (valid' := valid') Hlt p)
= parse_of_production__of__minimal_parse_of_production p.
Proof.
induction p; simpl; try reflexivity.
rewrite IHp, parse_of_contract_minimal_parse_of_item_lt.
reflexivity.
Qed.
Lemma parse_of_contract_minimal_parse_of_lt
{str0 str : String} {valid valid' : names_listT}
{Hlt : Length str < Length str0}
{pats}
(p : @minimal_parse_of str0 valid str pats)
: parse_of__of__minimal_parse_of
(contract_minimal_parse_of_lt (valid' := valid') Hlt p)
= parse_of__of__minimal_parse_of p.
Proof.
induction p; simpl;
progress rewrite ?IHp, ?parse_of_contract_minimal_parse_of_production_lt;
reflexivity.
Qed.
End contract_eq.
End contract.
(** Re-add this so rewrite works *)
Global Add Parametric Morphism : remove_name
with signature (sub_names_listT is_valid_name) ==> eq ==> (sub_names_listT is_valid_name)
as remove_name_mor.
Proof.
intros; apply (@remove_name_mor); try assumption; reflexivity.
Qed.
Definition expand_minimal_parse_of_name'
(expand_minimal_parse_of
: forall {str0 str0' valid valid' str prods}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of str0 valid str prods),
@minimal_parse_of str0' valid' str prods)
{str0 str0' valid valid' str name}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of_name str0 valid str name)
: @minimal_parse_of_name str0' valid' str name.
Proof.
destruct p;
first [ apply MinParseNonTerminalStrLt;
solve [ eapply length_le_trans; eassumption
| assumption ]
| idtac ]; [].
{ destruct (strle_to_sumbool _ Hstr); subst;
[ apply MinParseNonTerminalStrLt
| apply MinParseNonTerminalStrEq ];
solve [ assumption
| apply H; assumption
| eapply expand_minimal_parse_of; [ .. | eassumption ];
solve [ reflexivity
| rewrite ?H, ?Hinit;
eauto using sub_names_listT_remove;
reflexivity ] ]. }
Defined.
Definition expand_minimal_parse_of_item'
(expand_minimal_parse_of
: forall {str0 str0' valid valid' str prods}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of str0 valid str prods),
@minimal_parse_of str0' valid' str prods)
{str0 str0' valid valid' str it}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of_item str0 valid str it)
: @minimal_parse_of_item str0' valid' str it.
Proof.
destruct p.
{ apply MinParseTerminal. }
{ apply MinParseNonTerminal; [].
eapply expand_minimal_parse_of_name'; [..| eassumption ];
try assumption. }
Defined.
Fixpoint expand_minimal_parse_of
{str0 str0' valid valid' str pats}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of str0 valid str pats)
: @minimal_parse_of str0' valid' str pats
:= match p in (@MinimalParse.minimal_parse_of _ _ _ _ _ _ _ str0 valid str pats)
return (str0 ≤s str0'
-> sub_names_listT is_valid_name valid valid'
-> @minimal_parse_of str0' valid' str pats)
with
| MinParseHead str0 valid str pat pats p'
=> fun Hstr H => MinParseHead pats (expand_minimal_parse_of_production Hstr H Hinit p')
| MinParseTail str0 valid str pat pats p'
=> fun Hstr H => MinParseTail pat (expand_minimal_parse_of Hstr H Hinit p')
end Hstr H
with expand_minimal_parse_of_production
{str0 str0' valid valid' str pat}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of_production str0 valid str pat)
: @minimal_parse_of_production str0' valid' str pat
:= match p in (@MinimalParse.minimal_parse_of_production _ _ _ _ _ _ _ str0 valid str pats)
return (str0 ≤s str0' -> sub_names_listT is_valid_name valid valid' -> minimal_parse_of_production str0' valid' str pats)
with
| MinParseProductionNil str0 valid
=> fun _ _ => MinimalParse.MinParseProductionNil _ _ _ _ _ _ _
| MinParseProductionCons str0 valid str strs pat pats pf p' p''
=> fun Hstr H => MinParseProductionCons
(transitivity pf Hstr)
(expand_minimal_parse_of_item' (@expand_minimal_parse_of) Hstr H Hinit p')
(expand_minimal_parse_of_production Hstr H Hinit p'')
end Hstr H.
Definition expand_minimal_parse_of_name
: forall {str0 str0' valid valid' str name}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of_name str0 valid str name),
@minimal_parse_of_name str0' valid' str name
:= @expand_minimal_parse_of_name' (@expand_minimal_parse_of).
Definition expand_minimal_parse_of_item
: forall {str0 str0' valid valid' str it}
(Hstr : str0 ≤s str0')
(H : sub_names_listT is_valid_name valid valid')
(Hinit : sub_names_listT is_valid_name valid' initial_names_data)
(p : @minimal_parse_of_item str0 valid str it),
@minimal_parse_of_item str0' valid' str it
:= @expand_minimal_parse_of_item' (@expand_minimal_parse_of).
Section minimize.
Let P : String -> string -> Prop
:= fun _ p => is_valid_name initial_names_data p = true.
Let alt_option h valid str
:= { name : _ & (is_valid_name valid name = false /\ P str name)
* { p : parse_of String G str (Lookup G name)
& (size_of_parse p < h)
* Forall_parse_of P p } }%type.
Lemma not_alt_all {h str} (ps : alt_option h initial_names_data str)
: False.
Proof.
subst P; simpl in *.
destruct ps as [ ? [ H' _ ] ].
revert H'; clear; intros [? ?].
congruence.
Qed.
Definition alt_all_elim {h str T} (ps : T + alt_option h initial_names_data str)
: T.
Proof.
destruct ps as [|ps]; [ assumption | exfalso ].
eapply not_alt_all; eassumption.
Defined.
Definition expand_alt_option' {h h' str str' valid valid'}
(H : h <= h') (H' : sub_names_listT is_valid_name valid' valid) (H'' : str = str')
: alt_option h valid str -> alt_option h' valid' str'.
Proof.
hnf in H'; unfold alt_option.
repeat match goal with
| [ |- sigT _ -> _ ] => intros []
| [ |- sig _ -> _ ] => intros []
| [ |- prod _ _ -> _ ] => intros []
| [ |- and _ _ -> _ ] => intros []
| _ => intro
| _ => progress subst
| [ |- sigT _ ] => esplit
| [ |- sig _ ] => esplit
| [ |- prod _ _ ] => esplit
| [ |- and _ _ ] => esplit
| [ H : _ = false |- _ = false ]
=> apply Bool.not_true_iff_false in H;
apply Bool.not_true_iff_false;
intro; apply H
| _ => eapply H'; eassumption
| _ => assumption
| [ |- _ < _ ] => eapply Lt.lt_trans; eassumption
| [ |- _ < _ ] => eapply Lt.lt_le_trans; eassumption
end.
Defined.
Definition expand_alt_option {h h' str str' valid valid'}
(H : h < h') (H' : sub_names_listT is_valid_name valid' valid) (H'' : str = str')
: alt_option h valid str -> alt_option h' valid' str'.
Proof.
apply expand_alt_option'; try assumption.
apply Lt.lt_le_weak; assumption.
Defined.
Section wf_parts.
Let of_parse_item_T' h
{str0 str : String} (pf : str ≤s str0)
(valid : names_listT) {it : item CharType}
(p : parse_of_item String G str it)
:= forall (p_small : size_of_parse_item p < h),
sub_names_listT is_valid_name valid initial_names_data
-> Forall_parse_of_item P p
-> ({ p' : @minimal_parse_of_item str0 valid str it
& (size_of_parse_item (parse_of_item__of__minimal_parse_of_item p') <= size_of_parse_item p)
* Forall_parse_of_item P (parse_of_item__of__minimal_parse_of_item p') })%type
+ alt_option (size_of_parse_item p) valid str.
Let of_parse_item_T str0 h
:= forall str pf valid it p, @of_parse_item_T' h str0 str pf valid it p.
Let of_parse_production_T' h
{str0 str : String} (pf : str ≤s str0)
(valid : names_listT) {pat : production CharType}
(p : parse_of_production String G str pat)
:= forall (p_small : size_of_parse_production p < h),
sub_names_listT is_valid_name valid initial_names_data
-> Forall_parse_of_production P p
-> ({ p' : @minimal_parse_of_production str0 valid str pat
& (size_of_parse_production (parse_of_production__of__minimal_parse_of_production p') <= size_of_parse_production p)
* Forall_parse_of_production P (parse_of_production__of__minimal_parse_of_production p') })%type
+ alt_option (size_of_parse_production p) valid str.
Let of_parse_production_T str0 h
:= forall str pf valid pat p, @of_parse_production_T' h str0 str pf valid pat p.
Let of_parse_T' h
{str0 str : String} (pf : str ≤s str0)
(valid : names_listT) {pats : productions CharType}
(p : parse_of String G str pats)
:= forall (p_small : size_of_parse p < h),
sub_names_listT is_valid_name valid initial_names_data
-> Forall_parse_of P p
-> ({ p' : @minimal_parse_of str0 valid str pats
& (size_of_parse (parse_of__of__minimal_parse_of p') <= size_of_parse p)
* Forall_parse_of P (parse_of__of__minimal_parse_of p') })%type
+ alt_option (size_of_parse p) valid str.
Let of_parse_T str0 h
:= forall str pf valid pats p, @of_parse_T' h str0 str pf valid pats p.
Let of_parse_name_T {str0 str valid name} (p : parse_of String G str (Lookup G name)) h
:= size_of_parse_item (ParseNonTerminal name p) < h
-> str ≤s str0
-> sub_names_listT is_valid_name valid initial_names_data
-> Forall_parse_of_item P (ParseNonTerminal name p)
-> ({ p' : @minimal_parse_of_name str0 valid str name
& (size_of_parse_item (parse_of_item__of__minimal_parse_of_item (MinParseNonTerminal p')) <= size_of_parse_item (ParseNonTerminal name p))
* Forall_parse_of_item P (parse_of_item__of__minimal_parse_of_item (MinParseNonTerminal p')) })%type
+ alt_option (size_of_parse_item (ParseNonTerminal name p)) valid str.
Section item.
Context {str0 str : String} {valid : names_listT}.
Definition minimal_parse_of_item__of__parse_of_item
h
(minimal_parse_of_name__of__parse_of_name
: forall h' (pf : h' < S (S h)) {str0 str valid name}
(p : parse_of String G str (Lookup G name)),
@of_parse_name_T str0 str valid name p h')
: of_parse_item_T str h.
Proof.
intros str' pf valid' pats p H_h Hinit' H_forall.
destruct h as [|h']; [ exfalso; omega | ].
destruct p as [|name' str'' p'].
{ left.
eexists (@MinimalParse.MinParseTerminal _ _ _ _ _ _ _ _ _ _);
split; simpl; constructor. }
{ edestruct (fun pf => @minimal_parse_of_name__of__parse_of_name (S h') pf str _ valid' _ p') as [ [p'' H''] | p'' ];
try solve [ repeat (apply Lt.lt_n_Sn || apply Lt.lt_S)
| exact Hinit'
| exact H_h
| exact H_forall
| exact pf ];
[|];
[ left | right ].
{ exists (MinParseNonTerminal p'').
simpl in *.
exact H''. }
{ exact p''. } }
Defined.
End item.
Section production.
Context {str0 str : String} {valid : names_listT}.
Local Ltac min_parse_prod_t' :=
idtac;
match goal with
| _ => assumption
| [ |- ?R ?x ?x ]
=> reflexivity
| _ => progress destruct_head prod
| [ H : False |- _ ]
=> solve [ destruct H ]
| _ => progress simpl
| _ => progress rewrite ?parse_of_contract_minimal_parse_of_item_lt, ?parse_of_contract_minimal_parse_of_production_lt, ?parse_of_contract_minimal_parse_of_lt
| [ |- context G[size_of_parse_production (ParseProductionCons ?a ?b)] ]
=> let G' := context G[S (size_of_parse_item a + size_of_parse_production b)] in
change G'
| [ H : alt_option _ initial_names_data _ |- _ ]
=> apply not_alt_all in H
| [ p0 : minimal_parse_of_item _ _ ?s0 ?pat,
p1 : minimal_parse_of_production _ _ ?s1 ?pats,
H : ?s0 ++ ?s1 ≤s ?s'
|- ({ p' : minimal_parse_of_production ?s' _ (?s0 ++ ?s1) (?pat :: ?pats) & _ } + _)%type ]
=> left; exists (MinParseProductionCons H p0 p1)
| [ p0 : minimal_parse_of_item ?s' _ ?s0 ?pat,
p1 : minimal_parse_of_production ?s' _ ?s1 ?pats,
H : ?s0 ++ ?s1 ≤s ?s',
H' : Length ?s0 < Length ?s'
|- ({ p' : minimal_parse_of_production ?s' ?v (?s0 ++ ?s1) (?pat :: ?pats) & _ } + _)%type ]
=> left; exists (MinParseProductionCons
H
(contract_minimal_parse_of_item_lt (valid' := v) H' p0)
p1)
| [ p0 : minimal_parse_of_item ?s' _ ?s0 ?pat,
p1 : minimal_parse_of_production ?s' _ ?s1 ?pats,
H : ?s0 ++ ?s1 ≤s ?s',
H' : Length ?s1 < Length ?s'
|- ({ p' : minimal_parse_of_production ?s' ?v (?s0 ++ ?s1) (?pat :: ?pats) & _ } + _)%type ]
=> left; exists (MinParseProductionCons
H
p0
(contract_minimal_parse_of_production_lt (valid' := v) H' p1))
| [ p0 : minimal_parse_of_item ?s' _ ?s0 ?pat,
p1 : minimal_parse_of_production ?s' _ ?s1 ?pats,
H : ?s0 ++ ?s1 ≤s ?s',
H' : Length ?s0 < Length ?s',
H'' : Length ?s1 < Length ?s'
|- ({ p' : minimal_parse_of_production ?s' ?v (?s0 ++ ?s1) (?pat :: ?pats) & _ } + _)%type ]
=> left; exists (MinParseProductionCons
H
(contract_minimal_parse_of_item_lt (valid' := v) H' p0)
(contract_minimal_parse_of_production_lt (valid' := v) H'' p1))
| [ |- (_ * _)%type ]
=> split
| [ H : _ <= _ |- _ <= _ ] => apply H
| _ => apply Le.le_n_S
| _ => apply Plus.plus_le_compat
| [ H0 : Forall_parse_of_item _ _,
H1 : Forall_parse_of_production _ _
|- Forall_parse_of_production _ _ ]
=> exact (H0, H1)
| [ H : alt_option _ ?v ?x
|- (_ + alt_option _ ?v (?x ++ Empty _))%type ]
=> right; eapply expand_alt_option'; [ .. | exact H ]
| [ H : alt_option _ ?v ?x
|- (_ + alt_option _ ?v (Empty _ ++ ?x))%type ]
=> right; eapply expand_alt_option'; [ .. | exact H ]
| [ |- _ = _ ]
=> progress rewrite ?LeftId, ?RightId
| _
=> solve [ eauto using le_S, Le.le_trans, Plus.le_plus_l, Plus.le_plus_r with nocore ]
end.
Local Ltac min_parse_prod_pose_t' :=
idtac;
match goal with
| [ H : ?a <> Empty _,
H' : ?a ++ _ ≤s _ |- _ ]
=> unique pose proof (strle_to_lt_nonempty_r H H')
| [ H : ?a <> Empty _,
H' : _ ++ ?a ≤s _ |- _ ]
=> unique pose proof (strle_to_lt_nonempty_l H H')
end.
Local Ltac min_parse_prod_pose_t := repeat min_parse_prod_pose_t'.
Local Ltac min_parse_prod_t := repeat min_parse_prod_t'.
(** This is the proof where we pay the proof for conceptual
mismatch. We are, conceptually, simultaneously
"minimizing parse trees" and "producing parse traces". It
is marginally nicer(!!) to contain the ugliness in this
single proof, rather than have it infect everything. So
we must conceptually minimize the passed parse tree while
in fact building a trace of the parse algorithm. To do
this, in the cons case, we need to figure out how we're
decreasing. According with conceptual minimization, when
we have parsed [s0 ++ s1] as a cons of [p0] and [p1],
having a smaller parse tree for, say [s0], with any other
pattern, does us no good, unless [s1] is empty (and [s0 =
s0 ++ s1]), when we can simply pass that smaller parse up
the function call tree. So we must eliminate the
"alternate" option, by expanding the valid list to the
initial data. Luckily(?!), in the case where [s1] is
non-empty, [s0] is strictly smaller than [s0 ++ s1], and
thus we can rebuild the minimal parse tree to contract it.
This, finally, allows us to either build a minimal parse
tree for the thing we are asked about (or to contract the
"alternate option" parse tree, passing it back up?). *)
Fixpoint minimal_parse_of_production__of__parse_of_production
h
(minimal_parse_of_name__of__parse_of_name
: forall h' (pf : h' < S (S h)) {str0 str valid name}
(p : parse_of String G str (Lookup G name)),
@of_parse_name_T str0 str valid name p h')
{struct h}
: of_parse_production_T str h.
Proof.
intros str' pf valid' pats p H_h Hinit' H_forall.
destruct h as [|h']; [ exfalso; omega | ].
destruct p as [| str' strs' str'' pat' p0' p1' ].
{ clear minimal_parse_of_production__of__parse_of_production.
left.
eexists (@MinimalParse.MinParseProductionNil _ _ _ _ _ _ _ _ _);
repeat (reflexivity || esplit). }
{ specialize (fun h' pf
=> @minimal_parse_of_name__of__parse_of_name
h' (transitivity pf (Lt.lt_n_Sn _))).
change (S ((size_of_parse_item p0')
+ (size_of_parse_production p1'))
< S h') in H_h.
apply Lt.lt_S_n in H_h.
pose proof (Lt.le_lt_trans _ _ _ (Plus.le_plus_l _ _) H_h) as H_h0.
pose proof (Lt.le_lt_trans _ _ _ (Plus.le_plus_r _ _) H_h) as H_h1.
clear H_h.
pose proof (fun valid Hinit => @minimal_parse_of_item__of__parse_of_item _ h' minimal_parse_of_name__of__parse_of_name _ (transitivity (str_le1_append _ _ _) pf) valid _ p0' H_h0 Hinit (fst H_forall)) as p_it.
pose proof (fun valid Hinit => @minimal_parse_of_production__of__parse_of_production h' minimal_parse_of_name__of__parse_of_name _ (transitivity (str_le2_append _ _ _) pf) valid _ p1' H_h1 Hinit (snd H_forall)) as p_prod.
destruct (stringlike_dec str' (Empty _)), (stringlike_dec str'' (Empty _));
subst.
{ (* empty, empty *)
specialize (p_it valid' Hinit'); specialize (p_prod valid' Hinit').
destruct p_it as [ [ p0'' H0''] |], p_prod as [ [ p1'' H1'' ] |];
[ | | | ];
min_parse_prod_t. }
{ (* empty, nonempty *)
specialize (p_it initial_names_data (reflexivity _)); specialize (p_prod valid' Hinit').
destruct p_it as [ [ p0'' H0''] |], p_prod as [ [ p1'' H1'' ] |];
[ | | | ];
min_parse_prod_t;
min_parse_prod_pose_t;
min_parse_prod_t. }
{ (* nonempty, empty *)
specialize (p_it valid' Hinit'); specialize (p_prod initial_names_data (reflexivity _)).
destruct p_it as [ [ p0'' H0''] |], p_prod as [ [ p1'' H1'' ] |];
[ | | | ];
min_parse_prod_t;
min_parse_prod_pose_t;
min_parse_prod_t. }
{ (* nonempty, nonempty *)
specialize (p_it initial_names_data (reflexivity _)); specialize (p_prod initial_names_data (reflexivity _)).
destruct p_it as [ [ p0'' H0''] |], p_prod as [ [ p1'' H1'' ] |];
[ | | | ];
min_parse_prod_t;
min_parse_prod_pose_t;
min_parse_prod_t. } }
Defined.
End production.
Section productions.
Context {str0 str : String} {valid : names_listT}.
Fixpoint minimal_parse_of_productions__of__parse_of_productions
h
(minimal_parse_of_name__of__parse_of_name
: forall h' (pf : h' < S h) {str0 str valid name}
(p : parse_of String G str (Lookup G name)),
@of_parse_name_T str0 str valid name p h')
{struct h}
: of_parse_T str h.
Proof.
intros str' pf valid' pats p H_h Hinit' H_forall.
destruct h as [|h']; [ exfalso; omega | ].
destruct p as [str' pat pats p' | str' pat pats p'].
{ clear minimal_parse_of_productions__of__parse_of_productions.
edestruct (@minimal_parse_of_production__of__parse_of_production _ h' minimal_parse_of_name__of__parse_of_name _ pf valid' _ p') as [ [p'' p''H] | [name' H'] ];
try solve [ exact (Lt.lt_S_n _ _ H_h)
| exact H_forall
| exact Hinit' ];
[|].
{ left.
exists (MinParseHead pats p'').
simpl.
split;
solve [ exact (Le.le_n_S _ _ (fst p''H))
| exact (snd p''H) ]. }
{ right.
exists name'.
split;
try solve [ exact (fst H') ];
[].
exists (projT1 (snd H'));
split;
try solve [ exact (snd (projT2 (snd H')))
| exact (Lt.lt_S _ _ (fst (projT2 (snd H')))) ]. } }
{ specialize (fun h' pf
=> @minimal_parse_of_name__of__parse_of_name
h' (transitivity pf (Lt.lt_n_Sn _))).
edestruct (minimal_parse_of_productions__of__parse_of_productions h' minimal_parse_of_name__of__parse_of_name _ pf valid' _ p') as [ [p'' p''H] | [name' H'] ];
try solve [ exact (Lt.lt_S_n _ _ H_h)
| exact Hinit'
| exact H_forall ];
[|].
{ left.
exists (MinParseTail pat p'').
simpl.
split;
solve [ exact (Le.le_n_S _ _ (fst p''H))
| exact (snd p''H) ]. }
{ right.
exists name'.
split;
try solve [ exact (fst H') ];
[].
exists (projT1 (snd H'));
split;
try solve [ exact (snd (projT2 (snd H')))
| exact (Lt.lt_S _ _ (fst (projT2 (snd H')))) ]. } }
Defined.
End productions.
Section name.
Section step.
Definition minimal_parse_of_name__of__parse_of_name_step
h
(minimal_parse_of_name__of__parse_of_name
: forall h' (pf : h' < h) {str0 str valid name}
(p : parse_of String G str (Lookup G name)),
@of_parse_name_T str0 str valid name p h')
{str0 str valid name}
(p : parse_of String G str (Lookup G name))
: @of_parse_name_T str0 str valid name p h.
Proof.
destruct h as [|h]; [ clear; repeat intro; exfalso; omega | ].
intros pf Hstr Hinit' H_forall.
let H := match goal with H : str ≤s str0 |- _ => constr:H end in
destruct (strle_to_sumbool _ H) as [pf_lt|pf_eq].
{ (** [str] got smaller, so we reset the valid names list *)
destruct (@minimal_parse_of_productions__of__parse_of_productions str h minimal_parse_of_name__of__parse_of_name str (reflexivity _) initial_names_data (Lookup G name) p (Lt.lt_S_n _ _ pf) (reflexivity _) (snd H_forall)) as [p'|p'].
{ left.
exists (MinParseNonTerminalStrLt _ valid _ pf_lt (projT1 p'));
simpl.
simpl in *.
split;
[ exact (Le.le_n_S _ _ (fst (projT2 p')))
| split;
[ exact (fst H_forall)
| exact (snd (projT2 p')) ] ]. }
{ simpl.
right; eapply expand_alt_option; [..| exact p' ];
solve [ apply Lt.lt_n_Sn
| assumption
| reflexivity ]. } }
{ (** [str] didn't get smaller, so we cache the fact that we've hit this name already *)
destruct (Sumbool.sumbool_of_bool (is_valid_name valid name)) as [ Hvalid | Hinvalid ].
{ destruct (@minimal_parse_of_productions__of__parse_of_productions str h minimal_parse_of_name__of__parse_of_name str (reflexivity _) (remove_name valid name) (Lookup G name) p (Lt.lt_S_n _ _ pf) (transitivity (R := sub_names_listT is_valid_name) (@sub_names_listT_remove _ is_valid_name _ remove_name_1 _ _) Hinit') (snd H_forall)) as [p'|p'].
{ left.
subst str.
eexists (@MinimalParse.MinParseNonTerminalStrEq _ _ _ _ _ _ _ _ _ _ Hvalid (projT1 p')).
simpl in *.
split;
[ exact (Le.le_n_S _ _ (fst (projT2 p')))
| split;
[ exact (fst H_forall)
| exact (snd (projT2 p')) ] ]. }
{ destruct p' as [name' p'].
destruct (string_dec name name') as [|n].
{ subst name; simpl in *.
edestruct (@minimal_parse_of_name__of__parse_of_name (S (size_of_parse p)) pf str0 _ valid name' (projT1 (snd p'))) as [p''|p''];
try solve [ apply Lt.lt_n_S, (fst (projT2 (snd p')))
| subst; reflexivity
| assumption
| split; [ exact (proj2 (fst p'))
| exact (snd (projT2 (snd p'))) ] ];
[|].
{ left.
exists (projT1 p'').
split.
{ etransitivity;
[ exact (fst (projT2 p''))
| exact (Lt.lt_le_weak _ _ (Lt.lt_n_S _ _ (fst (projT2 (snd p'))))) ]. }
{ exact (snd (projT2 p'')). } }
{ right.
exists (projT1 p'').
split;
[ exact (fst (projT2 p''))
| ].
exists (projT1 (snd (projT2 p''))).
split;
[ etransitivity;
[ exact (fst (projT2 (snd (projT2 p''))))
| exact (Lt.lt_n_S _ _ (fst (projT2 (snd p')))) ]
| exact (snd (projT2 (snd (projT2 p'')))) ]. } }
{ right.
exists name'.
destruct p' as [p'H p'p].
split.
{ rewrite remove_name_5 in p'H by assumption.
exact p'H. }
{ exists (projT1 p'p).
split; [ exact (Lt.lt_S _ _ (fst (projT2 p'p)))
| exact (snd (projT2 p'p)) ]. } } } }
{ (** oops, we already saw this name in the past. ABORT! *)
right.
exists name.
destruct H_forall.
split; [ split; assumption
| ].
exists p.
split; solve [ assumption
| apply Lt.lt_n_Sn ]. } }
Defined.
End step.
Section wf.
Definition minimal_parse_of_name__of__parse_of_name
: forall h
{str0 str valid name}
(p : parse_of String G str (Lookup G name)),
@of_parse_name_T str0 str valid name p h
:= @Fix
_ lt lt_wf
(fun h => forall {str0 str valid name}
(p : parse_of String G str (Lookup G name)),
@of_parse_name_T str0 str valid name p h)
(@minimal_parse_of_name__of__parse_of_name_step).
End wf.
End name.
End wf_parts.
End minimize.
End cfg.
|
#include <linux/types.h>
#include "sweeny_bfs.h"
#include <stdio.h>
#include "timeseries.h"
#include "extract_args.h"
#include <math.h>
#include <gsl/gsl_rng.h>
#ifdef SEQUENTIAL
char impl_title[] = "Sequential BFS implementation";
#define TS_FILE_D "../time_series/sbfs/simulation_l%u_q%.4f_b%.4f_c%.4f_s%u.hdf5"
#define INFO_STRING "*Sequential BFS implementation of Sweeny's algorithm*\n"
#define INIT init_sweeny_sbfs
#define SIMULATE simulate_sweeny_sbfs
#define DESTROY destroy_sweeny_sbfs
#else
char impl_title[] = "Interleaved BFS implementation";
#define TS_FILE_D "../time_series/ibfs/simulation_l%u_q%.4f_b%.4f_c%.4f_s%u.hdf5"
#define INFO_STRING "*Interleaved BFS implementation of Sweeny's algorithm*\n"
#define INIT init_sweeny_ibfs
#define SIMULATE simulate_sweeny_ibfs
#define DESTROY destroy_sweeny_ibfs
#endif
#define BUF_LEN 512
char fn[BUF_LEN];
char verbose=0;
__u32 DX;
__u32 N;
__u32 seed;
double q;
double coupling;
double beta;
double v;
double K;
__u32 steps;
__s8 *bonds;
gsl_rng * r;
char *filename;
__u32 cutoff;
__u32 *num_bonds , *num_cluster, *size_giant;
__u64 *sec_cs_moment,*four_cs_moment;
int main(int argc, char *argv[])
{
if(!extractArgs(argc, argv,impl_title))
return EXIT_FAILURE;
snprintf(fn,BUF_LEN,TS_FILE_D,DX,q,beta,coupling,seed);
if(!init_observables())
return EXIT_FAILURE;
if(!INIT(q,DX,beta,coupling,cutoff,steps,seed,num_bonds,num_cluster,size_giant,sec_cs_moment,four_cs_moment))
return EXIT_FAILURE;
if(!SIMULATE())
return EXIT_FAILURE;
DESTROY();
save_timeseries();
destroy_observables();
return EXIT_SUCCESS;
}
/******************************************************************************
*****************************************************************************/
|
/* cdf/geometric.c
*
* Copyright (C) 2004 Jason H. Stover.
* Copyright (C) 2010 Brian Gough
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <math.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_cdf.h>
#include "error.h"
/* Pr (X <= k), i.e., the probability of n or fewer failures until the
first success. */
double
gsl_cdf_geometric_P (const unsigned int k, const double p)
{
double P, a, q;
if (p > 1.0 || p < 0.0)
{
CDF_ERROR ("p < 0 or p > 1", GSL_EDOM);
}
if (k < 1)
{
return 0.0;
}
q = 1.0 - p;
a = (double) k;
if (p < 0.5)
{
P = -expm1 (a * log1p (-p));
}
else
{
P = 1.0 - pow (q, a);
}
return P;
}
double
gsl_cdf_geometric_Q (const unsigned int k, const double p)
{
double Q, a, q;
if (p > 1.0 || p < 0.0)
{
CDF_ERROR ("p < 0 or p > 1", GSL_EDOM);
}
if (k < 1)
{
return 1.0;
}
q = 1.0 - p;
a = (double) k;
if (p < 0.5)
{
Q = exp (a * log1p (-p));
}
else
{
Q = pow (q, a);
}
return Q;
}
|
Formal statement is: lemma holomorphic_onD [dest?]: "\<lbrakk>f holomorphic_on s; x \<in> s\<rbrakk> \<Longrightarrow> f field_differentiable (at x within s)" Informal statement is: If $f$ is holomorphic on a set $S$, and $x \in S$, then $f$ is differentiable at $x$ on $S$. |
common_source_folder <- "~/Documents/R_Projects/Common_R_Source_Files/"; # directory to folder where you keep common source
source(paste(common_source_folder,"RevBayes_Setup.r",sep=""));
# This will take the Mesquite file and break it down into three matrices for 2-, 3- & 4-state characters.
# None of the notes or information about taxa, characters & states are retained; these choke RevBayes
analysis_name <- "Cinctamania_2019";
mesquite_to_RevBayes <- diffindo_character_matrix_by_state_numbers_and_other_partitions(analysis_name);
# This will take a nexus file plus a intervals.tsv file and an FBD parameterization script, and create a script for a strict clock analysis in RevBayes
set_wdir <- "/Users/bilbo_baggins/Documents/RevBayes_Projects/";
scribio_RevBayes_scripts_from_chosen_nexus_file_and_existing_FBD_script_and_data(analysis_name=analysis_name,set_wdir=set_wdir);
end();
|
(** This file implements finite set as unordered lists without duplicates
removed. This implementation forms a monad. *)
From stdpp Require Export sets list.
From stdpp Require Import options.
Record listset A := Listset { listset_car: list A }.
Global Arguments listset_car {_} _ : assert.
Global Arguments Listset {_} _ : assert.
Section listset.
Context {A : Type}.
Global Instance listset_elem_of: ElemOf A (listset A) := λ x l, x ∈ listset_car l.
Global Instance listset_empty: Empty (listset A) := Listset [].
Global Instance listset_singleton: Singleton A (listset A) := λ x, Listset [x].
Global Instance listset_union: Union (listset A) := λ '(Listset l) '(Listset k),
Listset (l ++ k).
Global Opaque listset_singleton listset_empty.
Global Instance listset_simple_set : SemiSet A (listset A).
Proof.
split.
- by apply not_elem_of_nil.
- by apply elem_of_list_singleton.
- intros [?] [?]. apply elem_of_app.
Qed.
Lemma listset_empty_alt X : X ≡ ∅ ↔ listset_car X = [].
Proof.
destruct X as [l]; split; [|by intros; simplify_eq/=].
rewrite elem_of_equiv_empty; intros Hl.
destruct l as [|x l]; [done|]. feed inversion (Hl x). left.
Qed.
Global Instance listset_empty_dec (X : listset A) : Decision (X ≡ ∅).
Proof.
refine (cast_if (decide (listset_car X = [])));
abstract (by rewrite listset_empty_alt).
Defined.
Context `{Aeq : !EqDecision A}.
Global Instance listset_elem_of_dec : RelDecision (∈@{listset A}).
Proof using Aeq.
refine (λ x X, cast_if (decide (x ∈ listset_car X))); done.
Defined.
Global Instance listset_intersection: Intersection (listset A) :=
λ '(Listset l) '(Listset k), Listset (list_intersection l k).
Global Instance listset_difference: Difference (listset A) :=
λ '(Listset l) '(Listset k), Listset (list_difference l k).
Local Instance listset_set: Set_ A (listset A).
Proof.
split.
- apply _.
- intros [?] [?]. apply elem_of_list_intersection.
- intros [?] [?]. apply elem_of_list_difference.
Qed.
Global Instance listset_elements: Elements A (listset A) :=
remove_dups ∘ listset_car.
Global Instance listset_fin_set : FinSet A (listset A).
Proof.
split.
- apply _.
- intros. apply elem_of_remove_dups.
- intros. apply NoDup_remove_dups.
Qed.
End listset.
Global Instance listset_ret: MRet listset := λ A x, {[ x ]}.
Global Instance listset_fmap: FMap listset := λ A B f '(Listset l),
Listset (f <$> l).
Global Instance listset_bind: MBind listset := λ A B f '(Listset l),
Listset (mbind (listset_car ∘ f) l).
Global Instance listset_join: MJoin listset := λ A, mbind id.
Global Instance listset_set_monad : MonadSet listset.
Proof.
split.
- intros. apply _.
- intros ??? [?] ?. apply elem_of_list_bind.
- intros. apply elem_of_list_ret.
- intros ??? [?]. apply elem_of_list_fmap.
- intros ? [?] ?. unfold mjoin, listset_join, elem_of, listset_elem_of.
simpl. by rewrite elem_of_list_bind.
Qed.
|
% Small technical example.
% Shows how to call for the multiresolution decomposition of an image
% and shows the detailed bookkeeping.
%
disp('Small technical example.');
disp('Shows how to call for the multiresolution decomposition of an image');
disp('and shows the detailed bookkeeping.');
disp('FOR MORE INFORMATION: help QLiftDec2');
disp(' ');
disp('See also the report http://repository.cwi.nl:8888/cwi_repository/docs/IV/04/04178D.pdf');
disp('Dr. Paul M. de Zeeuw <[email protected]>');
disp(' (C) 1998-2006 Stichting CWI, Amsterdam, The Netherlands');
disp(' ');
%---PARAMETERS-----------------------------------------------------------------
% How to execute, set parameters
N = 6; % maximum level (even number) in lifting scheme
filtername = 'Neville4';
%
%---INSERT YOUR IMAGE HERE-----------------------------------------------------
if exist('imread','file') == 2
Orig = double(imread('zenithgray.TIF','tiff'));
else
load zenithgray; Orig = zenithgray; clear zenithgray;
end
%
disp([' Dimensions of original ' int2str( size(Orig) )]);
%---DECOMPOSITION--------------------------------------------------------------
disp([' Filter type is ' filtername]);
[C,S] = QLiftDec2(Orig,N,filtername);
disp([' Dimensions of decomposition ' int2str( size(C) )]);
disp(' Contents of bookkeeping ');
disp(int2str(S));
%
|
Pupils sit crammed together without necessary materials , and often without skilled teaching staff . Moreover , the Polish schools are closed during at least five months out of the ten months of the school year due to lack of coal or other fuel . Of twenty @-@ thirty spacious school buildings which Kraków had before 1939 , today the worst two buildings are used ... Every day , pupils have to study in several shifts . Under such circumstances , the school day , which normally lasts five hours , is reduced to one hour .
|
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Jens Wagemaker, Aaron Anderson
-/
import algebra.gcd_monoid
import ring_theory.integral_domain
import ring_theory.noetherian
/-!
# Unique factorization
## Main Definitions
* `wf_dvd_monoid` holds for `monoid`s for which a strict divisibility relation is
well-founded.
* `unique_factorization_monoid` holds for `wf_dvd_monoid`s where
`irreducible` is equivalent to `prime`
## To do
* set up the complete lattice structure on `factor_set`.
-/
variables {α : Type*}
local infix ` ~ᵤ ` : 50 := associated
/-- Well-foundedness of the strict version of |, which is equivalent to the descending chain
condition on divisibility and to the ascending chain condition on
principal ideals in an integral domain.
-/
class wf_dvd_monoid (α : Type*) [comm_monoid_with_zero α] : Prop :=
(well_founded_dvd_not_unit : well_founded (@dvd_not_unit α _))
export wf_dvd_monoid (well_founded_dvd_not_unit)
@[priority 100] -- see Note [lower instance priority]
instance is_noetherian_ring.wf_dvd_monoid [integral_domain α] [is_noetherian_ring α] :
wf_dvd_monoid α :=
⟨by { convert inv_image.wf (λ a, ideal.span ({a} : set α)) (well_founded_submodule_gt _ _),
ext,
exact ideal.span_singleton_lt_span_singleton.symm }⟩
namespace wf_dvd_monoid
variables [comm_monoid_with_zero α]
open associates nat
theorem of_wf_dvd_monoid_associates (h : wf_dvd_monoid (associates α)): wf_dvd_monoid α :=
⟨begin
haveI := h,
refine (surjective.well_founded_iff mk_surjective _).2 wf_dvd_monoid.well_founded_dvd_not_unit,
intros, rw mk_dvd_not_unit_mk_iff
end⟩
variables [wf_dvd_monoid α]
instance wf_dvd_monoid_associates : wf_dvd_monoid (associates α) :=
⟨begin
refine (surjective.well_founded_iff mk_surjective _).1 wf_dvd_monoid.well_founded_dvd_not_unit,
intros, rw mk_dvd_not_unit_mk_iff
end⟩
theorem well_founded_associates : well_founded ((<) : associates α → associates α → Prop) :=
subrelation.wf (λ x y, dvd_not_unit_of_lt) wf_dvd_monoid.well_founded_dvd_not_unit
local attribute [elab_as_eliminator] well_founded.fix
lemma exists_irreducible_factor {a : α} (ha : ¬ is_unit a) (ha0 : a ≠ 0) :
∃ i, irreducible i ∧ i ∣ a :=
(irreducible_or_factor a ha).elim (λ hai, ⟨a, hai, dvd_refl _⟩)
(well_founded.fix
wf_dvd_monoid.well_founded_dvd_not_unit
(λ a ih ha ha0 ⟨x, y, hx, hy, hxy⟩,
have hx0 : x ≠ 0, from λ hx0, ha0 (by rw [← hxy, hx0, zero_mul]),
(irreducible_or_factor x hx).elim
(λ hxi, ⟨x, hxi, hxy ▸ by simp⟩)
(λ hxf, let ⟨i, hi⟩ := ih x ⟨hx0, y, hy, hxy.symm⟩ hx hx0 hxf in
⟨i, hi.1, dvd.trans hi.2 (hxy ▸ by simp)⟩)) a ha ha0)
@[elab_as_eliminator] lemma induction_on_irreducible {P : α → Prop} (a : α)
(h0 : P 0) (hu : ∀ u : α, is_unit u → P u)
(hi : ∀ a i : α, a ≠ 0 → irreducible i → P a → P (i * a)) :
P a :=
by haveI := classical.dec; exact
well_founded.fix wf_dvd_monoid.well_founded_dvd_not_unit
(λ a ih, if ha0 : a = 0 then ha0.symm ▸ h0
else if hau : is_unit a then hu a hau
else let ⟨i, hii, ⟨b, hb⟩⟩ := exists_irreducible_factor hau ha0 in
have hb0 : b ≠ 0, from λ hb0, by simp * at *,
hb.symm ▸ hi _ _ hb0 hii (ih _ ⟨hb0, i,
hii.1, by rw [hb, mul_comm]⟩))
a
lemma exists_factors (a : α) : a ≠ 0 →
∃f : multiset α, (∀b ∈ f, irreducible b) ∧ associated f.prod a :=
wf_dvd_monoid.induction_on_irreducible a
(λ h, (h rfl).elim)
(λ u hu _, ⟨0, ⟨by simp [hu], associated.symm (by simp [hu, associated_one_iff_is_unit])⟩⟩)
(λ a i ha0 hii ih hia0,
let ⟨s, hs⟩ := ih ha0 in
⟨i ::ₘ s, ⟨by clear _let_match; finish,
by { rw multiset.prod_cons,
exact associated_mul_mul (by refl) hs.2 }⟩⟩)
end wf_dvd_monoid
theorem wf_dvd_monoid.of_well_founded_associates [comm_cancel_monoid_with_zero α]
(h : well_founded ((<) : associates α → associates α → Prop)) : wf_dvd_monoid α :=
wf_dvd_monoid.of_wf_dvd_monoid_associates
⟨by { convert h, ext, exact associates.dvd_not_unit_iff_lt }⟩
theorem wf_dvd_monoid.iff_well_founded_associates [comm_cancel_monoid_with_zero α] :
wf_dvd_monoid α ↔ well_founded ((<) : associates α → associates α → Prop) :=
⟨by apply wf_dvd_monoid.well_founded_associates, wf_dvd_monoid.of_well_founded_associates⟩
section prio
set_option default_priority 100 -- see Note [default priority]
/-- unique factorization monoids.
These are defined as `comm_cancel_monoid_with_zero`s with well-founded strict divisibility
relations, but this is equivalent to more familiar definitions:
Each element (except zero) is uniquely represented as a multiset of irreducible factors.
Uniqueness is only up to associated elements.
Each element (except zero) is non-uniquely represented as a multiset
of prime factors.
To define a UFD using the definition in terms of multisets
of irreducible factors, use the definition `of_exists_unique_irreducible_factors`
To define a UFD using the definition in terms of multisets
of prime factors, use the definition `of_exists_prime_factors`
-/
class unique_factorization_monoid (α : Type*) [comm_cancel_monoid_with_zero α]
extends wf_dvd_monoid α : Prop :=
(irreducible_iff_prime : ∀ {a : α}, irreducible a ↔ prime a)
instance ufm_of_gcd_of_wf_dvd_monoid [nontrivial α] [comm_cancel_monoid_with_zero α]
[wf_dvd_monoid α] [gcd_monoid α] : unique_factorization_monoid α :=
{ irreducible_iff_prime := λ _, gcd_monoid.irreducible_iff_prime
.. ‹wf_dvd_monoid α› }
instance associates.ufm [comm_cancel_monoid_with_zero α]
[unique_factorization_monoid α] : unique_factorization_monoid (associates α) :=
{ irreducible_iff_prime := by { rw ← associates.irreducible_iff_prime_iff,
apply unique_factorization_monoid.irreducible_iff_prime, }
.. (wf_dvd_monoid.wf_dvd_monoid_associates : wf_dvd_monoid (associates α)) }
end prio
namespace unique_factorization_monoid
variables [comm_cancel_monoid_with_zero α] [unique_factorization_monoid α]
theorem exists_prime_factors (a : α) : a ≠ 0 →
∃ f : multiset α, (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a :=
by { simp_rw ← unique_factorization_monoid.irreducible_iff_prime,
apply wf_dvd_monoid.exists_factors a }
@[elab_as_eliminator] lemma induction_on_prime {P : α → Prop}
(a : α) (h₁ : P 0) (h₂ : ∀ x : α, is_unit x → P x)
(h₃ : ∀ a p : α, a ≠ 0 → prime p → P a → P (p * a)) : P a :=
begin
simp_rw ← unique_factorization_monoid.irreducible_iff_prime at h₃,
exact wf_dvd_monoid.induction_on_irreducible a h₁ h₂ h₃,
end
lemma factors_unique : ∀{f g : multiset α},
(∀x∈f, irreducible x) → (∀x∈g, irreducible x) → f.prod ~ᵤ g.prod →
multiset.rel associated f g :=
by haveI := classical.dec_eq α; exact
λ f, multiset.induction_on f
(λ g _ hg h,
multiset.rel_zero_left.2 $
multiset.eq_zero_of_forall_not_mem (λ x hx,
have is_unit g.prod, by simpa [associated_one_iff_is_unit] using h.symm,
(hg x hx).not_unit (is_unit_iff_dvd_one.2 (dvd.trans (multiset.dvd_prod hx)
(is_unit_iff_dvd_one.1 this)))))
(λ p f ih g hf hg hfg,
let ⟨b, hbg, hb⟩ := exists_associated_mem_of_dvd_prod
(irreducible_iff_prime.1 (hf p (by simp)))
(λ q hq, irreducible_iff_prime.1 (hg _ hq)) $
(dvd_iff_dvd_of_rel_right hfg).1
(show p ∣ (p ::ₘ f).prod, by simp) in
begin
rw ← multiset.cons_erase hbg,
exact multiset.rel.cons hb (ih (λ q hq, hf _ (by simp [hq]))
(λ q (hq : q ∈ g.erase b), hg q (multiset.mem_of_mem_erase hq))
(associated_mul_left_cancel
(by rwa [← multiset.prod_cons, ← multiset.prod_cons, multiset.cons_erase hbg]) hb
(hf p (by simp)).ne_zero))
end)
end unique_factorization_monoid
lemma prime_factors_unique [comm_cancel_monoid_with_zero α] : ∀ {f g : multiset α},
(∀ x ∈ f, prime x) → (∀ x ∈ g, prime x) → f.prod ~ᵤ g.prod →
multiset.rel associated f g :=
by haveI := classical.dec_eq α; exact
λ f, multiset.induction_on f
(λ g _ hg h,
multiset.rel_zero_left.2 $
multiset.eq_zero_of_forall_not_mem $ λ x hx,
have is_unit g.prod, by simpa [associated_one_iff_is_unit] using h.symm,
(irreducible_of_prime $ hg x hx).not_unit $ is_unit_iff_dvd_one.2 $
dvd.trans (multiset.dvd_prod hx) (is_unit_iff_dvd_one.1 this))
(λ p f ih g hf hg hfg,
let ⟨b, hbg, hb⟩ := exists_associated_mem_of_dvd_prod
(hf p (by simp)) (λ q hq, hg _ hq) $
(dvd_iff_dvd_of_rel_right hfg).1
(show p ∣ (p ::ₘ f).prod, by simp) in
begin
rw ← multiset.cons_erase hbg,
exact multiset.rel.cons hb (ih (λ q hq, hf _ (by simp [hq]))
(λ q (hq : q ∈ g.erase b), hg q (multiset.mem_of_mem_erase hq))
(associated_mul_left_cancel
(by rwa [← multiset.prod_cons, ← multiset.prod_cons, multiset.cons_erase hbg]) hb
(hf p (by simp)).ne_zero))
end)
/-- If an irreducible has a prime factorization,
then it is an associate of one of its prime factors. -/
lemma prime_factors_irreducible [comm_cancel_monoid_with_zero α] {a : α} {f : multiset α}
(ha : irreducible a) (pfa : (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a) :
∃ p, a ~ᵤ p ∧ f = p ::ₘ 0 :=
begin
haveI := classical.dec_eq α,
refine multiset.induction_on f (λ h, (ha.not_unit
(associated_one_iff_is_unit.1 (associated.symm h))).elim) _ pfa.2 pfa.1,
rintros p s _ ⟨u, hu⟩ hs,
use p,
have hs0 : s = 0,
{ by_contra hs0,
obtain ⟨q, hq⟩ := multiset.exists_mem_of_ne_zero hs0,
apply (hs q (by simp [hq])).2.1,
refine (ha.is_unit_or_is_unit (_ : _ = ((p * ↑u) * (s.erase q).prod) * _)).resolve_left _,
{ rw [mul_right_comm _ _ q, mul_assoc, ← multiset.prod_cons, multiset.cons_erase hq, ← hu,
mul_comm, mul_comm p _, mul_assoc],
simp, },
apply mt is_unit_of_mul_is_unit_left (mt is_unit_of_mul_is_unit_left _),
apply (hs p (multiset.mem_cons_self _ _)).2.1 },
simp only [mul_one, multiset.prod_cons, multiset.prod_zero, hs0] at *,
exact ⟨associated.symm ⟨u, hu⟩, rfl⟩,
end
section exists_prime_factors
variables [comm_cancel_monoid_with_zero α]
variables (pf : ∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a)
include pf
lemma wf_dvd_monoid.of_exists_prime_factors : wf_dvd_monoid α :=
⟨begin
classical,
apply rel_hom.well_founded (rel_hom.mk _ _) (with_top.well_founded_lt nat.lt_wf),
{ intro a,
by_cases h : a = 0, { exact ⊤ },
exact (classical.some (pf a h)).card },
rintros a b ⟨ane0, ⟨c, hc, b_eq⟩⟩,
rw dif_neg ane0,
by_cases h : b = 0, { simp [h, lt_top_iff_ne_top] },
rw [dif_neg h, with_top.coe_lt_coe],
have cne0 : c ≠ 0, { refine mt (λ con, _) h, rw [b_eq, con, mul_zero] },
calc multiset.card (classical.some (pf a ane0))
< _ + multiset.card (classical.some (pf c cne0)) :
lt_add_of_pos_right _ (multiset.card_pos.mpr (λ con, hc (associated_one_iff_is_unit.mp _)))
... = multiset.card (classical.some (pf a ane0) + classical.some (pf c cne0)) :
(multiset.card_add _ _).symm
... = multiset.card (classical.some (pf b h)) :
multiset.card_eq_card_of_rel (prime_factors_unique _ (classical.some_spec (pf _ h)).1 _),
{ convert (classical.some_spec (pf c cne0)).2.symm,
rw [con, multiset.prod_zero] },
{ intros x hadd,
rw multiset.mem_add at hadd,
cases hadd; apply (classical.some_spec (pf _ _)).1 _ hadd },
{ rw multiset.prod_add,
transitivity a * c,
{ apply associated_mul_mul; apply (classical.some_spec (pf _ _)).2 },
{ rw ← b_eq,
apply (classical.some_spec (pf _ _)).2.symm, } }
end⟩
lemma irreducible_iff_prime_of_exists_prime_factors {p : α} : irreducible p ↔ prime p :=
begin
by_cases hp0 : p = 0,
{ simp [hp0] },
refine ⟨λ h, _, irreducible_of_prime⟩,
obtain ⟨f, hf⟩ := pf p hp0,
obtain ⟨q, hq, rfl⟩ := prime_factors_irreducible h hf,
rw prime_iff_of_associated hq,
exact hf.1 q (multiset.mem_cons_self _ _)
end
theorem unique_factorization_monoid.of_exists_prime_factors :
unique_factorization_monoid α :=
{ irreducible_iff_prime := λ _, irreducible_iff_prime_of_exists_prime_factors pf,
.. wf_dvd_monoid.of_exists_prime_factors pf }
end exists_prime_factors
theorem unique_factorization_monoid.iff_exists_prime_factors [comm_cancel_monoid_with_zero α] :
unique_factorization_monoid α ↔
(∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a) :=
⟨λ h, @unique_factorization_monoid.exists_prime_factors _ _ h,
unique_factorization_monoid.of_exists_prime_factors⟩
theorem irreducible_iff_prime_of_exists_unique_irreducible_factors [comm_cancel_monoid_with_zero α]
(eif : ∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, irreducible b) ∧ f.prod ~ᵤ a)
(uif : ∀ (f g : multiset α),
(∀ x ∈ f, irreducible x) → (∀ x ∈ g, irreducible x) → f.prod ~ᵤ g.prod →
multiset.rel associated f g)
(p : α) : irreducible p ↔ prime p :=
⟨by letI := classical.dec_eq α; exact λ hpi,
⟨hpi.ne_zero, hpi.1,
λ a b ⟨x, hx⟩,
if hab0 : a * b = 0
then (eq_zero_or_eq_zero_of_mul_eq_zero hab0).elim
(λ ha0, by simp [ha0])
(λ hb0, by simp [hb0])
else
have hx0 : x ≠ 0, from λ hx0, by simp * at *,
have ha0 : a ≠ 0, from left_ne_zero_of_mul hab0,
have hb0 : b ≠ 0, from right_ne_zero_of_mul hab0,
begin
cases eif x hx0 with fx hfx,
cases eif a ha0 with fa hfa,
cases eif b hb0 with fb hfb,
have h : multiset.rel associated (p ::ₘ fx) (fa + fb),
{ apply uif,
{ exact λ i hi, (multiset.mem_cons.1 hi).elim (λ hip, hip.symm ▸ hpi) (hfx.1 _), },
{ exact λ i hi, (multiset.mem_add.1 hi).elim (hfa.1 _) (hfb.1 _), },
calc multiset.prod (p ::ₘ fx)
~ᵤ a * b : by rw [hx, multiset.prod_cons];
exact associated_mul_mul (by refl) hfx.2
... ~ᵤ (fa).prod * (fb).prod :
associated_mul_mul hfa.2.symm hfb.2.symm
... = _ : by rw multiset.prod_add, },
exact let ⟨q, hqf, hq⟩ := multiset.exists_mem_of_rel_of_mem h
(multiset.mem_cons_self p _) in
(multiset.mem_add.1 hqf).elim
(λ hqa, or.inl $ (dvd_iff_dvd_of_rel_left hq).2 $
(dvd_iff_dvd_of_rel_right hfa.2).1
(multiset.dvd_prod hqa))
(λ hqb, or.inr $ (dvd_iff_dvd_of_rel_left hq).2 $
(dvd_iff_dvd_of_rel_right hfb.2).1
(multiset.dvd_prod hqb))
end⟩, irreducible_of_prime⟩
theorem unique_factorization_monoid.of_exists_unique_irreducible_factors
[comm_cancel_monoid_with_zero α]
(eif : ∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, irreducible b) ∧ f.prod ~ᵤ a)
(uif : ∀ (f g : multiset α),
(∀ x ∈ f, irreducible x) → (∀ x ∈ g, irreducible x) → f.prod ~ᵤ g.prod →
multiset.rel associated f g) :
unique_factorization_monoid α :=
unique_factorization_monoid.of_exists_prime_factors (by
{ convert eif,
simp_rw irreducible_iff_prime_of_exists_unique_irreducible_factors eif uif })
namespace unique_factorization_monoid
variables [comm_cancel_monoid_with_zero α] [decidable_eq α] [nontrivial α] [normalization_monoid α]
variables [unique_factorization_monoid α]
/-- Noncomputably determines the multiset of prime factors. -/
noncomputable def factors (a : α) : multiset α := if h : a = 0 then 0 else
multiset.map normalize $ classical.some (unique_factorization_monoid.exists_prime_factors a h)
theorem factors_prod {a : α} (ane0 : a ≠ 0) : associated (factors a).prod a :=
begin
rw [factors, dif_neg ane0],
refine associated.trans _ (classical.some_spec (exists_prime_factors a ane0)).2,
rw [← associates.mk_eq_mk_iff_associated, ← associates.prod_mk, ← associates.prod_mk,
multiset.map_map],
congr' 2,
ext,
rw [function.comp_apply, associates.mk_normalize],
end
theorem prime_of_factor {a : α} : ∀ (x : α), x ∈ factors a → prime x :=
begin
rw [factors],
split_ifs with ane0, { simp },
intros x hx, rcases multiset.mem_map.1 hx with ⟨y, ⟨hy, rfl⟩⟩,
rw prime_iff_of_associated (normalize_associated),
exact (classical.some_spec (unique_factorization_monoid.exists_prime_factors a ane0)).1 y hy,
end
theorem irreducible_of_factor {a : α} : ∀ (x : α), x ∈ factors a → irreducible x :=
λ x h, irreducible_of_prime (prime_of_factor x h)
theorem normalize_factor {a : α} : ∀ (x : α), x ∈ factors a → normalize x = x :=
begin
rw factors,
split_ifs with h, { simp },
intros x hx,
obtain ⟨y, hy, rfl⟩ := multiset.mem_map.1 hx,
apply normalize_idem
end
lemma factors_irreducible {a : α} (ha : irreducible a) :
factors a = normalize a ::ₘ 0 :=
begin
obtain ⟨p, a_assoc, hp⟩ := prime_factors_irreducible ha
⟨prime_of_factor, factors_prod ha.ne_zero⟩,
have p_mem : p ∈ factors a,
{ rw hp, apply multiset.mem_cons_self },
convert hp,
rwa [← normalize_factor p p_mem, normalize_eq_normalize_iff, dvd_dvd_iff_associated]
end
lemma exists_mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) : p ∣ a →
∃ q ∈ factors a, p ~ᵤ q :=
λ ⟨b, hb⟩,
have hb0 : b ≠ 0, from λ hb0, by simp * at *,
have multiset.rel associated (p ::ₘ factors b) (factors a),
from factors_unique
(λ x hx, (multiset.mem_cons.1 hx).elim (λ h, h.symm ▸ hp)
(irreducible_of_factor _))
irreducible_of_factor
(associated.symm $ calc multiset.prod (factors a) ~ᵤ a : factors_prod ha0
... = p * b : hb
... ~ᵤ multiset.prod (p ::ₘ factors b) :
by rw multiset.prod_cons; exact associated_mul_mul
(associated.refl _)
(associated.symm (factors_prod hb0))),
multiset.exists_mem_of_rel_of_mem this (by simp)
@[simp] lemma factors_zero : factors (0 : α) = 0 := dif_pos rfl
@[simp] lemma factors_one : factors (1 : α) = 0 :=
begin
rw ← multiset.rel_zero_right,
apply factors_unique irreducible_of_factor,
{ intros x hx,
exfalso,
apply multiset.not_mem_zero x hx },
{ simp [factors_prod one_ne_zero] },
apply_instance
end
@[simp] lemma factors_mul {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
factors (x * y) = factors x + factors y :=
begin
have h : (normalize : α → α) = associates.out ∘ associates.mk,
{ ext, rw [function.comp_apply, associates.out_mk], },
rw [← multiset.map_id' (factors (x * y)), ← multiset.map_id' (factors x),
← multiset.map_id' (factors y), ← multiset.map_congr normalize_factor,
← multiset.map_congr normalize_factor, ← multiset.map_congr normalize_factor,
← multiset.map_add, h, ← multiset.map_map associates.out, eq_comm,
← multiset.map_map associates.out],
refine congr rfl _,
apply multiset.map_mk_eq_map_mk_of_rel,
apply factors_unique,
{ intros x hx,
rcases multiset.mem_add.1 hx with hx | hx;
exact irreducible_of_factor x hx },
{ exact irreducible_of_factor },
{ rw multiset.prod_add,
exact associated.trans (associated_mul_mul (factors_prod hx) (factors_prod hy))
(factors_prod (mul_ne_zero hx hy)).symm, }
end
@[simp] lemma factors_pow {x : α} (n : ℕ) :
factors (x ^ n) = n • factors x :=
begin
induction n with n ih,
{ simp },
by_cases h0 : x = 0,
{ simp [h0, zero_pow n.succ_pos, smul_zero] },
rw [pow_succ, succ_nsmul, factors_mul h0 (pow_ne_zero _ h0), ih],
end
lemma dvd_iff_factors_le_factors {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
x ∣ y ↔ factors x ≤ factors y :=
begin
split,
{ rintro ⟨c, rfl⟩,
simp [hx, right_ne_zero_of_mul hy] },
{ rw [← dvd_iff_dvd_of_rel_left (factors_prod hx), ← dvd_iff_dvd_of_rel_right (factors_prod hy)],
apply multiset.prod_dvd_prod }
end
end unique_factorization_monoid
namespace unique_factorization_monoid
open_locale classical
open multiset associates
noncomputable theory
variables [comm_cancel_monoid_with_zero α] [nontrivial α] [unique_factorization_monoid α]
/-- Noncomputably defines a `normalization_monoid` structure on a `unique_factorization_monoid`. -/
protected def normalization_monoid : normalization_monoid α :=
normalization_monoid_of_monoid_hom_right_inverse {
to_fun := λ a : associates α, if a = 0 then 0 else ((factors a).map
(classical.some mk_surjective.has_right_inverse : associates α → α)).prod,
map_one' := by simp,
map_mul' := λ x y, by {
by_cases hx : x = 0, { simp [hx] },
by_cases hy : y = 0, { simp [hy] },
simp [hx, hy] } } begin
intro x,
dsimp,
by_cases hx : x = 0, { simp [hx] },
have h : associates.mk_monoid_hom ∘ (classical.some mk_surjective.has_right_inverse) =
(id : associates α → associates α),
{ ext x,
rw [function.comp_apply, mk_monoid_hom_apply,
classical.some_spec mk_surjective.has_right_inverse x],
refl },
rw [if_neg hx, ← mk_monoid_hom_apply, monoid_hom.map_multiset_prod, map_map, h, map_id,
← associated_iff_eq],
apply factors_prod hx
end
instance : inhabited (normalization_monoid α) := ⟨unique_factorization_monoid.normalization_monoid⟩
end unique_factorization_monoid
namespace unique_factorization_monoid
variables {R : Type*} [comm_cancel_monoid_with_zero R] [unique_factorization_monoid R]
lemma no_factors_of_no_prime_factors {a b : R} (ha : a ≠ 0)
(h : (∀ {d}, d ∣ a → d ∣ b → ¬ prime d)) : ∀ {d}, d ∣ a → d ∣ b → is_unit d :=
λ d, induction_on_prime d
(by { simp only [zero_dvd_iff], intros, contradiction })
(λ x hx _ _, hx)
(λ d q hp hq ih dvd_a dvd_b,
absurd hq (h (dvd_of_mul_right_dvd dvd_a) (dvd_of_mul_right_dvd dvd_b)))
/-- Euclid's lemma: if `a ∣ b * c` and `a` and `c` have no common prime factors, `a ∣ b`.
Compare `is_coprime.dvd_of_dvd_mul_left`. -/
lemma dvd_of_dvd_mul_left_of_no_prime_factors {a b c : R} (ha : a ≠ 0) :
(∀ {d}, d ∣ a → d ∣ c → ¬ prime d) → a ∣ b * c → a ∣ b :=
begin
refine induction_on_prime c _ _ _,
{ intro no_factors,
simp only [dvd_zero, mul_zero, forall_prop_of_true],
haveI := classical.prop_decidable,
exact is_unit_iff_forall_dvd.mp
(no_factors_of_no_prime_factors ha @no_factors (dvd_refl a) (dvd_zero a)) _ },
{ rintros _ ⟨x, rfl⟩ _ a_dvd_bx,
apply units.dvd_mul_right.mp a_dvd_bx },
{ intros c p hc hp ih no_factors a_dvd_bpc,
apply ih (λ q dvd_a dvd_c hq, no_factors dvd_a (dvd_mul_of_dvd_right dvd_c _) hq),
rw mul_left_comm at a_dvd_bpc,
refine or.resolve_left (left_dvd_or_dvd_right_of_dvd_prime_mul hp a_dvd_bpc) (λ h, _),
exact no_factors h (dvd_mul_right p c) hp }
end
/-- Euclid's lemma: if `a ∣ b * c` and `a` and `b` have no common prime factors, `a ∣ c`.
Compare `is_coprime.dvd_of_dvd_mul_right`. -/
lemma dvd_of_dvd_mul_right_of_no_prime_factors {a b c : R} (ha : a ≠ 0)
(no_factors : ∀ {d}, d ∣ a → d ∣ b → ¬ prime d) : a ∣ b * c → a ∣ c :=
by simpa [mul_comm b c] using dvd_of_dvd_mul_left_of_no_prime_factors ha @no_factors
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
lemma exists_reduced_factors : ∀ (a ≠ (0 : R)) b,
∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → is_unit d) ∧ c' * a' = a ∧ c' * b' = b :=
begin
haveI := classical.prop_decidable,
intros a,
refine induction_on_prime a _ _ _,
{ intros, contradiction },
{ intros a a_unit a_ne_zero b,
use [a, b, 1],
split,
{ intros p p_dvd_a _,
exact is_unit_of_dvd_unit p_dvd_a a_unit },
{ simp } },
{ intros a p a_ne_zero p_prime ih_a pa_ne_zero b,
by_cases p ∣ b,
{ rcases h with ⟨b, rfl⟩,
obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b,
refine ⟨a', b', p * c', @no_factor, _, _⟩,
{ rw [mul_assoc, ha'] },
{ rw [mul_assoc, hb'] } },
{ obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b,
refine ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩,
intros q q_dvd_pa' q_dvd_b',
cases left_dvd_or_dvd_right_of_dvd_prime_mul p_prime q_dvd_pa' with p_dvd_q q_dvd_a',
{ have : p ∣ c' * b' := dvd_mul_of_dvd_right (dvd_trans p_dvd_q q_dvd_b') _,
contradiction },
exact coprime q_dvd_a' q_dvd_b' } }
end
lemma exists_reduced_factors' (a b : R) (hb : b ≠ 0) :
∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → is_unit d) ∧ c' * a' = a ∧ c' * b' = b :=
let ⟨b', a', c', no_factor, hb, ha⟩ := exists_reduced_factors b hb a
in ⟨a', b', c', λ _ hpb hpa, no_factor hpa hpb, ha, hb⟩
section multiplicity
variables [nontrivial R] [normalization_monoid R] [decidable_eq R]
variables [decidable_rel (has_dvd.dvd : R → R → Prop)]
open multiplicity multiset
lemma le_multiplicity_iff_repeat_le_factors {a b : R} {n : ℕ} (ha : irreducible a) (hb : b ≠ 0) :
↑n ≤ multiplicity a b ↔ repeat (normalize a) n ≤ factors b :=
begin
rw ← pow_dvd_iff_le_multiplicity,
revert b,
induction n with n ih, { simp },
intros b hb,
split,
{ rintro ⟨c, rfl⟩,
rw [ne.def, pow_succ, mul_assoc, mul_eq_zero, decidable.not_or_iff_and_not] at hb,
rw [pow_succ, mul_assoc, factors_mul hb.1 hb.2, repeat_succ, factors_irreducible ha,
cons_add, cons_le_cons_iff, zero_add, ← ih hb.2],
apply dvd.intro _ rfl },
{ rw [multiset.le_iff_exists_add],
rintro ⟨u, hu⟩,
rw [← dvd_iff_dvd_of_rel_right (factors_prod hb), hu, prod_add, prod_repeat],
apply dvd.trans (dvd_of_associated (associated_pow_pow _)) (dvd.intro u.prod rfl),
apply associated_normalize }
end
lemma multiplicity_eq_count_factors {a b : R} (ha : irreducible a) (hb : b ≠ 0) :
multiplicity a b = (factors b).count (normalize a) :=
begin
apply le_antisymm,
{ apply enat.le_of_lt_add_one,
rw [← enat.coe_one, ← enat.coe_add, lt_iff_not_ge, ge_iff_le,
le_multiplicity_iff_repeat_le_factors ha hb, ← le_count_iff_repeat_le],
simp },
rw [le_multiplicity_iff_repeat_le_factors ha hb, ← le_count_iff_repeat_le],
end
end multiplicity
end unique_factorization_monoid
namespace associates
open unique_factorization_monoid associated multiset
variables [comm_cancel_monoid_with_zero α]
/-- `factor_set α` representation elements of unique factorization domain as multisets.
`multiset α` produced by `factors` are only unique up to associated elements, while the multisets in
`factor_set α` are unqiue by equality and restricted to irreducible elements. This gives us a
representation of each element as a unique multisets (or the added ⊤ for 0), which has a complete
lattice struture. Infimum is the greatest common divisor and supremum is the least common multiple.
-/
@[reducible] def {u} factor_set (α : Type u) [comm_cancel_monoid_with_zero α] :
Type u :=
with_top (multiset { a : associates α // irreducible a })
local attribute [instance] associated.setoid
theorem factor_set.coe_add {a b : multiset { a : associates α // irreducible a }} :
(↑(a + b) : factor_set α) = a + b :=
by norm_cast
lemma factor_set.sup_add_inf_eq_add [decidable_eq (associates α)] :
∀(a b : factor_set α), a ⊔ b + a ⊓ b = a + b
| none b := show ⊤ ⊔ b + ⊤ ⊓ b = ⊤ + b, by simp
| a none := show a ⊔ ⊤ + a ⊓ ⊤ = a + ⊤, by simp
| (some a) (some b) := show (a : factor_set α) ⊔ b + a ⊓ b = a + b, from
begin
rw [← with_top.coe_sup, ← with_top.coe_inf, ← with_top.coe_add, ← with_top.coe_add,
with_top.coe_eq_coe],
exact multiset.union_add_inter _ _
end
/-- Evaluates the product of a `factor_set` to be the product of the corresponding multiset,
or `0` if there is none. -/
def factor_set.prod : factor_set α → associates α
| none := 0
| (some s) := (s.map coe).prod
@[simp] theorem prod_top : (⊤ : factor_set α).prod = 0 := rfl
@[simp] theorem prod_coe {s : multiset { a : associates α // irreducible a }} :
(s : factor_set α).prod = (s.map coe).prod :=
rfl
@[simp] theorem prod_add : ∀(a b : factor_set α), (a + b).prod = a.prod * b.prod
| none b := show (⊤ + b).prod = (⊤:factor_set α).prod * b.prod, by simp
| a none := show (a + ⊤).prod = a.prod * (⊤:factor_set α).prod, by simp
| (some a) (some b) :=
show (↑a + ↑b:factor_set α).prod = (↑a:factor_set α).prod * (↑b:factor_set α).prod,
by rw [← factor_set.coe_add, prod_coe, prod_coe, prod_coe, multiset.map_add, multiset.prod_add]
theorem prod_mono : ∀{a b : factor_set α}, a ≤ b → a.prod ≤ b.prod
| none b h := have b = ⊤, from top_unique h, by rw [this, prod_top]; exact le_refl _
| a none h := show a.prod ≤ (⊤ : factor_set α).prod, by simp; exact le_top
| (some a) (some b) h := prod_le_prod $ multiset.map_le_map $ with_top.coe_le_coe.1 $ h
/-- `bcount p s` is the multiplicity of `p` in the factor_set `s` (with bundled `p`)-/
def bcount [decidable_eq (associates α)] (p : {a : associates α // irreducible a}) :
factor_set α → ℕ
| none := 0
| (some s) := s.count p
variables [dec_irr : Π (p : associates α), decidable (irreducible p)]
include dec_irr
/-- `count p s` is the multiplicity of the irreducible `p` in the factor_set `s`.
If `p` is not irreducible, `count p s` is defined to be `0`. -/
def count [decidable_eq (associates α)] (p : associates α) :
factor_set α → ℕ :=
if hp : irreducible p then bcount ⟨p, hp⟩ else 0
@[simp] lemma count_some [decidable_eq (associates α)] {p : associates α} (hp : irreducible p)
(s : multiset _) : count p (some s) = s.count ⟨p, hp⟩:=
by { dunfold count, split_ifs, refl }
@[simp] lemma count_zero [decidable_eq (associates α)] {p : associates α} (hp : irreducible p) :
count p (0 : factor_set α) = 0 :=
by { dunfold count, split_ifs, refl }
lemma count_reducible [decidable_eq (associates α)] {p : associates α} (hp : ¬ irreducible p) :
count p = 0 := dif_neg hp
omit dec_irr
/-- membership in a factor_set (bundled version) -/
def bfactor_set_mem : {a : associates α // irreducible a} → (factor_set α) → Prop
| _ ⊤ := true
| p (some l) := p ∈ l
include dec_irr
/-- `factor_set_mem p s` is the predicate that the irreducible `p` is a member of
`s : factor_set α`.
If `p` is not irreducible, `p` is not a member of any `factor_set`. -/
def factor_set_mem (p : associates α) (s : factor_set α) : Prop :=
if hp : irreducible p then bfactor_set_mem ⟨p, hp⟩ s else false
instance : has_mem (associates α) (factor_set α) := ⟨factor_set_mem⟩
@[simp] lemma factor_set_mem_eq_mem (p : associates α) (s : factor_set α) :
factor_set_mem p s = (p ∈ s) := rfl
lemma mem_factor_set_top {p : associates α} {hp : irreducible p} :
p ∈ (⊤ : factor_set α) :=
begin
dunfold has_mem.mem, dunfold factor_set_mem, split_ifs, exact trivial
end
lemma mem_factor_set_some {p : associates α} {hp : irreducible p}
{l : multiset {a : associates α // irreducible a }} :
p ∈ (l : factor_set α) ↔ subtype.mk p hp ∈ l :=
begin
dunfold has_mem.mem, dunfold factor_set_mem, split_ifs, refl
end
lemma reducible_not_mem_factor_set {p : associates α} (hp : ¬ irreducible p)
(s : factor_set α) : ¬ p ∈ s :=
λ (h : if hp : irreducible p then bfactor_set_mem ⟨p, hp⟩ s else false),
by rwa [dif_neg hp] at h
omit dec_irr
variable [unique_factorization_monoid α]
theorem unique' {p q : multiset (associates α)} :
(∀a∈p, irreducible a) → (∀a∈q, irreducible a) → p.prod = q.prod → p = q :=
begin
apply multiset.induction_on_multiset_quot p,
apply multiset.induction_on_multiset_quot q,
assume s t hs ht eq,
refine multiset.map_mk_eq_map_mk_of_rel (unique_factorization_monoid.factors_unique _ _ _),
{ exact assume a ha, ((irreducible_mk _).1 $ hs _ $ multiset.mem_map_of_mem _ ha) },
{ exact assume a ha, ((irreducible_mk _).1 $ ht _ $ multiset.mem_map_of_mem _ ha) },
simpa [quot_mk_eq_mk, prod_mk, mk_eq_mk_iff_associated] using eq
end
variables [nontrivial α] [normalization_monoid α]
private theorem forall_map_mk_factors_irreducible [decidable_eq α] (x : α) (hx : x ≠ 0) :
∀(a : associates α), a ∈ multiset.map associates.mk (factors x) → irreducible a :=
begin
assume a ha,
rcases multiset.mem_map.1 ha with ⟨c, hc, rfl⟩,
exact (irreducible_mk c).2 (irreducible_of_factor _ hc)
end
theorem prod_le_prod_iff_le {p q : multiset (associates α)}
(hp : ∀a∈p, irreducible a) (hq : ∀a∈q, irreducible a) :
p.prod ≤ q.prod ↔ p ≤ q :=
iff.intro
begin
classical,
rintros ⟨⟨c⟩, eqc⟩,
have : c ≠ 0, from (mt mk_eq_zero.2 $
assume (hc : quot.mk setoid.r c = 0),
have (0 : associates α) ∈ q, from prod_eq_zero_iff.1 $ eqc.symm ▸ hc.symm ▸ mul_zero _,
not_irreducible_zero ((irreducible_mk 0).1 $ hq _ this)),
have : associates.mk (factors c).prod = quot.mk setoid.r c,
from mk_eq_mk_iff_associated.2 (factors_prod this),
refine multiset.le_iff_exists_add.2 ⟨(factors c).map associates.mk, unique' hq _ _⟩,
{ assume x hx,
rcases multiset.mem_add.1 hx with h | h,
exact hp x h,
exact forall_map_mk_factors_irreducible c ‹c ≠ 0› _ h },
{ simp [multiset.prod_add, prod_mk, *] at * }
end
prod_le_prod
variables [dec : decidable_eq α] [dec' : decidable_eq (associates α)]
include dec
/-- This returns the multiset of irreducible factors as a `factor_set`,
a multiset of irreducible associates `with_top`. -/
noncomputable def factors' (a : α) :
multiset { a : associates α // irreducible a } :=
(factors a).pmap (λa ha, ⟨associates.mk a, (irreducible_mk _).2 ha⟩)
(irreducible_of_factor)
@[simp] theorem map_subtype_coe_factors' {a : α} :
(factors' a).map coe = (factors a).map associates.mk :=
by simp [factors', multiset.map_pmap, multiset.pmap_eq_map]
theorem factors'_cong {a b : α} (ha : a ≠ 0) (hb : b ≠ 0) (h : a ~ᵤ b) :
factors' a = factors' b :=
have multiset.rel associated (factors a) (factors b), from
factors_unique irreducible_of_factor irreducible_of_factor
((factors_prod ha).trans $ h.trans $ (factors_prod hb).symm),
by simpa [(multiset.map_eq_map subtype.coe_injective).symm, rel_associated_iff_map_eq_map.symm]
include dec'
/-- This returns the multiset of irreducible factors of an associate as a `factor_set`,
a multiset of irreducible associates `with_top`. -/
noncomputable def factors (a : associates α) :
factor_set α :=
begin
refine (if h : a = 0 then ⊤ else
quotient.hrec_on a (λx h, some $ factors' x) _ h),
assume a b hab,
apply function.hfunext,
{ have : a ~ᵤ 0 ↔ b ~ᵤ 0, from
iff.intro (assume ha0, hab.symm.trans ha0) (assume hb0, hab.trans hb0),
simp only [associated_zero_iff_eq_zero] at this,
simp only [quotient_mk_eq_mk, this, mk_eq_zero] },
exact (assume ha hb eq, heq_of_eq $ congr_arg some $ factors'_cong
(λ c, ha (mk_eq_zero.2 c)) (λ c, hb (mk_eq_zero.2 c)) hab)
end
@[simp] theorem factors_0 : (0 : associates α).factors = ⊤ :=
dif_pos rfl
@[simp] theorem factors_mk (a : α) (h : a ≠ 0) :
(associates.mk a).factors = factors' a :=
by { classical, apply dif_neg, apply (mt mk_eq_zero.1 h) }
theorem prod_factors : ∀(s : factor_set α), s.prod.factors = s
| none := by simp [factor_set.prod]; refl
| (some s) :=
begin
unfold factor_set.prod,
generalize eq_a : (s.map coe).prod = a,
rcases a with ⟨a⟩,
rw quot_mk_eq_mk at *,
have : (s.map (coe : _ → associates α)).prod ≠ 0, from assume ha,
let ⟨⟨a, ha⟩, h, eq⟩ := multiset.mem_map.1 (prod_eq_zero_iff.1 ha) in
have irreducible (0 : associates α), from eq ▸ ha,
not_irreducible_zero ((irreducible_mk _).1 this),
have ha : a ≠ 0, by simp [*] at *,
suffices : (unique_factorization_monoid.factors a).map associates.mk = s.map coe,
{ rw [factors_mk a ha],
apply congr_arg some _,
simpa [(multiset.map_eq_map subtype.coe_injective).symm] },
refine unique'
(forall_map_mk_factors_irreducible _ ha)
(assume a ha, let ⟨⟨x, hx⟩, ha, eq⟩ := multiset.mem_map.1 ha in eq ▸ hx)
_,
rw [prod_mk, eq_a, mk_eq_mk_iff_associated],
exact factors_prod ha
end
@[simp]
theorem factors_prod (a : associates α) : a.factors.prod = a :=
quotient.induction_on a $ assume a, decidable.by_cases
(assume : associates.mk a = 0, by simp [quotient_mk_eq_mk, this])
(assume : associates.mk a ≠ 0,
have a ≠ 0, by simp * at *,
by simp [this, quotient_mk_eq_mk, prod_mk, mk_eq_mk_iff_associated.2 (factors_prod this)])
theorem eq_of_factors_eq_factors {a b : associates α} (h : a.factors = b.factors) : a = b :=
have a.factors.prod = b.factors.prod, by rw h,
by rwa [factors_prod, factors_prod] at this
omit dec dec'
theorem eq_of_prod_eq_prod {a b : factor_set α} (h : a.prod = b.prod) : a = b :=
begin
classical,
have : a.prod.factors = b.prod.factors, by rw h,
rwa [prod_factors, prod_factors] at this
end
include dec dec'
@[simp] theorem factors_mul (a b : associates α) : (a * b).factors = a.factors + b.factors :=
eq_of_prod_eq_prod $ eq_of_factors_eq_factors $
by rw [prod_add, factors_prod, factors_prod, factors_prod]
theorem factors_mono : ∀{a b : associates α}, a ≤ b → a.factors ≤ b.factors
| s t ⟨d, rfl⟩ := by rw [factors_mul] ; exact le_add_of_nonneg_right bot_le
theorem factors_le {a b : associates α} : a.factors ≤ b.factors ↔ a ≤ b :=
iff.intro
(assume h, have a.factors.prod ≤ b.factors.prod, from prod_mono h,
by rwa [factors_prod, factors_prod] at this)
factors_mono
omit dec dec'
theorem prod_le {a b : factor_set α} : a.prod ≤ b.prod ↔ a ≤ b :=
begin
classical,
exact iff.intro
(assume h, have a.prod.factors ≤ b.prod.factors, from factors_mono h,
by rwa [prod_factors, prod_factors] at this)
prod_mono
end
include dec dec'
noncomputable instance : has_sup (associates α) := ⟨λa b, (a.factors ⊔ b.factors).prod⟩
noncomputable instance : has_inf (associates α) := ⟨λa b, (a.factors ⊓ b.factors).prod⟩
noncomputable instance : bounded_lattice (associates α) :=
{ sup := (⊔),
inf := (⊓),
sup_le :=
assume a b c hac hbc, factors_prod c ▸ prod_mono (sup_le (factors_mono hac) (factors_mono hbc)),
le_sup_left := assume a b,
le_trans (le_of_eq (factors_prod a).symm) $ prod_mono $ le_sup_left,
le_sup_right := assume a b,
le_trans (le_of_eq (factors_prod b).symm) $ prod_mono $ le_sup_right,
le_inf :=
assume a b c hac hbc, factors_prod a ▸ prod_mono (le_inf (factors_mono hac) (factors_mono hbc)),
inf_le_left := assume a b,
le_trans (prod_mono inf_le_left) (le_of_eq (factors_prod a)),
inf_le_right := assume a b,
le_trans (prod_mono inf_le_right) (le_of_eq (factors_prod b)),
.. associates.partial_order,
.. associates.order_top,
.. associates.order_bot }
lemma sup_mul_inf (a b : associates α) : (a ⊔ b) * (a ⊓ b) = a * b :=
show (a.factors ⊔ b.factors).prod * (a.factors ⊓ b.factors).prod = a * b,
begin
refine eq_of_factors_eq_factors _,
rw [← prod_add, prod_factors, factors_mul, factor_set.sup_add_inf_eq_add]
end
include dec_irr
lemma dvd_of_mem_factors {a p : associates α} {hp : irreducible p}
(hm : p ∈ factors a) : p ∣ a :=
begin
by_cases ha0 : a = 0, { rw ha0, exact dvd_zero p },
obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha0,
rw [← associates.factors_prod a],
rw [← ha', factors_mk a0 nza] at hm ⊢,
erw prod_coe,
apply multiset.dvd_prod, apply multiset.mem_map.mpr,
exact ⟨⟨p, hp⟩, mem_factor_set_some.mp hm, rfl⟩
end
omit dec'
lemma dvd_of_mem_factors' {a : α} {p : associates α} {hp : irreducible p} {hz : a ≠ 0}
(h_mem : subtype.mk p hp ∈ factors' a) : p ∣ associates.mk a :=
by { haveI := classical.dec_eq (associates α),
apply @dvd_of_mem_factors _ _ _ _ _ _ _ _ _ _ hp,
rw factors_mk _ hz,
apply mem_factor_set_some.2 h_mem }
omit dec_irr
lemma mem_factors'_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) (hd : p ∣ a) :
subtype.mk (associates.mk p) ((irreducible_mk _).2 hp) ∈ factors' a :=
begin
obtain ⟨q, hq, hpq⟩ := exists_mem_factors_of_dvd ha0 hp hd,
apply multiset.mem_pmap.mpr, use q, use hq,
exact subtype.eq (eq.symm (mk_eq_mk_iff_associated.mpr hpq))
end
include dec_irr
lemma mem_factors'_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) :
subtype.mk (associates.mk p) ((irreducible_mk _).2 hp) ∈ factors' a ↔ p ∣ a :=
begin
split,
{ rw ← mk_dvd_mk, apply dvd_of_mem_factors', apply ha0 },
{ apply mem_factors'_of_dvd ha0 }
end
include dec'
lemma mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) (hd : p ∣ a) :
(associates.mk p) ∈ factors (associates.mk a) :=
begin
rw factors_mk _ ha0, exact mem_factor_set_some.mpr (mem_factors'_of_dvd ha0 hp hd)
end
lemma mem_factors_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) :
(associates.mk p) ∈ factors (associates.mk a) ↔ p ∣ a :=
begin
split,
{ rw ← mk_dvd_mk, apply dvd_of_mem_factors, exact (irreducible_mk p).mpr hp },
{ apply mem_factors_of_dvd ha0 hp }
end
lemma exists_prime_dvd_of_not_inf_one {a b : α}
(ha : a ≠ 0) (hb : b ≠ 0) (h : (associates.mk a) ⊓ (associates.mk b) ≠ 1) :
∃ (p : α), prime p ∧ p ∣ a ∧ p ∣ b :=
begin
have hz : (factors (associates.mk a)) ⊓ (factors (associates.mk b)) ≠ 0,
{ contrapose! h with hf,
change ((factors (associates.mk a)) ⊓ (factors (associates.mk b))).prod = 1,
rw hf,
exact multiset.prod_zero },
rw [factors_mk a ha, factors_mk b hb, ← with_top.coe_inf] at hz,
obtain ⟨⟨p0, p0_irr⟩, p0_mem⟩ := multiset.exists_mem_of_ne_zero ((mt with_top.coe_eq_coe.mpr) hz),
rw multiset.inf_eq_inter at p0_mem,
obtain ⟨p, rfl⟩ : ∃ p, associates.mk p = p0 := quot.exists_rep p0,
refine ⟨p, _, _, _⟩,
{ rw [← irreducible_iff_prime, ← irreducible_mk],
exact p0_irr },
{ apply dvd_of_mk_le_mk,
apply dvd_of_mem_factors' (multiset.mem_inter.mp p0_mem).left,
apply ha, },
{ apply dvd_of_mk_le_mk,
apply dvd_of_mem_factors' (multiset.mem_inter.mp p0_mem).right,
apply hb }
end
theorem coprime_iff_inf_one {a b : α} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
(associates.mk a) ⊓ (associates.mk b) = 1 ↔ ∀ {d : α}, d ∣ a → d ∣ b → ¬ prime d :=
begin
split,
{ intros hg p ha hb hp,
refine ((associates.prime_mk _).mpr hp).not_unit (is_unit_of_dvd_one _ _),
rw ← hg,
exact le_inf (mk_le_mk_of_dvd ha) (mk_le_mk_of_dvd hb) },
{ contrapose,
intros hg hc,
obtain ⟨p, hp, hpa, hpb⟩ := exists_prime_dvd_of_not_inf_one ha0 hb0 hg,
exact hc hpa hpb hp }
end
omit dec_irr
include dec_irr
theorem prime_pow_dvd_iff_le {m p : associates α} (h₁ : m ≠ 0)
(h₂ : irreducible p) {k : ℕ} : p ^ k ≤ m ↔ k ≤ count p m.factors :=
begin
obtain ⟨a, nz, rfl⟩ := associates.exists_non_zero_rep h₁,
rw [factors_mk _ nz, ← with_top.some_eq_coe, count_some, multiset.le_count_iff_repeat_le,
← factors_le, factors_prime_pow h₂, factors_mk _ nz],
exact with_top.coe_le_coe
end
theorem le_of_count_ne_zero {m p : associates α} (h0 : m ≠ 0)
(hp : irreducible p) : count p m.factors ≠ 0 → p ≤ m :=
begin
rw [← pos_iff_ne_zero],
intro h,
rw [← pow_one p],
apply (prime_pow_dvd_iff_le h0 hp).2,
simpa only
end
theorem count_mul {a : associates α} (ha : a ≠ 0) {b : associates α} (hb : b ≠ 0)
{p : associates α} (hp : irreducible p) :
count p (factors (a * b)) = count p a.factors + count p b.factors :=
begin
obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha,
obtain ⟨b0, nzb, hb'⟩ := exists_non_zero_rep hb,
rw [factors_mul, ← ha', ← hb', factors_mk a0 nza, factors_mk b0 nzb, ← factor_set.coe_add,
← with_top.some_eq_coe, ← with_top.some_eq_coe, ← with_top.some_eq_coe, count_some hp,
multiset.count_add, count_some hp, count_some hp]
end
theorem count_of_coprime {a : associates α} (ha : a ≠ 0) {b : associates α} (hb : b ≠ 0)
(hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) {p : associates α} (hp : irreducible p) :
count p a.factors = 0 ∨ count p b.factors = 0 :=
begin
rw [or_iff_not_imp_left, ← ne.def],
intro hca,
contrapose! hab with hcb,
exact ⟨p, le_of_count_ne_zero ha hp hca, le_of_count_ne_zero hb hp hcb,
(irreducible_iff_prime.mp hp)⟩,
end
theorem count_mul_of_coprime {a : associates α} (ha : a ≠ 0) {b : associates α} (hb : b ≠ 0)
{p : associates α} (hp : irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) :
count p a.factors = 0 ∨ count p a.factors = count p (a * b).factors :=
begin
cases count_of_coprime ha hb hab hp with hz hb0, { tauto },
apply or.intro_right,
rw [count_mul ha hb hp, hb0, add_zero]
end
theorem count_mul_of_coprime' {a : associates α} (ha : a ≠ 0) {b : associates α} (hb : b ≠ 0)
{p : associates α} (hp : irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) :
count p (a * b).factors = count p a.factors
∨ count p (a * b).factors = count p b.factors :=
begin
rw [count_mul ha hb hp],
cases count_of_coprime ha hb hab hp with ha0 hb0,
{ apply or.intro_right, rw [ha0, zero_add] },
{ apply or.intro_left, rw [hb0, add_zero] }
end
theorem dvd_count_of_dvd_count_mul {a b : associates α} (ha : a ≠ 0) (hb : b ≠ 0)
{p : associates α} (hp : irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d)
{k : ℕ} (habk : k ∣ count p (a * b).factors) : k ∣ count p a.factors :=
begin
cases count_of_coprime ha hb hab hp with hz h,
{ rw hz, exact dvd_zero k },
{ rw [count_mul ha hb hp, h] at habk, exact habk }
end
omit dec_irr
@[simp] lemma factors_one : factors (1 : associates α) = 0 :=
begin
apply eq_of_prod_eq_prod,
rw associates.factors_prod,
exact multiset.prod_zero,
end
@[simp] theorem pow_factors {a : associates α} {k : ℕ} : (a ^ k).factors = k • a.factors :=
begin
induction k with n h,
{ rw [zero_nsmul, pow_zero], exact factors_one },
{ rw [pow_succ, succ_nsmul, factors_mul, h] }
end
include dec_irr
lemma count_pow {a : associates α} (ha : a ≠ 0) {p : associates α} (hp : irreducible p)
(k : ℕ) : count p (a ^ k).factors = k * count p a.factors :=
begin
induction k with n h,
{ rw [pow_zero, factors_one, zero_mul, count_zero hp] },
{ rw [pow_succ, count_mul ha (pow_ne_zero _ ha) hp, h, nat.succ_eq_add_one], ring }
end
theorem dvd_count_pow {a : associates α} (ha : a ≠ 0) {p : associates α} (hp : irreducible p)
(k : ℕ) : k ∣ count p (a ^ k).factors := by { rw count_pow ha hp, apply dvd_mul_right }
theorem is_pow_of_dvd_count {a : associates α} (ha : a ≠ 0) {k : ℕ}
(hk : ∀ (p : associates α) (hp : irreducible p), k ∣ count p a.factors) :
∃ (b : associates α), a = b ^ k :=
begin
obtain ⟨a0, hz, rfl⟩ := exists_non_zero_rep ha,
rw [factors_mk a0 hz] at hk,
have hk' : ∀ (p : {a : associates α // irreducible a}), k ∣ (factors' a0).count p,
{ intro p,
have pp : p = ⟨p.val, p.2⟩, { simp only [subtype.coe_eta, subtype.val_eq_coe] },
rw [pp, ← count_some p.2], exact hk p.val p.2 },
obtain ⟨u, hu⟩ := multiset.exists_smul_of_dvd_count _ hk',
use (u : factor_set α).prod,
apply eq_of_factors_eq_factors,
rw [pow_factors, prod_factors, factors_mk a0 hz, ← with_top.some_eq_coe, hu],
exact with_bot.coe_nsmul u k
end
omit dec
omit dec_irr
omit dec'
theorem eq_pow_of_mul_eq_pow {a b c : associates α} (ha : a ≠ 0) (hb : b ≠ 0)
(hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) {k : ℕ} (h : a * b = c ^ k) :
∃ (d : associates α), a = d ^ k :=
begin
classical,
by_cases hk0 : k = 0,
{ use 1,
rw [hk0, pow_zero] at h ⊢,
apply (mul_eq_one_iff.1 h).1 },
{ refine is_pow_of_dvd_count ha _,
intros p hp,
apply dvd_count_of_dvd_count_mul ha hb hp hab,
rw h,
apply dvd_count_pow _ hp,
rintros rfl,
rw zero_pow' _ hk0 at h,
cases mul_eq_zero.mp h; contradiction }
end
end associates
section
open associates unique_factorization_monoid
/-- `to_gcd_monoid` constructs a GCD monoid out of a normalization on a
unique factorization domain. -/
noncomputable def unique_factorization_monoid.to_gcd_monoid
(α : Type*) [comm_cancel_monoid_with_zero α] [nontrivial α] [unique_factorization_monoid α]
[normalization_monoid α] [decidable_eq (associates α)] [decidable_eq α] : gcd_monoid α :=
{ gcd := λa b, (associates.mk a ⊓ associates.mk b).out,
lcm := λa b, (associates.mk a ⊔ associates.mk b).out,
gcd_dvd_left := assume a b, (out_dvd_iff a (associates.mk a ⊓ associates.mk b)).2 $ inf_le_left,
gcd_dvd_right := assume a b, (out_dvd_iff b (associates.mk a ⊓ associates.mk b)).2 $ inf_le_right,
dvd_gcd := assume a b c hac hab, show a ∣ (associates.mk c ⊓ associates.mk b).out,
by rw [dvd_out_iff, le_inf_iff, mk_le_mk_iff_dvd_iff, mk_le_mk_iff_dvd_iff]; exact ⟨hac, hab⟩,
lcm_zero_left := assume a, show (⊤ ⊔ associates.mk a).out = 0, by simp,
lcm_zero_right := assume a, show (associates.mk a ⊔ ⊤).out = 0, by simp,
gcd_mul_lcm := assume a b,
show (associates.mk a ⊓ associates.mk b).out * (associates.mk a ⊔ associates.mk b).out =
normalize (a * b),
by rw [← out_mk, ← out_mul, mul_comm, sup_mul_inf]; refl,
normalize_gcd := assume a b, by convert normalize_out _,
.. ‹normalization_monoid α› }
end
|
(*
File: FOL_Base.thy
Author: Bohua Zhan
Theorems in logic needed to setup auto2 for FOL.
*)
theory FOL_Base
imports FOL
begin
section \<open>Declare type of sets\<close>
declare [[eta_contract = false]]
(* Type of sets *)
typedecl i
instance i :: "term" ..
(* Membership relation *)
axiomatization mem :: "[i, i] \<Rightarrow> o" (infixl "\<in>" 50)
(* Bounded quantifiers *)
definition Ball :: "[i, i \<Rightarrow> o] \<Rightarrow> o" where
"Ball(A, P) \<longleftrightarrow> (\<forall>x. x\<in>A \<longrightarrow> P(x))"
definition Bex :: "[i, i \<Rightarrow> o] \<Rightarrow> o" where
"Bex(A, P) \<longleftrightarrow> (\<exists>x. x\<in>A \<and> P(x))"
syntax
"_Ball" :: "[pttrn, i, o] \<Rightarrow> o" ("(3\<forall>_\<in>_./ _)" 10)
"_Bex" :: "[pttrn, i, o] \<Rightarrow> o" ("(3\<exists>_\<in>_./ _)" 10)
translations
"\<forall>x\<in>A. P" \<rightleftharpoons> "CONST Ball(A, \<lambda>x. P)"
"\<exists>x\<in>A. P" \<rightleftharpoons> "CONST Bex(A, \<lambda>x. P)"
abbreviation not_mem :: "[i, i] \<Rightarrow> o" (infixl "\<notin>" 50) where
"x \<notin> y \<equiv> \<not> (x \<in> y)"
section \<open>Theorems in logic used in auto2\<close>
theorem to_contra_form: "Trueprop (A) \<equiv> (\<not>A \<Longrightarrow> False)" by (rule equal_intr_rule) auto
theorem to_contra_form': "Trueprop (\<not>A) \<equiv> (A \<Longrightarrow> False)" by (rule equal_intr_rule) auto
theorem iffD: "A \<longleftrightarrow> B \<Longrightarrow> (A \<longrightarrow> B) \<and> (B \<longrightarrow> A)" by auto
theorem contra_triv: "\<not>A \<Longrightarrow> A \<Longrightarrow> False" by simp
theorem or_intro1: "\<not> (P \<or> Q) \<Longrightarrow> \<not> P" by simp
theorem or_intro2: "\<not> (P \<or> Q) \<Longrightarrow> \<not> Q" by simp
theorem or_cancel1: "\<not>Q \<Longrightarrow> (P \<or> Q) \<longleftrightarrow> P" by auto
theorem or_cancel2: "\<not>P \<Longrightarrow> (P \<or> Q) \<longleftrightarrow> Q" by auto
theorem not_imp: "\<not>(P \<longrightarrow> Q) \<longleftrightarrow> P \<and> \<not>Q" by auto
theorem exE': "(\<And>x. P(x) \<Longrightarrow> Q) \<Longrightarrow> \<exists>x. P(x) \<Longrightarrow> Q" by auto
theorem eq_True: "A \<Longrightarrow> A \<longleftrightarrow> True" by simp
theorem eq_True_inv: "A \<longleftrightarrow> True \<Longrightarrow> A" by simp
theorem disj_True1: "(True \<or> A) \<longleftrightarrow> True" by simp
theorem disj_True2: "(A \<or> True) \<longleftrightarrow> True" by simp
theorem ex_vardef: "\<exists>x. x = a" by simp
theorem nn_create: "A \<Longrightarrow> \<not>\<not>A" by auto
theorem all_trivial: "(\<forall>x. P) \<longleftrightarrow> P" by auto
theorem obj_sym: "Trueprop (t = s) \<equiv> Trueprop (s = t)" by (rule equal_intr_rule) auto
theorem obj_sym_iff: "Trueprop (t \<longleftrightarrow> s) \<equiv> Trueprop (s \<longleftrightarrow> t)" by (rule equal_intr_rule) auto
theorem to_meta_eq: "Trueprop (t = s) \<equiv> (t \<equiv> s)" by (rule equal_intr_rule) auto
theorem to_meta_eq_iff: "Trueprop (t \<longleftrightarrow> s) \<equiv> (t \<equiv> s)" by (rule equal_intr_rule) auto
theorem inv_backward: "P \<longleftrightarrow> Q \<Longrightarrow> \<not>P \<Longrightarrow> \<not>Q" by simp
theorem backward_conv: "(A \<Longrightarrow> B) \<equiv> (\<not>B \<Longrightarrow> \<not>A)" by (rule equal_intr_rule) auto
theorem backward1_conv: "(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (\<not>C \<Longrightarrow> B \<Longrightarrow> \<not>A)" by (rule equal_intr_rule) auto
theorem backward2_conv: "(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (\<not>C \<Longrightarrow> A \<Longrightarrow> \<not>B)" by (rule equal_intr_rule) auto
theorem resolve_conv: "(A \<Longrightarrow> B) \<equiv> (\<not>B \<Longrightarrow> A \<Longrightarrow> False)" by (rule equal_intr_rule) auto
(* Quantifiers: swapping out of ALL or EX *)
theorem swap_ex_conj: "(P \<and> (\<exists>x. Q(x))) \<longleftrightarrow> (\<exists>x. P \<and> Q(x))" by auto
theorem swap_all_disj: "(P \<or> (\<forall>x. Q(x))) \<longleftrightarrow> (\<forall>x. P \<or> Q(x))" by auto
(* Use these instead of original versions to keep names in abstractions. *)
theorem Bex_def': "(\<exists>x\<in>S. P(x)) \<longleftrightarrow> (\<exists>x. x \<in> S \<and> P(x))" using Bex_def by auto
theorem Ball_def': "(\<forall>x\<in>S. P(x)) \<longleftrightarrow> (\<forall>x. x \<in> S \<longrightarrow> P(x))" using Ball_def by auto
(* Taking conjunction of assumptions *)
theorem atomize_conjL: "(A \<Longrightarrow> B \<Longrightarrow> PROP C) \<equiv> (A \<and> B \<Longrightarrow> PROP C)"
proof
assume 1: "A \<Longrightarrow> B \<Longrightarrow> PROP C" and 2: "A \<and> B"
have 3: "A" using 2 by auto
have 4: "B" using 2 by auto
show "PROP C" using 1[OF 3 4] by assumption
next
assume 1: "A \<and> B \<Longrightarrow> PROP C" and 2: A and 3: B
have 4: "A \<and> B" using 2 3 by auto
show "PROP C" using 1[OF 4] by assumption
qed
(* Other rules *)
theorem imp_conv_disj: "(P \<longrightarrow> Q) \<longleftrightarrow> (\<not>P \<or> Q)" by auto
theorem not_ex: "\<not>(\<exists>x. P(x)) \<longleftrightarrow> (\<forall>x. \<not>P(x))" by simp
theorem not_all: "\<not>(\<forall>x. P(x)) \<longleftrightarrow> (\<exists>x. \<not>P(x))" by simp
(* AC for conj and disj *)
theorem conj_assoc: "(P \<and> Q) \<and> R \<longleftrightarrow> P \<and> Q \<and> R" by simp
theorem disj_assoc: "(P \<or> Q) \<or> R \<longleftrightarrow> P \<or> Q \<or> R" by simp
end
|
%FILLPOLY Fills the area bounded by one or more polygons
%
% img = cv.fillPoly(img, pts)
% [...] = cv.fillPoly(..., 'OptionName', optionValue, ...)
%
% ## Input
% * __img__ Image.
% * __pts__ Array of polygons where each polygon is represented as an array
% of points. A cell array of cell arrays of 2-element vectors, in the form:
% `{{[x,y], [x,y], ...}, ...}`, or a cell array of Nx2 matrices.
%
% ## Output
% * __img__ Output image, same size and type as input `img`.
%
% ## Options
% * __Color__ 3-element floating-point vector specifying polygon color.
% default zeros
% * __LineType__ Type of the polygon boundaries. One of:
% * __4__ 4-connected line
% * __8__ 8-connected line (default)
% * __AA__ anti-aliased line
% * __Shift__ Number of fractional bits in the vertex coordinates. default 0
% * __Offset__ Optional offset of all points of the contours. default `[0,0]`
%
% The function cv.fillPoly fills an area bounded by several polygonal
% contours. The function can fill complex areas, for example, areas with
% holes, contours with self-intersections (some of thier parts), and so forth.
%
% See also: cv.line, cv.fillConvexPoly, roipoly, poly2mask
%
|
State Before: α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: have xεpos : 0 < ‖x‖ / ε := div_pos ((Ne.symm hx).le_iff_lt.1 (norm_nonneg x)) εpos State Before: α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: rcases exists_mem_Ico_zpow xεpos hc with ⟨n, hn⟩ State Before: case intro
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: have cpos : 0 < ‖c‖ := lt_trans (zero_lt_one : (0 : ℝ) < 1) hc State Before: case intro
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: have cnpos : 0 < ‖c ^ (n + 1)‖ := by
rw [norm_zpow]
exact lt_trans xεpos hn.2 State Before: case intro
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ∃ n, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ ε / ‖c‖ ≤ ‖c ^ n • x‖ ∧ ‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_1
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ c ^ (-(n + 1)) ≠ 0
case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: refine' ⟨-(n + 1), _, _, _, _⟩ State Before: case intro.refine'_1
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ c ^ (-(n + 1)) ≠ 0
case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_1
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ c ^ (-(n + 1)) ≠ 0
case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: show c ^ (-(n + 1)) ≠ 0 State Before: case intro.refine'_1
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ c ^ (-(n + 1)) ≠ 0
case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: exact zpow_ne_zero _ (norm_pos_iff.1 cpos) State Before: case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε
case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: show ‖c ^ (-(n + 1)) • x‖ < ε State Before: case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖
case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: show ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖ State Before: case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ Tactic: show ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State Before: α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
⊢ 0 < ‖c ^ (n + 1)‖ State After: α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
⊢ 0 < ‖c‖ ^ (n + 1) Tactic: rw [norm_zpow] State Before: α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
⊢ 0 < ‖c‖ ^ (n + 1) State After: no goals Tactic: exact lt_trans xεpos hn.2 State Before: case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1)) • x‖ < ε State After: case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖x‖ < ‖c‖ ^ (n + 1) * ε Tactic: rw [norm_smul, zpow_neg, norm_inv, ← _root_.div_eq_inv_mul, div_lt_iff cnpos, mul_comm,
norm_zpow] State Before: case intro.refine'_2
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖x‖ < ‖c‖ ^ (n + 1) * ε State After: no goals Tactic: exact (div_lt_iff εpos).1 hn.2 State Before: case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ε / ‖c‖ ≤ ‖c ^ (-(n + 1)) • x‖ State After: case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c‖ ^ n * ε ≤ ‖x‖ Tactic: rw [zpow_neg, div_le_iff cpos, norm_smul, norm_inv, norm_zpow, zpow_add₀ (ne_of_gt cpos),
zpow_one, mul_inv_rev, mul_comm, ← mul_assoc, ← mul_assoc, mul_inv_cancel (ne_of_gt cpos),
one_mul, ← _root_.div_eq_inv_mul, le_div_iff (zpow_pos_of_pos cpos _), mul_comm] State Before: case intro.refine'_3
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c‖ ^ n * ε ≤ ‖x‖ State After: no goals Tactic: exact (le_div_iff εpos).1 hn.1 State Before: case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c ^ (-(n + 1))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖ State After: case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c‖ ^ n * ‖c‖ ≤ ‖x‖ / ε * ‖c‖ Tactic: rw [zpow_neg, norm_inv, inv_inv, norm_zpow, zpow_add₀ cpos.ne', zpow_one, mul_right_comm, ←
_root_.div_eq_inv_mul] State Before: case intro.refine'_4
α : Type u_1
β : Type ?u.220958
γ : Type ?u.220961
ι : Type ?u.220964
inst✝⁵ : NormedField α
inst✝⁴ : SeminormedAddCommGroup β
E : Type u_2
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace α E
F : Type ?u.220995
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace α F
c : α
hc : 1 < ‖c‖
ε : ℝ
εpos : 0 < ε
x : E
hx : ‖x‖ ≠ 0
xεpos : 0 < ‖x‖ / ε
n : ℤ
hn : ‖x‖ / ε ∈ Ico (‖c‖ ^ n) (‖c‖ ^ (n + 1))
cpos : 0 < ‖c‖
cnpos : 0 < ‖c ^ (n + 1)‖
⊢ ‖c‖ ^ n * ‖c‖ ≤ ‖x‖ / ε * ‖c‖ State After: no goals Tactic: exact mul_le_mul_of_nonneg_right hn.1 (norm_nonneg _) |
The Crab with the Golden Claws ( French : Le <unk> aux pinces d 'or ) is the ninth volume of The Adventures of Tintin , the comics series by Belgian cartoonist Hergé . The story was serialised weekly in Le Soir Jeunesse , the children 's supplement to Le Soir , Belgium 's leading francophone newspaper , from October 1940 to October 1941 amidst the German occupation of Belgium during World War II . Partway through serialisation , Le Soir Jeunesse was cancelled and the story began to be serialised daily in the pages of Le Soir . The story tells of young Belgian reporter Tintin and his dog Snowy , who travel to Morocco to pursue a gang of international opium smugglers .
|
/-
Copyright (c) 2021 Alena Gusakov, Bhavik Mehta, Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alena Gusakov, Bhavik Mehta, Kyle Miller
-/
import data.fintype.basic
import data.set.finite
/-!
# Hall's Marriage Theorem for finite index types
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This module proves the basic form of Hall's theorem.
In constrast to the theorem described in `combinatorics.hall.basic`, this
version requires that the indexed family `t : ι → finset α` have `ι` be finite.
The `combinatorics.hall.basic` module applies a compactness argument to this version
to remove the `finite` constraint on `ι`.
The modules are split like this since the generalized statement
depends on the topology and category theory libraries, but the finite
case in this module has few dependencies.
A description of this formalization is in [Gusakov2021].
## Main statements
* `finset.all_card_le_bUnion_card_iff_exists_injective'` is Hall's theorem with
a finite index set. This is elsewhere generalized to
`finset.all_card_le_bUnion_card_iff_exists_injective`.
## Tags
Hall's Marriage Theorem, indexed families
-/
open finset
universes u v
namespace hall_marriage_theorem
variables {ι : Type u} {α : Type v} [decidable_eq α] {t : ι → finset α}
section fintype
variables [fintype ι]
lemma hall_cond_of_erase {x : ι} (a : α)
(ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card)
(s' : finset {x' : ι | x' ≠ x}) :
s'.card ≤ (s'.bUnion (λ x', (t x').erase a)).card :=
begin
haveI := classical.dec_eq ι,
specialize ha (s'.image coe),
rw [nonempty.image_iff, finset.card_image_of_injective s' subtype.coe_injective] at ha,
by_cases he : s'.nonempty,
{ have ha' : s'.card < (s'.bUnion (λ x, t x)).card,
{ convert ha he (λ h, by simpa [←h] using mem_univ x) using 2,
ext x,
simp only [mem_image, mem_bUnion, exists_prop, set_coe.exists,
exists_and_distrib_right, exists_eq_right, subtype.coe_mk], },
rw ←erase_bUnion,
by_cases hb : a ∈ s'.bUnion (λ x, t x),
{ rw card_erase_of_mem hb,
exact nat.le_pred_of_lt ha' },
{ rw erase_eq_of_not_mem hb,
exact nat.le_of_lt ha' }, },
{ rw [nonempty_iff_ne_empty, not_not] at he,
subst s',
simp },
end
/--
First case of the inductive step: assuming that
`∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card`
and that the statement of **Hall's Marriage Theorem** is true for all
`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.
-/
lemma hall_hard_inductive_step_A {n : ℕ} (hn : fintype.card ι = n + 1)
(ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)
(ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),
by exactI fintype.card ι' ≤ n →
(∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →
∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)
(ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card) :
∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=
begin
haveI : nonempty ι := fintype.card_pos_iff.mp (hn.symm ▸ nat.succ_pos _),
haveI := classical.dec_eq ι,
/- Choose an arbitrary element `x : ι` and `y : t x`. -/
let x := classical.arbitrary ι,
have tx_ne : (t x).nonempty,
{ rw ←finset.card_pos,
calc 0 < 1 : nat.one_pos
... ≤ (finset.bUnion {x} t).card : ht {x}
... = (t x).card : by rw finset.singleton_bUnion, },
choose y hy using tx_ne,
/- Restrict to everything except `x` and `y`. -/
let ι' := {x' : ι | x' ≠ x},
let t' : ι' → finset α := λ x', (t x').erase y,
have card_ι' : fintype.card ι' = n :=
calc fintype.card ι' = fintype.card ι - 1 : set.card_ne_eq _
... = n : by { rw [hn, nat.add_succ_sub_one, add_zero], },
rcases ih t' card_ι'.le (hall_cond_of_erase y ha) with ⟨f', hfinj, hfr⟩,
/- Extend the resulting function. -/
refine ⟨λ z, if h : z = x then y else f' ⟨z, h⟩, _, _⟩,
{ rintro z₁ z₂,
have key : ∀ {x}, y ≠ f' x,
{ intros x h,
simpa [←h] using hfr x, },
by_cases h₁ : z₁ = x; by_cases h₂ : z₂ = x; simp [h₁, h₂, hfinj.eq_iff, key, key.symm], },
{ intro z,
split_ifs with hz,
{ rwa hz },
{ specialize hfr ⟨z, hz⟩,
rw mem_erase at hfr,
exact hfr.2, }, },
end
lemma hall_cond_of_restrict {ι : Type u} {t : ι → finset α} {s : finset ι}
(ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)
(s' : finset (s : set ι)) :
s'.card ≤ (s'.bUnion (λ a', t a')).card :=
begin
classical,
rw ← card_image_of_injective s' subtype.coe_injective,
convert ht (s'.image coe) using 1,
apply congr_arg,
ext y,
simp,
end
lemma hall_cond_of_compl {ι : Type u} {t : ι → finset α} {s : finset ι}
(hus : s.card = (s.bUnion t).card)
(ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)
(s' : finset (sᶜ : set ι)) :
s'.card ≤ (s'.bUnion (λ x', t x' \ s.bUnion t)).card :=
begin
haveI := classical.dec_eq ι,
have disj : disjoint s (s'.image coe),
{ simp only [disjoint_left, not_exists, mem_image, exists_prop, set_coe.exists,
exists_and_distrib_right, exists_eq_right, subtype.coe_mk],
intros x hx hc h,
exact absurd hx hc, },
have : s'.card = (s ∪ s'.image coe).card - s.card,
{ simp [disj, card_image_of_injective _ subtype.coe_injective], },
rw [this, hus],
refine (tsub_le_tsub_right (ht _) _).trans _,
rw ← card_sdiff,
{ refine (card_le_of_subset _).trans le_rfl,
intros t,
simp only [mem_bUnion, mem_sdiff, not_exists, mem_image, and_imp, mem_union,
exists_and_distrib_right, exists_imp_distrib],
rintro x (hx | ⟨x', hx', rfl⟩) rat hs,
{ exact (hs x hx rat).elim },
{ exact ⟨⟨x', hx', rat⟩, hs⟩, } },
{ apply bUnion_subset_bUnion_of_subset_left,
apply subset_union_left }
end
/--
Second case of the inductive step: assuming that
`∃ (s : finset ι), s ≠ univ → s.card = (s.bUnion t).card`
and that the statement of **Hall's Marriage Theorem** is true for all
`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.
-/
lemma hall_hard_inductive_step_B {n : ℕ} (hn : fintype.card ι = n + 1)
(ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)
(ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),
by exactI fintype.card ι' ≤ n →
(∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →
∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)
(s : finset ι)
(hs : s.nonempty)
(hns : s ≠ univ)
(hus : s.card = (s.bUnion t).card) :
∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=
begin
haveI := classical.dec_eq ι,
/- Restrict to `s` -/
let t' : s → finset α := λ x', t x',
rw nat.add_one at hn,
have card_ι'_le : fintype.card s ≤ n,
{ apply nat.le_of_lt_succ,
calc fintype.card s = s.card : fintype.card_coe _
... < fintype.card ι : (card_lt_iff_ne_univ _).mpr hns
... = n.succ : hn },
rcases ih t' card_ι'_le (hall_cond_of_restrict ht) with ⟨f', hf', hsf'⟩,
/- Restrict to `sᶜ` in the domain and `(s.bUnion t)ᶜ` in the codomain. -/
set ι'' := (s : set ι)ᶜ with ι''_def,
let t'' : ι'' → finset α := λ a'', t a'' \ s.bUnion t,
have card_ι''_le : fintype.card ι'' ≤ n,
{ simp_rw [← nat.lt_succ_iff, ← hn, ι'', ← finset.coe_compl, coe_sort_coe],
rwa [fintype.card_coe, card_compl_lt_iff_nonempty] },
rcases ih t'' card_ι''_le (hall_cond_of_compl hus ht) with ⟨f'', hf'', hsf''⟩,
/- Put them together -/
have f'_mem_bUnion : ∀ {x'} (hx' : x' ∈ s), f' ⟨x', hx'⟩ ∈ s.bUnion t,
{ intros x' hx',
rw mem_bUnion,
exact ⟨x', hx', hsf' _⟩, },
have f''_not_mem_bUnion : ∀ {x''} (hx'' : ¬ x'' ∈ s), ¬ f'' ⟨x'', hx''⟩ ∈ s.bUnion t,
{ intros x'' hx'',
have h := hsf'' ⟨x'', hx''⟩,
rw mem_sdiff at h,
exact h.2, },
have im_disj : ∀ (x' x'' : ι) (hx' : x' ∈ s) (hx'' : ¬x'' ∈ s), f' ⟨x', hx'⟩ ≠ f'' ⟨x'', hx''⟩,
{ intros _ _ hx' hx'' h,
apply f''_not_mem_bUnion hx'',
rw ←h,
apply f'_mem_bUnion, },
refine ⟨λ x, if h : x ∈ s then f' ⟨x, h⟩ else f'' ⟨x, h⟩, _, _⟩,
{ exact hf'.dite _ hf'' im_disj },
{ intro x,
split_ifs with h,
{ exact hsf' ⟨x, h⟩ },
{ exact sdiff_subset _ _ (hsf'' ⟨x, h⟩) } }
end
end fintype
variables [finite ι]
/--
Here we combine the two inductive steps into a full strong induction proof,
completing the proof the harder direction of **Hall's Marriage Theorem**.
-/
theorem hall_hard_inductive
(ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card) :
∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=
begin
casesI nonempty_fintype ι,
unfreezingI
{ induction hn : fintype.card ι using nat.strong_induction_on with n ih generalizing ι },
rcases n with _|_,
{ rw fintype.card_eq_zero_iff at hn,
exactI ⟨is_empty_elim, is_empty_elim, is_empty_elim⟩, },
{ have ih' : ∀ (ι' : Type u) [fintype ι'] (t' : ι' → finset α),
by exactI fintype.card ι' ≤ n →
(∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →
∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x,
{ introsI ι' _ _ hι' ht',
exact ih _ (nat.lt_succ_of_le hι') ht' _ rfl },
by_cases h : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card,
{ exact hall_hard_inductive_step_A hn ht ih' h, },
{ push_neg at h,
rcases h with ⟨s, sne, snu, sle⟩,
exact hall_hard_inductive_step_B hn ht ih' s sne snu (nat.le_antisymm (ht _) sle), } },
end
end hall_marriage_theorem
/--
This is the version of **Hall's Marriage Theorem** in terms of indexed
families of finite sets `t : ι → finset α` with `ι` finite.
It states that there is a set of distinct representatives if and only
if every union of `k` of the sets has at least `k` elements.
See `finset.all_card_le_bUnion_card_iff_exists_injective` for a version
where the `finite ι` constraint is removed.
-/
theorem finset.all_card_le_bUnion_card_iff_exists_injective'
{ι α : Type*} [finite ι] [decidable_eq α] (t : ι → finset α) :
(∀ (s : finset ι), s.card ≤ (s.bUnion t).card) ↔
(∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x) :=
begin
split,
{ exact hall_marriage_theorem.hall_hard_inductive },
{ rintro ⟨f, hf₁, hf₂⟩ s,
rw ←card_image_of_injective s hf₁,
apply card_le_of_subset,
intro _,
rw [mem_image, mem_bUnion],
rintros ⟨x, hx, rfl⟩,
exact ⟨x, hx, hf₂ x⟩, },
end
|
lemma sigma_algebra_sigma_sets: "a \<subseteq> Pow \<Omega> \<Longrightarrow> sigma_algebra \<Omega> (sigma_sets \<Omega> a)" |
# 2021-09-15 Advection and stability
## Last time
* Variable coefficients
* Conservative/divergence form vs non-divergence forms
* Verification with discontinuities
## Today
* Advection and boundary layers
* The (cell) Péclet number and oscillations
```julia
using Plots
using LinearAlgebra
function vander(x, k=nothing)
if k === nothing
k = length(x)
end
V = ones(length(x), k)
for j = 2:k
V[:, j] = V[:, j-1] .* x
end
V
end
function fdstencil(source, target, k)
"kth derivative stencil from source to target"
x = source .- target
V = vander(x)
rhs = zero(x)'
rhs[k+1] = factorial(k)
rhs / V
end
function poisson(x, spoints, forcing; left=(0, zero), right=(0, zero))
n = length(x)
L = zeros(n, n)
rhs = forcing.(x)
for i in 2:n-1
jleft = min(max(1, i-spoints÷2), n-spoints+1)
js = jleft : jleft + spoints - 1
L[i, js] = -fdstencil(x[js], x[i], 2)
end
L[1,1:spoints] = fdstencil(x[1:spoints], x[1], left[1])
L[n,n-spoints+1:n] = fdstencil(x[n-spoints+1:n], x[n], right[1])
rhs[1] = left[2](x[1])
rhs[n] = right[2](x[n])
L, rhs
end
CosRange(a, b, n) = (a + b)/2 .+ (b - a)/2 * cos.(LinRange(-pi, 0, n))
function vander_chebyshev(x, n=nothing)
if isnothing(n)
n = length(x) # Square by default
end
m = length(x)
T = ones(m, n)
if n > 1
T[:, 2] = x
end
for k in 3:n
T[:, k] = 2 * x .* T[:,k-1] - T[:, k-2]
end
T
end
function chebdiff(x, n=nothing)
T = vander_chebyshev(x, n)
m, n = size(T)
dT = zero(T)
dT[:,2:3] = [one.(x) 4*x]
for j in 3:n-1
dT[:,j+1] = j * (2 * T[:,j] + dT[:,j-1] / (j-2))
end
ddT = zero(T)
ddT[:,3] .= 4
for j in 3:n-1
ddT[:,j+1] = j * (2 * dT[:,j] + ddT[:,j-1] / (j-2))
end
T, dT, ddT
end
function poisson_cheb(n, rhsfunc, leftbc=(0, zero), rightbc=(0, zero))
x = CosRange(-1, 1, n)
T, dT, ddT = chebdiff(x)
dT /= T
ddT /= T
T /= T
L = -ddT
rhs = rhsfunc.(x)
for (index, deriv, func) in
[(1, leftbc...), (n, rightbc...)]
L[index,:] = (T, dT)[deriv+1][index,:]
rhs[index] = func(x[index])
end
x, L, rhs
end
```
┌ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]
└ @ Base loading.jl:1342
poisson_cheb (generic function with 3 methods)
# Variable coefficients
* Heat conduction: steel, brick, wood, foam
* Electrical conductivity: copper, rubber, air
* Elasticity: steel, rubber, concrete, rock
* Linearization of nonlinear materials
* ketchup, glacier ice, rocks (mantle/lithosphere)
```julia
kappa_step(x) = .1 + .9 * (x > 0)
kappa_tanh(x, epsilon=.1) = .55 + .45 * tanh(x / epsilon)
plot([kappa_step, kappa_tanh], xlims=(-1, 1), ylims=(0, 1), label="κ")
```
┌ Info: Precompiling GR_jll [d2c73de3-f751-5644-a686-071e5b155ba9]
└ @ Base loading.jl:1342
# A naive finite difference solver
| Conservative (divergence) form | Non-divergence form |
| ------------------------------ | ------------------- |
| $-(\kappa u_x)_x = 0$ | $-\kappa u_{xx} - \kappa_x u_x = 0$ |
```julia
function poisson_nondivergence(x, spoints, kappa, forcing; leftbc=(0, zero), rightbc=(0, zero))
n = length(x)
L = zeros(n, n)
rhs = forcing.(x)
kappax = kappa.(x)
for i in 2:n-1
jleft = min(max(1, i-spoints÷2), n-spoints+1)
js = jleft : jleft + spoints - 1
kappa_x = fdstencil(x[js], x[i], 1) * kappax[js]
L[i, js] = -fdstencil(x[js], x[i], 2) .* kappax[i] - fdstencil(x[js], x[i], 1) * kappa_x
end
L[1,1:spoints] = fdstencil(x[1:spoints], x[1], leftbc[1])
if leftbc[1] == 1
L[1, :] *= kappax[1]
end
L[n,n-spoints+1:n] = fdstencil(x[n-spoints+1:n], x[n], rightbc[1])
if rightbc[1] == 1
L[n, :] *= kappax[n]
end
rhs[1] = leftbc[2](x[1])
rhs[n] = rightbc[2](x[n])
L, rhs
end
```
poisson_nondivergence (generic function with 1 method)
# Discretizing in conservative form
| Conservative (divergence) form | Non-divergence form |
| ------------------------------ | ------------------- |
| $-(\kappa u_x)_x = 0$ | $-\kappa u_{xx} - \kappa_x u_x = 0$ |
```julia
function poisson_conservative(n, kappa, forcing; leftbc=(0, zero), rightbc=(0, zero))
x = LinRange(-1, 1, n)
xstag = (x[1:end-1] + x[2:end]) / 2
L = zeros(n, n)
rhs = forcing.(x)
kappa_stag = kappa.(xstag)
for i in 2:n-1
flux_L = kappa_stag[i-1] * fdstencil(x[i-1:i], xstag[i-1], 1)
flux_R = kappa_stag[i] * fdstencil(x[i:i+1], xstag[i], 1)
js = i-1:i+1
weights = -fdstencil(xstag[i-1:i], x[i], 1)
L[i, i-1:i+1] = weights[1] * [flux_L..., 0] + weights[2] * [0, flux_R...]
end
if leftbc[1] == 0
L[1, 1] = 1
rhs[1] = leftbc[2](x[1])
rhs[2:end] -= L[2:end, 1] * rhs[1]
L[2:end, 1] .= 0
end
if rightbc[1] == 0
L[end,end] = 1
rhs[end] = rightbc[2](x[end])
rhs[1:end-1] -= L[1:end-1,end] * rhs[end]
L[1:end-1,end] .= 0
end
x, L, rhs
end
```
poisson_conservative (generic function with 1 method)
# Compare conservative vs non-divergence forms
```julia
forcing = zero # one
kappa_tanh(x, epsilon=.01) = .55 + .45 * tanh(x / epsilon)
x, L, rhs = poisson_conservative(20, kappa_tanh,
forcing, leftbc=(0, zero), rightbc=(0, one))
u = L \ rhs
plot(x, u, marker=:auto, legend=:bottomright)
```
```julia
x = LinRange(-1, 1, 20)
L, rhs = poisson_nondivergence(x, 3, kappa_tanh,
forcing, leftbc=(0, zero), rightbc=(0, one))
u = L \ rhs
plot(x, u, marker=:auto, legend=:bottomright)
```
# Continuity of flux
```julia
forcing = zero
x, L, rhs = poisson_conservative(20, kappa_step,
forcing, leftbc=(0, zero), rightbc=(0, one))
u = L \ rhs
plot(x, u, marker=:auto, legend=:bottomright)
```
```julia
xstag = (x[1:end-1] + x[2:end]) ./ 2
du = (u[1:end-1] - u[2:end]) ./ diff(x)
plot(xstag, [du .* kappa_step.(xstag)], marker=:auto, ylims=[-1, 1])
```
# Manufactured solutions with discontinuous coefficients
* We need to be able to evaluate derivatives of the flux $-\kappa u_x$.
* A physically-realizable solution would have continuous flux, but we we'd have to be making a physical solution to have that in verification.
* Idea: replace the discontinuous function with a continuous one with a rapid transition.
```julia
kappa_tanh(x, epsilon=.1) = .55 + .45 * tanh(x / epsilon)
d_kappa_tanh(x, epsilon=.1) = .45/epsilon * cosh(x/epsilon)^-2
plot([kappa_tanh])
```
# Solving with the smoothed step $\kappa$
```julia
kappa_tanh(x, epsilon=.01) = .55 + .45 * tanh(x / epsilon)
d_kappa_tanh(x, epsilon=.01) = .45/epsilon * cosh(x/epsilon)^-2
manufactured(x) = tanh(2*x)
d_manufactured(x) = 2*cosh(2*x).^-2
flux_manufactured_kappa_tanh(x) = kappa_tanh(x) * d_manufactured(x)
function forcing_manufactured_kappa_tanh(x)
8 * tanh(2x) / cosh(2x)^2 * kappa_tanh(x) -
d_kappa_tanh(x) * d_manufactured(x)
end
x, L, rhs = poisson_conservative(200, kappa_tanh,
forcing_manufactured_kappa_tanh,
leftbc=(0, manufactured), rightbc=(0, manufactured))
u = L \ rhs
plot(x, u, marker=:auto, legend=:bottomright, title="Error $(norm(u - manufactured.(x), Inf))")
plot!([manufactured flux_manufactured_kappa_tanh forcing_manufactured_kappa_tanh kappa_tanh])
```
# Convergence
```julia
function poisson_error(n, spoints=3)
x, L, rhs = poisson_conservative(n, kappa_tanh,
forcing_manufactured_kappa_tanh,
leftbc=(0, manufactured), rightbc=(0, manufactured))
u = L \ rhs
norm(u - manufactured.(x), Inf)
end
ns = 2 .^ (3:10)
plot(ns, poisson_error.(ns, 3), marker=:auto, xscale=:log10, yscale=:log10)
plot!(n -> n^-2, label="\$1/n^2\$")
```
# Advection
Advection represents transport in a "wind" $w$. The time-dependent model is
$$ u_t + (w u)_x = 0 $$
for which $u(t,x) = u(0, x - tw)$.
```julia
u0(x) = @. tanh(2*x)
usolution(t,x; w=1) = @. u0(x - t*w)
x = LinRange(-1, 1, 50)
plot(x, [usolution(t, x) for t in 0:.2:2])
```
## What boundary conditions can be specified on the steady-state ($t\to\infty$) problem?
## What is the steady state solution?
# Advection-diffusion with Chebyshev
$$ -u_{xx} + (wu)_x = f $$
```julia
function advdiff_cheb(n, wind, rhsfunc, leftbc=(0, zero), rightbc=(0, zero))
x = CosRange(-1, 1, n)
T, dT, ddT = chebdiff(x)
dT /= T
ddT /= T
T /= T
L = -ddT + wind * dT
rhs = rhsfunc.(x)
for (index, deriv, func) in
[(1, leftbc...), (n, rightbc...)]
L[index,:] = (T, dT)[deriv+1][index,:]
rhs[index] = func(x[index])
end
x, L, rhs
end
```
advdiff_cheb (generic function with 3 methods)
```julia
x, L, rhs = advdiff_cheb(25, 100, one)
@show minimum(diff(x))
plot(x, L \ rhs, legend=:none, marker=:auto)
```
minimum(diff(x)) = 0.008555138626189618
# Advection-diffusion with conservative FD
$$(- \kappa u_x + wu)_x = f$$
```julia
function advdiff_conservative(n, kappa, wind, forcing)
x = LinRange(-1, 1, n)
xstag = (x[1:end-1] + x[2:end]) / 2
L = zeros(n, n)
rhs = forcing.(x)
kappa_stag = kappa.(xstag)
for i in 2:n-1
flux_L = -kappa_stag[i-1] * fdstencil(x[i-1:i], xstag[i-1], 1) + wind * [.5 .5]
flux_R = -kappa_stag[i] * fdstencil(x[i:i+1], xstag[i], 1) + wind * [.5 .5]
js = i-1:i+1
weights = fdstencil(xstag[i-1:i], x[i], 1)
L[i, i-1:i+1] = weights[1] * [flux_L..., 0] + weights[2] * [0, flux_R...]
end
L[1, 1] = 1
rhs[1] = 0
L[2:end, 1] .= 0
L[end,end] = 1
rhs[end] = 0
L[1:end-1,end] .= 0
x, L, rhs
end
```
advdiff_conservative (generic function with 1 method)
# Experiments, The (cell) [Péclet number](https://en.wikipedia.org/wiki/P%C3%A9clet_number)
\begin{align}
(- \kappa u_x + wu)_x &= f & \mathrm{Pe}_h &= \frac{h \lvert w \rvert}{\kappa}
\end{align}
```julia
n = 30; h = 2/n
kappa = 1
wind = 10
x, L, rhs = advdiff_conservative(n, x -> kappa, wind, one)
@show minimum(diff(x))
plot(x, L \ rhs, marker=:auto, legend=:none, title="ratio $(wind*h/kappa)")
```
minimum(diff(x)) = 0.06896551724137923
# Upwinded discretization
Idea: incoming **advective flux** should depend only on upwind value, outgoing should depend only on my value.
```julia
function advdiff_upwind(n, kappa, wind, forcing)
x = LinRange(-1, 1, n)
xstag = (x[1:end-1] + x[2:end]) / 2
L = zeros(n, n)
rhs = forcing.(x)
kappa_stag = kappa.(xstag)
for i in 2:n-1
flux_L = -kappa_stag[i-1] * fdstencil(x[i-1:i], xstag[i-1], 1) +
wind * (wind > 0 ? [1 0] : [0 1])
flux_R = -kappa_stag[i] * fdstencil(x[i:i+1], xstag[i], 1) +
wind * (wind > 0 ? [1 0] : [0 1])
js = i-1:i+1
weights = fdstencil(xstag[i-1:i], x[i], 1)
L[i, i-1:i+1] = weights[1] * [flux_L..., 0] + weights[2] * [0, flux_R...]
end
L[1, 1] = 1
rhs[1] = 0
L[2:end, 1] .= 0
L[end,end] = 1
rhs[end] = 0
L[1:end-1,end] .= 0
x, L, rhs
end
```
advdiff_upwind (generic function with 1 method)
# Try it for robustness
```julia
n = 30; h = 2/n
kappa = 1
wind = 10
x, L, rhs = advdiff_upwind(n, x -> kappa, wind, one)
@show minimum(diff(x))
plot(x, L \ rhs, marker=:auto, legend=:none, title="ratio $(wind*h/kappa)")
```
minimum(diff(x)) = 0.06896551724137923
|
= = Result = =
|
module Category.Instance where
open import Level
open import Category.Core
𝟙 : Category _ _
𝟙 = record
{ Objects = record
{ Carrier = ⊤
; _≈_ = λ _ _ → ⊤
; isEquivalence = _
}
; Morphisms = record
{ Carrier = λ x → ⊤
; _≈_ = λ _ _ → ⊤
; isEquivalence = _
; _∘_ = λ _ _ → tt
; id = λ a → tt
; isMorphism = _
}
}
where
open import Data.Unit
-- "pointing" an element with a functor from 𝟙
point : ∀ {𝒸 ℓ} → {C : Category 𝒸 ℓ} → Category.Object C → Functor 𝟙 C
point {_} {_} {C} c = record
{ mapObject = λ _ → c
; mapMorphism = λ _ → id c
; isFunctor = record
{ preserve-id = λ a → MorphEq.refl
; preserve-∘ = λ _ _ → MorphEq.sym (left-identity (id c))
}
}
where
open Category C
open import Relation.Binary.Indexed
module MorphEq = IsEquivalence (MorphismStructure.isEquivalence Morphisms)
open IsMorphism isMorphism
-- the identity functo
identity : ∀ {𝒸 ℓ} → (C : Category 𝒸 ℓ) → Functor C C
identity C = record
{ mapObject = λ x → x
; mapMorphism = λ x → x
; isFunctor = record
{ preserve-id = λ a → MorphEq.refl
; preserve-∘ = λ f g → MorphEq.refl
}
}
where
open Category C
open import Relation.Binary.Indexed
module MorphEq = IsEquivalence (MorphismStructure.isEquivalence Morphisms)
open IsMorphism isMorphism
|
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Subsingleton R
x✝ : Basis ι R M
b : M ≃ₗ[R] ι →₀ R
⊢ { repr := b } = default
[PROOFSTEP]
rw [Subsingleton.elim b]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
f g : Basis ι R M
h : f.repr = g.repr
⊢ f = g
[PROOFSTEP]
cases f
[GOAL]
case ofRepr
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
g : Basis ι R M
repr✝ : M ≃ₗ[R] ι →₀ R
h : { repr := repr✝ }.repr = g.repr
⊢ { repr := repr✝ } = g
[PROOFSTEP]
cases g
[GOAL]
case ofRepr.ofRepr
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
repr✝¹ repr✝ : M ≃ₗ[R] ι →₀ R
h : { repr := repr✝¹ }.repr = { repr := repr✝ }.repr
⊢ { repr := repr✝¹ } = { repr := repr✝ }
[PROOFSTEP]
congr
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
f g : Basis ι R M
h :
(fun b i => ↑(LinearEquiv.symm b.repr) (Finsupp.single i 1)) f =
(fun b i => ↑(LinearEquiv.symm b.repr) (Finsupp.single i 1)) g
⊢ ↑(LinearEquiv.symm f.repr) = ↑(LinearEquiv.symm g.repr)
[PROOFSTEP]
ext
[GOAL]
case h.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
f g : Basis ι R M
h :
(fun b i => ↑(LinearEquiv.symm b.repr) (Finsupp.single i 1)) f =
(fun b i => ↑(LinearEquiv.symm b.repr) (Finsupp.single i 1)) g
a✝ : ι
⊢ ↑(LinearMap.comp (↑(LinearEquiv.symm f.repr)) (Finsupp.lsingle a✝)) 1 =
↑(LinearMap.comp (↑(LinearEquiv.symm g.repr)) (Finsupp.lsingle a✝)) 1
[PROOFSTEP]
exact congr_fun h _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑(LinearEquiv.symm b.repr) (Finsupp.single i c) = ↑(LinearEquiv.symm b.repr) (c • Finsupp.single i 1)
[PROOFSTEP]
{rw [Finsupp.smul_single', mul_one]
}
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑(LinearEquiv.symm b.repr) (Finsupp.single i c) = ↑(LinearEquiv.symm b.repr) (c • Finsupp.single i 1)
[PROOFSTEP]
rw [Finsupp.smul_single', mul_one]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑(LinearEquiv.symm b.repr) (c • Finsupp.single i 1) = c • ↑b i
[PROOFSTEP]
rw [LinearEquiv.map_smul, repr_symm_single_one]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
j : ι
inst✝ : Decidable (i = j)
⊢ ↑(↑b.repr (↑b i)) j = if i = j then 1 else 0
[PROOFSTEP]
rw [repr_self, Finsupp.single_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
v : ι →₀ R
⊢ ↑(LinearEquiv.symm b.repr) v = ↑(LinearEquiv.symm b.repr) (Finsupp.sum v Finsupp.single)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
v : ι →₀ R
⊢ ↑(LinearEquiv.symm b.repr) (Finsupp.sum v Finsupp.single) =
∑ i in v.support, ↑(LinearEquiv.symm b.repr) (Finsupp.single i (↑v i))
[PROOFSTEP]
rw [Finsupp.sum, LinearEquiv.map_sum]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
v : ι →₀ R
⊢ ∑ i in v.support, ↑(LinearEquiv.symm b.repr) (Finsupp.single i (↑v i)) = ↑(Finsupp.total ι M R ↑b) v
[PROOFSTEP]
simp [repr_symm_single, Finsupp.total_apply, Finsupp.sum]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
v : ι →₀ R
⊢ ↑b.repr (↑(Finsupp.total ι M R ↑b) v) = v
[PROOFSTEP]
rw [← b.coe_repr_symm]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
v : ι →₀ R
⊢ ↑b.repr (↑↑(LinearEquiv.symm b.repr) v) = v
[PROOFSTEP]
exact b.repr.apply_symm_apply v
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑(Finsupp.total ι M R ↑b) (↑b.repr x) = x
[PROOFSTEP]
rw [← b.coe_repr_symm]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑↑(LinearEquiv.symm b.repr) (↑b.repr x) = x
[PROOFSTEP]
exact b.repr.symm_apply_apply x
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ LinearMap.range ↑b.repr = Finsupp.supported R R univ
[PROOFSTEP]
rw [LinearEquiv.range, Finsupp.supported_univ]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x m : M
⊢ ↑b.repr m ∈ Finsupp.supported R R ↑(↑b.repr m).support ∧ ↑(Finsupp.total ι M R ↑b) (↑b.repr m) = m
[PROOFSTEP]
simp [Finsupp.mem_supported_support]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
s : Set ι
m : M
hm : m ∈ span R (↑b '' s)
⊢ ↑(↑b.repr m).support ⊆ s
[PROOFSTEP]
rcases(Finsupp.mem_span_image_iff_total _).1 hm with ⟨l, hl, rfl⟩
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
s : Set ι
l : ι →₀ R
hl : l ∈ Finsupp.supported R R s
hm : ↑(Finsupp.total ι M R ↑b) l ∈ span R (↑b '' s)
⊢ ↑(↑b.repr (↑(Finsupp.total ι M R ↑b) l)).support ⊆ s
[PROOFSTEP]
rwa [repr_total, ← Finsupp.mem_supported R l]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
inst✝ : Nontrivial R
i : ι
s : Set ι
⊢ ↑b i ∈ span R (↑b '' s) ↔ i ∈ s
[PROOFSTEP]
simp [mem_span_image, Finsupp.support_single_ne_zero]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ x : M
⊢ (∀ (i : ι), ↑(coord b i) x = 0) ↔ ↑b.repr x = 0
[PROOFSTEP]
simp only [b.coord_apply, FunLike.ext_iff, Finsupp.zero_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑(sumCoords b) = fun m => ∑ᶠ (i : ι), ↑(coord b i) m
[PROOFSTEP]
ext m
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x m : M
⊢ ↑(sumCoords b) m = ∑ᶠ (i : ι), ↑(coord b i) m
[PROOFSTEP]
simp only [Basis.sumCoords, Basis.coord, Finsupp.lapply_apply, LinearMap.id_coe, LinearEquiv.coe_coe,
Function.comp_apply, Finsupp.coe_lsum, LinearMap.coe_comp, finsum_eq_sum _ (b.repr m).finite_support, Finsupp.sum,
Finset.finite_toSet_toFinset, id.def, Finsupp.fun_support_eq]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
inst✝ : Fintype ι
⊢ ↑(sumCoords b) = ↑(∑ i : ι, coord b i)
[PROOFSTEP]
ext m
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
inst✝ : Fintype ι
m : M
⊢ ↑(sumCoords b) m = ↑(∑ i : ι, coord b i) m
[PROOFSTEP]
simp only [sumCoords, Finsupp.sum_fintype, LinearMap.id_coe, LinearEquiv.coe_coe, coord_apply, id.def,
Fintype.sum_apply, imp_true_iff, Finsupp.coe_lsum, LinearMap.coe_comp, comp_apply, LinearMap.coeFn_sum]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
⊢ ↑(sumCoords b) (↑b i) = 1
[PROOFSTEP]
simp only [Basis.sumCoords, LinearMap.id_coe, LinearEquiv.coe_coe, id.def, Basis.repr_self, Function.comp_apply,
Finsupp.coe_lsum, LinearMap.coe_comp, Finsupp.sum_single_index]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
i : ι
m : M
r : R
⊢ ↑(coord b i) (r • m) = r * ↑(coord b i) m
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b✝ b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b : Basis ι R M
i : ι
f : ι →₀ R
⊢ ↑(coord b i) (↑(LinearEquiv.symm b.repr) f) = ↑f i
[PROOFSTEP]
simp only [repr_symm_apply, coord_apply, repr_total]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f₁ f₂ : M →ₛₗ[σ] M₁
h : ∀ (i : ι), ↑f₁ (↑b i) = ↑f₂ (↑b i)
⊢ f₁ = f₂
[PROOFSTEP]
ext x
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f₁ f₂ : M →ₛₗ[σ] M₁
h : ∀ (i : ι), ↑f₁ (↑b i) = ↑f₂ (↑b i)
x : M
⊢ ↑f₁ x = ↑f₂ x
[PROOFSTEP]
rw [← b.total_repr x, Finsupp.total_apply, Finsupp.sum]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f₁ f₂ : M →ₛₗ[σ] M₁
h : ∀ (i : ι), ↑f₁ (↑b i) = ↑f₂ (↑b i)
x : M
⊢ ↑f₁ (∑ a in (↑b.repr x).support, ↑(↑b.repr x) a • ↑b a) = ↑f₂ (∑ a in (↑b.repr x).support, ↑(↑b.repr x) a • ↑b a)
[PROOFSTEP]
simp only [LinearMap.map_sum, LinearMap.map_smulₛₗ, h]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f₁ f₂ : M ≃ₛₗ[σ] M₁
h : ∀ (i : ι), ↑f₁ (↑b i) = ↑f₂ (↑b i)
⊢ f₁ = f₂
[PROOFSTEP]
ext x
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f₁ f₂ : M ≃ₛₗ[σ] M₁
h : ∀ (i : ι), ↑f₁ (↑b i) = ↑f₂ (↑b i)
x : M
⊢ ↑f₁ x = ↑f₂ x
[PROOFSTEP]
rw [← b.total_repr x, Finsupp.total_apply, Finsupp.sum]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f₁ f₂ : M ≃ₛₗ[σ] M₁
h : ∀ (i : ι), ↑f₁ (↑b i) = ↑f₂ (↑b i)
x : M
⊢ ↑f₁ (∑ a in (↑b.repr x).support, ↑(↑b.repr x) a • ↑b a) = ↑f₂ (∑ a in (↑b.repr x).support, ↑(↑b.repr x) a • ↑b a)
[PROOFSTEP]
simp only [LinearEquiv.map_sum, LinearEquiv.map_smulₛₗ, h]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
x y : M
⊢ x = y ↔ ∀ (i : ι), ↑(↑b.repr x) i = ↑(↑b.repr y) i
[PROOFSTEP]
simp only [← FunLike.ext_iff, EmbeddingLike.apply_eq_iff_eq]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
⊢ ↑(↑b.repr x) i = f x i
[PROOFSTEP]
let f_i : M →ₗ[R] R :=
{ toFun := fun x => f x i
map_add' := fun _ _ => by dsimp only []; rw [hadd, Pi.add_apply]
map_smul' := fun _ _ => by simp [hsmul, Pi.smul_apply] }
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝² : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
x✝¹ x✝ : M
⊢ (fun x => f x i) (x✝¹ + x✝) = (fun x => f x i) x✝¹ + (fun x => f x i) x✝
[PROOFSTEP]
dsimp only []
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝² : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
x✝¹ x✝ : M
⊢ f (x✝¹ + x✝) i = f x✝¹ i + f x✝ i
[PROOFSTEP]
rw [hadd, Pi.add_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝² : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
x✝¹ : R
x✝ : M
⊢ AddHom.toFun
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) }
(x✝¹ • x✝) =
↑(RingHom.id R) x✝¹ •
AddHom.toFun
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) }
x✝
[PROOFSTEP]
simp [hsmul, Pi.smul_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
⊢ ↑(↑b.repr x) i = f x i
[PROOFSTEP]
have : Finsupp.lapply i ∘ₗ ↑b.repr = f_i := by
refine' b.ext fun j => _
show b.repr (b j) i = f (b j) i
rw [b.repr_self, f_eq]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
⊢ LinearMap.comp (Finsupp.lapply i) ↑b.repr = f_i
[PROOFSTEP]
refine' b.ext fun j => _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
j : ι
⊢ ↑(LinearMap.comp (Finsupp.lapply i) ↑b.repr) (↑b j) = ↑f_i (↑b j)
[PROOFSTEP]
show b.repr (b j) i = f (b j) i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
j : ι
⊢ ↑(↑b.repr (↑b j)) i = f (↑b j) i
[PROOFSTEP]
rw [b.repr_self, f_eq]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
this : LinearMap.comp (Finsupp.lapply i) ↑b.repr = f_i
⊢ ↑(↑b.repr x) i = f x i
[PROOFSTEP]
calc
b.repr x i = f_i x := by {
rw [← this]
rfl
}
_ = f x i := rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
this : LinearMap.comp (Finsupp.lapply i) ↑b.repr = f_i
⊢ ↑(↑b.repr x) i = ↑f_i x
[PROOFSTEP]
{ rw [← this]
rfl
}
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
this : LinearMap.comp (Finsupp.lapply i) ↑b.repr = f_i
⊢ ↑(↑b.repr x) i = ↑f_i x
[PROOFSTEP]
rw [← this]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
f : M → ι → R
hadd : ∀ (x y : M), f (x + y) = f x + f y
hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x
f_eq : ∀ (i : ι), f (↑b i) = ↑(Finsupp.single i 1)
x : M
i : ι
f_i : M →ₗ[R] R :=
{
toAddHom :=
{ toFun := fun x => f x i,
map_add' := (_ : ∀ (x x_1 : M), (fun x => f x i) (x + x_1) = (fun x => f x i) x + (fun x => f x i) x_1) },
map_smul' := (_ : ∀ (x : R) (x_1 : M), f (x • x_1) i = x * f x_1 i) }
this : LinearMap.comp (Finsupp.lapply i) ↑b.repr = f_i
⊢ ↑(↑b.repr x) i = ↑(LinearMap.comp (Finsupp.lapply i) ↑b.repr) x
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁✝ : Basis ι R M
i : ι
c : R
x : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
b₁ b₂ : Basis ι R M
h : ∀ (x : M) (i : ι), ↑(↑b₁.repr x) i = ↑(↑b₂.repr x) i
⊢ b₁.repr = b₂.repr
[PROOFSTEP]
ext
[GOAL]
case h.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁹ : Semiring R
inst✝⁸ : AddCommMonoid M
inst✝⁷ : Module R M
inst✝⁶ : AddCommMonoid M'
inst✝⁵ : Module R M'
b b₁✝ : Basis ι R M
i : ι
c : R
x : M
R₁ : Type u_10
inst✝⁴ : Semiring R₁
σ : R →+* R₁
σ' : R₁ →+* R
inst✝³ : RingHomInvPair σ σ'
inst✝² : RingHomInvPair σ' σ
M₁ : Type u_11
inst✝¹ : AddCommMonoid M₁
inst✝ : Module R₁ M₁
b₁ b₂ : Basis ι R M
h : ∀ (x : M) (i : ι), ↑(↑b₁.repr x) i = ↑(↑b₂.repr x) i
x✝ : M
a✝ : ι
⊢ ↑(↑b₁.repr x✝) a✝ = ↑(↑b₂.repr x✝) a✝
[PROOFSTEP]
apply h
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
⊢ Basis ι R' M
[PROOFSTEP]
letI : Module R' R := Module.compHom R (↑f.symm : R' →+* R)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
this : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
⊢ Basis ι R' M
[PROOFSTEP]
haveI : IsScalarTower R' R M :=
{
smul_assoc := fun x y z => by
-- Porting note: `dsimp [(· • ·)]` is unavailable because
-- `HSMul.hsmul` becomes `SMul.smul`.
change (f.symm x * y) • z = x • (y • z)
rw [mul_smul, ← h, f.apply_symm_apply] }
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
this : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
x : R'
y : R
z : M
⊢ (x • y) • z = x • y • z
[PROOFSTEP]
change (f.symm x * y) • z = x • (y • z)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
this : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
x : R'
y : R
z : M
⊢ (↑(RingEquiv.symm f) x * y) • z = x • y • z
[PROOFSTEP]
rw [mul_smul, ← h, f.apply_symm_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
this✝ : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
this : IsScalarTower R' R M
⊢ Basis ι R' M
[PROOFSTEP]
exact
ofRepr <| (b.repr.restrictScalars R').trans <| Finsupp.mapRange.linearEquiv (Module.compHom.toLinearEquiv f.symm).symm
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
i : ι
⊢ ↑(mapCoeffs b f h).repr (↑b i) = Finsupp.single i 1
[PROOFSTEP]
letI : Module R' R := Module.compHom R (↑f.symm : R' →+* R)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
i : ι
this : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
⊢ ↑(mapCoeffs b f h).repr (↑b i) = Finsupp.single i 1
[PROOFSTEP]
haveI : IsScalarTower R' R M :=
{
smul_assoc := fun x y z => by
-- Porting note: `dsimp [(· • ·)]` is unavailable because
-- `HSMul.hsmul` becomes `SMul.smul`.
change (f.symm x * y) • z = x • (y • z)
rw [mul_smul, ← h, f.apply_symm_apply] }
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
i : ι
this : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
x : R'
y : R
z : M
⊢ (x • y) • z = x • y • z
[PROOFSTEP]
change (f.symm x * y) • z = x • (y • z)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
i : ι
this : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
x : R'
y : R
z : M
⊢ (↑(RingEquiv.symm f) x * y) • z = x • y • z
[PROOFSTEP]
rw [mul_smul, ← h, f.apply_symm_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
R' : Type u_10
inst✝¹ : Semiring R'
inst✝ : Module R' M
f : R ≃+* R'
h : ∀ (c : R) (x : M), ↑f c • x = c • x
i : ι
this✝ : Module R' R := Module.compHom R ↑(RingEquiv.symm f)
this : IsScalarTower R' R M
⊢ ↑(mapCoeffs b f h).repr (↑b i) = Finsupp.single i 1
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i' : ι'
⊢ ↑(LinearEquiv.symm (LinearEquiv.trans b.repr (Finsupp.domLCongr e))) (Finsupp.single i' 1) =
↑(LinearEquiv.symm b.repr) (Finsupp.single (↑e.symm i') 1)
[PROOFSTEP]
rw [LinearEquiv.symm_trans_apply, Finsupp.domLCongr_symm, Finsupp.domLCongr_single]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i' : ι'
⊢ ↑(↑(Finsupp.domLCongr e) (↑b.repr x)) i' = ↑(↑b.repr x) (↑e.symm i')
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
⊢ ∀ (x_1 : ι'), ↑(↑(reindex b e).repr x) x_1 = ↑(Finsupp.mapDomain (↑e) (↑b.repr x)) x_1
[PROOFSTEP]
simp [repr_reindex_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
⊢ ↑(reindex b (Equiv.refl ι)) i = ↑b i
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
⊢ range ↑(reindex b e) = range ↑b
[PROOFSTEP]
simp [coe_reindex, range_comp]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
⊢ sumCoords (reindex b e) = sumCoords b
[PROOFSTEP]
ext x
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
⊢ ↑(sumCoords (reindex b e)) x = ↑(sumCoords b) x
[PROOFSTEP]
simp only [coe_sumCoords, repr_reindex]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
⊢ (Finsupp.sum (Finsupp.mapDomain (↑e) (↑b.repr x)) fun x => id) = Finsupp.sum (↑b.repr x) fun x => id
[PROOFSTEP]
exact Finsupp.sum_mapDomain_index (fun _ => rfl) fun _ _ _ => rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
h : optParam (↑b i ∈ range ↑b) (_ : ↑b i ∈ range ↑b)
⊢ ↑(reindexRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
by_cases htr : Nontrivial R
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
h : optParam (↑b i ∈ range ↑b) (_ : ↑b i ∈ range ↑b)
htr : Nontrivial R
⊢ ↑(reindexRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
letI := htr
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
h : optParam (↑b i ∈ range ↑b) (_ : ↑b i ∈ range ↑b)
htr : Nontrivial R
this : Nontrivial R := htr
⊢ ↑(reindexRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
simp [htr, reindexRange, reindex_apply, Equiv.apply_ofInjective_symm b.injective, Subtype.coe_mk]
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
h : optParam (↑b i ∈ range ↑b) (_ : ↑b i ∈ range ↑b)
htr : ¬Nontrivial R
⊢ ↑(reindexRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
letI : Subsingleton R := not_nontrivial_iff_subsingleton.mp htr
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
h : optParam (↑b i ∈ range ↑b) (_ : ↑b i ∈ range ↑b)
htr : ¬Nontrivial R
this : Subsingleton R := Iff.mp not_nontrivial_iff_subsingleton htr
⊢ ↑(reindexRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
letI := Module.subsingleton R M
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
h : optParam (↑b i ∈ range ↑b) (_ : ↑b i ∈ range ↑b)
htr : ¬Nontrivial R
this✝ : Subsingleton R := Iff.mp not_nontrivial_iff_subsingleton htr
this : Subsingleton M := Module.subsingleton R M
⊢ ↑(reindexRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
simp [reindexRange]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : ↑(range ↑b)
⊢ ↑(reindexRange b) x = ↑x
[PROOFSTEP]
rcases x with ⟨bi, ⟨i, rfl⟩⟩
[GOAL]
case mk.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
⊢ ↑(reindexRange b) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) } =
↑{ val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }
[PROOFSTEP]
exact b.reindexRange_self i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x bi : M
i : ι
h : ↑b i = bi
⊢ ↑(↑(reindexRange b).repr x) { val := bi, property := (_ : ∃ y, ↑b y = bi) } = ↑(↑b.repr x) i
[PROOFSTEP]
nontriviality
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x bi : M
i : ι
h : ↑b i = bi
✝ : Nontrivial ((fun x => R) { val := bi, property := (_ : ∃ y, ↑b y = bi) })
⊢ ↑(↑(reindexRange b).repr x) { val := bi, property := (_ : ∃ y, ↑b y = bi) } = ↑(↑b.repr x) i
[PROOFSTEP]
subst h
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) })
⊢ ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) } = ↑(↑b.repr x) i
[PROOFSTEP]
apply (b.repr_apply_eq (fun x i => b.reindexRange.repr x ⟨b i, _⟩) _ _ _ x i).symm
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) })
⊢ ∀ (x y : M),
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (x + y) =
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) x +
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) y
[PROOFSTEP]
intro x y
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝¹ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x✝ : M
i : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) })
x y : M
⊢ (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (x + y) =
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) x +
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) y
[PROOFSTEP]
ext i
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x✝¹ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x✝ : M
i✝ : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i✝, property := (_ : ∃ y, ↑b y = ↑b i✝) })
x y : M
i : ι
⊢ (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (x + y) i =
((fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) x +
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) y)
i
[PROOFSTEP]
simp only [Pi.add_apply, LinearEquiv.map_add, Finsupp.coe_add]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) })
⊢ ∀ (c : R) (x : M),
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (c • x) =
c • (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) x
[PROOFSTEP]
intro c x
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c✝ : R
x✝¹ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x✝ : M
i : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) })
c : R
x : M
⊢ (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (c • x) =
c • (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) x
[PROOFSTEP]
ext i
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c✝ : R
x✝¹ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x✝ : M
i✝ : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i✝, property := (_ : ∃ y, ↑b y = ↑b i✝) })
c : R
x : M
i : ι
⊢ (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (c • x) i =
(c • (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) x) i
[PROOFSTEP]
simp only [Pi.smul_apply, LinearEquiv.map_smul, Finsupp.coe_smul]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) })
⊢ ∀ (i : ι),
(fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (↑b i) =
↑(Finsupp.single i 1)
[PROOFSTEP]
intro i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i✝ : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i✝, property := (_ : ∃ y, ↑b y = ↑b i✝) })
i : ι
⊢ (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (↑b i) =
↑(Finsupp.single i 1)
[PROOFSTEP]
ext j
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i✝ : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i✝, property := (_ : ∃ y, ↑b y = ↑b i✝) })
i j : ι
⊢ (fun x i => ↑(↑(reindexRange b).repr x) { val := ↑b i, property := (_ : ∃ y, ↑b y = ↑b i) }) (↑b i) j =
↑(Finsupp.single i 1) j
[PROOFSTEP]
simp only [reindexRange_repr_self]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i✝ : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i✝, property := (_ : ∃ y, ↑b y = ↑b i✝) })
i j : ι
⊢ ↑(Finsupp.single { val := ↑b i, property := (_ : ↑b i ∈ range ↑b) } 1)
{ val := ↑b j, property := (_ : ∃ y, ↑b y = ↑b j) } =
↑(Finsupp.single i 1) j
[PROOFSTEP]
apply Finsupp.single_apply_left (f := fun i => (⟨b i, _⟩ : Set.range b))
[GOAL]
case h.hf
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
x : M
i✝ : ι
✝ : Nontrivial ((fun x => R) { val := ↑b i✝, property := (_ : ∃ y, ↑b y = ↑b i✝) })
i j : ι
⊢ Injective fun i => { val := ↑b i, property := (_ : ↑b i ∈ range ↑b) }
[PROOFSTEP]
exact fun i j h => b.injective (Subtype.mk.inj h)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
⊢ ∀ (a : M), a ∈ range ↑b ↔ ↑(Equiv.refl M) a ∈ Finset.image (↑b) Finset.univ
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
i : ι
h : optParam (↑b i ∈ Finset.image (↑b) Finset.univ) (_ : ↑b i ∈ Finset.image (↑b) Finset.univ)
⊢ ↑(reindexFinsetRange b) { val := ↑b i, property := h } = ↑b i
[PROOFSTEP]
rw [reindexFinsetRange, reindex_apply, reindexRange_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
i : ι
h : optParam (↑b i ∈ Finset.image (↑b) Finset.univ) (_ : ↑b i ∈ Finset.image (↑b) Finset.univ)
⊢ ↑(↑(Equiv.subtypeEquiv (Equiv.refl M) (_ : ∀ (a : M), a ∈ range ↑b ↔ a ∈ Finset.image (↑b) Finset.univ)).symm
{ val := ↑b i, property := h }) =
↑b i
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
x : { x // x ∈ Finset.image (↑b) Finset.univ }
⊢ ↑(reindexFinsetRange b) x = ↑x
[PROOFSTEP]
rcases x with ⟨bi, hbi⟩
[GOAL]
case mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
bi : M
hbi : bi ∈ Finset.image (↑b) Finset.univ
⊢ ↑(reindexFinsetRange b) { val := bi, property := hbi } = ↑{ val := bi, property := hbi }
[PROOFSTEP]
rcases Finset.mem_image.mp hbi with ⟨i, -, rfl⟩
[GOAL]
case mk.intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
i : ι
hbi : ↑b i ∈ Finset.image (↑b) Finset.univ
⊢ ↑(reindexFinsetRange b) { val := ↑b i, property := hbi } = ↑{ val := ↑b i, property := hbi }
[PROOFSTEP]
exact b.reindexFinsetRange_self i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
i : ι
⊢ ↑(reindexFinsetRange b).repr (↑b i) =
Finsupp.single { val := ↑b i, property := (_ : ↑b i ∈ Finset.image (↑b) Finset.univ) } 1
[PROOFSTEP]
ext ⟨bi, hbi⟩
[GOAL]
case h.mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
i : ι
bi : M
hbi : bi ∈ Finset.image (↑b) Finset.univ
⊢ ↑(↑(reindexFinsetRange b).repr (↑b i)) { val := bi, property := hbi } =
↑(Finsupp.single { val := ↑b i, property := (_ : ↑b i ∈ Finset.image (↑b) Finset.univ) } 1)
{ val := bi, property := hbi }
[PROOFSTEP]
rw [reindexFinsetRange, repr_reindex, Finsupp.mapDomain_equiv_apply, reindexRange_repr_self]
-- Porting note: replaced a `convert; refl` with `simp`
[GOAL]
case h.mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
i : ι
bi : M
hbi : bi ∈ Finset.image (↑b) Finset.univ
⊢ ↑(Finsupp.single { val := ↑b i, property := (_ : ↑b i ∈ range ↑b) } 1)
(↑(Equiv.subtypeEquiv (Equiv.refl M) (_ : ∀ (a : M), a ∈ range ↑b ↔ a ∈ Finset.image (↑b) Finset.univ)).symm
{ val := bi, property := hbi }) =
↑(Finsupp.single { val := ↑b i, property := (_ : ↑b i ∈ Finset.image (↑b) Finset.univ) } 1)
{ val := bi, property := hbi }
[PROOFSTEP]
simp [Finsupp.single_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : Fintype ι
inst✝ : DecidableEq M
x : M
i : ι
h : optParam (↑b i ∈ Finset.image (↑b) Finset.univ) (_ : ↑b i ∈ Finset.image (↑b) Finset.univ)
⊢ ↑(↑(reindexFinsetRange b).repr x) { val := ↑b i, property := h } = ↑(↑b.repr x) i
[PROOFSTEP]
simp [reindexFinsetRange]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
l : ι →₀ R
hl : ↑(Finsupp.total ι M R ↑b) l = 0
⊢ ↑b.repr (↑(Finsupp.total ι M R ↑b) l) = 0
[PROOFSTEP]
rw [hl, LinearEquiv.map_zero]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x : M
b : Basis ι R M
inst✝ : Nontrivial M
⊢ Nonempty ι
[PROOFSTEP]
obtain ⟨x, y, ne⟩ : ∃ x y : M, x ≠ y := Nontrivial.exists_pair_ne
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
b : Basis ι R M
inst✝ : Nontrivial M
x y : M
ne : x ≠ y
⊢ Nonempty ι
[PROOFSTEP]
obtain ⟨i, _⟩ := not_forall.mp (mt b.ext_elem_iff.2 ne)
[GOAL]
case intro.intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
b : Basis ι R M
inst✝ : Nontrivial M
x y : M
ne : x ≠ y
i : ι
h✝ : ¬↑(↑b.repr x) i = ↑(↑b.repr y) i
⊢ Nonempty ι
[PROOFSTEP]
exact ⟨i⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
P : Submodule R M
b : Basis ι R { x // x ∈ P }
x : M
⊢ x ∈ P ↔ ∃ c, x = Finsupp.sum c fun i x => x • ↑(↑b i)
[PROOFSTEP]
conv_lhs =>
rw [← P.range_subtype, ← Submodule.map_top, ← b.span_eq, Submodule.map_span, ← Set.range_comp, ← Finsupp.range_total]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
P : Submodule R M
b : Basis ι R { x // x ∈ P }
x : M
| x ∈ P
[PROOFSTEP]
rw [← P.range_subtype, ← Submodule.map_top, ← b.span_eq, Submodule.map_span, ← Set.range_comp, ← Finsupp.range_total]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
P : Submodule R M
b : Basis ι R { x // x ∈ P }
x : M
| x ∈ P
[PROOFSTEP]
rw [← P.range_subtype, ← Submodule.map_top, ← b.span_eq, Submodule.map_span, ← Set.range_comp, ← Finsupp.range_total]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
P : Submodule R M
b : Basis ι R { x // x ∈ P }
x : M
| x ∈ P
[PROOFSTEP]
rw [← P.range_subtype, ← Submodule.map_top, ← b.span_eq, Submodule.map_span, ← Set.range_comp, ← Finsupp.range_total]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
P : Submodule R M
b : Basis ι R { x // x ∈ P }
x : M
⊢ x ∈ LinearMap.range (Finsupp.total ι M R (↑(Submodule.subtype P) ∘ ↑b)) ↔
∃ c, x = Finsupp.sum c fun i x => x • ↑(↑b i)
[PROOFSTEP]
simp [@eq_comm _ x, Function.comp, Finsupp.total_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f g : ι → M'
⊢ (fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr)) (f + g) =
(fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr)) f +
(fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr)) g
[PROOFSTEP]
refine' b.ext fun i => _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f g : ι → M'
i : ι
⊢ ↑((fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr)) (f + g))
(↑b i) =
↑((fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr)) f +
(fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr)) g)
(↑b i)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c✝ : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
c : S
f : ι → M'
⊢ AddHom.toFun
{ toFun := fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
(c • f) =
↑(RingHom.id S) c •
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f => LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
f
[PROOFSTEP]
refine' b.ext fun i => _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c✝ : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
c : S
f : ι → M'
i : ι
⊢ ↑(AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
(c • f))
(↑b i) =
↑(↑(RingHom.id S) c •
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
f)
(↑b i)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
⊢ (fun f i => ↑f (↑b i))
(AddHom.toFun
{
toAddHom :=
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) },
map_smul' :=
(_ :
∀ (c : S) (f : ι → M'),
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
(c • f) =
↑(RingHom.id S) c •
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
f) }.toAddHom
f) =
f
[PROOFSTEP]
ext
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x✝ : ι
⊢ (fun f i => ↑f (↑b i))
(AddHom.toFun
{
toAddHom :=
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) },
map_smul' :=
(_ :
∀ (c : S) (f : ι → M'),
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
(c • f) =
↑(RingHom.id S) c •
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
f) }.toAddHom
f)
x✝ =
f x✝
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : M →ₗ[R] M'
⊢ AddHom.toFun
{
toAddHom :=
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) },
map_smul' :=
(_ :
∀ (c : S) (f : ι → M'),
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
(c • f) =
↑(RingHom.id S) c •
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
f) }.toAddHom
((fun f i => ↑f (↑b i)) f) =
f
[PROOFSTEP]
refine' b.ext fun i => _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : M →ₗ[R] M'
i : ι
⊢ ↑(AddHom.toFun
{
toAddHom :=
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id) (LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) },
map_smul' :=
(_ :
∀ (c : S) (f : ι → M'),
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
(c • f) =
↑(RingHom.id S) c •
AddHom.toFun
{
toFun := fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr),
map_add' :=
(_ :
∀ (f g : ι → M'),
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
(f + g) =
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
f +
(fun f =>
LinearMap.comp (Finsupp.total M' M' R id)
(LinearMap.comp (Finsupp.lmapDomain R R f) ↑b.repr))
g) }
f) }.toAddHom
((fun f i => ↑f (↑b i)) f))
(↑b i) =
↑f (↑b i)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x : M
⊢ ↑(↑(constr b S) f) x = Finsupp.sum (↑b.repr x) fun b a => a • f b
[PROOFSTEP]
simp only [constr_def, LinearMap.comp_apply, Finsupp.lmapDomain_apply, Finsupp.total_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x : M
⊢ (Finsupp.sum (Finsupp.mapDomain f (↑↑b.repr x)) fun i a => a • id i) = Finsupp.sum (↑b.repr x) fun b a => a • f b
[PROOFSTEP]
rw [Finsupp.sum_mapDomain_index]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x : M
⊢ (Finsupp.sum (↑↑b.repr x) fun a m => m • id (f a)) = Finsupp.sum (↑b.repr x) fun b a => a • f b
[PROOFSTEP]
simp [add_smul]
[GOAL]
case h_zero
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x : M
⊢ ∀ (b : M'), 0 • id b = 0
[PROOFSTEP]
simp [add_smul]
[GOAL]
case h_add
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x✝ : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x : M
⊢ ∀ (b : M') (m₁ m₂ : R), (m₁ + m₂) • id b = m₁ • id b + m₂ • id b
[PROOFSTEP]
simp [add_smul]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
i : ι
⊢ ↑(↑(constr b S) f) (↑b i) = f i
[PROOFSTEP]
simp [Basis.constr_apply, b.repr_self]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁸ : Semiring R
inst✝⁷ : AddCommMonoid M
inst✝⁶ : Module R M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
S : Type u_10
inst✝³ : Semiring S
inst✝² : Module S M'
inst✝¹ : SMulCommClass R S M'
inst✝ : Nonempty ι
f : ι → M'
⊢ LinearMap.range (↑(constr b S) f) = span R (range f)
[PROOFSTEP]
rw [b.constr_def S f, LinearMap.range_comp, LinearMap.range_comp, LinearEquiv.range, ← Finsupp.supported_univ,
Finsupp.lmapDomain_supported, ← Set.image_univ, ← Finsupp.span_image_eq_map_total, Set.image_id]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : M' →ₗ[R] M'
v : ι → M'
i : ι
⊢ ↑(↑(constr b S) (↑f ∘ v)) (↑b i) = ↑(LinearMap.comp f (↑(constr b S) v)) (↑b i)
[PROOFSTEP]
simp only [Basis.constr_basis, LinearMap.comp_apply, Function.comp]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : AddCommMonoid M''
inst✝ : Module R M''
⊢ ↑(Basis.equiv b b' e) (↑b i) = ↑b' (↑e i)
[PROOFSTEP]
simp [Basis.equiv]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : AddCommMonoid M''
inst✝ : Module R M''
i : ι
⊢ ↑(Basis.equiv b b (Equiv.refl ι)) (↑b i) = ↑(LinearEquiv.refl R M) (↑b i)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e : ι ≃ ι'
inst✝¹ : AddCommMonoid M''
inst✝ : Module R M''
i : ι'
⊢ ↑(Basis.equiv b b' e) (↑(LinearEquiv.symm (Basis.equiv b b' e)) (↑b' i)) =
↑(Basis.equiv b b' e) (↑(Basis.equiv b' b e.symm) (↑b' i))
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
e✝ : ι ≃ ι'
inst✝¹ : AddCommMonoid M''
inst✝ : Module R M''
ι'' : Type u_10
b'' : Basis ι'' R M''
e : ι ≃ ι'
e' : ι' ≃ ι''
i : ι
⊢ ↑(LinearEquiv.trans (Basis.equiv b b' e) (Basis.equiv b' b'' e')) (↑b i) = ↑(Basis.equiv b b'' (e.trans e')) (↑b i)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x : M
b'✝ : Basis ι' R M'
e✝ : ι ≃ ι'
inst✝¹ : AddCommMonoid M''
inst✝ : Module R M''
b : Basis ι R M
b' : Basis ι' R M'
e : ι ≃ ι'
⊢ Basis.map b (Basis.equiv b b' e) = reindex b' e.symm
[PROOFSTEP]
ext i
[GOAL]
case a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
b✝ b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b'✝ : Basis ι' R M'
e✝ : ι ≃ ι'
inst✝¹ : AddCommMonoid M''
inst✝ : Module R M''
b : Basis ι R M
b' : Basis ι' R M'
e : ι ≃ ι'
i : ι
⊢ ↑(Basis.map b (Basis.equiv b b' e)) i = ↑(reindex b' e.symm) i
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι
⊢ ↑b.repr (↑(Basis.prod b b') (Sum.inl i)).fst = ↑b.repr (↑b i)
[PROOFSTEP]
ext j
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i j : ι
⊢ ↑(↑b.repr (↑(Basis.prod b b') (Sum.inl i)).fst) j = ↑(↑b.repr (↑b i)) j
[PROOFSTEP]
simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply,
b.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe,
Finsupp.fst_sumFinsuppLEquivProdFinsupp]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i j : ι
⊢ ↑(Finsupp.single (Sum.inl i) 1) (Sum.inl j) = ↑(Finsupp.single i 1) j
[PROOFSTEP]
apply Finsupp.single_apply_left Sum.inl_injective
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι'
⊢ ↑b.repr (↑(Basis.prod b b') (Sum.inr i)).fst = ↑b.repr 0
[PROOFSTEP]
ext i
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x : M
b' : Basis ι' R M'
i✝ : ι'
i : ι
⊢ ↑(↑b.repr (↑(Basis.prod b b') (Sum.inr i✝)).fst) i = ↑(↑b.repr 0) i
[PROOFSTEP]
simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply,
b.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe,
Finsupp.fst_sumFinsuppLEquivProdFinsupp, LinearEquiv.map_zero, Finsupp.zero_apply]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x : M
b' : Basis ι' R M'
i✝ : ι'
i : ι
⊢ ↑(Finsupp.single (Sum.inr i✝) 1) (Sum.inl i) = 0
[PROOFSTEP]
apply Finsupp.single_eq_of_ne Sum.inr_ne_inl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι
⊢ ↑b'.repr (↑(Basis.prod b b') (Sum.inl i)).snd = ↑b'.repr 0
[PROOFSTEP]
ext j
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι
j : ι'
⊢ ↑(↑b'.repr (↑(Basis.prod b b') (Sum.inl i)).snd) j = ↑(↑b'.repr 0) j
[PROOFSTEP]
simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply,
b'.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe,
Finsupp.snd_sumFinsuppLEquivProdFinsupp, LinearEquiv.map_zero, Finsupp.zero_apply]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι
j : ι'
⊢ ↑(Finsupp.single (Sum.inl i) 1) (Sum.inr j) = 0
[PROOFSTEP]
apply Finsupp.single_eq_of_ne Sum.inl_ne_inr
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι'
⊢ ↑b'.repr (↑(Basis.prod b b') (Sum.inr i)).snd = ↑b'.repr (↑b' i)
[PROOFSTEP]
ext i
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x : M
b' : Basis ι' R M'
i✝ i : ι'
⊢ ↑(↑b'.repr (↑(Basis.prod b b') (Sum.inr i✝)).snd) i = ↑(↑b'.repr (↑b' i✝)) i
[PROOFSTEP]
simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply,
b'.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe,
Finsupp.snd_sumFinsuppLEquivProdFinsupp]
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝¹ : ι
c : R
x : M
b' : Basis ι' R M'
i✝ i : ι'
⊢ ↑(Finsupp.single (Sum.inr i✝) 1) (Sum.inr i) = ↑(Finsupp.single i✝ 1) i
[PROOFSTEP]
apply Finsupp.single_apply_left Sum.inr_injective
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι ⊕ ι'
⊢ ↑(Basis.prod b b') i = Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') i
[PROOFSTEP]
ext
[GOAL]
case h₁
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι ⊕ ι'
⊢ (↑(Basis.prod b b') i).fst = (Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') i).fst
[PROOFSTEP]
cases i
[GOAL]
case h₂
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i✝ : ι
c : R
x : M
b' : Basis ι' R M'
i : ι ⊕ ι'
⊢ (↑(Basis.prod b b') i).snd = (Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') i).snd
[PROOFSTEP]
cases i
[GOAL]
case h₁.inl
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
val✝ : ι
⊢ (↑(Basis.prod b b') (Sum.inl val✝)).fst =
(Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') (Sum.inl val✝)).fst
[PROOFSTEP]
simp only [prod_apply_inl_fst, Sum.elim_inl, LinearMap.inl_apply, prod_apply_inr_fst, Sum.elim_inr, LinearMap.inr_apply,
prod_apply_inl_snd, prod_apply_inr_snd, Function.comp]
[GOAL]
case h₁.inr
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
val✝ : ι'
⊢ (↑(Basis.prod b b') (Sum.inr val✝)).fst =
(Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') (Sum.inr val✝)).fst
[PROOFSTEP]
simp only [prod_apply_inl_fst, Sum.elim_inl, LinearMap.inl_apply, prod_apply_inr_fst, Sum.elim_inr, LinearMap.inr_apply,
prod_apply_inl_snd, prod_apply_inr_snd, Function.comp]
[GOAL]
case h₂.inl
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
val✝ : ι
⊢ (↑(Basis.prod b b') (Sum.inl val✝)).snd =
(Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') (Sum.inl val✝)).snd
[PROOFSTEP]
simp only [prod_apply_inl_fst, Sum.elim_inl, LinearMap.inl_apply, prod_apply_inr_fst, Sum.elim_inr, LinearMap.inr_apply,
prod_apply_inl_snd, prod_apply_inr_snd, Function.comp]
[GOAL]
case h₂.inr
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b b₁ : Basis ι R M
i : ι
c : R
x : M
b' : Basis ι' R M'
val✝ : ι'
⊢ (↑(Basis.prod b b') (Sum.inr val✝)).snd =
(Sum.elim (↑(LinearMap.inl R M M') ∘ ↑b) (↑(LinearMap.inr R M M') ∘ ↑b') (Sum.inr val✝)).snd
[PROOFSTEP]
simp only [prod_apply_inl_fst, Sum.elim_inl, LinearMap.inl_apply, prod_apply_inr_fst, Sum.elim_inr, LinearMap.inr_apply,
prod_apply_inl_snd, prod_apply_inr_snd, Function.comp]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c✝ : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
c : R
x : M
hcx : c • x = 0
⊢ c = 0 ∨ x = 0
[PROOFSTEP]
exact
or_iff_not_imp_right.mpr fun hx =>
by
rw [← b.total_repr x, ← LinearMap.map_smul] at hcx
have := linearIndependent_iff.mp b.linearIndependent (c • b.repr x) hcx
rw [smul_eq_zero] at this
exact this.resolve_right fun hr => hx (b.repr.map_eq_zero_iff.mp hr)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c✝ : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
c : R
x : M
hcx : c • x = 0
hx : ¬x = 0
⊢ c = 0
[PROOFSTEP]
rw [← b.total_repr x, ← LinearMap.map_smul] at hcx
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c✝ : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
c : R
x : M
hcx : ↑(Finsupp.total ι M R ↑b) (c • ↑b.repr x) = 0
hx : ¬x = 0
⊢ c = 0
[PROOFSTEP]
have := linearIndependent_iff.mp b.linearIndependent (c • b.repr x) hcx
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c✝ : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
c : R
x : M
hcx : ↑(Finsupp.total ι M R ↑b) (c • ↑b.repr x) = 0
hx : ¬x = 0
this : c • ↑b.repr x = 0
⊢ c = 0
[PROOFSTEP]
rw [smul_eq_zero] at this
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c✝ : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
c : R
x : M
hcx : ↑(Finsupp.total ι M R ↑b) (c • ↑b.repr x) = 0
hx : ¬x = 0
this : c = 0 ∨ ↑b.repr x = 0
⊢ c = 0
[PROOFSTEP]
exact this.resolve_right fun hr => hx (b.repr.map_eq_zero_iff.mp hr)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
rank_eq : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m = 0
⊢ N = ⊥
[PROOFSTEP]
rw [Submodule.eq_bot_iff]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
rank_eq : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m = 0
⊢ ∀ (x : M), x ∈ N → x = 0
[PROOFSTEP]
intro x hx
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
rank_eq : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m = 0
x : M
hx : x ∈ N
⊢ x = 0
[PROOFSTEP]
contrapose! rank_eq with x_ne
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
x : M
hx : x ∈ N
x_ne : x ≠ 0
⊢ Exists fun {m} => ∃ v, LinearIndependent R (Subtype.val ∘ v) ∧ m ≠ 0
[PROOFSTEP]
refine' ⟨1, fun _ => ⟨x, hx⟩, _, one_ne_zero⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
x : M
hx : x ∈ N
x_ne : x ≠ 0
⊢ LinearIndependent R (Subtype.val ∘ fun x_1 => { val := x, property := hx })
[PROOFSTEP]
rw [Fintype.linearIndependent_iff]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
x : M
hx : x ∈ N
x_ne : x ≠ 0
⊢ ∀ (g : Fin 1 → R),
∑ i : Fin 1, g i • (Subtype.val ∘ fun x_1 => { val := x, property := hx }) i = 0 → ∀ (i : Fin 1), g i = 0
[PROOFSTEP]
rintro g sum_eq i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i✝ : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
x : M
hx : x ∈ N
x_ne : x ≠ 0
g : Fin 1 → R
sum_eq : ∑ i : Fin 1, g i • (Subtype.val ∘ fun x_1 => { val := x, property := hx }) i = 0
i : Fin 1
⊢ g i = 0
[PROOFSTEP]
cases' i with _ hi
[GOAL]
case mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
x : M
hx : x ∈ N
x_ne : x ≠ 0
g : Fin 1 → R
sum_eq : ∑ i : Fin 1, g i • (Subtype.val ∘ fun x_1 => { val := x, property := hx }) i = 0
val✝ : ℕ
hi : val✝ < 1
⊢ g { val := val✝, isLt := hi } = 0
[PROOFSTEP]
simp only [Function.const_apply, Fin.default_eq_zero, Submodule.coe_mk, Finset.univ_unique, Function.comp_const,
Finset.sum_singleton] at sum_eq
[GOAL]
case mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b✝ b₁ : Basis ι R M
i : ι
c : R
x✝ : M
inst✝ : NoZeroDivisors R
b : Basis ι R M
N : Submodule R M
x : M
hx : x ∈ N
x_ne : x ≠ 0
g : Fin 1 → R
val✝ : ℕ
hi : val✝ < 1
sum_eq : g 0 • (Subtype.val ∘ fun x_1 => { val := x, property := hx }) 0 = 0
⊢ g { val := val✝, isLt := hi } = 0
[PROOFSTEP]
convert (b.smul_eq_zero.mp sum_eq).resolve_right x_ne
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R✝
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R✝ M
inst✝³ : AddCommMonoid M'
inst✝² : Module R✝ M'
b b₁ : Basis ι✝ R✝ M
i : ι✝
c : R✝
x✝ : M
ι : Type u_10
R : Type u_11
inst✝¹ : Unique ι
inst✝ : Semiring R
x y : R
⊢ (fun x => Finsupp.single default x) (x + y) =
(fun x => Finsupp.single default x) x + (fun x => Finsupp.single default x) y
[PROOFSTEP]
simp
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R✝
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R✝ M
inst✝³ : AddCommMonoid M'
inst✝² : Module R✝ M'
b b₁ : Basis ι✝ R✝ M
i : ι✝
c✝ : R✝
x✝ : M
ι : Type u_10
R : Type u_11
inst✝¹ : Unique ι
inst✝ : Semiring R
c x : R
⊢ AddHom.toFun
{ toFun := fun x => Finsupp.single default x,
map_add' :=
(_ : ∀ (x y : R), Finsupp.single default (x + y) = Finsupp.single default x + Finsupp.single default y) }
(c • x) =
↑(RingHom.id R) c •
AddHom.toFun
{ toFun := fun x => Finsupp.single default x,
map_add' :=
(_ : ∀ (x y : R), Finsupp.single default (x + y) = Finsupp.single default x + Finsupp.single default y) }
x
[PROOFSTEP]
simp
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R✝
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R✝ M
inst✝³ : AddCommMonoid M'
inst✝² : Module R✝ M'
b b₁ : Basis ι✝ R✝ M
i : ι✝
c : R✝
x✝ : M
ι : Type u_10
R : Type u_11
inst✝¹ : Unique ι
inst✝ : Semiring R
x : R
⊢ (fun f => ↑f default)
(AddHom.toFun
{
toAddHom :=
{ toFun := fun x => Finsupp.single default x,
map_add' :=
(_ :
∀ (x y : R),
Finsupp.single default (x + y) = Finsupp.single default x + Finsupp.single default y) },
map_smul' := (_ : ∀ (c x : R), Finsupp.single default (c * x) = c • Finsupp.single default x) }.toAddHom
x) =
x
[PROOFSTEP]
simp
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R✝
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R✝ M
inst✝³ : AddCommMonoid M'
inst✝² : Module R✝ M'
b b₁ : Basis ι✝ R✝ M
i : ι✝
c : R✝
x : M
ι : Type u_10
R : Type u_11
inst✝¹ : Unique ι
inst✝ : Semiring R
f : ι →₀ R
⊢ ↑(AddHom.toFun
{
toAddHom :=
{ toFun := fun x => Finsupp.single default x,
map_add' :=
(_ :
∀ (x y : R),
Finsupp.single default (x + y) = Finsupp.single default x + Finsupp.single default y) },
map_smul' := (_ : ∀ (c x : R), Finsupp.single default (c * x) = c • Finsupp.single default x) }.toAddHom
((fun f => ↑f default) f))
default =
↑f default
[PROOFSTEP]
simp
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R✝
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R✝ M
inst✝³ : AddCommMonoid M'
inst✝² : Module R✝ M'
b b₁ : Basis ι✝ R✝ M
i✝ : ι✝
c : R✝
x : M
ι : Type u_10
R : Type u_11
inst✝¹ : Unique ι
inst✝ : Semiring R
i : ι
⊢ ↑(Basis.singleton ι R).repr 1 = Finsupp.single i 1
[PROOFSTEP]
simp [Basis.singleton]
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R✝
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R✝ M
inst✝³ : AddCommMonoid M'
inst✝² : Module R✝ M'
b b₁ : Basis ι✝ R✝ M
i✝ : ι✝
c : R✝
x✝ : M
ι : Type u_10
R : Type u_11
inst✝¹ : Unique ι
inst✝ : Semiring R
x : R
i : ι
⊢ ↑(↑(Basis.singleton ι R).repr x) i = x
[PROOFSTEP]
simp [Basis.singleton, Unique.eq_default i]
[GOAL]
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
⊢ Nonempty (Basis ι R M) ↔ ∃ x x_1, ∀ (y : M), ∃ r, r • x = y
[PROOFSTEP]
constructor
[GOAL]
case mp
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
⊢ Nonempty (Basis ι R M) → ∃ x x_1, ∀ (y : M), ∃ r, r • x = y
[PROOFSTEP]
rintro ⟨b⟩
[GOAL]
case mp.intro
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b✝ b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
b : Basis ι R M
⊢ ∃ x x_1, ∀ (y : M), ∃ r, r • x = y
[PROOFSTEP]
refine' ⟨b default, b.linearIndependent.ne_zero _, _⟩
[GOAL]
case mp.intro
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b✝ b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
b : Basis ι R M
⊢ ∀ (y : M), ∃ r, r • ↑b default = y
[PROOFSTEP]
simpa [span_singleton_eq_top_iff, Set.range_unique] using b.span_eq
[GOAL]
case mpr
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
⊢ (∃ x x_1, ∀ (y : M), ∃ r, r • x = y) → Nonempty (Basis ι R M)
[PROOFSTEP]
rintro ⟨x, nz, w⟩
[GOAL]
case mpr.intro.intro
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
⊢ Nonempty (Basis ι R M)
[PROOFSTEP]
refine
⟨ofRepr <|
LinearEquiv.symm
{ toFun := fun f => f default • x
invFun := fun y => Finsupp.single default (w y).choose
left_inv := fun f => Finsupp.unique_ext ?_
right_inv := fun y => ?_
map_add' := fun y z => ?_
map_smul' := fun c y => ?_ }⟩
[GOAL]
case mpr.intro.intro.refine_1
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
y z : ι →₀ R
⊢ (fun f => ↑f default • x) (y + z) = (fun f => ↑f default • x) y + (fun f => ↑f default • x) z
[PROOFSTEP]
simp [Finsupp.add_apply, add_smul]
[GOAL]
case mpr.intro.intro.refine_2
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c✝ : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
c : R
y : ι →₀ R
⊢ AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' := (_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
(c • y) =
↑(RingHom.id R) c •
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' := (_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
y
[PROOFSTEP]
simp only [Finsupp.coe_smul, Pi.smul_apply, RingHom.id_apply]
[GOAL]
case mpr.intro.intro.refine_2
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c✝ : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
c : R
y : ι →₀ R
⊢ (c • ↑y default) • x = c • ↑y default • x
[PROOFSTEP]
rw [← smul_assoc, smul_eq_mul]
[GOAL]
case mpr.intro.intro.refine_3
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
f : ι →₀ R
⊢ ↑((fun y => Finsupp.single default (Exists.choose (_ : ∃ r, r • x = y)))
(AddHom.toFun
{
toAddHom :=
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) },
map_smul' :=
(_ :
∀ (c : R) (y : ι →₀ R),
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
(c • y) =
↑(RingHom.id R) c •
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ :
∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
y) }.toAddHom
f))
default =
↑f default
[PROOFSTEP]
refine' smul_left_injective _ nz _
[GOAL]
case mpr.intro.intro.refine_3
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
f : ι →₀ R
⊢ (fun c => c • x)
(↑((fun y => Finsupp.single default (Exists.choose (_ : ∃ r, r • x = y)))
(AddHom.toFun
{
toAddHom :=
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) },
map_smul' :=
(_ :
∀ (c : R) (y : ι →₀ R),
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ :
∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
(c • y) =
↑(RingHom.id R) c •
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ :
∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
y) }.toAddHom
f))
default) =
(fun c => c • x) (↑f default)
[PROOFSTEP]
simp only [Finsupp.single_eq_same]
[GOAL]
case mpr.intro.intro.refine_3
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
f : ι →₀ R
⊢ Exists.choose
(_ :
∃ r,
r • x =
AddHom.toFun
{
toAddHom :=
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) },
map_smul' :=
(_ :
∀ (c : R) (y : ι →₀ R),
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ :
∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
(c • y) =
↑(RingHom.id R) c •
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ :
∀ (y z : ι →₀ R),
(↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
y) }.toAddHom
f) •
x =
↑f default • x
[PROOFSTEP]
exact (w (f default • x)).choose_spec
[GOAL]
case mpr.intro.intro.refine_4
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
y : M
⊢ AddHom.toFun
{
toAddHom :=
{ toFun := fun f => ↑f default • x,
map_add' := (_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) },
map_smul' :=
(_ :
∀ (c : R) (y : ι →₀ R),
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
(c • y) =
↑(RingHom.id R) c •
AddHom.toFun
{ toFun := fun f => ↑f default • x,
map_add' :=
(_ : ∀ (y z : ι →₀ R), (↑y default + ↑z default) • x = ↑y default • x + ↑z default • x) }
y) }.toAddHom
((fun y => Finsupp.single default (Exists.choose (_ : ∃ r, r • x = y))) y) =
y
[PROOFSTEP]
simp only [Finsupp.single_eq_same]
[GOAL]
case mpr.intro.intro.refine_4
ι✝ : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M✝ : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝¹⁰ : Semiring R✝
inst✝⁹ : AddCommMonoid M✝
inst✝⁸ : Module R✝ M✝
inst✝⁷ : AddCommMonoid M'
inst✝⁶ : Module R✝ M'
b b₁ : Basis ι✝ R✝ M✝
i : ι✝
c : R✝
x✝ : M✝
R : Type u_10
M : Type u_11
inst✝⁵ : Ring R
inst✝⁴ : Nontrivial R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : NoZeroSMulDivisors R M
ι : Type u_12
inst✝ : Unique ι
x : M
nz : x ≠ 0
w : ∀ (y : M), ∃ r, r • x = y
y : M
⊢ Exists.choose (_ : ∃ r, r • x = y) • x = y
[PROOFSTEP]
exact (w y).choose_spec
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
inst✝² : Fintype ι
b✝ b : Basis ι R M
inst✝¹ : Fintype R
inst✝ : Fintype M
⊢ card M = card R ^ card ι
[PROOFSTEP]
classical calc
card M = card (ι → R) := card_congr b.equivFun.toEquiv
_ = card R ^ card ι := card_fun
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
inst✝⁴ : AddCommMonoid M'
inst✝³ : Module R M'
inst✝² : Fintype ι
b✝ b : Basis ι R M
inst✝¹ : Fintype R
inst✝ : Fintype M
⊢ card M = card R ^ card ι
[PROOFSTEP]
calc
card M = card (ι → R) := card_congr b.equivFun.toEquiv
_ = card R ^ card ι := card_fun
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
x : ι → R
⊢ ↑(LinearEquiv.symm (equivFun b)) x = ∑ i : ι, x i • ↑b i
[PROOFSTEP]
simp [Basis.equivFun, Finsupp.total_apply, Finsupp.sum_fintype, Finsupp.equivFunOnFinite]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
u : M
⊢ ∑ i : ι, ↑(equivFun b) u i • ↑b i = u
[PROOFSTEP]
conv_rhs => rw [← b.total_repr u]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
u : M
| u
[PROOFSTEP]
rw [← b.total_repr u]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
u : M
| u
[PROOFSTEP]
rw [← b.total_repr u]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
u : M
| u
[PROOFSTEP]
rw [← b.total_repr u]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
u : M
⊢ ∑ i : ι, ↑(equivFun b) u i • ↑b i = ↑(Finsupp.total ι M R ↑b) (↑b.repr u)
[PROOFSTEP]
simp [Finsupp.total_apply, Finsupp.sum_fintype, b.equivFun_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
inst✝¹ : Fintype ι
b : Basis ι R M
inst✝ : DecidableEq ι
i j : ι
⊢ ↑(equivFun b) (↑b i) j = if i = j then 1 else 0
[PROOFSTEP]
rw [b.equivFun_apply, b.repr_self_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
⊢ ↑(↑b.repr (∑ i : ι, c i • ↑b i)) = c
[PROOFSTEP]
ext j
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j : ι
⊢ ↑(↑b.repr (∑ i : ι, c i • ↑b i)) j = c j
[PROOFSTEP]
simp only [map_sum, LinearEquiv.map_smul, repr_self, Finsupp.smul_single, smul_eq_mul, mul_one, Finset.sum_apply']
[GOAL]
case h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j : ι
⊢ ∑ x : ι, ↑(Finsupp.single x (c x)) j = c j
[PROOFSTEP]
rw [Finset.sum_eq_single j, Finsupp.single_eq_same]
[GOAL]
case h.h₀
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j : ι
⊢ ∀ (b : ι), b ∈ Finset.univ → b ≠ j → ↑(Finsupp.single b (c b)) j = 0
[PROOFSTEP]
rintro i - hi
[GOAL]
case h.h₀
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j i : ι
hi : i ≠ j
⊢ ↑(Finsupp.single i (c i)) j = 0
[PROOFSTEP]
exact Finsupp.single_eq_of_ne hi
[GOAL]
case h.h₁
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j : ι
⊢ ¬j ∈ Finset.univ → ↑(Finsupp.single j (c j)) j = 0
[PROOFSTEP]
intros
[GOAL]
case h.h₁
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j : ι
a✝ : ¬j ∈ Finset.univ
⊢ ↑(Finsupp.single j (c j)) j = 0
[PROOFSTEP]
have := Finset.mem_univ j
[GOAL]
case h.h₁
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
c : ι → R
j : ι
a✝ : ¬j ∈ Finset.univ
this : j ∈ Finset.univ
⊢ ↑(Finsupp.single j (c j)) j = 0
[PROOFSTEP]
contradiction
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
inst✝³ : AddCommMonoid M'
inst✝² : Module R M'
inst✝¹ : Fintype ι
b : Basis ι R M
inst✝ : DecidableEq ι
e : M ≃ₗ[R] ι → R
i j : ι
⊢ ↑e (↑(ofEquivFun e) i) j = ↑e (↑(LinearEquiv.symm e) (update 0 i 1)) j
[PROOFSTEP]
simp [Basis.ofEquivFun, ← Finsupp.single_eq_pi_single, Finsupp.single_eq_update]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b v : Basis ι R M
⊢ ofEquivFun (equivFun v) = v
[PROOFSTEP]
classical
ext j
simp only [Basis.equivFun_symm_apply, Basis.coe_ofEquivFun]
simp_rw [Function.update_apply, ite_smul]
simp only [Finset.mem_univ, if_true, Pi.zero_apply, one_smul, Finset.sum_ite_eq', zero_smul]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b v : Basis ι R M
⊢ ofEquivFun (equivFun v) = v
[PROOFSTEP]
ext j
[GOAL]
case a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b v : Basis ι R M
j : ι
⊢ ↑(ofEquivFun (equivFun v)) j = ↑v j
[PROOFSTEP]
simp only [Basis.equivFun_symm_apply, Basis.coe_ofEquivFun]
[GOAL]
case a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b v : Basis ι R M
j : ι
⊢ ∑ x : ι, update 0 j 1 x • ↑v x = ↑v j
[PROOFSTEP]
simp_rw [Function.update_apply, ite_smul]
[GOAL]
case a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b v : Basis ι R M
j : ι
⊢ (∑ x : ι, if x = j then 1 • ↑v x else OfNat.ofNat 0 x • ↑v x) = ↑v j
[PROOFSTEP]
simp only [Finset.mem_univ, if_true, Pi.zero_apply, one_smul, Finset.sum_ite_eq', zero_smul]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
e : M ≃ₗ[R] ι → R
⊢ equivFun (ofEquivFun e) = e
[PROOFSTEP]
ext j
[GOAL]
case h.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : Semiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
inst✝ : Fintype ι
b : Basis ι R M
e : M ≃ₗ[R] ι → R
j : M
x✝ : ι
⊢ ↑(equivFun (ofEquivFun e)) j x✝ = ↑e j x✝
[PROOFSTEP]
simp_rw [Basis.equivFun_apply, Basis.ofEquivFun_repr_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁸ : Semiring R
inst✝⁷ : AddCommMonoid M
inst✝⁶ : Module R M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : Module R M'
inst✝³ : Fintype ι
b : Basis ι R M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
f : ι → M'
x : M
⊢ ↑(↑(constr b S) f) x = ∑ i : ι, ↑(equivFun b) x i • f i
[PROOFSTEP]
simp [b.constr_apply, b.equivFun_apply, Finsupp.sum_fintype]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁸ : Semiring R
inst✝⁷ : AddCommMonoid M
inst✝⁶ : Module R M
inst✝⁵ : AddCommMonoid M'
inst✝⁴ : Module R M'
inst✝³ : Fintype ι
b✝ : Basis ι R M
S : Type u_10
inst✝² : Semiring S
inst✝¹ : Module S M'
inst✝ : SMulCommClass R S M'
P : Submodule R M
b : Basis ι R { x // x ∈ P }
x : M
c : ι → R
⊢ (x = Finsupp.sum (↑Finsupp.equivFunOnFinite.symm c) fun i x => x • ↑(↑b i)) ↔ x = ∑ i : ι, c i • ↑(↑b i)
[PROOFSTEP]
simp [Finsupp.sum_fintype, Finsupp.equivFunOnFinite]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : CommSemiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b : Basis ι R M
b' : Basis ι' R M'
f : M → M'
g : M' → M
hf : ∀ (i : ι), f (↑b i) ∈ range ↑b'
hg : ∀ (i : ι'), g (↑b' i) ∈ range ↑b
hgf : ∀ (i : ι), g (f (↑b i)) = ↑b i
hfg : ∀ (i : ι'), f (g (↑b' i)) = ↑b' i
src✝ : (fun x => M →ₗ[R] M') (f ∘ ↑b) := ↑(constr b R) (f ∘ ↑b)
i : ι
i' : ι'
hi' : ↑b' i' = f (↑b i)
⊢ ↑(LinearMap.comp (↑(constr b' R) (g ∘ ↑b')) (↑(constr b R) (f ∘ ↑b))) (↑b i) = ↑LinearMap.id (↑b i)
[PROOFSTEP]
rw [LinearMap.comp_apply, b.constr_basis, Function.comp_apply, ← hi', b'.constr_basis, Function.comp_apply, hi', hgf,
LinearMap.id_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁴ : CommSemiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : AddCommMonoid M'
inst✝ : Module R M'
b : Basis ι R M
b' : Basis ι' R M'
f : M → M'
g : M' → M
hf : ∀ (i : ι), f (↑b i) ∈ range ↑b'
hg : ∀ (i : ι'), g (↑b' i) ∈ range ↑b
hgf : ∀ (i : ι), g (f (↑b i)) = ↑b i
hfg : ∀ (i : ι'), f (g (↑b' i)) = ↑b' i
src✝ : (fun x => M →ₗ[R] M') (f ∘ ↑b) := ↑(constr b R) (f ∘ ↑b)
i : ι'
i' : ι
hi' : ↑b i' = g (↑b' i)
⊢ ↑(LinearMap.comp (↑(constr b R) (f ∘ ↑b)) (↑(constr b' R) (g ∘ ↑b'))) (↑b' i) = ↑LinearMap.id (↑b' i)
[PROOFSTEP]
rw [LinearMap.comp_apply, b'.constr_basis, Function.comp_apply, ← hi', b.constr_basis, Function.comp_apply, hi', hfg,
LinearMap.id_apply]
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
⊢ ∑ j : ι', ↑(↑b.repr (↑b' j)) i * ↑(↑b'.repr x) j = ↑(↑b.repr x) i
[PROOFSTEP]
conv_rhs => rw [← b'.sum_repr x]
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
| ↑(↑b.repr x) i
[PROOFSTEP]
rw [← b'.sum_repr x]
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
| ↑(↑b.repr x) i
[PROOFSTEP]
rw [← b'.sum_repr x]
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
| ↑(↑b.repr x) i
[PROOFSTEP]
rw [← b'.sum_repr x]
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
⊢ ∑ j : ι', ↑(↑b.repr (↑b' j)) i * ↑(↑b'.repr x) j = ↑(↑b.repr (∑ i : ι', ↑(↑b'.repr x) i • ↑b' i)) i
[PROOFSTEP]
simp_rw [LinearEquiv.map_sum, LinearEquiv.map_smul, Finset.sum_apply']
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
⊢ ∑ x_1 : ι', ↑(↑b.repr (↑b' x_1)) i * ↑(↑b'.repr x) x_1 = ∑ x_1 : ι', ↑(↑(↑b'.repr x) x_1 • ↑b.repr (↑b' x_1)) i
[PROOFSTEP]
refine' Finset.sum_congr rfl fun j _ => _
[GOAL]
ι : Type u_1
ι'✝ : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝⁵ : CommSemiring R
inst✝⁴ : AddCommMonoid M
inst✝³ : Module R M
inst✝² : AddCommMonoid M'
inst✝¹ : Module R M'
b : Basis ι R M
b'✝ : Basis ι'✝ R M'
ι' : Type u_10
inst✝ : Fintype ι'
b' : Basis ι' R M
x : M
i : ι
j : ι'
x✝ : j ∈ Finset.univ
⊢ ↑(↑b.repr (↑b' j)) i * ↑(↑b'.repr x) j = ↑(↑(↑b'.repr x) j • ↑b.repr (↑b' j)) i
[PROOFSTEP]
rw [Finsupp.smul_apply, smul_eq_mul, mul_comm]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
⊢ Set.range ↑b = w
[PROOFSTEP]
apply le_antisymm h
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
⊢ w ≤ Set.range ↑b
[PROOFSTEP]
intro x p
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
⊢ x ∈ Set.range ↑b
[PROOFSTEP]
by_contra q
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
⊢ False
[PROOFSTEP]
have e := b.total_repr x
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
e : ↑(Finsupp.total ι M R ↑b) (↑b.repr x) = x
⊢ False
[PROOFSTEP]
let u : ι ↪ w := ⟨fun i => ⟨b i, h ⟨i, rfl⟩⟩, fun i i' r => b.injective (by simpa only [Subtype.mk_eq_mk] using r)⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
e : ↑(Finsupp.total ι M R ↑b) (↑b.repr x) = x
i i' : ι
r : (fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i = (fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i'
⊢ ↑b i = ↑b i'
[PROOFSTEP]
simpa only [Subtype.mk_eq_mk] using r
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
e : ↑(Finsupp.total ι M R ↑b) (↑b.repr x) = x
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
⊢ False
[PROOFSTEP]
simp_rw [Finsupp.total_apply] at e
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
e : (Finsupp.sum (↑b.repr x) fun i a => a • ↑b i) = x
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
⊢ False
[PROOFSTEP]
change ((b.repr x).sum fun (i : ι) (a : R) ↦ a • (u i : M)) = ((⟨x, p⟩ : w) : M) at e
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
e : (Finsupp.sum (↑b.repr x) fun i a => a • ↑(↑u i)) = ↑{ val := x, property := p }
⊢ False
[PROOFSTEP]
rw [← Finsupp.sum_embDomain (f := u) (g := fun x r ↦ r • (x : M)), ← Finsupp.total_apply] at e
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
e : ↑(Finsupp.total (↑w) M R fun x => ↑x) (Finsupp.embDomain u (↑b.repr x)) = ↑{ val := x, property := p }
⊢ False
[PROOFSTEP]
refine' hi.total_ne_of_not_mem_support _ _ e
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
e : ↑(Finsupp.total (↑w) M R fun x => ↑x) (Finsupp.embDomain u (↑b.repr x)) = ↑{ val := x, property := p }
⊢ ¬{ val := x, property := p } ∈ (Finsupp.embDomain u (↑b.repr x)).support
[PROOFSTEP]
simp only [Finset.mem_map, Finsupp.support_embDomain]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
e : ↑(Finsupp.total (↑w) M R fun x => ↑x) (Finsupp.embDomain u (↑b.repr x)) = ↑{ val := x, property := p }
⊢ ¬∃ a,
a ∈ (↑b.repr x).support ∧
↑{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
a =
{ val := x, property := p }
[PROOFSTEP]
rintro ⟨j, -, W⟩
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
e : ↑(Finsupp.total (↑w) M R fun x => ↑x) (Finsupp.embDomain u (↑b.repr x)) = ↑{ val := x, property := p }
j : ι
W :
↑{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
j =
{ val := x, property := p }
⊢ False
[PROOFSTEP]
simp only [Embedding.coeFn_mk, Subtype.mk_eq_mk] at W
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x✝ y : M
b✝ : Basis ι R M
inst✝ : Nontrivial R
b : Basis ι R M
w : Set M
hi : LinearIndependent R Subtype.val
h : Set.range ↑b ≤ w
x : M
p : x ∈ w
q : ¬x ∈ Set.range ↑b
u : ι ↪ ↑w :=
{ toFun := fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) },
inj' :=
(_ :
∀ (i i' : ι),
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i =
(fun i => { val := ↑b i, property := (_ : ↑b i ∈ w) }) i' →
i = i') }
e : ↑(Finsupp.total (↑w) M R fun x => ↑x) (Finsupp.embDomain u (↑b.repr x)) = ↑{ val := x, property := p }
j : ι
W : ↑b j = x
⊢ False
[PROOFSTEP]
apply q ⟨j, W⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
hsp : ⊤ ≤ span R (Set.range v)
i : ι
⊢ ↑(Finsupp.total ι M R v) (Finsupp.single i 1) = v i
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
hsp : ⊤ ≤ span R (Set.range v)
i : ι
⊢ ↑(↑(LinearIndependent.repr hli) { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) }) i = 1
[PROOFSTEP]
simp [hli.repr_eq_single i]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
hsp : ⊤ ≤ span R (Set.range v)
i j : ι
h : j ≠ i
⊢ ↑(↑(LinearIndependent.repr hli) { val := v j, property := (_ : v j ∈ ↑(span R (Set.range v))) }) i = 0
[PROOFSTEP]
simp [hli.repr_eq_single j, h]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
hsp : ⊤ ≤ span R (Set.range v)
inst✝ : DecidableEq ι
i j : ι
⊢ ↑(coord (Basis.mk hli hsp) i) (v j) = if j = i then 1 else 0
[PROOFSTEP]
cases' eq_or_ne j i with h h
[GOAL]
case inl
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
hsp : ⊤ ≤ span R (Set.range v)
inst✝ : DecidableEq ι
i j : ι
h : j = i
⊢ ↑(coord (Basis.mk hli hsp) i) (v j) = if j = i then 1 else 0
[PROOFSTEP]
simp only [h, if_true, eq_self_iff_true, mk_coord_apply_eq i]
[GOAL]
case inr
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M
inst✝³ : Module R₂ M
inst✝² : Module R M'
inst✝¹ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
hsp : ⊤ ≤ span R (Set.range v)
inst✝ : DecidableEq ι
i j : ι
h : j ≠ i
⊢ ↑(coord (Basis.mk hli hsp) i) (v j) = if j = i then 1 else 0
[PROOFSTEP]
simp only [h, if_false, mk_coord_apply_ne h]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
hli : LinearIndependent R v
⊢ ⊤ ≤ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
intro x _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
have : ∀ i, v i ∈ span R (range v) := fun i ↦ subset_span (Set.mem_range_self _)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
have h₁ : (((↑) : span R (range v) → M) '' range fun i => ⟨v i, this i⟩) = range v :=
by
simp only [SetLike.coe_sort_coe, ← Set.range_comp]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
⊢ (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
[PROOFSTEP]
simp only [SetLike.coe_sort_coe, ← Set.range_comp]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
⊢ Set.range (Subtype.val ∘ fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
have h₂ : map (Submodule.subtype (span R (range v))) (span R (range fun i => ⟨v i, this i⟩)) = span R (range v) :=
by
rw [← span_image, Submodule.coeSubtype]
-- Porting note: why doesn't `rw [h₁]` work here?
exact congr_arg _ h₁
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
⊢ map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
[PROOFSTEP]
rw [← span_image, Submodule.coeSubtype]
-- Porting note: why doesn't `rw [h₁]` work here?
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
⊢ span R (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) =
span R (Set.range v)
[PROOFSTEP]
exact congr_arg _ h₁
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
have h₃ : (x : M) ∈ map (Submodule.subtype (span R (range v))) (span R (Set.range fun i => Subtype.mk (v i) _)) :=
by
rw [h₂]
apply Subtype.mem x
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
⊢ ↑x ∈
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : ?m.886970 (v i)) }))
[PROOFSTEP]
rw [h₂]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
⊢ ↑x ∈ span R (Set.range v)
[PROOFSTEP]
apply Subtype.mem x
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
h₃ :
↑x ∈
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }))
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
rcases mem_map.1 h₃ with ⟨y, hy₁, hy₂⟩
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y✝ : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
h₃ :
↑x ∈
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }))
y : { x // x ∈ span R (Set.range v) }
hy₁ : y ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })
hy₂ : ↑(Submodule.subtype (span R (Set.range v))) y = ↑x
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
have h_x_eq_y : x = y := by
rw [Subtype.ext_iff, ← hy₂]
simp
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y✝ : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
h₃ :
↑x ∈
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }))
y : { x // x ∈ span R (Set.range v) }
hy₁ : y ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })
hy₂ : ↑(Submodule.subtype (span R (Set.range v))) y = ↑x
⊢ x = y
[PROOFSTEP]
rw [Subtype.ext_iff, ← hy₂]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y✝ : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
h₃ :
↑x ∈
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }))
y : { x // x ∈ span R (Set.range v) }
hy₁ : y ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })
hy₂ : ↑(Submodule.subtype (span R (Set.range v))) y = ↑x
⊢ ↑(Submodule.subtype (span R (Set.range v))) y = ↑y
[PROOFSTEP]
simp
[GOAL]
case intro.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝ y✝ : M
b : Basis ι R M
hli : LinearIndependent R v
x : { x // x ∈ span R (Set.range v) }
a✝ : x ∈ ⊤
this : ∀ (i : ι), v i ∈ span R (Set.range v)
h₁ : (Subtype.val '' Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }) = Set.range v
h₂ :
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })) =
span R (Set.range v)
h₃ :
↑x ∈
map (Submodule.subtype (span R (Set.range v)))
(span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) }))
y : { x // x ∈ span R (Set.range v) }
hy₁ : y ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ span R (Set.range v)) })
hy₂ : ↑(Submodule.subtype (span R (Set.range v))) y = ↑x
h_x_eq_y : x = y
⊢ x ∈ span R (Set.range fun i => { val := v i, property := (_ : v i ∈ ↑(span R (Set.range v))) })
[PROOFSTEP]
rwa [h_x_eq_y]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
⊢ span R (Set.range (w • v)) = ⊤
[PROOFSTEP]
rw [eq_top_iff]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
⊢ ⊤ ≤ span R (Set.range (w • v))
[PROOFSTEP]
intro j hj
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
j : M
hj : j ∈ ⊤
⊢ j ∈ span R (Set.range (w • v))
[PROOFSTEP]
rw [← hv] at hj
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
j : M
hj : j ∈ span R (Set.range v)
⊢ j ∈ span R (Set.range (w • v))
[PROOFSTEP]
rw [Submodule.mem_span] at hj ⊢
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
j : M
hj : ∀ (p : Submodule R M), Set.range v ⊆ ↑p → j ∈ p
⊢ ∀ (p : Submodule R M), Set.range (w • v) ⊆ ↑p → j ∈ p
[PROOFSTEP]
refine' fun p hp => hj p fun u hu => _
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
j : M
hj : ∀ (p : Submodule R M), Set.range v ⊆ ↑p → j ∈ p
p : Submodule R M
hp : Set.range (w • v) ⊆ ↑p
u : M
hu : u ∈ Set.range v
⊢ u ∈ ↑p
[PROOFSTEP]
obtain ⟨i, rfl⟩ := hu
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
j : M
hj : ∀ (p : Submodule R M), Set.range v ⊆ ↑p → j ∈ p
p : Submodule R M
hp : Set.range (w • v) ⊆ ↑p
i : ι
⊢ v i ∈ ↑p
[PROOFSTEP]
have : ((w i)⁻¹ • (1 : R)) • w i • v i ∈ p := p.smul_mem ((w i)⁻¹ • (1 : R)) (hp ⟨i, rfl⟩)
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v✝ : ι → M
inst✝¹² : Ring R
inst✝¹¹ : CommRing R₂
inst✝¹⁰ : AddCommGroup M
inst✝⁹ : AddCommGroup M'
inst✝⁸ : AddCommGroup M''
inst✝⁷ : Module R M
inst✝⁶ : Module R₂ M
inst✝⁵ : Module R M'
inst✝⁴ : Module R M''
c d : R
x y : M
b : Basis ι R M
G : Type u_10
inst✝³ : Group G
inst✝² : DistribMulAction G R
inst✝¹ : DistribMulAction G M
inst✝ : IsScalarTower G R M
v : ι → M
hv : span R (Set.range v) = ⊤
w : ι → G
j : M
hj : ∀ (p : Submodule R M), Set.range v ⊆ ↑p → j ∈ p
p : Submodule R M
hp : Set.range (w • v) ⊆ ↑p
i : ι
this : ((w i)⁻¹ • 1) • w i • v i ∈ p
⊢ v i ∈ ↑p
[PROOFSTEP]
rwa [smul_one_smul, inv_smul_smul] at this
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i : ι
⊢ coord (unitsSMul e w) i = (w i)⁻¹ • coord e i
[PROOFSTEP]
classical
apply e.ext
intro j
trans ((unitsSMul e w).coord i) ((w j)⁻¹ • (unitsSMul e w) j)
· congr
simp [Basis.unitsSMul, ← mul_smul]
simp only [Basis.coord_apply, LinearMap.smul_apply, Basis.repr_self, Units.smul_def, SMulHomClass.map_smul,
Finsupp.single_apply]
split_ifs with h <;> simp [h]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i : ι
⊢ coord (unitsSMul e w) i = (w i)⁻¹ • coord e i
[PROOFSTEP]
apply e.ext
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i : ι
⊢ ∀ (i_1 : ι), ↑(coord (unitsSMul e w) i) (↑e i_1) = ↑((w i)⁻¹ • coord e i) (↑e i_1)
[PROOFSTEP]
intro j
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
⊢ ↑(coord (unitsSMul e w) i) (↑e j) = ↑((w i)⁻¹ • coord e i) (↑e j)
[PROOFSTEP]
trans ((unitsSMul e w).coord i) ((w j)⁻¹ • (unitsSMul e w) j)
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
⊢ ↑(coord (unitsSMul e w) i) (↑e j) = ↑(coord (unitsSMul e w) i) ((w j)⁻¹ • ↑(unitsSMul e w) j)
[PROOFSTEP]
congr
[GOAL]
case h.e_6.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
⊢ ↑e j = (w j)⁻¹ • ↑(unitsSMul e w) j
[PROOFSTEP]
simp [Basis.unitsSMul, ← mul_smul]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
⊢ ↑(coord (unitsSMul e w) i) ((w j)⁻¹ • ↑(unitsSMul e w) j) = ↑((w i)⁻¹ • coord e i) (↑e j)
[PROOFSTEP]
simp only [Basis.coord_apply, LinearMap.smul_apply, Basis.repr_self, Units.smul_def, SMulHomClass.map_smul,
Finsupp.single_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
⊢ ↑(↑(w j)⁻¹ • Finsupp.single j 1) i = ↑(w i)⁻¹ • if j = i then 1 else 0
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
h : j = i
⊢ ↑(↑(w j)⁻¹ • Finsupp.single j 1) i = ↑(w i)⁻¹ • 1
[PROOFSTEP]
simp [h]
[GOAL]
case neg
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y : M
b : Basis ι R M
e : Basis ι R₂ M
w : ι → R₂ˣ
i j : ι
h : ¬j = i
⊢ ↑(↑(w j)⁻¹ • Finsupp.single j 1) i = ↑(w i)⁻¹ • 0
[PROOFSTEP]
simp [h]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
⊢ span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N
[PROOFSTEP]
rw [Set.range_comp, Submodule.span_image, b.span_eq, Submodule.map_subtype_top]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
span_b : span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N
⊢ ∀ (c : R) (y_1 : { x // x ∈ span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) }), c • y + ↑y_1 = 0 → c = 0
[PROOFSTEP]
rintro c ⟨x, hx⟩ hc
[GOAL]
case mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c✝ d : R
x✝ y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
span_b : span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N
c : R
x : M
hx : x ∈ span R (Set.range (↑(Submodule.subtype N) ∘ ↑b))
hc : c • y + ↑{ val := x, property := hx } = 0
⊢ c = 0
[PROOFSTEP]
rw [span_b] at hx
[GOAL]
case mk
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c✝ d : R
x✝ y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
span_b : span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N
c : R
x : M
hx✝ : x ∈ span R (Set.range (↑(Submodule.subtype N) ∘ ↑b))
hx : x ∈ N
hc : c • y + ↑{ val := x, property := hx✝ } = 0
⊢ c = 0
[PROOFSTEP]
exact hli c x hx hc
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝¹ y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
span_b : span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N
x : M
x✝ : x ∈ ⊤
⊢ x ∈ span R (Set.range (Fin.cons y (↑(Submodule.subtype N) ∘ ↑b)))
[PROOFSTEP]
rw [Fin.range_cons, Submodule.mem_span_insert', span_b]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x✝¹ y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
span_b : span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N
x : M
x✝ : x ∈ ⊤
⊢ ∃ a, x + a • y ∈ N
[PROOFSTEP]
exact hsp x
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
⊢ ↑(mkFinCons y b hli hsp) = Fin.cons y (Subtype.val ∘ ↑b)
[PROOFSTEP]
unfold mkFinCons
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁸ : Ring R
inst✝⁷ : CommRing R₂
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup M'
inst✝⁴ : AddCommGroup M''
inst✝³ : Module R M
inst✝² : Module R₂ M
inst✝¹ : Module R M'
inst✝ : Module R M''
c d : R
x y✝ : M
b✝ : Basis ι R M
n : ℕ
N : Submodule R M
y : M
b : Basis (Fin n) R { x // x ∈ N }
hli : ∀ (c : R) (x : M), x ∈ N → c • y + x = 0 → c = 0
hsp : ∀ (z : M), ∃ c, z + c • y ∈ N
⊢ ↑(let_fun span_b := (_ : span R (Set.range (↑(Submodule.subtype N) ∘ ↑b)) = N);
Basis.mk (_ : LinearIndependent R (Fin.cons y (↑(Submodule.subtype N) ∘ ↑b)))
(_ : ∀ (x : M), x ∈ ⊤ → x ∈ span R (Set.range (Fin.cons y (↑(Submodule.subtype N) ∘ ↑b))))) =
Fin.cons y (Subtype.val ∘ ↑b)
[PROOFSTEP]
exact coe_mk (v := Fin.cons y (N.subtype ∘ b)) _ _
[GOAL]
ι : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R✝
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R✝ M
inst✝³ : Module R₂ M
inst✝² : Module R✝ M'
inst✝¹ : Module R✝ M''
c d : R✝
x y : M
b : Basis ι R✝ M
R : Type u_10
inst✝ : Semiring R
⊢ ↑(Basis.finTwoProd R) 0 = (1, 0)
[PROOFSTEP]
simp [Basis.finTwoProd, LinearEquiv.finTwoArrow]
[GOAL]
ι : Type u_1
ι' : Type u_2
R✝ : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
v : ι → M
inst✝⁹ : Ring R✝
inst✝⁸ : CommRing R₂
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R✝ M
inst✝³ : Module R₂ M
inst✝² : Module R✝ M'
inst✝¹ : Module R✝ M''
c d : R✝
x y : M
b : Basis ι R✝ M
R : Type u_10
inst✝ : Semiring R
⊢ ↑(Basis.finTwoProd R) 1 = (0, 1)
[PROOFSTEP]
simp [Basis.finTwoProd, LinearEquiv.finTwoArrow]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
⊢ P N
[PROOFSTEP]
haveI : DecidableEq M := Classical.decEq M
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
⊢ P N
[PROOFSTEP]
have Pbot : P ⊥ := by
apply ih
intro N _ x x_mem x_ortho
exfalso
rw [mem_bot] at x_mem
simpa [x_mem] using x_ortho 1 0 N.zero_mem
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
⊢ P ⊥
[PROOFSTEP]
apply ih
[GOAL]
case a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
⊢ (N' : Submodule R M) → N' ≤ ⊥ → (x : M) → x ∈ ⊥ → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N'
[PROOFSTEP]
intro N _ x x_mem x_ortho
[GOAL]
case a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N✝ : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
N : Submodule R M
a✝ : N ≤ ⊥
x : M
x_mem : x ∈ ⊥
x_ortho : ∀ (c : R) (y : M), y ∈ N → c • x + y = 0 → c = 0
⊢ P N
[PROOFSTEP]
exfalso
[GOAL]
case a.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N✝ : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
N : Submodule R M
a✝ : N ≤ ⊥
x : M
x_mem : x ∈ ⊥
x_ortho : ∀ (c : R) (y : M), y ∈ N → c • x + y = 0 → c = 0
⊢ False
[PROOFSTEP]
rw [mem_bot] at x_mem
[GOAL]
case a.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N✝ : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
N : Submodule R M
a✝ : N ≤ ⊥
x : M
x_mem : x = 0
x_ortho : ∀ (c : R) (y : M), y ∈ N → c • x + y = 0 → c = 0
⊢ False
[PROOFSTEP]
simpa [x_mem] using x_ortho 1 0 N.zero_mem
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
Pbot : P ⊥
⊢ P N
[PROOFSTEP]
induction' n with n rank_ih generalizing N
[GOAL]
case zero
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
Pbot : P ⊥
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.zero
⊢ P N
[PROOFSTEP]
suffices N = ⊥ by rwa [this]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this✝ : DecidableEq M
Pbot : P ⊥
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.zero
this : N = ⊥
⊢ P N
[PROOFSTEP]
rwa [this]
[GOAL]
case zero
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
this : DecidableEq M
Pbot : P ⊥
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.zero
⊢ N = ⊥
[PROOFSTEP]
apply Basis.eq_bot_of_rank_eq_zero b _ fun m hv => le_zero_iff.mp (rank_le _ hv)
[GOAL]
case succ
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
⊢ P N
[PROOFSTEP]
apply ih
[GOAL]
case succ.a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
⊢ (N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N'
[PROOFSTEP]
intro N' N'_le x x_mem x_ortho
[GOAL]
case succ.a
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
⊢ P N'
[PROOFSTEP]
apply rank_ih
[GOAL]
case succ.a.rank_le
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
⊢ ∀ {m : ℕ} (v : Fin m → { x // x ∈ N' }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n
[PROOFSTEP]
intro m v hli
[GOAL]
case succ.a.rank_le
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
⊢ m ≤ n
[PROOFSTEP]
refine' Nat.succ_le_succ_iff.mp (rank_le (Fin.cons ⟨x, x_mem⟩ fun i => ⟨v i, N'_le (v i).2⟩) _)
[GOAL]
case succ.a.rank_le
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
⊢ LinearIndependent R
(Subtype.val ∘ Fin.cons { val := x, property := x_mem } fun i => { val := ↑(v i), property := (_ : ↑(v i) ∈ ?N) })
[PROOFSTEP]
convert hli.fin_cons' x _ ?_
[GOAL]
case h.e'_4
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
⊢ (Subtype.val ∘ Fin.cons { val := x, property := x_mem } fun i => { val := ↑(v i), property := (_ : ↑(v i) ∈ ?N) }) =
Fin.cons x (Subtype.val ∘ v)
[PROOFSTEP]
ext i
[GOAL]
case h.e'_4.h
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
i : Fin (Nat.succ m)
⊢ (Subtype.val ∘ Fin.cons { val := x, property := x_mem } fun i => { val := ↑(v i), property := (_ : ↑(v i) ∈ ?N) }) i =
Fin.cons x (Subtype.val ∘ v) i
[PROOFSTEP]
refine' Fin.cases _ _ i
[GOAL]
case h.e'_4.h.refine'_1
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
i : Fin (Nat.succ m)
⊢ (Subtype.val ∘ Fin.cons { val := x, property := x_mem } fun i => { val := ↑(v i), property := (_ : ↑(v i) ∈ ?N) }) 0 =
Fin.cons x (Subtype.val ∘ v) 0
[PROOFSTEP]
simp
[GOAL]
case h.e'_4.h.refine'_2
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
i : Fin (Nat.succ m)
⊢ ∀ (i : Fin m),
(Subtype.val ∘ Fin.cons { val := x, property := x_mem } fun i => { val := ↑(v i), property := (_ : ↑(v i) ∈ ?N) })
(Fin.succ i) =
Fin.cons x (Subtype.val ∘ v) (Fin.succ i)
[PROOFSTEP]
simp
[GOAL]
case succ.a.rank_le
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
⊢ ∀ (c : R) (y : { x // x ∈ span R (range (Subtype.val ∘ v)) }), c • x + ↑y = 0 → c = 0
[PROOFSTEP]
intro c y hcy
[GOAL]
case succ.a.rank_le
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
c : R
y : { x // x ∈ span R (range (Subtype.val ∘ v)) }
hcy : c • x + ↑y = 0
⊢ c = 0
[PROOFSTEP]
refine' x_ortho c y (Submodule.span_le.mpr _ y.2) hcy
[GOAL]
case succ.a.rank_le
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
c : R
y : { x // x ∈ span R (range (Subtype.val ∘ v)) }
hcy : c • x + ↑y = 0
⊢ range (Subtype.val ∘ v) ⊆ ↑N'
[PROOFSTEP]
rintro _ ⟨z, rfl⟩
[GOAL]
case succ.a.rank_le.intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
inst✝³ : Ring R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
b✝ : ι → M
b : Basis ι R M
P : Submodule R M → Sort u_10
ih :
(N : Submodule R M) →
((N' : Submodule R M) → N' ≤ N → (x : M) → x ∈ N → (∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0) → P N') → P N
n✝ : ℕ
N✝ : Submodule R M
rank_le✝ : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N✝ }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n✝
this : DecidableEq M
Pbot : P ⊥
n : ℕ
rank_ih :
(N : Submodule R M) → (∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ n) → P N
N : Submodule R M
rank_le : ∀ {m : ℕ} (v : Fin m → { x // x ∈ N }), LinearIndependent R (Subtype.val ∘ v) → m ≤ Nat.succ n
N' : Submodule R M
N'_le : N' ≤ N
x : M
x_mem : x ∈ N
x_ortho : ∀ (c : R) (y : M), y ∈ N' → c • x + y = 0 → c = 0
m : ℕ
v : Fin m → { x // x ∈ N' }
hli : LinearIndependent R (Subtype.val ∘ v)
c : R
y : { x // x ∈ span R (range (Subtype.val ∘ v)) }
hcy : c • x + ↑y = 0
z : Fin m
⊢ (Subtype.val ∘ v) z ∈ ↑N'
[PROOFSTEP]
exact (v z).2
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
i : ι
⊢ ↑(↑(restrictScalars R b) i) = ↑b i
[PROOFSTEP]
simp only [Basis.restrictScalars, Basis.span_apply]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : { x // x ∈ span R (range ↑b) }
i : ι
⊢ ↑(algebraMap R S) (↑(↑(restrictScalars R b).repr m) i) = ↑(↑b.repr ↑m) i
[PROOFSTEP]
suffices
Finsupp.mapRange.linearMap (Algebra.linearMap R S) ∘ₗ (b.restrictScalars R).repr.toLinearMap =
((b.repr : M →ₗ[S] ι →₀ S).restrictScalars R).domRestrict _
by exact FunLike.congr_fun (LinearMap.congr_fun this m) i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : { x // x ∈ span R (range ↑b) }
i : ι
this :
LinearMap.comp (Finsupp.mapRange.linearMap (Algebra.linearMap R S)) ↑(restrictScalars R b).repr =
LinearMap.domRestrict (↑R ↑b.repr) (span R (range ↑b))
⊢ ↑(algebraMap R S) (↑(↑(restrictScalars R b).repr m) i) = ↑(↑b.repr ↑m) i
[PROOFSTEP]
exact FunLike.congr_fun (LinearMap.congr_fun this m) i
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : { x // x ∈ span R (range ↑b) }
i : ι
⊢ LinearMap.comp (Finsupp.mapRange.linearMap (Algebra.linearMap R S)) ↑(restrictScalars R b).repr =
LinearMap.domRestrict (↑R ↑b.repr) (span R (range ↑b))
[PROOFSTEP]
refine Basis.ext (b.restrictScalars R) fun _ => ?_
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : { x // x ∈ span R (range ↑b) }
i x✝ : ι
⊢ ↑(LinearMap.comp (Finsupp.mapRange.linearMap (Algebra.linearMap R S)) ↑(restrictScalars R b).repr)
(↑(restrictScalars R b) x✝) =
↑(LinearMap.domRestrict (↑R ↑b.repr) (span R (range ↑b))) (↑(restrictScalars R b) x✝)
[PROOFSTEP]
simp only [LinearMap.coe_comp, LinearEquiv.coe_toLinearMap, Function.comp_apply, map_one, Basis.repr_self,
Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Algebra.linearMap_apply, LinearMap.domRestrict_apply,
LinearEquiv.coe_coe, Basis.restrictScalars_apply, LinearMap.coe_restrictScalars]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : M
⊢ m ∈ span R (range ↑b) ↔ ∀ (i : ι), ↑(↑b.repr m) i ∈ range ↑(algebraMap R S)
[PROOFSTEP]
refine ⟨fun hm i => ⟨(b.restrictScalars R).repr ⟨m, hm⟩ i, b.restrictScalars_repr_apply R ⟨m, hm⟩ i⟩, fun h => ?_⟩
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : M
h : ∀ (i : ι), ↑(↑b.repr m) i ∈ range ↑(algebraMap R S)
⊢ m ∈ span R (range ↑b)
[PROOFSTEP]
rw [← b.total_repr m, Finsupp.total_apply S _]
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : M
h : ∀ (i : ι), ↑(↑b.repr m) i ∈ range ↑(algebraMap R S)
⊢ (Finsupp.sum (↑b.repr m) fun i a => a • ↑b i) ∈ span R (range ↑b)
[PROOFSTEP]
refine sum_mem fun i _ => ?_
[GOAL]
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : M
h : ∀ (i : ι), ↑(↑b.repr m) i ∈ range ↑(algebraMap R S)
i : ι
x✝ : i ∈ (↑b.repr m).support
⊢ (fun i a => a • ↑b i) i (↑(↑b.repr m) i) ∈ span R (range ↑b)
[PROOFSTEP]
obtain ⟨_, h⟩ := h i
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : M
h✝ : ∀ (i : ι), ↑(↑b.repr m) i ∈ range ↑(algebraMap R S)
i : ι
x✝ : i ∈ (↑b.repr m).support
w✝ : R
h : ↑(algebraMap R S) w✝ = ↑(↑b.repr m) i
⊢ (fun i a => a • ↑b i) i (↑(↑b.repr m) i) ∈ span R (range ↑b)
[PROOFSTEP]
simp_rw [← h, algebraMap_smul]
[GOAL]
case intro
ι : Type u_1
ι' : Type u_2
R : Type u_3
R₂ : Type u_4
K : Type u_5
M : Type u_6
M' : Type u_7
M'' : Type u_8
V : Type u
V' : Type u_9
S : Type u_10
inst✝⁸ : CommRing R
inst✝⁷ : Ring S
inst✝⁶ : Nontrivial S
inst✝⁵ : AddCommGroup M
inst✝⁴ : Algebra R S
inst✝³ : Module S M
inst✝² : Module R M
inst✝¹ : IsScalarTower R S M
inst✝ : NoZeroSMulDivisors R S
b : Basis ι S M
m : M
h✝ : ∀ (i : ι), ↑(↑b.repr m) i ∈ range ↑(algebraMap R S)
i : ι
x✝ : i ∈ (↑b.repr m).support
w✝ : R
h : ↑(algebraMap R S) w✝ = ↑(↑b.repr m) i
⊢ w✝ • ↑b i ∈ span R (range ↑b)
[PROOFSTEP]
exact smul_mem _ _ (subset_span (Set.mem_range_self i))
|
probs <- read.table("D:/_tmp/tst_probsconfirmtst.txt", header = F)$V1
plot(probs, type='l'); abline(h=0.004)
tchps = read.table("D:/DATASETS/UKTraffic/TrueChanges.txt", header = F)$V1
#plot(ttt, type = 'l', xlim = c(1, 3000)); abline(v = tchps, col = "red")
#tchps[4]
#plot(ttt, type = 'l', xlim = c(8000, 10000)); abline(v = tchps, col = "red"); abline(h = 0.004);
predicted = read.table("D:/_tmp/tst_predictedtps0.txt", header = F)$V1
detections = read.table("D:/_tmp/tst_detections.txt", header = F)$V1
plot(ttt, type = 'l', xlim = c(1000, 5000)); abline(v = tchps, col = "red"); abline(h = 0.004);
abline(v = detections, col ="green")
abline(v = predicted , col = "blue")
|
lemma lift_trans_bigtheta: assumes "f \<in> L F (g)" assumes "(\<lambda>x. t x (g x)) \<in> \<Theta>[F](h)" assumes "\<And>f g. f \<in> L F (g) \<Longrightarrow> (\<lambda>x. t x (f x)) \<in> L F (\<lambda>x. t x (g x))" shows "(\<lambda>x. t x (f x)) \<in> L F (h)" |
" [ Peters ] coins the phrase , ' turnspeak ' , she says she 's using it as a play off of George Orwell which as all listeners know used the phrase ' <unk> . ' She coined her own phrase , ' turnspeak ' . You go to Mr. Dershowitz 's book , he got so confused in his massive borrowings from Joan Peters that on two occasions , I 'll cite them for those who have a copy of the book , on page 57 and on page 153 he uses the phrase , quote , George Orwell 's ' turnspeak ' . ' <unk> ' is not Orwell , Mr. Dershowitz , you 're the Felix Frankfurter chair at Harvard , you must know that Orwell would never use such a clunky phrase as ' turnspeak ' " .
|
lemma connected_iff_interval: "connected U \<longleftrightarrow> (\<forall>x\<in>U. \<forall>y\<in>U. \<forall>z. x \<le> z \<longrightarrow> z \<le> y \<longrightarrow> z \<in> U)" for U :: "'a::linear_continuum_topology set" |
[STATEMENT]
lemma deformation_retract_relative_homology_group_isomorphisms:
"\<lbrakk>retraction_maps X Y r id; V \<subseteq> U; r ` U \<subseteq> V; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X r id\<rbrakk>
\<Longrightarrow> group_isomorphisms (relative_homology_group p X U) (relative_homology_group p Y V)
(hom_induced p X U Y V r) (hom_induced p Y V X U id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>retraction_maps X Y r id; V \<subseteq> U; r ` U \<subseteq> V; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X r id\<rbrakk> \<Longrightarrow> group_isomorphisms (relative_homology_group p X U) (relative_homology_group p Y V) (hom_induced p X U Y V r) (hom_induced p Y V X U id)
[PROOF STEP]
by (simp add: deformation_retraction_relative_homology_group_isomorphisms) |
On Sunday, June 19th, it will be Fathers Day. If you have photos of a father in Davis, upload them here, and well use them as the Wiki Logo logo header for the wiki as a celebration of the fathers of Davis!
To upload a file, just click the Edit icon in the light blue bar above, and then look for the Upload Files button under the editor.
Image(fathers day.jpeg) Users/SueHjerpe
|
module WebAssembly.Structure
import public WebAssembly.Structure.Values
import public WebAssembly.Structure.Types
import public WebAssembly.Structure.Instructions
import public WebAssembly.Structure.Modules
|
(* Distributed under the terms of the MIT license. *)
From Coq Require Import Utf8 CRelationClasses ProofIrrelevance.
From MetaCoq.Template Require Import config Universes utils BasicAst.
From MetaCoq.PCUIC Require Import PCUICAst PCUICAstUtils PCUICTactics PCUICInduction
PCUICReflect PCUICLiftSubst PCUICSigmaCalculus
PCUICUnivSubst PCUICTyping PCUICUnivSubstitutionConv PCUICUnivSubstitutionTyp
PCUICCumulativity PCUICPosition PCUICEquality
PCUICInversion PCUICCumulativity PCUICReduction
PCUICCasesContexts
PCUICConfluence PCUICParallelReductionConfluence PCUICConversion PCUICContextConversion
PCUICContextConversionTyp
PCUICWeakeningEnvConv PCUICWeakeningEnvTyp
PCUICClosed PCUICClosedTyp PCUICSubstitution PCUICContextSubst
PCUICWellScopedCumulativity
PCUICWeakeningConv PCUICWeakeningTyp PCUICGeneration PCUICUtils PCUICContexts
PCUICArities.
Require Import Equations.Prop.DepElim.
Require Import Equations.Type.Relation_Properties.
From Equations Require Import Equations.
Require Import ssreflect ssrbool.
Implicit Types (cf : checker_flags) (Σ : global_env_ext).
Derive Signature for ctx_inst.
Notation ctx_inst := (ctx_inst typing).
Ltac splits := repeat split.
Notation spnil isty isty' w := (type_spine_nil _ isty isty' w).
Arguments type_spine_cons {cf Σ Γ ty hd tl na A B B'} : rename.
Notation spcons isty isty' w tyhd sp := (@type_spine_cons _ _ _ _ _ _ _ _ _ _ isty isty' w tyhd sp).
Lemma typing_spine_eq {cf:checker_flags} Σ Γ ty s s' ty' :
s = s' ->
typing_spine Σ Γ ty s ty' ->
typing_spine Σ Γ ty s' ty'.
Proof. now intros ->. Qed.
Lemma All2_fold_mapi_right P (Γ Δ : context) g :
All2_fold (fun Γ Δ d d' =>
P Γ (mapi_context g Δ) d (map_decl (g #|Γ|) d')) Γ Δ
-> All2_fold P Γ (mapi_context g Δ).
Proof.
induction 1; simpl; constructor; intuition auto;
now rewrite <-(All2_fold_length X).
Qed.
Import PCUICOnFreeVars.
Lemma weakening_closed_red {cf} {Σ} {wfΣ : wf Σ} {Γ Γ' Γ'' M N} :
Σ ;;; Γ ,,, Γ' ⊢ M ⇝ N ->
is_closed_context (Γ ,,, Γ'') ->
Σ ;;; Γ ,,, Γ'' ,,, lift_context #|Γ''| 0 Γ' ⊢ lift #|Γ''| #|Γ'| M ⇝ lift #|Γ''| #|Γ'| N.
Proof.
intros onf onctx.
eapply into_closed_red.
- destruct onf. eapply weakening_red; tea.
now rewrite on_free_vars_ctx_on_ctx_free_vars.
- eapply is_closed_context_lift; eauto with fvs.
- eapply is_open_term_lift; eauto with fvs.
Qed.
Lemma subslet_eq_context_alpha {cf} {Σ Γ s Δ Δ'} :
eq_context_upto_names Δ Δ' →
subslet Σ Γ s Δ →
subslet Σ Γ s Δ'.
Proof.
intros eq subs.
induction subs in Δ', eq |- *; depelim eq; try constructor.
* depelim c; constructor; auto. now subst.
* depelim c; subst; constructor; auto.
Qed.
Lemma eq_context_alpha_conv {cf} {Σ} {wfΣ : wf Σ} {Γ Γ'} :
eq_context_upto_names Γ Γ' -> conv_context cumulAlgo_gen Σ Γ Γ'.
Proof.
intros a.
eapply eq_context_upto_empty_conv_context.
eapply All2_fold_All2.
eapply (All2_impl a).
intros ?? []; constructor; subst; auto; reflexivity.
Qed.
Lemma wf_local_alpha {cf} {Σ} {wfΣ : wf Σ} Γ Γ' : eq_context_upto_names Γ Γ' ->
wf_local Σ Γ ->
wf_local Σ Γ'.
Proof.
induction 1; intros h; depelim h; try constructor; auto.
all:depelim r; constructor; subst; auto.
all: eapply lift_typing_impl; tea; intros T Hty.
all: eapply context_conversion; eauto.
all: now apply eq_context_alpha_conv.
Qed.
Lemma subslet_eq_context_alpha_dom {cf} {Σ} {wfΣ : wf Σ} {Γ Γ' s Δ} :
eq_context_upto_names Γ Γ' →
subslet Σ Γ s Δ →
subslet Σ Γ' s Δ.
Proof.
intros eq subs.
induction subs in Γ', eq |- *; try constructor.
* now apply IHsubs.
* eapply context_conversion; tea.
eapply wf_local_alpha; tea. eapply typing_wf_local in t0. exact t0.
now eapply eq_context_alpha_conv.
* now eapply IHsubs.
* eapply context_conversion; tea.
eapply wf_local_alpha; tea. eapply typing_wf_local in t0. exact t0.
now eapply eq_context_alpha_conv.
Qed.
Lemma subslet_app {cf:checker_flags} Σ Γ s s' Δ Δ' :
subslet Σ Γ s (subst_context s' 0 Δ) ->
subslet Σ Γ s' Δ' ->
subslet Σ Γ (s ++ s') (Δ' ,,, Δ).
Proof.
induction Δ in s, s', Δ' |- *; simpl; auto; move=> sub'.
- depelim sub'. auto.
- rewrite subst_context_snoc in sub' => sub''.
move:(subslet_length sub') => /=.
rewrite /snoc /= subst_context_length /= => Hlen.
destruct a as [na [b|] ty].
* depelim sub'; simpl in t0, Hlen.
rewrite -subst_app_simpl' /=. lia.
constructor. eauto.
now rewrite - !subst_app_simpl' in t0; try lia.
* rewrite /subst_decl /map_decl /snoc /= in sub'.
depelim sub'; simpl in Hlen.
rewrite - !subst_app_simpl' in t0; try lia.
simpl; constructor; eauto.
Qed.
Lemma subslet_skipn {cf:checker_flags} Σ Γ s Δ n :
subslet Σ Γ s Δ ->
subslet Σ Γ (skipn n s) (skipn n Δ).
Proof.
induction n in s, Δ |- *.
- now rewrite !skipn_0.
- intros H; depelim H.
* rewrite !skipn_nil. constructor.
* rewrite !skipn_S. auto.
* rewrite !skipn_S. auto.
Qed.
Lemma untyped_subslet_skipn Γ s Δ n :
untyped_subslet Γ s Δ ->
untyped_subslet Γ (skipn n s) (skipn n Δ).
Proof.
induction n in s, Δ |- *.
- now rewrite !skipn_0.
- intros H; depelim H.
* rewrite !skipn_nil. constructor.
* rewrite !skipn_S. auto.
* rewrite !skipn_S. auto.
Qed.
Lemma untyped_subslet_eq_subst Γ s s' Δ :
untyped_subslet Γ s Δ -> s = s' ->
untyped_subslet Γ s' Δ.
Proof. now intros H ->. Qed.
Lemma context_subst_app_inv {ctx ctx' : context} {args s : list term} :
context_subst (subst_context (skipn #|ctx| s) 0 ctx)
(skipn (context_assumptions ctx') args)
(firstn #|ctx| s)
× context_subst ctx' (firstn (context_assumptions ctx') args) (skipn #|ctx| s) ->
context_subst (ctx ++ ctx') args s.
Proof.
move=> [Hl Hr].
rewrite -(firstn_skipn (context_assumptions ctx') args).
assert (lenctx' : context_assumptions ctx' + context_assumptions ctx = #|args|).
{ assert (lenctx'' : context_assumptions ctx' <= #|args|).
move: (context_subst_assumptions_length Hr).
rewrite firstn_length; lia.
move: (context_subst_assumptions_length Hr).
move: (context_subst_assumptions_length Hl).
rewrite firstn_length skipn_length; try lia.
intros H1 H2. rewrite context_assumptions_subst in H1. lia. }
move: args s ctx' lenctx' Hl Hr.
induction ctx => args s ctx' lenctx' Hl Hr.
- simpl in *. depelim Hl. rewrite H app_nil_r. now rewrite skipn_0 in Hr.
- simpl in *. destruct s as [|u s];
simpl in *; rewrite subst_context_snoc0 in Hl; depelim Hl.
simpl in H. noconf H.
* destruct a as [na [b|] ty]; simpl in *; noconf H.
rewrite skipn_S in Hl, Hr. destruct args using rev_case. rewrite skipn_nil in H0.
apply (f_equal (@length _)) in H0. simpl in H0. autorewrite with len in H0.
simpl in H0; lia. rewrite H0.
rewrite skipn_app in H0.
rewrite app_length /= in lenctx'.
specialize (IHctx args s ctx'). forward IHctx by lia.
assert (context_assumptions ctx' - #|args| = 0) by lia.
rewrite H skipn_0 in H0. apply app_inj_tail in H0 as [Ha xu]. subst x.
rewrite -Ha.
rewrite -Ha in Hl. specialize (IHctx Hl).
rewrite firstn_app in Hr |- *.
rewrite H [firstn _ [u]]firstn_0 // app_nil_r in Hr |- *.
specialize (IHctx Hr). rewrite app_assoc.
now econstructor.
* rewrite skipn_S in Hl, Hr, H.
destruct a as [na' [b'|] ty']; simpl in *; noconf H.
pose proof (context_subst_length Hl). rewrite subst_context_length in H.
rewrite {3}H -subst_app_simpl [firstn #|ctx| _ ++ _]firstn_skipn. constructor.
apply IHctx => //.
Qed.
Lemma ctx_inst_inst {cf:checker_flags} Σ ext u Γ i Δ :
wf_global_ext Σ.1 ext ->
ctx_inst (Σ.1, ext) Γ i Δ ->
consistent_instance_ext Σ ext u ->
ctx_inst Σ (subst_instance u Γ)
(map (subst_instance u) i)
(subst_instance u Δ).
Proof.
intros wfext ctxi cu.
induction ctxi; simpl; constructor; auto.
* destruct Σ as [Σ univs].
eapply (typing_subst_instance'' Σ); eauto.
* rewrite (subst_telescope_subst_instance u [i]).
apply IHctxi.
* rewrite (subst_telescope_subst_instance u [b]).
apply IHctxi.
Qed.
Record spine_subst {cf:checker_flags} Σ Γ inst s Δ := mkSpineSubst {
spine_dom_wf : wf_local Σ Γ;
spine_codom_wf : wf_local Σ (Γ ,,, Δ);
inst_ctx_subst :> context_subst Δ inst s;
inst_subslet :> subslet Σ Γ s Δ }.
Arguments inst_ctx_subst {cf Σ Γ inst s Δ}.
Arguments inst_subslet {cf Σ Γ inst s Δ}.
#[global]
Hint Resolve inst_ctx_subst inst_subslet : pcuic.
Lemma spine_subst_eq {cf:checker_flags} {Σ Γ inst s Δ Δ'} :
spine_subst Σ Γ inst s Δ ->
Δ = Δ' ->
spine_subst Σ Γ inst s Δ'.
Proof.
now intros sp ->.
Qed.
Lemma spine_subst_inj_subst {cf:checker_flags} {Σ Γ inst s s' Δ} :
spine_subst Σ Γ inst s Δ ->
spine_subst Σ Γ inst s' Δ ->
s = s'.
Proof.
intros [_ _ c _] [_ _ c' _].
induction c in s', c' |- *; depelim c'; simpl; auto.
apply app_inj_tail in H as [-> ->].
f_equal; eauto.
specialize (IHc _ c'). now subst.
Qed.
Lemma make_context_subst_skipn {Γ args s s'} :
make_context_subst Γ args s = Some s' ->
skipn #|Γ| s' = s.
Proof.
induction Γ in args, s, s' |- *.
- destruct args; simpl; auto.
+ now intros [= ->].
+ now discriminate.
- destruct a as [na [b|] ty]; simpl.
+ intros H.
specialize (IHΓ _ _ _ H).
now eapply skipn_n_Sn.
+ destruct args; try discriminate.
intros Hsub.
specialize (IHΓ _ _ _ Hsub).
now eapply skipn_n_Sn.
Qed.
Inductive arity_spine {cf : checker_flags} (Σ : global_env_ext) (Γ : context) :
term -> list term -> term -> Type :=
| arity_spine_nil ty : arity_spine Σ Γ ty [] ty
| arity_spine_conv ty ty' : isType Σ Γ ty' ->
Σ ;;; Γ ⊢ ty ≤ ty' -> arity_spine Σ Γ ty [] ty'
| arity_spine_def : forall (tl : list term)
(na : aname) (A a B B' : term),
arity_spine Σ Γ (B {0 := a}) tl B' ->
arity_spine Σ Γ (tLetIn na a A B) tl B'
| arity_spine_ass : forall (hd : term) (tl : list term)
(na : aname) (A B B' : term),
Σ;;; Γ |- hd : A ->
arity_spine Σ Γ (B {0 := hd}) tl B' ->
arity_spine Σ Γ (tProd na A B) (hd :: tl) B'.
Derive Signature for arity_spine.
Record wf_arity_spine {cf:checker_flags} Σ Γ T args T' :=
{ wf_arity_spine_wf : isType Σ Γ T;
wf_arity_spine_spine : arity_spine Σ Γ T args T' }.
#[global] Hint Resolve isType_wf_local : pcuic.
Lemma context_subst_subst Δ inst0 s Γ inst s' :
context_subst Δ inst0 s ->
context_subst (subst_context s 0 Γ) inst s' ->
context_subst (Δ ,,, Γ) (inst0 ++ inst) (s' ++ s).
Proof.
induction Γ in inst, s' |- *.
+ intros HΔ Hi. depelim Hi.
now rewrite app_nil_r.
+ intros H' Hsub.
rewrite subst_context_snoc0 in Hsub.
destruct a as [na [b|] ty];
depelim Hsub.
- specialize (IHΓ _ _ H' Hsub).
assert(#|Γ| = #|s0|) as ->.
{ apply context_subst_length in Hsub.
now rewrite subst_context_length in Hsub. }
rewrite -(subst_app_simpl s0 s 0 b).
simpl. now constructor.
- specialize (IHΓ _ _ H' Hsub).
assert(#|Γ| = #|s0|).
{ apply context_subst_length in Hsub.
now rewrite subst_context_length in Hsub. }
rewrite app_assoc /=. now constructor.
Qed.
Section WfEnv.
Context {cf} {Σ : global_env_ext} {wfΣ : wf Σ}.
Lemma typing_spine_strengthen {Γ T args U} :
typing_spine Σ Γ T args U ->
forall T',
isType Σ Γ T' ->
Σ ;;; Γ ⊢ T' ≤ T ->
typing_spine Σ Γ T' args U.
Proof using wfΣ.
induction 1 in |- *; intros T' isTy redT.
- constructor; eauto. transitivity ty; auto.
- specialize (IHX (B {0 := hd})).
pose proof (isType_apply i0 t); tea.
do 2 forward IHX by pcuic.
eapply type_spine_cons; eauto.
etransitivity; eauto.
Qed.
Lemma typing_spine_refl {Γ T} :
isType Σ Γ T ->
typing_spine Σ Γ T [] T.
Proof using wfΣ.
intros isty. constructor; auto.
eauto with pcuic.
Qed.
Lemma inversion_mkApps_direct {Γ f u T} :
isType Σ Γ T ->
Σ ;;; Γ |- mkApps f u : T ->
∑ A s', Σ ;;; Γ |- f : A × Σ ;;; Γ |- A : tSort s' × typing_spine Σ Γ A u T.
Proof using wfΣ.
induction u in f, T |- *. simpl. intros.
{ destruct X as [s X]. exists T, s. intuition pcuic. eapply typing_spine_refl. eexists; eauto. }
intros HT Hf. simpl in Hf.
destruct u. simpl in Hf, IHu.
- edestruct @inversion_App_size with (H := Hf) as (na' & A' & B' & s & Hf' & Ha & HA & _ & _ & _ & HA'''); tea.
eexists _, _; intuition eauto.
econstructor; eauto with pcuic.
eapply isType_ws_cumul_pb_refl; eexists; eauto.
econstructor. all:eauto with pcuic.
eapply inversion_Prod in HA as (? & ? & ? & ? & ?); tea.
eapply isType_subst. econstructor. econstructor. rewrite subst_empty; eauto.
econstructor; cbn; eauto.
- specialize (IHu (tApp f a) T).
epose proof (IHu _ Hf) as [T' [s' [H' [H''' H'']]]].
edestruct @inversion_App_size with (H := H') as (na' & A' & B' & s & Hf' & Ha & HA & _ & _ & _ & HA'''); tea.
exists (tProd na' A' B'). exists s. intuition; eauto.
econstructor; eauto with wf.
1,2: eexists; eauto. 1:eapply isType_ws_cumul_pb_refl; eexists; eauto.
eapply typing_spine_strengthen; tea.
eapply inversion_Prod in HA as (? & ? & ? & ? & ?); tea.
eapply isType_subst. econstructor. econstructor. rewrite subst_empty; eauto.
econstructor; cbn; eauto.
Unshelve. eauto.
Qed.
Lemma subst_type_local_ctx {Γ Γ' Δ Δ' s ctxs} :
wf_local Σ (Γ ,,, Δ ,,, Γ') ->
type_local_ctx (lift_typing typing) Σ (Γ ,,, Δ ,,, Γ') Δ' ctxs ->
subslet Σ Γ s Δ ->
type_local_ctx (lift_typing typing) Σ (Γ ,,, subst_context s 0 Γ') (subst_context s #|Γ'| Δ') ctxs.
Proof using wfΣ.
induction Δ' in Γ' |- *; simpl; auto.
destruct a as [na [b|] ty];
rewrite subst_context_snoc /= /subst_decl /map_decl /=;
simpl; intuition auto.
1: apply infer_typing_sort_impl with id a0; intros Hs.
1: destruct a0 as (? & t); cbn in Hs |- *; clear t.
2: rename b1 into Hs.
3: rename b into Hs.
all: rewrite -app_context_assoc in Hs.
all: eapply substitution in Hs; eauto.
all: rewrite subst_context_app app_context_assoc in Hs.
all: simpl in Hs; rewrite Nat.add_0_r in Hs.
all: now rewrite app_context_length in Hs.
Qed.
Lemma subst_sorts_local_ctx {Γ Γ' Δ Δ' s ctxs} :
wf_local Σ (Γ ,,, Δ ,,, Γ') ->
sorts_local_ctx (lift_typing typing) Σ (Γ ,,, Δ ,,, Γ') Δ' ctxs ->
subslet Σ Γ s Δ ->
sorts_local_ctx (lift_typing typing) Σ (Γ ,,, subst_context s 0 Γ') (subst_context s #|Γ'| Δ') ctxs.
Proof using wfΣ.
induction Δ' in Γ', ctxs |- *; simpl; auto.
destruct a as [na [b|] ty]; rewrite subst_context_snoc /= /subst_decl /map_decl /=;
intuition auto.
+ eapply infer_typing_sort_impl with id a0; intros Hs.
destruct a0 as (? & t); cbn in Hs |- *; clear t.
rewrite -app_context_assoc in Hs.
eapply substitution in Hs; eauto.
rewrite subst_context_app app_context_assoc in Hs.
simpl in Hs. rewrite Nat.add_0_r in Hs.
now rewrite app_context_length in Hs.
+ rewrite -app_context_assoc in b1.
eapply substitution in b1; eauto.
rewrite subst_context_app app_context_assoc Nat.add_0_r in b1.
now rewrite app_context_length in b1.
+ destruct ctxs => //.
intuition auto.
rewrite -app_context_assoc in b.
eapply substitution in b; eauto.
rewrite subst_context_app app_context_assoc in b.
rewrite Nat.add_0_r in b.
now rewrite app_context_length in b.
Qed.
Lemma wf_arity_spine_typing_spine {Γ T args T'} :
wf_arity_spine Σ Γ T args T' ->
typing_spine Σ Γ T args T'.
Proof using wfΣ.
intros [wf sp].
have wfΓ := isType_wf_local wf.
induction sp; try constructor; auto; pcuic.
- eapply typing_spine_strengthen; eauto.
2:{ eapply into_ws_cumul_pb.
apply red_cumul. apply red1_red. constructor.
1-2:eauto with fvs.
eapply isType_tLetIn_red in wf; eauto with fvs. }
now eapply isType_tLetIn_red in wf.
- econstructor; eauto with pcuic.
apply IHsp. now eapply isType_apply in wf => //.
Qed.
Import PCUICConversion.
Lemma arity_typing_spine {Γ Γ' s inst s'} :
typing_spine Σ Γ (it_mkProd_or_LetIn Γ' (tSort s)) inst (tSort s') ->
[× (#|inst| = context_assumptions Γ'), leq_universe (global_ext_constraints Σ) s s' &
∑ instsubst, spine_subst Σ Γ inst instsubst Γ'].
Proof using wfΣ.
revert s inst s'.
(* assert (wf_local Σ Γ). now apply wf_local_app_l in wfΓ'. move X after wfΓ'.
rename X into wfΓ. *)
generalize (le_n #|Γ'|).
generalize (#|Γ'|) at 2.
induction n in Γ' |- *.
- destruct Γ' using rev_ind; try clear IHΓ'; simpl; intros len s inst s' Hsp.
+ dependent elimination Hsp as [spnil _ _ cum|spcons isty isty' cum tyhd sp].
++ split=>//.
now eapply ws_cumul_pb_Sort_inv in cum.
exists []. split; try constructor; eauto with pcuic.
all:now eapply isType_wf_local.
++ now eapply ws_cumul_pb_Sort_Prod_inv in cum.
+ rewrite app_length /= in len; elimtype False; lia.
- intros len s inst s' Hsp.
destruct Γ' using rev_ind; try clear IHΓ'.
-- dependent elimination Hsp as [spnil _ _ cum|spcons isty isty' cum tyhd sp].
1:split; auto.
--- now eapply ws_cumul_pb_Sort_inv in cum.
--- exists []; split; try constructor; auto.
all:now eapply isType_wf_local.
--- now eapply ws_cumul_pb_Sort_Prod_inv in cum.
-- rewrite app_length /= in len.
destruct x as [na [b|] ty]; simpl in *; rewrite /mkProd_or_LetIn /= in Hsp.
+ rewrite context_assumptions_app /= Nat.add_0_r.
assert (Hsp' := Hsp).
rewrite it_mkProd_or_LetIn_app /= in Hsp'.
eapply typing_spine_letin_inv in Hsp'; auto.
rewrite /subst1 subst_it_mkProd_or_LetIn /= in Hsp'.
eapply typing_spine_isType_dom in Hsp.
eapply isType_it_mkProd_or_LetIn_wf_local in Hsp.
specialize (IHn (subst_context [b] 0 l)).
forward IHn by rewrite subst_context_length; lia.
specialize (IHn s inst s' Hsp').
rewrite context_assumptions_subst in IHn.
destruct IHn as [instlen leq [instsubst [wfdom wfcodom cs subi]]].
split => //.
exists (instsubst ++ [subst0 [] b]).
split; auto.
* apply context_subst_app_inv. cbn.
rewrite !skipn_0 {1}subst_empty.
assert(#|l| <= n) by lia.
pose proof (context_subst_length cs). rewrite subst_context_length in H0.
rewrite !firstn_app_left //.
split. now rewrite H0 skipn_all_app.
rewrite H0 skipn_all_app. repeat constructor.
* apply subslet_app; rewrite !subst_empty //.
eapply subslet_def_tip.
rewrite app_context_assoc /= in Hsp.
apply wf_local_app_l in Hsp. now depelim Hsp.
+ rewrite context_assumptions_app /=.
assert (Hsp' := Hsp).
rewrite it_mkProd_or_LetIn_app in Hsp'.
dependent elimination Hsp' as [spnil typ tys cum|type_spine_cons typ tys cum tyhd sp].
{ now eapply ws_cumul_pb_Prod_Sort_inv in cum. }
eapply ws_cumul_pb_Prod_Prod_inv in cum as [eqna conva cumulB].
eapply (PCUICConversion.substitution_ws_cumul_pb (Γ' := [vass na0 A]) (Γ'':=[]) (s := [hd0])) in cumulB; auto.
rewrite /subst1 subst_it_mkProd_or_LetIn /= in cumulB.
specialize (IHn (subst_context [hd0] 0 l)).
forward IHn by rewrite subst_context_length; lia.
specialize (IHn s tl0 s'). 2:pcuic.
rewrite context_assumptions_subst in IHn.
assert (Σ ;;; Γ |- hd0 : ty).
{ eapply type_ws_cumul_pb; tea.
now eapply isType_tProd in typ as [].
symmetry; pcuic. }
eapply typing_spine_strengthen in sp.
3:eapply cumulB.
2:{ cbn in *.
eapply isType_apply in typ; tea.
now rewrite /subst1 subst_it_mkProd_or_LetIn Nat.add_0_r in typ. }
all:pcuic.
destruct X0 as [instlen leq [instsubst [wfdom wfcodom cs subi]]].
split=> /= //; try lia.
exists (instsubst ++ [hd0]).
eapply typing_spine_isType_dom in Hsp.
eapply isType_it_mkProd_or_LetIn_wf_local in Hsp.
split; auto.
* apply context_subst_app_inv. cbn.
rewrite !skipn_S skipn_0.
assert(#|l| <= n) by lia.
pose proof (context_subst_length cs). rewrite subst_context_length in H0.
rewrite !firstn_app_left //.
split. now rewrite H0 skipn_all_app.
rewrite H0 skipn_all_app. apply (context_subst_ass _ []). constructor.
* apply subslet_app => //. now apply subslet_ass_tip.
Qed.
(*Lemma typing_spine_it_mkProd_or_LetIn_gen {Γ Δ : context} {T args s s' args' T'} :
make_context_subst (List.rev Δ) args s' = Some s ->
typing_spine Σ Γ (subst0 s T) args' T' ->
#|args| = context_assumptions Δ ->
subslet Σ Γ s Δ ->
isType Σ Γ (it_mkProd_or_LetIn Δ T) ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T'.
Proof.
induction Δ using ctx_length_rev_ind in args, args', s, s', T |- *.
- cbn. destruct args => // => [= <-].
intros Hsp _ Hsub ist. cbn. depelim Hsub. rewrite subst_empty in Hsp. auto.
- intros Hsub Hsp Hargs subs.
rewrite context_assumptions_app in Hargs.
destruct d as [na [b|] ty]; simpl in *.
* rewrite it_mkProd_or_LetIn_app /= /mkProd_or_LetIn /= => Hty.
rewrite Nat.add_0_r in Hargs.
rewrite rev_app_distr in Hsub. simpl in Hsub.
specialize (X (subst_context [b] 0 Γ0) ltac:(len; lia) (subst [b] #|Γ0| T)). _ _ _ _ _ Hsub Hsp Hargs).
forward X.
now rewrite it_mkProd_or_LetIn_app /=.
eapply typing_spine_letin; auto.
pose proof (subslet_app_inv subs) as.
eapply isType_substitution_it_mkProd_or_LetIn
p
rewrite /subst1.
now rewrite -subst_app_simpl.
* rewrite it_mkProd_or_LetIn_app /= /mkProd_or_LetIn /=.
rewrite rev_app_distr in Hsub.
simpl in Hsub. destruct args; try discriminate.
simpl in Hargs. rewrite Nat.add_1_r in Hargs. noconf Hargs.
intros subs. rewrite app_context_assoc in subs.
specialize (IHn Δ _ T args s _ ltac:(lia) Hsub Hsp H subs).
intros Har.
forward IHn. now rewrite it_mkProd_or_LetIn_app.
eapply subslet_app_inv in subs as [subsl subsr].
depelim subsl.
have Hskip := make_context_subst_skipn Hsub.
rewrite List.rev_length in Hskip. rewrite Hskip in H0; noconf H0.
simpl; eapply typing_spine_prod; auto; first
now rewrite /subst1 -subst_app_simpl.
eapply isType_substitution_it_mkProd_or_LetIn in Har; eauto.
Qed.*)
Lemma typing_spine_it_mkProd_or_LetIn_gen {Γ Δ Δ' : context} {T args s s' args' T'} :
make_context_subst (List.rev Δ) args s' = Some s ->
typing_spine Σ Γ (subst0 s T) args' T' ->
#|args| = context_assumptions Δ ->
subslet Σ Γ s (Δ' ,,, Δ) ->
isType Σ Γ (subst0 s' (it_mkProd_or_LetIn Δ T)) ->
typing_spine Σ Γ (subst0 s' (it_mkProd_or_LetIn Δ T)) (args ++ args') T'.
Proof using wfΣ.
generalize (le_n #|Δ|).
generalize (#|Δ|) at 2.
induction n in Δ, Δ', args, s, s', T |- *.
- destruct Δ using rev_ind.
+ intros le Hsub Hsp.
destruct args; simpl; try discriminate.
simpl in Hsub. now depelim Hsub.
+ rewrite app_length /=; intros; elimtype False; lia.
- destruct Δ using rev_ind.
1:intros le Hsub Hsp; destruct args; simpl; try discriminate;
simpl in Hsub; now depelim Hsub.
clear IHΔ.
rewrite app_length /=; intros Hlen Hsub Hsp Hargs.
rewrite context_assumptions_app in Hargs.
destruct x as [na [b|] ty]; simpl in *.
* rewrite it_mkProd_or_LetIn_app /= /mkProd_or_LetIn /=.
rewrite Nat.add_0_r in Hargs.
rewrite rev_app_distr in Hsub. simpl in Hsub.
intros subs isty. rewrite app_context_assoc in subs.
specialize (IHn l _ T args s _ ltac:(lia) Hsub Hsp Hargs subs).
forward IHn.
{ eapply isType_tLetIn_red in isty; pcuic.
move: isty. rewrite /subst1 -subst_app_simpl //. }
eapply typing_spine_letin; auto.
rewrite /subst1.
now rewrite -subst_app_simpl.
* rewrite it_mkProd_or_LetIn_app /= /mkProd_or_LetIn /=.
rewrite rev_app_distr in Hsub.
simpl in Hsub. destruct args; try discriminate.
simpl in Hargs. rewrite Nat.add_1_r in Hargs. noconf Hargs.
intros subs. rewrite app_context_assoc in subs.
specialize (IHn l _ T args s _ ltac:(lia) Hsub Hsp H subs).
intros Har.
eapply subslet_app_inv in subs as [subsl subsr].
depelim subsl.
have Hskip := make_context_subst_skipn Hsub.
rewrite List.rev_length in Hskip. rewrite Hskip in H0; noconf H0.
forward IHn.
{ eapply isType_apply in Har; tea.
now move: Har; rewrite /subst1 -subst_app_simpl. }
simpl; eapply typing_spine_prod; auto; first
now rewrite /subst1 -subst_app_simpl.
Qed.
Lemma typing_spine_it_mkProd_or_LetIn {Γ Δ T args s args' T'} :
make_context_subst (List.rev Δ) args [] = Some s ->
typing_spine Σ Γ (subst0 s T) args' T' ->
#|args| = context_assumptions Δ ->
subslet Σ Γ s Δ ->
isType Σ Γ (it_mkProd_or_LetIn Δ T) ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T'.
Proof using wfΣ.
intros.
pose proof (@typing_spine_it_mkProd_or_LetIn_gen Γ Δ [] T args s [] args' T'); auto.
now rewrite subst_empty app_context_nil_l in X2.
Qed.
Lemma typing_spine_it_mkProd_or_LetIn' {Γ Δ T args s args' T'} :
spine_subst Σ Γ args s Δ ->
typing_spine Σ Γ (subst0 s T) args' T' ->
isType Σ Γ (it_mkProd_or_LetIn Δ T) ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T'.
Proof using wfΣ.
intros. destruct X.
eapply typing_spine_it_mkProd_or_LetIn; eauto.
eapply make_context_subst_spec_inv. now rewrite List.rev_involutive.
now pose proof (context_subst_length2 inst_ctx_subst0).
Qed.
Lemma typing_spine_it_mkProd_or_LetIn_close_make_subst {Γ Δ T args s} :
make_context_subst (List.rev Δ) args [] = Some s ->
#|args| = context_assumptions Δ ->
subslet Σ Γ s Δ ->
isType Σ Γ (it_mkProd_or_LetIn Δ T) ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) args (subst0 s T).
Proof using wfΣ.
intros.
pose proof (@typing_spine_it_mkProd_or_LetIn_gen Γ Δ [] T args s [] []); auto.
rewrite app_nil_r subst_empty in X1. apply X1; eauto.
eapply isType_substitution_it_mkProd_or_LetIn in X0; tea.
constructor; pcuic.
now rewrite app_context_nil_l.
Qed.
Lemma typing_spine_it_mkProd_or_LetIn_close {Γ Δ T args s T'} :
spine_subst Σ Γ args s Δ ->
isType Σ Γ (it_mkProd_or_LetIn Δ T) ->
T' = (subst0 s T) ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) args T'.
Proof using wfΣ.
intros [] H ->.
eapply typing_spine_it_mkProd_or_LetIn_close_make_subst; eauto.
eapply make_context_subst_spec_inv.
now rewrite List.rev_involutive.
now eapply context_subst_length2 in inst_ctx_subst0.
Qed.
Lemma spine_subst_conv {Γ inst insts Δ inst' insts' Δ'} :
spine_subst Σ Γ inst insts Δ ->
spine_subst Σ Γ inst' insts' Δ' ->
ws_cumul_ctx_pb_rel Conv Σ Γ Δ Δ' ->
ws_cumul_pb_terms Σ Γ inst inst' ->
ws_cumul_pb_terms Σ Γ insts insts'.
Proof using wfΣ.
move=> [_ wf cs sl] [_ wf' cs' sl'] [clΓ cv].
move: inst insts cs wf sl inst' insts' cs' sl'.
induction cv; intros; depelim cs; depelim cs'.
1:constructor; auto.
all:depelim p.
- apply All2_app_r in X as (?&?).
depelim sl; depelim sl'; depelim wf; depelim wf'.
specialize (IHcv wf' _ _ cs wf sl _ _ cs' sl' a1).
constructor; auto.
- depelim sl; depelim sl'; depelim wf; depelim wf'.
specialize (IHcv wf' _ _ cs wf sl _ _ cs' sl' X).
constructor; auto.
eapply (substitution_ws_cumul_pb_subst_conv (Δ := [])); eauto using subslet_untyped_subslet with fvs.
Qed.
Lemma spine_subst_subst {Γ Γ0 Γ' i s Δ sub} :
spine_subst Σ (Γ ,,, Γ0 ,,, Γ') i s Δ ->
subslet Σ Γ sub Γ0 ->
spine_subst Σ (Γ ,,, subst_context sub 0 Γ')
(map (subst sub #|Γ'|) i) (map (subst sub #|Γ'|) s)
(subst_context sub #|Γ'| Δ).
Proof using wfΣ.
move=> [wfl wfΔ cs subl] subs.
split.
eapply substitution_wf_local; eauto.
pose proof (subst_context_app sub 0 Γ' Δ). rewrite Nat.add_0_r in H. rewrite -app_context_assoc -H.
clear H.
eapply substitution_wf_local; eauto. now rewrite app_context_assoc.
clear subl wfl wfΔ.
induction cs in Γ, Γ0, Γ', subs |- *; rewrite ?subst_context_snoc ?map_app; simpl; try constructor.
eapply IHcs; eauto.
specialize (IHcs _ _ Γ' subs).
epose proof (context_subst_def _ _ _ na (subst sub (#|Γ1| + #|Γ'|) b) (subst sub (#|Γ1| + #|Γ'|) t) IHcs).
rewrite /subst_decl /map_decl /=.
rewrite distr_subst.
now rewrite (context_subst_length cs) in X |- *.
clear cs wfΔ.
induction subl; rewrite ?subst_context_snoc ?map_app; simpl; try constructor; auto.
- eapply substitution in t0; eauto. simpl.
rewrite -(subslet_length subl).
now rewrite -distr_subst.
- eapply substitution in t0; eauto. simpl.
rewrite -(subslet_length subl).
rewrite !distr_subst in t0.
epose proof (cons_let_def _ _ _ _ _ _ _ IHsubl t0).
now rewrite - !distr_subst in X.
Qed.
Lemma spine_subst_subst_first {Γ Γ' i s Δ sub} :
spine_subst Σ (Γ ,,, Γ') i s Δ ->
subslet Σ [] sub Γ ->
spine_subst Σ (subst_context sub 0 Γ') (map (subst sub #|Γ'|) i) (map (subst sub #|Γ'|) s)
(subst_context sub #|Γ'| Δ).
Proof using wfΣ.
move=> sp subs.
epose proof (@spine_subst_subst [] Γ Γ' i s Δ sub).
rewrite !app_context_nil_l in X. apply X; auto.
Qed.
Lemma weaken_subslet {s Δ Γ Γ'} :
wf_local Σ Γ -> wf_local Σ Γ' ->
subslet Σ Γ' s Δ -> subslet Σ (Γ ,,, Γ') s Δ.
Proof using wfΣ.
intros wfΔ wfΓ'.
induction 1; constructor; auto.
+ eapply (weaken_ctx Γ); eauto.
+ eapply (weaken_ctx Γ); eauto.
Qed.
Lemma spine_subst_weaken {Γ i s Δ Γ'} :
wf_local Σ Γ' ->
spine_subst Σ Γ i s Δ ->
spine_subst Σ (Γ' ,,, Γ) i s Δ.
Proof using wfΣ.
move=> wfl [cs subl].
split; auto.
eapply weaken_wf_local => //.
rewrite -app_context_assoc. eapply weaken_wf_local => //.
eapply weaken_subslet; eauto.
Qed.
Lemma spine_subst_app_inv {Γ Δ Δ' inst inst' insts} :
#|inst| = context_assumptions Δ ->
spine_subst Σ Γ (inst ++ inst') insts (Δ ,,, Δ') ->
spine_subst Σ Γ inst (skipn #|Δ'| insts) Δ *
spine_subst Σ Γ inst' (firstn #|Δ'| insts) (subst_context (skipn #|Δ'| insts) 0 Δ').
Proof using wfΣ.
intros len sp.
destruct sp as [wfdom wfcodom cs subs].
eapply context_subst_app in cs as [csl csr].
rewrite skipn_all_app_eq in csl => //.
rewrite firstn_app_left in csr => //.
eapply subslet_app_inv in subs as [sl sr].
split; split; auto. rewrite app_context_assoc in wfcodom.
now eapply All_local_env_app_inv in wfcodom as [? ?].
eapply substitution_wf_local; eauto.
now rewrite app_context_assoc in wfcodom.
Qed.
Lemma spine_subst_smash_app_inv {Γ Δ Δ' δ δ'} :
#|δ| = context_assumptions Δ ->
spine_subst Σ Γ (δ ++ δ') (List.rev (δ ++ δ')) (smash_context [] (Δ ,,, Δ')) ->
spine_subst Σ Γ δ (List.rev δ) (smash_context [] Δ) ×
spine_subst Σ Γ δ' (List.rev δ')
(subst_context_let_expand (List.rev δ) Δ (smash_context [] Δ')).
Proof using wfΣ.
intros hδ sp.
rewrite smash_context_app_expand in sp.
eapply spine_subst_app_inv in sp; eauto.
2:{ rewrite context_assumptions_smash_context /= //. }
rewrite expand_lets_ctx_length smash_context_length /= in sp.
destruct sp as [sppars spidx].
assert (lenidx : context_assumptions Δ' = #|δ'|).
{ pose proof (PCUICContextSubst.context_subst_length2 spidx). len in H. }
assert (firstn (context_assumptions Δ')
(List.rev (δ ++ δ')) = List.rev δ').
{ rewrite List.rev_app_distr.
now rewrite firstn_app_left // List.rev_length. }
assert (skipn (context_assumptions Δ')
(List.rev (δ ++ δ')) = List.rev δ).
{ rewrite List.rev_app_distr.
erewrite (skipn_all_app_eq) => //; rewrite List.rev_length //. }
rewrite H H0 in spidx, sppars.
split => //.
Qed.
Lemma spine_subst_inst {ext u Γ i s Δ} :
wf_global_ext Σ.1 ext ->
spine_subst (Σ.1, ext) Γ i s Δ ->
consistent_instance_ext Σ ext u ->
spine_subst Σ (subst_instance u Γ)
(map (subst_instance u) i)
(map (subst_instance u) s)
(subst_instance u Δ).
Proof using wfΣ.
intros wfext [wfdom wfcodom cs subsl] cu.
split.
eapply wf_local_subst_instance; eauto.
rewrite -subst_instance_app_ctx.
eapply wf_local_subst_instance; eauto.
clear -cs cu wfext wfΣ.
induction cs; simpl; rewrite ?map_app; try constructor; auto.
rewrite subst_instance_cons; simpl.
rewrite subst_instance_subst.
constructor; auto.
clear -subsl cu wfΣ wfext.
induction subsl; simpl; rewrite ?subst_instance_subst; constructor; auto.
* destruct Σ as [Σ' univs].
rewrite -subst_instance_subst.
eapply (typing_subst_instance'' Σ'); simpl; eauto.
* rewrite - !subst_instance_subst. simpl.
destruct Σ as [Σ' univs].
eapply (typing_subst_instance'' Σ'); simpl; eauto.
Qed.
Lemma spine_subst_weakening {Γ i s Δ Γ'} :
wf_local Σ (Γ ,,, Γ') ->
spine_subst Σ Γ i s Δ ->
spine_subst Σ (Γ ,,, Γ') (map (lift0 #|Γ'|) i) (map (lift0 #|Γ'|) s) (lift_context #|Γ'| 0 Δ).
Proof using wfΣ.
move=> wfl [cs subl].
split; auto.
eapply weakening_wf_local; eauto.
now apply context_subst_lift.
now apply subslet_lift.
Qed.
Lemma ctx_inst_length {Γ args Δ} :
ctx_inst Σ Γ args Δ ->
#|args| = context_assumptions Δ.
Proof using Type.
induction 1; simpl; auto.
rewrite /subst_telescope in IHX.
rewrite context_assumptions_mapi in IHX. congruence.
rewrite context_assumptions_mapi in IHX. congruence.
Qed.
Lemma ctx_inst_subst {Γ Γ0 Γ' i Δ sub} :
ctx_inst Σ (Γ ,,, Γ0 ,,, Γ') i Δ ->
subslet Σ Γ sub Γ0 ->
ctx_inst Σ (Γ ,,, subst_context sub 0 Γ') (map (subst sub #|Γ'|) i) (subst_telescope sub #|Γ'| Δ).
Proof using wfΣ.
move=> ctxinst subs.
induction ctxinst in sub, subs |- *.
- simpl; intros; constructor; auto.
- intros. rewrite subst_telescope_cons; simpl; constructor.
* simpl. eapply substitution; eauto.
* specialize (IHctxinst _ subs).
now rewrite (subst_telescope_comm [i]).
- intros. rewrite subst_telescope_cons; simpl; constructor.
specialize (IHctxinst _ subs).
now rewrite (subst_telescope_comm [b]).
Qed.
Lemma ctx_inst_weaken {Γ i Δ Γ'} :
wf_local Σ Γ' ->
ctx_inst Σ Γ i Δ ->
ctx_inst Σ (Γ' ,,, Γ) i Δ.
Proof using wfΣ.
move=> wfl subl.
induction subl; constructor; auto.
now eapply (weaken_ctx Γ').
Qed.
Lemma make_context_subst_tele s s' Δ inst sub :
make_context_subst (subst_telescope s' #|s| Δ) inst s = Some sub ->
make_context_subst Δ inst (s ++ s') = Some (sub ++ s').
Proof using Type.
induction Δ in s, s', sub, inst |- *.
simpl. destruct inst; try discriminate.
intros [= ->]. reflexivity.
rewrite subst_telescope_cons.
destruct a as [na [b|] ty]; simpl in *.
intros. specialize (IHΔ _ _ _ _ H).
now rewrite -subst_app_simpl in IHΔ.
destruct inst. discriminate.
intros. now specialize (IHΔ _ _ _ _ H).
Qed.
Fixpoint ctx_inst_sub {cf:checker_flags} {Σ Γ Δ args} (c : ctx_inst Σ Γ args Δ) {struct c} : list term :=
match c return _ with
| ctx_inst_nil => []
| ctx_inst_ass na t i inst Δ P c => ctx_inst_sub c ++ [i]
| ctx_inst_def na b t inst Δ c => ctx_inst_sub c ++ [b]
end.
Lemma ctx_inst_sub_spec {Γ Δ args} (c : ctx_inst Σ Γ args Δ) :
make_context_subst Δ args [] = Some (ctx_inst_sub c).
Proof using Type.
induction c; simpl; auto.
now apply (make_context_subst_tele [] [i]) in IHc.
apply (make_context_subst_tele [] [b]) in IHc.
now rewrite subst_empty.
Qed.
Lemma subst_telescope_empty k Δ : subst_telescope [] k Δ = Δ.
Proof using Type.
unfold subst_telescope, mapi. generalize 0. induction Δ; simpl; auto.
intros.
destruct a as [na [b|] ty]; unfold map_decl at 1; simpl; rewrite !subst_empty.
f_equal. apply IHΔ.
f_equal. apply IHΔ.
Qed.
Lemma subst_telescope_app s k Γ Δ : subst_telescope s k (Γ ++ Δ) = subst_telescope s k Γ ++
subst_telescope s (#|Γ| + k) Δ.
Proof using Type.
rewrite /subst_telescope /mapi.
rewrite mapi_rec_app. f_equal. rewrite mapi_rec_add.
apply mapi_rec_ext. intros. destruct x as [na [b|] ty]; simpl; f_equal; f_equal; lia.
Qed.
Hint Extern 0 => lia : lia.
Lemma context_assumptions_subst_telescope s k Δ : context_assumptions (subst_telescope s k Δ) =
context_assumptions Δ.
Proof using Type.
rewrite /subst_telescope /mapi. generalize 0.
induction Δ; simpl; auto.
destruct a as [na [b|] ty]; simpl; auto with lia.
intros. specialize (IHΔ (S n)). lia.
Qed.
Lemma subst_app_telescope s s' k Γ :
subst_telescope (s ++ s') k Γ = subst_telescope s k (subst_telescope s' (#|s| + k) Γ).
Proof using Type.
rewrite /subst_telescope /mapi.
rewrite mapi_rec_compose.
apply mapi_rec_ext. intros. destruct x as [na [b|] ty]; simpl; unfold map_decl; simpl; f_equal.
rewrite subst_app_simpl. f_equal; f_equal. f_equal. lia.
rewrite subst_app_simpl. f_equal; f_equal. lia.
rewrite subst_app_simpl. f_equal; f_equal. lia.
Qed.
Lemma make_context_subst_length Γ args acc sub : make_context_subst Γ args acc = Some sub ->
#|sub| = #|Γ| + #|acc|.
Proof using Type.
induction Γ in args, acc, sub |- *; simpl.
destruct args; try discriminate. now intros [= ->].
destruct a as [? [b|] ty] => /=. intros H.
specialize (IHΓ _ _ _ H). simpl in IHΓ. lia.
destruct args; try discriminate.
intros H.
specialize (IHΓ _ _ _ H). simpl in IHΓ. lia.
Qed.
Lemma subst_telescope_length s k Γ : #|subst_telescope s k Γ| = #|Γ|.
Proof using Type.
now rewrite /subst_telescope mapi_length.
Qed.
Lemma arity_spine_it_mkProd_or_LetIn {Γ Δ T args s args' T'} :
spine_subst Σ Γ args s Δ ->
arity_spine Σ Γ (subst0 s T) args' T' ->
arity_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T'.
Proof using Type.
intros sp asp. destruct sp as [wfΓ _ cs subsl].
move: Δ args s T cs subsl asp.
induction Δ using ctx_length_rev_ind => args s T cs subsl asp.
- depelim cs. depelim subsl.
now rewrite subst_empty in asp.
- rewrite it_mkProd_or_LetIn_app /= /mkProd_or_LetIn /=.
destruct d as [na [b|] ty]; simpl in *.
* constructor. rewrite /subst1 subst_it_mkProd_or_LetIn.
rewrite Nat.add_0_r.
apply subslet_app_inv in subsl as [subsl subsl'].
depelim subsl; depelim subsl.
apply context_subst_app in cs as [cs cs'].
simpl in *. rewrite skipn_0 in cs.
specialize (X (subst_context (skipn #|Γ0| s) 0 Γ0) ltac:(now autorewrite with len) _ _
(subst [b] #|Γ0| T) cs subsl').
rewrite subst_empty in H.
rewrite H in X. apply X.
rewrite -subst_app_simpl'.
apply subslet_length in subsl'.
now autorewrite with len in subsl'.
rewrite -H. now rewrite firstn_skipn.
* apply subslet_app_inv in subsl as [subsl subsl'].
depelim subsl; depelim subsl.
apply context_subst_app in cs as [cs cs'].
simpl in *.
destruct args. depelim cs'.
depelim cs'. discriminate.
simpl in *. rewrite skipn_S skipn_0 in cs.
rewrite subst_empty in t0.
depelim cs'; depelim cs'. simpl in H; noconf H.
rewrite H1 in H0. noconf H0.
constructor; auto.
rewrite /subst1 subst_it_mkProd_or_LetIn.
rewrite Nat.add_0_r.
specialize (X (subst_context (skipn #|Γ0| s) 0 Γ0) ltac:(now autorewrite with len) _ _
(subst [t1] #|Γ0| T) cs subsl').
rewrite -{1}H1. apply X.
rewrite -subst_app_simpl'.
apply subslet_length in subsl'.
now autorewrite with len in subsl'.
rewrite -H1. now rewrite firstn_skipn.
Qed.
Lemma spine_subst_is_closed_context Γ args inst ctx :
spine_subst Σ Γ args inst ctx ->
is_closed_context Γ.
Proof using wfΣ.
now move=> [] /wf_local_closed_context.
Qed.
Lemma spine_subst_is_closed_context_codom Γ args inst ctx :
spine_subst Σ Γ args inst ctx ->
is_closed_context (Γ ,,, ctx).
Proof using wfΣ.
now move=> [] _ /wf_local_closed_context.
Qed.
Hint Resolve spine_subst_is_closed_context spine_subst_is_closed_context_codom : fvs.
Lemma arity_spine_it_mkProd_or_LetIn_Sort {Γ ctx s s' args inst} :
wf_universe Σ s' ->
leq_universe Σ s s' ->
spine_subst Σ Γ args inst ctx ->
arity_spine Σ Γ (it_mkProd_or_LetIn ctx (tSort s)) args (tSort s').
Proof using wfΣ.
intros wfs le sp. rewrite -(app_nil_r args).
eapply arity_spine_it_mkProd_or_LetIn => //.
eauto. constructor.
eapply isType_Sort; eauto.
eapply sp. simpl.
apply ws_cumul_pb_compare => //; eauto with pcuic fvs. now constructor.
Qed.
Lemma ctx_inst_subst_length {Γ} {Δ : context} {args} (c : ctx_inst Σ Γ args Δ) :
#|ctx_inst_sub c| = #|Δ|.
Proof using Type.
induction c; simpl; auto; try lia;
rewrite app_length IHc subst_telescope_length /=; lia.
Qed.
Lemma ctx_inst_app {Γ} {Δ : context} {Δ' args args'}
(dom : ctx_inst Σ Γ args Δ) :
ctx_inst Σ Γ args' (subst_telescope (ctx_inst_sub dom) 0 Δ') ->
ctx_inst Σ Γ (args ++ args') (Δ ++ Δ').
Proof using Type.
induction dom in args', Δ' |- *; simpl.
- now rewrite subst_telescope_empty.
- rewrite subst_app_telescope /= ctx_inst_subst_length /= subst_telescope_length Nat.add_0_r /=.
move/IHdom => IH.
constructor => //.
now rewrite subst_telescope_app Nat.add_0_r.
- rewrite subst_app_telescope /= ctx_inst_subst_length /= subst_telescope_length Nat.add_0_r /=.
move/IHdom => IH.
constructor => //.
now rewrite subst_telescope_app Nat.add_0_r.
Qed.
Lemma ctx_inst_app_inv {Γ} {Δ : context} {Δ' args}
(c : ctx_inst Σ Γ args (Δ ++ Δ')) :
∑ (dom : ctx_inst Σ Γ (firstn (context_assumptions Δ) args) Δ),
ctx_inst Σ Γ (skipn (context_assumptions Δ) args) (subst_telescope (ctx_inst_sub dom) 0 Δ').
Proof using Type.
revert args Δ' c.
induction Δ using ctx_length_ind; intros.
simpl. unshelve eexists. constructor.
simpl. rewrite skipn_0. now rewrite subst_telescope_empty.
depelim c; simpl.
- specialize (X (subst_telescope [i] 0 Γ0) ltac:(now rewrite /subst_telescope mapi_length)).
rewrite subst_telescope_app in c.
specialize (X _ _ c).
rewrite context_assumptions_subst_telescope in X.
destruct X as [dom codom].
unshelve eexists.
constructor; auto. simpl.
pose proof (ctx_inst_sub_spec dom) as Hsub.
simpl in *. rewrite Nat.add_0_r in codom. rewrite skipn_S.
rewrite subst_app_telescope.
apply make_context_subst_length in Hsub.
rewrite subst_telescope_length Nat.add_0_r in Hsub.
now rewrite Hsub Nat.add_0_r.
- specialize (X (subst_telescope [b] 0 Γ0) ltac:(now rewrite /subst_telescope mapi_length)).
rewrite subst_telescope_app in c.
specialize (X _ _ c).
rewrite context_assumptions_subst_telescope in X.
destruct X as [dom codom].
unshelve eexists.
constructor; auto. simpl.
pose proof (ctx_inst_sub_spec dom) as Hsub.
simpl in *. rewrite Nat.add_0_r in codom.
rewrite subst_app_telescope.
apply make_context_subst_length in Hsub.
rewrite subst_telescope_length Nat.add_0_r in Hsub.
now rewrite Hsub Nat.add_0_r.
Qed.
Lemma ctx_inst_sub_eq {Γ} {Δ : context} {Δ' args args'} (c : ctx_inst Σ Γ args Δ) (d : ctx_inst Σ Γ args' Δ') :
args' = args ->
Δ = Δ' -> ctx_inst_sub c = ctx_inst_sub d.
Proof using Type.
intros -> ->. induction c; depelim d; auto; simpl in *; now rewrite (IHc d).
Qed.
Lemma ctx_inst_app_sub {Γ} {Δ : context} {Δ' args} (c : ctx_inst Σ Γ args (Δ ++ Δ')) :
let (dom, codom) := ctx_inst_app_inv c in
ctx_inst_sub c = ctx_inst_sub codom ++ ctx_inst_sub dom.
Proof using Type.
destruct (ctx_inst_app_inv c).
induction Δ using ctx_length_ind in Δ', c, x, args, c0 |- *. simpl in *. depelim x. simpl in *.
rewrite app_nil_r; apply ctx_inst_sub_eq. now rewrite skipn_0.
now rewrite subst_telescope_empty.
simpl in *. destruct d as [na [b|] ty]; simpl in *.
depelim c; simpl in *.
depelim x; simpl in *.
injection H0. discriminate. injection H0. discriminate.
specialize (H (subst_telescope [b] 0 Γ0) ltac:(now rewrite /subst_telescope mapi_length)).
revert c. rewrite subst_telescope_app.
intros c.
specialize (H _ _ c). simpl in *.
revert H. rewrite context_assumptions_subst_telescope.
intros.
specialize (H x).
revert c0. rewrite subst_app_telescope.
rewrite (ctx_inst_subst_length x) subst_telescope_length.
intros c1.
now rewrite (H c1) app_assoc.
depelim c; depelim x; simpl in *.
specialize (H (subst_telescope [i] 0 Γ0) ltac:(now rewrite /subst_telescope mapi_length)).
revert c. rewrite subst_telescope_app. intros c.
specialize (H _ _ c). simpl in *.
revert H. rewrite context_assumptions_subst_telescope.
intros.
specialize (H x).
revert c0. rewrite subst_app_telescope.
rewrite (ctx_inst_subst_length x) subst_telescope_length.
intros c1.
now rewrite (H c1) app_assoc.
Qed.
Lemma ctx_inst_def {Γ args na b t} (c : ctx_inst Σ Γ args [vdef na b t]) :
((args = []) * (ctx_inst_sub c = [b]))%type.
Proof using Type.
depelim c; simpl in c. depelim c; simpl in *. constructor; simpl in *; auto.
Qed.
Lemma ctx_inst_ass {Γ args na t} (c : ctx_inst Σ Γ args [vass na t]) :
∑ i, ((args = [i]) * (lift_typing typing Σ Γ i (Typ t)) * (ctx_inst_sub c = [i]))%type.
Proof using Type.
depelim c; simpl in *.
depelim c. exists i; constructor; auto.
Qed.
Lemma ctx_inst_spine_subst {Γ Δ args} :
wf_local Σ (Γ ,,, Δ) ->
forall ci : ctx_inst Σ Γ args (List.rev Δ),
spine_subst Σ Γ args (ctx_inst_sub ci) Δ.
Proof using wfΣ.
move=> wfΔ ci.
pose proof (ctx_inst_sub_spec ci) as msub.
eapply make_context_subst_spec in msub.
rewrite List.rev_involutive in msub.
split; pcuic. now eapply wf_local_app_inv in wfΔ as [].
move: ci msub.
induction Δ in wfΔ, args |- *.
simpl. intros ci. depelim ci. constructor.
intros. simpl in ci.
pose proof (ctx_inst_app_sub ci).
destruct (ctx_inst_app_inv ci). rewrite H in msub |- *.
clear ci H.
simpl in c.
apply (@context_subst_app [a]) in msub.
simpl in msub.
destruct a as [na [b|] ty]; simpl in *.
- pose proof (ctx_inst_def c) as [Hargs Hinst].
rewrite Hinst in msub |- *. simpl in *.
destruct msub as [subl subr].
rewrite skipn_S skipn_0 in subr.
generalize dependent x. rewrite context_assumptions_rev.
intros.
depelim wfΔ.
specialize (IHΔ _ wfΔ _ subr). constructor; auto.
red in l0. eapply (substitution (Δ := [])); eauto.
- pose proof (ctx_inst_ass c) as [i [[Hargs Hty] Hinst]].
rewrite Hinst in msub |- *. simpl in *.
destruct msub as [subl subr].
rewrite skipn_S skipn_0 in subr subl.
generalize dependent x. rewrite context_assumptions_rev.
intros.
depelim wfΔ.
specialize (IHΔ _ wfΔ _ subr). constructor; auto.
Qed.
Lemma spine_subst_ctx_inst {Γ Δ args s} :
spine_subst Σ Γ args s Δ ->
ctx_inst Σ Γ args (List.rev Δ).
Proof using Type.
move=> [wfd _ cs subsl].
induction subsl in args, cs |- *.
- depelim cs. constructor.
- depelim cs.
specialize (IHsubsl _ cs).
unshelve eapply ctx_inst_app; tea. cbn.
rewrite /map_decl /=. repeat constructor.
pose proof (ctx_inst_sub_spec IHsubsl) as msub.
eapply make_context_subst_spec in msub.
rewrite List.rev_involutive in msub.
now pose proof (context_subst_fun cs msub); subst s.
- depelim cs.
specialize (IHsubsl _ cs). cbn.
rewrite -(app_nil_r args).
unshelve eapply ctx_inst_app; tea. cbn.
rewrite /map_decl /=. repeat constructor.
Qed.
End WfEnv.
Lemma subst_instance_rev u Γ :
subst_instance u (List.rev Γ) = List.rev (subst_instance u Γ).
Proof.
now rewrite /subst_instance /subst_instance_context /= /map_context List.map_rev.
Qed.
Lemma subst_telescope_subst_context s k Γ :
subst_telescope s k (List.rev Γ) = List.rev (subst_context s k Γ).
Proof.
rewrite /subst_telescope subst_context_alt.
rewrite rev_mapi. apply mapi_rec_ext.
intros n [na [b|] ty] le le'; rewrite /= /subst_decl /map_decl /=;
rewrite List.rev_length Nat.add_0_r in le';
f_equal. f_equal. f_equal. lia. f_equal; lia.
f_equal; lia.
Qed.
Lemma lift_context_subst_context n s Γ: lift_context n 0 (subst_context s 0 Γ) =
subst_context s n (lift_context n 0 Γ).
Proof.
induction Γ in n, s |- *.
- reflexivity.
- rewrite !subst_context_snoc.
rewrite !lift_context_snoc !subst_context_snoc.
f_equal; auto.
rewrite /lift_decl /subst_decl /map_decl.
simpl. f_equal. unfold option_map. destruct (decl_body a).
rewrite !subst_context_length lift_context_length Nat.add_0_r.
rewrite commut_lift_subst_rec; auto. reflexivity.
rewrite !subst_context_length lift_context_length Nat.add_0_r.
rewrite commut_lift_subst_rec; auto.
Qed.
Lemma subst_app_context_gen s s' k Γ : subst_context (s ++ s') k Γ = subst_context s k (subst_context s' (k + #|s|) Γ).
Proof.
induction Γ in k |- *; simpl; auto.
rewrite !subst_context_snoc /= /subst_decl /map_decl /=. simpl.
rewrite IHΓ. f_equal. f_equal.
- destruct a as [na [b|] ty]; simpl; auto.
f_equal. rewrite subst_context_length.
now rewrite subst_app_simpl.
- rewrite subst_context_length.
now rewrite subst_app_simpl.
Qed.
Lemma closed_k_ctx_subst n k ctx : closedn_ctx k ctx = true -> subst_context n k ctx = ctx.
Proof.
induction ctx in n, k |- *; auto.
simpl.
move/andb_and => /= [Hctx Hd].
rewrite subst_context_snoc /snoc /= IHctx // subst_decl_closed //.
Qed.
Fixpoint all_rels (Γ : context) (n : nat) (k : nat) :=
match Γ with
| nil => nil
| cons d vs =>
match decl_body d with
| Some b =>
let s := all_rels vs (S n) k in
(subst0 s (lift k #|s| b)) :: s
| None => tRel n :: all_rels vs (S n) k
end
end.
Lemma all_rels_length Γ n k : #|all_rels Γ n k| = #|Γ|.
Proof.
induction Γ in n, k |- *; simpl; auto.
now destruct a as [? [?|] ?] => /=; simpl; rewrite IHΓ.
Qed.
Lemma nth_error_all_rels_spec Γ n k x i : nth_error (all_rels Γ n k) i = Some x ->
∑ decl, (nth_error Γ i = Some decl) *
match decl_body decl with
| Some b => x = subst0 (all_rels (skipn (S i) Γ) (S n + i) k) (lift k (#|Γ| - S i) b)
| None => x = tRel (n + i)
end.
Proof.
induction Γ in n, k, i, x |- *.
simpl. destruct i; simpl; discriminate.
destruct i; simpl.
destruct a as [? [?|] ?]; simpl.
intros [= <-].
eexists; split; eauto. simpl.
now rewrite skipn_S skipn_0 Nat.add_0_r all_rels_length.
intros [= <-].
eexists; split; eauto. simpl.
now rewrite Nat.add_0_r.
intros. destruct (decl_body a); try discriminate.
rewrite skipn_S.
specialize (IHΓ _ _ _ _ H).
rewrite Nat.add_succ_r. apply IHΓ.
rewrite skipn_S.
specialize (IHΓ _ _ _ _ H).
rewrite Nat.add_succ_r. apply IHΓ.
Qed.
Lemma subst_lift_lift s k t : subst0 (map (lift0 k) s) (lift k #|s| t) = lift0 k (subst0 s t).
Proof.
now rewrite (distr_lift_subst_rec _ _ _ 0 0).
Qed.
#[global]
Hint Rewrite all_rels_length : len.
Lemma all_rels_lift (Δ : context) n : all_rels Δ n (n + #|Δ|) = map (lift0 n) (all_rels Δ 0 #|Δ|).
Proof.
rewrite -{1}(Nat.add_0_r n).
generalize 0 at 1 3. revert n.
induction Δ at 1 3.
simpl. auto.
intros n n'.
destruct a as [na [?|] ?]. simpl.
f_equal.
specialize (IHc n (S n')).
rewrite Nat.add_succ_r in IHc.
rewrite {1}IHc.
rewrite all_rels_length.
assert(#|all_rels c (S n') #|Δ| | = #|c|) by now autorewrite with len.
rewrite -(simpl_lift _ _ _ _ #|c|); try lia.
rewrite -{1}H.
epose proof (distr_lift_subst _ _ n 0).
rewrite Nat.add_0_r in H0. now erewrite <-H0.
specialize (IHc n (S n')).
now rewrite -IHc.
simpl.
f_equal.
specialize (IHc n (S n')).
now rewrite -IHc.
Qed.
Lemma all_rels_subst {cf:checker_flags} Σ Δ Γ t :
wf Σ.1 -> wf_local Σ (Γ ,,, Δ) ->
red Σ.1 (Γ ,,, Δ) t (subst0 (all_rels Δ 0 #|Δ|) (lift #|Δ| #|Δ| t)).
Proof.
intros wfΣ wf.
assert(forall Γ' t (wf : wf_local Σ Γ'),
((All_local_env_over typing
(fun Σ Γ' wfΓ' t T _ =>
forall Γ Δ, Γ' = Γ ,,, Δ ->
red Σ.1 (Γ ,,, Δ) t (subst0 (all_rels Δ 0 #|Δ|) (lift #|Δ| #|Δ| t)))
Σ Γ' wf) *
(match t with
| Some t => forall Γ Δ, Γ' = Γ ,,, Δ ->
red Σ.1 (Γ ,,, Δ) t (subst0 (all_rels Δ 0 #|Δ|) (lift #|Δ| #|Δ| t))
| None => unit end))).
clear t Δ Γ wf. intros Γ' t.
Subterm.rec_wf_rel IH (Γ', t) (Subterm.lexprod (precompose lt (@length context_decl))
(precompose lt (fun x => match x with Some t => S (PCUICSize.size t) | None => 0 end))).
simpl.
rename pr1 into cf.
rename pr0 into Σ.
rename pr2 into wfΣ.
rename pr3 into Γ.
rename pr4 into t. clear H0.
intros wf.
split.
- specialize (IH cf Σ wfΣ).
destruct wf.
constructor.
constructor.
apply (IH Γ t ltac:(left; simpl; lia) wf).
intros; subst Γ.
now apply (IH (Γ0 ,,, Δ) (Some t0) ltac:(left; simpl; lia) wf).
constructor; auto.
apply (IH Γ t ltac:(left; simpl; lia) wf).
intros.
now apply (IH Γ (Some b) ltac:(left; simpl; lia) wf).
now apply (IH Γ (Some t0) ltac:(left; simpl; lia) wf).
- destruct t; [|exact tt].
intros Γ0 Δ ->.
rename Γ0 into Γ.
specialize (IH cf Σ).
assert (All_local_env_over typing
(fun (Σ : PCUICEnvironment.global_env_ext)
(Γ'0 : PCUICEnvironment.context) (_ : wf_local Σ Γ'0)
(t T : term) (_ : Σ;;; Γ'0 |- t : T) =>
forall Γ Δ : context,
Γ'0 = Γ ,,, Δ ->
red Σ.1 (Γ ,,, Δ) t (subst0 (all_rels Δ 0 #|Δ|) (lift #|Δ| #|Δ| t)))
Σ _ wf).
{ specialize (IH wfΣ (Γ ,,, Δ) None).
forward IH. simpl. right. lia.
apply (IH wf). }
clear IH.
change (Γ ,,, Δ) with (Γ ,,, Δ ,,, []).
rewrite -{3}(Nat.add_0_r #|Δ|).
change 0 with #|@nil context_decl| at 2 3.
generalize (@nil context_decl) as Δ'.
induction t using term_ind_size_app; try solve [constructor]; intros Δ'.
* simpl.
destruct (leb_spec_Set (#|Δ| +#|Δ'|) n); simpl.
**
elim: leb_spec_Set => Hle.
destruct (nth_error_spec (all_rels Δ 0 #|Δ|) (#|Δ| + n - #|Δ'|));
rewrite all_rels_length in l0 |- *. lia.
assert (#|Δ| + n - #|Δ| = n) as -> by lia.
reflexivity. lia.
**
elim: leb_spec_Set => Hle.
destruct (nth_error_spec (all_rels Δ 0 #|Δ|) (n - #|Δ'|));
rewrite all_rels_length in l0 |- *; try lia.
eapply nth_error_all_rels_spec in e.
destruct e as [decl [Hnth Hdecl]].
destruct decl as [? [?|] ?]; simpl in Hdecl; subst x.
assert (n = #|Δ'| + (n - #|Δ'|)). lia.
rewrite {1}H.
change (tRel (#|Δ'| + (n - #|Δ'|))) with
(lift0 #|Δ'| (tRel (n - #|Δ'|))).
eapply (weakening_red (Γ' := [])); auto.
{ erewrite on_free_vars_ctx_on_ctx_free_vars; tea.
clear X.
now eapply wf_local_closed_context in wf. }
{ cbn. rewrite /PCUICOnFreeVars.shiftnP app_length. nat_compare_specs => //. }
simpl.
set (i := n - #|Δ'|) in *. clearbody i.
clear l Hle H.
etransitivity.
+ eapply red1_red. constructor.
rewrite nth_error_app_lt; auto.
rewrite Hnth. reflexivity.
+ rewrite -{1 3 4}(firstn_skipn (S i) Δ).
rewrite app_context_assoc.
assert (Hf:#|firstn (S i) Δ| = S i) by now rewrite firstn_length_le; lia.
rewrite app_length Hf.
rewrite all_rels_lift.
erewrite <-(simpl_lift _ _ _ _ #|skipn (S i) Δ|); try lia.
epose proof (distr_lift_subst (lift #|skipn (S i) Δ| (#|Δ| - S i) t)
(all_rels (skipn (S i) Δ) 0 #|skipn (S i) Δ|) (S i) 0).
rewrite Nat.add_0_r in H.
autorewrite with len in H.
rewrite -{}H.
rewrite -{3 4}Hf.
eapply (weakening_red (Γ' := [])); auto. simpl.
{ clear X; apply wf_local_closed_context in wf.
move: wf.
erewrite on_free_vars_ctx_on_ctx_free_vars.
rewrite !on_free_vars_ctx_app => /andP[] onΓ. erewrite onΓ => /=.
rewrite -{1}(firstn_skipn (S i) Δ) on_free_vars_ctx_app => /andP[] //.
}
{ clear X; eapply (nth_error_All_local_env (n:=i)) in wf. 2:len; lia.
rewrite nth_error_app_lt // in wf.
rewrite Hnth /= in wf.
rewrite skipn_app in wf.
replace (S i - #|Δ|) with 0 in wf. 2:lia.
rewrite skipn_0 in wf.
rewrite /on_local_decl /= in wf.
move: wf => [] /subject_closed //.
rewrite is_open_term_closed //. }
rewrite skipn_length; simpl.
unshelve eapply (nth_error_All_local_env_over (n:=i)) in X.
2:{ rewrite nth_error_app_lt //. apply Hnth. }
destruct X as [_ [Xb Xt]].
specialize (Xb Γ (skipn (S i) Δ)).
forward Xb. rewrite skipn_app. unfold app_context. f_equal.
assert(S i - #|Δ| = 0) by lia. rewrite H. apply skipn_0.
now rewrite skipn_length in Xb; try lia.
now rewrite skipn_length.
+ simpl. assert(#|Δ'| + (n - #|Δ'|) = n) as -> by lia.
reflexivity.
+ reflexivity.
* simpl; eapply red_evar.
do 2 apply All2_map_right.
apply (All_All2 X0); auto.
* simpl. eapply red_prod. auto.
specialize (IHt2 (Δ' ,, vass n t1)).
now rewrite -Nat.add_succ_r.
* simpl; eapply red_abs; auto.
rewrite -Nat.add_succ_r.
eapply (IHt2 (Δ' ,, vass n _)).
* simpl; eapply red_letin; auto.
rewrite -Nat.add_succ_r.
eapply (IHt3 (Δ' ,, vdef n _ _)).
* simpl; eapply red_app; auto.
* simpl. rewrite map_branches_k_map_branches_k.
relativize (subst_predicate _ _ _).
eapply red_case.
5:{ reflexivity. }
all:auto.
+ rewrite map_map_compose.
apply All2_map_right. solve_all.
+ destruct X0 as [? [? ?]].
specialize (r (Δ' ,,, inst_case_predicate_context p)).
rewrite app_context_assoc in r. len in r.
cbn. relativize (#|pcontext p| + (_ + _)). eapply r. lia.
+ red in X1 |- *.
eapply All2_map_right; cbn; solve_all.
eapply All_All2; tea.
cbn; intros; solve_all.
specialize (b (Δ' ,,, inst_case_branch_context p x)).
rewrite app_context_assoc in b.
len. rewrite -Nat.add_assoc (Nat.add_comm #|Δ|) Nat.add_assoc.
relativize (#|bcontext x| + _). rewrite Nat.add_comm. eapply b.
now len.
* simpl; eapply red_proj_c. auto.
* simpl; eapply red_fix_congr.
do 2 eapply All2_map_right.
eapply (All_All2 X0); simpl; intuition auto.
rewrite map_length.
specialize (b (Δ' ,,, fix_context m)).
autorewrite with len in b.
rewrite Nat.add_shuffle3.
now rewrite app_context_assoc in b.
* simpl. eapply red_cofix_congr.
do 2 eapply All2_map_right.
eapply (All_All2 X0); simpl; intuition auto.
rewrite map_length.
specialize (b (Δ' ,,, fix_context m)).
autorewrite with len in b.
rewrite Nat.add_shuffle3.
now rewrite app_context_assoc in b.
- specialize (X (Γ ,,, Δ) (Some t) wf). simpl in X.
apply X. reflexivity.
Qed.
Section WfEnv.
Context {cf} {Σ} {wfΣ : wf Σ}.
Lemma all_rels_subst_lift {Δ Γ Δ' t} :
wf_local Σ (Γ ,,, Δ) ->
is_closed_context (Γ ,,, Δ ,,, Δ') ->
is_open_term (Γ ,,, Δ) t ->
Σ ;;; Γ ,,, Δ ,,, Δ' ⊢ lift0 #|Δ'| t =
subst0 (all_rels Δ #|Δ'| (#|Δ| + #|Δ'|)) (lift (#|Δ| + #|Δ'|) #|Δ| t).
Proof using wfΣ.
intros.
rewrite Nat.add_comm.
erewrite <-(simpl_lift _ _ _ _ #|Δ|); try lia.
rewrite all_rels_lift.
have dl := distr_lift_subst (lift #|Δ| #|Δ| t) (all_rels Δ 0 #|Δ|) #|Δ'| 0.
rewrite Nat.add_0_r in dl.
rewrite -{2}(all_rels_length Δ 0 #|Δ|) -{}dl.
eapply (weakening_ws_cumul_pb (Γ'' := Δ') (Γ' := [])) => // /=.
apply red_ws_cumul_pb.
apply into_closed_red => //.
eapply all_rels_subst; auto => //.
eauto with fvs.
Qed.
Lemma lift_context0_app {n Γ Δ} : lift_context n 0 (Γ ,,, Δ) = lift_context n 0 Γ ,,, lift_context n #|Γ| Δ.
Proof using Type.
now rewrite lift_context_app Nat.add_0_r.
Qed.
Lemma spine_subst_to_extended_list_k {Δ Γ} :
wf_local Σ (Γ ,,, Δ) ->
spine_subst Σ (Γ ,,, Δ) (reln [] 0 Δ) (all_rels Δ 0 #|Δ|)
(lift_context #|Δ| 0 Δ).
Proof using wfΣ.
move=> wf.
assert (wf_local Σ (Γ,,, Δ,,, lift_context #|Δ| 0 Δ)).
{ apply weakening_wf_local; auto. }
split; auto.
{ clear wf X.
generalize 0 at 2 3.
induction Δ at 2 3 4; intros n; rewrite ?lift_context_snoc0; simpl; auto.
destruct a as [na [?|] ?] => /=;
rewrite /lift_decl /= /map_decl /=.
specialize (IHc (S n)).
eapply (context_subst_def _ _ _ _ (lift #|Δ| (#|c| + 0) t)) in IHc.
rewrite Nat.add_1_r.
rewrite all_rels_length.
rewrite Nat.add_0_r in IHc |- *.
apply IHc.
rewrite reln_acc.
constructor.
specialize (IHc (S n)).
now rewrite Nat.add_1_r. }
move: X.
generalize (@eq_refl _ Δ).
change Δ with ([] ++ Δ) at 1 5.
change 0 with (length (@nil context_decl)) at 2.
generalize (@nil context_decl).
induction Δ at 1 5 7 10; rewrite /= => l eql.
- constructor.
- specialize (IHc (l ++ [a])).
rewrite -app_assoc in IHc. specialize (IHc eql).
destruct a as [na [?|] ?] => /=;
rewrite lift_context_snoc /lift_decl /map_decl /=.
* rewrite app_length /= Nat.add_1_r in IHc.
rewrite all_rels_length Nat.add_0_r.
intros X. specialize (IHc X).
constructor; auto.
assert (Some (Some t) = option_map decl_body (nth_error Δ #|l|)).
destruct (nth_error_spec Δ #|l|).
rewrite -eql in e.
rewrite nth_error_app_ge in e. lia.
rewrite Nat.sub_diag in e. simpl in e. noconf e. simpl. reflexivity.
rewrite -eql in l0. autorewrite with len in l0. simpl in l0. lia.
eapply (substitution (Δ := []) IHc); auto.
rewrite lift_context0_app !app_context_assoc in X. cbn in X.
eapply wf_local_app_inv in X as [].
rewrite lift_context_snoc0 Nat.add_0_r /= in a. cbn in a.
depelim a. now cbn in l1.
* rewrite app_length /= Nat.add_1_r in IHc.
intros Hwf. specialize (IHc Hwf).
constructor; auto.
pose proof wf as wf'.
rewrite -eql in wf'.
rewrite !app_context_assoc in wf'.
apply wf_local_app_l in wf'. depelim wf'.
rewrite Nat.add_0_r.
eapply type_ws_cumul_pb.
constructor. auto.
rewrite -eql nth_error_app_lt ?app_length /=; try lia.
rewrite nth_error_app_ge // ?Nat.sub_diag //.
destruct l0.
exists x.
change (tSort x) with
(subst0 (all_rels c (S #|l|) #|Δ|) (lift #|Δ| #|c| (tSort x))).
{ eapply (substitution (Γ' := lift_context #|Δ| 0 c) (Δ := [])); cbn; auto.
change (tSort x) with (lift #|Δ| #|c| (tSort x)).
eapply (weakening_typing); eauto. }
eapply ws_cumul_pb_eq_le. simpl.
rewrite -{1}eql. simpl.
rewrite !app_context_assoc.
rewrite /app_context !app_assoc.
epose proof (@all_rels_subst_lift c Γ
(l ++ [{|decl_name := na; decl_body := None; decl_type := decl_type|}]) decl_type).
assert (#|Δ| = #|c| + S #|l|).
{ rewrite -eql. autorewrite with len. simpl. lia. }
rewrite H. rewrite app_length /= in X.
rewrite Nat.add_1_r in X.
unfold app_context in X.
rewrite !app_tip_assoc /= in X.
rewrite -app_assoc.
forward X by auto.
apply X; auto. all:eauto with fvs.
rewrite -app_tip_assoc app_assoc -[(l ++ _) ++ _]app_assoc eql.
eapply wf_local_app_inv in Hwf as []. eauto with fvs.
Qed.
Lemma red_expand_let {Γ na b ty t} :
wf_local Σ (Γ ,,, [vdef na b ty]) ->
is_open_term (Γ ,,, [vdef na b ty]) t ->
Σ ;;; Γ ,, vdef na b ty ⊢ t ⇝ lift0 1 (subst1 b 0 t).
Proof using wfΣ.
intros wfΓ ont.
pose proof (all_rels_subst Σ [vdef na b ty] Γ t wfΣ wfΓ).
simpl in X.
rewrite subst_empty in X.
rewrite distr_lift_subst.
eapply into_closed_red => //; eauto with fvs.
Qed.
Lemma type_it_mkProd_or_LetIn_inv {Γ Δ t s} :
Σ ;;; Γ |- it_mkProd_or_LetIn Δ t : tSort s ->
∑ Δs ts,
[× sorts_local_ctx (lift_typing typing) Σ Γ Δ Δs,
Σ ;;; Γ ,,, Δ |- t : tSort ts,
wf_universe Σ s &
leq_universe Σ (sort_of_products Δs ts) s].
Proof using wfΣ.
intros h. revert Γ t s h.
induction Δ; intros.
- exists [], s; splits. apply h. eauto with pcuic. apply leq_universe_refl.
- destruct a as [na [b|] ty]; simpl in *;
rewrite /mkProd_or_LetIn /= in h.
* specialize (IHΔ _ _ _ h) as (Δs & ts & [sorts IHΔ leq]).
exists Δs, ts.
pose proof (PCUICWfUniverses.typing_wf_universe _ IHΔ) as wfts.
eapply inversion_LetIn in IHΔ as [s' [? [? [? [? e]]]]]; auto.
splits; eauto. now eexists.
eapply (type_ws_cumul_pb (pb:=Cumul)). eapply t2. apply isType_Sort; pcuic.
eapply ws_cumul_pb_LetIn_l_inv in e; auto.
eapply ws_cumul_pb_Sort_r_inv in e as [u' [redu' cumu']].
transitivity (tSort u').
2:{ eapply ws_cumul_pb_compare; eauto with fvs.
eapply typing_wf_local in t2. eauto with fvs.
econstructor. eauto with fvs. }
eapply ws_cumul_pb_red.
exists (tSort u'), (tSort u'). split; auto.
3:now constructor.
transitivity (lift0 1 (x {0 := b})).
eapply red_expand_let. pcuic.
eapply type_closed in t2.
rewrite -is_open_term_closed //.
change (tSort u') with (lift0 1 (tSort u')).
eapply (weakening_closed_red (Γ := Γ ,,, Δ) (Γ' := []) (Γ'' := [_])); auto with fvs.
apply typing_wf_local in t2. eauto with fvs.
eapply closed_red_refl; eauto with fvs.
* specialize (IHΔ _ _ _ h) as (Δs & ts & [sorts IHΔ leq]).
eapply inversion_Prod in IHΔ as [? [? [? [? e]]]]; tea.
exists (x :: Δs), x0. splits; tea.
eapply ws_cumul_pb_Sort_inv in e.
transitivity (sort_of_products Δs ts); auto using leq_universe_product.
simpl. eapply leq_universe_sort_of_products_mon.
eapply Forall2_same. reflexivity.
exact: e.
Qed.
Lemma leq_universe_sort_of_products {u v} :
leq_universe Σ v (sort_of_products u v).
Proof using Type.
induction u; simpl; auto.
- reflexivity.
- etransitivity; tea.
eapply leq_universe_sort_of_products_mon => //.
eapply Forall2_same. reflexivity.
eapply leq_universe_product.
Qed.
Lemma inversion_it_mkProd_or_LetIn {Γ Δ t s} :
Σ ;;; Γ |- it_mkProd_or_LetIn Δ t : tSort s ->
Σ ;;; Γ ,,, Δ |- t : tSort s.
Proof using wfΣ.
move/type_it_mkProd_or_LetIn_inv => [Δs [ts [hΔ ht hs leq]]].
eapply type_Cumul; tea. eapply type_Sort; pcuic.
eapply cumul_Sort.
transitivity (sort_of_products Δs ts); auto using leq_universe_product.
apply leq_universe_sort_of_products.
Qed.
Lemma isType_it_mkProd_or_LetIn_app {Γ Δ Δ' args T s} :
Σ ;;; Γ |- it_mkProd_or_LetIn (Δ ,,, Δ') T : tSort s ->
subslet Σ Γ args (smash_context [] Δ) ->
Σ ;;; Γ |- subst_let_expand args Δ (it_mkProd_or_LetIn Δ' T) : tSort s.
Proof using wfΣ.
intros Hs sub.
move: Hs. rewrite it_mkProd_or_LetIn_app.
move/inversion_it_mkProd_or_LetIn => Hs.
eapply typing_expand_lets in Hs.
eapply (PCUICSubstitution.substitution (Δ := [])) in Hs; tea.
Qed.
Lemma lift_to_extended_list_k n Γ : map (lift n #|Γ|) (to_extended_list_k Γ 0) =
to_extended_list_k Γ 0.
Proof using Type.
rewrite /to_extended_list_k.
change [] with (map (lift n #|Γ|) []) at 2.
rewrite -(Nat.add_0_r #|Γ|).
generalize 0.
move:(@nil term).
induction Γ; simpl; auto.
intros l n'.
destruct a as [? [?|] ?].
specialize (IHΓ l (S n')).
rewrite Nat.add_succ_r in IHΓ.
now rewrite Nat.add_1_r IHΓ.
specialize (IHΓ (tRel n' :: l) (S n')).
rewrite Nat.add_succ_r in IHΓ.
rewrite Nat.add_1_r IHΓ. simpl.
destruct (leb_spec_Set (S (#|Γ| + n')) n'). lia.
reflexivity.
Qed.
Lemma reln_subst acc s Γ k :
reln (map (subst s (k + #|Γ|)) acc) k (subst_context s 0 Γ) =
map (subst s (k + #|Γ|)) (reln acc k Γ).
Proof using Type.
induction Γ in acc, s, k |- *; simpl; auto.
rewrite subst_context_snoc.
simpl.
destruct a as [? [?|] ?]; simpl in *.
specialize (IHΓ acc s (S k)).
rewrite Nat.add_succ_r !Nat.add_1_r -IHΓ.
f_equal.
specialize (IHΓ (tRel k :: acc) s (S k)).
rewrite Nat.add_succ_r !Nat.add_1_r -IHΓ.
f_equal.
simpl.
destruct (leb_spec_Set (S (k + #|Γ|)) k). lia.
reflexivity.
Qed.
Lemma subst_context_telescope s k Γ : subst_context s k Γ = List.rev (subst_telescope s k (List.rev Γ)).
Proof using Type.
now rewrite subst_telescope_subst_context List.rev_involutive.
Qed.
Lemma ctx_inst_sub_to_extended_list_k Γ args Δ :
forall inst : ctx_inst Σ Γ args Δ,
map (subst0 (ctx_inst_sub inst)) (to_extended_list_k (List.rev Δ) 0) = args.
Proof using Type.
induction inst; simpl; rewrite /to_extended_list_k; auto.
rewrite reln_app. simpl.
have len := ctx_inst_subst_length inst0.
rewrite subst_telescope_length in len.
rewrite List.rev_length.
f_equal.
rewrite nth_error_app_ge. lia.
assert(#|Δ| + 0 - 0 - #|ctx_inst_sub inst0| = 0) as -> by lia.
cbn. apply lift0_id.
rewrite -{2}IHinst.
rewrite -map_subst_app_simpl.
rewrite -map_map_compose. f_equal.
simpl. unfold to_extended_list_k.
epose proof (reln_subst [] [i] (List.rev Δ) 0). simpl in H.
rewrite subst_context_telescope in H.
rewrite List.rev_involutive in H. rewrite H.
now rewrite List.rev_length len.
rewrite reln_app. simpl.
have len := ctx_inst_subst_length inst0.
rewrite subst_telescope_length in len.
rewrite -{2}IHinst.
rewrite -map_subst_app_simpl.
rewrite -map_map_compose. f_equal.
simpl. unfold to_extended_list_k.
epose proof (reln_subst [] [b] (List.rev Δ) 0). simpl in H.
rewrite subst_context_telescope in H.
rewrite List.rev_involutive in H. rewrite H.
now rewrite List.rev_length len.
Qed.
Lemma spine_subst_subst_to_extended_list_k {Γ args s Δ} :
spine_subst Σ Γ args s Δ ->
map (subst0 s) (to_extended_list_k Δ 0) = args.
Proof using Type.
intros [_ _ sub _].
rewrite /to_extended_list_k.
rewrite -(map_lift0 args).
generalize 0 at 1 2 3.
induction sub; simpl; auto.
intros n.
rewrite reln_acc.
rewrite !map_app.
simpl. rewrite Nat.leb_refl Nat.sub_diag /=.
simpl.
f_equal. rewrite -IHsub.
rewrite reln_lift.
rewrite (reln_lift 1).
rewrite -{4}(Nat.add_0_r n).
rewrite (reln_lift n 0).
rewrite !map_map_compose.
apply map_ext.
intros x. rewrite (subst_app_decomp [a] s).
f_equal. simpl.
rewrite -(commut_lift_subst_rec _ _ _ 0) //.
rewrite simpl_subst_k //.
intros n.
rewrite -IHsub.
rewrite reln_lift.
rewrite (reln_lift 1).
rewrite -{4}(Nat.add_0_r n).
rewrite (reln_lift n 0).
rewrite !map_map_compose.
apply map_ext.
intros x. rewrite (subst_app_decomp [subst0 s b] s).
f_equal. simpl.
rewrite -(commut_lift_subst_rec _ _ _ 0) //.
rewrite simpl_subst_k //.
Qed.
Lemma spine_subst_subst_to_extended_list_k_gen {Γ args s Δ Δ'} :
spine_subst Σ Γ args s Δ ->
to_extended_list_k Δ 0 = to_extended_list_k Δ' 0 ->
map (subst0 s) (to_extended_list_k Δ' 0) = args.
Proof using Type.
intros sp <-; eapply spine_subst_subst_to_extended_list_k; eauto.
Qed.
Lemma arity_spine_eq {Γ T T'} :
isType Σ Γ T' ->
T = T' -> arity_spine Σ Γ T [] T'.
Proof using Type. intros H ->; constructor;auto. Qed.
Lemma typing_spine_wf_local {Γ T args T'} :
typing_spine Σ Γ T args T' ->
wf_local Σ Γ.
Proof using Type.
move/typing_spine_isType_dom; pcuic.
Qed.
Hint Resolve typing_spine_wf_local : pcuic.
Lemma substitution_ws_cumul_pb_vass {pb : conv_pb} {Γ} {a na ty M N} :
Σ ;;; Γ |- a : ty ->
Σ ;;; Γ,, vass na ty ⊢ M ≤[pb] N ->
Σ ;;; Γ ⊢ M{0 := a} ≤[pb] N{0 := a}.
Proof using wfΣ.
intros ha hm.
eapply (PCUICConversion.substitution_ws_cumul_pb (Γ' := [vass na ty]) (s := [a]) (Γ'':=[])); eauto with pcuic.
Qed.
Lemma substitution_ws_cumul_pb_vdef {pb : conv_pb} {Γ} {a na ty M N} :
wf_local Σ (Γ ,, vdef na a ty) ->
Σ ;;; Γ,, vdef na a ty ⊢ M ≤[pb] N ->
Σ ;;; Γ ⊢ M{0 := a} ≤[pb] N{0 := a}.
Proof using wfΣ.
intros ha hm.
eapply (PCUICConversion.substitution_ws_cumul_pb (Γ' := [vdef na a ty]) (s := [a]) (Γ'':=[])); eauto with pcuic.
eapply subslet_def_tip. now depelim ha.
Qed.
Lemma subst0_it_mkProd_or_LetIn s Γ T : subst s 0 (it_mkProd_or_LetIn Γ T) =
it_mkProd_or_LetIn (subst_context s 0 Γ) (subst s #|Γ| T).
Proof using Type.
now rewrite subst_it_mkProd_or_LetIn Nat.add_0_r.
Qed.
Lemma typing_spine_inv {Γ Δ : context} {T args args' T'} :
#|args| = context_assumptions Δ ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T' ->
∑ args_sub,
spine_subst Σ Γ args args_sub Δ *
typing_spine Σ Γ (subst0 args_sub T) args' T'.
Proof using wfΣ.
intros len.
revert args len T.
induction Δ as [|d Δ] using ctx_length_rev_ind; intros args. simpl.
destruct args; simpl; try discriminate.
- intros _ T sp; exists []. split; [repeat constructor|.. ]; auto; rewrite ?subst_empty //.
all:pcuic.
- rewrite context_assumptions_app => eq T sp.
assert (wfΓΔ := isType_it_mkProd_or_LetIn_wf_local (Δ := Δ ++ [d])
(typing_spine_isType_dom sp)).
rewrite it_mkProd_or_LetIn_app in sp.
destruct d as [? [b|] ?]; simpl in *.
+ rewrite Nat.add_0_r in eq.
eapply typing_spine_letin_inv in sp => //.
rewrite /subst1 subst_it_mkProd_or_LetIn in sp.
specialize (X (subst_context [b] 0 Δ) ltac:(now autorewrite with len)).
specialize (X args ltac:(now rewrite context_assumptions_subst)).
rewrite Nat.add_0_r in sp.
destruct (X _ sp) as [args_sub [sps sp']].
exists (args_sub ++ [b]); split; auto; [constructor|..]; pcuic.
* eapply context_subst_app_inv.
simpl. rewrite skipn_0.
move: (context_subst_length sps).
len.
move=> eq'. rewrite eq'.
rewrite skipn_all_app firstn_app_left //.
split; auto. apply sps. rewrite -{2}(subst_empty 0 b).
constructor. constructor.
* eapply subslet_app => //. eapply sps.
rewrite -{1}(subst_empty 0 b).
repeat constructor. rewrite !subst_empty.
eapply All_local_env_app_inv in wfΓΔ as [_ wf].
eapply All_local_env_app_inv in wf as [wfd _].
depelim wfd. apply l0.
* rewrite subst_app_simpl.
move: (context_subst_length sps).
now autorewrite with len => <-.
+ rewrite /mkProd_or_LetIn /= in sp.
destruct args as [|a args]; simpl in eq; try lia.
specialize (X (subst_context [a] 0 Δ) ltac:(now autorewrite with len)).
specialize (X args ltac:(now rewrite context_assumptions_subst)).
specialize (X (subst [a] #|Δ| T)).
dependent elimination sp as [spcons isty isty' e tyhd sp].
eapply ws_cumul_pb_Prod_Prod_inv in e as [eqna conv cum]; auto.
eapply (substitution_ws_cumul_pb_vass (a:=hd0)) in cum; auto.
assert (Σ ;;; Γ |- hd0 : decl_type).
{ eapply (type_ws_cumul_pb (pb:=Conv)); tea. 2:now symmetry.
now eapply isType_tProd in isty as []. }
eapply isType_apply in isty; tea.
eapply typing_spine_strengthen in sp. 3:tea. 2:tas.
rewrite /subst1 subst0_it_mkProd_or_LetIn in sp; auto.
specialize (X sp).
destruct X as [args_sub [sps sp']].
exists (args_sub ++ [hd0]); split; auto; [constructor|..]; pcuic.
* eapply context_subst_app_inv.
simpl. rewrite skipn_S skipn_0.
move: (context_subst_length sps). len.
move=> eq'. rewrite eq'.
rewrite skipn_all_app firstn_app_left //.
split; auto. apply sps.
eapply (context_subst_ass _ []). constructor.
* eapply subslet_app => //. eapply sps.
rewrite -{1}(subst_empty 0 hd0).
repeat constructor. now rewrite !subst_empty.
* rewrite subst_app_simpl.
move: (context_subst_length sps).
now autorewrite with len => <-.
Qed.
Arguments ctx_inst_nil {typing} {Σ} {Γ}.
Arguments PCUICTyping.ctx_inst_ass {typing} {Σ} {Γ} {na t i inst Δ}.
Arguments PCUICTyping.ctx_inst_def {typing} {Σ} {Γ} {na b t inst Δ}.
Lemma spine_subst_ctx_inst_sub {Γ args argsub Δ} (sp : spine_subst Σ Γ args argsub Δ) :
ctx_inst_sub (spine_subst_ctx_inst sp) = argsub.
Proof using Type.
set (ci := spine_subst_ctx_inst sp).
pose proof (ctx_inst_sub_spec ci).
eapply make_context_subst_spec in H. rewrite List.rev_involutive in H.
now rewrite (context_subst_fun sp H).
Qed.
Lemma typing_spine_ctx_inst {Γ Δ : context} {T args args' T'} :
#|args| = context_assumptions Δ ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T' ->
∑ argsi : ctx_inst Σ Γ args (List.rev Δ),
typing_spine Σ Γ (subst0 (ctx_inst_sub argsi) T) args' T'.
Proof using wfΣ.
move=> len /(typing_spine_inv len) [argsub [sp Hargs']].
exists (spine_subst_ctx_inst sp).
now rewrite spine_subst_ctx_inst_sub.
Qed.
Lemma typing_spine_app {Γ ty args na A B arg} :
typing_spine Σ Γ ty args (tProd na A B) ->
Σ ;;; Γ |- arg : A ->
typing_spine Σ Γ ty (args ++ [arg]) (B {0 := arg}).
Proof using wfΣ.
intros H; revert arg.
dependent induction H.
- intros arg Harg. simpl. econstructor; eauto.
eapply isType_apply in i0; tea.
constructor; auto. eauto with fvs pcuic.
- intros arg Harg.
econstructor; eauto.
Qed.
Lemma typing_spine_nth_error {Γ Δ T args n arg concl} :
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) args concl ->
nth_error args n = Some arg ->
(n < context_assumptions Δ) ->
∑ decl, (nth_error (smash_context [] Δ) (context_assumptions Δ - S n) = Some decl) *
(Σ ;;; Γ |- arg : subst0 (List.rev (firstn n args)) (decl_type decl)).
Proof using wfΣ.
revert n args T.
induction Δ using ctx_length_rev_ind => /= // n args T.
- simpl. lia.
- rewrite it_mkProd_or_LetIn_app context_assumptions_app.
destruct d as [na [b|] ty]; simpl.
+ move=> sp. rewrite /= Nat.add_0_r. simpl.
eapply typing_spine_letin_inv in sp => //.
rewrite /subst1 subst_it_mkProd_or_LetIn Nat.add_0_r in sp.
specialize (X (subst_context [b] 0 Γ0) ltac:(len; lia) n args _ sp).
rewrite context_assumptions_subst in X.
move=> Hnth Hn. specialize (X Hnth Hn) as [decl [nthsmash Hty]].
exists decl; split; auto.
rewrite smash_context_app. simpl.
now rewrite -(smash_context_subst []) /= subst_context_nil.
+ simpl.
move=> sp.
dependent elimination sp as [spnil _ _ _|spcons isty isty' e e' sp]; rewrite ?nth_error_nil //.
destruct n as [|n']; simpl.
* move=> [=] eq; subst hd0.
move=> Hctx. exists {| decl_name := na; decl_body := None; decl_type := ty |}.
rewrite smash_context_app. simpl.
rewrite nth_error_app_ge; rewrite smash_context_length /=. lia.
assert(context_assumptions Γ0 + 1 - 1 - context_assumptions Γ0 = 0) as -> by lia.
split; auto. rewrite subst_empty.
pose proof (isType_wf_local isty).
eapply ws_cumul_pb_Prod_Prod_inv in e as [conv cum]; auto.
eapply (type_ws_cumul_pb (pb:=Conv)); eauto.
eapply isType_tProd in isty as [dom codom]; auto. cbn in *.
now symmetry.
* move=> Hnth Hn'.
pose proof (isType_wf_local isty).
eapply isType_tProd in isty as [dom' codom']; auto. cbn in *.
eapply ws_cumul_pb_Prod_Prod_inv in e as [conv cum e]; auto. simpl in codom'.
assert (Σ ;;; Γ |- hd0 : ty).
{ eapply (type_ws_cumul_pb (pb:=Conv)); eauto. now symmetry. }
unshelve eapply (isType_subst (Δ:=[vass na ty]) [hd0]) in codom'.
2:{ now eapply subslet_ass_tip. }
specialize (X (subst_context [hd0] 0 Γ0) ltac:(autorewrite with len; lia)).
eapply substitution_ws_cumul_pb_vass in e; tea.
specialize (X n' tl0 (subst [hd0] #|Γ0| T)).
forward X.
rewrite -subst0_it_mkProd_or_LetIn.
eapply typing_spine_strengthen; eauto.
specialize (X Hnth).
forward X by (rewrite context_assumptions_subst; lia).
destruct X as [decl [Hnth' Hty]].
rewrite (smash_context_subst []) nth_error_subst_context in Hnth'.
rewrite smash_context_app. simpl.
rewrite context_assumptions_subst in Hnth'.
replace (context_assumptions Γ0 + 1 - S (S n')) with
(context_assumptions Γ0 - S n') by lia.
rewrite nth_error_app_context_lt ?smash_context_length. lia.
destruct (nth_error (smash_context [] Γ0) _) eqn:Heq; try discriminate.
simpl in Hnth'. exists c; split; auto.
noconf Hnth'.
rewrite /= smash_context_length /= in Hty.
replace ((context_assumptions Γ0 - S (context_assumptions Γ0 - S n') + 0))
with n' in Hty by lia.
rewrite subst_app_simpl /= List.rev_length firstn_length_le.
now eapply nth_error_Some_length in Hnth.
assumption.
Qed.
Import PCUICInstDef PCUICInstConv.
Local Open Scope sigma.
Lemma spine_subst_smash {Γ inst s Δ} :
spine_subst Σ Γ inst s Δ ->
spine_subst Σ Γ inst (List.rev inst) (smash_context [] Δ).
Proof using wfΣ.
intros [].
assert (context_subst (smash_context [] Δ) inst (List.rev inst)).
{ apply closed_wf_local in spine_dom_wf0.
clear -inst_ctx_subst0 spine_dom_wf0. induction inst_ctx_subst0.
constructor. rewrite List.rev_app_distr /=.
rewrite smash_context_acc. simpl.
constructor. auto.
simpl. rewrite smash_context_acc. simpl. auto.
auto. }
split; auto.
- eapply All_local_env_app; split; auto.
eapply wf_local_rel_smash_context; auto.
- induction inst_subslet0 in inst, inst_ctx_subst0, spine_codom_wf0 |- *.
depelim inst_ctx_subst0.
+ constructor.
+ depelim inst_ctx_subst0.
simpl. rewrite smash_context_acc.
simpl. rewrite List.rev_app_distr.
depelim spine_codom_wf0.
constructor. now apply IHinst_subslet0.
eapply meta_conv. eauto.
simpl.
autorewrite with sigma.
apply inst_ext.
unfold Upn. rewrite subst_consn_compose.
autorewrite with sigma.
apply subst_consn_proper.
2:{ (rewrite subst_consn_shiftn; try now autorewrite with len); [].
autorewrite with sigma.
rewrite subst_consn_shiftn //.
rewrite List.rev_length.
now apply context_subst_length2 in inst_ctx_subst0. }
clear -inst_ctx_subst0.
rewrite map_inst_idsn. now autorewrite with len.
now apply context_subst_extended_subst.
+ simpl. rewrite smash_context_acc.
simpl. depelim spine_codom_wf0.
depelim inst_ctx_subst0; apply IHinst_subslet0; auto.
Qed.
Lemma ctx_inst_sub_subst {Γ Δ : context} {args} :
forall ci : ctx_inst Σ Γ args (List.rev Δ),
ctx_inst_sub ci = map (subst0 (List.rev args)) (extended_subst Δ 0).
Proof using Type.
intros ci.
pose proof (ctx_inst_sub_spec ci).
eapply make_context_subst_spec in H.
revert H. generalize (ctx_inst_sub ci). clear ci.
intros l cs.
apply context_subst_extended_subst in cs.
rewrite List.rev_involutive in cs.
rewrite cs. apply map_ext => t.
now rewrite subst0_inst.
Qed.
Lemma typing_spine_ctx_inst_smash {Γ Δ : context} {T args args' T'} :
#|args| = context_assumptions Δ ->
typing_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T' ->
spine_subst Σ Γ args (List.rev args) (smash_context [] Δ) *
typing_spine Σ Γ (subst_let_expand (List.rev args) Δ T) args' T'.
Proof using wfΣ.
intros.
pose proof (typing_spine_isType_dom X).
eapply isType_it_mkProd_or_LetIn_wf_local in X0.
eapply typing_spine_ctx_inst in X as [argsi sp]; tea.
unshelve epose proof (ctx_inst_spine_subst _ argsi).
1: now pcuic.
pose proof (spine_subst_smash X). split => //.
rewrite (ctx_inst_sub_subst argsi) in sp.
rewrite /subst_let_expand.
rewrite /expand_lets /expand_lets_k /=.
rewrite distr_subst. len.
rewrite simpl_subst_k. now len.
assumption.
Qed.
Lemma shift_subst_consn_tip t : ↑ ∘s ([t] ⋅n ids) =1 ids.
Proof using Type.
rewrite /subst_consn; intros [|i] => /= //.
Qed.
Lemma subst_context_lift_id Γ k : subst_context [tRel 0] k (lift_context 1 (S k) Γ) = Γ.
Proof using Type.
rewrite subst_context_alt lift_context_alt.
rewrite mapi_compose.
replace Γ with (mapi (fun k x => x) Γ) at 2.
2:unfold mapi; generalize 0; induction Γ; simpl; intros; auto; congruence.
apply mapi_ext.
len.
intros n [? [?|] ?]; unfold lift_decl, subst_decl, map_decl; simpl.
generalize (Nat.pred #|Γ| - n).
intros.
now rewrite !Nat.add_succ_r !subst_rel0_lift_id.
now rewrite !Nat.add_succ_r !subst_rel0_lift_id.
Qed.
Lemma subst_extended_subst s Γ : extended_subst (subst_context s 0 Γ) 0 =
map (subst s (context_assumptions Γ)) (extended_subst Γ 0).
Proof using Type.
induction Γ as [|[na [b|] ty] Γ]; simpl; auto; rewrite subst_context_snoc /=;
autorewrite with len; rewrite ? (lift_extended_subst _ 1); f_equal; auto.
- rewrite IHΓ.
rewrite commut_lift_subst_rec. auto.
rewrite distr_subst. now autorewrite with len.
- rewrite IHΓ.
rewrite !map_map_compose. apply map_ext.
intros x.
erewrite (commut_lift_subst_rec). lia_f_equal.
lia.
Qed.
Lemma map_subst_extended_subst_lift_to_extended_list_k Γ :
map (subst0 (extended_subst Γ 0)) (map (lift (context_assumptions Γ) #|Γ|)
(to_extended_list Γ)) = to_extended_list (smash_context [] Γ).
Proof using Type.
induction Γ as [|[na [b|] ty] ?]; cbn; auto.
rewrite (reln_lift 1).
rewrite -[reln [] 0 (smash_context [] Γ)]IHΓ.
rewrite !map_map_compose. apply map_ext => x.
rewrite -Nat.add_1_r -(permute_lift _ _ _ 1). lia.
rewrite (subst_app_decomp [_]).
rewrite simpl_subst_k /= //.
rewrite reln_acc (reln_lift 1) map_app /=.
rewrite smash_context_acc /= (reln_acc [tRel 0]) (reln_lift 1) map_app /=.
f_equal.
rewrite -[reln [] 0 (smash_context [] Γ)]IHΓ.
rewrite !map_map_compose. apply map_ext => x.
rewrite -(Nat.add_1_r #|Γ|) -(permute_lift _ _ _ 1). lia.
rewrite (subst_app_decomp [_]).
rewrite simpl_subst_k /= //.
rewrite lift_extended_subst.
rewrite distr_lift_subst. f_equal.
autorewrite with len. rewrite simpl_lift; lia_f_equal.
Qed.
Lemma arity_spine_it_mkProd_or_LetIn_smash {Γ Δ T args args' T'} :
subslet Σ Γ (List.rev args) (smash_context [] Δ) ->
arity_spine Σ Γ (subst_let_expand (List.rev args) Δ T) args' T' ->
arity_spine Σ Γ (it_mkProd_or_LetIn Δ T) (args ++ args') T'.
Proof using Type.
intros subsl asp.
rewrite /subst_let_expand /expand_lets /expand_lets_k in asp.
move: Δ T args subsl asp.
induction Δ using ctx_length_rev_ind => T args subsl asp.
- simpl in subsl. simpl in asp. rewrite subst_empty lift0_id in asp. depelim subsl.
rewrite /= H !subst_empty in asp. destruct args => //.
simpl in H. apply (f_equal (@List.length _)) in H. simpl in H.
rewrite app_length /= in H. lia.
- rewrite it_mkProd_or_LetIn_app /= /mkProd_or_LetIn /=.
destruct d as [na [b|] ty]; simpl in *.
* constructor. rewrite /subst1 subst_it_mkProd_or_LetIn.
rewrite Nat.add_0_r.
rewrite smash_context_app smash_context_acc /= in subsl.
rewrite lift0_id /= subst_context_nil app_nil_r
lift0_context in subsl.
rewrite -(smash_context_subst []) /= subst_context_nil in subsl.
rewrite subst_empty in subsl.
apply (X (subst_context [b] 0 Γ0) ltac:(now autorewrite with len)
(subst [b] #|Γ0| T) _ subsl).
rewrite extended_subst_app /= in asp.
rewrite !subst_empty lift0_id lift0_context in asp.
erewrite subst_app_simpl' in asp.
2:now autorewrite with len.
simpl in asp. autorewrite with len in asp.
simpl in asp.
autorewrite with len.
now rewrite -{1}(Nat.add_0_r #|Γ0|) distr_lift_subst_rec /= Nat.add_0_r.
* simpl in *. len in asp.
simpl in asp.
assert (len:=subslet_length subsl).
len in len. simpl in len.
rewrite Nat.add_1_r in len.
rewrite smash_context_app smash_context_acc /= in subsl.
rewrite subst_context_lift_id in subsl.
eapply subslet_app_inv in subsl as [subsl subsr].
destruct args; simpl in * => //.
noconf len.
len in subsl; len in subsr. simpl in *.
rewrite -H in subsl subsr. rewrite skipn_all_app_eq ?List.rev_length in subsl subsr => //.
rewrite (firstn_app_left) ?firstn_0 ?app_nil_r ?List.rev_length in subsr => //.
depelim subsl.
constructor. now rewrite subst_empty in t1.
rewrite /subst1 subst_it_mkProd_or_LetIn Nat.add_0_r.
rewrite -(smash_context_subst []) /= in subsr.
apply (X (subst_context [t] 0 Γ0) ltac:(now autorewrite with len)
(subst [t] #|Γ0| T) _ subsr).
rewrite extended_subst_app /= in asp.
rewrite subst_context_lift_id in asp.
erewrite subst_app_simpl' in asp.
2:now autorewrite with len.
simpl in asp.
autorewrite with len.
rewrite -{1}(Nat.add_0_r #|Γ0|) distr_lift_subst_rec /= Nat.add_0_r.
move: asp. rewrite subst_app_simpl /=; autorewrite with len.
rewrite distr_subst. autorewrite with len.
rewrite (distr_subst_rec _ _ [t]).
cbn [map]. rewrite -H. erewrite (subst_rel_eq _ _ 0) =>//.
simpl; autorewrite with len.
rewrite (Nat.add_1_r #|args|).
erewrite <-(simpl_lift T #|args| _ 1 (#|Γ0| + 1 + #|args|)).
all:try lia.
rewrite (simpl_subst_k) //.
now rewrite subst_extended_subst H.
Qed.
(** This shows that we can promote an argument spine for a given context to
a spine for a context whose types are higher in the cumulativity relation.
*)
Lemma subslet_cumul {pb Δ args Γ Γ'} :
assumption_context Γ -> assumption_context Γ' ->
wf_local Σ (Δ ,,, Γ) ->
wf_local Σ (Δ ,,, Γ') ->
ws_cumul_ctx_pb_rel pb Σ Δ Γ Γ' ->
subslet Σ Δ args Γ -> subslet Σ Δ args Γ'.
Proof using wfΣ.
intros ass ass' wf wf' a2.
destruct a2.
induction a in wf, wf', args, ass, ass' |- *.
- inversion 1; constructor.
- intros subsl; depelim subsl.
2:{ elimtype False; inv ass. }
specialize (IHa s).
forward IHa by now depelim ass.
forward IHa by now depelim ass'.
depelim wf.
depelim wf'.
2:{ elimtype False; inv ass'. }
specialize (IHa wf wf' subsl).
constructor; auto.
eapply type_ws_cumul_pb; eauto. depelim p.
eapply isType_subst. exact IHa. eauto.
depelim p.
eapply (PCUICConversion.substitution_ws_cumul_pb (s:=s) (Γ' := Γ) (Γ'' := [])); eauto.
Qed.
Lemma spine_subst_cumul {Δ args Γ Γ'} :
assumption_context Γ -> assumption_context Γ' ->
wf_local Σ (Δ ,,, Γ) ->
wf_local Σ (Δ ,,, Γ') ->
ws_cumul_ctx_pb_rel Cumul Σ Δ Γ Γ' ->
spine_subst Σ Δ args (List.rev args) Γ ->
spine_subst Σ Δ args (List.rev args) Γ'.
Proof using wfΣ.
intros ass ass' wf wf' a2.
intros []; split; auto.
- clear -a2 ass ass' inst_ctx_subst0.
revert inst_ctx_subst0; generalize (List.rev args).
intros l ctxs.
induction ctxs in ass, Γ', ass', a2 |- *; depelim a2; try (simpl in H; noconf H); try constructor; auto.
* depelim a. constructor.
* depelim a. depelim a0. econstructor. eapply IHctxs. now depelim ass.
now depelim ass'. red. split => //.
* elimtype False; depelim ass.
- eapply subslet_cumul. 6:eauto. all:eauto.
Qed.
Lemma type_mkApps {Γ t u T t_ty} :
Σ ;;; Γ |- t : t_ty ->
typing_spine Σ Γ t_ty u T ->
Σ ;;; Γ |- mkApps t u : T.
Proof using Type.
intros Ht Hsp.
revert t Ht. induction Hsp; simpl; auto.
intros t Ht. eapply type_ws_cumul_pb; eauto.
intros.
specialize (IHHsp (tApp t0 hd)). apply IHHsp.
destruct i as [s Hs].
eapply type_App; eauto. eapply i0.π2.
eapply type_ws_cumul_pb; eauto.
Qed.
Lemma pre_type_mkApps_arity {Γ t u tty T} :
Σ;;; Γ |- t : tty -> isType Σ Γ tty ->
arity_spine Σ Γ tty u T ->
Σ;;; Γ |- mkApps t u : T.
Proof using wfΣ.
intros Ht Hty Har.
eapply type_mkApps; tea.
eapply wf_arity_spine_typing_spine.
constructor; tas.
Qed.
Lemma map_subst_extended_subst Γ k :
map (subst0 (List.rev (to_extended_list_k Γ k))) (extended_subst Γ 0) =
all_rels Γ k 0.
Proof using Type.
unfold to_extended_list_k.
induction Γ in k |- *; simpl; auto.
destruct a as [na [b|] ty]; simpl.
f_equal. len.
rewrite lift0_id.
rewrite distr_subst. autorewrite with len.
rewrite simpl_subst_k. len.
rewrite IHΓ. now rewrite Nat.add_1_r.
rewrite IHΓ. now rewrite Nat.add_1_r.
rewrite reln_acc List.rev_app_distr /=.
rewrite (map_subst_app_decomp [tRel k]).
simpl. f_equal. rewrite lift_extended_subst.
rewrite map_map_compose -IHΓ. apply map_ext.
intros x. f_equal. now rewrite Nat.add_1_r.
len. simpl.
rewrite simpl_subst // lift0_id //.
Qed.
Lemma subst_ext_list_ext_subst Γ k' k t :
subst (List.rev (to_extended_list_k Γ k)) k'
(subst (extended_subst Γ 0) k'
(lift (context_assumptions Γ) (k' + #|Γ|) t)) =
subst (all_rels Γ k 0) k' t.
Proof using Type.
epose proof (distr_subst_rec _ _ _ 0 _).
rewrite Nat.add_0_r in H. rewrite -> H. clear H.
len.
rewrite simpl_subst_k. now len.
now rewrite map_subst_extended_subst.
Qed.
Lemma expand_lets_ctx_o_lets Γ k k' Δ :
subst_context (List.rev (to_extended_list_k Γ k)) k' (expand_lets_k_ctx Γ k' Δ) =
subst_context (all_rels Γ k 0) k' Δ.
Proof using Type.
revert k k'; induction Δ using rev_ind; simpl; auto.
intros k k'; rewrite expand_lets_k_ctx_decl /map_decl /=.
rewrite !subst_context_app /=.
simpl; unfold app_context.
f_equal. specialize (IHΔ k (S k')). simpl in IHΔ.
rewrite -IHΔ.
destruct x; simpl.
destruct decl_body; simpl in * => //.
unfold subst_context, fold_context_k; simpl.
f_equal.
unfold expand_lets_k, subst_context => /=.
unfold map_decl; simpl. unfold map_decl. simpl. f_equal.
destruct (decl_body x); simpl. f_equal.
now rewrite subst_ext_list_ext_subst. auto.
now rewrite subst_ext_list_ext_subst.
Qed.
Lemma subst_subst_context s k s' Γ :
subst_context s k (subst_context s' 0 Γ) =
subst_context (map (subst s k) s') 0 (subst_context s (#|s'| + k) Γ).
Proof using Type.
rewrite !subst_context_alt.
rewrite !mapi_compose; len.
eapply mapi_ext. intros n x.
rewrite /subst_decl !compose_map_decl.
apply map_decl_ext. intros t.
rewrite Nat.add_0_r.
remember (Nat.pred #|Γ| - n) as i.
rewrite distr_subst_rec. lia_f_equal.
Qed.
Lemma closed_ctx_subst n k ctx : closedn_ctx k ctx = true -> subst_context n k ctx = ctx.
Proof using Type.
induction ctx in n, k |- *; auto.
simpl.
move/andb_and => /= [Hctx Hd].
rewrite subst_context_snoc /snoc /= IHctx // subst_decl_closed //.
Qed.
Lemma expand_lets_k_ctx_subst_id' Γ k Δ :
closed_ctx Γ ->
closedn_ctx #|Γ| Δ ->
expand_lets_k_ctx Γ k (subst_context (List.rev (to_extended_list_k Γ k)) 0
(expand_lets_ctx Γ Δ)) =
subst_context (List.rev (to_extended_list_k (smash_context [] Γ) k)) 0
(expand_lets_ctx Γ Δ).
Proof using Type.
intros clΓ clΔ.
assert (closed_ctx (Γ ,,, Δ)).
{ rewrite closedn_ctx_app clΓ //. }
rewrite {1}/expand_lets_k_ctx.
rewrite PCUICClosed.closed_ctx_lift.
rewrite -(Nat.add_0_r (k + #|Γ|)).
eapply closedn_ctx_subst. simpl; len'.
eapply closedn_ctx_expand_lets. eapply closedn_ctx_upwards; tea. lia.
rewrite forallb_rev. now eapply closedn_to_extended_list_k.
rewrite subst_subst_context. len'.
rewrite map_rev extended_subst_to_extended_list_k.
rewrite (closed_ctx_subst _ (context_assumptions Γ + k)) //.
rewrite Nat.add_comm. eapply closedn_ctx_expand_lets => //.
eapply closedn_ctx_upwards; eauto. lia.
Qed.
Local Set SimplIsCbn.
Lemma subst_lift1 x s : (subst0 (x :: s) ∘ lift0 1) =1 subst0 s.
Proof using Type.
intros t. erewrite <- PCUICParallelReduction.subst_skipn'.
rewrite lift0_id. simpl. now rewrite skipn_S skipn_0.
lia. simpl. lia.
Qed.
Lemma map_subst_lift1 x s l : map (subst0 (x :: s) ∘ lift0 1) l = map (subst0 s) l.
Proof using Type.
apply map_ext. apply subst_lift1.
Qed.
Lemma subst_extended_lift Γ k :
closed_ctx Γ ->
map (subst0 (List.rev (to_extended_list_k (smash_context [] Γ) k)))
(extended_subst Γ 0) = extended_subst Γ k.
Proof using Type.
induction Γ in k |- *; intros cl; simpl; auto.
destruct a as [na [b|] ty] => /=.
len.
rewrite closed_ctx_decl in cl. move/andb_and: cl => [cld clΓ].
simpl. f_equal.
rewrite distr_subst. len.
simpl in cld.
rewrite IHΓ //. f_equal.
rewrite simpl_subst_k ?lengths // lift_closed //. now move/andb_and: cld => /= //.
rewrite IHΓ //.
cbn -[nth_error] => /=. rewrite nth_error_rev; len.
rewrite List.rev_involutive /=.
rewrite smash_context_acc /=.
f_equal; auto. rewrite reln_acc /=.
rewrite nth_error_app_ge; len.
replace (context_assumptions Γ - 0 - context_assumptions Γ) with 0 by lia.
now simpl.
rewrite reln_acc List.rev_app_distr /=.
rewrite lift_extended_subst.
rewrite map_map_compose.
rewrite map_subst_lift1.
rewrite closed_ctx_decl in cl. move/andb_and: cl => [cld clΓ].
now rewrite IHΓ // Nat.add_1_r.
Qed.
Lemma closed_subst_map_lift s n k t :
closedn (#|s| + k) t ->
subst (map (lift0 n) s) k t = subst s (n + k) (lift n k t).
Proof using Type.
intros cl.
sigma.
eapply inst_ext_closed; tea.
intros x Hx.
rewrite -Upn_Upn Nat.add_comm Upn_Upn Upn_compose shiftn_Upn; sigma.
now rewrite !Upn_subst_consn_lt; len; try lia.
Qed.
Lemma subst_map_lift_lift_context (Γ : context) k s :
closedn_ctx #|s| Γ ->
subst_context (map (lift0 k) s) 0 Γ =
subst_context s k (lift_context k 0 Γ).
Proof using Type.
induction Γ as [|[? [] ?] ?] in k |- *; intros cl; auto;
rewrite lift_context_snoc !subst_context_snoc /= /subst_decl /map_decl /=;
rewrite closed_ctx_decl in cl; move/andb_and: cl => [cld clΓ].
- rewrite IHΓ //. f_equal. f_equal. f_equal;
len.
rewrite closed_subst_map_lift //. now move/andb_and: cld => /=.
lia_f_equal.
len.
rewrite closed_subst_map_lift //. now move/andb_and: cld => /=.
lia_f_equal.
- f_equal. apply IHΓ => //.
f_equal; len. rewrite closed_subst_map_lift //.
lia_f_equal.
Qed.
Lemma subst_context_lift_context_comm (Γ : context) n k k' s :
k' = k + n ->
subst_context s k' (lift_context n k Γ) =
lift_context n k (subst_context s k Γ).
Proof using Type.
intros ->; induction Γ as [|[? [] ?] ?] in |- *; auto;
rewrite !lift_context_snoc !subst_context_snoc !lift_context_snoc /=
/subst_decl /lift_decl /map_decl /=.
- rewrite IHΓ //. f_equal. f_equal. f_equal; len.
rewrite commut_lift_subst_rec. lia. lia_f_equal.
len.
rewrite commut_lift_subst_rec. lia. lia_f_equal.
- f_equal. apply IHΓ => //.
f_equal; len. rewrite commut_lift_subst_rec //; try lia.
lia_f_equal.
Qed.
Lemma spine_subst_extended_subst {Γ inst s Δ} :
spine_subst Σ Γ inst s Δ ->
s = map (subst0 (List.rev inst)) (extended_subst Δ 0).
Proof using Type.
intros [_ _ sp _]. now apply context_subst_subst_extended_subst in sp.
Qed.
Lemma spine_subst_app {Γ Δ Δ' inst inst' insts} :
#|inst| = context_assumptions Δ ->
wf_local Σ (Γ ,,, Δ ,,, Δ') ->
spine_subst Σ Γ inst (skipn #|Δ'| insts) Δ ->
spine_subst Σ Γ inst' (firstn #|Δ'| insts) (subst_context (skipn #|Δ'| insts) 0 Δ') ->
spine_subst Σ Γ (inst ++ inst') insts (Δ ,,, Δ').
Proof using Type.
intros len wf [wfdom wfcodom cs subst] [wfdom' wfcodom' cs' subst'].
split; auto.
now rewrite app_context_assoc.
eapply context_subst_app_inv; split; auto.
rewrite skipn_all_app_eq; try lia. auto.
rewrite (firstn_app_left) ?Nat.add_0_r // firstn_0 // app_nil_r //.
rewrite -(firstn_skipn #|Δ'| insts).
eapply subslet_app; auto.
Qed.
Lemma context_assumptions_lift {n k Γ} : context_assumptions (lift_context n k Γ) = context_assumptions Γ.
Proof using Type. apply context_assumptions_fold. Qed.
Lemma context_assumptions_subst {n k Γ} : context_assumptions (subst_context n k Γ) = context_assumptions Γ.
Proof using Type. apply context_assumptions_fold. Qed.
Hint Rewrite @context_assumptions_lift @context_assumptions_subst : len.
Lemma ws_cumul_ctx_pb_rel'_context_assumptions {pb} {Γ} {Δ Δ'} :
All2_fold
(fun Γ' _ : context =>
All_decls_alpha_pb pb
(fun pb (x y : term) => Σ ;;; Γ,,, Γ' ⊢ x ≤[pb] y)) Δ Δ' ->
context_assumptions Δ = context_assumptions Δ'.
Proof using Type.
induction 1; auto.
depelim p; simpl; auto. lia.
Qed.
Lemma ws_cumul_ctx_pb_rel_context_assumptions {pb} {Γ} {Δ Δ'} :
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
context_assumptions Δ = context_assumptions Δ'.
Proof using Type.
intros []. now eapply ws_cumul_ctx_pb_rel'_context_assumptions.
Qed.
(* Lemma subslet_subs {cf} {Σ} {wfΣ : wf Σ} {Γ i Δ Δ'} :
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
ctx_inst Σ Γ i (Li *)
Lemma ws_cumul_pb_expand_lets_k {pb} {Γ Δ Γ'} {T T'} :
wf_local Σ (Γ ,,, Δ) ->
Σ ;;; Γ ,,, Δ ,,, Γ' ⊢ T ≤[pb] T' ->
Σ ;;; Γ ,,, smash_context [] Δ ,,, expand_lets_ctx Δ Γ' ⊢
expand_lets_k Δ #|Γ'| T ≤[pb] expand_lets_k Δ #|Γ'| T'.
Proof using wfΣ.
intros wf cum.
rewrite -app_context_assoc in cum.
eapply (weakening_ws_cumul_pb (Γ'' := smash_context [] Δ)) in cum; tea.
rewrite /expand_lets /expand_lets_k.
rewrite lift_context_app in cum.
rewrite app_context_assoc in cum.
eapply substitution_ws_cumul_pb in cum; tea.
len in cum; tea.
destruct (wf_local_app_inv wf).
simpl.
len.
now eapply PCUICContexts.subslet_extended_subst.
eapply wf_local_smash_end in wf. eauto with fvs.
Qed.
Lemma ws_cumul_pb_expand_lets {pb} {Γ} {Δ} {T T'} :
wf_local Σ (Γ ,,, Δ) ->
Σ ;;; Γ ,,, Δ ⊢ T ≤[pb] T' ->
Σ ;;; Γ ,,, smash_context [] Δ ⊢ expand_lets Δ T ≤[pb] expand_lets Δ T'.
Proof using wfΣ.
intros wf cum.
eapply (weakening_ws_cumul_pb (Γ'' := smash_context [] Δ)) in cum; tea.
rewrite /expand_lets /expand_lets_k.
eapply (PCUICConversion.substitution_ws_cumul_pb (Γ'' := [])) in cum; tea. len in cum; tea.
destruct (wf_local_app_inv wf).
simpl.
len.
now eapply PCUICContexts.subslet_extended_subst.
eapply wf_local_smash_end in wf. eauto with fvs.
Qed.
Lemma ws_cumul_pb_terms_lift {Γ Δ args args'} :
is_closed_context (Γ,,, Δ) ->
ws_cumul_pb_terms Σ Γ args args' ->
ws_cumul_pb_terms Σ (Γ ,,, Δ) (map (lift0 #|Δ|) args) (map (lift0 #|Δ|) args').
Proof using wfΣ.
intros onctx conv.
eapply All2_map.
eapply (All2_impl conv).
intros x y eqxy.
eapply (weakening_ws_cumul_pb (Γ' := [])) => //.
Qed.
Lemma ws_cumul_pb_le_le {pb Γ T T'} :
Σ ;;; Γ ⊢ T ≤[pb] T' -> Σ ;;; Γ ⊢ T ≤ T'.
Proof using Type.
destruct pb; eauto.
eapply ws_cumul_pb_eq_le.
Qed.
Lemma ws_cumul_ctx_pb_le_le {pb Γ Γ'} :
Σ ⊢ Γ ≤[pb] Γ' -> Σ ⊢ Γ ≤ Γ'.
Proof using Type.
intros a; eapply All2_fold_impl; tea.
cbn; intros.
depelim X; constructor; auto.
now eapply ws_cumul_pb_le_le.
now eapply ws_cumul_pb_le_le.
Qed.
Lemma ws_cumul_ctx_pb_eq_le {pb Γ Δ} :
Σ ⊢ Γ = Δ -> Σ ⊢ Γ ≤[pb] Δ.
Proof using Type.
destruct pb; eauto.
apply ws_cumul_ctx_pb_le_le.
Qed.
Lemma subslet_ws_cumul_ctx_pb {pb} {Γ Γ' Δ Δ'} {s} :
wf_local Σ (Γ ,,, Δ) ->
wf_local Σ (Γ ,,, Δ') ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ' Δ ->
subslet Σ (Γ ,,, Δ) s Γ' ->
subslet Σ (Γ ,,, Δ') s Γ'.
Proof using wfΣ.
intros wfl wfr cumul.
induction 1; constructor; auto.
* eapply context_cumulativity; tea.
eapply ws_cumul_ctx_pb_rel_app in cumul.
eapply ws_cumul_ctx_pb_le_le in cumul.
now apply ws_cumul_ctx_pb_forget in cumul.
* eapply context_cumulativity; tea.
eapply ws_cumul_ctx_pb_rel_app in cumul.
eapply ws_cumul_ctx_pb_le_le in cumul.
now apply ws_cumul_ctx_pb_forget in cumul.
Qed.
Arguments on_free_vars_ctx _ _ : simpl never.
Lemma ws_cumul_ctx_pb_rel_conv_extended_subst {pb} {Γ Δ Δ'} :
wf_local Σ (Γ ,,, Δ) ->
wf_local Σ (Γ ,,, Δ') ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
ws_cumul_pb_terms Σ (Γ ,,, smash_context [] Δ) (extended_subst Δ 0) (extended_subst Δ' 0) ×
ws_cumul_ctx_pb_rel pb Σ Γ (smash_context [] Δ) (smash_context [] Δ').
Proof using wfΣ.
intros wfl wfr [clΓ cum].
assert (is_closed_context (Γ ,,, smash_context [] Δ)).
{ eapply wf_local_smash_end in wfl. eauto with fvs. }
induction cum in |- *; simpl; auto.
- split; constructor => //. constructor.
- depelim p; simpl;
depelim wfl; depelim wfr;
specialize (IHcum wfl wfr) as [conv cum'];
try assert (is_closed_context (Γ,,, smash_context [] Γ0)) by
(rewrite /= smash_context_acc /= on_free_vars_ctx_snoc in H; now move/andP: H) => //.
all:auto.
* split; try constructor; auto.
+ eapply ws_cumul_pb_refl => //. cbn. len.
+ rewrite !(lift_extended_subst _ 1).
move: H.
rewrite /= ![smash_context [_] _]smash_context_acc /= /map_decl /= => ha.
eapply (ws_cumul_pb_terms_lift (Δ := [_])) => //.
+ move: H; simpl; rewrite /= !(smash_context_acc _ [_]) /=;
constructor; auto.
apply cum'. rewrite /map_decl /=.
constructor; auto.
eapply ws_cumul_pb_expand_lets in eqt; tea.
etransitivity;tea. rewrite /expand_lets /expand_lets_k. simpl.
rewrite -(length_of cum).
rewrite -(ws_cumul_ctx_pb_rel'_context_assumptions cum).
move: (context_assumptions_smash_context [] Γ0); cbn => <-. simpl.
change (Γ ,,, smash_context [] Γ0) with (Γ ,,, smash_context [] Γ0 ,,, []).
eapply (substitution_ws_cumul_pb_subst_conv (Δ := [])); tea.
{ now eapply subslet_untyped_subslet, PCUICContexts.subslet_extended_subst. }
{ eapply subslet_untyped_subslet, subslet_ws_cumul_ctx_pb. 3:tea.
now eapply wf_local_smash_end.
now eapply wf_local_smash_end.
now eapply PCUICContexts.subslet_extended_subst. }
relativize (context_assumptions Γ').
eapply is_closed_context_lift; tea; eauto with fvs. len.
now rewrite -(ws_cumul_ctx_pb_rel'_context_assumptions cum).
eapply ws_cumul_pb_refl.
rewrite -[context_assumptions Γ0](smash_context_length []).
eapply is_closed_context_lift; tea; eauto with fvs.
rewrite -[context_assumptions Γ0](smash_context_length []); cbn.
rewrite context_assumptions_smash_context /=.
rewrite -[context_assumptions Γ0](smash_context_length []); cbn.
relativize #|Γ0|.
eapply is_open_term_lift.
destruct l0 as [s Hs]. eapply subject_closed in Hs.
rewrite is_open_term_closed in Hs. move: Hs.
now rewrite !app_length -(All2_fold_length cum). reflexivity.
* split; auto.
constructor; auto.
len.
eapply ws_cumul_pb_expand_lets in eqb; tea.
etransitivity; tea.
rewrite /expand_lets /expand_lets_k. simpl.
rewrite -(length_of cum).
rewrite -(ws_cumul_ctx_pb_rel'_context_assumptions cum).
move: (context_assumptions_smash_context [] Γ0); cbn => <-. simpl.
change (smash_context [] Γ0 ++ Γ) with (Γ ,,, smash_context [] Γ0 ,,, []).
cbn. rewrite smash_context_acc /=.
change (smash_context [] Γ0 ++ Γ) with (Γ ,,, smash_context [] Γ0 ,,, []).
eapply (substitution_ws_cumul_pb_subst_conv (Δ := [])); tea.
{ now eapply subslet_untyped_subslet, PCUICContexts.subslet_extended_subst. }
{ eapply subslet_untyped_subslet, subslet_ws_cumul_ctx_pb. 3:tea.
now eapply wf_local_smash_end.
now eapply wf_local_smash_end.
now eapply PCUICContexts.subslet_extended_subst. }
relativize (context_assumptions Γ').
eapply is_closed_context_lift; tea; eauto with fvs. len.
now rewrite -(ws_cumul_ctx_pb_rel'_context_assumptions cum).
eapply ws_cumul_pb_refl.
rewrite -[context_assumptions Γ0](smash_context_length []).
eapply is_closed_context_lift; tea; eauto with fvs.
rewrite -[context_assumptions Γ0](smash_context_length []); cbn.
rewrite context_assumptions_smash_context /=.
rewrite -[context_assumptions Γ0](smash_context_length []); cbn.
relativize #|Γ0|.
eapply is_open_term_lift.
eapply subject_closed in l2.
rewrite is_open_term_closed in l2. move: l2.
now rewrite !app_length -(All2_fold_length cum). reflexivity.
Qed.
Lemma ws_cumul_ctx_pb_rel_smash {pb} {Γ Δ Δ'} :
wf_local Σ (Γ ,,, Δ) ->
wf_local Σ (Γ ,,, Δ') ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
ws_cumul_ctx_pb_rel pb Σ Γ (smash_context [] Δ) (smash_context [] Δ').
Proof using wfΣ.
now intros; apply ws_cumul_ctx_pb_rel_conv_extended_subst.
Qed.
Lemma ws_cumul_pb_terms_ws_cumul_ctx {pb} {Γ Δ Δ'} {ts ts'} :
wf_local Σ (Γ ,,, Δ) ->
wf_local Σ (Γ ,,, Δ') ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
ws_cumul_pb_terms Σ (Γ ,,, Δ') ts ts' ->
ws_cumul_pb_terms Σ (Γ ,,, Δ) ts ts'.
Proof using wfΣ.
intros wfl wfr cum conv.
eapply (All2_impl conv).
intros x y xy.
eapply ws_cumul_pb_ws_cumul_ctx.
now eapply ws_cumul_ctx_pb_rel_app in cum.
assumption.
Qed.
Lemma ws_cumul_ctx_pb_rel_length {pb Γ Δ Δ'} :
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
#|Δ| = #|Δ'|.
Proof using Type. intros []. apply (length_of a). Qed.
Lemma is_closed_context_smash_end {Γ Δ} :
is_closed_context (Γ ,,, Δ) ->
is_closed_context (Γ ,,, smash_context [] Δ).
Proof using Type.
rewrite - !is_closed_ctx_closed.
rewrite !closedn_ctx_app /= => /andP[] ->.
eapply closedn_smash_context.
Qed.
Hint Resolve is_closed_context_smash_end : fvs.
Lemma ws_cumul_pb_expand_lets_ws_cumul_ctx {pb le'} {Γ} {Δ Δ'} {T T'} :
wf_local Σ (Γ ,,, Δ) ->
wf_local Σ (Γ ,,, Δ') ->
Σ ;;; Γ ,,, Δ ⊢ T ≤[le'] T' ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
Σ ;;; Γ ,,, smash_context [] Δ ⊢ expand_lets Δ T ≤[le'] expand_lets Δ' T'.
Proof using wfΣ.
intros wfl wfr cum cumΓ.
rewrite /expand_lets /expand_lets_k.
rewrite -(ws_cumul_ctx_pb_rel_length cumΓ) /=.
rewrite -(ws_cumul_ctx_pb_rel_context_assumptions cumΓ).
change (Γ ,,, smash_context [] Δ) with (Γ ,,, smash_context [] Δ ,,, []).
eapply (substitution_ws_cumul_pb_subst_conv (Δ := [])); tea.
3:{ eapply ws_cumul_ctx_pb_rel_conv_extended_subst; tea. }
* eapply subslet_untyped_subslet, PCUICContexts.subslet_extended_subst; tea.
* eapply subslet_untyped_subslet, subslet_ws_cumul_ctx_pb; cycle 2.
+ eapply ws_cumul_ctx_pb_rel_smash; tea.
+ eapply PCUICContexts.subslet_extended_subst; tea.
+ now eapply wf_local_smash_end.
+ now eapply wf_local_smash_end.
* simpl.
rewrite -(ws_cumul_ctx_pb_rel_context_assumptions cumΓ).
rewrite -[context_assumptions _](smash_context_length [] Δ).
eapply is_closed_context_lift; eauto with fvs.
* rewrite -[context_assumptions _](smash_context_length [] Δ).
eapply weakening_ws_cumul_pb => //; eauto with fvs.
Qed.
Lemma ctx_inst_cumul {pb Γ i Δ Δ'} :
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
ctx_inst Σ Γ i (List.rev Δ) ->
wf_local_rel Σ Γ Δ ->
wf_local_rel Σ Γ Δ' ->
ctx_inst Σ Γ i (List.rev Δ').
Proof using wfΣ.
intros [clΓ a].
induction a in i |- *; intros ci.
- depelim ci. constructor.
- simpl in ci. eapply PCUICSpine.ctx_inst_app_inv in ci as [dom codom].
depelim p.
* simpl in codom. depelim codom.
simpl in codom. depelim codom. cbn in t1.
destruct i as [|i t0] using rev_case.
{ rewrite skipn_nil in H => //. }
assert (context_assumptions (List.rev Γ0) = #|i|).
apply (f_equal (@length _)) in H. simpl in H.
rewrite List.skipn_length app_length /= in H. lia.
rewrite skipn_all_app_eq // in H. noconf H.
intros HΔ; depelim HΔ.
intros HΔ'; depelim HΔ'.
destruct l0 as [s Hs]. simpl.
rewrite (ctx_inst_sub_subst dom) in t1.
rewrite firstn_app_left // in dom.
specialize (IHa _ dom HΔ HΔ').
eapply (ctx_inst_app IHa).
simpl. constructor; [|constructor].
rewrite (ctx_inst_sub_subst IHa).
rewrite firstn_app_left // in t1.
simpl.
rewrite context_assumptions_rev in H0.
assert (context_assumptions Γ' = #|i|) by now rewrite -(ws_cumul_ctx_pb_rel'_context_assumptions a).
rewrite map_subst_expand_lets in t1; len=> //.
rewrite map_subst_expand_lets; len=> //.
unshelve epose proof (ctx_inst_spine_subst _ IHa); tea.
now eapply typing_wf_local in Hs.
eapply spine_subst_smash in X; tea.
eapply type_ws_cumul_pb; tea.
+ eapply typing_expand_lets in Hs.
eapply (substitution (s := List.rev i) (Δ := [])) in Hs; tea.
simpl in Hs. now exists s; rewrite subst_context_nil /= in Hs.
exact X.
+ unshelve epose proof (ctx_inst_spine_subst _ dom); tea.
eapply wf_local_app; tea. now eapply typing_wf_local.
pose proof (spine_codom_wf _ _ _ _ _ X0).
eapply spine_subst_smash in X0; tea.
eapply (PCUICConversion.substitution_ws_cumul_pb (Γ := Γ) (Γ'' := []) X0).
simpl.
eapply ws_cumul_pb_expand_lets_ws_cumul_ctx; tea.
now eapply typing_wf_local in Hs. split; tea.
* simpl in codom. depelim codom.
simpl in codom. depelim codom.
assert (context_assumptions (List.rev Γ0) = #|i|).
pose proof (ctx_inst_length dom).
apply (f_equal (@length _)) in H. simpl in H.
rewrite List.skipn_length /= in H.
apply firstn_length_le_inv in H0. lia.
rewrite H0 in H, dom. rewrite firstn_all in dom.
intros HΔ; depelim HΔ.
intros HΔ'; depelim HΔ'.
destruct l as [s Hs]. simpl in *.
specialize (IHa _ dom).
forward IHa. apply wf_local_app_inv; pcuic.
forward IHa. apply wf_local_app_inv; pcuic.
rewrite -(app_nil_r i).
eapply (ctx_inst_app IHa).
rewrite (ctx_inst_sub_subst IHa) /=.
repeat constructor.
Qed.
Lemma subst_context_rev_subst_telescope s k Γ :
subst_context s k (List.rev Γ) = List.rev (subst_telescope s k Γ).
Proof using Type.
induction Γ in s, k |- *.
- simpl; auto.
- rewrite subst_telescope_cons /= subst_context_app IHΓ.
reflexivity.
Qed.
Lemma ctx_inst_smash_acc {Γ i Δ} :
ctx_inst Σ Γ i Δ <~>
ctx_inst Σ Γ i (List.rev (smash_context [] (List.rev Δ))).
Proof using Type.
split.
- induction 1.
+ constructor.
+ simpl.
rewrite smash_context_app_ass. len.
rewrite List.rev_app_distr /=.
constructor. auto.
rewrite subst_telescope_subst_context.
rewrite -smash_context_subst /=; len.
now rewrite subst_context_rev_subst_telescope.
+ simpl. rewrite smash_context_app_def.
now rewrite subst_context_rev_subst_telescope.
- induction Δ using ctx_length_ind in i |- *; simpl; auto.
destruct d as [na [b|] ty] => /=.
* rewrite smash_context_app_def /=.
rewrite subst_context_rev_subst_telescope.
intros ctxi. constructor.
apply X => //. now rewrite subst_telescope_length //.
* rewrite smash_context_app_ass List.rev_app_distr /=.
intros ctxi; depelim ctxi.
constructor => //.
apply X. rewrite subst_telescope_length //.
rewrite subst_telescope_subst_context in ctxi.
rewrite -(smash_context_subst []) in ctxi.
now rewrite subst_context_rev_subst_telescope in ctxi.
Qed.
Lemma ctx_inst_smash {Γ i Δ} :
ctx_inst Σ Γ i (List.rev Δ) <~>
ctx_inst Σ Γ i (List.rev (smash_context [] Δ)).
Proof using Type.
split; intros.
- apply (fst ctx_inst_smash_acc) in X. now rewrite List.rev_involutive in X.
- apply (snd ctx_inst_smash_acc). now rewrite List.rev_involutive.
Qed.
Lemma subst_context_subst_telescope s k Γ :
subst_context s k (List.rev Γ) = List.rev (subst_telescope s k Γ).
Proof using Type.
rewrite /subst_telescope subst_context_alt.
rewrite rev_mapi. apply mapi_rec_ext.
intros n [na [b|] ty] le le'; rewrite /= /subst_decl /map_decl /=;
rewrite List.rev_length Nat.add_0_r in le'; len; lia_f_equal.
Qed.
Lemma ws_cumul_ctx_pb_rel_trans {pb Γ Δ Δ' Δ''} :
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ' ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ' Δ'' ->
ws_cumul_ctx_pb_rel pb Σ Γ Δ Δ''.
Proof using wfΣ.
move/ws_cumul_ctx_pb_rel_app => h /ws_cumul_ctx_pb_rel_app h'.
apply ws_cumul_ctx_pb_rel_app.
now etransitivity.
Qed.
Lemma OnOne2_ctx_inst {pb} {P} {Γ inst inst' Δ} :
(forall Γ Δ' Δ s s', wf_local Σ (Γ ,,, Δ' ,,, Δ) ->
subslet Σ Γ (List.rev s) Δ' ->
subslet Σ Γ (List.rev s') Δ' ->
OnOne2 (P Σ Γ) s s' ->
ws_cumul_ctx_pb pb Σ (Γ ,,, subst_context (List.rev s) 0 Δ)
(Γ ,,, subst_context (List.rev s') 0 Δ)) ->
wf_local Σ (Γ ,,, (List.rev Δ)) ->
PCUICTyping.ctx_inst
(fun (Σ : global_env_ext) (Γ : context) (t T : term) =>
forall u : term, P Σ Γ t u -> Σ;;; Γ |- u : T) Σ Γ inst Δ ->
ctx_inst Σ Γ inst Δ ->
OnOne2 (P Σ Γ) inst inst' ->
ctx_inst Σ Γ inst' Δ.
Proof using wfΣ.
intros HP wf c.
induction c in inst', wf |- *; intros ctxi; depelim ctxi; intros o.
- depelim o.
- depelim o. constructor. apply t0. auto.
rewrite -(List.rev_involutive Δ).
rewrite subst_telescope_subst_context.
simpl in wf. rewrite - !/(app_context _ _) app_context_assoc in wf.
eapply ctx_inst_cumul.
2:{ instantiate (1:=subst_context [i] 0 (List.rev Δ)).
rewrite -subst_telescope_subst_context List.rev_involutive. exact ctxi. }
eapply ws_cumul_ctx_pb_rel_app.
eapply (HP _ _ _ [i] [hd']); tea.
repeat constructor. now rewrite subst_empty. repeat constructor.
now rewrite subst_empty. constructor. auto.
eapply wf_local_app_inv. eapply substitution_wf_local; tea.
repeat (constructor; tea). rewrite subst_empty; tea.
eapply wf_local_app_inv. eapply substitution_wf_local; tea.
repeat (constructor; tea). rewrite subst_empty; tea. now eapply t0.
constructor; auto. eapply IHc.
rewrite -subst_context_subst_telescope.
eapply substitution_wf_local; tea.
repeat (constructor; tea). rewrite subst_empty; tea.
simpl in wf. rewrite - !/(app_context _ _) app_context_assoc in wf.
exact wf. tas. tas.
- constructor. eapply IHc; eauto.
simpl in wf. rewrite - !/(app_context _ _) app_context_assoc in wf.
rewrite -subst_context_subst_telescope.
eapply substitution_wf_local; tea.
repeat (constructor; tea). eapply subslet_def_tip.
eapply wf_local_app_inv in wf as [wf _]. now depelim wf.
Qed.
Lemma All2_ctx_inst {pb} {P} {Γ inst inst' Δ} :
(forall Γ Δ' Δ s s', wf_local Σ (Γ ,,, Δ' ,,, Δ) ->
subslet Σ Γ (List.rev s) Δ' ->
subslet Σ Γ (List.rev s') Δ' ->
All2 (P Σ Γ) s s' ->
ws_cumul_ctx_pb pb Σ (Γ ,,, subst_context (List.rev s) 0 Δ)
(Γ ,,, subst_context (List.rev s') 0 Δ)) ->
wf_local Σ (Γ ,,, (List.rev Δ)) ->
PCUICTyping.ctx_inst
(fun (Σ : global_env_ext) (Γ : context) (t T : term) =>
forall u : term, P Σ Γ t u -> Σ;;; Γ |- u : T) Σ Γ inst Δ ->
ctx_inst Σ Γ inst Δ ->
All2 (P Σ Γ) inst inst' ->
ctx_inst Σ Γ inst' Δ.
Proof using wfΣ.
intros HP wf c.
induction c in inst', wf |- *; intros ctxi; depelim ctxi; intros o.
- depelim o. constructor.
- depelim o. constructor. apply t0. auto.
rewrite -(List.rev_involutive Δ).
rewrite subst_telescope_subst_context.
simpl in wf. rewrite - !/(app_context _ _) app_context_assoc in wf.
eapply ctx_inst_cumul.
2:{ instantiate (1:=subst_context [i] 0 (List.rev Δ)).
rewrite -subst_telescope_subst_context List.rev_involutive. eapply IHc => //.
rewrite -subst_context_subst_telescope.
eapply substitution_wf_local; tea.
repeat (constructor; tea). rewrite subst_empty; tea. }
eapply ws_cumul_ctx_pb_rel_app.
eapply (HP _ _ _ [i] [y]); tea.
repeat constructor. now rewrite subst_empty.
now apply subslet_ass_tip.
now repeat constructor.
* eapply wf_local_app_inv. eapply substitution_wf_local; tea.
now apply subslet_ass_tip.
* eapply wf_local_app_inv. eapply substitution_wf_local; tea.
now apply subslet_ass_tip.
- constructor. eapply IHc; eauto.
simpl in wf. rewrite - !/(app_context _ _) app_context_assoc in wf.
rewrite -subst_context_subst_telescope.
eapply substitution_wf_local; tea.
repeat (constructor; tea). eapply subslet_def_tip.
eapply wf_local_app_inv in wf as [wf _]. now depelim wf.
Qed.
Lemma ctx_inst_open_terms Γ args Δ :
ctx_inst Σ Γ args Δ ->
All (is_open_term Γ) args.
Proof using wfΣ.
induction 1; try constructor; eauto using subject_is_open_term.
Qed.
Lemma subslet_open_terms Γ s Δ :
subslet Σ Γ s Δ ->
All (is_open_term Γ) s.
Proof using wfΣ.
induction 1; try constructor; eauto using subject_is_open_term.
Qed.
Lemma ctx_inst_eq_context {Γ Δ : context} {args args'} :
wf_local Σ (Γ ,,, List.rev Δ) ->
PCUICTyping.ctx_inst
(fun (Σ : global_env_ext) (Γ : context) (u A : term) =>
forall v : term, upto_names' u v -> Σ;;; Γ |- v : A) Σ Γ args Δ ->
ctx_inst Σ Γ args Δ ->
All2 upto_names' args args' ->
ctx_inst Σ Γ args' Δ.
Proof using wfΣ.
intros wf ctxi ctxi' a.
eapply All2_ctx_inst; tea.
2:exact ctxi. 2:auto.
cbn; clear -wfΣ; intros.
eapply substitution_ws_cumul_ctx_pb.
now eapply subslet_untyped_subslet.
now eapply subslet_untyped_subslet.
eapply All2_rev.
move/wf_local_app_inv: X => [] /wf_local_app_inv[] /wf_local_closed_context clΓ0 _ _.
eapply subslet_open_terms, All_rev_inv in X0.
eapply subslet_open_terms, All_rev_inv in X1.
solve_all. eapply into_ws_cumul_pb; tea.
constructor. now apply upto_names_impl_eq_term.
all:eauto with fvs.
Qed.
End WfEnv.
Lemma spine_subst_vass `{cf: checker_flags} Σ Γ s t σ Δ na A :
wf Σ.1 ->
spine_subst Σ Γ s σ Δ ->
isType Σ (Γ ,,, Δ) A ->
Σ ;;; Γ |- t : subst0 σ A ->
spine_subst Σ Γ (s ++ [t]) (t :: σ) (Δ ,, vass na A).
Proof.
move=> wfΣ sss Atyp ttyp; move: (sss)=> [????].
change (?x ,, ?y) with (x ,,, [ y ]).
apply: spine_subst_app=> //=.
+ apply: PCUICContextSubst.context_subst_length2; eassumption.
+ apply: localenv_cons_abs=> //.
+ rewrite /skipn /subst_context /fold_context_k /= /map_decl /=.
constructor=> //=.
* apply: localenv_cons_abs=> //.
apply: isType_subst; eassumption.
* apply: (PCUICContextSubst.context_subst_ass [] [] [] na _ t); constructor.
* econstructor; first constructor.
by rewrite PCUICLiftSubst.subst_empty.
Qed.
Lemma wf_local_nth_isType {cf} {Σ} {Γ n d} :
wf_local Σ Γ ->
nth_error Γ n = Some d ->
isType Σ (skipn (S n) Γ) d.(decl_type).
Proof.
intros Hwf hnth.
epose proof (nth_error_All_local_env (nth_error_Some_length hnth) Hwf).
rewrite hnth /= in X. unfold on_local_decl in X.
destruct decl_body => //. destruct X => //.
Qed.
Lemma spine_subst_vass' `{cf:checker_flags} Σ Γ s t σ Δ na A :
wf Σ.1 ->
spine_subst Σ Γ s σ Δ ->
wf_local Σ (Γ ,,, Δ ,, vass na A) ->
(spine_subst Σ Γ s σ Δ ->
isType Σ Γ (subst0 σ A) ->
Σ ;;; Γ |- t : subst0 σ A) ->
spine_subst Σ Γ (s ++ [t]) (t :: σ) (Δ ,, vass na A).
Proof.
move=> wfΣ sss Atyp /(_ sss) ttyp; apply: spine_subst_vass=> //.
2: apply: ttyp; apply: isType_subst; first (apply: inst_subslet; eassumption).
all: exact (wf_local_nth_isType (n := 0) Atyp eq_refl).
Qed.
Lemma mk_ctx_subst_spec' `{cf : checker_flags} {Σ Γ Δ args} (c : ctx_inst Σ Γ args (List.rev Δ)) :
mk_ctx_subst Δ args = ctx_inst_sub c.
Proof.
apply: context_subst_fun.
- apply: mk_ctx_subst_spec; by rewrite (ctx_inst_length c) context_assumptions_rev.
- move: (ctx_inst_sub_spec c)=> /make_context_subst_spec.
rewrite {1}rev_involutive //.
Qed.
Section ClosedSpineSubst.
Context `{cf: checker_flags}.
Lemma closed_subslet {Σ} {wfΣ : wf Σ.1} {Γ s Δ} : subslet Σ Γ s Δ -> forallb (closedn #|Γ|) s.
Proof using cf.
move=> z; depind z=> //=; rewrite IHz andb_true_r;
apply: PCUICClosedTyp.subject_closed; eassumption.
Qed.
Lemma closed_spine_subst {Σ} {wfΣ : wf Σ.1} {Γ inst s Δ} :
spine_subst Σ Γ inst s Δ -> forallb (closedn #|Γ|) s.
Proof using cf. move=> /inst_subslet; apply: closed_subslet. Qed.
Lemma closed_spine_subst_inst {Σ} {wfΣ : wf Σ.1} {Γ inst s Δ} :
spine_subst Σ Γ inst s Δ -> forallb (closedn #|Γ|) inst.
Proof using cf.
move=> /spine_subst_smash /closed_spine_subst; by rewrite forallb_rev.
Qed.
End ClosedSpineSubst.
|
(*
Copyright 2014 Cornell University
Copyright 2015 Cornell University
Copyright 2016 Cornell University
Copyright 2017 Cornell University
This file is part of VPrl (the Verified Nuprl project).
VPrl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
VPrl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VPrl. If not, see <http://www.gnu.org/licenses/>.
Websites: http://nuprl.org/html/verification/
http://nuprl.org/html/Nuprl2Coq
https://github.com/vrahli/NuprlInCoq
Authors: Abhishek Anand & Vincent Rahli
*)
Require Export sequents2.
Require Export sequents_lib.
Require Export sequents_tacs.
Require Export sequents_tacs2.
Require Export rules_useful.
Require Export per_props_equality.
Require Export sequents_equality.
Require Export rules_tyfam.
Require Export subst_tacs_aeq.
Require Export cequiv_tacs.
Require Export lsubstc_weak.
(** printing |- $\vdash$ *)
(** printing -> $\rightarrow$ *)
(* begin hide *)
Hint Rewrite @nh_vars_hyps_app : slow.
Hint Rewrite @nh_vars_hyps_snoc : slow.
(* end hide *)
(* begin hide *)
(* end hide *)
(* [26] ============ APPLY @EQUALITY ============ *)
(**
We following rule called ``apply @equality`` allows one to prove that
applications are well-typed.
<<
H |- f1 t1 = f2 t2 in B[x\t1]
By applyEquality ()
H |- f1 = f2 in x:A->B
H |- t1 = t2 in A
>>
*)
Definition rule_apply_equality_concl {o} (H : @bhyps o) f1 t1 f2 t2 B x :=
mk_baresequent H (mk_conclax (mk_equality
(mk_apply f1 t1)
(mk_apply f2 t2)
(subst B x t1))).
Definition rule_apply_equality_hyp1 {o} (H : @bhyps o) f1 f2 A x B e1 :=
mk_baresequent H (mk_concl (mk_equality f1 f2 (mk_function A x B)) e1).
Definition rule_apply_equality_hyp2 {o} (H : @bhyps o) t1 t2 A e2 :=
mk_baresequent H (mk_concl (mk_equality t1 t2 A) e2).
Definition rule_apply_equality {o}
(A B f1 f2 t1 t2 : NTerm)
(e1 e2 : NTerm)
(x : NVar)
(H : @barehypotheses o) :=
mk_rule
(rule_apply_equality_concl H f1 t1 f2 t2 B x)
[ rule_apply_equality_hyp1 H f1 f2 A x B e1,
rule_apply_equality_hyp2 H t1 t2 A e2
]
[].
Lemma rule_apply_equality_true3 {o} :
forall lib (A B f1 f2 t1 t2 e1 e2 : NTerm)
(x : NVar)
(H : @bhyps o),
rule_true3 lib (rule_apply_equality A B f1 f2 t1 t2 e1 e2 x H).
Proof.
intros.
unfold rule_apply_equality, rule_true3, wf_bseq, closed_type_baresequent, closed_extract_baresequent; simpl.
intros.
(* We prove the well-formedness of things *)
destseq; allsimpl.
dLin_hyp; exrepnd.
rename Hyp into hyp1.
rename Hyp0 into hyp2.
destruct hyp1 as [ ws1 hyp1 ].
destruct hyp2 as [ ws2 hyp2 ].
destseq; allsimpl; proof_irr; GC.
match goal with
| [ |- sequent_true2 _ ?s ] => assert (wf_csequent s) as wfc by (prove_seq; eauto 3 with slow)
end.
exists wfc.
unfold wf_csequent, wf_sequent, wf_concl in wfc; allsimpl; repnd; proof_irr; GC.
(* We prove some simple facts on our sequents *)
(* xxx *)
(* done with proving these simple facts *)
(* we now start proving the sequent *)
vr_seq_true.
vr_seq_true in hyp1.
vr_seq_true in hyp2.
generalize (hyp1 s1 s2 eqh sim); clear hyp1; intro hyp1; exrepnd.
generalize (hyp2 s1 s2 eqh sim); clear hyp2; intro hyp2; exrepnd.
lsubst_tac.
apply equality_in_mkc_equality in hyp1.
apply equality_in_mkc_equality in hyp2.
repnd.
repeat match goal with
| [ H : _ ===>(_) mkc_axiom |- _ ] => clear H
end.
rw @tequality_mkc_equality in hyp3.
rw @tequality_mkc_equality in hyp0.
repeat (rw prod_assoc).
repnd.
rw @tequality_function in hyp1; repnd.
(* a few assertions *)
assert (equality
lib
(lsubstc t1 w1 s1 c1)
(lsubstc t1 w1 s2 c0)
(lsubstc A wT s1 cT))
as eq1. { apply @equality_refl in hyp4; sp. }
assert (equality lib (lsubstc t2 w2 s1 c2)
(lsubstc t2 w2 s2 c3)
(lsubstc A wT s1 cT))
as eq5.
{
apply @equality_trans with (t2 := lsubstc t2 w2 s1 c2); sp.
apply @equality_sym in hyp4; apply @equality_refl in hyp4; sp.
apply hyp3.
apply @equality_sym in hyp4; apply @equality_refl in hyp4; sp.
}
assert (equality lib (lsubstc f2 w3 s1 c5)
(lsubstc f2 w3 s2 c8)
(mkc_function (lsubstc A wT s1 cT) x
(lsubstc_vars B w5 (csub_filter s1 [x]) [x] c7)))
as eq6.
{
apply @equality_trans with (t2 := lsubstc f2 w3 s1 c5); sp.
apply @equality_sym in hyp6; apply @equality_refl in hyp6; sp.
apply hyp0.
apply @equality_sym in hyp6; apply @equality_refl in hyp6; sp.
}
assert (equality lib (lsubstc t1 w1 s1 c1)
(lsubstc t2 w2 s2 c3)
(lsubstc A wT s1 cT))
as eq7 by (apply @equality_trans with (t2 := lsubstc t2 w2 s1 c2); sp).
assert (wf_term (subst B x t2))
as wfs2
by (apply lsubst_preserves_wf_term; sp;
unfold wf_sub, sub_range_sat; simpl; sp; cpx; rw @nt_wf_eq; sp).
assert (cover_vars (subst B x t2) s1) as cv2.
{
rw @cover_vars_eq.
rw @cover_vars_eq in cT3.
unfold subst.
rw subvars_prop; introv k.
generalize (eqvars_free_vars_disjoint B [(x,t1)]); intro u1.
generalize (eqvars_free_vars_disjoint B [(x,t2)]); intro u2.
rw eqvars_prop in u1.
rw eqvars_prop in u2.
rw u2 in k; simpl in k.
rw in_app_iff in k; rw in_remove_nvars in k; rw in_single_iff in k; repdors; repnd.
rw subvars_prop in cT3.
apply cT3; unfold subst.
rw u1.
rw in_app_iff; rw in_remove_nvars; rw in_single_iff; sp.
revert k.
boolvar; simpl; allrw app_nil_r; intro k; sp.
clear_dependents c2.
rw @cover_vars_eq in c2.
rw subvars_prop in c2.
apply c2; sp.
}
assert (cover_vars (subst B x t2) s2) as cv3.
{
rw @cover_vars_eq.
rw @cover_vars_eq in cv2.
allapply @similarity_dom; repnd; allrw.
rw sim0 in cv2; sp.
}
assert (tequality lib (lsubstc (subst B x t1) wT1 s1 cT3)
(lsubstc (subst B x t2) wfs2 s1 cv2)) as teqB.
{
generalize (hyp1 (lsubstc t1 w1 s1 c1) (lsubstc t2 w2 s2 c3)); intro k1.
autodimp k1 hyp; sp.
generalize (hyp1 (lsubstc t2 w2 s1 c2) (lsubstc t2 w2 s2 c3)); intro k2.
autodimp k2 hyp; sp.
repeat lsubstc_subst_aeq2.
proof_irr.
eapply tequality_trans;[eauto|].
apply tequality_sym; auto.
}
(* now we start proving our conclusion *)
dands.
{ apply @tequality_mkc_equality_if_equal; auto.
{
(* from hyp 4 *)
generalize (hyp1 (lsubstc t1 w1 s1 c1) (lsubstc t1 w1 s2 c0) eq1); intro teq.
repeat lsubstc_subst_aeq2.
proof_irr.
auto.
}
{
(* from eq1 and hyp5 *)
dimp hyp5. apply equality_refl in hyp6; auto.
rw @equality_in_function in hyp; repnd.
apply hyp in eq1.
repeat lsubstc_subst_aeq2.
proof_irr.
tcsp.
}
{
(* from eq6 and eq5 *)
rw @equality_in_function in eq6; repnd.
apply eq6 in eq5.
repeat lsubstc_subst_aeq2.
proof_irr.
tcsp.
eapply tequality_preserving_equality. exact eq5.
apply tequality_sym. exact teqB.
}
}
{(* from hyp1 and hyp2 *)
apply member_equality; auto.
repeat lsubstc_subst_aeq2.
proof_irr.
tcsp.
rw @equality_in_function in hyp6; repnd.
apply hyp6 in hyp4; auto.
}
Qed.
Lemma rule_apply_equality_true {o} :
forall lib (A B f1 f2 t1 t2 e1 e2 : NTerm)
(x : NVar)
(H : @barehypotheses o),
rule_true lib (rule_apply_equality A B f1 f2 t1 t2 e1 e2 x H).
Proof.
introv.
apply rule_true3_implies_rule_true.
apply rule_apply_equality_true3; auto.
Qed.
Lemma rule_apply_equality_true_ext_lib {o} :
forall lib (A B f1 f2 t1 t2 e1 e2 : NTerm)
(x : NVar)
(H : @barehypotheses o),
rule_true_ext_lib lib (rule_apply_equality A B f1 f2 t1 t2 e1 e2 x H).
Proof.
introv.
apply rule_true3_implies_rule_true_ext_lib.
introv.
apply rule_apply_equality_true3; auto.
Qed.
Lemma rule_apply_equality_true_ext_lib2 {o} :
forall lib (A B f1 f2 t1 t2 e1 e2 : NTerm)
(x : NVar)
(H : @barehypotheses o),
rule_true_ext_lib lib (rule_apply_equality A B f1 f2 t1 t2 e1 e2 x H).
Proof.
introv.
apply rule_true3_implies_rule_true_ext_lib.
introv.
apply rule_apply_equality_true3; auto.
Qed.
Lemma rule_apply_equality_wf2 {o} :
forall (A B f1 f2 t1 t2 e1 e2 : NTerm)
(x : NVar)
(H : @barehypotheses o),
wf_term A
-> covered A (vars_hyps H)
-> wf_rule2 (rule_apply_equality A B f1 f2 t1 t2 e1 e2 x H).
Proof.
introv wfA covA wf j.
allsimpl; repndors; subst; tcsp;
allunfold @wf_bseq; repnd; allsimpl; wfseq;
allrw <- @wf_apply_iff; allrw @covered_apply; repnd; tcsp.
- apply lsubst_wf_term in w1; dands; auto.
- allunfold @covered.
allrw subvars_eq.
introv i; simpl.
destruct (deq_nvar x x0) as [d|d]; subst; tcsp.
right.
apply c1.
apply eqset_free_vars_disjoint; simpl.
rw in_app_iff; rw in_remove_nvars; rw in_single_iff.
left; tcsp.
Qed.
(* begin hide *)
(* end hide *)
(* [27] ============ APPLY REDUCE ============ *)
(**
The following rule called the ``apply reduce'' rule is the
computation rule for applications.
<<
H |- (\x.t)s = u in T
By applyReduce ()
H |- t[x\s] = u in T
>>
*)
Definition rule_apply_reduce {o}
(T t s u : NTerm)
(x : NVar)
(H : @barehypotheses o) :=
mk_rule
(mk_baresequent
H
(mk_conclax (mk_equality (mk_apply (mk_lam x t) s) u T)))
[ mk_baresequent
H
(mk_conclax (mk_equality (subst t x s) u T))
]
[].
Lemma rule_apply_reduce_true {o} :
forall lib (T t s u : NTerm)
(x : NVar)
(H : @barehypotheses o)
(bc1 : disjoint (free_vars s) (bound_vars t)),
rule_true lib (rule_apply_reduce T t s u x H).
Proof.
intros.
unfold rule_apply_reduce, rule_true, closed_type_baresequent, closed_extract_baresequent; simpl.
intros.
(* We prove the well-formedness of things *)
destseq; allsimpl.
generalize (hyps (mk_baresequent H (mk_conclax (mk_equality (subst t x s) u T)))
(inl eq_refl));
simpl; intros hyp1.
destruct hyp1 as [ ws1 hyp1 ].
destseq; allsimpl; proof_irr; GC.
allunfold @closed_type; allunfold @closed_extract; allsimpl.
duplicate wfct as wfi.
rw <- @wf_equality_iff in wfct.
destruct wfct as [ wa wfct ].
destruct wfct as [ wu wT ].
rw <- @wf_apply_iff in wa.
destruct wa as [ wt ws ].
rw <- @wf_lam_iff in wt.
exists (@covered_axiom o (nh_vars_hyps H)); GC.
(* We prove some simple facts on our sequents *)
(* xxx *)
(* done with proving these simple facts *)
(* we now start proving the sequent *)
vr_seq_true.
vr_seq_true in hyp1.
generalize (hyp1 s1 s2 eqh sim); clear hyp1; intro hyp1; exrepnd.
lsubst_tac.
allrw @member_eq.
allrw <- @member_equality_iff.
rw @tequality_mkc_equality in hyp0; repnd.
assert (cequivc lib
(mkc_apply
(mkc_lam x (lsubstc_vars t wt (csub_filter s1 [x]) [x] c10))
(lsubstc s ws s1 c6))
(lsubstc (subst t x s) w1 s1 c1))
as ceq1.
(* begin proof of assert *)
destruct_cterms; unfold cequivc; simpl.
generalize (cequiv_beta lib x (csubst t (csub_filter s1 [x])) (csubst s s1)); intro k.
autodimp k hyp.
rw <- @isprog_vars_csubst_iff.
rw @isprog_vars_eq; sp.
rw @nt_wf_eq; sp.
autodimp k hyp.
apply isprogram_csubst; sp.
rw @nt_wf_eq; sp.
eapply cequiv_trans.
exact k.
rw <- @simple_csubst_subst; sp.
apply cequiv_refl.
apply isprogram_csubst; sp.
unfold subst; apply lsubst_wf_iff; try (rw @nt_wf_eq; sp).
unfold wf_sub, sub_range_sat; simpl; sp; cpx; rw @nt_wf_eq; sp.
(* end proof of assert *)
assert (cequivc lib
(mkc_apply
(mkc_lam x (lsubstc_vars t wt (csub_filter s2 [x]) [x] c11))
(lsubstc s ws s2 c9))
(lsubstc (subst t x s) w1 s2 c0))
as ceq2.
(* begin proof of assert *)
destruct_cterms; unfold cequivc; simpl.
generalize (cequiv_beta lib x (csubst t (csub_filter s2 [x])) (csubst s s2)); intro k.
autodimp k hyp.
rw <- @isprog_vars_csubst_iff.
rw @isprog_vars_eq; sp.
rw @nt_wf_eq; sp.
autodimp k hyp.
apply isprogram_csubst; sp.
rw @nt_wf_eq; sp.
eapply cequiv_trans.
exact k.
rw <- @simple_csubst_subst; sp.
apply cequiv_refl.
apply isprogram_csubst; sp.
unfold subst; apply lsubst_wf_iff; try (rw @nt_wf_eq; sp).
unfold wf_sub, sub_range_sat; simpl; sp; cpx; rw @nt_wf_eq; sp.
(* end proof of assert *)
(* we start proving our conclusion *)
dands; try (complete sp).
apply @tequality_mkc_equality_if_equal; auto.
eapply @equality_respects_cequivc_left.
apply cequivc_sym. exact ceq1.
apply @equality_sym.
eapply @equality_respects_cequivc_left.
apply cequivc_sym.
exact ceq2.
apply @equality_sym. apply hyp4; apply equality_refl in hyp1; auto.
apply hyp0. apply equality_sym in hyp1; apply equality_refl in hyp1; auto.
eapply @equality_respects_cequivc_left.
apply cequivc_sym.
exact ceq1.
sp.
Qed.
(* begin hide *)
(* end hide *)
(* [28] ============ FUNCTION EXTENSIONALITY ============ *)
(**
The following rule called the ``function extensionality rule''
states that the equality between functions in Nuprl is extensional.
<<
H |- f1 = f2 in x:A->B
By functionExtensionality lvl(i) z ()
H z : A |- f1 z = f2 z in B[x\z]
H |- A = A in Type(i)
>>
*)
Definition rule_function_extensionality {o}
(A B f1 f2 : NTerm)
(x z : NVar)
(i : nat)
(H : @barehypotheses o) :=
mk_rule
(mk_baresequent
H
(mk_conclax (mk_equality f1 f2 (mk_function A x B))))
[ mk_baresequent
(snoc H (mk_hyp z A))
(mk_conclax (mk_equality
(mk_apply f1 (mk_var z))
(mk_apply f2 (mk_var z))
(subst B x (mk_var z)))),
mk_baresequent
H
(mk_conclax (mk_equality A A (mk_uni i))) ]
[sarg_var z].
Lemma rule_function_extensionality_true {o} :
forall lib (A B f1 f2 : NTerm)
(x z : NVar)
(i : nat)
(H : @barehypotheses o)
(bc1 : !LIn z (bound_vars B)),
rule_true lib (rule_function_extensionality A B f1 f2 x z i H).
Proof.
intros.
unfold rule_function_extensionality, rule_true, closed_type_baresequent, closed_extract_baresequent; simpl.
intros.
(* We prove the well-formedness of things *)
destseq; allsimpl.
generalize (hyps (mk_baresequent (snoc H (mk_hyp z A))
(mk_conclax (mk_equality
(mk_apply f1 (mk_var z))
(mk_apply f2 (mk_var z))
(subst B x (mk_var z)))))
(inl eq_refl))
(hyps (mk_baresequent H (mk_conclax (mk_equality A A (mk_uni i))))
(inr (inl eq_refl)));
simpl; intros hyp1 hyp2.
destruct hyp1 as [ ws1 hyp1 ].
destruct hyp2 as [ ws2 hyp2 ].
destseq; allsimpl; proof_irr; GC.
allunfold @closed_type; allunfold @closed_extract; allsimpl.
duplicate wfct as wfi.
rw <- @wf_equality_iff in wfct.
destruct wfct as [ wf1 wfct ].
destruct wfct as [ wf2 wfct ].
rw <- @wf_function_iff in wfct.
destruct wfct as [ wA wB ].
exists (@covered_axiom o (nh_vars_hyps H)); GC.
(* We prove some simple facts on our sequents *)
assert ((z <> x -> !LIn z (free_vars B))
# !LIn z (free_vars f1)
# !LIn z (free_vars f2)
# !LIn z (free_vars A)
# !LIn z (vars_hyps H)) as vhyps.
clear hyp1 hyp2.
dwfseq.
sp;
try (complete (generalize (cg z); sp;
allrw in_remove_nvars; allsimpl;
autodimp X0 h; sp));
try (complete (generalize (cg0 z); sp;
allrw in_remove_nvars; allsimpl;
autodimp X0 h; sp));
try (complete (generalize (cg1 z); sp;
allrw in_remove_nvars; allsimpl;
autodimp X0 h; sp));
try (complete (apply_in_hyp p;
generalize (subvars_hs_vars_hyps H); intro sv;
rw subvars_prop in sv;
apply sv in p; sp)).
destruct vhyps as [ nzB vhyps ].
destruct vhyps as [ nzf1 vhyps ].
destruct vhyps as [ nzf2 vhyps ].
destruct vhyps as [ nzA nzH ].
(* done with proving these simple facts *)
(* we now start proving the sequent *)
vr_seq_true.
lift_lsubst.
rw @member_eq.
rw <- @member_equality_iff.
assert (tequality lib
(mkc_function (lsubstc A wA s1 c4) x
(lsubstc_vars B wB (csub_filter s1 [x]) [x] c5))
(mkc_function (lsubstc A wA s2 c6) x
(lsubstc_vars B wB (csub_filter s2 [x]) [x] c7))) as eqfunc.
rw @tequality_function.
split.
(* First, we prove that the a's are types *)
vr_seq_true in hyp2.
generalize (hyp2 s1 s2 eqh sim); clear hyp2; intro hyp2.
exrepd.
lift_lsubst in t.
lift_lsubst in e.
rw @member_eq in e.
rw <- @member_equality_iff in e.
applydup @equality_in_uni in e as e'.
rw @fold_type in e'.
apply @equality_commutes2 in t; try (complete auto).
apply @equality_in_uni in t; sp.
(* Then we prove that the b's are type families *)
intros a a' eqaa'.
vr_seq_true in hyp1.
generalize (hyp1 (snoc s1 (z, a)) (snoc s2 (z, a'))); clear hyp1; intro hyp1.
autodimp hyp1 hyp.
(* we have to prove the functionality of our hypotheses *)
apply hyps_functionality_snoc2; simpl; try (complete sp).
introv eq s.
vr_seq_true in hyp2.
generalize (hyp2 s1 s' eqh s); clear hyp2; intro hyp2.
exrepd.
lift_lsubst in t.
lift_lsubst in e.
rw @member_eq in e.
rw <- @member_equality_iff in e.
applydup @equality_in_uni in e as e'.
rw @fold_type in e'.
apply @equality_commutes2 in t; try (complete auto).
apply @equality_in_uni in t; sp.
(* we have to prove the similarity of our hypotheses *)
autodimp hyp1 hyp.
rw @similarity_snoc; simpl.
exists s1 s2 a a' wA c4; sp.
(* we can now use hyp1 *)
exrepnd; lsubst_tac.
(* we use hyp0 *)
rw @tequality_mkc_equality in hyp0; repnd.
(* we use hyp3 *)
assert (lsubstc (subst B x (mk_var z)) wT0 (snoc s1 (z, a)) cT1
= substc a x (lsubstc_vars B wB (csub_filter s1 [x]) [x] c5)) as eq1
by (apply lsubstc_subst_snoc_eq; try (complete sp);
allapply @similarity_dom; exrepd; allrw; sp).
rewrite eq1 in hyp3.
assert (lsubstc (subst B x (mk_var z)) wT0 (snoc s2 (z, a')) cT2
= substc a' x (lsubstc_vars B wB (csub_filter s2 [x]) [x] c7)) as eq2
by (apply lsubstc_subst_snoc_eq; try (complete sp);
allapply @similarity_dom; exrepd; allrw; sp).
rewrite eq2 in hyp3.
sp.
(* we prove the membership *)
assert (forall a a' s1 s2,
hyps_functionality lib s1 H
-> similarity lib s1 s2 H
-> {c1f : cover_vars f1 s1
, {c2f : cover_vars f2 s2
, {c1A : cover_vars A s1
, {c1B : cover_vars_upto B (csub_filter s1 [x]) [x]
, equality lib a a' (lsubstc A wA s1 c1A)
-> equality lib
(mkc_apply (lsubstc f1 wf1 s1 c1f) a)
(mkc_apply (lsubstc f2 wf2 s2 c2f) a')
(substc a x (lsubstc_vars B wB (csub_filter s1 [x]) [x] c1B))}}}}) as eqlam.
introv eqh0 sim0.
assert (cover_vars f1 s0) as c1f1.
clear eqfunc.
allapply @similarity_dom; repnd.
allrw @cover_vars_eq.
allrw.
rw sim2 in c1; sp.
assert (cover_vars f1 s3) as c2f1.
clear eqfunc.
allapply @similarity_dom; repnd.
allrw @cover_vars_eq.
allrw.
rw sim2 in c1; sp.
assert (cover_vars f2 s0) as c1f2.
clear eqfunc.
allapply @similarity_dom; repnd.
allrw @cover_vars_eq.
allrw.
rw sim2 in c2; sp.
assert (cover_vars f2 s3) as c2f2.
clear eqfunc.
allapply @similarity_dom; repnd.
allrw @cover_vars_eq.
allrw.
rw sim2 in c2; sp.
assert (cover_vars_upto B (csub_filter s0 [x]) [x]) as cB0.
clear eqfunc.
allapply @similarity_dom; repnd.
allunfold @cover_vars_upto.
allrw @dom_csub_csub_filter.
allrw.
rw sim in c7; sp.
assert (cover_vars_upto B (csub_filter s3 [x]) [x]) as cB3.
clear eqfunc.
allapply @similarity_dom; repnd.
allunfold @cover_vars_upto.
allrw @dom_csub_csub_filter.
allrw.
rw sim in c7; sp.
assert (cover_vars A s0) as cA0.
clear eqfunc.
allrw @cover_vars_eq.
allapply @similarity_dom; repnd.
allrw.
rw sim in c6; sp.
assert (cover_vars A s3) as cA3.
clear eqfunc.
allrw @cover_vars_eq.
allapply @similarity_dom; repnd.
allrw.
rw sim in c6; sp.
exists c1f1 c2f2 cA0 cB0.
introv eqaa'.
vr_seq_true in hyp1.
generalize (hyp1 (snoc s0 (z, a)) (snoc s3 (z, a'))); clear hyp1; intro hyp1.
autodimp hyp1 hyp.
(* we have to prove the functionality of our hypotheses *)
apply hyps_functionality_snoc2; simpl; try (complete sp).
introv eq s.
vr_seq_true in hyp2.
generalize (hyp2 s0 s' eqh0 s); clear hyp2; intro hyp2.
exrepd.
lift_lsubst in t.
lift_lsubst in e.
rw @member_eq in e.
rw <- @member_equality_iff in e.
applydup @equality_in_uni in e as e'.
rw @fold_type in e'.
apply @equality_commutes2 in t; try (complete auto).
apply @equality_in_uni in t; sp.
(* we have to prove the similarity of our hypotheses *)
autodimp hyp1 hyp.
rw @similarity_snoc; simpl.
exists s0 s3 a a' wA cA0; sp.
(* we can now use hyp1 *)
exrepnd; lsubst_tac.
rw @tequality_mkc_equality in hyp0; repnd.
rw @member_eq in hyp1.
rw <- @member_equality_iff in hyp1.
clear_irr; GC.
assert (lsubstc (subst B x (mk_var z)) wT0 (snoc s0 (z, a)) cT1
= substc a x (lsubstc_vars B wB (csub_filter s0 [x]) [x] cB0)) as eq1
by (apply lsubstc_subst_snoc_eq; try (complete sp);
allapply @similarity_dom; exrepd; allrw; sp).
allrw eq1.
clear eq1.
assert (lsubstc (subst B x (mk_var z)) wT0 (snoc s3 (z, a')) cT2
= substc a' x (lsubstc_vars B wB (csub_filter s3 [x]) [x] cB3)) as eq2
by (apply lsubstc_subst_snoc_eq; try (complete sp);
allapply @similarity_dom; exrepd; allrw; sp).
rewrite eq2 in hyp3.
clear eq2.
eapply equality_trans. exact hyp1. apply hyp0.
apply equality_sym in hyp1; apply equality_refl in hyp1; auto.
(* a few useful assertions *)
assert (similarity lib s1 s1 H)
as sim1
by (allapply @similarity_refl; sp).
assert (similarity lib s2 s2 H)
as sim2
by (apply @similarity_sym in sim; allapplydup @similarity_refl; sp;
apply eqh in sim; sp).
assert (hyps_functionality lib s2 H)
as eqh2
by (apply @similarity_hyps_functionality_trans with (s1 := s1); sp).
(* we start proving our conclusion *)
rw @equality_in_function2.
dands; try (complete sp).
(* tequality *)
apply @tequality_mkc_equality_if_equal.
dands; try (complete sp).
(* application in B *)
rw @equality_in_function2.
split; try (complete (apply @tequality_refl in eqfunc; sp)).
introv e.
assert (equality lib a' a' (lsubstc A wA s2 c6))
as e'
by (apply @equality_sym in e; apply @equality_refl in e;
rw @tequality_function in eqfunc; repnd;
eapply @tequality_preserving_equality;
try (exact e); sp).
generalize (eqlam a a' s1 s2 eqh sim); intro k1; exrepnd; clear_irr; sp.
generalize (eqlam a' a' s2 s2 eqh2 sim2); intro k2; exrepnd; clear_irr; sp.
eapply @equality_trans; sp.
exact k1.
apply @equality_sym.
eapply @tequality_preserving_equality.
exact k2.
apply @tequality_sym.
rw @tequality_function in eqfunc; repnd; sp.
(* application in B *)
rw @equality_in_function2.
split; try (complete (apply @tequality_refl in eqfunc; sp)).
introv e.
assert (equality lib a a (lsubstc A wA s1 c4)) as e' by (allapply @equality_refl; sp).
generalize (eqlam a a' s1 s2 eqh sim); intro k1; exrepnd; clear_irr; sp.
generalize (eqlam a a s1 s1 eqh sim1); intro k2; exrepnd; clear_irr; sp.
eapply @equality_trans; sp.
apply equality_sym.
exact k2.
auto.
(* type *)
apply @tequality_refl in eqfunc; sp.
(* application in B *)
introv e.
generalize (eqlam a a' s1 s1 eqh sim1); intro k; exrepnd; clear_irr; sp.
Qed.
(* end hide *)
|
(******************************************************************************
* Orca: A Functional Correctness Verifier for Imperative Programs
* Based on Isabelle/UTP
*
* Copyright (c) 2016-2018 Virginia Tech, USA
* 2016-2018 Technische Universität München, Germany
* 2016-2018 University of York, UK
* 2016-2018 Université Paris-Saclay, Univ. Paris-Sud, France
*
* This software may be distributed and modified according to the terms of
* the GNU Lesser General Public License version 3.0 or any later version.
* Note that NO WARRANTY is provided.
*
* See CONTRIBUTORS, LICENSE and CITATION files for details.
******************************************************************************)
section \<open>Algebraic laws of programming\<close>
text \<open>In this section we introduce the semantic rules related to the different
statements of IMP. In the literature this also known as the algebraic laws of programming.
In our framework we will use these rules in order to optimize a given program written in our
language, and this before any deductive proof verification activity or formal testing.\<close>
theory Algebraic_Laws
imports "../../Isabelle-UTP/utp/utp_urel_laws"
begin
named_theorems symbolic_exec and symbolic_exec_assign_uop and symbolic_exec_assign_bop and
symbolic_exec_assign_trop and symbolic_exec_assign_qtop and symbolic_exec_ex
(* Usage of symbolic_exec_ex for the simp lemmas avoids annoying warnings about duplicate theorems
when using `simp add: symbolic_exec` *)
subsection \<open>SKIP Laws\<close>
text \<open>In this section we introduce the algebraic laws of programming related to the SKIP
statement.\<close>
lemma pre_skip_post: "(\<lceil>b\<rceil>\<^sub>< \<and> II) = (II \<and> \<lceil>b\<rceil>\<^sub>>)"
by rel_auto
lemma skip_var:
fixes x :: "(bool \<Longrightarrow> '\<alpha>)"
shows "($x \<and> II) = (II \<and> $x\<acute>)"
by rel_auto
lemma assign_r_alt_def [symbolic_exec]:
fixes x :: "('a \<Longrightarrow>'\<alpha>)"
shows "x :== v = II\<lbrakk>\<lceil>v\<rceil>\<^sub></$x\<rbrakk>"
by rel_auto
lemma skip_r_alpha_eq:
"II = ($\<Sigma>\<acute> =\<^sub>u $\<Sigma>)"
by rel_auto
lemma skip_r_refine_orig:
"(p \<Rightarrow> p) \<sqsubseteq> II"
by pred_blast
lemma skip_r_eq[simp]: "\<lbrakk>II\<rbrakk>\<^sub>e (a, b) \<longleftrightarrow> a = b"
by rel_auto
lemma skip_refine_join:
"(p \<Rightarrow> q) \<sqsubseteq> II \<longleftrightarrow> `((p \<squnion> II) \<Rightarrow> q)`"
by pred_auto
lemma skip_refine_rel:
"`(II \<Rightarrow> (p \<Rightarrow> q))` \<Longrightarrow> (p \<Rightarrow> q) \<sqsubseteq> II"
by pred_auto
lemma skip_r_refine_pred:
"`(p \<Rightarrow> q)` \<Longrightarrow> (\<lceil>p\<rceil>\<^sub>< \<Rightarrow> \<lceil>q\<rceil>\<^sub>>) \<sqsubseteq> II"
by rel_auto
subsection \<open>Assignment Laws\<close>
text \<open>In this section we introduce the algebraic laws of programming related to the assignment
statement.\<close>
lemma "&v\<lbrakk>expr/v\<rbrakk> = [v \<mapsto>\<^sub>s expr] \<dagger> &v" ..
lemma usubst_cancel[usubst,symbolic_exec]:
assumes 1:"weak_lens v"
shows "(&v)\<lbrakk>expr/v\<rbrakk> = expr"
using 1
by transfer' rel_auto
lemma usubst_cancel_r[usubst,symbolic_exec]:
assumes 1:"weak_lens v"
shows "($v)\<lbrakk>\<lceil>expr\<rceil>\<^sub></$v\<rbrakk>= \<lceil>expr\<rceil>\<^sub><"
using 1
by rel_auto
lemma assign_test[symbolic_exec]:
assumes 1:"mwb_lens x"
shows "(x :== \<guillemotleft>u\<guillemotright> ;; x :== \<guillemotleft>v\<guillemotright>) = (x :== \<guillemotleft>v\<guillemotright>)"
using 1
by (simp add: assigns_comp subst_upd_comp subst_lit usubst_upd_idem)
lemma assign_r_comp[symbolic_exec]:
"(x :== u ;; P) = P\<lbrakk>\<lceil>u\<rceil>\<^sub></$x\<rbrakk>"
by (simp add: assigns_r_comp usubst)
lemma assign_twice[symbolic_exec]:
assumes "mwb_lens x" and "x \<sharp> f"
shows "(x :== e ;; x :== f) = (x :== f)"
using assms
by (simp add: assigns_comp usubst)
lemma assign_commute:
assumes "x \<bowtie> y" "x \<sharp> f" "y \<sharp> e"
shows "(x :== e ;; y :== f) = (y :== f ;; x :== e)"
using assms
by (rel_auto, simp_all add: lens_indep_comm)
lemma assign_cond:
fixes x :: "('a \<Longrightarrow> '\<alpha>)"
assumes "out\<alpha> \<sharp> b"
shows "(x :== e ;; (P \<triangleleft> b \<triangleright> Q)) =
((x :== e ;; P) \<triangleleft>b\<lbrakk>\<lceil>e\<rceil>\<^sub></$x\<rbrakk>\<triangleright> (x :== e ;; Q))"
by rel_auto
lemma assign_rcond[symbolic_exec]:
fixes x :: "('a \<Longrightarrow> '\<alpha>)"
shows "(x :== e ;; (P \<triangleleft> b \<triangleright>\<^sub>r Q)) = ((x :== e ;; P) \<triangleleft> (b\<lbrakk>e/x\<rbrakk>) \<triangleright>\<^sub>r (x :== e ;; Q))"
by rel_auto
lemma assign_uop1[symbolic_exec_assign_uop]:
assumes 1: "mwb_lens v"
shows "(v :== e1 ;; v :== (uop F (&v))) = (v :== (uop F e1))"
using 1
by rel_auto
lemma assign_bop1[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2"
shows "(v :== e1 ;; v :== (bop bp (&v) e2)) = (v :== (bop bp e1 e2))"
using 1 2
by rel_auto
lemma assign_bop2[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2"
shows "(v :== e1 ;; v :== (bop bp e2 (&v))) = (v :== (bop bp e2 e1))"
using 1 2
by rel_auto
lemma assign_trop1[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3"
shows "(v :== e1 ;; v :== (trop tp (&v) e2 e3)) =
(v :== (trop tp e1 e2 e3))"
using 1 2 3
by rel_auto
lemma assign_trop2[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3"
shows "(v :== e1 ;; v :== (trop tp e2 (&v) e3)) =
(v :== (trop tp e2 e1 e3))"
using 1 2 3
by rel_auto
lemma assign_trop3[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3"
shows "(v :== e1 ;; v :== (trop tp e2 e3 (&v))) =
(v :== (trop tp e2 e3 e1))"
using 1 2 3
by rel_auto
lemma assign_qtop1[symbolic_exec_assign_qtop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3" and 4:"v \<sharp> e4"
shows "(v :== e1 ;; v :== (qtop tp (&v) e2 e3 e4)) =
(v :== (qtop tp e1 e2 e3 e4))"
using 1 2 3 4
by rel_auto
lemma assign_qtop2[symbolic_exec_assign_qtop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3" and 4:"v \<sharp> e4"
shows "(v :== e1 ;; v :== (qtop tp e2 (&v) e3 e4)) =
(v :== (qtop tp e2 e1 e3 e4))"
using 1 2 3 4
by rel_auto
lemma assign_qtop3[symbolic_exec_assign_qtop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3" and 4:"v \<sharp> e4"
shows "(v :== e1 ;; v :== (qtop tp e2 e3 (&v) e4)) =
(v :== (qtop tp e2 e3 e1 e4))"
using 1 2 3 4
by rel_auto
lemma assign_qtop4[symbolic_exec_assign_qtop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> e2" and 3:"v \<sharp> e3" and 4:"v \<sharp> e4"
shows "(v :== e1 ;; v :== (qtop tp e2 e3 e4 (&v))) =
(v :== (qtop tp e2 e3 e4 e1))"
using 1 2 3 4
by rel_auto
lemma assign_cond_seqr_dist:
"(v :== e ;; (P \<triangleleft> b \<triangleright> Q)) = ((v :== e ;; P) \<triangleleft> b\<lbrakk>\<lceil>e\<rceil>\<^sub></$v\<rbrakk> \<triangleright> (v :== e ;; Q))"
by rel_auto
text \<open>In the sequel we find assignment laws proposed by Hoare\<close>
lemma assign_vwb_skip:
assumes 1: "vwb_lens v"
shows "(v :== &v) = II"
by (simp add: assms skip_r_def usubst_upd_var_id)
lemma assign_simultaneous:
assumes 1: "vwb_lens v2"
and 2: "v1 \<bowtie> v2"
shows "(v1,v2 :== e, (&v2)) = (v1 :== e)"
by (simp add: 1 2 usubst_upd_comm usubst_upd_var_id)
lemma assign_seq:
assumes 1: "vwb_lens var2"
shows"(var1:== expr);; (var2 :== &var2) = (var1:== expr)"
using 1 by rel_auto
lemma assign_cond_uop[symbolic_exec_assign_uop]:
assumes 1: "weak_lens v"
shows "v :== expr ;; (C1 \<triangleleft>uop F (&v)\<triangleright>\<^sub>r C2) =
(v :== expr ;; C1) \<triangleleft>uop F expr\<triangleright>\<^sub>r (v :== expr ;; C2)"
using 1
by rel_auto
lemma assign_cond_bop1[symbolic_exec_assign_bop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2"
shows "(v :== expr ;; (C1 \<triangleleft>(bop bp (&v) exp2)\<triangleright>\<^sub>r C2)) =
((v :== expr ;; C1) \<triangleleft>(bop bp expr exp2)\<triangleright>\<^sub>r (v :== expr ;; C2))"
using 1 2
by rel_auto
lemma assign_cond_bop2[symbolic_exec_assign_bop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2"
shows "(v :== exp1 ;; (C1 \<triangleleft>(bop bp exp2 (&v))\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(bop bp exp2 exp1)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2
by rel_auto
lemma assign_cond_trop1[symbolic_exec_assign_trop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3"
shows "(v :== expr ;; (C1 \<triangleleft>(trop tp (&v) exp2 exp3)\<triangleright>\<^sub>r C2)) =
((v :== expr ;; C1) \<triangleleft>(trop tp expr exp2 exp3)\<triangleright>\<^sub>r (v :== expr ;; C2))"
using 1 2 3
by rel_auto
lemma assign_cond_trop2[symbolic_exec_assign_trop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3"
shows "(v :== exp1 ;; (C1 \<triangleleft>(trop tp exp2 (&v) exp3)\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(trop tp exp2 exp1 exp3)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2 3
by rel_auto
lemma assign_cond_trop3[symbolic_exec_assign_trop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3"
shows "(v :== exp1 ;; (C1 \<triangleleft>(trop bp exp2 exp3 (&v))\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(trop bp exp2 exp3 exp1)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2 3
by rel_auto
lemma assign_cond_qtop1[symbolic_exec_assign_qtop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3" and 4: "v \<sharp> exp4"
shows "(v :== exp1 ;; (C1 \<triangleleft>(qtop tp (&v) exp2 exp3 exp4)\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(qtop tp exp1 exp2 exp3 exp4)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2 3 4
by rel_auto
lemma assign_cond_qtop2[symbolic_exec_assign_qtop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3" and 4:"v \<sharp> exp4"
shows "(v :== exp1 ;; (C1 \<triangleleft>(qtop tp exp2 (&v) exp3 exp4)\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(qtop tp exp2 exp1 exp3 exp4)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2 3 4
by rel_auto
lemma assign_cond_qtop3[symbolic_exec_assign_qtop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3" and 4: "v \<sharp> exp4"
shows "(v :== exp1 ;; (C1 \<triangleleft>(qtop bp exp2 exp3 (&v) exp4)\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(qtop bp exp2 exp3 exp1 exp4)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2 3 4
by rel_auto
lemma assign_cond_qtop4[symbolic_exec_assign_qtop]:
assumes 1: "weak_lens v" and 2: "v \<sharp> exp2" and 3: "v \<sharp> exp3" and 4: "v \<sharp> exp4"
shows "(v :== exp1 ;; (C1 \<triangleleft>(qtop bp exp2 exp3 exp4 (&v))\<triangleright>\<^sub>r C2)) =
((v :== exp1 ;; C1) \<triangleleft>(qtop bp exp2 exp3 exp4 exp1)\<triangleright>\<^sub>r (v :== exp1 ;; C2))"
using 1 2 3 4
by rel_auto
lemma assign_cond_If [symbolic_exec]:
"((v :== exp1) \<triangleleft> bexp\<triangleright>\<^sub>r (v :== exp2)) =
(v :== (trop If bexp exp1 exp2))"
by rel_auto
lemma assign_cond_If_uop[symbolic_exec_assign_uop]:
assumes 1: "mwb_lens v"
shows "(v :== E;;
((v :== uop F (&v)) \<triangleleft>uop F (&v)\<triangleright>\<^sub>r (v :== uop G (&v)))) =
(v :== trop If (uop F E) (uop F E) (uop G E))"
using 1
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_bop[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> expr"
shows "((v :== E);;
((v :== (bop F expr (&v))) \<triangleleft>bop F expr (&v)\<triangleright>\<^sub>r (v :== (bop G expr (&v))))) =
(v :== (trop If (bop F expr E) (bop F expr E) (bop G expr E)))"
using 1 2
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_bop1[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> expr"
shows "((v :== E);;
((v :== (bop F (&v) expr)) \<triangleleft>bop F (&v) expr\<triangleright>\<^sub>r (v :== (bop G (&v) expr)))) =
(v :== (trop If (bop F E expr) (bop F E expr) (bop G E expr)))"
using 1 2
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_bop2[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (bop F (&v) exp1)) \<triangleleft>bop F (&v) exp1\<triangleright>\<^sub>r (v :== (bop G (&v) exp2)))) =
(v :== (trop If (bop F E exp1) (bop F E exp1) (bop G E exp2)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_bop4[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (bop F (&v) exp1)) \<triangleleft>bop F (&v) exp1\<triangleright>\<^sub>r (v :== (bop G exp2 (&v))))) =
(v :== (trop If (bop F E exp1) (bop F E exp1) (bop G exp2 E)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_bop5[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (bop F exp1 (&v))) \<triangleleft>bop F exp1 (&v)\<triangleright>\<^sub>r (v :== (bop G (&v) exp2)))) =
(v :== (trop If (bop F exp1 E) (bop F exp1 E) (bop G E exp2)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_bop6[symbolic_exec_assign_bop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (bop F exp1 (&v))) \<triangleleft>bop F exp1 (&v)\<triangleright>\<^sub>r (v :== (bop G exp2 (&v))))) =
(v :== (trop If (bop F exp1 E) (bop F exp1 E) (bop G exp2 E)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_trop[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (trop F exp1 exp2 (&v))) \<triangleleft>trop F exp1 exp2 (&v)\<triangleright>\<^sub>r (v :== (trop G exp1 exp2 (&v))))) =
(v :== (trop If (trop F exp1 exp2 E) (trop F exp1 exp2 E) (trop G exp1 exp2 E)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_trop1[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (trop F exp1 (&v) exp2)) \<triangleleft>trop F exp1 (&v) exp2\<triangleright>\<^sub>r (v :== (trop G exp1 (&v) exp2)))) =
(v :== (trop If (trop F exp1 E exp2) (trop F exp1 E exp2) (trop G exp1 E exp2)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_trop2[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2"
shows "((v :== E);;
((v :== (trop F (&v) exp1 exp2)) \<triangleleft>trop F (&v) exp1 exp2\<triangleright>\<^sub>r (v :== (trop G (&v) exp1 exp2)))) =
(v :== (trop If (trop F E exp1 exp2) (trop F E exp1 exp2) (trop G E exp1 exp2)))"
using 1 2 3
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_trop3[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2" and 4:"v \<sharp> exp3" and 5:"v \<sharp> exp4"
shows "((v :== E);;
((v :== (trop F exp1 exp2 (&v))) \<triangleleft>trop F exp1 exp2 (&v)\<triangleright>\<^sub>r (v :== (trop G exp3 exp4 (&v))))) =
(v :== (trop If (trop F exp1 exp2 E) (trop F exp1 exp2 E) (trop G exp3 exp4 E)))"
using 1 2 3 4 5
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_trop4[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2" and 4:"v \<sharp> exp3" and 5:"v \<sharp> exp4"
shows "((v :== E);;
((v :== (trop F exp1 (&v) exp2)) \<triangleleft>trop F exp1 (&v) exp2\<triangleright>\<^sub>r (v :== (trop G exp3 (&v) exp4)))) =
(v :== (trop If (trop F exp1 E exp2) (trop F exp1 E exp2) (trop G exp3 E exp4)))"
using 1 2 3 4 5
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
lemma assign_cond_If_trop5[symbolic_exec_assign_trop]:
assumes 1: "mwb_lens v" and 2:"v \<sharp> exp1" and 3:"v \<sharp> exp2" and 4:"v \<sharp> exp3" and 5:"v \<sharp> exp4"
shows "((v :== E);;
((v :== (trop F (&v) exp1 exp2)) \<triangleleft>trop F (&v) exp1 exp2\<triangleright>\<^sub>r (v :== (trop G (&v) exp3 exp4)))) =
(v :== (trop If (trop F E exp1 exp2) (trop F E exp1 exp2) (trop G E exp3 exp4)))"
using 1 2 3 4 5
proof (rel_simp, transfer)
fix a :: 'a and b :: 'a and va :: "bool \<Longrightarrow> 'a" and Fa :: "bool \<Rightarrow> bool" and Ea :: "'a \<Rightarrow> bool" and Ga :: "bool \<Rightarrow> bool"
have "Fa (Ea a) \<longrightarrow> (Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)) \<and> (\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a)))"
by presburger
then have "\<not> ((\<not> Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Fa (Ea a))) \<and> (Fa (Ea a) \<or> \<not> b = put\<^bsub>va\<^esub> a (Ga (Ea a)))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by fastforce
then show "(Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Fa (Ea a)) \<or> \<not> Fa (Ea a) \<and> b = put\<^bsub>va\<^esub> a (Ga (Ea a))) = (b = put\<^bsub>va\<^esub> a (Fa (Ea a) \<or> \<not> Fa (Ea a) \<and> Ga (Ea a)))"
by meson
qed
subsection \<open>Conditional Laws\<close>
text \<open>In this section we introduce the algebraic laws of programming related to the conditional
statement.\<close>
named_theorems urel_cond
lemma cond_idem[urel_cond]:
"(P \<triangleleft> b \<triangleright> P) = P"
by rel_auto
lemma cond_symm:
"(P \<triangleleft> b \<triangleright> Q) = (Q \<triangleleft>\<not> b\<triangleright> P)"
by rel_auto
lemma cond_assoc:
"(P \<triangleleft> b \<triangleright> (Q \<triangleleft> b \<triangleright> R)) = ((P \<triangleleft> b \<triangleright> Q) \<triangleleft> b \<triangleright> R)"
by rel_auto
lemma cond_distr[urel_cond]:
"((P \<triangleleft> b'\<triangleright> R) \<triangleleft> b \<triangleright> (Q \<triangleleft> b'\<triangleright> R))= ((P \<triangleleft> b \<triangleright> Q) \<triangleleft> b'\<triangleright> R)"
by rel_auto
lemma cond_unit_T:
"(P \<triangleleft>true\<triangleright> Q) = P"
by auto
lemma cond_unit_F:
"(P \<triangleleft>false\<triangleright> Q) = Q"
by auto
lemma cond_and_T_integrate[urel_cond]:
"((P \<and> b) \<or> (Q \<triangleleft> b \<triangleright> R)) = ((P \<or> Q) \<triangleleft> b \<triangleright> R)"
by rel_auto
lemma cond_L6[urel_cond]:
"(P \<triangleleft> b \<triangleright> (Q \<triangleleft> b \<triangleright> R)) = (P \<triangleleft> b \<triangleright> R)"
by rel_auto
lemma cond_L7[urel_cond]:
"(P \<triangleleft> b \<triangleright> (P \<triangleleft> c \<triangleright> Q)) = (P \<triangleleft> b \<or> c \<triangleright> Q)"
by rel_auto
lemma cond_and_distr[urel_cond]:
"((P \<and> Q) \<triangleleft> b \<triangleright> (R \<and> S)) = ((P \<triangleleft> b \<triangleright> R) \<and> (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_or_distr[urel_cond]:
"((P \<or> Q) \<triangleleft> b \<triangleright> (R \<or> S)) = ((P \<triangleleft> b \<triangleright> R) \<or> (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_imp_distr[urel_cond]:
"((P \<Rightarrow> Q) \<triangleleft> b \<triangleright> (R \<Rightarrow> S)) =
((P \<triangleleft> b \<triangleright> R) \<Rightarrow> (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_eq_distr[urel_cond]:
"((P \<Leftrightarrow> Q) \<triangleleft> b \<triangleright> (R \<Leftrightarrow> S)) =
((P \<triangleleft> b \<triangleright> R) \<Leftrightarrow> (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_ueq_distr[urel_cond]:
"((P =\<^sub>u Q) \<triangleleft> b \<triangleright> (R =\<^sub>u S)) =
((P \<triangleleft> b \<triangleright> R) =\<^sub>u (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_conj_distr[urel_cond]:
"((P \<and> Q) \<triangleleft> b \<triangleright> (P \<and> S)) = (P \<and> (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_disj_distr [urel_cond]:
"((P \<or> Q) \<triangleleft> b \<triangleright> (P \<or> S)) = (P \<or> (Q \<triangleleft> b \<triangleright> S))"
by rel_auto
lemma cond_neg[urel_cond]:
"\<not> (P \<triangleleft> b \<triangleright> Q) = ((\<not> P) \<triangleleft> b \<triangleright> (\<not> Q))"
by rel_auto
lemma cond_conj[urel_cond]:
"(P \<triangleleft>b \<and> c\<triangleright> Q) = (P \<triangleleft> c \<triangleright> Q) \<triangleleft> b \<triangleright> Q"
by rel_auto
(*IF Theorem by Hoare: It optimize nested IF*)
theorem COND12[urel_cond]:
"((C1 \<triangleleft>bexp2\<triangleright> C3) \<triangleleft>bexp1\<triangleright> (C2 \<triangleleft>bexp3\<triangleright> C3)) =
((C1 \<triangleleft>bexp1\<triangleright> C2) \<triangleleft>(bexp2 \<triangleleft>bexp1\<triangleright>bexp3)\<triangleright> C3)"
by rel_auto
lemma comp_cond_left_distr:
"((P \<triangleleft> b \<triangleright>\<^sub>r Q) ;; R) = ((P ;; R) \<triangleleft> b \<triangleright>\<^sub>r (Q ;; R))"
by rel_auto
lemma cond_var_subst_left[urel_cond]:
assumes "vwb_lens x"
shows "(P\<lbrakk>true/x\<rbrakk> \<triangleleft>&x \<triangleright> Q) = (P \<triangleleft>&x \<triangleright> Q)"
using assms
apply rel_auto apply transfer
using vwb_lens.put_eq by fastforce
lemma cond_var_subst_right[urel_cond]:
assumes "vwb_lens x"
shows "(P \<triangleleft>&x \<triangleright> Q\<lbrakk>false/x\<rbrakk>) = (P \<triangleleft>&x \<triangleright> Q)"
using assms
apply pred_auto apply transfer
by (metis (full_types) vwb_lens.put_eq)
lemma cond_var_split[urel_cond]:
"vwb_lens x \<Longrightarrow> (P\<lbrakk>true/x\<rbrakk> \<triangleleft>&x \<triangleright> P\<lbrakk>false/x\<rbrakk>) = P"
by (rel_auto, (metis (full_types) vwb_lens.put_eq)+)
lemma cond_seq_left_distr[urel_comp]:
"out\<alpha> \<sharp> b \<Longrightarrow> ((P \<triangleleft> b \<triangleright> Q) ;; R) = ((P ;; R) \<triangleleft> b \<triangleright> (Q ;; R))"
by rel_auto
lemma cond_seq_right_distr[urel_comp]:
"in\<alpha> \<sharp> b \<Longrightarrow> (P ;; (Q \<triangleleft> b \<triangleright> R)) = ((P ;; Q) \<triangleleft> b \<triangleright> (P ;; R))"
by rel_auto
subsection \<open>Sequential Laws\<close>
text \<open>In this section we introduce the algebraic laws of programming related to the sequential
composition of statements.\<close>
lemma seqr_exists_left[symbolic_exec]:
"((\<exists> $x \<bullet> P) ;; Q) = (\<exists> $x \<bullet> (P ;; Q))"
by rel_auto
lemma seqr_exists_right[symbolic_exec]:
"(P ;; (\<exists> $x\<acute> \<bullet> Q)) = (\<exists> $x\<acute> \<bullet> (P ;; Q))"
by rel_auto
lemma seqr_left_zero [simp, symbolic_exec_ex]:
"false ;; P = false"
by pred_auto
lemma seqr_right_zero [simp, symbolic_exec_ex]:
"P ;; false = false"
by pred_auto
lemma seqr_or_distr[urel_comp]:
"(P ;; (Q \<or> R)) = ((P ;; Q) \<or> (P ;; R))"
by rel_auto
lemma seqr_unfold:
"(P ;; Q) = (\<^bold>\<exists> v \<bullet> P\<lbrakk>\<guillemotleft>v\<guillemotright>/$\<Sigma>\<acute>\<rbrakk> \<and> Q\<lbrakk>\<guillemotleft>v\<guillemotright>/$\<Sigma>\<rbrakk>)"
by rel_auto
lemma seqr_middle:
assumes "vwb_lens x"
shows "(P ;; Q) = (\<^bold>\<exists> v \<bullet> P\<lbrakk>\<guillemotleft>v\<guillemotright>/$x\<acute>\<rbrakk> ;; Q\<lbrakk>\<guillemotleft>v\<guillemotright>/$x\<rbrakk>)"
using assms
apply (rel_auto robust)
apply (rename_tac xa P Q a b y)
apply (rule_tac x="get\<^bsub>xa\<^esub> y" in exI)
apply (rule_tac x="y" in exI)
apply (simp)
done
lemma seqr_left_one_point[urel_comp]:
assumes "vwb_lens x"
shows "((P \<and> $x\<acute> =\<^sub>u \<guillemotleft>v\<guillemotright>) ;; Q) = (P\<lbrakk>\<guillemotleft>v\<guillemotright>/$x\<acute>\<rbrakk> ;; Q\<lbrakk>\<guillemotleft>v\<guillemotright>/$x\<rbrakk>)"
using assms
by (rel_auto, metis vwb_lens_wb wb_lens.get_put)
lemma seqr_right_one_point[urel_comp]:
assumes "vwb_lens x"
shows "(P ;; ($x =\<^sub>u \<guillemotleft>v\<guillemotright> \<and> Q)) = (P\<lbrakk>\<guillemotleft>v\<guillemotright>/$x\<acute>\<rbrakk> ;; Q\<lbrakk>\<guillemotleft>v\<guillemotright>/$x\<rbrakk>)"
using assms
by (rel_auto, metis vwb_lens_wb wb_lens.get_put)
lemma seqr_insert_ident_left[urel_comp]:
assumes "vwb_lens x" "$x\<acute> \<sharp> P" "$x \<sharp> Q"
shows "(($x\<acute> =\<^sub>u $x \<and> P) ;; Q) = (P ;; Q)"
using assms
by (rel_auto, meson vwb_lens_wb wb_lens_weak weak_lens.put_get)
lemma seqr_insert_ident_right[urel_comp]:
assumes "vwb_lens x" "$x\<acute> \<sharp> P" "$x \<sharp> Q"
shows "(P ;; ($x\<acute> =\<^sub>u $x \<and> Q)) = (P ;; Q)"
using assms
by (rel_auto, metis (no_types, hide_lams) vwb_lens_def wb_lens_def weak_lens.put_get)
lemma seq_var_ident_lift[urel_comp]:
assumes "vwb_lens x" "$x\<acute> \<sharp> P" "$x \<sharp> Q"
shows "(($x\<acute> =\<^sub>u $x \<and> P) ;; ($x\<acute> =\<^sub>u $x \<and> Q)) = ($x\<acute> =\<^sub>u $x \<and> (P ;; Q))"
using assms
by (rel_auto, metis (no_types, lifting) vwb_lens_wb wb_lens_weak weak_lens.put_get)
lemma seqr_skip: "II ;; C = C ;; II"
by (metis seqr_left_unit seqr_right_unit)
(*The rules SEQ6 SEQ7 related to SEQ and non-deterministic choice are missing for now*)
subsection \<open>While laws for normal designs\<close>
text \<open>In this section we introduce the algebraic laws of programming related to the while
statement.\<close>
lemma while_gfp_rel_def_alt:
"(while\<^sup>\<top> b do body od) = (\<nu> X \<bullet> bif b then (body ;; X) else SKIP\<^sub>r eif)"
unfolding from_until_gfp_rel_def while_gfp_rel_def
by simp
lemma while_lfp_rel_def_alt:
"(while\<^sub>\<bottom> b do body od) = (\<mu> X \<bullet> bif b then (body ;; X) else SKIP\<^sub>r eif)"
unfolding from_until_lfp_rel_def while_lfp_rel_def
by simp
theorem while_gfp_rel_unfold:
"while\<^sup>\<top> b do body od = (bif b then (body ;; while\<^sup>\<top> b do body od) else SKIP\<^sub>r eif)"
proof -
have m:"mono (\<lambda>X. bif b then (body ;; X) else SKIP\<^sub>r eif)"
by (auto intro: monoI seqr_mono cond_mono)
have "(while\<^sup>\<top> b do body od) = (\<nu> X \<bullet> bif b then (body;; X) else SKIP\<^sub>r eif)"
by (simp add: while_gfp_rel_def_alt)
also have "... = (bif b then (body ;; (\<nu> X \<bullet> bif b then (body ;; X) else SKIP\<^sub>r eif)) else SKIP\<^sub>r eif)"
by (rule lfp_fixpoint[THEN sym, OF m])
also have "... = (bif b then (body ;; while\<^sup>\<top> b do body od) else SKIP\<^sub>r eif)"
by (simp add: while_gfp_rel_def_alt)
finally show ?thesis .
qed
theorem while_lfp_rel_unfold:
"while\<^sub>\<bottom> b do body od = (bif b then (body;; while\<^sub>\<bottom> b do body od) else SKIP\<^sub>r eif)"
proof -
have m:"mono (\<lambda>X. bif b then (body ;; X) else SKIP\<^sub>r eif)"
by (auto intro: monoI seqr_mono cond_mono)
have "(while\<^sub>\<bottom> b do body od) = (\<mu> X \<bullet> bif b then (body ;; X) else SKIP\<^sub>r eif)"
by (simp add: while_lfp_rel_def_alt)
also have "... = (bif b then (body ;; (\<mu> X \<bullet> bif b then (body ;; X) else SKIP\<^sub>r eif)) else SKIP\<^sub>r eif)"
by (rule gfp_fixpoint[THEN sym, OF m])
also have "... = (bif b then (body ;; while\<^sub>\<bottom> b do body od) else SKIP\<^sub>r eif)"
by (simp add: while_lfp_rel_def_alt)
finally show ?thesis .
qed
theorem while_lfp_rel_true:
"while\<^sub>\<bottom> true do body od = (\<mu> X \<bullet> (body;; X))"
by (simp add: while_lfp_rel_def_alt alpha)
lemma while_lfp_rel_false:
"(while\<^sub>\<bottom> false do body od) = SKIP\<^sub>r"
by (simp add: while_lfp_rel_def_alt alpha gfp_const)
theorem while_gfp_rel_false:
"while\<^sup>\<top> false do body od = SKIP\<^sub>r"
by (simp add: while_gfp_rel_def_alt alpha lfp_const)
theorem while_gfp_rel_non_termination: (*because of this lemma and the lemma utp_designs.design_top we do not use gfp for capturing termination *)
"while\<^sup>\<top> true do SKIP\<^sub>r od = false"
unfolding while_gfp_rel_def_alt
proof (rule lfp_eqI[of "(\<lambda>X. bif true then SKIP\<^sub>r ;; X else SKIP\<^sub>r eif)"] , goal_cases)
case 1
then show ?case by (auto intro: monoI seqr_mono cond_mono)
next
case 2
then show ?case by rel_simp
next
case 3
then show ?case by simp
qed
theorem while_lfp_rel_non_termination:
"while\<^sub>\<bottom> true do SKIP\<^sub>r od = true"
unfolding while_lfp_rel_def_alt
proof (rule gfp_eqI[of "(\<lambda>X. bif true then SKIP\<^sub>r ;; X else SKIP\<^sub>r eif)"] , goal_cases)
case 1
then show ?case by (auto intro: monoI seqr_mono cond_mono)
next
case 2
then show ?case by rel_simp
next
case 3
then show ?case by simp
qed
text \<open>An infinite loop with a feasible body corresponds to a program error (non-termination).\<close>
theorem while_infinite:
assumes is_in_abort_situation: "P ;; true\<^sub>h = true"
shows "while\<^sub>\<bottom> true do P od = true"
apply (simp add: while_lfp_rel_true)
apply (rule antisym)
apply (simp)
apply (rule gfp_upperbound)
apply (simp add: assms)
done
subsection \<open>Other Iteration laws for relations\<close>
theorem from_until_gfp_rel_alt_def:
"from\<^sup>\<top> init until exit do body od = init ;; while\<^sup>\<top> \<not> exit do body od"
unfolding while_gfp_rel_def_alt from_until_gfp_rel_def
by simp
lemma from_until_while_gfp_rel:
"from\<^sup>\<top> SKIP\<^sub>r until exit do body od = while\<^sup>\<top> \<not> exit do body od"
unfolding from_until_gfp_rel_alt_def
by simp
theorem from_until_gfp_rel_unfold:
"from\<^sup>\<top> init until exit do body od =
init ;; (bif \<not> exit then (body;; while\<^sup>\<top> \<not> exit do body od) else SKIP\<^sub>r eif)"
unfolding from_until_gfp_rel_alt_def using while_gfp_rel_unfold[of "\<not>exit"]
by simp
theorem from_until_lfp_rel_alt_def:
"from\<^sub>\<bottom> init until exit do body od = init ;; while\<^sub>\<bottom> \<not> exit do body od"
unfolding while_lfp_rel_def_alt from_until_lfp_rel_def
by simp
lemma from_until_while_lfp_rel:
"from\<^sub>\<bottom> SKIP\<^sub>r until exit do body od = while\<^sub>\<bottom> \<not> exit do body od"
unfolding from_until_lfp_rel_alt_def
by simp
theorem from_until_lfp_rel_unfold:
"from\<^sub>\<bottom> init until exit do body od =
init ;; (bif \<not> exit then (body;; while\<^sub>\<bottom> \<not> exit do body od) else SKIP\<^sub>r eif)"
unfolding from_until_lfp_rel_alt_def using while_lfp_rel_unfold[of "\<not>exit"]
by simp
theorem do_while_gfp_rel_alt_def:
"do body while\<^sup>\<top> exit od = body ;; while\<^sup>\<top> exit do body od"
unfolding do_while_gfp_rel_def from_until_gfp_rel_alt_def
by simp
theorem do_while_gfp_rel_unfold:
"do body while\<^sup>\<top> exit od =
body ;; (bif exit then (body;; while\<^sup>\<top> exit do body od) else SKIP\<^sub>r eif)"
unfolding do_while_gfp_rel_alt_def using while_gfp_rel_unfold[of exit]
by simp
theorem do_while_lfp_rel_alt_def:
"do body while\<^sub>\<bottom> exit od = body ;; while\<^sub>\<bottom> exit do body od"
unfolding do_while_lfp_rel_def from_until_lfp_rel_alt_def
by simp
theorem do_while_lfp_rel_unfold:
"do body while\<^sub>\<bottom> exit od =
body ;; (bif exit then (body;; while\<^sub>\<bottom> exit do body od) else SKIP\<^sub>r eif)"
unfolding do_while_lfp_rel_alt_def using while_lfp_rel_unfold[of exit]
by simp
theorem for_gfp_rel_alt_def:
"for\<^sup>\<top> (init, exit, incr) do body od = init ;; while\<^sup>\<top> exit do body;;incr od"
unfolding for_gfp_rel_def from_until_gfp_rel_alt_def
by simp
theorem for_gfp_rel_unfold:
shows "for\<^sup>\<top> (init, exit, incr) do body od =
init ;; (bif exit then (body;;incr;;while\<^sup>\<top> exit do body ;; incr od) else SKIP\<^sub>r eif)"
unfolding for_gfp_rel_alt_def using while_gfp_rel_unfold
by (metis seqr_assoc)
theorem for_lfp_rel_alt_def:
"for\<^sub>\<bottom> (init, exit, incr) do body od = init ;; while\<^sub>\<bottom> exit do body;;incr od"
unfolding for_lfp_rel_def from_until_lfp_rel_alt_def
by simp
theorem for_lfp_rel_unfold:
"for\<^sub>\<bottom> (init, exit, incr) do body od =
init ;; (bif exit then (body;;incr;;while\<^sub>\<bottom> exit do body ;; incr od) else SKIP\<^sub>r eif)"
unfolding for_lfp_rel_alt_def using while_lfp_rel_unfold
by (metis seqr_assoc)
subsection \<open>assume and assert laws\<close>
lemma assume_twice[urel_comp]: "(b\<^sup>\<top> ;; c\<^sup>\<top>) = (b \<and> c)\<^sup>\<top>"
by rel_auto
lemma assert_twice[urel_comp]: "(b\<^sub>\<bottom> ;; c\<^sub>\<bottom>) = (b \<and> c)\<^sub>\<bottom>"
by rel_auto
subsection \<open>Relation algebra laws\<close>
theorem RA1: "(P ;; (Q ;; R)) = ((P ;; Q) ;; R)"
using seqr_assoc by auto
theorem RA2: "(P ;; II) = P" "(II ;; P) = P"
by simp_all
theorem RA3: "P\<^sup>-\<^sup>- = P"
by simp
theorem RA4: "(P ;; Q)\<^sup>- = (Q\<^sup>- ;; P\<^sup>-)"
by simp
theorem RA5: "(P \<or> Q)\<^sup>- = (P\<^sup>- \<or> Q\<^sup>-)"
by (rel_auto)
theorem RA6[urel_comp]: "((P \<or> Q) ;; R) = ((P;;R) \<or> (Q;;R))"
using seqr_or_distl by blast
subsection \<open>Refinement rules\<close>
lemma reverse_impl_refine:
"`Q2 \<Rightarrow> Q1` = (Q1 \<sqsubseteq> Q2)"
by pred_auto
lemma pre_weak_rel:
assumes "`Pre \<Rightarrow> I`"
and "(I \<Rightarrow> Post) \<sqsubseteq> P"
shows "(Pre \<Rightarrow> Post) \<sqsubseteq> P"
using assms
by(rel_auto)
lemma post_str_rel:
"(p\<Rightarrow>q) \<sqsubseteq> P \<Longrightarrow> `q\<Rightarrow>r` \<Longrightarrow> (p\<Rightarrow>r) \<sqsubseteq> P"
by pred_blast
lemma cond_refine_rel:
assumes "(b \<and> p \<Rightarrow> q) \<sqsubseteq> C\<^sub>1" and "(\<not>b \<and> p \<Rightarrow> q)\<sqsubseteq> C\<^sub>2"
shows "(p \<Rightarrow> q) \<sqsubseteq> (C\<^sub>1 \<triangleleft> b \<triangleright> C\<^sub>2)"
using assms by rel_auto
lemma cond_refine_pred:
assumes "(\<lceil>b \<and> p\<rceil>\<^sub><\<Rightarrow> \<lceil>q\<rceil>\<^sub>>) \<sqsubseteq> C\<^sub>1" and "(\<lceil>\<not>b \<and> p\<rceil>\<^sub><\<Rightarrow> \<lceil>q\<rceil>\<^sub>>)\<sqsubseteq> C\<^sub>2"
shows "(\<lceil>p\<rceil>\<^sub>< \<Rightarrow> \<lceil>q\<rceil>\<^sub>>) \<sqsubseteq> (C\<^sub>1 \<triangleleft> \<lceil>b\<rceil>\<^sub>< \<triangleright> C\<^sub>2)"
using assms by rel_auto
lemma seq_refine_pred:
assumes "(\<lceil>p\<rceil>\<^sub>< \<Rightarrow> \<lceil>s\<rceil>\<^sub>>) \<sqsubseteq> f" and "(\<lceil>s\<rceil>\<^sub>< \<Rightarrow> \<lceil>q\<rceil>\<^sub>>) \<sqsubseteq> fa"
shows "(\<lceil>p\<rceil>\<^sub>< \<Rightarrow> \<lceil>q\<rceil>\<^sub>>) \<sqsubseteq> (f ;; fa)"
using assms by rel_auto
lemma seq_refine_unrest:
assumes "out\<alpha> \<sharp> p" "in\<alpha> \<sharp> q"
assumes "(p \<Rightarrow> \<lceil>s\<rceil>\<^sub>>) \<sqsubseteq> f" and "(\<lceil>s\<rceil>\<^sub>< \<Rightarrow> q) \<sqsubseteq> fa"
shows "(p \<Rightarrow> q) \<sqsubseteq> (f ;; fa)"
using assms by rel_blast
lemmas skip_refine' = post_str_rel[OF skip_r_refine_orig]
end
|
# set working directory
setwd("./")
## install packages
# install.packages(c("BiocManager","readr","dplyr", "magrittr","ggplot2","hexbin"),
# lib = "./libraries",
# repos = 'http://cran.us.r-project.org')
# BiocManager::install("tximport", lib = "./libraries")
# BiocManager::install("DESeq2", lib = "./libraries")
# BiocManager::install("RUVSeq", lib = "./libraries")
# BiocManager::install("EDASeq", lib = "./libraries")
# load libraries
library(readr, lib.loc = "./libraries")
library(dplyr, lib.loc = "./libraries/")
library(magrittr, lib.loc = "./libraries")
library(tximport, lib.loc = "./libraries")
library(DESeq2, lib.loc = "./libraries")
library(ggplot2, lib.loc = "./libraries")
library(hexbin, lib.loc = "./libraries")
library(EDASeq, lib.loc = "./libraries")
library(RUVSeq, lib.loc = "./libraries")
# load metadata
sample_table <-read.table("metadata_complete.csv", sep = ",", header = T)
# delete_samples
#sample_table<-rows_delete(sample_table, tibble(Sample.Number = 37))
# load files paths
sample_files = paste0(pull(sample_table , "Sample_file"), "/quant.sf")
# name table columns
names(sample_files) = pull(sample_table, "Sample_file")
# relate genes to transcripts
tx2gene = read.table("txgen2.txt", sep = "\t", col.names =c("genid","transid"))
# import count data to tximport
count_data = tximport( files = sample_files,
type = "salmon",
tx2gene = tx2gene,
ignoreTxVersion = T)
sample_table$Condition <- as.factor((sample_table$Condition))
sample_table$Genotype <- as.factor((sample_table$Genotype))
sample_table$DevStage <- as.factor((sample_table$DevStage))
sample_table$Individual <- as.factor((sample_table$Individual))
raw <- DESeqDataSetFromTximport(txi = count_data,
colData = sample_table,
design = ~ Condition)
data <- estimateSizeFactors(raw)
vst <- varianceStabilizingTransformation(data)
rld <- rlog(data, blind = FALSE)
### pca vst
pca_vst <- plotPCA(vst, intgroup ='Condition') +
theme_bw() +
geom_point(size=4.5, aes(colour = Condition, shape = vst$Genotype))+
labs(title = "VST", col="Condition", shape="Genotype")+
theme( text = element_text(size=22),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(hjust = 0.5),
axis.line = element_line(colour = "black") )
ggsave( pca_vst, filename = "./PCA_VST.png",units = "cm",width = 20*1.3, height = 20,dpi = 320)
#### pcs rld
pca_rld <- plotPCA(rld, intgroup ='Condition') +
geom_point(size=4.5, aes(colour = Condition, shape = rld$Genotype))+
labs(title = "RLD", col="Condition", shape="Genotype")+
theme_bw() +
theme( text = element_text(size=22),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(hjust = 0.5),
axis.line = element_line(colour = "black") )
pca_rld
ggsave( pca_rld, filename = "./PCA_nrld.png",units = "cm",width = 20*1.3, height = 20,dpi = 320)
#### RUV
differences <- makeGroups(sample_table$Condition)
genes <- row.names(count_data$counts)
setRUV <- RUVs(as.matrix(assay(raw)), genes, k=1, differences)
dataRUV <- DESeqDataSetFromMatrix(countData = setRUV$normalizedCounts,
colData = sample_table,
design = ~ Condition)
dataRUV <- estimateSizeFactors(dataRUV)
ruv_vst <- varianceStabilizingTransformation(dataRUV)
ruv_rld <- rlog(dataRUV, blind = FALSE)
# PCA RUV VST
pca_ruv_vst <- plotPCA(ruv_vst, intgroup ='Condition') +
theme_bw() +
geom_point(size=4.5, aes(colour = Condition, shape = ruv_vst$Genotype))+
labs(title = "PCA RUV CONDITION VST", col="Condition", shape="Genotype")+
theme( text = element_text(size=22),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(hjust = 0.5),
axis.line = element_line(colour = "black") )
pca_ruv_vst
ggsave( pca_ruv_vst, filename = "./PCA_RUV-CONDITION-VST.png",units = "cm",width = 20*1.3, height = 20,dpi = 320)
# PCA RUV RLD
pca_ruv_rld <- plotPCA(ruv_rld, intgroup ='Condition') +
theme_bw() +
geom_point(size=4.5, aes(colour = Condition, shape = ruv_rld$Genotype))+
labs(title = "RUV CONDITION RLD", col="Condition", shape="Genotype")+
theme( text = element_text(size=22),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(hjust = 0.5),
axis.line = element_line(colour = "black") )
ggsave( pca_ruv_rld, filename = "./PCA_RUV-CONDITION_RLD.png",units = "cm",width = 20*1.3, height = 20,dpi = 320)
## RUV GENOTYPE
differences <- makeGroups(sample_table$Genotype)
genes <- row.names(count_data$counts)
setRUV <- RUVs(as.matrix(assay(raw)), genes, k=1, differences)
dataRUV <- DESeqDataSetFromMatrix(countData = setRUV$normalizedCounts,
colData = sample_table,
design = ~ Condition)
dataRUV <- estimateSizeFactors(dataRUV)
ruv_vst <- varianceStabilizingTransformation(dataRUV)
ruv_rld <- rlog(dataRUV, blind = FALSE)
# PCA RUV RLD GENOTYPE
pca_ruv_rld <- plotPCA(ruv_rld, intgroup ='Condition') +
theme_bw() +
geom_point(size=4.5, aes(colour = Condition, shape = ruv_rld$Genotype))+
labs(title = "ruv rld", col="Condition", shape="Genotype")+
theme( text = element_text(size=22),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(hjust = 0.5),
axis.line = element_line(colour = "black") )
ggsave( pca_ruv_rld, filename = "./PCA_RUV_RLD-GENOTYPE.png",units = "cm",width = 20*1.3, height = 20,dpi = 320)
# PCA RUV VST GENOTYPE
pca_ruv_vst <- plotPCA(ruv_vst, intgroup ='Condition') +
theme_bw() +
geom_point(size=4.5, aes(colour = Condition, shape = ruv_vst$Genotype))+
labs(title = "PCA RUV~CONDITION VST", col="Condition", shape="Genotype")+
theme( text = element_text(size=22),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(hjust = 0.5),
axis.line = element_line(colour = "black") )
ggsave( pca_ruv_vst, filename = "./PCA_RUV-VST-GENOTYPE.png",units = "cm",width = 20*1.3, height = 20,dpi = 320)
|
{-# OPTIONS --copatterns #-}
-- {-# OPTIONS -v tc.lhs.split:50 -v tc.cover:20 -v tc.cc:15 -v tc.lhs.top:10 #-}
-- {-# OPTIONS -v term:20 #-}
-- {-# OPTIONS --no-positivity-check #-}
-- {-# OPTIONS -v tc.def.fun:50 #-}
-- {-# OPTIONS -v 100 #-}
module CoPatStream where
import Common.Level
open import Common.Prelude hiding (map)
open import Common.Equality
record Stream (A : Set) : Set where
coinductive
constructor cons
field
head : A
tail : Stream A
module S = Stream
record _≈_ {A : Set}(s t : Stream A) : Set where
coinductive
field
head : S.head s ≡ S.head t
tail : S.tail s ≈ S.tail t
module B = _≈_
repeat : {A : Set}(a : A) → Stream A
-- repeat a = cons a (repeat a)
S.head (repeat a) = a
S.tail (repeat a) = repeat a
module Cycle where
cycle : Nat -> Stream Nat
cycle n = cycle' n where
cycle' : Nat -> Stream Nat
S.head (cycle' n) = n
S.tail (cycle' zero ) = cycle n
S.tail (cycle' (suc n')) = cycle' n'
module CoPat where
map : {A B : Set} → (A → B) → Stream A → Stream B
S.head (map f s) = f (S.head s)
S.tail (map f s) = map f (S.tail s)
map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s
B.head (map_id s) = refl
B.tail (map_id s) = map_id (S.tail s)
module HandTranslated where
{-# NON_TERMINATING #-}
map : {A B : Set} → (A → B) → Stream A → Stream B
map f s = record
{ head = f (S.head s)
; tail = map f (S.tail s)
}
{- rejected because map is not unfolded
{-# NON_TERMINATING #-}
map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s
map_id s = record
{ head = refl
; tail = map_id (S.tail s)
}
-}
module DeepCoPat where
repeat₂ : {A : Set}(a₁ a₂ : A) → Stream A
( (S.head (repeat₂ a₁ a₂))) = a₁
(S.head (S.tail (repeat₂ a₁ a₂))) = a₂
(S.tail (S.tail (repeat₂ a₁ a₂))) = repeat₂ a₁ a₂
repeat≈repeat₂ : {A : Set}(a : A) → repeat a ≈ repeat₂ a a
( (B.head (repeat≈repeat₂ a))) = refl
(B.head (B.tail (repeat≈repeat₂ a))) = refl
(B.tail (B.tail (repeat≈repeat₂ a))) = repeat≈repeat₂ a
module ProjectionRHS where
repeat′ : {A : Set}(a : A) → Stream A
( (S.head (repeat′ a))) = a
(S.head (S.tail (repeat′ a))) = a
(S.tail (S.tail (repeat′ a))) = S.tail (repeat′ a)
-- -- Type error:
-- repeat≈repeat′ : {A : Set}(a : A) → repeat a ≈ repeat′ a
-- ( (B.head (repeat≈repeat′ a))) = refl
-- (B.head (B.tail (repeat≈repeat′ a))) = refl
-- (B.tail (B.tail (repeat≈repeat′ a))) = repeat≈repeat′ a
|
## Used to write data out to files for cuIF2
writedata <- function(data, neinum, neibmat, outdir, thread) {
datafile <- paste(outdir, "/", "data-", thread, ".txt", sep = "")
write(format(t(data), scientific = FALSE), file = datafile, ncolumns = dim(data)[2])
neinumfile <- paste(outdir, "/", "neinum-", thread, ".txt", sep = "")
write(neinum, file = neinumfile, ncolumns = 1)
neibmatfile <- paste(outdir, "/", "neibmat-", thread, ".txt", sep = "")
write(t(neibmat), file = neibmatfile, ncolumns = dim(neibmat)[2])
} |
Formal statement is: lemma degree_primitive_part [simp]: "degree (primitive_part p) = degree p" Informal statement is: The degree of the primitive part of a polynomial is the same as the degree of the polynomial. |
\documentclass[10pt,a4paper]{article}
\usepackage[british]{babel}
\usepackage[utf8]{inputenc}
\title{Bluetooth Low Energy}
\begin{document}
\maketitle
\section{Indoor positioning}
Nowadays we find BLE indoor positioning applications based in beacons \cite{WOS:000363238300013, WOS:000371717205060}, and are applied to museums \cite{WOS:000380412500076}, offices \cite{WOS:000449004400022}, and otheres. Some other research works perform an analysis of the positioning accuracy \cite{WOS:000380396600019, WOS:000426343700039, WOS:000403647100020}, and user experiences \cite{WOS:000390296600023}.
\section{Beacons}
Bluetooth Low Energy Beacons applications include proximity detection \cite{WOS:000376613200033}, Secure Location Sensing in Healthcare \cite{WOS:000433385100006}, mobile crowd sensing \cite{WOS:000426978700312}, Patient Queuing Solution \cite{WOS:000458534800043}, and smart campus \cite{WOS:000403973600278}.
\bibliographystyle{unsrt}
\bibliography{bibliography}
\end{document} |
{-# OPTIONS --without-K #-}
module #1 where
open import Relation.Binary.PropositionalEquality
{-
Exercise 2.1. Show that the three obvious proofs of Lemma 2.1.2 are pairwise equal.
-}
ind₌ : ∀{a b}{A : Set a} → (C : (x y : A) → (x ≡ y) → Set b) → ((x : A) → C x x refl) → {x y : A} → (p : x ≡ y) → C x y p
ind₌ C c {x}{y} p rewrite p = c y
composite : ∀ {i} {A : Set i}{x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
composite {i} {A} {_}{_}{z} p = ind₌ D d p where
D : (x y : A) → (p : x ≡ y) → Set i
D x y _ = y ≡ z → x ≡ z
d : (x₁ : A) → D x₁ x₁ refl
d _ = λ x → x
composite' : ∀ {i} {A : Set i}{x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
composite' {i} {A} {_}{_}{z} = ind₌ D d where
D : (x y : A) → (p : x ≡ y) → Set i
D x y _ = y ≡ z → x ≡ z
d : (x : A) → D x x refl
d x = ind₌ E e where
E : (x z : A) → (q : x ≡ z) → Set i
E x z _ = x ≡ z
e : (x : A) → E x x refl
e x = refl
composite'' : ∀ {i} {A : Set i}{x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
composite'' refl refl = refl
composite=composite' : ∀ {i} {A : Set i}{x y z : A} → (p : x ≡ y)(q : y ≡ z) → composite p q ≡ composite' p q
composite=composite' refl refl = refl
composite=composite'' : ∀ {i} {A : Set i}{x y z : A} → (p : x ≡ y)(q : y ≡ z) → composite p q ≡ composite'' p q
composite=composite'' refl refl = refl
composite'=composite'' : ∀ {i} {A : Set i}{x y z : A} → (p : x ≡ y)(q : y ≡ z) → composite' p q ≡ composite'' p q
composite'=composite'' refl refl = refl
|
State Before: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
⊢ IsPathConnected s State After: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
⊢ ∀ (x : E), x ∈ s → ∀ (y : E), y ∈ s → JoinedIn s x y Tactic: refine' isPathConnected_iff.mpr ⟨hne, _⟩ State Before: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
⊢ ∀ (x : E), x ∈ s → ∀ (y : E), y ∈ s → JoinedIn s x y State After: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
x : E
x_in : x ∈ s
y : E
y_in : y ∈ s
⊢ JoinedIn s x y Tactic: intro x x_in y y_in State Before: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
x : E
x_in : x ∈ s
y : E
y_in : y ∈ s
⊢ JoinedIn s x y State After: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
x : E
x_in : x ∈ s
y : E
y_in : y ∈ s
H : [x-[ℝ]y] ⊆ s
⊢ JoinedIn s x y Tactic: have H := hconv.segment_subset x_in y_in State Before: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
x : E
x_in : x ∈ s
y : E
y_in : y ∈ s
H : [x-[ℝ]y] ⊆ s
⊢ JoinedIn s x y State After: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
x : E
x_in : x ∈ s
y : E
y_in : y ∈ s
H : ↑(lineMap x y) '' Icc 0 1 ⊆ s
⊢ JoinedIn s x y Tactic: rw [segment_eq_image_lineMap] at H State Before: ι : Type ?u.191359
𝕜 : Type ?u.191362
E : Type u_1
inst✝⁴ : AddCommGroup E
inst✝³ : Module ℝ E
inst✝² : TopologicalSpace E
inst✝¹ : TopologicalAddGroup E
inst✝ : ContinuousSMul ℝ E
s : Set E
hconv : Convex ℝ s
hne : Set.Nonempty s
x : E
x_in : x ∈ s
y : E
y_in : y ∈ s
H : ↑(lineMap x y) '' Icc 0 1 ⊆ s
⊢ JoinedIn s x y State After: no goals Tactic: exact
JoinedIn.ofLine AffineMap.lineMap_continuous.continuousOn (lineMap_apply_zero _ _)
(lineMap_apply_one _ _) H |
module Text.Parse (Tok : Set) where
open import Prelude
private
data P′ (A : Set) : Set where
symbolBind : (Tok → P′ A) → P′ A
fail′ : P′ A
returnPlus : A → P′ A → P′ A
_+++′_ : ∀ {A} → P′ A → P′ A → P′ A
symbolBind f +++′ symbolBind g = symbolBind λ x → f x +++′ g x
fail′ +++′ q = q
p +++′ fail′ = p
returnPlus x p +++′ q = returnPlus x (p +++′ q)
p +++′ returnPlus x q = returnPlus x (p +++′ q)
parse′ : ∀ {A} → P′ A → List Tok → List (A × List Tok)
parse′ (symbolBind _) [] = []
parse′ (symbolBind f) (c ∷ s) = parse′ (f c) s
parse′ (returnPlus x p) s = (x , s) ∷ parse′ p s
parse′ fail′ xs = []
record P (A : Set) : Set₁ where
constructor mkP
field
unP : ∀ {B} → (A → P′ B) → P′ B
open P
symbol : P Tok
symbol = mkP symbolBind
fail : ∀ {A} → P A
fail = mkP λ _ → fail′
infixr 2 _+++_
_+++_ : ∀ {A} → P A → P A → P A
p +++ q = mkP λ k → unP p k +++′ unP q k
private
ret : ∀ {A} → A → P A
ret x = mkP λ k → k x
bind : ∀ {A B} → P A → (A → P B) → P B
bind p f = mkP λ k → unP p (λ x → unP (f x) k)
parse : ∀ {A} → P A → List Tok → List (A × List Tok)
parse p = parse′ (unP p (λ x → returnPlus x fail′))
parse! : ∀ {A} → P A → List Tok → Maybe A
parse! p s with filter (null ∘ snd) (parse p s)
... | [] = nothing
... | (x , _) ∷ _ = just x
--- Instances ---
instance
FunctorP : Functor P
fmap {{FunctorP}} f m = bind m λ x → ret (f x)
ApplicativeP : Applicative P
pure {{ApplicativeP}} = ret
_<*>_ {{ApplicativeP}} = monadAp bind
MonadP : Monad P
_>>=_ {{MonadP}} = bind
MonoidP : ∀ {A} → Monoid (P A)
mempty {{MonoidP}} = fail
_<>_ {{MonoidP}} = _+++_
--- Derived combinators ---
sat : (p : Tok → Bool) → P (Σ Tok (IsTrue ∘ p))
sat p = symbol >>= match
where
-- Inlining 'match' gives internal error!
match : Tok → P (Σ Tok (IsTrue ∘ p))
match t = if′ p t then return (t , it) else fail
sat! : (Tok → Bool) → P Tok
sat! p = fst <$> sat p
token : {{EqTok : Eq Tok}} → Tok → P ⊤
token t = _ <$ sat (isYes ∘ _==_ t)
{-# NON_TERMINATING #-}
many many₁ : ∀ {A} → P A → P (List A)
many p = return [] +++ many₁ p
many₁ p = _∷_ <$> p <*> many p
|
\chapter{Introduction}
WEC-Sim (Wave Energy Converter SIMulator) is an open source wave energy converter (WEC) simulation tool. The code is developed in MATLAB and Simulink using the multibody dynamics solver SimMechanics. WEC-Sim has the ability to model devices that are comprised of rigid bodies, power-take-off (PTO) systems, and mooring systems. Hydrodynamic forces are modeled using a radiation and diffarction method, and the system dynamics is performed in the time domain by solving the governing WEC equations of motion in 6 degrees of freedom (DOF).
In this user manual, the theory of WEC-Sim is described in \hyperlink{chapter.2}{Chapter 2}. The installation of MATLAB and WEC-Sim and how to run WEC-Sim is described in \hyperlink{chapter.3}{Chapter 3}. The pre-developed WEC component library structure is presented in \hyperlink{chapter.4}{Chapter 4}. The code WEC-Sim structure and the input parameters for running WEC-Sim are described in \hyperlink{chapter.5}{Chapter 5}. Finally, the application of WEC-Sim to model a point absorber and a oscillating surge device is presented in \hyperlink{chapter.6}{Chapter 6}. |
!
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 Guido Dhondt
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation(version 2);
!
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
subroutine mechmodel(elconloc,elas,emec,kode,emec0,ithermal,
& icmd,beta,stre,xkl,ckl,vj,xikl,vij,plconloc,xstate,xstateini,
& ielas,amat,t1l,dtime,time,ttime,iel,iint,nstate_,mi,
& iorien,pgauss,orab,eloc,mattyp,pnewdt,istep,iinc,ipkon,
& nmethod,iperturb)
!
! kode=-1: Arruda-Boyce
! -2: Mooney-Rivlin
! -3: Neo-Hooke
! -4: Ogden (N=1)
! -5: Ogden (N=2)
! -6: Ogden (N=3)
! -7: Polynomial (N=1)
! -8: Polynomial (N=2)
! -9: Polynomial (N=3)
! -10: Reduced Polynomial (N=1)
! -11: Reduced Polynomial (N=2)
! -12: Reduced Polynomial (N=3)
! -13: Van der Waals (not implemented yet)
! -14: Yeoh
! -15: Hyperfoam (N=1)
! -16: Hyperfoam (N=2)
! -17: Hyperfoam (N=3)
! -50: deformation plasticity
! -51: incremental plasticity (no viscosity)
! -52: viscoplasticity
! < -100: user material routine with -kode-100 user
! defined constants with keyword *USER MATERIAL
!
implicit none
!
character*80 amat
!
integer kode,ithermal,icmd,ielas,iel,iint,nstate_,mi(*),iorien,
& mattyp,istep,iinc,ipkon(*),nmethod,iperturb(*)
!
real*8 elconloc(*),elas(21),emec(*),emec0(*),beta(*),stre(*),
& ckl(*),vj,plconloc(*),t1l,xkl(*),xikl(*),vij,
& dtime,didc(27),d2idc2(243),dibdc(27),d2ibdc2(243),
& dudc(9),d2udc2(81),dldc(27),d2ldc2(243),dlbdc(27),d2lbdc2(243),
& pgauss(3),orab(7,*),time,ttime,eloc(6),pnewdt
!
real*8 xstate(nstate_,mi(1),*),xstateini(nstate_,mi(1),*)
!
if(kode.gt.0) then
call linel(kode,mattyp,beta,emec,stre,elas,elconloc,
& iorien,orab,pgauss)
elseif(kode.gt.-50) then
mattyp=3
call rubber(elconloc,elas,emec,kode,didc,d2idc2,
& dibdc,d2ibdc2,dudc,d2udc2,dldc,d2ldc2,dlbdc,d2lbdc2,
& ithermal,icmd,beta,stre)
elseif(kode.eq.-50) then
mattyp=3
call defplas(elconloc,elas,emec,ithermal,icmd,beta,stre,
& ckl,vj)
elseif(kode.gt.-100) then
mattyp=3
if(iperturb(2).eq.1) then
call incplas(elconloc,plconloc,xstate,xstateini,elas,emec,
& ithermal,icmd,beta,stre,vj,kode,ielas,amat,t1l,dtime,
& time,ttime,iel,iint,nstate_,mi(1),eloc,pgauss,nmethod,
& pnewdt)
else
call incplas_lin(elconloc,plconloc,xstate,xstateini,elas,
& emec,
& ithermal,icmd,beta,stre,vj,kode,ielas,amat,t1l,dtime,
& time,ttime,iel,iint,nstate_,mi(1),eloc,pgauss,nmethod,
& pnewdt)
endif
else
mattyp=3
call umat_main(amat,iel,iint,kode,elconloc,emec,emec0,beta,
& xikl,vij,xkl,vj,ithermal,t1l,dtime,time,ttime,icmd,ielas,
& mi(1),nstate_,xstateini,xstate,stre,elas,iorien,pgauss,
& orab,pnewdt,istep,iinc,ipkon,nmethod,iperturb)
endif
!
return
end
|
State Before: n : ℕ
α : Type u_1
v : Vector α n
⊢ reverse (reverse v) = v State After: case mk
n : ℕ
α : Type u_1
val✝ : List α
property✝ : List.length val✝ = n
⊢ reverse (reverse { val := val✝, property := property✝ }) = { val := val✝, property := property✝ } Tactic: cases v State Before: case mk
n : ℕ
α : Type u_1
val✝ : List α
property✝ : List.length val✝ = n
⊢ reverse (reverse { val := val✝, property := property✝ }) = { val := val✝, property := property✝ } State After: no goals Tactic: simp [Vector.reverse] |
[STATEMENT]
lemma KBasic_4[PLM]:
"[\<^bold>\<box>(\<phi> \<^bold>\<equiv> \<psi>) \<^bold>\<equiv> (\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>)) in v]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. [\<^bold>\<box>(\<phi> \<^bold>\<equiv> \<psi>) \<^bold>\<equiv> \<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) in v]
[PROOF STEP]
apply (rule "\<^bold>\<equiv>I")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. [\<^bold>\<box>(\<phi> \<^bold>\<equiv> \<psi>) \<^bold>\<rightarrow> \<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) in v]
2. [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) \<^bold>\<rightarrow> \<^bold>\<box>(\<phi> \<^bold>\<equiv> \<psi>) in v]
[PROOF STEP]
unfolding equiv_def
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. [\<^bold>\<box>((\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& (\<psi> \<^bold>\<rightarrow> \<phi>)) \<^bold>\<rightarrow> \<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) in v]
2. [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) \<^bold>\<rightarrow> \<^bold>\<box>((\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& (\<psi> \<^bold>\<rightarrow> \<phi>)) in v]
[PROOF STEP]
using KBasic_3 PLM.CP "\<^bold>\<equiv>E"(1)
[PROOF STATE]
proof (prove)
using this:
[\<^bold>\<box>(?\<phi> \<^bold>& ?\<psi>) \<^bold>\<equiv> \<^bold>\<box>?\<phi> \<^bold>& \<^bold>\<box>?\<psi> in ?v]
([?\<phi> in ?v] \<Longrightarrow> [?\<psi> in ?v]) \<Longrightarrow> [?\<phi> \<^bold>\<rightarrow> ?\<psi> in ?v]
\<lbrakk>[?\<phi> \<^bold>\<equiv> ?\<psi> in ?v]; [?\<phi> in ?v]\<rbrakk> \<Longrightarrow> [?\<psi> in ?v]
goal (2 subgoals):
1. [\<^bold>\<box>((\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& (\<psi> \<^bold>\<rightarrow> \<phi>)) \<^bold>\<rightarrow> \<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) in v]
2. [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) \<^bold>\<rightarrow> \<^bold>\<box>((\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& (\<psi> \<^bold>\<rightarrow> \<phi>)) in v]
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) \<^bold>\<rightarrow> \<^bold>\<box>((\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& (\<psi> \<^bold>\<rightarrow> \<phi>)) in v]
[PROOF STEP]
using KBasic_3 PLM.CP "\<^bold>\<equiv>E"(2)
[PROOF STATE]
proof (prove)
using this:
[\<^bold>\<box>(?\<phi> \<^bold>& ?\<psi>) \<^bold>\<equiv> \<^bold>\<box>?\<phi> \<^bold>& \<^bold>\<box>?\<psi> in ?v]
([?\<phi> in ?v] \<Longrightarrow> [?\<psi> in ?v]) \<Longrightarrow> [?\<phi> \<^bold>\<rightarrow> ?\<psi> in ?v]
\<lbrakk>[?\<phi> \<^bold>\<equiv> ?\<psi> in ?v]; [?\<psi> in ?v]\<rbrakk> \<Longrightarrow> [?\<phi> in ?v]
goal (1 subgoal):
1. [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& \<^bold>\<box>(\<psi> \<^bold>\<rightarrow> \<phi>) \<^bold>\<rightarrow> \<^bold>\<box>((\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>& (\<psi> \<^bold>\<rightarrow> \<phi>)) in v]
[PROOF STEP]
by blast |
module HELICS
__precompile__(true)
import Libdl
# Module initialization function
function __init__()
atexit(helicsCloseLibrary)
end
module Lib
using CEnum
using HELICS_jll
const HELICS_EXPORT = nothing
const HELICS_NO_EXPORT = nothing
include("ctypes.jl")
include("common.jl")
include("lib.jl")
end
include("wrapper.jl")
include("utils.jl")
include("enums.jl")
include("api.jl")
const HELICS_LIBRARY_VERSION = VersionNumber(split(helicsGetVersion())[1])
const HELICS_PACKAGE_VERSION = VersionNumber(match(r"version\s*=\s*\"(.+)\"", read(joinpath(@__DIR__, "..", "Project.toml"), String)).captures[1])
end # module
|
<a href="https://colab.research.google.com/github/AmanPriyanshu/Spiking-Neural-Networks/blob/main/spike_basics.ipynb" target="_parent"></a>
# Spiking Neural Networks - 1:
The difference between an ordinary artificial neural network (ANN) and SNN is that, a SNN's neuron only activates/spikes upon crossing a threshold value. The most common model for simulating or exhibiting such spikes are integerate&fire or leaky integerate&fire. More powerful than traditional machine learning techniques, it is rare to see such powerful implementation not widespread in the booming ML/AI world. However, an important reason for such an effect, is the inability to differentiate such spiking or binary functions. In essence, it is our incapacity to train in a supervised fashion such a model with efficient learning progress. Therefore, it has seen rare use cases, and can only be trained using unsupervised learning methods.
## Installation:
`pip install brian2`
```
!pip install brian2
```
Requirement already satisfied: brian2 in /usr/local/lib/python3.7/dist-packages (2.4.2)
Requirement already satisfied: cython>=0.29 in /usr/local/lib/python3.7/dist-packages (from brian2) (0.29.22)
Requirement already satisfied: setuptools>=24.2 in /usr/local/lib/python3.7/dist-packages (from brian2) (54.0.0)
Requirement already satisfied: pyparsing in /usr/local/lib/python3.7/dist-packages (from brian2) (2.4.7)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib/python3.7/dist-packages (from brian2) (1.19.5)
Requirement already satisfied: sympy>=1.2 in /usr/local/lib/python3.7/dist-packages (from brian2) (1.7.1)
Requirement already satisfied: jinja2>=2.7 in /usr/local/lib/python3.7/dist-packages (from brian2) (2.11.3)
Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.7/dist-packages (from sympy>=1.2->brian2) (1.2.1)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.7/dist-packages (from jinja2>=2.7->brian2) (1.1.1)
## Imports:
```
from brian2 import *
import matplotlib.pyplot as plt
%matplotlib inline
```
## Units:
```
20*volt
```
$20.0\,\mathrm{V}$
```
20*amp
```
$20.0\,\mathrm{A}$
```
1000*namp
```
$1.0\,\mathrm{\mu}\,\mathrm{A}$
```
10*nA
```
$10.0\,\mathrm{n}\,\mathrm{A}$
```
(10*nA)*(5*mohm)
```
$50.0\,\mathrm{p}\,\mathrm{V}$
```
5*ohm
```
$5.0\,\mathrm{ohm}$
## Defining a Neuron:
```
tau = 10*ms
eqs = '''
dv/dt = (1-v)/tau : 1
'''
```
```
G = NeuronGroup(1, eqs)
G
```
NeuronGroup "neurongroup" with 1 neurons.<br>
<b>Model:</b><nr>
\begin{align*}\mathtt{\text{\textbackslashfrac\{\textbackslashmathrm\{d\}v\}\{\textbackslashmathrm\{d\}t\}}} &= \frac{1 - v}{\tau} && \text{(unit of $v$: $\mathrm{rad}$)}\end{align*}
### Running a simulation:
```
start_scope()
tau = 10*ms
eqs = '''
dv/dt = (1-v)/tau : 1
'''
G = NeuronGroup(1, eqs)
run(100*ms)
```
INFO No numerical integration method specified for group 'neurongroup_1', using method 'exact' (took 0.03s). [brian2.stateupdaters.base.method_choice]
```
start_scope()
G = NeuronGroup(1, eqs, method='exact')
print('Before v = %s' % G.v[0])
run(100*ms)
print('After v = %s' % G.v[0])
```
Before v = 0.0
After v = 0.9999546000702376
As, tau = 10ms and run limit = 100ms, therefore, t = \[0ms, 100ms\].
Now, looking at our differential equation,
```
dv/dt = (1-v)/tau
```
thus, v = 1 - e^(-t/tau).
Going through with the limits at the two ends, we get v=0 @ t=0 and v=~1 @ t=100ms
```
print('Expected value of v = %s' % (1-exp(-100*ms/tau)))
```
Expected value of v = 0.9999546000702375
## Plotting our simulation:
```
start_scope()
G = NeuronGroup(1, eqs, method='exact')
M = StateMonitor(G, 'v', record=True)
run(30*ms)
plot(M.t/ms, M.v[0])
xlabel('Time (ms)')
ylabel('v');
```
### Theoretical v/s Simulations:
```
start_scope()
G = NeuronGroup(1, eqs, method='exact')
M = StateMonitor(G, 'v', record=0)
run(30*ms)
plot(M.t/ms, M.v[0], 'C0', label='Brian')
plot(M.t/ms, 1-exp(-M.t/tau), 'C1--',label='Analytic')
xlabel('Time (ms)')
ylabel('v')
legend();
```
## Simulation 2:
```
start_scope()
tau = 10*ms
eqs = '''
dv/dt = (sin(2*pi*100*Hz*t)-v)/tau : 1
'''
G = NeuronGroup(1, eqs, method='euler')
M = StateMonitor(G, 'v', record=0)
G.v = 5 # initial value
run(60*ms)
plot(M.t/ms, M.v[0])
xlabel('Time (ms)')
ylabel('v');
```
## Simulation 3: Spikes
```
start_scope()
tau = 10*ms
eqs = '''
dv/dt = (1-v)/tau : 1
'''
G = NeuronGroup(1, eqs, threshold='v>0.8', reset='v = 0', method='exact')
M = StateMonitor(G, 'v', record=0)
run(50*ms)
plot(M.t/ms, M.v[0])
xlabel('Time (ms)')
ylabel('v');
```
```
start_scope()
G = NeuronGroup(1, eqs, threshold='v>0.8', reset='v = 0', method='exact')
spikemon = SpikeMonitor(G)
run(50*ms)
print('Spike times: %s' % spikemon.t[:])
```
Spike times: [16. 32.1 48.2] ms
```
start_scope()
G = NeuronGroup(1, eqs, threshold='v>0.8', reset='v = 0', method='exact')
statemon = StateMonitor(G, 'v', record=0)
spikemon = SpikeMonitor(G)
run(50*ms)
plot(statemon.t/ms, statemon.v[0])
for t in spikemon.t:
axvline(t/ms, ls='--', c='C1', lw=3)
xlabel('Time (ms)')
ylabel('v');
```
## Refractory:
This means that after the neuron fires a spike it becomes refractory for a certain duration and cannot fire another spike until this period is over.
```
start_scope()
tau = 10*ms
eqs = '''
dv/dt = (1-v)/tau : 1 (unless refractory)
'''
G = NeuronGroup(1, eqs, threshold='v>0.8', reset='v = 0', refractory=5*ms, method='exact')
statemon = StateMonitor(G, 'v', record=0)
spikemon = SpikeMonitor(G)
run(50*ms)
plot(statemon.t/ms, statemon.v[0])
for t in spikemon.t:
axvline(t/ms, ls='--', c='C1', lw=3)
xlabel('Time (ms)')
ylabel('v');
```
```
start_scope()
tau = 5*ms
eqs = '''
dv/dt = (1-v)/tau : 1
'''
G = NeuronGroup(1, eqs, threshold='v>0.8', reset='v = 0', refractory=15*ms, method='exact')
statemon = StateMonitor(G, 'v', record=0)
spikemon = SpikeMonitor(G)
run(50*ms)
plot(statemon.t/ms, statemon.v[0])
for t in spikemon.t:
axvline(t/ms, ls='--', c='C1', lw=3)
axhline(0.8, ls=':', c='C2', lw=3)
xlabel('Time (ms)')
ylabel('v')
print("Spike times: %s" % spikemon.t[:])
```
```
start_scope()
tau = 5*ms
eqs = '''
dv/dt = (1-v)/tau : 1
'''
G = NeuronGroup(1, eqs, threshold='v>0.8', reset='v = 0', refractory=5*ms, method='exact')
statemon = StateMonitor(G, 'v', record=0)
spikemon = SpikeMonitor(G)
run(50*ms)
plot(spikemon.t/ms, spikemon.i, '.k')
xlim([0, 50])
xlabel('Time (ms)')
ylabel('Neuron Spikes');
```
### Multiple Neurons
```
start_scope()
N = 100
tau = 10*ms
eqs = '''
dv/dt = (2-v)/tau : 1
'''
G = NeuronGroup(N, eqs, threshold='v>1', reset='v=0', method='exact')
G.v = 'rand()'
spikemon = SpikeMonitor(G)
run(50*ms)
plot(spikemon.t/ms, spikemon.i, '.k')
xlabel('Time (ms)')
ylabel('Neuron index');
```
```
start_scope()
N = 100
tau = 10*ms
v0_max = 3.
duration = 1000*ms
eqs = '''
dv/dt = (v0-v)/tau : 1 (unless refractory)
v0 : 1
'''
G = NeuronGroup(N, eqs, threshold='v>1', reset='v=0', refractory=5*ms, method='exact')
M = SpikeMonitor(G)
G.v0 = 'i*v0_max/(N-1)'
run(duration)
figure(figsize=(12,4))
subplot(121)
plot(M.t/ms, M.i, '.k')
xlabel('Time (ms)')
ylabel('Neuron index')
subplot(122)
plot(G.v0, M.count/duration)
xlabel('v0')
ylabel('Firing rate (sp/s)');
```
## Modelling Noise:
by introducing xi
```
start_scope()
N = 100
tau = 10*ms
v0_max = 3.
duration = 1000*ms
sigma = 0.2
eqs = '''
dv/dt = (v0-v)/tau+sigma*xi*tau**-0.5 : 1 (unless refractory)
v0 : 1
'''
G = NeuronGroup(N, eqs, threshold='v>1', reset='v=0', refractory=5*ms, method='euler')
M = SpikeMonitor(G)
G.v0 = 'i*v0_max/(N-1)'
run(duration)
figure(figsize=(12,4))
subplot(121)
plot(M.t/ms, M.i, '.k')
xlabel('Time (ms)')
ylabel('Neuron index')
subplot(122)
plot(G.v0, M.count/duration)
xlabel('v0')
ylabel('Firing rate (sp/s)');
```
```
```
|
[STATEMENT]
lemma morgan: \<open>A \<turnstile> .\<not> (p .\<and>. q) \<longleftrightarrow> A \<turnstile> (.\<not> p) .\<or>. (.\<not> q)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (A \<turnstile> .\<not> (p .\<and>. q)) = (A \<turnstile> .\<not> p .\<or>. .\<not> q)
[PROOF STEP]
by (meson conj_imp disj_PL disj_com imp_PL imp_contrapos notE_PL notI_PL) |
-- 2014-02-08 Andreas
-- Eta-equality for records that are recursive via some data type
module _ where
open import Common.Equality
module Nested where
data List (A : Set) : Set where
[] : List A
_∷_ : (x : A)(xs : List A) → List A
record Tree (A : Set) : Set where
constructor tree
field
elem : A
subtrees : List (Tree A)
open Tree
test : ∀ {A} (t : Tree A) → t ≡ tree (elem t) (subtrees t)
test t = refl
-- we should have eta for Tree!
module Mutual where
mutual
data TreeList (A : Set) : Set where
[] : TreeList A
_∷_ : (x : Tree A)(xs : TreeList A) → TreeList A
record Tree (A : Set) : Set where
constructor tree
field
elem : A
subtrees : TreeList A
open Tree
test : ∀ {A} (t : Tree A) → t ≡ tree (elem t) (subtrees t)
test t = refl
|
(*
* 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)
*)
(* Author: Gerwin Klein, 2012
Maintainers: Gerwin Klein <kleing at cse.unsw.edu.au>
Rafal Kolanski <rafal.kolanski at nicta.com.au>
*)
chapter "Equivalence between Separation Algebra Formulations"
theory Sep_Eq
imports
Separation_Algebra
Separation_Algebra_Alt
begin
text {*
In this theory we show that our total formulation of separation algebra is
equivalent in strength to Calcagno et al's original partial one.
This theory is not intended to be included in own developments.
*}
no_notation map_add (infixl "++" 100)
declare [[syntax_ambiguity_warning = false]]
section "Total implies Partial"
definition add2 :: "'a::sep_algebra => 'a => 'a option" where
"add2 x y \<equiv> if x ## y then Some (x + y) else None"
lemma add2_zero: "add2 x 0 = Some x"
by (simp add: add2_def)
lemma add2_assoc:
"lift2 add2 a (lift2 add2 b c) = lift2 add2 (lift2 add2 a b) c"
by (auto simp: add2_def lift2_def sep_add_assoc
dest: sep_disj_addD sep_disj_addI3
sep_add_disjD sep_disj_addI2 sep_disj_commuteI
split: option.splits)
interpretation total_partial: sep_algebra_alt 0 add2
by (unfold_locales) (auto intro: add2_zero add2_comm add2_assoc)
section "Partial implies Total"
definition
sep_add' :: "'a \<Rightarrow> 'a \<Rightarrow> 'a :: sep_algebra_alt" where
"sep_add' x y \<equiv> if disjoint x y then the (add x y) else undefined"
lemma sep_disj_zero':
"disjoint x 0"
by simp
lemma sep_disj_commuteI':
"disjoint x y \<Longrightarrow> disjoint y x"
by (clarsimp simp: disjoint_def add_comm)
lemma sep_add_zero':
"sep_add' x 0 = x"
by (simp add: sep_add'_def)
lemma sep_add_commute':
"disjoint x y \<Longrightarrow> sep_add' x y = sep_add' y x"
by (clarsimp simp: sep_add'_def disjoint_def add_comm)
lemma sep_add_assoc':
"\<lbrakk> disjoint x y; disjoint y z; disjoint x z \<rbrakk> \<Longrightarrow>
sep_add' (sep_add' x y) z = sep_add' x (sep_add' y z)"
using add_assoc [of "Some x" "Some y" "Some z"]
by (clarsimp simp: disjoint_def sep_add'_def lift2_def
split: option.splits)
lemma sep_disj_addD1':
"disjoint x (sep_add' y z) \<Longrightarrow> disjoint y z \<Longrightarrow> disjoint x y"
proof (clarsimp simp: disjoint_def sep_add'_def)
fix a assume a: "y \<oplus> z = Some a"
fix b assume b: "x \<oplus> a = Some b"
with a have "Some x ++ (Some y ++ Some z) = Some b" by (simp add: lift2_def)
hence "(Some x ++ Some y) ++ Some z = Some b" by (simp add: add_assoc)
thus "\<exists>b. x \<oplus> y = Some b" by (simp add: lift2_def split: option.splits)
qed
lemma sep_disj_addI1':
"disjoint x (sep_add' y z) \<Longrightarrow> disjoint y z \<Longrightarrow> disjoint (sep_add' x y) z"
apply (clarsimp simp: disjoint_def sep_add'_def)
apply (rule conjI)
apply clarsimp
apply (frule lift_to_add2, assumption)
apply (simp add: add_assoc)
apply (clarsimp simp: lift2_def add_comm)
apply clarsimp
apply (frule lift_to_add2, assumption)
apply (simp add: add_assoc)
apply (clarsimp simp: lift2_def)
done
interpretation partial_total: sep_algebra sep_add' 0 disjoint
apply (unfold_locales)
apply (rule sep_disj_zero')
apply (erule sep_disj_commuteI')
apply (rule sep_add_zero')
apply (erule sep_add_commute')
apply (erule (2) sep_add_assoc')
apply (erule (1) sep_disj_addD1')
apply (erule (1) sep_disj_addI1')
done
end
|
The Canadian attack on San Leonardo by the Seaforth Highlanders of Canada began late on 5 December 1943 with A Company establishing a bridgehead across the Moro , taking heavy casualties . In the early morning of 6 December , A Company was withdrawn and two additional Seaforth companies resumed the offensive . As PPCLI secured and held their bridgehead over the Moro River , the Seaforth Highlanders were struggling to enter San Leonardo . By 07 : 15 , a single objective had been taken , with Canadian units pinned down by well @-@ coordinated defensive fire from several companies of the 361st Regiment . Simultaneously , small arms fire prevented C Company from moving up the road from the Moro to San Leonardo , while D Company remained on the southern banks of the Moro throughout the early morning .
|
#!/usr/bin/env python
"""
FVCOM: Using model input from unstructured grid
===============================================
"""
import sys
sys.path.append('/work/kvile/opendrift')
import os
from datetime import datetime, timedelta
import numpy as np
import cartopy.io.shapereader as shpreader
from pyproj import Proj
from tools import Filelist
from opendrift.readers import reader_netCDF_CF_generic
from opendrift.readers import reader_netCDF_CF_unstructured # FVCOM reader
from opendrift.readers import reader_shape
from opendrift.models.oceandrift import OceanDrift
o = OceanDrift(loglevel=20) #logfile='log.txt')
start_time='2018-3-1-0'
stop_time='2018-6-1-0'
#Readers
reader_coast = reader_shape.Reader.from_shpfiles('coast/po10_coast.shp')
o.add_reader(reader_coast) # Add coastline identical to the FVCOM grid
#reader_wind = reader_netcdf_CF_generic('/work/olean/fvcom/run/MATNOC/PO10/Forcing/PO10_wnd_20171201-20180630.nc')
# - not working with generic or unstructured
proj = "+proj=utm +zone=33W, +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
fl = Filelist('fileList.txt', start_time=start_time, stop_time=stop_time) # List of path to forcing
unique_files = fl.unique_files()
for f in unique_files:
print(f)
fvcom = reader_netCDF_CF_unstructured.Reader(filename=f, proj4=proj)
o.add_reader(fvcom)
#Configuration
o.set_config('general:use_auto_landmask',False) # Override default landmask
o.set_config('general:coastline_action', 'previous') # Jump back to previous position when meeting coast
o.set_config('drift:vertical_mixing',True) # Move particles vertically according to eddy diffusivity and buoyancy
o.set_config('vertical_mixing:diffusivitymodel', 'windspeed_Sundby1983')
o.set_config('drift:vertical_advection',True) # Move particles vertically according to vertical ocean currents
o.set_config('environment:fallback:sea_surface_wave_stokes_drift_x_velocity',.2)
#o.set_config('drift:current_uncertainty',2)
#o.set_config('drift:wind_uncertainty',2)
N = 10 # Number of particles
#z = -10 * np.random.uniform(0, 1, N)
z = -5 # Particle depth
#Måselvsutløpet
#lon1 = [18.521, 18.696, 18.998]
#lat2 = [69.308, 69.261, 69.289]
#Aursfjordbotn
#lon1 = [18.521, 18.696, 18.998]
#lat2 = [69.308, 69.261, 69.289]
#Nordfjordbotn
#lon1 = [18.521, 18.696, 18.998]
#lat2 = [69.308, 69.261, 69.289]
#utm33 = Proj(proj)
#x1, y1 = utm33(lon1, lat1)
#start_times = [datetime(2018, 4, 1, 0), datetime(2018, 4, 2, 0)] # Seed at specific times
start_times = [fl.datetime[0] + timedelta(days=n) for n in range(0, 14, 1)] # Seed at multiple times
for t in start_times:
o.seed_elements(lon=18.5160648, lat=69.2769774, z=z, time=t, number=N, radius=20, origin_marker=0) #Målselv
o.seed_elements(lon=18.7029564, lat=69.2612744, z=z, time=t, number=N, radius=20, origin_marker=1) #Aursfjord
o.seed_elements(lon=18.9946535, lat=69.2933032, z=z, time=t, number=N, radius=20, origin_marker=2) #Nordfjordbotn
# Running model
outfile = '../results/opendrift_%s_to_%s.nc'%(start_time,stop_time)
o.run(time_step=3600, end_time=fl.datetime[-1], time_step_output=3600*24, outfile=outfile, export_buffer_length=4)
# Show output
#o.plot(fast=True, linecolor='origin_marker', legend=['Målselv','Aursfjord','Nordfjord'],colorbar=False,filename='drift_plot.png')
#o.plot_property('z')
#o.plot_property('z', mean=True)
#o.animation(fast=True, color='origin_marker', legend=['Målselv','Aursfjord','Nordfjord'],colorbar=False,filename='drift_animation.mp4')
|
from PIL import Image
from maskgen import exif
import numpy as np
from maskgen.tool_set import *
def check_rotate(im, jpg_file_name):
return ImageWrapper(exif.rotateAccordingToExif(np.asarray(im),exif.getOrientationFromExif(jpg_file_name)))
def transform(im, source, target, **kwargs):
if 'donor' in kwargs and 'Image Rotated' in kwargs and kwargs['Image Rotated'] == 'yes':
im = check_rotate(im, kwargs['donor'])
else:
im = Image.open(source)
im.save(target, format='BMP')
if 'donor' in kwargs:
donor = kwargs['donor']
exif.runexif(['-overwrite_original', '-P', '-q', '-m', '-XMPToolkit=', target])
exif.runexif(['-q', '-all=', target])
exif.runexif(['-P', '-q', '-m', '-TagsFromFile', donor, '-all:all', '-unsafe', target])
createtime = exif.getexif(target, args=['-args', '-System:FileCreateDate'], separator='=')
if '-FileCreateDate' in createtime:
exif.runexif(['-P', '-q', '-m', '-System:fileModifyDate=' + createtime['-FileCreateDate'], target])
return None, None
def operation():
return {'name':'OutputBmp',
'category':'Output',
'description':'Output as BMP and copy metadata, if supplied.',
'software':'maskgen',
'version':'04',
'arguments':{
'donor':{
'type':'donor',
'defaultvalue':None,
'description':'BMP file with desired metadata.'
},
'Image Rotated': {
'type': 'yesno',
'defaultvalue': None,
'description': 'Answer yes if the image should be counter rotated according to EXIF Orientation.'
}
},
'transitions':[
'image.image'
]
}
def suffix():
return '.bmp'
|
The Bulls entered the 1989 – 90 season as a team on the rise , with their core group of Jordan and young improving players like Scottie Pippen and Horace Grant , and under the guidance of new coach Phil Jackson . Jordan averaged a league leading 33 @.@ 6 ppg on 52 @.@ 6 % shooting , to go with 6 @.@ 9 rpg and 6 @.@ 3 apg in leading the Bulls to a 55 – 27 record . They again advanced to the Eastern Conference Finals beating the Bucks and Philadelphia 76ers . However , despite pushing the series to seven games , the Bulls lost to the Pistons for the third consecutive season .
|
% Script to compile C code for EEG-BEM
% Christophe Phillips
% $Id: make.m 2718 2009-02-09 19:14:20Z vladimir $
mex -O bem_Cii_cog.c
mex -O bem_Cii_cst.c
mex -O bem_Cii_lin.c
mex -O bem_Cij_cog.c
mex -O bem_Cij_cst.c
mex -O bem_Cij_lin.c
mex -O bem_Gi_cog.c
mex -O bem_Gi_vert.c
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#https://qiita.com/Umaremin/items/4317fb88299995e54e5f
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import preprocessing
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.layers.recurrent import LSTM
from keras.optimizers import Adam
from keras.callbacks import EarlyStopping
from sklearn.model_selection import train_test_split
# データ読み込み
df = pd.read_csv("nikkei_stock_average_daily_jp.csv")
df['date'] = pd.to_datetime(df['date'], format = '%Y-%m-%d')
#データの標準化
df2 = df.loc[:, ['date', 'close']]
df2['close'] = preprocessing.scale(df2['close'])
#dfx = []
#for val in df2['close']:
# dfx.append(val/30000)
#df2['close'] = dfx
#訓練、テストデータの作成
maxlen = 10
X, Y = [], []
for i in range(len(df2) - maxlen):
X.append(df2[['close']].iloc[i:(i+maxlen)].as_matrix())
Y.append(df2[['close']].iloc[i+maxlen].as_matrix())
X=np.array(X)
Y=np.array(Y)
# 訓練用のデータと、テスト用のデータに分ける
N_train = int(len(df2) * 0.8)
N_test = len(df2) - N_train
X_train, X_test, y_train, y_test = \
train_test_split(X, Y, test_size=N_test, shuffle = False)
# 隠れ層の数などを定義: 隠れ層の数が大きいほど精度が上がる?
n_in = 1 # len(X[0][0])
n_out = 1 # len(Y[0])
n_hidden = 300
#モデル作成 (Kerasのフレームワークで簡易に記載できる)
model = Sequential()
model.add(LSTM(n_hidden,
batch_input_shape=(None, maxlen, n_in),
kernel_initializer='random_uniform',
return_sequences=False))
model.add(Dense(n_in, kernel_initializer='random_uniform'))
model.add(Activation("linear"))
opt = Adam(lr=0.001, beta_1=0.9, beta_2=0.999)
model.compile(loss = "mean_squared_error", optimizer=opt)
early_stopping = EarlyStopping(monitor='loss', patience=10, verbose=1)
hist = model.fit(X_train, y_train, batch_size=maxlen, epochs=500,
callbacks=[early_stopping])
# 損失のグラフ化
loss = hist.history['loss']
epochs = len(loss)
plt.rc('font', family='serif')
fig = plt.figure()
fig.patch.set_facecolor('white')
plt.plot(range(epochs), loss, marker='.', label='loss(training data)')
plt.show()
# 予測結果
predicted = model.predict(X_test)
result = pd.DataFrame(predicted)
result.columns = ['predict']
result['actual'] = y_test
result.plot()
plt.show()
|
Egyptian gods were involved in human lives as well as in the overarching order of nature . This divine influence applied mainly to Egypt , as foreign peoples were traditionally believed to be outside the divine order . But in the New Kingdom , when other nations were under Egyptian control , foreigners were said to be under the sun god 's benign rule in the same way that Egyptians were .
|
Formal statement is: lemma fun_complex_eq: "f = (\<lambda>x. Re (f x) + \<i> * Im (f x))" Informal statement is: Every complex-valued function $f$ is equal to the function $x \mapsto \mathrm{Re}(f(x)) + i \mathrm{Im}(f(x))$. |
#pragma once
#include "movie_writer.h"
#include <boost/math/tools/roots.hpp>
#include <cxxopts.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/rotate_vector.hpp>
#include <glm/gtx/string_cast.hpp>
#include <gsl/gsl_integration.h>
#include <omp.h>
#include <opencv2/opencv.hpp>
#include <QApplication>
#include <QCheckBox>
#include <QGraphicsView>
#include <QGuiApplication>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QMainWindow>
#include <QMenuBar>
#include <QPushButton>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include <array>
#include <chrono>
#include <cmath>
#include <filesystem>
#include <iostream>
#include <random>
#include <thread>
#include <vector> |
lemma pathfinish_circlepath [simp]: "pathfinish (circlepath z r) = z + r" |
[STATEMENT]
lemma anonymous_neutral_indifference:
assumes profileP: "profile A Is P"
and xyA: "hasw [x,y] A"
and tallyP: "card { i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y } = card { i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x }"
shows "x \<^bsub>(scf P)\<^esub>\<approx> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x \<^bsub>(scf P)\<^esub>\<approx> y
[PROOF STEP]
proof -
\<comment> \<open>Neutrality insists the results for @{term "P"} are symmetrical to those for @{term "swapAltsP P"}.\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. x \<^bsub>(scf P)\<^esub>\<approx> y
[PROOF STEP]
from xyA
[PROOF STATE]
proof (chain)
picking this:
hasw [x, y] A
[PROOF STEP]
have symPP': "(x \<^bsub>(scf P)\<^esub>\<preceq> y \<longleftrightarrow> y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x)
\<and> (y \<^bsub>(scf P)\<^esub>\<preceq> x \<longleftrightarrow> x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)"
[PROOF STATE]
proof (prove)
using this:
hasw [x, y] A
goal (1 subgoal):
1. (x \<^bsub>(scf P)\<^esub>\<preceq> y) = (y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x) \<and> (y \<^bsub>(scf P)\<^esub>\<preceq> x) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
[PROOF STEP]
by - (rule neutralD[OF neutral profileP profile_swapAltsP[OF profileP]],
simp_all, (rule swapAltsP_ab)+)
\<comment> \<open>Anonymity and neutrality insist the results for @{term "P"} are identical to those for @{term "swapAltsP P"}.\<close>
[PROOF STATE]
proof (state)
this:
(x \<^bsub>(scf P)\<^esub>\<preceq> y) = (y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x) \<and> (y \<^bsub>(scf P)\<^esub>\<preceq> x) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
goal (1 subgoal):
1. x \<^bsub>(scf P)\<^esub>\<approx> y
[PROOF STEP]
from xyA tallyP
[PROOF STATE]
proof (chain)
picking this:
hasw [x, y] A
card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x}
[PROOF STEP]
have "card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card { i \<in> Is. x \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> y }"
and "card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x} = card { i \<in> Is. y \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> x }"
[PROOF STATE]
proof (prove)
using this:
hasw [x, y] A
card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x}
goal (1 subgoal):
1. card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card {i \<in> Is. x \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> y} &&& card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x} = card {i \<in> Is. y \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> x}
[PROOF STEP]
unfolding swapAltsP_def swapAlts_def strict_pref_def
[PROOF STATE]
proof (prove)
using this:
hasw [x, y] A
card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<preceq> y \<and> (y, x) \<notin> P i} = card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<preceq> x \<and> (x, y) \<notin> P i}
goal (1 subgoal):
1. card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<preceq> y \<and> (y, x) \<notin> P i} = card {i \<in> Is. x \<^bsub>{(u, v). (if u = x then y else if u = y then x else u) \<^bsub>(P i)\<^esub>\<preceq> (if v = x then y else if v = y then x else v)}\<^esub>\<preceq> y \<and> (y, x) \<notin> {(u, v). (if u = x then y else if u = y then x else u) \<^bsub>(P i)\<^esub>\<preceq> (if v = x then y else if v = y then x else v)}} &&& card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<preceq> x \<and> (x, y) \<notin> P i} = card {i \<in> Is. y \<^bsub>{(u, v). (if u = x then y else if u = y then x else u) \<^bsub>(P i)\<^esub>\<preceq> (if v = x then y else if v = y then x else v)}\<^esub>\<preceq> x \<and> (x, y) \<notin> {(u, v). (if u = x then y else if u = y then x else u) \<^bsub>(P i)\<^esub>\<preceq> (if v = x then y else if v = y then x else v)}}
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card {i \<in> Is. x \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> y}
card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x} = card {i \<in> Is. y \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> x}
goal (1 subgoal):
1. x \<^bsub>(scf P)\<^esub>\<approx> y
[PROOF STEP]
with profileP xyA
[PROOF STATE]
proof (chain)
picking this:
profile A Is P
hasw [x, y] A
card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card {i \<in> Is. x \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> y}
card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x} = card {i \<in> Is. y \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> x}
[PROOF STEP]
have idPP': "x \<^bsub>(scf P)\<^esub>\<preceq> y \<longleftrightarrow> x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y"
and "y \<^bsub>(scf P)\<^esub>\<preceq> x \<longleftrightarrow> y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x"
[PROOF STATE]
proof (prove)
using this:
profile A Is P
hasw [x, y] A
card {i \<in> Is. x \<^bsub>(P i)\<^esub>\<prec> y} = card {i \<in> Is. x \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> y}
card {i \<in> Is. y \<^bsub>(P i)\<^esub>\<prec> x} = card {i \<in> Is. y \<^bsub>(swapAltsP P x y i)\<^esub>\<prec> x}
goal (1 subgoal):
1. (x \<^bsub>(scf P)\<^esub>\<preceq> y) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y) &&& (y \<^bsub>(scf P)\<^esub>\<preceq> x) = (y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x)
[PROOF STEP]
by - (rule anonymous_card[OF profileP profile_swapAltsP], clarsimp+)+
[PROOF STATE]
proof (state)
this:
(x \<^bsub>(scf P)\<^esub>\<preceq> y) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
(y \<^bsub>(scf P)\<^esub>\<preceq> x) = (y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x)
goal (1 subgoal):
1. x \<^bsub>(scf P)\<^esub>\<approx> y
[PROOF STEP]
from xyA SCF_completeD[OF SCF] profileP symPP' idPP'
[PROOF STATE]
proof (chain)
picking this:
hasw [x, y] A
universal_domain A Is ?P \<Longrightarrow> complete A (scf ?P)
profile A Is P
(x \<^bsub>(scf P)\<^esub>\<preceq> y) = (y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x) \<and> (y \<^bsub>(scf P)\<^esub>\<preceq> x) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
(x \<^bsub>(scf P)\<^esub>\<preceq> y) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
[PROOF STEP]
show "x \<^bsub>(scf P)\<^esub>\<approx> y"
[PROOF STATE]
proof (prove)
using this:
hasw [x, y] A
universal_domain A Is ?P \<Longrightarrow> complete A (scf ?P)
profile A Is P
(x \<^bsub>(scf P)\<^esub>\<preceq> y) = (y \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> x) \<and> (y \<^bsub>(scf P)\<^esub>\<preceq> x) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
(x \<^bsub>(scf P)\<^esub>\<preceq> y) = (x \<^bsub>(scf (swapAltsP P x y))\<^esub>\<preceq> y)
goal (1 subgoal):
1. x \<^bsub>(scf P)\<^esub>\<approx> y
[PROOF STEP]
by (simp, blast)
[PROOF STATE]
proof (state)
this:
x \<^bsub>(scf P)\<^esub>\<approx> y
goal:
No subgoals!
[PROOF STEP]
qed |
{-# OPTIONS_HADDOCK prune #-}
module ForSyDe.Atom.Skel.FastVector.DSP where
import Data.Complex
import qualified Data.Number.FixedFunctions as F
import ForSyDe.Atom.MoC as MoC
import ForSyDe.Atom.Skel.FastVector.Lib as V hiding (duals, unduals)
import ForSyDe.Atom.Skel.FastVector.Matrix as M
import ForSyDe.Atom ((><))
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.taylor'.
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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.taylor''.
taylor' n = taylor 4 (-30)
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.dotvm'.
dotvm :: Num a => Vector a -> Vector (Vector a) -> Vector a
dotvm = dotvm' (+) (*)
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.dotvv'.
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"
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.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"
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.dotmv''.
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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.dotvm''.
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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.hanning'.
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)))
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.hamming'.
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))
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.blackman'.
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))
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.fir'.
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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.fir''.
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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.twiddles'.
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)
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.fft'.
fft :: RealFloat a
=> Int -> 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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.fft''.
fft' :: Floating a
=> (Complex a -> a -> a -> (a, a))
-> Int -> 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
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.duals'.
duals :: Vector a -> (Vector a, Vector a)
duals v = (V.take k v, V.drop k v)
where
k = V.length v `div` 2
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.unduals'.
unduals :: Vector a -> Vector a -> Vector a
unduals x y = x <++> y
-- | See 'ForSyDe.Atom.Skel.Vector.DSP.bitrev'.
bitrev = V.unsafeLift bitrevF
where
bitrevF [x] = [x]
bitrevF xs = bitrevF (V.evensF xs) ++ bitrevF (V.oddsF xs)
|
theory Helper
imports Main
begin
section\<open>Hilfslemmata\<close>
lemma helper_sum_int_if: \<open>a \<notin> set P \<Longrightarrow>
(\<Sum>x\<in>set P. int (if a = x then A1 x else A2 x) * B x) =
(\<Sum>x\<in>set P. int (A2 x) * B x)\<close>
apply(rule sum.cong, simp)
by fastforce
lemma sum_list_map_eq_sum_count_int:
fixes f :: \<open>'a \<Rightarrow> int\<close>
shows \<open>sum_list (map f xs) = sum (\<lambda>x. (int (count_list xs x)) * f x) (set xs)\<close>
proof(induction \<open>xs\<close>)
case (Cons x xs)
show \<open>?case\<close> (is \<open>?l = ?r\<close>)
proof cases
assume \<open>x \<in> set xs\<close>
have XXX: \<open>(\<Sum>xa\<in>set xs - {x}. int (if x = xa then count_list xs xa + 1 else count_list xs xa) * f xa)
= (\<Sum>xa\<in>set xs - {x}. int (count_list xs xa) * f xa)\<close>
thm helper_sum_int_if
apply(rule sum.cong, simp)
by auto
have \<open>?l = f x + (\<Sum>x\<in>set xs. (int (count_list xs x)) * f x)\<close> by (simp add: Cons.IH)
also have \<open>set xs = insert x (set xs - {x})\<close> using \<open>x \<in> set xs\<close>by blast
also have \<open>f x + (\<Sum>x\<in>insert x (set xs - {x}). (int (count_list xs x)) * f x) = ?r\<close>
apply(simp add: sum.insert_remove XXX)
by (simp add: mult.commute ring_class.ring_distribs(1))
finally show \<open>?thesis\<close> .
next
assume \<open>x \<notin> set xs\<close>
hence \<open>\<And>xa. xa \<in> set xs \<Longrightarrow> x \<noteq> xa\<close> by blast
thus \<open>?thesis\<close> by (simp add: Cons.IH \<open>x \<notin> set xs\<close>)
qed
qed simp
lemma count_list_distinct: \<open>distinct P \<Longrightarrow> x \<in> set P \<Longrightarrow> count_list P x = 1\<close>
apply(induction \<open>P\<close>)
apply(simp; fail)
by(auto)
lemma is_singleton_the_elem_as_set: \<open>is_singleton A \<Longrightarrow> the_elem A = a \<longleftrightarrow> A = {a}\<close>
apply(rule iffI)
apply (simp add: is_singleton_the_elem)
apply(simp add: the_elem_def)
done
(*the simplifier loops with this one, sometimes. If it loops, apply(elim is_singletonE) first.*)
lemma singleton_set_to_all: \<open>{a \<in> A. P a} = {b} \<longleftrightarrow> (\<forall>a. (a \<in> A \<and> P a) = (a = b))\<close>
by fastforce
lemma singleton_set_to_all2: \<open>A = {b} \<longleftrightarrow> (\<forall>a. (a \<in> A) = (a = b))\<close>
by fastforce
lemma is_singleton_bij_image: \<open>bij f \<Longrightarrow> is_singleton (f ` A) = is_singleton A\<close>
by (metis bij_betw_same_card bij_betw_subset is_singleton_altdef subset_UNIV)
text\<open>For some reason, I like \<^const>\<open>List.map_filter\<close>. But standard library support is poor.\<close>
lemma List_map_filter_as_comprehension:
\<open>List.map_filter f xs = [the (f x). x \<leftarrow> xs, f x \<noteq> None]\<close>
by(induction \<open>xs\<close>) (simp add: List.map_filter_def)+
lemma List_map_filter_as_foldr:
\<open>List.map_filter f xs = foldr (\<lambda>x acc. case f x of Some a \<Rightarrow> a#acc | None \<Rightarrow> acc) xs []\<close>
apply(induction \<open>xs\<close>)
apply(simp add: List.map_filter_def)
apply(simp add: List.map_filter_def)
apply(safe, simp)
done
lemma concat_map_if: \<open>concat (map (\<lambda>x. if P x then [x] else []) xs) = filter P xs\<close>
by(induction \<open>xs\<close>) auto
lemma fold_fun_update_call_helper:
\<open>p \<notin> set xs \<Longrightarrow> fold (\<lambda>x acc. acc(x := f x)) xs start p = start p\<close>
by(induction \<open>xs\<close> arbitrary: \<open>start\<close>) simp+
lemma fold_fun_update_call:
\<open>p \<in> set xs \<Longrightarrow> distinct xs \<Longrightarrow> fold (\<lambda>x acc. acc(x := f x)) xs start p = f p\<close>
apply(induction \<open>xs\<close> arbitrary: \<open>start\<close>)
apply(simp; fail)
apply(simp)
apply(safe)
apply(simp add: fold_fun_update_call_helper; fail)
apply(simp)
done
lemma fold_enum_fun_update_call:
\<open>fold (\<lambda>x acc. acc(x := f x)) Enum.enum start p = f p\<close>
apply(rule fold_fun_update_call)
apply(simp add: enum_class.enum_UNIV)
apply(simp add: enum_class.enum_distinct)
done
lemma fold_enum_fun_update:
\<open>fold (\<lambda>x acc. acc(x := f x)) Enum.enum start = f\<close>
using fold_enum_fun_update_call by auto
end |
= = Eighth commandment = =
|
\documentclass[../main.tex]{subfiles}
\begin{document}
\section{Rate of Completions}
As learners engage in activities supported by a learning ecosystem, they will build
up a history of learning experiences. When the digital resources of that learning ecosystem
adhere to a framework dedicated to supporting and understanding the
learner, such as the Total Learning Architecture (TLA), it becomes
possible to retell their learning story through data and data visualization. One important aspect of
that story is the rate of completion\footnote{\label{defOfCompletion}
Completion can be defined by the presence of the verb completed or by the presence of
$\$.result.completion$ set equal to true. In this algorithm,
completion is defined by the presence of the verb completed
regardless of $\$.result.completion$. This decision affects how
statements are retrieved and filtered. In the case where completion
is defined by $\$.result.completion$, the query to the LRS would not
include the verb paramater and there would need to be a filtering
process which looks for the presence of $\$.result.completion$ =
true} of the various digital resources within the learning
ecosystem.
\subsection{Ideal Statements}
In order to accurately portray the rates of completion, there
are a few base requirements of the data produced by a Learning Record
Provider (LRP). They are as follows:
\begin{itemize}
\item statements describing a learner completing an activity
should\footnote{\label{verbIRICompletion} See footnote 4}
use the verb $http://adlnet.gov/expapi/verbs/completed$
\item statements describing a learner completing an activity should
report if the learner was successful or not via
$\$.result.success$
\item statement describing a learner completing a scored activity
should report the learners score via $\$.result.score.raw$,
$\$.result.score.min$ and $\$.result.score.max$
\item activites must be uniquely and consistently identified across
all statements
\item The time at which a learner completed a learning activity must be recorded
\begin{itemize}
\item The timestamp should contain an appropriate level of specificity.
\item ie. Year, Month, Day, Hour, Minute, Second, Timezone
\end{itemize}
\item statements describing a learner completing an activity should
report the amount of time taken to complete the activity via $\$.result.duration$
\end{itemize}
\subsection{Input Data Retrieval}
How to query an LRS via a GET request to the Statements Resource via
curl. The following section contains the appropriate parameters with
example values as well as the curl command necessary for making the
request.\footnote{\label{refMoreLink2} See footnote
1.}\footnote{\label{refnoZ2} See footnote
2.}\footnote{\label{refallTime2} See footnote 3.}
\begin{lstlisting}[frame=single]
Verb = "verb=http://adlnet.gov/expapi/verbs/completed"
Since = "since=2018-07-20T12:08:47Z"
Until = "until=2018-07-21T12:08:47Z"
Base = "https://example.endpoint/statements?"
endpoint = Base + Verb + "&" + Since + "&" + Until
Auth = Hash generated from basic auth
S = curl -X GET -H "Authorization: Auth"
-H "Content-Type: application/json"
-H "X-Experience-API-Version: 1.0.3"
Endpoint
\end{lstlisting}
\subsection{Statement Parameters to Utilize}
The statement parameter locations here are written in
\href{http://goessner.net/articles/JsonPath/}{JSONPath}. This notation
is also compatable with the xAPI Z notation due to the defined
hierarchy of components. Within the Z specifications, a variable name
will be used instead of the $\$$
\begin{itemize}
\item $\$.timestamp$
\item $\$.object.id$
\end{itemize}
\subsection{2018 Pilot TLA Statement Problems}
The initial pilot test data supports the core requirements of this
algorithm but completion statements only reports completion scores via
$\$.result.scaled$ instead of $\$.result.score.raw$,
$\$.result.score.min$ and
$\$.result.score.max$.\footnote{\label{scaledScores} The one potential
issue with using scaled score is the
calculation of scaled is not stricly defined by the xAPI
specification but is instead up to the authors of the LRP. This
results in the inability to reliably compare scaled scores across
LRPs. if $\$.result.score.raw$ , $\$.result.score.min$ and
$\$.result.score.max$ are reported for all questions, it becomes
possible to reliably compare scores across LRPs by generating a
scaled score in a consistent way.} Given that the offical 2018 pilot
test is scheduled to take place on July 27th, 2018, this section may
require updates pending future data review.
\subsection{Summary}
\begin{enumerate}
\item Query an LRS via a GET request to the statemetns endpoint
using the paramters verb, since and until.
\item group statements by their $\$.object.id$
\item select time range unit for use within rate calculation. Will
default to day.
\item determine the amount of time between the first and last instance of a $\$.object.id$ (in seconds) and divide it by the time unit. ie if the unit is minute, you would divide by 60.
\item calculate the rate by dividing the count of a group (2) by the number of time units covered by the statements (4) so that the rate is the number of completions per activity per time unit.
\end{enumerate}
\subsection{Formal Specification}
\subsubsection{Basic Types}
$TIMEUNIT$ :== $\{second\} | \{minute\} | \{hour\} | \{day\} |
\{week\} | \{month\} | \{year\}$
\subsubsection{System State}
\begin{schema}{RateOfCompletion}
Statements \\
S_{completions} : \finset_1 \\
S_{grouped},S_{timeunit}, S_{processed} : \finset \\
\where
S_{completions} = statements \\
S_{grouped} = \{byId : \seq_1 statement\} \\
S_{withRate} = \{byGroup: (\seq_1 statement, \nat)\} \\
S_{processed} = \{rate : (id , \nat, TIMEUNIT)\}
\end{schema}
\begin{itemize}
\item The set $S_{completions}$ is a non-empty, finite set and is the
component $statements$ which contains the results of the query to
the LRS.
\item The sets $S_{grouped}$, $S_{withRate}$ and $S_{processed}$ are all finite sets
\item the set $S_{grouped}$ is a finite set of objects $byId$ which
are non-empty, finite sequences of the component $statement$
\item the set $S_{withRate}$ is a finite set of objects $byGroup$ which
are ordered pairs of non-empty, finite sequences of the component $statement$ and a natural number
\item the set $S_{processed}$ is a finite set of objects $rate$ where each
contains the component $id$, a natural number and the type $TIMEUNIT$
\end{itemize}
\subsubsection{Initial System State}
\begin{schema}{InitRateOfCompletion}
RateOfCompletion \\
T : TIMEUNIT
\where
S_{completions} \not = \emptyset \\
S_{grouped} = \emptyset \\
S_{withRate} = \emptyset \\
S_{processed} = \emptyset \\
T = \{day\}
\end{schema}
\begin{itemize}
\item The set $S_{completions}$ is a non-empty set which contains the results of the GET request(s) to the LRS
\item The sets $S_{grouped}$ , $S_{withRate}$ and $S_{processed}$ are
all initially empty
\item the variable T has the type $TIMEUNIT$ and the value $\{day\}$
\end{itemize}
\subsubsection{Calculate Rate}
\begin{schema}{IsoToUnix}
convert : \finset_1 \fun \nat\#1 \\
c? : \finset_1 \\
c! : \nat\#1
\where
c! = convert(c?)
\end{schema}
\begin{itemize}
\item The schema $IsoToUnix$ introduces the function $convert$ which
takes in a finit set of one thing (a timestamp) and converts it to
a single natural number.
\item the purpose of this function is to convert an ISO 8601
timestamp to the Unix epoch. The concrete definition of the conversion
is outside the scope of this document
\begin{itemize}
\item The Unix epoch is the number of seconds that have elapsed
since January 1, 1970 (midnight UTC/GMT), not counting leap seconds.
\end{itemize}
\end{itemize}
\begin{schema}{CalcRateByUnit}
Statement \\
IsoToUnix \\
CountPerGroup \\
unit? : TIMEUNIT \\
s?,s! : \finset \\
r : \nat \\
rate : (\finset, TIMEUNIT) \fun \finset
\where
unit? \, = \,\{second\} \implies 1 \lor \{minute\} \implies 60
\lor \{hour\} \implies 3600 \,\lor \\\t2 \{day\} \implies 86400 \lor
\{week\} \implies 604800 \,\lor \\\t2 \{month\} \implies 2629743
\lor \{year\} \implies 31556926 \\
s? = \{g : seq_1 statement\} \\
s! = rate(s?, unit?) \\
s! = \{s : (g, r) \,|\, \forall g_{n}: g_{i}..g_{j} @ i \leq n \leq j @
\exists \, s_{n} : (g_{n}, r_{n}) @ \\\t1
r_{n} = count(g_{n}) \div ((convert(last~g_{n}.timestamp) - convert(head~g_{n}.timestamp)) \div unit?)\}
\end{schema}
\begin{itemize}
\item The schema $CalcRateByUnit$ introduces the function $rate$ where
the input $s?$ is a set of objects $g$ which are each a non-empty,
finite sequence of statements and the input $unit?$ represents a
unit of time.
\item for every $g_{n}$ within the range $g_{i}..g_{j}$, there exists an associated object $s_{n}$ which is an orderd pair of $(g_{n}, r_{n})$ where $r_{n}$ is equal to the number of items within $g_{n}$ divided by the number of $unit?$s within the time range of $last~g_{n}.timestamp-head~g_{n}.timestamp$
\item the output of the function $rate$ is $s!$, the set of all $s_{n}$
\end{itemize}
$\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$ %%% keep header with z-schema
\subsubsection{Processes Results}
\begin{schema}{AggergateCompletionStatements}
\Delta RateOfCompletion \\
GroupByActivityId \\
CalcRateByUnit \\
grouped,processed,withRate : \finset \\
r : \nat \\
T? : TIMEUNIT
\where
T? = \{day\} \\
grouped = \emptyset \\
grouped' = group(S_{completions}) \\
S_{grouped}' = S_{grouped} \cup grouped' \\
withRate \subseteq S_{grouped}' \\
withRate' = rate(withRate, T?) \\
S_{withRate}' = withRate' \cup S_{withRate} \\
processed \subseteq S_{withRate}' \\
processed' = \{p: (id, r, T?) \,|\,
\\\t3 \LET \{processed_{i}..processed_{j}\} == \{b_{i}..b_{j}\} @ \\\t3
\forall b_{n} : b_{i}..b_{j} @ i \leq n \leq j @
\exists \, p_{n} : (id_{n}, r_{n}, T?) @ \\\t3
id_{n} = (head~(first~b_{n})).object.id \, \land \, \\\t3
r_{n} = (second~b_{n})\} \\
S_{processed}' = processed' \cup S_{processed}
\end{schema}
\begin{itemize}
\item The schema $AggergateCompletionStatements$ outlines how to calculate
the rate of completion per $\$.object.id$ per $second|minute|hour|day|week|month|year$
\begin{enumerate}
\item $S_{grouped}'$ is the result of grouping the statements within $S_{completions}$ by their $\$.object.id$
\item The groups from (1) are passed to the function $rate$ with the
variable $T?$ which controls the unit of time, ie per day vs per week
\item the result of (2) is then processed to create a triplet of
$\$.object.id$, rate, unit of time for all unique $\$.object.id$
within $S_{completions}$
\end{enumerate}
\end{itemize}
\subsubsection{Return}
\begin{schema}{ReturnAggergateCompletionStatements}
\Xi RateOfCompletion \\
AggergateCompletionStatements \\
S_{processed}! : \finset
\where
S_{processed}! = S_{processed}
\end{schema}
\begin{itemize}
\item The return value $S_{processed}!$ is equal to $S_{processed}$ after the operation described by $AggergateCompletionStatements$
\end{itemize}
\subsection{Pseudocode}
\begin{algorithm}[H]
\SetAlgoLined
\KwIn{$S_{completed}$, $timeUnit$}
\KwResult{$ratePerObjTu'$}
\emph{context = \{\}}\;
\emph {ratePerObjTu = []}\;
\While{$S_{completion} \not = \emptyset$}
{\ForEach{$s \in S_{completion}$}
{$id \leftarrow s.object.id$\;
$ts \leftarrow convert(s.timestamp)$\;
\eIf{$id \notin context$}
{\bf do \\
$times = [ts]$\;
$context' \leftarrow \{id : times \}$\;
$S_{completion}' \leftarrow S_{completion} \setminus s$\;
recur $context', S_{completion}'$\;}
{\bf do \\
$times' \leftarrow context.id \cat ts$\;
$context' \leftarrow \{id : times'\}$\;
$S_{completion}' \leftarrow S_{completion} \setminus s$\;
recur $context', S_{completion}'$\;}}}
\ForEach {$k \in context'$}
{$allTs \leftarrow context'.k$\;
$totalDuration \leftarrow max(allTs) - min(allTs)$\;
$totalCount \leftarrow count(allTs)$\;
$rate \leftarrow totalCount \div (totalDuration \div timeUnit)$\;
$subVec = [k, rate, timeUnit]$\;
$ratePerObjTu' \leftarrow ratePerObjTu \cat subVec$\;
{\bf recur} $ratePerObjTu'$\;}
\Return $ratePerObjTu'$
\caption{Rate of Completions}
\end{algorithm}
\begin{itemize}
\item Values from Z schemas are used within this pseudocode
\item the result of the algorithm is an array of arrays where each
subarray contains a $statement.object.id$, the $rate$ and the
$timeUnit$ used to calculate $rate$.
\end{itemize}
$\\$ %% header with text
\subsection{JSON Schema}
\begin{lstlisting}[]
{"type":"array",
"items":{"type":"array",
"items":[{"type":"string"}, {"type":"number"},
{"type":"string"}]}}
\end{lstlisting}
\subsection{Visualization Description}
The \textbf{Rate of Completions} visualization will be
a bar chart where the domain consists of $statement.object.id$ and the
range is a number greater than 0 (the rate of completions for that
$statement.object.id$). Every subarray within the array $ratePerObjTu$
will be a grouping within the bar chart. The pseudocode specifies an
input paramter $timeUnit$ which controls the calculation of the rate
(range of the visualization). $timeUnit$ could be per minute, per day,
per week, etc.
\subsection{Visualization prototype}
\pgfplotstabletypeset[string type]
\begin{tikzpicture}
\begin{axis}[
title = Rate of Completions,
ylabel = Completions per Time Unit,
symbolic x coords={question1-id,question2-id,question3-id},
xtick=data]
\addplot[ybar,fill=blue] coordinates{
(question1-id,18)
(question2-id,9)
(question3-id,13)
};
\end{axis}
\end{tikzpicture}
\subsection{Prototype Improvement Suggestions}
Additional features may be implemented on top of this base
specification but they would require adding aditional values to each
subarray returned by the algorithm. These additional values can be
retrieved via (1) performing metadata lookup within or independently of the
algorithm (2) by utilizing additional xAPI statement paramters and/or (3) by
performing additional computations. The following examples assume the
metadata is contained within each statement available to the algorithm.
\begin{itemize}
\item use $statement.object.definition.name$ instead of
$statement.object.id$ for x axis label
\item populate a tooltip with the people who have completed the
activity. This could also include the number of times they have
completed it.
\item populate a tooltip with the breakdown of which devices or platforms the
activity was completed on. This would require the device type or platform to be
reported within $statement.context.platform$
\item populate a tooltip with the breakdown of percentage successful
for all completions of the activty. This would require
$statement.result.success$
\item populate a tooltip with the breakdown of scores earned (if
appliciable) for the completions. This would require
$statement.result.score.raw$, $statement.result.score.min$ and
$statement.result.score.max$
\item populate a tooltip with the competency assocaited with the
completed activities. The competency should be reported
via $statement.context.contextActivities$
\item populate a tooltip with the average duration spent to reach
completions. This would require $statement.result.duration$ to be reported.
\end{itemize}
\end{document}
|
State Before: α : Type u
β : Type v
ι : Sort w
a✝ : α
s✝ s₁ s₂ t✝ : Set α
p✝ p₁ p₂ : α → Prop
inst✝ : TopologicalSpace α
a : α
p : ι → Prop
s : ι → Set α
h : HasBasis (𝓝 a) p s
t : Set α
⊢ (∀ ⦃i : ι⦄, p i → ∀ ⦃j : Unit⦄, True → Set.Nonempty (s i ∩ t)) ↔ ∀ (i : ι), p i → Set.Nonempty (s i ∩ t) State After: no goals Tactic: simp only [exists_prop, forall_const] |
[STATEMENT]
lemma eSuc_minus_eSuc [simp]: "eSuc n - eSuc m = n - m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. eSuc n - eSuc m = n - m
[PROOF STEP]
by (simp add: eSuc_def split: enat.split) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.