Datasets:
AI4M
/

text
stringlengths
0
3.34M
import numpy as np import cv2 import os def detect_face_from_img_path(frontal_face_model_file_path, image_path): if not os.path.exists(frontal_face_model_file_path): print('failed to find face detection opencv model: ', frontal_face_model_file_path) face_cascade = cv2.CascadeClassifier(frontal_face_model_file_path) img = cv2.imread(image_path) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5) print('faces detected: ', len(faces)) for (x, y, w, h) in faces: img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2) cv2.imshow('img', img) cv2.waitKey(0) cv2.destroyAllWindows() def main(): frontal_face_model_file_path = '../../demo/opencv-files/haarcascade_frontalface_alt.xml' detect_face_from_img_path( frontal_face_model_file_path, '../../demo/data/opencv-images/test1.jpg') detect_face_from_img_path( frontal_face_model_file_path, '../../demo/data/opencv-images/test4.jpg') if __name__ == '__main__': main()
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.Choice module cohomology.Theory where record CohomologyTheory i : Type (lsucc i) where field C : ℤ → Ptd i → Group i CEl : ℤ → Ptd i → Type i CEl n X = Group.El (C n X) Cid : (n : ℤ) (X : Ptd i) → CEl n X Cid n X = GroupStructure.ident (Group.group-struct (C n X)) ⊙CEl : ℤ → Ptd i → Ptd i ⊙CEl n X = ⊙[ CEl n X , Cid n X ] field CF-hom : (n : ℤ) {X Y : Ptd i} → fst (X ⊙→ Y) → (C n Y →ᴳ C n X) CF-ident : (n : ℤ) {X : Ptd i} → CF-hom n {X} {X} (⊙idf X) == idhom (C n X) CF-comp : (n : ℤ) {X Y Z : Ptd i} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) → CF-hom n (g ⊙∘ f) == CF-hom n f ∘ᴳ CF-hom n g CF : (n : ℤ) {X Y : Ptd i} → fst (X ⊙→ Y) → fst (⊙CEl n Y ⊙→ ⊙CEl n X) CF n f = GroupHom.⊙f (CF-hom n f) field C-abelian : (n : ℤ) (X : Ptd i) → is-abelian (C n X) C-Susp : (n : ℤ) (X : Ptd i) → C (succ n) (⊙Susp X) == C n X C-exact : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) → is-exact (CF n (⊙cfcod f)) (CF n f) C-additive : (n : ℤ) {I : Type i} (Z : I → Ptd i) → ((W : I → Type i) → has-choice ⟨0⟩ I W) → C n (⊙BigWedge Z) == Πᴳ I (C n ∘ Z) {- A quick useful special case of C-additive: C n (X ∨ Y) == C n X × C n Y -} C-binary-additive : (n : ℤ) (X Y : Ptd i) → C n (X ⊙∨ Y) == C n X ×ᴳ C n Y C-binary-additive n X Y = ap (C n) (! (BigWedge-Bool-⊙path Pick)) ∙ C-additive n _ (λ _ → Bool-has-choice) ∙ Πᴳ-Bool-is-×ᴳ (C n ∘ Pick) where Pick : Lift {j = i} Bool → Ptd i Pick (lift true) = X Pick (lift false) = Y record OrdinaryTheory i : Type (lsucc i) where constructor ordinary-theory field cohomology-theory : CohomologyTheory i open CohomologyTheory cohomology-theory public field C-dimension : (n : ℤ) → n ≠ O → C n (⊙Sphere O) == 0ᴳ
theory List_Demo imports Main begin datatype 'a list = Nil | Cons "'a" "'a list" datatype 'a ll = Nil | Cons "'a * 'a" "'a ll" datatype 'a tree = Leaf | Node "'a tree" 'a "'a tree" term "Nil" declare [[names_short]] fun app :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" where "app Nil ys = ys" | "app (Cons x xs) ys = Cons x (app xs ys)" (* Associativity of append. Intuitively: It makes no difference if we first append xs and ys, and then append zs to the result, or if we first append ys and zs, and append the result to xs. *) lemma "app (app xs ys) zs = app xs (app ys zs)" apply (induction xs) apply auto done (* Reverse a list ... we'll come here later! *) fun rev :: "'a list \<Rightarrow> 'a list" where "rev Nil = Nil" | "rev (Cons x xs) = app (rev xs) (Cons x Nil)" value "rev(Cons True (Cons False Nil))" value "rev(Cons a (Cons b Nil))" theorem rev_rev: "rev (rev xs) = xs" apply (induction xs) apply (auto) (* For now, we are stuck here: We'll later see how to complete the proof. *) oops (* Oops cancels unsuccessful proof attempt. *) end
```python import numpy as np import pandas as pd from sympy import Matrix ``` ```python from IPython.display import SVG, display ``` # Types of vectors Vectors come in three flavors: (1) geometric vectors, (2) polynomials, (3) and elements of Rn space. ## Geometric vectors Geometric vectors are oriented segments. These are the kind of vectors you probably learned about in high-school physics and geometry. Many linear algebra concepts come from the geometric point of view of vectors: space, plane, distance, etc. Fig. 2: Geometric vectors ```python def show_svg(): display(SVG(url='https://pabloinsente.github.io/assets/post-10/b-geometric-vectors.svg')) show_svg() ``` ## Polynomials A polynomial is an expression like f(x)=x2+y+1. This is, a expression adding multiple “terms” (nomials). Polynomials are vectors because they meet the definition of a vector: they can be added together to get another polynomial, and they can be multiplied together to get another polynomial. function addition is valid f(x)+g(x) and multiplying by a scalar is valid 5×f(x) Fig. 3: Polynomials ```python def show_svg(): display(SVG(url='https://pabloinsente.github.io/assets/post-10/b-polynomials-vectors.svg')) show_svg() ``` ```python # dot product x, y = np.array([[-2], [2]]), np.array([[4], [-3]]) np.dot(x.T, y) ``` array([[-14]]) # Vector space, span and subspace ## Vector Space In its more general form, a vector space, also known as linear space, is a collection of objects that follow the rules defined for vectors in Rn. We mentioned those rules when we defined vectors: they can be added together and multiplied by scalars, and return vectors of the same type. More colloquially, a vector space is the set of proper vectors and all possible linear combinatios of the vector set. In addition, vector addition and multiplication must follow these eight rules: - commutativity: x+y=y+x - associativity: x+(y+x)=(y+x)+z - unique zero vector such that: x+0=x ∀ x - ∀ x there is a unique vector x such that x+−x=0 - identity element of scalar multiplication: 1x=x - distributivity of scalar multiplication w.r.t vector addition: x(y+z)=xz+zy - x(yz)=(xy)z - (y+z)x=yx+zx ## Vector Span Consider the vectors x and y and the scalars α and β. If we take all possible linear combinations of αx+βy we would obtain the span of such vectors. This is easier to grasp when you think about geometric vectors. If our vectors x and y point into different directions in the 2-dimensional space, we get that the span(x,y) is equal to the entire 2-dimensional plane, as shown in the middle-pane in Fig. 5. Just imagine having an unlimited number of two types of sticks: one pointing vertically, and one pointing horizontally. Now, you can reach any point in the 2-dimensional space by simply combining the necessary number of vertical and horizontal sticks (including taking fractions of sticks). Fig. 5: Vector Span <p> </p> What would happen if the vectors point in the same direction? Now, if you combine them, you just can span a line, as shown in the left-pane in Fig. 5. If you have ever heard of the term “multicollinearity”, it’s closely related to this issue: when two variables are “colinear” they are pointing in the same direction, hence they provide redundant information, so can drop one without information loss. With three vectors pointing into different directions, we can span the entire 3-dimensional space or a hyper-plane, as in the right-pane of Fig. 5. Note that the sphere is just meant as a 3-D reference, not as a limit. Four vectors pointing into different directions will span the 4-dimensional space, and so on. From here our geometrical intuition can’t help us. This is an example of how linear algebra can describe the behavior of vectors beyond our basics intuitions. ## Vector subspaces A vector subspace (or linear subspace) is a vector space that lies within a larger vector space. These are also known as linear subspaces. Consider a subspace S. For a vector to be a valid subspace it has to meet three conditions: - Contains the zero vector, 0∈S - Closure under multiplication, ∀α∈R→α×si∈S - Closure under addition, ∀si∈S→s1+s2∈S Intuitively, you can think in closure as being unable to “jump out” from space into another. A pair of vectors laying flat in the 2-dimensional space, can’t, by either addition or multiplication, “jump out” into the 3-dimensional space. Fig. 6: Vector subspaces <p> </p> Consider the following questions: Is x=[1 1] a valid subspace of R2? Let’s evaluate x on the three conditions: **Contains the zero vector**: it does. Remember that the span of a vector are all linear combinations of such a vector. Therefore, we can simply multiply by 0 to get [0 0]: x×0=0[1 1]=[0 0] **Closure under multiplication** implies that if take any vector belonging to x and multiply by any real scalar α, the resulting vector stays within the span of x. Algebraically is easy to see that we can multiply [1 1] by any scalar α, and the resulting vector remains in the 2-dimensional plane (i.e., the span of R2). **Closure under addition** implies that if we add together any vectors belonging to x, the resulting vector remains within the span of R2. Again, algebraically is clear that if we add x + x, the resulting vector will remain in R2. There is no way to get to R3 or R4 or any space outside the two-dimensional plane by adding x multiple times. ## Linear dependence and independence The left-pane shows a triplet of linearly dependent vectors, whereas the right-pane shows a triplet of linearly independent vectors. Fig. 7: Linear dependence and independence <p> </p> A set of vectors is linearly dependent if at least one vector can be obtained as a linear combination of other vectors in the set. As you can see in the left pane, we can combine vectors x and y to obtain z. There is more rigurous (but slightly harder to grasp) definition of linear dependence. Consider a set of vectors x1,…,xk and scalars β∈R. If there is a way to get 0=∑βixi with at least one β≠0, we have linearly dependent vectors. In other words, if we can get the zero vector as a linear combination of the vectors in the set, with weights that are not all zero, we have a linearly dependent set. A set of vectors is linearly independent if none vector can be obtained as a linear combination of other vectors in the set. As you can see in the right pane, there is no way for us to combine vectors x and y to obtain z. Again, consider a set of vectors x1,…,xk and scalars β∈R. If the only way to get 0=∑ki=1βixi requires all β1,…,βk=0, the we have linearly independent vectors. In words, the only way to get the zero vectors in by multoplying each vector in the set by 0. ## Vector Null space Now that we know what subspaces and linear dependent vectors are, we can introduce the idea of the null space. Intuitively, the null space of a set of vectors are all linear combinations that “map” into the zero vector. Consider a set of geometric vectors w, x, y, and z as in Fig. 8. By inspection, we can see that vectors x and z are parallel to each other, hence, independent. On the contrary, vectors w and y can be obtained as linear combinations of x and z, therefore, dependent. Fig. 8: Vector null space <p> </p> <p> </p> As result, with this four vectors, we can form the following two combinations that will “map” into the origin of the coordinate system, this is, the zero vector (0,0): z−y+x=0 z−x+w=0 ## Vector Norms Measuring vectors is another important operation in machine learning applications. Intuitively, we can think about the norm or the length of a vector as the distance between its “origin” and its “end”. Norms “map” vectors to non-negative values. In this sense are functions that assign length ∥x∥∈Rn to a vector x. To be valid, a norm has to satisfy these properties (keep in mind these properties are a bit abstruse to understand): Absolutely homogeneous: ∀α∈R,∥αx∥=|α∥∥x∥. In words: for all real-valued scalars, the norm scales proportionally with the value of the scalar. Triangle inequality: ∥x+y∥≤∥x∥+∥y∥. In words: in geometric terms, for any triangle the sum of any two sides must be greater or equal to the lenght of the third side. This is easy to see experimentally: grab a piece of rope, form triangles of different sizes, measure all the sides, and test this property. Positive definite: ∥x∥≥0 and ∥x∥=0⟺x=0. In words: the length of any x has to be a positive value (i.e., a vector can’t have negative length), and a length of 0 occurs only of x=0 Grasping the meaning of these three properties may be difficult at this point, but they probably become clearer as you improve your understanding of linear algebra. Fig. 9: Vector norms <p> </p> ### Euclidean Norm <p> </p> ```python x = np.array([[3], [4]]) np.linalg.norm(x, 2) #If you remember the first “Pythagorean triplet”, you can confirm that the norm is correct. ``` 5.0 ```python # In machine learning, unless made explicit, we can safely assume that an inner product refers to the dot product. x, y = np.array([[-2],[2]]), np.array([[4],[-3]]) x.T @ y ``` array([[-14]]) ```python # As with the inner product, usually, we can safely assume that distance stands for the Euclidean distance or # L2 norm unless otherwise noted. To compute the L2 distance between a pair of vectors: distance = np.linalg.norm(x-y, 2) print(f'L_2 distance : {distance}') ``` L_2 distance : 7.810249675906654 ### Manhattan Norm <p> </p> ```python x = np.array([[3], [-4]]) np.linalg.norm(x, 1) #easy to confirm that the sum of the absolute values of 3 and −4 is 7. ``` 7.0 ## Max Norm <p> </p> ```python x = np.array([[3], [-4]]) np.linalg.norm(x, np.inf) ``` 4.0 ## Vector angles and orthogonality <p> </p> <p> </p> <p> </p> ```python x, y = np.array([[1], [2]]), np.array([[5], [7]]) cos_theta = np.dot(x.T, y) / (np.linalg.norm(x,2) * (np.linalg.norm(y,2))) print(f"Cos of the angle:{np.round(cos_theta, 3)} ") ``` Cos of the angle:[[0.988]] ```python cos_inv = np.arccos(cos_theta) print(f"Angle in Radians: {np.round(cos_inv, 3)}") ``` Angle in Radians: [[0.157]] ```python degrees = cos_inv * (180/np.pi) print(f"Angle in degrees: {np.round(degrees,3)}") ``` Angle in degrees: [[8.973]] **Orthogonality** is often used interchangeably with “independence” although they are mathematically different concepts. Orthogonality can be seen as a generalization of perpendicularity to vectors in any number of dimensions. **We say that a pair of vectors x and y are orthogonal if their inner product is zero, ⟨x,y⟩=0**. The notation for a pair of orthogonal vectors is x⊥y. In the 2-dimensional plane, this equals to a pair of vectors forming a 90∘ angle. ## Solving a system of Linear Equations x+2y=8 5x−3y=1 ```python df = pd.DataFrame({"x1": [0, 2], "y1":[8, 3], "x2": [0, 2], "y2": [0, 3]}) df ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>x1</th> <th>y1</th> <th>x2</th> <th>y2</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>0</td> <td>8</td> <td>0</td> <td>0</td> </tr> <tr> <th>1</th> <td>2</td> <td>3</td> <td>2</td> <td>3</td> </tr> </tbody> </table> </div> ```python df.plot(x = "x1", y = ["y1", "y2"]) ``` ## Matrix Inverse ```python A = np.array([[1, 2, 1], [4, 4, 5], [6, 7, 7]]) A_inv = np.linalg.inv(A) A_inv ``` array([[-7., -7., 6.], [ 2., 1., -1.], [ 4., 5., -4.]]) ## Hadamard product It is matrix-matrix multiplication as an element-wise operation. aij⋅bij:=cij ```python A = np.array([[0,2], [1,4]]) B = np.array([[1,3], [2,1]]) np.multiply(A,B) ``` array([[0, 6], [2, 4]]) <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> ## Solving systems of linear equations with Matrices ```python # Ax = y A = np.array([[1, 3, 5], [2, 2, -1], [1, 3, 2]]) y = np.array([[-1], [1], [2]]) np.linalg.solve(A, y) ``` array([[-2.], [ 2.], [-1.]]) ## Matrix Basis and Rank <p> </p> <p> </p> ```python A = Matrix([[1, 0, 1], [0, 1, 1]]) B = Matrix([[1, 2, 3, -1], [2, -1, -4, 8], [-1, 1, 3, -5], [-1, 2, 5, -6], [-1, -2, -3, 1]]) A_rref, A_pivots = A.rref() print(f'Reduced row echelon form of A: {A_rref}') ``` Reduced row echelon form of A: Matrix([[1, 0, 1], [0, 1, 1]]) ```python print(f'Column pivots of A: {A_pivots}') ``` Column pivots of A: (0, 1) ```python B_rref, B_pivots = B.rref() print(f'Reduced row echelon form of B:{B_rref}') ``` Reduced row echelon form of B:Matrix([[1, 0, -1, 0], [0, 1, 2, 0], [0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0]]) ```python print(f'Column pivots of A: {B_pivots}') ``` Column pivots of A: (0, 1, 3) For A, we found that the first and second column vectors are the basis, whereas for B is the first, second, and fourth. Now that we know about a basis and how to find it, understanding the concept of rank is simpler. The rank of a matrix A is the dimensionality of the vector space generated by its number of linearly independent column vectors. This happens to be identical to the dimensionality of the vector space generated by its row vectors. We denote the rank of matrix as rk(A) or rank(A). For an square matrix Rm×n (i.e., m=n), we say is full rank when every column and/or row is linearly independent. For a non-square matrix with m>n (i.e., more rows than columns), we say is full rank when every row is linearly independent. When m<n (i.e., more columns than rows), we say is full rank when every column is linearly independent. From an applied machine learning perspective, the rank of a matrix is relevant as [a measure of the information content of the matrix](https://math.stackexchange.com/questions/21100/importance-of-matrix-rank). Take matrix B from the example above. Although the original matrix has 5 columns, we know is rank 4, hence, it has less information than it appears at first glance. ## Matrix Norm As with vectors, we can measure the size of a matrix by computing its norm. There are multiple ways to define the norm for a matrix, as long it satisfies the same properties defined for vectors norms: (1) absolutely homogeneous, (2) triangle inequality, (3) positive definite (see vector norms section). For our purposes, I’ll cover two of the most commonly used norms in machine learning: (1) Frobenius norm, (2) max norm, (3) spectral norm. <p> </p> ```python A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) np.linalg.norm(A, 'fro') ``` 16.881943016134134 <p> </p> ```python A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) np.linalg.norm(A, np.inf) #In this case, is easy to see that the third row has the largest absolute value. ``` 24.0 <p> </p> ```python A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) np.linalg.norm(A, 2) ``` 16.84810335261421 ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ```python ``` ## REFERNCES https://pabloinsente.github.io/intro-linear-algebra
State Before: α : Type u_1 β : Type ?u.141391 γ : Type ?u.141394 inst✝ : DecidableEq α s s₁ s₂ t t₁ t₂ u v : Finset α a b : α ⊢ ¬a ∈ s ∪ t ↔ ¬a ∈ s ∧ ¬a ∈ t State After: no goals Tactic: rw [mem_union, not_or]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker ! This file was ported from Lean 3 source module data.polynomial.field_division ! leanprover-community/mathlib commit cb3ceec8485239a61ed51d944cb9a95b68c6bafc ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Data.Polynomial.Derivative import Mathbin.Data.Polynomial.RingDivision import Mathbin.RingTheory.EuclideanDomain /-! # Theory of univariate polynomials > THIS FILE IS SYNCHRONIZED WITH MATHLIB4. > Any changes to this file require a corresponding PR to mathlib4. This file starts looking like the ring theory of $ R[X] $ -/ noncomputable section open Classical BigOperators Polynomial namespace Polynomial universe u v w y z variable {R : Type u} {S : Type v} {k : Type y} {A : Type z} {a b : R} {n : ℕ} section IsDomain variable [CommRing R] [IsDomain R] /- warning: polynomial.derivative_root_multiplicity_of_root -> Polynomial.derivative_rootMultiplicity_of_root is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : CharZero.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {t : R}, (Polynomial.IsRoot.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p t) -> (Eq.{1} Nat (Polynomial.rootMultiplicity.{u1} R _inst_1 t (coeFn.{succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (fun (_x : LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.hasCoeToFun.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.derivative.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Polynomial.rootMultiplicity.{u1} R _inst_1 t p) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : CharZero.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (Ring.toAddGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1)))] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {t : R}, (Polynomial.IsRoot.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p t) -> (Eq.{1} Nat (Polynomial.rootMultiplicity.{u1} R _inst_1 t (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => (fun ([email protected]._hyg.6190 : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.derivative.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Polynomial.rootMultiplicity.{u1} R _inst_1 t p) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) Case conversion may be inaccurate. Consider using '#align polynomial.derivative_root_multiplicity_of_root Polynomial.derivative_rootMultiplicity_of_rootₓ'. -/ theorem derivative_rootMultiplicity_of_root [CharZero R] {p : R[X]} {t : R} (hpt : p.IsRoot t) : p.derivative.rootMultiplicity t = p.rootMultiplicity t - 1 := by rcases eq_or_ne p 0 with (rfl | hp) · simp nth_rw 1 [← p.div_by_monic_mul_pow_root_multiplicity_eq t] simp only [derivative_pow, derivative_mul, derivative_sub, derivative_X, derivative_C, sub_zero, mul_one] set n := p.root_multiplicity t - 1 have hn : n + 1 = _ := tsub_add_cancel_of_le ((root_multiplicity_pos hp).mpr hpt) rw [← hn] set q := p /ₘ (X - C t) ^ (n + 1) with hq convert_to root_multiplicity t ((X - C t) ^ n * (derivative q * (X - C t) + q * C ↑(n + 1))) = n · congr rw [mul_add, mul_left_comm <| (X - C t) ^ n, ← pow_succ'] congr 1 rw [mul_left_comm <| (X - C t) ^ n, mul_comm <| (X - C t) ^ n] have h : (derivative q * (X - C t) + q * C ↑(n + 1)).eval t ≠ 0 := by suffices eval t q * ↑(n + 1) ≠ 0 by simpa refine' mul_ne_zero _ (nat.cast_ne_zero.mpr n.succ_ne_zero) convert eval_div_by_monic_pow_root_multiplicity_ne_zero t hp exact hn ▸ hq rw [root_multiplicity_mul, root_multiplicity_X_sub_C_pow, root_multiplicity_eq_zero h, add_zero] refine' mul_ne_zero (pow_ne_zero n <| X_sub_C_ne_zero t) _ contrapose! h rw [h, eval_zero] #align polynomial.derivative_root_multiplicity_of_root Polynomial.derivative_rootMultiplicity_of_root /- warning: polynomial.root_multiplicity_sub_one_le_derivative_root_multiplicity -> Polynomial.rootMultiplicity_sub_one_le_derivative_rootMultiplicity is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : CharZero.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (t : R), LE.le.{0} Nat Nat.hasLe (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Polynomial.rootMultiplicity.{u1} R _inst_1 t p) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Polynomial.rootMultiplicity.{u1} R _inst_1 t (coeFn.{succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (fun (_x : LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.hasCoeToFun.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.derivative.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : CharZero.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (Ring.toAddGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1)))] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (t : R), LE.le.{0} Nat instLENat (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Polynomial.rootMultiplicity.{u1} R _inst_1 t p) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Polynomial.rootMultiplicity.{u1} R _inst_1 t (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => (fun ([email protected]._hyg.6190 : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.derivative.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p)) Case conversion may be inaccurate. Consider using '#align polynomial.root_multiplicity_sub_one_le_derivative_root_multiplicity Polynomial.rootMultiplicity_sub_one_le_derivative_rootMultiplicityₓ'. -/ theorem rootMultiplicity_sub_one_le_derivative_rootMultiplicity [CharZero R] (p : R[X]) (t : R) : p.rootMultiplicity t - 1 ≤ p.derivative.rootMultiplicity t := by by_cases p.is_root t · exact (derivative_root_multiplicity_of_root h).symm.le · rw [root_multiplicity_eq_zero h, zero_tsub] exact zero_le _ #align polynomial.root_multiplicity_sub_one_le_derivative_root_multiplicity Polynomial.rootMultiplicity_sub_one_le_derivative_rootMultiplicity section NormalizationMonoid variable [NormalizationMonoid R] instance : NormalizationMonoid R[X] where normUnit p := ⟨C ↑(normUnit p.leadingCoeff), C ↑(normUnit p.leadingCoeff)⁻¹, by rw [← RingHom.map_mul, Units.mul_inv, C_1], by rw [← RingHom.map_mul, Units.inv_mul, C_1]⟩ normUnit_zero := Units.ext (by simp) normUnit_mul p q hp0 hq0 := Units.ext (by dsimp rw [Ne.def, ← leading_coeff_eq_zero] at * rw [leading_coeff_mul, norm_unit_mul hp0 hq0, Units.val_mul, C_mul]) normUnit_coe_units u := Units.ext (by rw [← mul_one u⁻¹, Units.val_mul, Units.eq_inv_mul_iff_mul_eq] dsimp rcases Polynomial.isUnit_iff.1 ⟨u, rfl⟩ with ⟨_, ⟨w, rfl⟩, h2⟩ rw [← h2, leading_coeff_C, norm_unit_coe_units, ← C_mul, Units.mul_inv, C_1]) /- warning: polynomial.coe_norm_unit -> Polynomial.coe_normUnit is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (coeBase.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.hasCoe.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))))) (NormalizationMonoid.normUnit.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.normalizationMonoid.{u1} R _inst_1 _inst_2 _inst_3) p)) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R (coeBase.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R (Units.hasCoe.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))))))) (NormalizationMonoid.normUnit.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2) _inst_3 (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p)))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.val.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (NormalizationMonoid.normUnit.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R _inst_1 _inst_2 _inst_3) p)) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.val.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (NormalizationMonoid.normUnit.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2) _inst_3 (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p)))) Case conversion may be inaccurate. Consider using '#align polynomial.coe_norm_unit Polynomial.coe_normUnitₓ'. -/ @[simp] theorem coe_normUnit {p : R[X]} : (normUnit p : R[X]) = C ↑(normUnit p.leadingCoeff) := by simp [norm_unit] #align polynomial.coe_norm_unit Polynomial.coe_normUnit /- warning: polynomial.leading_coeff_normalize -> Polynomial.leadingCoeff_normalize is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (fun (_x : MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.normalizationMonoid.{u1} R _inst_1 _inst_2 _inst_3)) p)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) (fun (_x : MonoidWithZeroHom.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) => R -> R) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) (normalize.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2) _inst_3) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => (fun ([email protected]._hyg.2391 : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R _inst_1 _inst_2 _inst_3)) p)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => R) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R R (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))))) (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R R (MulZeroOneClass.toMulOneClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) (MulZeroOneClass.toMulOneClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2))))) R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} R R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))) (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)))))))) (normalize.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2) _inst_3) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p)) Case conversion may be inaccurate. Consider using '#align polynomial.leading_coeff_normalize Polynomial.leadingCoeff_normalizeₓ'. -/ theorem leadingCoeff_normalize (p : R[X]) : leadingCoeff (normalize p) = normalize (leadingCoeff p) := by simp #align polynomial.leading_coeff_normalize Polynomial.leadingCoeff_normalize /- warning: polynomial.monic.normalize_eq_self -> Polynomial.Monic.normalize_eq_self is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p) -> (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (fun (_x : MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.normalizationMonoid.{u1} R _inst_1 _inst_2 _inst_3)) p) p) but is expected to have type forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) p) -> (Eq.{succ u1} ((fun ([email protected]._hyg.2391 : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => (fun ([email protected]._hyg.2391 : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R _inst_1 _inst_2 _inst_3)) p) p) Case conversion may be inaccurate. Consider using '#align polynomial.monic.normalize_eq_self Polynomial.Monic.normalize_eq_selfₓ'. -/ theorem Monic.normalize_eq_self {p : R[X]} (hp : p.Monic) : normalize p = p := by simp only [Polynomial.coe_normUnit, normalize_apply, hp.leading_coeff, normUnit_one, Units.val_one, polynomial.C.map_one, mul_one] #align polynomial.monic.normalize_eq_self Polynomial.Monic.normalize_eq_self /- warning: polynomial.roots_normalize -> Polynomial.roots_normalize is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Eq.{succ u1} (Multiset.{u1} R) (Polynomial.roots.{u1} R _inst_1 _inst_2 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (fun (_x : MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.isDomain.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.normalizationMonoid.{u1} R _inst_1 _inst_2 _inst_3)) p)) (Polynomial.roots.{u1} R _inst_1 _inst_2 p) but is expected to have type forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] [_inst_3 : NormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_2)] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Eq.{succ u1} (Multiset.{u1} R) (Polynomial.roots.{u1} R _inst_1 _inst_2 (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => (fun ([email protected]._hyg.2391 : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2))))))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1) _inst_2)) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R _inst_1 _inst_2 _inst_3)) p)) (Polynomial.roots.{u1} R _inst_1 _inst_2 p) Case conversion may be inaccurate. Consider using '#align polynomial.roots_normalize Polynomial.roots_normalizeₓ'. -/ theorem roots_normalize {p : R[X]} : (normalize p).roots = p.roots := by rw [normalize_apply, mul_comm, coe_norm_unit, roots_C_mul _ (norm_unit (leading_coeff p)).NeZero] #align polynomial.roots_normalize Polynomial.roots_normalize end NormalizationMonoid end IsDomain section DivisionRing variable [DivisionRing R] {p q : R[X]} /- warning: polynomial.degree_pos_of_ne_zero_of_nonunit -> Polynomial.degree_pos_of_ne_zero_of_nonunit is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : DivisionRing.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))}, (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))))) -> (Not (IsUnit.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) p)) -> (LT.lt.{0} (WithBot.{0} Nat) (Preorder.toLT.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))))) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (OfNat.mk.{0} (WithBot.{0} Nat) 0 (Zero.zero.{0} (WithBot.{0} Nat) (WithBot.hasZero.{0} Nat Nat.hasZero)))) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : DivisionRing.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))}, (Ne.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.zero.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))) -> (Not (IsUnit.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) p)) -> (LT.lt.{0} (WithBot.{0} Nat) (Preorder.toLT.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)))) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (Zero.toOfNat0.{0} (WithBot.{0} Nat) (WithBot.zero.{0} Nat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero)))) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) p)) Case conversion may be inaccurate. Consider using '#align polynomial.degree_pos_of_ne_zero_of_nonunit Polynomial.degree_pos_of_ne_zero_of_nonunitₓ'. -/ theorem degree_pos_of_ne_zero_of_nonunit (hp0 : p ≠ 0) (hp : ¬IsUnit p) : 0 < degree p := lt_of_not_ge fun h => by rw [eq_C_of_degree_le_zero h] at hp0 hp exact hp (IsUnit.map C (IsUnit.mk0 (coeff p 0) (mt C_inj.2 (by simpa using hp0)))) #align polynomial.degree_pos_of_ne_zero_of_nonunit Polynomial.degree_pos_of_ne_zero_of_nonunit /- warning: polynomial.monic_mul_leading_coeff_inv -> Polynomial.monic_mul_leadingCoeff_inv is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : DivisionRing.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))}, (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))))) -> (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))) p (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R _inst_1)) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) p))))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : DivisionRing.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))}, (Ne.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.zero.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))) -> (Polynomial.Monic.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Inv.inv.{u1} R (DivisionRing.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) p))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))) p (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Inv.inv.{u1} R (DivisionRing.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) p))))) Case conversion may be inaccurate. Consider using '#align polynomial.monic_mul_leading_coeff_inv Polynomial.monic_mul_leadingCoeff_invₓ'. -/ theorem monic_mul_leadingCoeff_inv (h : p ≠ 0) : Monic (p * C (leadingCoeff p)⁻¹) := by rw [monic, leading_coeff_mul, leading_coeff_C, mul_inv_cancel (show leading_coeff p ≠ 0 from mt leading_coeff_eq_zero.1 h)] #align polynomial.monic_mul_leading_coeff_inv Polynomial.monic_mul_leadingCoeff_inv /- warning: polynomial.degree_mul_leading_coeff_inv -> Polynomial.degree_mul_leadingCoeff_inv is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : DivisionRing.{u1} R] {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))} (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))), (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) q (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))))) -> (Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))) p (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R _inst_1)) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) q))))) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : DivisionRing.{u1} R] {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))} (p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))), (Ne.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) q (OfNat.ofNat.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.zero.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))) -> (Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Inv.inv.{u1} R (DivisionRing.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) q))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))) p (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1))) (Inv.inv.{u1} R (DivisionRing.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) q))))) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (DivisionRing.toDivisionSemiring.{u1} R _inst_1)) p)) Case conversion may be inaccurate. Consider using '#align polynomial.degree_mul_leading_coeff_inv Polynomial.degree_mul_leadingCoeff_invₓ'. -/ theorem degree_mul_leadingCoeff_inv (p : R[X]) (h : q ≠ 0) : degree (p * C (leadingCoeff q)⁻¹) = degree p := by have h₁ : (leadingCoeff q)⁻¹ ≠ 0 := inv_ne_zero (mt leadingCoeff_eq_zero.1 h) rw [degree_mul, degree_C h₁, add_zero] #align polynomial.degree_mul_leading_coeff_inv Polynomial.degree_mul_leadingCoeff_inv #print Polynomial.map_eq_zero /- @[simp] theorem map_eq_zero [Semiring S] [Nontrivial S] (f : R →+* S) : p.map f = 0 ↔ p = 0 := by simp only [Polynomial.ext_iff, map_eq_zero, coeff_map, coeff_zero] #align polynomial.map_eq_zero Polynomial.map_eq_zero -/ #print Polynomial.map_ne_zero /- theorem map_ne_zero [Semiring S] [Nontrivial S] {f : R →+* S} (hp : p ≠ 0) : p.map f ≠ 0 := mt (map_eq_zero f).1 hp #align polynomial.map_ne_zero Polynomial.map_ne_zero -/ end DivisionRing section Field variable [Field R] {p q : R[X]} /- warning: polynomial.is_unit_iff_degree_eq_zero -> Polynomial.isUnit_iff_degree_eq_zero is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, Iff (IsUnit.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p) (Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (OfNat.mk.{0} (WithBot.{0} Nat) 0 (Zero.zero.{0} (WithBot.{0} Nat) (WithBot.hasZero.{0} Nat Nat.hasZero))))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, Iff (IsUnit.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) p) (Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (Zero.toOfNat0.{0} (WithBot.{0} Nat) (WithBot.zero.{0} Nat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero))))) Case conversion may be inaccurate. Consider using '#align polynomial.is_unit_iff_degree_eq_zero Polynomial.isUnit_iff_degree_eq_zeroₓ'. -/ theorem isUnit_iff_degree_eq_zero : IsUnit p ↔ degree p = 0 := ⟨degree_eq_zero_of_isUnit, fun h => have : degree p ≤ 0 := by simp [*, le_refl] have hc : coeff p 0 ≠ 0 := fun hc => by rw [eq_C_of_degree_le_zero this, hc] at h <;> simpa using h isUnit_iff_dvd_one.2 ⟨C (coeff p 0)⁻¹, by conv in p => rw [eq_C_of_degree_le_zero this] rw [← C_mul, _root_.mul_inv_cancel hc, C_1]⟩⟩ #align polynomial.is_unit_iff_degree_eq_zero Polynomial.isUnit_iff_degree_eq_zero #print Polynomial.div /- /-- Division of polynomials. See `polynomial.div_by_monic` for more details.-/ def div (p q : R[X]) := C (leadingCoeff q)⁻¹ * (p /ₘ (q * C (leadingCoeff q)⁻¹)) #align polynomial.div Polynomial.div -/ #print Polynomial.mod /- /-- Remainder of polynomial division. See `polynomial.mod_by_monic` for more details. -/ def mod (p q : R[X]) := p %ₘ (q * C (leadingCoeff q)⁻¹) #align polynomial.mod Polynomial.mod -/ private theorem quotient_mul_add_remainder_eq_aux (p q : R[X]) : q * div p q + mod p q = p := if h : q = 0 then by simp only [h, MulZeroClass.zero_mul, mod, mod_by_monic_zero, zero_add] else by conv => rhs rw [← mod_by_monic_add_div p (monic_mul_leading_coeff_inv h)] rw [div, mod, add_comm, mul_assoc] #align polynomial.quotient_mul_add_remainder_eq_aux polynomial.quotient_mul_add_remainder_eq_aux private theorem remainder_lt_aux (p : R[X]) (hq : q ≠ 0) : degree (mod p q) < degree q := by rw [← degree_mul_leading_coeff_inv q hq] <;> exact degree_mod_by_monic_lt p (monic_mul_leading_coeff_inv hq) #align polynomial.remainder_lt_aux polynomial.remainder_lt_aux instance : Div R[X] := ⟨div⟩ instance : Mod R[X] := ⟨mod⟩ /- warning: polynomial.div_def -> Polynomial.div_def is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasDiv.{u1} R _inst_1)) p q) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) q))) (Polynomial.divByMonic.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) p (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) q (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) q)))))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instDivPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p q) (HMul.hMul.{u1, u1, u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) (instHMul.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) (Polynomial.divByMonic.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) p (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) q (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q)))))) Case conversion may be inaccurate. Consider using '#align polynomial.div_def Polynomial.div_defₓ'. -/ theorem div_def : p / q = C (leadingCoeff q)⁻¹ * (p /ₘ (q * C (leadingCoeff q)⁻¹)) := rfl #align polynomial.div_def Polynomial.div_def /- warning: polynomial.mod_def -> Polynomial.mod_def is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HMod.hMod.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMod.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasMod.{u1} R _inst_1)) p q) (Polynomial.modByMonic.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) p (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) q (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) q))))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (HMod.hMod.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHMod.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instModPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p q) (Polynomial.modByMonic.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) p (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) q (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))))) Case conversion may be inaccurate. Consider using '#align polynomial.mod_def Polynomial.mod_defₓ'. -/ theorem mod_def : p % q = p %ₘ (q * C (leadingCoeff q)⁻¹) := rfl #align polynomial.mod_def Polynomial.mod_def #print Polynomial.modByMonic_eq_mod /- theorem modByMonic_eq_mod (p : R[X]) (hq : Monic q) : p %ₘ q = p % q := show p %ₘ q = p %ₘ (q * C (leadingCoeff q)⁻¹) by simp only [monic.def.1 hq, inv_one, mul_one, C_1] #align polynomial.mod_by_monic_eq_mod Polynomial.modByMonic_eq_mod -/ #print Polynomial.divByMonic_eq_div /- theorem divByMonic_eq_div (p : R[X]) (hq : Monic q) : p /ₘ q = p / q := show p /ₘ q = C (leadingCoeff q)⁻¹ * (p /ₘ (q * C (leadingCoeff q)⁻¹)) by simp only [monic.def.1 hq, inv_one, C_1, one_mul, mul_one] #align polynomial.div_by_monic_eq_div Polynomial.divByMonic_eq_div -/ /- warning: polynomial.mod_X_sub_C_eq_C_eval -> Polynomial.mod_x_sub_c_eq_c_eval is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (a : R), Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HMod.hMod.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMod.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasMod.{u1} R _inst_1)) p (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHSub.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.sub.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.X.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.eval.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) a p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] (p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (a : R), Eq.{succ u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.eval.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) a p)) (HMod.hMod.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.eval.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) a p)) (instHMod.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instModPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHSub.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.sub.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.X.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.eval.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) a p)) Case conversion may be inaccurate. Consider using '#align polynomial.mod_X_sub_C_eq_C_eval Polynomial.mod_x_sub_c_eq_c_evalₓ'. -/ theorem mod_x_sub_c_eq_c_eval (p : R[X]) (a : R) : p % (X - C a) = C (p.eval a) := modByMonic_eq_mod p (monic_X_sub_C a) ▸ modByMonic_X_sub_C_eq_C_eval _ _ #align polynomial.mod_X_sub_C_eq_C_eval Polynomial.mod_x_sub_c_eq_c_eval /- warning: polynomial.mul_div_eq_iff_is_root -> Polynomial.mul_div_eq_iff_isRoot is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, Iff (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHSub.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.sub.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.X.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a)) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasDiv.{u1} R _inst_1)) p (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHSub.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.sub.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.X.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a)))) p) (Polynomial.IsRoot.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p a) but is expected to have type forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, Iff (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHSub.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.sub.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.X.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a)) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instDivPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHSub.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.sub.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.X.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a)))) p) (Polynomial.IsRoot.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p a) Case conversion may be inaccurate. Consider using '#align polynomial.mul_div_eq_iff_is_root Polynomial.mul_div_eq_iff_isRootₓ'. -/ theorem mul_div_eq_iff_isRoot : (X - C a) * (p / (X - C a)) = p ↔ IsRoot p a := divByMonic_eq_div p (monic_X_sub_C a) ▸ mul_divByMonic_eq_iff_isRoot #align polynomial.mul_div_eq_iff_is_root Polynomial.mul_div_eq_iff_isRoot instance : EuclideanDomain R[X] := { Polynomial.commRing, Polynomial.nontrivial with Quotient := (· / ·) quotient_zero := by simp [div_def] remainder := (· % ·) R := _ r_wellFounded := degree_lt_wf quotient_mul_add_remainder_eq := quotient_mul_add_remainder_eq_aux remainder_lt := fun p q hq => remainder_lt_aux _ hq mul_left_not_lt := fun p q hq => not_lt_of_ge (degree_le_mul_left _ hq) } #print Polynomial.mod_eq_self_iff /- theorem mod_eq_self_iff (hq0 : q ≠ 0) : p % q = p ↔ degree p < degree q := ⟨fun h => h ▸ EuclideanDomain.mod_lt _ hq0, fun h => by have : ¬degree (q * C (leadingCoeff q)⁻¹) ≤ degree p := not_le_of_gt <| by rwa [degree_mul_leading_coeff_inv q hq0] rw [mod_def, mod_by_monic, dif_pos (monic_mul_leading_coeff_inv hq0)] unfold div_mod_by_monic_aux simp only [this, false_and_iff, if_false]⟩ #align polynomial.mod_eq_self_iff Polynomial.mod_eq_self_iff -/ #print Polynomial.div_eq_zero_iff /- theorem div_eq_zero_iff (hq0 : q ≠ 0) : p / q = 0 ↔ degree p < degree q := ⟨fun h => by have := EuclideanDomain.div_add_mod p q <;> rwa [h, MulZeroClass.mul_zero, zero_add, mod_eq_self_iff hq0] at this, fun h => by have hlt : degree p < degree (q * C (leadingCoeff q)⁻¹) := by rwa [degree_mul_leading_coeff_inv q hq0] have hm : Monic (q * C (leadingCoeff q)⁻¹) := monic_mul_leadingCoeff_inv hq0 rw [div_def, (div_by_monic_eq_zero_iff hm).2 hlt, MulZeroClass.mul_zero]⟩ #align polynomial.div_eq_zero_iff Polynomial.div_eq_zero_iff -/ #print Polynomial.degree_add_div /- theorem degree_add_div (hq0 : q ≠ 0) (hpq : degree q ≤ degree p) : degree q + degree (p / q) = degree p := by have : degree (p % q) < degree (q * (p / q)) := calc degree (p % q) < degree q := EuclideanDomain.mod_lt _ hq0 _ ≤ _ := degree_le_mul_left _ (mt (div_eq_zero_iff hq0).1 (not_lt_of_ge hpq)) conv_rhs => rw [← EuclideanDomain.div_add_mod p q, degree_add_eq_left_of_degree_lt this, degree_mul] #align polynomial.degree_add_div Polynomial.degree_add_div -/ #print Polynomial.degree_div_le /- theorem degree_div_le (p q : R[X]) : degree (p / q) ≤ degree p := if hq : q = 0 then by simp [hq] else by rw [div_def, mul_comm, degree_mul_leading_coeff_inv _ hq] <;> exact degree_div_by_monic_le _ _ #align polynomial.degree_div_le Polynomial.degree_div_le -/ #print Polynomial.degree_div_lt /- theorem degree_div_lt (hp : p ≠ 0) (hq : 0 < degree q) : degree (p / q) < degree p := by have hq0 : q ≠ 0 := fun hq0 => by simpa [hq0] using hq rw [div_def, mul_comm, degree_mul_leading_coeff_inv _ hq0] <;> exact degree_div_by_monic_lt _ (monic_mul_leading_coeff_inv hq0) hp (by rw [degree_mul_leading_coeff_inv _ hq0] <;> exact hq) #align polynomial.degree_div_lt Polynomial.degree_div_lt -/ #print Polynomial.degree_map /- @[simp] theorem degree_map [DivisionRing k] (p : R[X]) (f : R →+* k) : degree (p.map f) = degree p := p.degree_map_eq_of_injective f.Injective #align polynomial.degree_map Polynomial.degree_map -/ #print Polynomial.natDegree_map /- @[simp] theorem natDegree_map [DivisionRing k] (f : R →+* k) : natDegree (p.map f) = natDegree p := natDegree_eq_of_degree_eq (degree_map _ f) #align polynomial.nat_degree_map Polynomial.natDegree_map -/ /- warning: polynomial.leading_coeff_map -> Polynomial.leadingCoeff_map is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} [_inst_2 : DivisionRing.{u2} k] (f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))), Eq.{succ u2} k (Polynomial.leadingCoeff.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k _inst_2)) (Polynomial.map.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k _inst_2)) f p)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) (fun (_x : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) => R -> k) (RingHom.hasCoeToFun.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) f (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p)) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} [_inst_2 : DivisionRing.{u2} k] (f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))), Eq.{succ u2} k (Polynomial.leadingCoeff.{u2} k (DivisionSemiring.toSemiring.{u2} k (DivisionRing.toDivisionSemiring.{u2} k _inst_2)) (Polynomial.map.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u2} k (DivisionRing.toDivisionSemiring.{u2} k _inst_2)) f p)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => k) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) R k (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) R k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2)))) R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2))) (RingHom.instRingHomClassRingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k _inst_2))))))) f (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p)) Case conversion may be inaccurate. Consider using '#align polynomial.leading_coeff_map Polynomial.leadingCoeff_mapₓ'. -/ @[simp] theorem leadingCoeff_map [DivisionRing k] (f : R →+* k) : leadingCoeff (p.map f) = f (leadingCoeff p) := by simp only [← coeff_nat_degree, coeff_map f, nat_degree_map] #align polynomial.leading_coeff_map Polynomial.leadingCoeff_map #print Polynomial.monic_map_iff /- theorem monic_map_iff [DivisionRing k] {f : R →+* k} {p : R[X]} : (p.map f).Monic ↔ p.Monic := by rw [monic, leading_coeff_map, ← f.map_one, Function.Injective.eq_iff f.injective, monic] #align polynomial.monic_map_iff Polynomial.monic_map_iff -/ /- warning: polynomial.is_unit_map -> Polynomial.isUnit_map is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} [_inst_2 : Field.{u2} k] (f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))))), Iff (IsUnit.{u2} (Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) (Ring.toMonoid.{u2} (Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) (Polynomial.ring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) (Polynomial.map.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))) f p)) (IsUnit.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} [_inst_2 : Field.{u2} k] (f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))))), Iff (IsUnit.{u2} (Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) (MonoidWithZero.toMonoid.{u2} (Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) (Semiring.toMonoidWithZero.{u2} (Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) (Polynomial.semiring.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))))) (Polynomial.map.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2))) f p)) (IsUnit.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) p) Case conversion may be inaccurate. Consider using '#align polynomial.is_unit_map Polynomial.isUnit_mapₓ'. -/ theorem isUnit_map [Field k] (f : R →+* k) : IsUnit (p.map f) ↔ IsUnit p := by simp_rw [is_unit_iff_degree_eq_zero, degree_map] #align polynomial.is_unit_map Polynomial.isUnit_map #print Polynomial.map_div /- theorem map_div [Field k] (f : R →+* k) : (p / q).map f = p.map f / q.map f := if hq0 : q = 0 then by simp [hq0] else by rw [div_def, div_def, Polynomial.map_mul, map_div_by_monic f (monic_mul_leading_coeff_inv hq0)] <;> simp [coeff_map f] #align polynomial.map_div Polynomial.map_div -/ #print Polynomial.map_mod /- theorem map_mod [Field k] (f : R →+* k) : (p % q).map f = p.map f % q.map f := if hq0 : q = 0 then by simp [hq0] else by rw [mod_def, mod_def, leading_coeff_map f, ← map_inv₀ f, ← map_C f, ← Polynomial.map_mul f, map_mod_by_monic f (monic_mul_leading_coeff_inv hq0)] #align polynomial.map_mod Polynomial.map_mod -/ section open EuclideanDomain /- warning: polynomial.gcd_map -> Polynomial.gcd_map is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} [_inst_2 : Field.{u2} k] (f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))))), Eq.{succ u2} (Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) (EuclideanDomain.gcd.{u2} (Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) (Polynomial.euclideanDomain.{u2} k _inst_2) (fun (a : Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) (b : Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) => Classical.propDecidable (Eq.{succ u2} (Polynomial.{u2} k (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2)))) a b)) (Polynomial.map.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))) f p) (Polynomial.map.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))) f q)) (Polynomial.map.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))) f (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) p q)) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} [_inst_2 : Field.{u2} k] (f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (DivisionRing.toRing.{u2} k (Field.toDivisionRing.{u2} k _inst_2))))), Eq.{succ u2} (Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) (EuclideanDomain.gcd.{u2} (Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u2} k _inst_2) (fun (a : Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) (b : Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) => Classical.propDecidable (Eq.{succ u2} (Polynomial.{u2} k (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2)))) a b)) (Polynomial.map.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2))) f p) (Polynomial.map.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2))) f q)) (Polynomial.map.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u2} k (Semifield.toDivisionSemiring.{u2} k (Field.toSemifield.{u2} k _inst_2))) f (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) p q)) Case conversion may be inaccurate. Consider using '#align polynomial.gcd_map Polynomial.gcd_mapₓ'. -/ theorem gcd_map [Field k] (f : R →+* k) : gcd (p.map f) (q.map f) = (gcd p q).map f := GCD.induction p q (fun x => by simp_rw [Polynomial.map_zero, EuclideanDomain.gcd_zero_left]) fun x y hx ih => by rw [gcd_val, ← map_mod, ih, ← gcd_val] #align polynomial.gcd_map Polynomial.gcd_map end /- warning: polynomial.eval₂_gcd_eq_zero -> Polynomial.eval₂_gcd_eq_zero is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {α : k}, (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α f) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α g) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {g : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {α : k}, (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α f) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α g) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) Case conversion may be inaccurate. Consider using '#align polynomial.eval₂_gcd_eq_zero Polynomial.eval₂_gcd_eq_zeroₓ'. -/ theorem eval₂_gcd_eq_zero [CommSemiring k] {ϕ : R →+* k} {f g : R[X]} {α : k} (hf : f.eval₂ ϕ α = 0) (hg : g.eval₂ ϕ α = 0) : (EuclideanDomain.gcd f g).eval₂ ϕ α = 0 := by rw [EuclideanDomain.gcd_eq_gcd_ab f g, Polynomial.eval₂_add, Polynomial.eval₂_mul, Polynomial.eval₂_mul, hf, hg, MulZeroClass.zero_mul, MulZeroClass.zero_mul, zero_add] #align polynomial.eval₂_gcd_eq_zero Polynomial.eval₂_gcd_eq_zero /- warning: polynomial.eval_gcd_eq_zero -> Polynomial.eval_gcd_eq_zero is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {α : R}, (Eq.{succ u1} R (Polynomial.eval.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) α f) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) -> (Eq.{succ u1} R (Polynomial.eval.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) α g) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) -> (Eq.{succ u1} R (Polynomial.eval.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {f : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {g : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {α : R}, (Eq.{succ u1} R (Polynomial.eval.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) α f) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Eq.{succ u1} R (Polynomial.eval.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) α g) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Eq.{succ u1} R (Polynomial.eval.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) Case conversion may be inaccurate. Consider using '#align polynomial.eval_gcd_eq_zero Polynomial.eval_gcd_eq_zeroₓ'. -/ theorem eval_gcd_eq_zero {f g : R[X]} {α : R} (hf : f.eval α = 0) (hg : g.eval α = 0) : (EuclideanDomain.gcd f g).eval α = 0 := eval₂_gcd_eq_zero hf hg #align polynomial.eval_gcd_eq_zero Polynomial.eval_gcd_eq_zero /- warning: polynomial.root_left_of_root_gcd -> Polynomial.root_left_of_root_gcd is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {α : k}, (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α f) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {g : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {α : k}, (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α f) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) Case conversion may be inaccurate. Consider using '#align polynomial.root_left_of_root_gcd Polynomial.root_left_of_root_gcdₓ'. -/ theorem root_left_of_root_gcd [CommSemiring k] {ϕ : R →+* k} {f g : R[X]} {α : k} (hα : (EuclideanDomain.gcd f g).eval₂ ϕ α = 0) : f.eval₂ ϕ α = 0 := by cases' EuclideanDomain.gcd_dvd_left f g with p hp rw [hp, Polynomial.eval₂_mul, hα, MulZeroClass.zero_mul] #align polynomial.root_left_of_root_gcd Polynomial.root_left_of_root_gcd /- warning: polynomial.root_right_of_root_gcd -> Polynomial.root_right_of_root_gcd is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {α : k}, (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α g) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {g : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {α : k}, (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) -> (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α g) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) Case conversion may be inaccurate. Consider using '#align polynomial.root_right_of_root_gcd Polynomial.root_right_of_root_gcdₓ'. -/ theorem root_right_of_root_gcd [CommSemiring k] {ϕ : R →+* k} {f g : R[X]} {α : k} (hα : (EuclideanDomain.gcd f g).eval₂ ϕ α = 0) : g.eval₂ ϕ α = 0 := by cases' EuclideanDomain.gcd_dvd_right f g with p hp rw [hp, Polynomial.eval₂_mul, hα, MulZeroClass.zero_mul] #align polynomial.root_right_of_root_gcd Polynomial.root_right_of_root_gcd /- warning: polynomial.root_gcd_iff_root_left_right -> Polynomial.root_gcd_iff_root_left_right is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {α : k}, Iff (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) (And (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α f) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))))))))) (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α g) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} k (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2)))))))))) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommSemiring.{u2} k] {ϕ : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u2} k (CommSemiring.toSemiring.{u2} k _inst_2))} {f : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {g : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {α : k}, Iff (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) f g)) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) (And (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α f) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2))))) (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (CommSemiring.toSemiring.{u2} k _inst_2) ϕ α g) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommSemiring.toCommMonoidWithZero.{u2} k _inst_2)))))) Case conversion may be inaccurate. Consider using '#align polynomial.root_gcd_iff_root_left_right Polynomial.root_gcd_iff_root_left_rightₓ'. -/ theorem root_gcd_iff_root_left_right [CommSemiring k] {ϕ : R →+* k} {f g : R[X]} {α : k} : (EuclideanDomain.gcd f g).eval₂ ϕ α = 0 ↔ f.eval₂ ϕ α = 0 ∧ g.eval₂ ϕ α = 0 := ⟨fun h => ⟨root_left_of_root_gcd h, root_right_of_root_gcd h⟩, fun h => eval₂_gcd_eq_zero h.1 h.2⟩ #align polynomial.root_gcd_iff_root_left_right Polynomial.root_gcd_iff_root_left_right /- warning: polynomial.is_root_gcd_iff_is_root_left_right -> Polynomial.isRoot_gcd_iff_isRoot_left_right is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {α : R}, Iff (Polynomial.IsRoot.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.euclideanDomain.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (b : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a b)) f g) α) (And (Polynomial.IsRoot.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) f α) (Polynomial.IsRoot.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) g α)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {f : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {g : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {α : R}, Iff (Polynomial.IsRoot.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (EuclideanDomain.gcd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1) (fun (a : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (b : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Classical.propDecidable (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a b)) f g) α) (And (Polynomial.IsRoot.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) f α) (Polynomial.IsRoot.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) g α)) Case conversion may be inaccurate. Consider using '#align polynomial.is_root_gcd_iff_is_root_left_right Polynomial.isRoot_gcd_iff_isRoot_left_rightₓ'. -/ theorem isRoot_gcd_iff_isRoot_left_right {f g : R[X]} {α : R} : (EuclideanDomain.gcd f g).IsRoot α ↔ f.IsRoot α ∧ g.IsRoot α := root_gcd_iff_root_left_right #align polynomial.is_root_gcd_iff_is_root_left_right Polynomial.isRoot_gcd_iff_isRoot_left_right #print Polynomial.isCoprime_map /- theorem isCoprime_map [Field k] (f : R →+* k) : IsCoprime (p.map f) (q.map f) ↔ IsCoprime p q := by rw [← EuclideanDomain.gcd_isUnit_iff, ← EuclideanDomain.gcd_isUnit_iff, gcd_map, is_unit_map] #align polynomial.is_coprime_map Polynomial.isCoprime_map -/ /- warning: polynomial.mem_roots_map -> Polynomial.mem_roots_map is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} [_inst_2 : CommRing.{u2} k] [_inst_3 : IsDomain.{u2} k (Ring.toSemiring.{u2} k (CommRing.toRing.{u2} k _inst_2))] {f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (CommRing.toRing.{u2} k _inst_2)))} {x : k}, (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))))) -> (Iff (Membership.Mem.{u2, u2} k (Multiset.{u2} k) (Multiset.hasMem.{u2} k) x (Polynomial.roots.{u2} k _inst_2 _inst_3 (Polynomial.map.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (CommRing.toRing.{u2} k _inst_2)) f p))) (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (CommRing.toRing.{u2} k _inst_2)) f x p) (OfNat.ofNat.{u2} k 0 (OfNat.mk.{u2} k 0 (Zero.zero.{u2} k (MulZeroClass.toHasZero.{u2} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} k (NonAssocRing.toNonUnitalNonAssocRing.{u2} k (Ring.toNonAssocRing.{u2} k (CommRing.toRing.{u2} k _inst_2))))))))))) but is expected to have type forall {R : Type.{u1}} {k : Type.{u2}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} [_inst_2 : CommRing.{u2} k] [_inst_3 : IsDomain.{u2} k (Ring.toSemiring.{u2} k (CommRing.toRing.{u2} k _inst_2))] {f : RingHom.{u1, u2} R k (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} k (Ring.toNonAssocRing.{u2} k (CommRing.toRing.{u2} k _inst_2)))} {x : k}, (Ne.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Iff (Membership.mem.{u2, u2} k (Multiset.{u2} k) (Multiset.instMembershipMultiset.{u2} k) x (Polynomial.roots.{u2} k _inst_2 _inst_3 (Polynomial.map.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (CommRing.toRing.{u2} k _inst_2)) f p))) (Eq.{succ u2} k (Polynomial.eval₂.{u1, u2} R k (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Ring.toSemiring.{u2} k (CommRing.toRing.{u2} k _inst_2)) f x p) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CancelCommMonoidWithZero.toCommMonoidWithZero.{u2} k (IsDomain.toCancelCommMonoidWithZero.{u2} k (CommRing.toCommSemiring.{u2} k _inst_2) _inst_3))))))) Case conversion may be inaccurate. Consider using '#align polynomial.mem_roots_map Polynomial.mem_roots_mapₓ'. -/ theorem mem_roots_map [CommRing k] [IsDomain k] {f : R →+* k} {x : k} (hp : p ≠ 0) : x ∈ (p.map f).roots ↔ p.eval₂ f x = 0 := by rw [mem_roots (map_ne_zero hp), is_root, Polynomial.eval_map] <;> infer_instance #align polynomial.mem_roots_map Polynomial.mem_roots_map /- warning: polynomial.root_set_monomial -> Polynomial.rootSet_monomial is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (forall {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (coeFn.{succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))) (fun (_x : LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))) (LinearMap.hasCoeToFun.{u1, u1, u1, u1} R R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))) (Polynomial.monomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) n) a) S _inst_2 _inst_3 _inst_4) (Singleton.singleton.{u2, u2} S (Set.{u2} S) (Set.hasSingleton.{u2} S) (OfNat.ofNat.{u2} S 0 (OfNat.mk.{u2} S 0 (Zero.zero.{u2} S (MulZeroClass.toHasZero.{u2} S (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} S (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} S (NonAssocRing.toNonUnitalNonAssocRing.{u2} S (Ring.toNonAssocRing.{u2} S (CommRing.toRing.{u2} S _inst_2)))))))))))) but is expected to have type forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (forall {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (Semiring.toModule.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Semiring.toModule.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.6190 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u1, u1} R R R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (Semiring.toModule.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Semiring.toModule.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (Polynomial.monomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) n) a) S _inst_2 _inst_3 _inst_4) (Singleton.singleton.{u2, u2} S (Set.{u2} S) (Set.instSingletonSet.{u2} S) (OfNat.ofNat.{u2} S 0 (Zero.toOfNat0.{u2} S (CommMonoidWithZero.toZero.{u2} S (CancelCommMonoidWithZero.toCommMonoidWithZero.{u2} S (IsDomain.toCancelCommMonoidWithZero.{u2} S (CommRing.toCommSemiring.{u2} S _inst_2) _inst_3)))))))) Case conversion may be inaccurate. Consider using '#align polynomial.root_set_monomial Polynomial.rootSet_monomialₓ'. -/ theorem rootSet_monomial [CommRing S] [IsDomain S] [Algebra R S] {n : ℕ} (hn : n ≠ 0) {a : R} (ha : a ≠ 0) : (monomial n a).rootSet S = {0} := by rw [root_set, map_monomial, roots_monomial ((_root_.map_ne_zero (algebraMap R S)).2 ha), Multiset.toFinset_nsmul _ _ hn, Multiset.toFinset_singleton, Finset.coe_singleton] #align polynomial.root_set_monomial Polynomial.rootSet_monomial /- warning: polynomial.root_set_C_mul_X_pow -> Polynomial.rootSet_C_mul_X_pow is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (forall {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) Nat (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHPow.{u1, 0} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.X.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) n)) S _inst_2 _inst_3 _inst_4) (Singleton.singleton.{u2, u2} S (Set.{u2} S) (Set.hasSingleton.{u2} S) (OfNat.ofNat.{u2} S 0 (OfNat.mk.{u2} S 0 (Zero.zero.{u2} S (MulZeroClass.toHasZero.{u2} S (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} S (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} S (NonAssocRing.toNonUnitalNonAssocRing.{u2} S (Ring.toNonAssocRing.{u2} S (CommRing.toRing.{u2} S _inst_2)))))))))))) but is expected to have type forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (forall {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))) (instHMul.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) Nat (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHPow.{u1, 0} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))))) (Polynomial.X.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) n)) S _inst_2 _inst_3 _inst_4) (Singleton.singleton.{u2, u2} S (Set.{u2} S) (Set.instSingletonSet.{u2} S) (OfNat.ofNat.{u2} S 0 (Zero.toOfNat0.{u2} S (CommMonoidWithZero.toZero.{u2} S (CancelCommMonoidWithZero.toCommMonoidWithZero.{u2} S (IsDomain.toCancelCommMonoidWithZero.{u2} S (CommRing.toCommSemiring.{u2} S _inst_2) _inst_3)))))))) Case conversion may be inaccurate. Consider using '#align polynomial.root_set_C_mul_X_pow Polynomial.rootSet_C_mul_X_powₓ'. -/ theorem rootSet_C_mul_X_pow [CommRing S] [IsDomain S] [Algebra R S] {n : ℕ} (hn : n ≠ 0) {a : R} (ha : a ≠ 0) : (C a * X ^ n).rootSet S = {0} := by rw [C_mul_X_pow_eq_monomial, root_set_monomial hn ha] #align polynomial.root_set_C_mul_X_pow Polynomial.rootSet_C_mul_X_pow /- warning: polynomial.root_set_X_pow -> Polynomial.rootSet_X_pow is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) Nat (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHPow.{u1, 0} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.X.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) n) S _inst_2 _inst_3 _inst_4) (Singleton.singleton.{u2, u2} S (Set.{u2} S) (Set.hasSingleton.{u2} S) (OfNat.ofNat.{u2} S 0 (OfNat.mk.{u2} S 0 (Zero.zero.{u2} S (MulZeroClass.toHasZero.{u2} S (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} S (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} S (NonAssocRing.toNonUnitalNonAssocRing.{u2} S (Ring.toNonAssocRing.{u2} S (CommRing.toRing.{u2} S _inst_2))))))))))) but is expected to have type forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) Nat (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHPow.{u1, 0} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))))) (Polynomial.X.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) n) S _inst_2 _inst_3 _inst_4) (Singleton.singleton.{u2, u2} S (Set.{u2} S) (Set.instSingletonSet.{u2} S) (OfNat.ofNat.{u2} S 0 (Zero.toOfNat0.{u2} S (CommMonoidWithZero.toZero.{u2} S (CancelCommMonoidWithZero.toCommMonoidWithZero.{u2} S (IsDomain.toCancelCommMonoidWithZero.{u2} S (CommRing.toCommSemiring.{u2} S _inst_2) _inst_3))))))) Case conversion may be inaccurate. Consider using '#align polynomial.root_set_X_pow Polynomial.rootSet_X_powₓ'. -/ theorem rootSet_X_pow [CommRing S] [IsDomain S] [Algebra R S] {n : ℕ} (hn : n ≠ 0) : (X ^ n : R[X]).rootSet S = {0} := by rw [← one_mul (X ^ n : R[X]), ← C_1, root_set_C_mul_X_pow hn] exact one_ne_zero #align polynomial.root_set_X_pow Polynomial.rootSet_X_pow /- warning: polynomial.root_set_prod -> Polynomial.rootSet_prod is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Field.{u1} R] [_inst_2 : CommRing.{u2} S] [_inst_3 : IsDomain.{u2} S (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] [_inst_4 : Algebra.{u1, u2} R S (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)) (Ring.toSemiring.{u2} S (CommRing.toRing.{u2} S _inst_2))] {ι : Type.{u3}} (f : ι -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (s : Finset.{u3} ι), (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Finset.prod.{u1, u3} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) ι (CommRing.toCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) s f) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))))) -> (Eq.{succ u2} (Set.{u2} S) (Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Finset.prod.{u1, u3} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) ι (CommRing.toCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)))) s f) S _inst_2 _inst_3 _inst_4) (Set.unionᵢ.{u2, succ u3} S ι (fun (i : ι) => Set.unionᵢ.{u2, 0} S (Membership.Mem.{u3, u3} ι (Finset.{u3} ι) (Finset.hasMem.{u3} ι) i s) (fun (H : Membership.Mem.{u3, u3} ι (Finset.{u3} ι) (Finset.hasMem.{u3} ι) i s) => Polynomial.rootSet.{u1, u2} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (f i) S _inst_2 _inst_3 _inst_4)))) but is expected to have type forall {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : Field.{u2} R] [_inst_2 : CommRing.{u3} S] [_inst_3 : IsDomain.{u3} S (Ring.toSemiring.{u3} S (CommRing.toRing.{u3} S _inst_2))] [_inst_4 : Algebra.{u2, u3} R S (Semifield.toCommSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)) (Ring.toSemiring.{u3} S (CommRing.toRing.{u3} S _inst_2))] {ι : Type.{u1}} (f : ι -> (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1))))) (s : Finset.{u1} ι), (Ne.{succ u2} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) (Finset.prod.{u2, u1} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) ι (CommRing.toCommMonoid.{u2} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) (Polynomial.commRing.{u2} R (EuclideanDomain.toCommRing.{u2} R (Field.toEuclideanDomain.{u2} R _inst_1)))) s f) (OfNat.ofNat.{u2} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) 0 (Zero.toOfNat0.{u2} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) (Polynomial.zero.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1))))))) -> (Eq.{succ u3} (Set.{u3} S) (Polynomial.rootSet.{u2, u3} R (EuclideanDomain.toCommRing.{u2} R (Field.toEuclideanDomain.{u2} R _inst_1)) (Finset.prod.{u2, u1} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) ι (CommRing.toCommMonoid.{u2} (Polynomial.{u2} R (DivisionSemiring.toSemiring.{u2} R (Semifield.toDivisionSemiring.{u2} R (Field.toSemifield.{u2} R _inst_1)))) (Polynomial.commRing.{u2} R (EuclideanDomain.toCommRing.{u2} R (Field.toEuclideanDomain.{u2} R _inst_1)))) s f) S _inst_2 _inst_3 _inst_4) (Set.unionᵢ.{u3, succ u1} S ι (fun (i : ι) => Set.unionᵢ.{u3, 0} S (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) (fun (H : Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) => Polynomial.rootSet.{u2, u3} R (EuclideanDomain.toCommRing.{u2} R (Field.toEuclideanDomain.{u2} R _inst_1)) (f i) S _inst_2 _inst_3 _inst_4)))) Case conversion may be inaccurate. Consider using '#align polynomial.root_set_prod Polynomial.rootSet_prodₓ'. -/ theorem rootSet_prod [CommRing S] [IsDomain S] [Algebra R S] {ι : Type _} (f : ι → R[X]) (s : Finset ι) (h : s.Prod f ≠ 0) : (s.Prod f).rootSet S = ⋃ i ∈ s, (f i).rootSet S := by simp only [root_set, ← Finset.mem_coe] rw [Polynomial.map_prod, roots_prod, Finset.bind_toFinset, s.val_to_finset, Finset.coe_bunionᵢ] rwa [← Polynomial.map_prod, Ne, map_eq_zero] #align polynomial.root_set_prod Polynomial.rootSet_prod #print Polynomial.exists_root_of_degree_eq_one /- theorem exists_root_of_degree_eq_one (h : degree p = 1) : ∃ x, IsRoot p x := ⟨-(p.coeff 0 / p.coeff 1), by have : p.coeff 1 ≠ 0 := by rw [← nat_degree_eq_of_degree_eq_some h] <;> exact mt leading_coeff_eq_zero.1 fun h0 => by simpa [h0] using h conv in p => rw [eq_X_add_C_of_degree_le_one (show degree p ≤ 1 by rw [h] <;> exact le_rfl)] <;> simp [is_root, mul_div_cancel' _ this]⟩ #align polynomial.exists_root_of_degree_eq_one Polynomial.exists_root_of_degree_eq_one -/ /- warning: polynomial.coeff_inv_units -> Polynomial.coeff_inv_units is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] (u : Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (n : Nat), Eq.{succ u1} R (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeBase.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Units.hasCoe.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))))) u) n)) (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeBase.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Units.hasCoe.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))))) (Inv.inv.{u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (Units.hasInv.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) u)) n) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] (u : Units.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (n : Nat), Eq.{succ u1} R (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.coeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Units.val.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) u) n)) (Polynomial.coeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Units.val.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (Inv.inv.{u1} (Units.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (Units.instInvUnits.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) u)) n) Case conversion may be inaccurate. Consider using '#align polynomial.coeff_inv_units Polynomial.coeff_inv_unitsₓ'. -/ theorem coeff_inv_units (u : R[X]ˣ) (n : ℕ) : ((↑u : R[X]).coeff n)⁻¹ = (↑u⁻¹ : R[X]).coeff n := by rw [eq_C_of_degree_eq_zero (degree_coe_units u), eq_C_of_degree_eq_zero (degree_coe_units u⁻¹), coeff_C, coeff_C, inv_eq_one_div] split_ifs · rw [div_eq_iff_mul_eq (coeff_coe_units_zero_ne_zero u), coeff_zero_eq_eval_zero, coeff_zero_eq_eval_zero, ← eval_mul, ← Units.val_mul, inv_mul_self] <;> simp · simp #align polynomial.coeff_inv_units Polynomial.coeff_inv_units /- warning: polynomial.monic_normalize -> Polynomial.monic_normalize is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))))) -> (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (fun (_x : MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.normalizationMonoid.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.normalizedGcdMonoid.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b)))))) p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Ne.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Polynomial.Monic.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (fun (_x : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => (fun ([email protected]._hyg.2391 : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))))) (normalize.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b)))))) p)) Case conversion may be inaccurate. Consider using '#align polynomial.monic_normalize Polynomial.monic_normalizeₓ'. -/ theorem monic_normalize (hp0 : p ≠ 0) : Monic (normalize p) := by rw [Ne.def, ← leading_coeff_eq_zero, ← Ne.def, ← isUnit_iff_ne_zero] at hp0 rw [monic, leading_coeff_normalize, normalize_eq_one] apply hp0 #align polynomial.monic_normalize Polynomial.monic_normalize /- warning: polynomial.leading_coeff_div -> Polynomial.leadingCoeff_div is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (LE.le.{0} (WithBot.{0} Nat) (Preorder.toLE.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))))) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) q) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p)) -> (Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasDiv.{u1} R _inst_1)) p q)) (HDiv.hDiv.{u1, u1, u1} R R R (instHDiv.{u1} R (DivInvMonoid.toHasDiv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) q))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (LE.le.{0} (WithBot.{0} Nat) (Preorder.toLE.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)))) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p)) -> (Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instDivPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p q)) (HDiv.hDiv.{u1, u1, u1} R R R (instHDiv.{u1} R (Field.toDiv.{u1} R _inst_1)) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) q))) Case conversion may be inaccurate. Consider using '#align polynomial.leading_coeff_div Polynomial.leadingCoeff_divₓ'. -/ theorem leadingCoeff_div (hpq : q.degree ≤ p.degree) : (p / q).leadingCoeff = p.leadingCoeff / q.leadingCoeff := by by_cases hq : q = 0; · simp [hq] rw [div_def, leading_coeff_mul, leading_coeff_C, leading_coeff_div_by_monic_of_monic (monic_mul_leading_coeff_inv hq) _, mul_comm, div_eq_mul_inv] rwa [degree_mul_leading_coeff_inv q hq] #align polynomial.leading_coeff_div Polynomial.leadingCoeff_div /- warning: polynomial.div_C_mul -> Polynomial.div_C_mul is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasDiv.{u1} R _inst_1)) p (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a) q)) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) a)) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.hasDiv.{u1} R _inst_1)) p q)) but is expected to have type forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instDivPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p (HMul.hMul.{u1, u1, u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (instHMul.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) q)) (HMul.hMul.{u1, u1, u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) a)) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) a)) (instHMul.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) a)) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) a)) (HDiv.hDiv.{u1, u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (instHDiv.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instDivPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)) p q)) Case conversion may be inaccurate. Consider using '#align polynomial.div_C_mul Polynomial.div_C_mulₓ'. -/ theorem div_C_mul : p / (C a * q) = C a⁻¹ * (p / q) := by by_cases ha : a = 0 · simp [ha] simp only [div_def, leading_coeff_mul, mul_inv, leading_coeff_C, C.map_mul, mul_assoc] congr 3 rw [mul_left_comm q, ← mul_assoc, ← C.map_mul, mul_inv_cancel ha, C.map_one, one_mul] #align polynomial.div_C_mul Polynomial.div_C_mul /- warning: polynomial.C_mul_dvd -> Polynomial.C_mul_dvd is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) -> (Iff (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))))) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a) p) q) (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))))) p q)) but is expected to have type forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Iff (Dvd.dvd.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (semigroupDvd.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (SemigroupWithZero.toSemigroup.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (NonUnitalSemiring.toSemigroupWithZero.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (NonUnitalRing.toNonUnitalSemiring.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (NonUnitalCommRing.toNonUnitalRing.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (CommRing.toNonUnitalCommRing.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (EuclideanDomain.toCommRing.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)))))))) (HMul.hMul.{u1, u1, u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (instHMul.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) p) q) (Dvd.dvd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (EuclideanDomain.toCommRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)))))))) p q)) Case conversion may be inaccurate. Consider using '#align polynomial.C_mul_dvd Polynomial.C_mul_dvdₓ'. -/ theorem C_mul_dvd (ha : a ≠ 0) : C a * p ∣ q ↔ p ∣ q := ⟨fun h => dvd_trans (dvd_mul_left _ _) h, fun ⟨r, hr⟩ => ⟨C a⁻¹ * r, by rw [mul_assoc, mul_left_comm p, ← mul_assoc, ← C.map_mul, _root_.mul_inv_cancel ha, C.map_one, one_mul, hr]⟩⟩ #align polynomial.C_mul_dvd Polynomial.C_mul_dvd /- warning: polynomial.dvd_C_mul -> Polynomial.dvd_C_mul is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))))))))) -> (Iff (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))))) p (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) a) q)) (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commRing.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))))))))) p q)) but is expected to have type forall {R : Type.{u1}} {a : R} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))} {q : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommGroupWithZero.toCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Iff (Dvd.dvd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (EuclideanDomain.toCommRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)))))))) p (HMul.hMul.{u1, u1, u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (instHMul.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) (Polynomial.mul'.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) a) q)) (Dvd.dvd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (semigroupDvd.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (EuclideanDomain.toCommRing.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.instEuclideanDomainPolynomialToSemiringToDivisionSemiringToSemifield.{u1} R _inst_1)))))))) p q)) Case conversion may be inaccurate. Consider using '#align polynomial.dvd_C_mul Polynomial.dvd_C_mulₓ'. -/ theorem dvd_C_mul (ha : a ≠ 0) : p ∣ Polynomial.C a * q ↔ p ∣ q := ⟨fun ⟨r, hr⟩ => ⟨C a⁻¹ * r, by rw [mul_left_comm p, ← hr, ← mul_assoc, ← C.map_mul, _root_.inv_mul_cancel ha, C.map_one, one_mul]⟩, fun h => dvd_trans h (dvd_mul_left _ _)⟩ #align polynomial.dvd_C_mul Polynomial.dvd_C_mul /- warning: polynomial.coe_norm_unit_of_ne_zero -> Polynomial.coe_normUnit_of_ne_zero is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Ne.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))))) -> (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeBase.{succ u1, succ u1} (Units.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Units.hasCoe.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))))) (NormalizationMonoid.normUnit.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.normalizationMonoid.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.normalizedGcdMonoid.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b))))) p)) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (Polynomial.leadingCoeff.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p)))) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Ne.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.zero.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) -> (Eq.{succ u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Units.val.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (NormalizationMonoid.normUnit.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b))))) p)) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Inv.inv.{u1} R (Field.toInv.{u1} R _inst_1) (Polynomial.leadingCoeff.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p)))) Case conversion may be inaccurate. Consider using '#align polynomial.coe_norm_unit_of_ne_zero Polynomial.coe_normUnit_of_ne_zeroₓ'. -/ theorem coe_normUnit_of_ne_zero (hp : p ≠ 0) : (normUnit p : R[X]) = C p.leadingCoeff⁻¹ := by have : p.leadingCoeff ≠ 0 := mt leadingCoeff_eq_zero.mp hp simp [CommGroupWithZero.coe_normUnit _ this] #align polynomial.coe_norm_unit_of_ne_zero Polynomial.coe_normUnit_of_ne_zero /- warning: polynomial.normalize_monic -> Polynomial.normalize_monic is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p) -> (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (fun (_x : MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.normalizationMonoid.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.normalizedGcdMonoid.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b)))))) p) p) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Polynomial.Monic.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p) -> (Eq.{succ u1} ((fun ([email protected]._hyg.2391 : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) p) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (fun (_x : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => (fun ([email protected]._hyg.2391 : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))))) (normalize.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b)))))) p) p) Case conversion may be inaccurate. Consider using '#align polynomial.normalize_monic Polynomial.normalize_monicₓ'. -/ theorem normalize_monic (h : Monic p) : normalize p = p := by simp [h] #align polynomial.normalize_monic Polynomial.normalize_monic #print Polynomial.map_dvd_map' /- theorem map_dvd_map' [Field k] (f : R →+* k) {x y : R[X]} : x.map f ∣ y.map f ↔ x ∣ y := if H : x = 0 then by rw [H, Polynomial.map_zero, zero_dvd_iff, zero_dvd_iff, map_eq_zero] else by rw [← normalize_dvd_iff, ← @normalize_dvd_iff R[X], normalize_apply, normalize_apply, coe_norm_unit_of_ne_zero H, coe_norm_unit_of_ne_zero (mt (map_eq_zero f).1 H), leading_coeff_map, ← map_inv₀ f, ← map_C, ← Polynomial.map_mul, map_dvd_map _ f.injective (monic_mul_leading_coeff_inv H)] #align polynomial.map_dvd_map' Polynomial.map_dvd_map' -/ /- warning: polynomial.degree_normalize -> Polynomial.degree_normalize is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (fun (_x : MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) => (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (normalize.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.isDomain.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.normalizationMonoid.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.normalizedGcdMonoid.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b)))))) p)) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (fun (_x : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => (fun ([email protected]._hyg.2391 : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))) (MulOneClass.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (MulZeroOneClass.toMulOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))))))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))) (MonoidWithZero.toMulZeroOneClass.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1)))))))))) (normalize.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (IsDomain.toCancelCommMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.commSemiring.{u1} R (Semifield.toCommSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) (Polynomial.instIsDomainPolynomialToSemiringSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1))) (Polynomial.instNormalizationMonoidPolynomialToSemiringToRingToCancelCommMonoidWithZeroCommSemiringToCommSemiringInstIsDomainPolynomialToSemiringSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1)) (Field.isDomain.{u1} R _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R (Field.toEuclideanDomain.{u1} R _inst_1))) (Field.isDomain.{u1} R _inst_1)) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} R (Semifield.toCommGroupWithZero.{u1} R (Field.toSemifield.{u1} R _inst_1)) (fun (a : R) (b : R) => Classical.propDecidable (Eq.{succ u1} R a b)))))) p)) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p) Case conversion may be inaccurate. Consider using '#align polynomial.degree_normalize Polynomial.degree_normalizeₓ'. -/ theorem degree_normalize : degree (normalize p) = degree p := by simp #align polynomial.degree_normalize Polynomial.degree_normalize #print Polynomial.prime_of_degree_eq_one /- theorem prime_of_degree_eq_one (hp1 : degree p = 1) : Prime p := have : Prime (normalize p) := Monic.prime_of_degree_eq_one (hp1 ▸ degree_normalize) (monic_normalize fun hp0 => absurd hp1 (hp0.symm ▸ by simp <;> exact by decide)) (normalize_associated _).Prime this #align polynomial.prime_of_degree_eq_one Polynomial.prime_of_degree_eq_one -/ /- warning: polynomial.irreducible_of_degree_eq_one -> Polynomial.irreducible_of_degree_eq_one is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p) (OfNat.ofNat.{0} (WithBot.{0} Nat) 1 (OfNat.mk.{0} (WithBot.{0} Nat) 1 (One.one.{0} (WithBot.{0} Nat) (WithBot.hasOne.{0} Nat Nat.hasOne))))) -> (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p) (OfNat.ofNat.{0} (WithBot.{0} Nat) 1 (One.toOfNat1.{0} (WithBot.{0} Nat) (WithBot.one.{0} Nat (CanonicallyOrderedCommSemiring.toOne.{0} Nat Nat.canonicallyOrderedCommSemiring))))) -> (Irreducible.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) p) Case conversion may be inaccurate. Consider using '#align polynomial.irreducible_of_degree_eq_one Polynomial.irreducible_of_degree_eq_oneₓ'. -/ theorem irreducible_of_degree_eq_one (hp1 : degree p = 1) : Irreducible p := (prime_of_degree_eq_one hp1).Irreducible #align polynomial.irreducible_of_degree_eq_one Polynomial.irreducible_of_degree_eq_one /- warning: polynomial.not_irreducible_C -> Polynomial.not_irreducible_c is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] (x : R), Not (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) x)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] (x : R), Not (Irreducible.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) x) (MonoidWithZero.toMonoid.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) x) (Semiring.toMonoidWithZero.{u1} ((fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) x) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (fun (_x : R) => (fun ([email protected]._hyg.2391 : R) => Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))))))))) (Polynomial.C.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) x)) Case conversion may be inaccurate. Consider using '#align polynomial.not_irreducible_C Polynomial.not_irreducible_cₓ'. -/ theorem not_irreducible_c (x : R) : ¬Irreducible (C x) := if H : x = 0 then by rw [H, C_0] exact not_irreducible_zero else fun hx => Irreducible.not_unit hx <| isUnit_C.2 <| isUnit_iff_ne_zero.2 H #align polynomial.not_irreducible_C Polynomial.not_irreducible_c /- warning: polynomial.degree_pos_of_irreducible -> Polynomial.degree_pos_of_irreducible is a dubious translation: lean 3 declaration is forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))}, (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) (Polynomial.ring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1)))) p) -> (LT.lt.{0} (WithBot.{0} Nat) (Preorder.toLT.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))))) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (OfNat.mk.{0} (WithBot.{0} Nat) 0 (Zero.zero.{0} (WithBot.{0} Nat) (WithBot.hasZero.{0} Nat Nat.hasZero)))) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R (Field.toDivisionRing.{u1} R _inst_1))) p)) but is expected to have type forall {R : Type.{u1}} [_inst_1 : Field.{u1} R] {p : Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))}, (Irreducible.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))) (Polynomial.semiring.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1)))))) p) -> (LT.lt.{0} (WithBot.{0} Nat) (Preorder.toLT.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)))) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (Zero.toOfNat0.{0} (WithBot.{0} Nat) (WithBot.zero.{0} Nat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero)))) (Polynomial.degree.{u1} R (DivisionSemiring.toSemiring.{u1} R (Semifield.toDivisionSemiring.{u1} R (Field.toSemifield.{u1} R _inst_1))) p)) Case conversion may be inaccurate. Consider using '#align polynomial.degree_pos_of_irreducible Polynomial.degree_pos_of_irreducibleₓ'. -/ theorem degree_pos_of_irreducible (hp : Irreducible p) : 0 < p.degree := lt_of_not_ge fun hp0 => have := eq_C_of_degree_le_zero hp0 not_irreducible_c (p.coeff 0) <| this ▸ hp #align polynomial.degree_pos_of_irreducible Polynomial.degree_pos_of_irreducible /- warning: polynomial.is_coprime_of_is_root_of_eval_derivative_ne_zero -> Polynomial.isCoprime_of_is_root_of_eval_derivative_ne_zero is a dubious translation: lean 3 declaration is forall {K : Type.{u1}} [_inst_2 : Field.{u1} K] (f : Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (a : K), (Ne.{succ u1} K (Polynomial.eval.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) a (coeFn.{succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} K K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (RingHom.id.{u1} K (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))) (Polynomial.module.{u1, u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Semiring.toModule.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (Polynomial.module.{u1, u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Semiring.toModule.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) (fun (_x : LinearMap.{u1, u1, u1, u1} K K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (RingHom.id.{u1} K (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))) (Polynomial.module.{u1, u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Semiring.toModule.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (Polynomial.module.{u1, u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Semiring.toModule.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) => (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) -> (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (LinearMap.hasCoeToFun.{u1, u1, u1, u1} K K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))) (Polynomial.module.{u1, u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Semiring.toModule.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (Polynomial.module.{u1, u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))) (Semiring.toModule.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (RingHom.id.{u1} K (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) (Polynomial.derivative.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) f)) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (MulZeroClass.toHasZero.{u1} K (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))))))))) -> (IsCoprime.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.commSemiring.{u1} K (Semifield.toCommSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (instHSub.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.sub.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.X.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) (fun (_x : RingHom.{u1, u1} K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) => K -> (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (RingHom.hasCoeToFun.{u1, u1} K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) (Polynomial.C.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) a)) (Polynomial.divByMonic.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)) f (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (instHSub.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.sub.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.X.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) (fun (_x : RingHom.{u1, u1} K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) => K -> (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2))))) (RingHom.hasCoeToFun.{u1, u1} K (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))))) (Polynomial.C.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) a)))) but is expected to have type forall {K : Type.{u1}} [_inst_2 : Field.{u1} K] (f : Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (a : K), (Ne.{succ u1} K (Polynomial.eval.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) a (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} K K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (RingHom.id.{u1} K (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) (Polynomial.module.{u1, u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (Semiring.toModule.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (Polynomial.module.{u1, u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (Semiring.toModule.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (fun (_x : Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) => (fun ([email protected]._hyg.6190 : Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) => Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u1, u1} K K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) (Polynomial.module.{u1, u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (Semiring.toModule.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (Polynomial.module.{u1, u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (Semiring.toModule.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (RingHom.id.{u1} K (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) (Polynomial.derivative.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) f)) (OfNat.ofNat.{u1} K 0 (Zero.toOfNat0.{u1} K (CommMonoidWithZero.toZero.{u1} K (CommGroupWithZero.toCommMonoidWithZero.{u1} K (Semifield.toCommGroupWithZero.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) -> (IsCoprime.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.commSemiring.{u1} K (Semifield.toCommSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))) (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) ((fun ([email protected]._hyg.2391 : K) => Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) a) (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (instHSub.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.sub.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.X.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (fun (_x : K) => (fun ([email protected]._hyg.2391 : K) => Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (RingHom.instRingHomClassRingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))))) (Polynomial.C.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) a)) (Polynomial.divByMonic.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)) f (HSub.hSub.{u1, u1, u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) ((fun ([email protected]._hyg.2391 : K) => Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) a) (Polynomial.{u1} K (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (instHSub.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.sub.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_2)))) (Polynomial.X.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (fun (_x : K) => (fun ([email protected]._hyg.2391 : K) => Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))))) K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))) (RingHom.instRingHomClassRingHom.{u1, u1} K (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) (Polynomial.semiring.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2))))))))) (Polynomial.C.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_2)))) a)))) Case conversion may be inaccurate. Consider using '#align polynomial.is_coprime_of_is_root_of_eval_derivative_ne_zero Polynomial.isCoprime_of_is_root_of_eval_derivative_ne_zeroₓ'. -/ /-- If `f` is a polynomial over a field, and `a : K` satisfies `f' a ≠ 0`, then `f / (X - a)` is coprime with `X - a`. Note that we do not assume `f a = 0`, because `f / (X - a) = (f - f a) / (X - a)`. -/ theorem isCoprime_of_is_root_of_eval_derivative_ne_zero {K : Type _} [Field K] (f : K[X]) (a : K) (hf' : f.derivative.eval a ≠ 0) : IsCoprime (X - C a : K[X]) (f /ₘ (X - C a)) := by refine' Or.resolve_left (EuclideanDomain.dvd_or_coprime (X - C a) (f /ₘ (X - C a)) (irreducible_of_degree_eq_one (Polynomial.degree_X_sub_C a))) _ contrapose! hf' with h have key : (X - C a) * (f /ₘ (X - C a)) = f - f %ₘ (X - C a) := by rw [eq_sub_iff_add_eq, ← eq_sub_iff_add_eq', mod_by_monic_eq_sub_mul_div] exact monic_X_sub_C a replace key := congr_arg derivative key simp only [derivative_X, derivative_mul, one_mul, sub_zero, derivative_sub, mod_by_monic_X_sub_C_eq_C_eval, derivative_C] at key have : X - C a ∣ derivative f := key ▸ dvd_add h (dvd_mul_right _ _) rw [← dvd_iff_mod_by_monic_eq_zero (monic_X_sub_C _), mod_by_monic_X_sub_C_eq_C_eval] at this rw [← C_inj, this, C_0] #align polynomial.is_coprime_of_is_root_of_eval_derivative_ne_zero Polynomial.isCoprime_of_is_root_of_eval_derivative_ne_zero end Field end Polynomial
function engine = kalman_inf_engine(bnet) % KALMAN_INF_ENGINE Inference engine for Linear-Gaussian state-space models. % engine = kalman_inf_engine(bnet) % % 'onodes' specifies which nodes are observed; these must be leaves. % The remaining nodes are all hidden. All nodes must have linear-Gaussian CPDs. % The hidden nodes must be persistent, i.e., they must have children in % the next time slice. In addition, they may not have any children within the current slice, % except to the observed leaves. In other words, the topology must be isomorphic to a standard LDS. % % There are many derivations of the filtering and smoothing equations for Linear Dynamical % Systems in the literature. I particularly like the following % - "From HMMs to LDSs", T. Minka, MIT Tech Report, (no date), available from % ftp://vismod.www.media.mit.edu/pub/tpminka/papers/minka-lds-tut.ps.gz [engine.trans_mat, engine.trans_cov, engine.obs_mat, engine.obs_cov, engine.init_state, engine.init_cov] = ... dbn_to_lds(bnet); % This is where we will store the results between enter_evidence and marginal_nodes engine.one_slice_marginal = []; engine.two_slice_marginal = []; engine = class(engine, 'kalman_inf_engine', inf_engine(bnet));
#!/usr/bin/env python3 import sys import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import LogLocator, NullFormatter from parse_titania_out import parse_tna_out, ParseInfoTNA hatch_pattern = ("//", "/", "\\\\", "\\", "+", "o", ".", "O") def seconda_argument_parser(argv): import argparse parser = argparse.ArgumentParser() parser.add_argument( "--input", "-i", nargs="+", default=[], help="Input file name. This is by default the " "<file.tna.out> output file generated by TITANIA.", required=True, ) parser.add_argument( "--output", "-o", nargs=1, default=None, help="Prefix for the output files.", ) parser.add_argument( "--silent", "-s", action="store_true", help="Prevents command line output of plot script.", ) parser.add_argument( "--ylimits", "-y", default="5,105", help="Saves the minimal kappa value (-y=<val>) or comma separated " "limits for kappa (-y=<val_min>,<val_max>).", ) parser.add_argument( "--xlimits", "-x", default=None, help="Saves the minimal eigenvalue (-x=<val>) or comma separated " "limits for the eigenvalues (-x=<val_min>,<val_max>).", ) parser.add_argument( "--hiderho", action="store_true", help="Prevents the rho (=l5/l6) gap to be printed.", ) parser.add_argument( "--eigenvectors", "-e", action="store_true", help="Plots the eigenvectors of the significant eigenvalues. Significant" "are those eigenvalues, that are larger than the (user defined) cutoff.", ) parser.add_argument( "--hide_eigen_legend", action="store_true", help="Hides the legend of the eigenvector plot.", ) parser.add_argument( "--align", "-a", action="store_true", help="Aligns the eigenmodes." ) parser.add_argument( "--large", "-l", action="store_true", help="Increases the font size." ) return parser.parse_args(argv) def get_tics(tnadat, args): if args.xlimits is not None: cutoff = float(args.xlimits.split(",")[0]) upper_lim = ( 0.0 if len(args.xlimits.split(",")) == 1 else float(args.xlimits.split(",")[1]) ) for set in tnadat: if set["SECONDA"]["SECONDA"][0]["EigVal"] > upper_lim: eval = set["SECONDA"]["SECONDA"][0]["EigVal"] upper_lim = np.power( 10, int(float("{:.0f}".format(np.log10(eval))) + 1) ) xtics_minor = int(np.log10(upper_lim / cutoff)) + 1 else: upper_lim = 0.0 for set in tnadat: if set["SECONDA"]["SECONDA"][0]["EigVal"] > upper_lim: eval = set["SECONDA"]["SECONDA"][0]["EigVal"] cutoff = set["SECONDA"]["Cutoff"] upper_lim = np.power( 10, int(float("{:.0f}".format(np.log10(eval))) + 1) ) xtics_minor = int(np.log10(upper_lim / cutoff)) + 1 xtics_major = int(xtics_minor / 2) return upper_lim, cutoff, xtics_major, xtics_minor def handle_plots(tnafiledata, plot_info, args): if args.large: font = {'weight' : 'bold', 'size' : 22} plt.rc('font', **font) plot_info["num_eig_vals"] = handle_seconda_plots(tnafiledata, plot_info, args) if args.eigenvectors: handle_eigenvector_plots(tnafiledata, plot_info, args) def handle_seconda_plots(tnafiledata, plot_info, args): num_eig_vals = 0 # Prepare SECONDA eigenvalue plot fig, axis = plt.subplots() fig.set_size_inches(11.69, 8.27) # Set labels plt.xlabel(r"Eigenvalue $\lambda$ / Hz$^2$", weight="bold") plt.ylabel(r"Collectivity $\kappa$ / %", weight="bold") # Set limits and generate grid plt.xlim((plot_info["xlim"][0], plot_info["xlim"][1])) plt.ylim((plot_info["ylim"][0], plot_info["ylim"][1])) plt.xscale("log") axis.xaxis.set_major_locator(LogLocator(base=10, numticks=plot_info["xtics_major"])) locmin = LogLocator( base=10.0, subs=(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0), numticks=plot_info["xtics_minor"], ) axis.xaxis.set_minor_locator(locmin) axis.xaxis.set_minor_formatter(NullFormatter()) plt.grid(True, which="minor") plt.grid(which="major", axis="both", color="grey", alpha=0.5, linestyle="--") plt.grid(which="minor", axis="x", color="grey", alpha=0.1, linestyle="--") point_size = 12 if args.large else 7 # Plot rho if len(tnafiledata) == 1: props = dict(boxstyle="round", facecolor="white", alpha=0.5) plt.text( plot_info["xlim"][0] * 5, 0.95 * plot_info["ylim"][1] + 0.05 * plot_info["ylim"][0], plot_info["out_text"], fontsize=14, verticalalignment="top", bbox=props, ) for idx, data in enumerate(tnafiledata): data["eig_vals"] = plot_seconda_data( data, axis, plot_info["ylim"], hatch_pattern[idx], args.hiderho, point_size ) num_eig_vals = ( (len(data["eig_vals"]) - 1) if len(data["eig_vals"]) > num_eig_vals else num_eig_vals ) plt.legend(loc="upper right", fontsize=14) # Plot, save and finish if args.output is None: fig.savefig("seconda.pdf", bbox_inches="tight") else: fig.savefig("".join([args.output[0], ".sec.pdf"]), bbox_inches="tight") return num_eig_vals def handle_eigenvector_plots(tnafiledata, plot_info, args): num_modes = plot_info["num_eig_vals"] if plot_info["num_eig_vals"] >= 5 else 5 plot_info["rows"] = 5 plot_info["cols"] = int(num_modes / plot_info["rows"]) + (1 if num_modes > 5 else 0) fig, ax = plt.subplots(plot_info["rows"], plot_info["cols"]) fig.set_size_inches(1.27 + 7 * plot_info["cols"], 11.69) if args.align: rdc_template=[] for data in tnafiledata: rdc_template=rdc_template + list(set(data["RDCs"]) - set(rdc_template)) rdc_template.sort() plot_info["rdc_template"]=rdc_template for data in tnafiledata: plot_eigenvectors(data, ax, num_modes, plot_info) fig.tight_layout() fig.savefig("eigvecs.pdf", bbox_inches="tight") def align_eigenmodes(mode, rdcs, template): new_mode=np.zeros(len(template)) for idx, rdc in enumerate(template): if rdc in rdcs: new_mode[idx]=mode[rdcs.index(rdc)] else: new_mode[idx]=None return new_mode def plot_eigenvectors(tnafiledata, ax, num_modes, plot_info): xlim = plot_info["xlim"] eig_val = tnafiledata["eig_vals"] eig_vec = tnafiledata["SECONDA"]["Eigenmodes"] props = dict(boxstyle="round", facecolor="white", alpha=0.5) for idx_m, mode in enumerate(eig_vec): for idx_e, element in enumerate(mode): eig_vec[idx_m][idx_e] = element * element if plot_info["cols"] > 1: for col in range(plot_info["cols"]): for row in range(plot_info["rows"]): idx = col * 5 + row if plot_info["align"]: mode=align_eigenmodes(eig_vec[idx], tnafiledata["RDCs"], plot_info["rdc_template"]) else: mode = eig_vec[idx] if idx == 0: legend="".join([tnafiledata["Title"], " ($\lambda$[", str(idx), "]): ", str(tnafiledata["SECONDA"]["SECONDA"][idx]["EigVal"])]) elif idx < (len(tnafiledata["SECONDA"]["SECONDA"]) - 1): legend="".join(["$\lambda$[", str(idx), "]: ", str(tnafiledata["SECONDA"]["SECONDA"][idx]["EigVal"])]) else: legend="".join(["$\lambda$[", str(idx), "]: <", str(plot_info["xlim"][0])]) ax[row, col].plot(mode, 'o-', linewidth=1, markersize=4,label=legend) ax[row, col].text( 0.01, 0.95, "".join(["Eigenmode ", str(idx + 1)]), transform=ax[row, col].transAxes, fontsize=14, verticalalignment="top", horizontalalignment="left", bbox=props, ) ax[row, col].set_ylabel("$|q_i>^2$") ax[row, col].set_xlabel("RDC index i") ax[row, col].set_xlim((0, len(mode) - 1)) if not plot_info["hide_eigen_legend"]: ax[row, col].legend(loc="upper right", fontsize=14) else: for row in range(plot_info["rows"]): idx = row if plot_info["align"]: mode=align_eigenmodes(eig_vec[idx], tnafiledata["RDCs"], plot_info["rdc_template"]) else: mode = eig_vec[idx] if idx == 0: legend="".join([tnafiledata["Title"], " ($\lambda$[", str(idx), "]): ", str(tnafiledata["SECONDA"]["SECONDA"][idx]["EigVal"])]) elif idx < (len(tnafiledata["SECONDA"]["SECONDA"]) - 1): legend="".join(["$\lambda$[", str(idx), "]: ", str(tnafiledata["SECONDA"]["SECONDA"][idx]["EigVal"])]) else: legend="".join(["$\lambda$[", str(idx), "]: <", str(plot_info["xlim"][0])]) ax[row].plot(mode, 'o-', linewidth=1, markersize=4,label=legend) ax[row].text( 0.01, 0.95, "".join(["Eigenmode ", str(idx + 1)]), transform=ax[row].transAxes, fontsize=14, verticalalignment="top", horizontalalignment="left", bbox=props, ) ax[row].set_ylabel("$|q_i>^2$") ax[row].set_xlabel("RDC index i") ax[row].set_xlim((0, len(mode) - 1)) if not plot_info["hide_eigen_legend"]: ax[row].legend(loc="upper right", fontsize=14) return 0 def plot_seconda_data(tnafiledata, axis, ylim, hatch_pat, hiderho, point_size): eig_val = [] kappa = [] cum_sum = [] for seconda_point in tnafiledata["SECONDA"]["SECONDA"]: eig_val.append(seconda_point["EigVal"]) kappa.append(seconda_point["Kappa"]) cum_sum.append(seconda_point["csum"]) (line,) = axis.plot(eig_val, kappa, ".", label=tnafiledata["Title"], markersize=point_size) if not hiderho: idx_max = 4 if len(eig_val) > 5 else len(eig_val) - 1 min = 0 if len(eig_val) < 6 else eig_val[5] plt.fill_between( [eig_val[idx_max], min], ylim[0], ylim[1], alpha=0.0, color=line.get_color(), hatch=hatch_pat, ) return eig_val def main(argv): args = seconda_argument_parser(argv) tnafiledata = [] for input in args.input: tnafiledata.append(parse_tna_out(input, args.silent, ParseInfoTNA("SECONDA","RDCs"))) ylim = [ float(args.ylimits.split(",")[0]), 105.0 if len(args.ylimits.split(",")) == 1 else float(args.ylimits.split(",")[1]), ] if len(tnafiledata) == 1: # Calculate additional parameters rho = ( "undefined" if len(tnafiledata[0]["SECONDA"]["SECONDA"]) < 6 or ( tnafiledata[0]["SECONDA"]["SECONDA"][5]["EigVal"] == tnafiledata[0]["SECONDA"]["Cutoff"] and tnafiledata[0]["SECONDA"]["SECONDA"][5]["EigVal"] == 0 ) else tnafiledata[0]["SECONDA"]["SECONDA"][4]["EigVal"] / tnafiledata[0]["SECONDA"]["SECONDA"][5]["EigVal"] ) out_text = "$\\lambda_1/\\lambda_5$={:.2e}\n$\\lambda_5/\\lambda_6$={}".format( ( tnafiledata[0]["SECONDA"]["SECONDA"][0]["EigVal"] / tnafiledata[0]["SECONDA"]["SECONDA"][4]["EigVal"] ), rho, ) upper_lim, cutoff, xtics_major, xtics_minor = get_tics(tnafiledata, args) plot_info = { "xlim": [cutoff, upper_lim], "xtics_major": xtics_major, "xtics_minor": xtics_minor, "ylim": ylim, "out_text": out_text if "out_text" in locals() else None, "hide_eigen_legend": args.hide_eigen_legend, "align": args.align, } handle_plots(tnafiledata, plot_info, args) plt.close() if __name__ == "__main__": main(sys.argv[1:])
function [v,y,w]=v_nearnonz(x,d) %V_NEARNONZ replace each zero element with the nearest non-zero element [V,Y,W]=v_nearnonz(X,D) % % Inputs: x input vector, matrix or larger array % d dimension to apply filter along [default 1st non-singleton] % % Outputs: v v is the same size as x but with each zero entry replaced by % the nearest non-zero value along dimension d % elements equidistant from two non-zero entries will be taken % from the higher index % y y is the same size as x and gives the index along dimension d % from which the corresponding entry in v was taken % If there are no non-zero entries, then the corresponding % elements of y will be zero. % w w is the same size as x and gives the distance (+ or -) to the % nearest non-zero entry in x % Copyright (C) Mike Brookes 1997 % Version: $Id: v_nearnonz.m 10865 2018-09-21 17:22:45Z dmb $ % % VOICEBOX is a MATLAB toolbox for speech processing. % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 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 can obtain a copy of the GNU General Public License from % http://www.gnu.org/copyleft/gpl.html or by writing to % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% e=size(x); p=prod(e); if nargin<2 % if no dimension given, find the first non-singleton d=find(e>1,1); if ~numel(d) d=1; end end k=e(d); % size of active dimension q=p/k; % size of remainder if d==1 z=reshape(x,k,q); else z=shiftdim(x,d-1); r=size(z); z=reshape(z,k,q); end xx=z~=0; cx=cumsum(xx); [i,j]=find(z); qq=cx(xx); pos=full(sparse(qq,j,i,k,q)); % list the positions of non-zero elements in each column mp=ceil((pos(1:end-1,:)+pos(2:end,:))*0.5); % find the mid point between consecutive non-zero elements [i2,j2]=find(pos(2:end,:)>0); zz=1+cumsum(full(sparse(mp(pos(2:end,:)>0),j2,1,k,q))); y=pos(zz+repmat((0:q-1)*k,k,1)); v=z(max(y,1)+repmat((0:q-1)*k,k,1)); w=y-repmat((1:k)',1,q); w(y==0)=0; if d==1 y=reshape(y,e); v=reshape(v,e); w=reshape(w,e); else y=shiftdim(reshape(y,r),length(e)+1-d); v=shiftdim(reshape(v,r),length(e)+1-d); w=shiftdim(reshape(w,r),length(e)+1-d); end
# Internal stability of Runge-Kutta methods, revisited We previously looked at internal stability of some classes of Runge--Kutta methods in [this notebook](https://github.com/ketch/nodepy/blob/master/examples/Internal_stability.ipynb), also posted on my blog [here](http://www.davidketcheson.info/2012/10/11/Internal_stability.html). There I gave a formula for the internal stability polynomials based on the Butcher coefficients of the method. It turns out that internal stability depends on the manner in which a Runge--Kutta method is implemented. That is, two mathematically equivalent implementations of the same method can have quite different internal stability polynomials and internal amplification factors. This is rather surprising, since the *stability polynomial* that we traditionally study doesn't depend on the particular implementation. A general form for implementations of Runge--Kutta methods is the *modified Shu-Osher form*, which was introduced in order to facilitate analysis of strong stability preserving RK methods: \begin{align} y_1 & = u^n \end{align} ```python from nodepy import rk import numpy as np from matplotlib import pyplot as plt rk4 = rk.loadRKM('RK44') ssprk4 = rk.loadRKM('SSP104') print(rk4) ssprk4.print_shu_osher() ``` ## Absolute stability regions First we can use NodePy to plot the region of absolute stability for each method. The absolute stability region is the set <center>$\\{ z \in C : |\phi (z)|\le 1 \\}$</center> where $\phi(z)$ is the *stability function* of the method: <center>$1 + z b^T (I-zA)^{-1}$</center> If we solve $u'(t) = \lambda u$ with a given method, then $z=\lambda \Delta t$ must lie inside this region or the computation will be unstable. ```python p,q = rk4.stability_function() print(p) h1=rk4.plot_stability_region() ``` ```python p,q = ssprk4.stability_function() print(p) h2=ssprk4.plot_stability_region() ``` # Internal stability The stability function tells us by how much errors from one step are amplified in the next one. This is important since we introduce truncation errors at every step. However, we also introduce roundoff errors at the each stage within a step. Internal stability tells us about the growth of those. Internal stability is typically less important than (step-by-step) absolute stability for two reasons: - Roundoff errors are typically much smaller than truncation errors, so moderate amplification of them typically is not significant - Although the propagation of stage errors within a step is governed by internal stability functions, in later steps these errors are propagated according to the (principal) stability function Nevertheless, in methods with many stages, internal stability can play a key role. Questions: *In the solution of PDEs, large spatial truncation errors enter at each stage. Does this mean internal stability becomes more significant? How does this relate to stiff accuracy analysis and order reduction?* ## Internal stability functions We can write the equations of a Runge-Kutta method compactly as \begin{align} y & = u^n e + h A F(y) \\ u^{n+1} & = u^n + h b^T F(y), \end{align} where $y$ is the vector of stage values, $u^n$ is the previous step solution, $e$ is a vector with all entries equal to 1, $h$ is the step size, $A$ and $b$ are the coefficients in the Butcher tableau, and $F(y)$ is the vector of stage derivatives. In floating point arithmetic, roundoff errors will be made at each stage. Representing these errors by a vector $r$, we have <center>$y = u^n e + h A F(y) + r.$</center> Considering the test problem $F(y)=\lambda y$ and solving for $y$ gives <center>$y = u^n (I-zA)^{-1}e + (I-zA)^{-1}r,$</center> where $z=h\lambda$. Substituting this result in the equation for $u^{n+1}$ gives <center>$u^{n+1} = u^n (1 + zb^T(I-zA)^{-1}e) + zb^T(I-zA)^{-1}r = \psi(z) u^n + \theta(z)^T r.$</center> Here $\psi(z)$ is the *stability function* of the method, that we already encountered above. Meanwhile, the vector $\theta(z)$ contains the *internal stability functions* that govern the amplification of roundoff errors $r$ within a step: <center>$\theta(z) = z b^T (I-zA)^{-1}.$</center> Let's compute $\theta$ for the classical RK4 method: ```python theta=rk4.internal_stability_polynomials() theta ``` ```python for theta_j in theta: print(theta_j) ``` Thus the roundoff errors in the first stage are amplified by a factor $z^4/24 + z^3/12 + z^2/6 + z/6$, while the errors in the last stage are amplified by a factor $z/6$. ## Internal instability Usually internal stability is unimportant since it relates to amplification of roundoff errors, which are very small. Let's think about when things can go wrong in terms of internal instability. If $|\theta(z)|$ is of the order $1/\epsilon_{machine}$, then roundoff errors could be amplified so much that they destroy the accuracy of the computation. More specifically, we should be concerned if $|\theta(z)|$ is of the order $tol/\epsilon_{machine}$ where $tol$ is our desired error tolerance. Of course, we only care about values of $z$ that lie inside the absolute stability region $S$, since internal stability won't matter if the computation is not absolutely stable. We can get some idea about the amplification of stage errors by plotting the curves $|\theta(z)|=1$ along with the stability region. Ideally these curves will all lie outside the stability region, so that all stage errors are damped. ```python rk4.internal_stability_plot() ``` ```python ssprk4.internal_stability_plot() ``` For both methods, we see that some of the curves intersect the absolute stability region, so some stage errors are amplified. But by how much? We'd really like to know the maximum amplification of the stage errors under the condition of absolute stability. We therefore define the *maximum internal amplification factor* $M$: <center>$M = \max_j \max_{z \in S} |\theta_j(z)|$</center> ```python print(rk4.maximum_internal_amplification()) print(ssprk4.maximum_internal_amplification()) ``` We see that both methods have small internal amplification factors, so internal stability is not a concern in either case. This is not surprising for the method with only four stages; it is a surprisingly good property of the method with ten stages. Questions: *Do SSP RK methods always (necessarily) have small amplification factors? Can we prove it?* Now let's look at some methods with many stages. ## Runge-Kutta Chebyshev methods The paper of Verwer, Hundsdorfer, and Sommeijer deals with RKC methods, which can have very many stages. The construction of these methods is implemented in NodePy, so let's take a look at them. The functions `RKC1(s)` and `RKC2(s)` construct RKC methods of order 1 and 2, respectively, with $s$ stages. ```python s=4 rkc = rk.RKC1(s) print(rkc) ``` ```python rkc.internal_stability_plot() ``` It looks like there could be some significant internal amplification here. Let's see: ```python rkc.maximum_internal_amplification() ``` Nothing catastrophic. Let's try a larger value of $s$: ```python s = 20 rkc = rk.RKC1(s) rkc.maximum_internal_amplification(formula='pow') ``` As promised, these methods seem to have good internal stability properties. What about the second-order methods? ```python s = 20 rkc = rk.RKC2(s) rkc.maximum_internal_amplification(formula='pow') ``` Again, nothing catastrophic. We could take $s$ much larger than 20, but the calculations get to be rather slow (in Python) and since we're using floating point arithmetic, the accuracy deteriorates. Remark: *we could do the calculations in exact arithmetic using Sympy, but things would get even slower. Perhaps there are some optimizations that could be done to speed this up. Or perhaps we should use Mathematica if we need to do this kind of thing.* Remark 2: *of course, for the RKC methods the internal stability polynomials are shifted Chebyshev polynomials. So we could evaluate them directly in a stable manner using the three-term recurrence (or perhaps scipy's special functions library). This would also be a nice check on the calculations above.* ## Other methods with many stages Three other classes of methods with many stages have been implemented in NodePy: - SSP families - Integral deferred correction (IDC) methods - Extrapolation methods ### SSP Families ```python s = 20 ssprk = rk.SSPRK2(s) ssprk.internal_stability_plot() ssprk.maximum_internal_amplification(formula='pow') ``` ```python s = 25 # # of stages ssprk = rk.SSPRK3(s) ssprk.internal_stability_plot() ssprk.maximum_internal_amplification(formula='pow') ``` The SSP methods seem to have excellent internal stability properties. ### IDC methods ```python p = 6 #order idc = rk.DC(p-1) print(len(idc)) idc.internal_stability_plot() idc.maximum_internal_amplification(formula='pow') ``` IDC methods also seem to have excellent internal stability. ### Extrapolation methods ```python p = 6 #order ex = rk.extrap(p) print(len(ex)) ex.internal_stability_plot() ex.maximum_internal_amplification() ``` Not so good. Let's try a method with even more stages (this next computation will take a while; go stretch your legs). ```python p = 10 #order ex = rk.extrap(p) print(len(ex)) ex.maximum_internal_amplification() ``` Now we're starting to see something that might cause trouble, especially since such high order extrapolation methods are usually used when extremely tight error tolerances are required. Internal amplification will cause a loss of about 5 digits of accuracy here, so the best we can hope for is about 10 digits of accuracy in double precision. Higher order extrapolation methods will make things even worse. How large are their amplification factors? (Really long calculation here...) ```python pmax = 12 ampfac = np.zeros(pmax+1) for p in range(1,pmax+1): ex = rk.extrap(p) ampfac[p] = ex.maximum_internal_amplification()[0] print(p, ampfac[p]) ``` ```python plt.semilogy(ampfac,linewidth=3) plt.xlabel(r"Order $p$") plt.ylabel(r"Amplification factor") ``` We see roughly geometric growth of the internal amplification factor as a function of the order $p$. It seems clear that very high order extrapolation methods applied to problems with high accuracy requirements will fall victim to internal stability issues.
(** Conditions to lift a biadjunction to a displayed biadjunction to a dependent product. *) Require Import UniMath.Foundations.All. Require Import UniMath.MoreFoundations.All. Require Import UniMath.CategoryTheory.Core.Categories. Require Import UniMath.CategoryTheory.Core.Functors. Require Import UniMath.CategoryTheory.DisplayedCats.Core. Require Import UniMath.Bicategories.Core.Bicat. Import Bicat.Notations. Require Import UniMath.Bicategories.Core.Invertible_2cells. Require Import UniMath.Bicategories.Core.Univalence. Require Import UniMath.Bicategories.Core.BicategoryLaws. Require Import UniMath.Bicategories.Morphisms.Adjunctions. Require Import UniMath.Bicategories.PseudoFunctors.Display.Base. Require Import UniMath.Bicategories.PseudoFunctors.Display.Map1Cells. Require Import UniMath.Bicategories.PseudoFunctors.Display.Map2Cells. Require Import UniMath.Bicategories.PseudoFunctors.Display.Identitor. Require Import UniMath.Bicategories.PseudoFunctors.Display.Compositor. Require Import UniMath.Bicategories.PseudoFunctors.Display.PseudoFunctorBicat. Require Import UniMath.Bicategories.PseudoFunctors.PseudoFunctor. Import PseudoFunctor.Notations. Require Import UniMath.Bicategories.PseudoFunctors.Biadjunction. Require Import UniMath.Bicategories.PseudoFunctors.Examples.Identity. Require Import UniMath.Bicategories.PseudoFunctors.Examples.Composition. Require Import UniMath.Bicategories.Transformations.PseudoTransformation. Require Import UniMath.Bicategories.Transformations.Examples.Whiskering. Require Import UniMath.Bicategories.Transformations.Examples.Unitality. Require Import UniMath.Bicategories.Transformations.Examples.Associativity. Require Import UniMath.Bicategories.Modifications.Modification. Require Import UniMath.Bicategories.DisplayedBicats.DispBicat. Require Import UniMath.Bicategories.DisplayedBicats.Examples.DisplayedCatToBicat. Require Import UniMath.Bicategories.DisplayedBicats.Examples.Add2Cell. Require Import UniMath.Bicategories.DisplayedBicats.DispPseudofunctor. Require Import UniMath.Bicategories.DisplayedBicats.DispTransformation. Require Import UniMath.Bicategories.DisplayedBicats.DispModification. Require Import UniMath.Bicategories.DisplayedBicats.DispBuilders. Require Import UniMath.Bicategories.DisplayedBicats.DispBiadjunction. Require Import UniMath.Bicategories.DisplayedBicats.Examples.DispDepProd. Local Open Scope cat. Section LiftPseudofunctor. Context {B₁ B₂ : bicat} (F : psfunctor B₁ B₂) {I : UU} {D₁ : I → disp_bicat B₁} {D₂ : I → disp_bicat B₂} (FF : ∏ (i : I), disp_psfunctor (D₁ i) (D₂ i) F) (D₂_locally_prop : ∏ (i : I), disp_2cells_isaprop (D₂ i)) (D₂_locally_groupoid : ∏ (i : I), disp_locally_groupoid (D₂ i)). Definition disp_depprod_psfunctor : disp_psfunctor (disp_depprod_bicat I D₁) (disp_depprod_bicat I D₂) F. Proof. use make_disp_psfunctor. - apply disp_2cells_isaprop_depprod. exact D₂_locally_prop. - apply disp_locally_groupoid_depprod. exact D₂_locally_groupoid. - exact (λ x xx i, FF i x (xx i)). - exact (λ x y f xx yy ff i, pr121 (FF i) _ _ _ _ _ (ff i)). - exact (λ x y f g α xx yy ff gg αα i, pr1 (pr221 (FF i)) _ _ _ _ _ _ _ _ _ (αα i)). - refine (λ x xx, _). exact (λ i, pr12 (pr221 (FF i)) _ (xx i)). - refine (λ x y z f g xx yy zz ff gg, _). exact (λ i, pr22 (pr221 (FF i)) _ _ _ _ _ _ _ _ (ff i) (gg i)). Defined. End LiftPseudofunctor. Section LiftBiadjunction. Context {B₁ B₂ : bicat} {L : psfunctor B₁ B₂} (R : left_biadj_data L) {I : UU} {D₁ : I → disp_bicat B₁} {D₂ : I → disp_bicat B₂} (LL : ∏ (i : I), disp_psfunctor (D₁ i) (D₂ i) L) (RR : ∏ (i : I), disp_left_biadj_data _ _ R (LL i)) (D₁_locally_prop : ∏ (i : I), disp_2cells_isaprop (D₁ i)) (D₁_locally_groupoid : ∏ (i : I), disp_locally_groupoid (D₁ i)) (D₂_locally_prop : ∏ (i : I), disp_2cells_isaprop (D₂ i)) (D₂_locally_groupoid : ∏ (i : I), disp_locally_groupoid (D₂ i)). Definition disp_depprod_biadjunction : disp_left_biadj_data _ _ R (disp_depprod_psfunctor L LL D₂_locally_prop D₂_locally_groupoid). Proof. use tpair. - use tpair. + exact (disp_depprod_psfunctor R (λ i, pr11 (RR i)) D₁_locally_prop D₁_locally_groupoid). + split. * use make_disp_pstrans. ** apply disp_2cells_isaprop_depprod. exact D₁_locally_prop. ** apply disp_locally_groupoid_depprod. exact D₁_locally_groupoid. ** exact (λ x xx i, pr121 (RR i) _ (xx i)). ** exact (λ x y f xx yy ff i, pr21 (pr121 (RR i)) _ _ _ _ _ (ff i)). * use make_disp_pstrans. ** apply disp_2cells_isaprop_depprod. exact D₂_locally_prop. ** apply disp_locally_groupoid_depprod. exact D₂_locally_groupoid. ** exact (λ x xx i, pr221 (RR i) _ (xx i)). ** exact (λ x y f xx yy ff i, pr21 (pr221 (RR i)) _ _ _ _ _ (ff i)). - split. + use make_disp_invmodification. * apply disp_2cells_isaprop_depprod. exact D₂_locally_prop. * apply disp_locally_groupoid_depprod. exact D₂_locally_groupoid. * exact (λ x xx i, pr1 (pr12 (RR i)) _ (xx i)). + use make_disp_invmodification. * apply disp_2cells_isaprop_depprod. exact D₁_locally_prop. * apply disp_locally_groupoid_depprod. exact D₁_locally_groupoid. * exact (λ x xx i, pr1 (pr22 (RR i)) _ (xx i)). Defined. End LiftBiadjunction.
Require Import Crypto.Arithmetic.PrimeFieldTheorems. Require Import Crypto.Specific.solinas32_2e129m25_6limbs.Synthesis. (* TODO : change this to field once field isomorphism happens *) Definition freeze : { freeze : feBW_tight -> feBW_limbwidths | forall a, phiBW_limbwidths (freeze a) = phiBW_tight a }. Proof. Set Ltac Profiling. Time synthesize_freeze (). Show Ltac Profile. Time Defined. Print Assumptions freeze.
(******************************************************************************) (* Copyright (c) 2015 Daniel Lustig, Princeton University *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"), *) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included in *) (* all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (******************************************************************************) Require Import List. Require Import Arith. Require Import String. Require Import Ascii. Import ListNotations. Open Scope string_scope. Definition tab := String (ascii_of_nat 9) "". Definition newline := String (ascii_of_nat 10) "". Definition quote := String (ascii_of_nat 34) "". Definition stringOfNat'' (n : nat) : string := String (ascii_of_nat (nat_of_ascii "0" + n)) "". Fixpoint stringOfNat' (n tens ones : nat) : string := match (n, tens, ones) with | (S n', _, S (S (S (S (S (S (S (S (S (S ones')))))))))) => stringOfNat' n' (S tens) ones' | (S n', S t', _) => stringOfNat' n' 0 tens ++ stringOfNat'' ones | (S n', 0, _) => stringOfNat'' ones | _ => "(overflow)" end. Definition stringOfNat (n : nat) : string := stringOfNat' (S n) 0 n. Definition StringOf (l : list string) : string := fold_left append l "". Fixpoint beq_string (s1 s2 : string) : bool := match (s1, s2) with | (String h1 t1, String h2 t2) => if beq_nat (nat_of_ascii h1) (nat_of_ascii h2) then beq_string t1 t2 else false | (EmptyString, EmptyString) => true | _ => false end.
[STATEMENT] lemma isGlb_dual_isLub: "isGlb S cl = isLub S (dual cl)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. isGlb S cl = isLub S (dual cl) [PROOF STEP] by (simp add: isLub_def isGlb_def dual_def converse_unfold)
fibtests <- read.csv('./history/benchmark_13nov2017_n4050i3.csv') plot( x=fibtests$n_arg, y=fibtests$recursive_seconds, type='o', col='red', main='Benchmarking de algoritmos Fibonacci', xlab='Valor do argumento n da função', ylab='Segundos levados executar 10^6 de vezes', ylim=c(0, 10) ) lines( x=fibtests$n_arg, y=fibtests$iterative_seconds, type='o', col='green' ) lines( x=fibtests$n_arg, y=fibtests$explicit_seconds, type='o', col='blue' ) legend( x=30, y=10, c('Recursivo', 'Iterativo', 'Fechado'), fill=c('red', 'green', 'blue') )
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From: On the Bright Side of Type Classes: Instances Arguments in -- Agda (ICFP'11). module InstanceArguments where open import Data.Bool.Base open import Data.Nat hiding ( equal ) renaming ( suc to succ ) -- Note: Agda doesn't have a primitive function primBoolEquality. boolEq : Bool → Bool → Bool boolEq true true = true boolEq false false = true {-# CATCHALL #-} boolEq _ _ = false natEq : ℕ → ℕ → Bool natEq zero zero = true natEq (succ m) (succ n) = natEq m n {-# CATCHALL #-} natEq _ _ = false record Eq (t : Set) : Set where field equal : t → t → Bool instance eqInstanceBool : Eq Bool eqInstanceBool = record { equal = boolEq } eqInstanceℕ : Eq ℕ eqInstanceℕ = record { equal = natEq } equal : {t : Set} → {{eqT : Eq t}} → t → t → Bool equal {{eqT}} = Eq.equal eqT test : Bool test = equal 5 3 ∨ equal true false
In July 2002 , Beyoncé had already recorded several songs which would appear on Dangerously in Love . Columbia Records planned to release the album in October 2002 ; however the release was postponed several times to capitalize on the success of American rapper Nelly 's single " Dilemma " ( 2002 ) , which features Destiny 's Child singer Kelly Rowland . These delays allowed Beyoncé to record more songs for the album .
Load LFindLoad. From lfind Require Import LFind. From QuickChick Require Import QuickChick. From adtind Require Import goal33. Derive Show for natural. Derive Arbitrary for natural. Instance Dec_Eq_natural : Dec_Eq natural. Proof. dec_eq. Qed. Lemma conj10eqsynthconj4 : forall (lv0 : natural) (lv1 : natural), (@eq natural (plus (mult lv0 (Succ lv1)) (Succ lv1)) (plus lv1 (Succ (mult (Succ lv1) lv0)))). Admitted. QuickChick conj10eqsynthconj4.
In June 2010 , the Home Office announced it would review the use of FITs during public order policing . The move was influenced by the discovery that information collected by FITs , included that which was unrelated to suspected crimes , for example recording who made speeches at demonstrations .
# Optimization Exercise 1 ## Imports ```python %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt ``` ## Hat potential The following potential is often used in Physics and other fields to describe symmetry breaking and is often known as the "hat potential": $$ V(x) = -a x^2 + b x^4 $$ Write a function `hat(x,a,b)` that returns the value of this function: ```python # YOUR CODE HERE def hat(x, a, b): return (-a * x**2) + (b * x**4) ``` ```python assert hat(0.0, 1.0, 1.0)==0.0 assert hat(0.0, 1.0, 1.0)==0.0 assert hat(1.0, 10.0, 1.0)==-9.0 ``` Plot this function over the range $x\in\left[-3,3\right]$ with $b=1.0$ and $a=5.0$: ```python a = 5.0 b = 1.0 x = np.linspace(-3, 3, 100) plt.plot(x, hat(x, a, b)) ``` ```python # YOUR CODE HERE raise NotImplementedError() ``` ```python assert True # leave this to grade the plot ``` Write code that finds the two local minima of this function for $b=1.0$ and $a=5.0$. * Use `scipy.optimize.minimize` to find the minima. You will have to think carefully about how to get this function to find both minima. * Print the x values of the minima. * Plot the function as a blue line. * On the same axes, show the minima as red circles. * Customize your visualization to make it beatiful and effective. ```python # YOUR CODE HERE #specifies a number of divisions which the function will look for a minimum on each. #more divisions = more accurate def minima(divisions, function, a, b): critpoints = [] for n in range(0, divisions): sectionx = np.linspace(n*(6/divisions) - 3, (n+1)*(6/divisions) - 3, 100) sectiony = function(np.linspace(n*(6/divisions) - 3, (n+1)*(6/divisions) - 3, 100), a, b) #make sure the minimum is not on the ends if np.amin(sectiony) != sectiony[0] and np.amin(sectiony) != sectiony[-1]: minpt = np.argmin(sectiony) critpoints.append(sectionx[minpt]) return critpoints ``` ```python minpts = minima(100, hat, a, b) ``` ```python x = np.linspace(-3, 3, 100) plt.plot(x, hat(x, a, b)) plt.scatter(minpts[0], hat(minpts[0], a, b), color = "r") plt.scatter(minpts[1], hat(minpts[1], a, b), color = "r") plt.xlabel("X") plt.ylabel("V(x)") print("Minimums: ", minpts) ``` ```python assert True # leave this for grading the plot ``` To check your numerical results, find the locations of the minima analytically. Show and describe the steps in your derivation using LaTeX equations. Evaluate the location of the minima using the above parameters. To find the minima, we can take the derivative of the function and set it to zero, finding the critical points. \begin{equation} V'(x) = -2ax + 4bx^3 = 0 \end{equation} Dividing both sides by x gives us a quadratic, and we can put in the given values of a and b: \begin{equation} -10 + 4x^2 = 0 \end{equation} Solving this gives us the intercepts, where V'(x) = 0. \begin{equation} x = \pm \sqrt{\frac{5}{2}} \end{equation} Which approximates to: \begin{equation} x = \pm 1.5811 \end{equation} And this agrees with the program's results. ```python ```
/** * Swaggy Jenkins * Jenkins API clients generated from Swagger / Open API specification * * OpenAPI spec version: 1.1.1 * Contact: [email protected] * * NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ #include "PipelineRunImpllinks.h" #include <string> #include <sstream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> using boost::property_tree::ptree; using boost::property_tree::read_json; using boost::property_tree::write_json; namespace org { namespace openapitools { namespace server { namespace model { PipelineRunImpllinks::PipelineRunImpllinks() { m__class = ""; } PipelineRunImpllinks::~PipelineRunImpllinks() { } std::string PipelineRunImpllinks::toJsonString() { std::stringstream ss; ptree pt; pt.put("_class", m__class); write_json(ss, pt, false); return ss.str(); } void PipelineRunImpllinks::fromJsonString(std::string const& jsonString) { std::stringstream ss(jsonString); ptree pt; read_json(ss,pt); m__class = pt.get("_class", ""); } std::shared_ptr<Link> PipelineRunImpllinks::getNodes() const { return m_Nodes; } void PipelineRunImpllinks::setNodes(std::shared_ptr<Link> value) { m_Nodes = value; } std::shared_ptr<Link> PipelineRunImpllinks::getLog() const { return m_Log; } void PipelineRunImpllinks::setLog(std::shared_ptr<Link> value) { m_Log = value; } std::shared_ptr<Link> PipelineRunImpllinks::getSelf() const { return m_Self; } void PipelineRunImpllinks::setSelf(std::shared_ptr<Link> value) { m_Self = value; } std::shared_ptr<Link> PipelineRunImpllinks::getActions() const { return m_Actions; } void PipelineRunImpllinks::setActions(std::shared_ptr<Link> value) { m_Actions = value; } std::shared_ptr<Link> PipelineRunImpllinks::getSteps() const { return m_Steps; } void PipelineRunImpllinks::setSteps(std::shared_ptr<Link> value) { m_Steps = value; } std::string PipelineRunImpllinks::getClass() const { return m__class; } void PipelineRunImpllinks::setClass(std::string value) { m__class = value; } } } } }
#ifdef TIMER # define TIMER_START(tname) call domain%timer%timer_start(tname) # define TIMER_STOP(tname) call domain%timer%timer_end(tname) #else # define TIMER_START(tname) # define TIMER_STOP(tname) #endif module local_routines use global_mod, only: dp, ip, charlen, wall_elevation use domain_mod, only: domain_type, STG, UH, VH, ELV use read_raster_mod, only: multi_raster_type !gdal_raster_dataset_type use which_mod, only: which use file_io_mod, only: read_csv_into_array use stop_mod, only: generic_stop implicit none contains subroutine set_initial_conditions_generic(domain, input_elevation_raster, & input_stage_raster, hazard_points_file, skip_header,& adaptive_computational_extents, negative_elevation_raster) class(domain_type), target, intent(inout):: domain character(len=charlen), intent(in):: input_elevation_raster, & input_stage_raster, hazard_points_file integer(ip), intent(in):: skip_header logical, intent(in):: adaptive_computational_extents, negative_elevation_raster integer(ip):: i, j real(dp), allocatable:: x(:), y(:), xy_coords(:,:) integer(ip):: xl, xU, yl, yU type(multi_raster_type):: elevation_data, stage_data ! Make space for x/y coordinates, at which we will look-up the rasters allocate(x(domain%nx(1)), y(domain%nx(1))) x = domain%x print*, "Setting elevation ..." call elevation_data%initialise([input_elevation_raster]) print*, ' bounding box of input elevation: ' print*, ' ', elevation_data%lowerleft print*, ' ', elevation_data%upperright ! Allow periodic elevation data where( x < elevation_data%lowerleft(1) ) x = x + 360.0_dp end where where( x > elevation_data%upperright(1) ) x = x - 360.0_dp end where do j = 1, domain%nx(2) y = domain%y(j) call elevation_data%get_xy(x, y, domain%U(:,j,ELV), domain%nx(1), & bilinear=1_ip) if(negative_elevation_raster) domain%U(:,j,ELV) = -domain%U(:,j,ELV) end do call elevation_data%finalise() print*, "Setting stage ..." ! Set stage -- zero outside of initial condition file range domain%U(:,:,[STG,UH,VH]) = 0.0_dp CALL stage_data%initialise([input_stage_raster]) ! Do not allow periodic stage data (unlike elevation, since the latter has to be set ! everywhere, whereas the former will just be set inside the provided data and use ! the default 0 everywhere else) x = domain%x ! Get the x indices which are inside the stage raster ! We permit this to only cover a small part of the domain xl = count(domain%x < stage_data%lowerleft(1)) + 1 xU = count(domain%x < stage_data%upperright(1)) yl = count(domain%y < stage_data%lowerleft(2)) + 1 yU = count(domain%y < stage_data%upperright(2)) print*, ' bounding box of input stage: ' print*, ' ', stage_data%lowerleft print*, ' ', stage_data%upperright print*, ' xl: ', xl, ' xU: ', xU print*, ' yl: ', yl, ' yU: ', yU if(xl > 0 .AND. xU > 0) then do j = 1, domain%nx(2) if((domain%y(j) > stage_data%lowerleft(2)) .AND. & (domain%y(j) < stage_data%upperright(2))) then y(xl:xU) = domain%y(j) CALL stage_data%get_xy(x(xl:xU), y(xl:xU), & domain%U(xl:xU, j, STG), (xU-xl+1)) end if end do end if call stage_data%finalise() print*, ' max stage: ', maxval(domain%U(:,:,STG)) print*, ' min stage: ', minval(domain%U(:,:,STG)) ! By updating the boundary, we prevent changes to the elevation that can occur ! e.g. if the elevation could be updated at edges by the boundary, call domain%update_boundary() ! Ensure stage >= elevation domain%U(:,:,STG) = max(domain%U(:,:,STG), domain%U(:,:,ELV)+1.0e-06) ! Setup gauges if(hazard_points_file /= '') then print*, '' print*, 'Reading hazard points' call read_csv_into_array(xy_coords, hazard_points_file, skip_header) print*, ' Setting up gauges' print*, domain%lower_left, domain%lw call domain%setup_point_gauges(xy_coords(1:2,:), time_series_var=[STG], static_var=[ELV], gauge_ids=xy_coords(3,:)) if(allocated(domain%point_gauges%xy)) then print*, ' The number of points is', domain%point_gauges%n_gauges print*, ' The first point is (lon,lat): ', domain%point_gauges%xy(1:2,1) print*, ' The last point is (lon,lat): ', domain%point_gauges%xy(1:2, domain%point_gauges%n_gauges) print*, '' end if else print*, '' print*, 'No hazard points' print*, '' end if if(adaptive_computational_extents) then #ifdef COARRAY print*, 'Cannot have adaptive computational extents with coarrays' call generic_stop() #endif ! Make up some xL/xU limits to do preliminary checks on allowing that ! to evolve domain%xL = xl domain%xU = xU domain%yL = yL domain%yU = yU end if print*, 'Initial conditions set' print*, '' end subroutine end module !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! program coarray_example use global_mod, only: ip, dp, minimum_allowed_depth use domain_mod, only: domain_type use boundary_mod, only: flather_boundary, periodic_EW_reflective_NS #ifdef COARRAY use coarray_point2point_comms_mod, only: allocate_p2p_comms #endif use local_routines implicit none integer(ip) :: i, j, ti, ni, nx_ca, ny_ca real(dp) :: last_write_time type(domain_type) :: domain character(charlen) :: timestepping_method, input_parameter_file real(dp) :: approximate_writeout_frequency, final_time real(dp) :: global_ur(2), global_ll(2), global_lw(2), cfl, dx(2) integer(ip) :: global_nx(2) integer(ip) :: skip_header_hazard_points_file character(len=charlen) :: input_elevation_raster, input_stage_raster, & hazard_points_file, output_basedir logical :: record_max_u, output_grid_timeseries, adaptive_computational_extents, & negative_elevation_raster, ew_periodic, ns_periodic real(dp) :: timestep ! Input data namelist /MODELCONFIG/ & input_elevation_raster, input_stage_raster, global_ll, & global_ur, global_nx, approximate_writeout_frequency, output_basedir, & final_time, timestepping_method,& cfl, hazard_points_file, skip_header_hazard_points_file, record_max_U,& output_grid_timeseries, adaptive_computational_extents, negative_elevation_raster, & nx_ca, ny_ca #ifdef COARRAY sync all #endif TIMER_START('SETUP') #ifdef COARRAY ni = num_images() ti = this_image() #else ti = 1 ni = 1 #endif ! Read input namelist call get_command_argument(1, input_parameter_file) open(newunit=j, file=input_parameter_file, action='read') read(j, nml=MODELCONFIG) close(j) domain%myid = 1000 + ti print*, '' print*, '#### INPUT FROM MODELCONFIG ####' print*, '' print*, 'input_elevation_raster: ', trim(input_elevation_raster) print*, 'input_stage_raster: ', trim(input_stage_raster) print*, 'global_ll: ', global_ll print*, 'global_ur: ', global_ur print*, 'global_nx: ', global_nx print*, 'approximate_writeout_frequency: ', approximate_writeout_frequency print*, 'output_basedir: ', trim(output_basedir) print*, 'final_time: ', final_time print*, 'timestepping_method: ', trim(timestepping_method) print*, 'cfl: ', cfl print*, 'hazard_points_file: ', trim(hazard_points_file) print*, 'skip_header_hazard_points_file: ', skip_header_hazard_points_file print*, 'record_max_U: ', record_max_U print*, 'output_grid_timeseries: ', output_grid_timeseries print*, 'adaptive_computational_extents: ', adaptive_computational_extents print*, 'negative_elevation_raster: ', negative_elevation_raster print*, '' print*, '#### END INPUT ####' print*, '' print*, 'Other key variables: ' print*, 'dp: ', dp print*, 'ip: ', ip print*, 'charlen: ', charlen global_lw = global_ur - global_ll dx = global_lw/(1.0_dp*global_nx) ! Use either ew-periodic or flather boundaries if(abs(global_lw(1) - 360.0_dp) < (0.1_dp*dx(1))) then ! Global model in EW direction. ! Case with periodic EW boundaries print*, '' print*, 'Assuming global model with periodic boundaries' print*, '' domain%boundary_subroutine => periodic_EW_reflective_NS #ifndef COARRAY global_nx = global_nx + [4,0] global_ur = global_ur + [2*dx(1), 0.0_dp] global_ll = global_ll - [2*dx(1), 0.0_dp] global_lw = global_ur - global_ll #endif ew_periodic = .TRUE. ns_periodic = .FALSE. else domain%boundary_subroutine => flather_boundary ew_periodic = .FALSE. ns_periodic = .FALSE. end if domain%timestepping_method = timestepping_method domain%record_max_U = record_max_U domain%output_basedir = output_basedir #ifndef COARRAY call domain%allocate_quantities(global_lw, global_nx, global_ll) #else print*, 'Allocating image ', ti ! Allocate domain with coarrays call domain%allocate_quantities(global_lw, global_nx, global_ll, co_size_xy = [nx_ca, ny_ca], & ew_periodic = ew_periodic, ns_periodic = ns_periodic) sync all call allocate_p2p_comms #endif domain%cfl = cfl call domain%log_outputs() write(domain%logfile_unit, MODELCONFIG) ! Call local routine to set initial conditions call set_initial_conditions_generic(domain, input_elevation_raster,& input_stage_raster, hazard_points_file, skip_header_hazard_points_file,& adaptive_computational_extents, negative_elevation_raster) #ifdef COARRAY ! Also print information about whether boundary conditions are applied write(domain%logfile_unit, *) 'ti: ', ti, 'boundary_exterior: ', domain%boundary_exterior #endif timestep = domain%linear_timestep_max() if(domain%timestepping_method /= 'linear') then ! The Finite volume methods have 1/2 as long a timestep for the same cfl timestep = 0.5_dp * timestep end if #ifdef COARRAY call co_min(timestep) write(domain%logfile_unit, *) 'reduced ts: ', timestep #else write(domain%logfile_unit, *) 'ts: ', timestep #endif ! Trick to get the code to write out just after the first timestep last_write_time = -approximate_writeout_frequency #ifdef COARRAY sync all #endif TIMER_STOP('SETUP') ! Evolve the code do while (.true.) if(domain%time - last_write_time >= approximate_writeout_frequency) then last_write_time = last_write_time + approximate_writeout_frequency call domain%print() call domain%write_to_output_files(time_only = (output_grid_timeseries .eqv. .false.)) call domain%write_gauge_time_series() end if if (domain%time > final_time) exit !! Example with fixed timestep call domain%evolve_one_step(timestep=timestep) ! Evolve the active domain? NOT WITH COARRAYS domain%xL = max(domain%xL - 1, 1) domain%xU = min(domain%xU + 1, domain%nx(1)) domain%yL = max(domain%yL - 1, 1) domain%yU = min(domain%yU + 1, domain%nx(2)) ! Treatment of spherical models with periodic EW conditions ! The BC region is within 4 cells of the boundaries (considering ! cells that copy-out, as well as cells that copy-in) if((domain%xl <= 4).or.(domain%xU >= domain%nx(1) - 3)) then domain%xl = 1_ip domain%xU = domain%nx(1) end if end do print*, '' call domain%write_max_quantities() ! Print timing info call domain%timer%print(output_file_unit = domain%logfile_unit) call domain%finalise() end program
## Introduction ----- In this assignment we will recursively estimate the position of a vehicle along a trajectory using available measurements and a motion model. The vehicle is equipped with a very simple type of LIDAR sensor, which returns range and bearing measurements corresponding to individual landmarks in the environment. The global positions of the landmarks are assumed to be known beforehand. We will also assume known data association, that is, which measurment belong to which landmark. ## Motion and Measurement Models ----- ### Motion Model The vehicle motion model recieves linear and angular velocity odometry readings as inputs, and outputs the state (i.e., the 2D pose) of the vehicle: \begin{align} \mathbf{x}_{k} &= \mathbf{x}_{k-1} + T \begin{bmatrix} \cos\theta_{k-1} &0 \\ \sin\theta_{k-1} &0 \\ 0 &1 \end{bmatrix} \left( \begin{bmatrix} v_k \\ \omega_k \end{bmatrix} + \mathbf{w}_k \right) \, , \, \, \, \, \, \mathbf{w}_k = \mathcal{N}\left(\mathbf{0}, \mathbf{Q}\right) \end{align} - $\mathbf{x}_k = \left[ x \, y \, \theta \right]^T$ is the current 2D pose of the vehicle - $v_k$ and $\omega_k$ are the linear and angular velocity odometry readings, which we use as inputs to the model The process noise $\mathbf{w}_k$ has a (zero mean) normal distribution with a constant covariance $\mathbf{Q}$. ### Measurement Model The measurement model relates the current pose of the vehicle to the LIDAR range and bearing measurements $\mathbf{y}^l_k = \left[r \, \phi \right]^T$. \begin{align} \mathbf{y}^l_k = \begin{bmatrix} \sqrt{(x_l - x_k - d\cos\theta_{k})^2 + (y_l - y_k - d\sin\theta_{k})^2} \\ atan2\left(y_l - y_k - d\sin\theta_{k},x_l - x_k - d\cos\theta_{k}\right) - \theta_k \end{bmatrix} + \mathbf{n}^l_k \, , \, \, \, \, \, \mathbf{n}^l_k = \mathcal{N}\left(\mathbf{0}, \mathbf{R}\right) \end{align} - $x_l$ and $y_l$ are the ground truth coordinates of the landmark $l$ - $x_k$ and $y_k$ and $\theta_{k}$ represent the current pose of the vehicle - $d$ is the known distance between robot center and laser rangefinder (LIDAR) The landmark measurement noise $\mathbf{n}^l_k$ has a (zero mean) normal distribution with a constant covariance $\mathbf{R}$. ## Getting Started ----- Since the models above are nonlinear, we recommend using the extended Kalman filter (EKF) as the state estimator. Specifically, we will need to provide code implementing the following steps: - the prediction step, which uses odometry measurements and the motion model to produce a state and covariance estimate at a given timestep, and - the correction step, which uses the range and bearing measurements provided by the LIDAR to correct the pose and pose covariance estimates ### Unpack the Data First, let's unpack the available data: ```python import pickle import numpy as np import matplotlib.pyplot as plt with open('data/data.pickle', 'rb') as f: data = pickle.load(f) t = data['t'] # timestamps [s] x_init = data['x_init'] # initial x position [m] y_init = data['y_init'] # initial y position [m] th_init = data['th_init'] # initial theta position [rad] # input signal v = data['v'] # translational velocity input [m/s] om = data['om'] # rotational velocity input [rad/s] # bearing and range measurements, LIDAR constants b = data['b'] # bearing to each landmarks center in the frame attached to the laser [rad] r = data['r'] # range measurements [m] l = data['l'] # x,y positions of landmarks [m] d = data['d'] # distance between robot center and laser rangefinder [m] ``` ```python x_init.shape ``` () ```python y_init.shape ``` () ```python th_init.shape ``` () ```python print(v.shape) print(len(v)) ``` (501,) 501 ```python om.shape ``` (501,) ```python b.shape ``` (501, 8) ```python r.shape ``` (501, 8) ```python l.shape ``` (8, 2) ```python print(d.shape) print(d[0]) ``` (1,) 0 Note that distance from the LIDAR frame to the robot center is provided and loaded as an array into the `d` variable. ### Ground Truth If available, it is useful to plot the ground truth position and orientation before starting the assignment. <table><tr> <td> </td> <td> </td> </tr></table> Notice that the orientation values are wrapped to the $\left[-\pi,\pi\right]$ range in radians. ### Initializing Parameters Now that our data is loaded, we can begin getting things set up for our solver. One of the most important aspects of designing a filter is determining the input and measurement noise covariance matrices, as well as the initial state and covariance values. We set the values here: ```python v_var = 0.01 # translation velocity variance om_var = 0.01 # rotational velocity variance # allowed to tune these values # r_var = 0.1 # range measurements variance r_var = 0.01 # b_var = 0.1 # bearing measurement variance b_var = 10 Q_km = np.diag([v_var, om_var]) # input noise covariance cov_y = np.diag([r_var, b_var]) # measurement noise covariance x_est = np.zeros([len(v), 3]) # estimated states, x, y, and theta P_est = np.zeros([len(v), 3, 3]) # state covariance matrices x_est[0] = np.array([x_init, y_init, th_init]) # initial state P_est[0] = np.diag([1, 1, 0.1]) # initial state covariance ``` ```python print(Q_km.shape) print(Q_km) ``` (2, 2) [[0.01 0. ] [0. 0.01]] ```python print(cov_y.shape) print(cov_y) ``` (2, 2) [[ 0.01 0. ] [ 0. 10. ]] ```python x_est.shape ``` (501, 3) ```python print(P_est.shape) print(P_est[0]) print(P_est[1]) ``` (501, 3, 3) [[1. 0. 0. ] [0. 1. 0. ] [0. 0. 0.1]] [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]] **Remember:** that it is neccessary to tune the measurement noise variances `r_var`, `b_var` in order for the filter to perform well! In order for the orientation estimates to coincide with the bearing measurements, it is also neccessary to wrap all estimated $\theta$ values to the $(-\pi , \pi]$ range. ```python # Wraps angle to (-pi,pi] range def wraptopi(x): # x = ((x / np.pi + 1) % 2 - 1) * np.pi if x > np.pi: x = x - (np.floor(x / (2 * np.pi)) + 1) * 2 * np.pi elif x < -np.pi: x = x + (np.floor(x / (-2 * np.pi)) + 1) * 2 * np.pi return np.array(x) ``` ## Correction Step ----- First, let's implement the measurement update function, which takes an available landmark measurement $l$ and updates the current state estimate $\mathbf{\check{x}}_k$. For each landmark measurement received at a given timestep $k$, you should implement the following steps: - Compute the measurement model Jacobians at $\mathbf{\check{x}}_{k}$ \begin{align} \mathbf{y}^l_k = &\mathbf{h}(\mathbf{x}_{k}, \mathbf{n}^l_k) \\\\ \mathbf{H}_{k} = \frac{\partial \mathbf{h}}{\partial \mathbf{x}_{k}}\bigg|_{\mathbf{\check{x}}_{k},0}& \, , \, \, \, \, \mathbf{M}_{k} = \frac{\partial \mathbf{h}}{\partial \mathbf{n}_{k}}\bigg|_{\mathbf{\check{x}}_{k},0} \, . \end{align} - Compute the Kalman Gain \begin{align} \mathbf{K}_k &= \mathbf{\check{P}}_k \mathbf{H}_k^T \left(\mathbf{H}_k \mathbf{\check{P}}_k \mathbf{H}_k^T + \mathbf{M}_k \mathbf{R}_k \mathbf{M}_k^T \right)^{-1} \end{align} - Correct the predicted state \begin{align} \mathbf{\check{y}}^l_k &= \mathbf{h}\left(\mathbf{\check{x}}_k, \mathbf{0}\right) \\ \mathbf{\hat{x}}_k &= \mathbf{\check{x}}_k + \mathbf{K}_k \left(\mathbf{y}^l_k - \mathbf{\check{y}}^l_k\right) \end{align} - Correct the covariance \begin{align} \mathbf{\hat{P}}_k &= \left(\mathbf{I} - \mathbf{K}_k \mathbf{H}_k \right)\mathbf{\check{P}}_k \end{align} ```python def measurement_update(lk, rk, bk, P_check, x_check): x_k = x_check[0] y_k = x_check[1] theta_k = wraptopi(x_check[2]) x_l = lk[0] y_l = lk[1] d_x = x_l - x_k - d*np.cos(theta_k) d_y = y_l - y_k - d*np.sin(theta_k) r = np.sqrt(d_x**2 + d_y**2) phi = np.arctan2(d_y, d_x) - theta_k # 1. Compute measurement Jacobian H_k = np.zeros((2,3)) H_k[0,0] = -d_x/r H_k[0,1] = -d_y/r H_k[0,2] = d*(d_x*np.sin(theta_k) - d_y*np.cos(theta_k))/r H_k[1,0] = d_y/r**2 H_k[1,1] = -d_x/r**2 H_k[1,2] = -1-d*(d_y*np.sin(theta_k) + d_x*np.cos(theta_k))/r**2 M_k = np.identity(2) y_out = np.vstack([r, wraptopi(phi)]) y_mes = np.vstack([rk, wraptopi(bk)]) # 2. Compute Kalman Gain K_k = P_check.dot(H_k.T).dot(np.linalg.inv(H_k.dot(P_check).dot(H_k.T) + M_k.dot(cov_y).dot(M_k.T))) # 3. Correct predicted state (remember to wrap the angles to [-pi,pi]) x_check = x_check + K_k.dot(y_mes - y_out) x_check[2] = wraptopi(x_check[2]) # 4. Correct covariance P_check = (np.identity(3) - K_k.dot(H_k)).dot(P_check) return x_check, P_check ``` ## Prediction Step ----- Now, implement the main filter loop, defining the prediction step of the EKF using the motion model provided: \begin{align} \mathbf{\check{x}}_k &= \mathbf{f}\left(\mathbf{\hat{x}}_{k-1}, \mathbf{u}_{k-1}, \mathbf{0} \right) \\ \mathbf{\check{P}}_k &= \mathbf{F}_{k-1}\mathbf{\hat{P}}_{k-1}\mathbf{F}_{k-1}^T + \mathbf{L}_{k-1}\mathbf{Q}_{k-1}\mathbf{L}_{k-1}^T \, . \end{align} Where \begin{align} \mathbf{F}_{k-1} = \frac{\partial \mathbf{f}}{\partial \mathbf{x}_{k-1}}\bigg|_{\mathbf{\hat{x}}_{k-1},\mathbf{u}_{k},0} \, , \, \, \, \, \mathbf{L}_{k-1} = \frac{\partial \mathbf{f}}{\partial \mathbf{w}_{k}}\bigg|_{\mathbf{\hat{x}}_{k-1},\mathbf{u}_{k},0} \, . \end{align} ```python #### 5. Main Filter Loop ####################################################################### # set the initial values P_check = P_est[0] x_check = x_est[0, :].reshape(3,1) for k in range(1, len(t)): # start at 1 because we've set the initial prediciton delta_t = t[k] - t[k - 1] # time step (difference between timestamps) theta = wraptopi(x_check[2]) # 1. Update state with odometry readings (remember to wrap the angles to [-pi,pi]) # x_check = np.zeros(3) F = np.array([[np.cos(theta), 0], [np.sin(theta), 0], [0, 1]], dtype='float') inp = np.array([[v[k-1]], [om[k-1]]]) x_check = x_check + F.dot(inp).dot(delta_t) x_check[2] = wraptopi(x_check[2]) # 2. Motion model jacobian with respect to last state F_km = np.zeros([3, 3]) F_km = np.array([[1, 0, -np.sin(theta)*delta_t*v[k-1]], [0, 1, np.cos(theta)*delta_t*v[k-1]], [0, 0, 1]], dtype='float') # dtype='float' # 3. Motion model jacobian with respect to noise L_km = np.zeros([3, 2]) L_km = np.array([[np.cos(theta)*delta_t, 0], [np.sin(theta)*delta_t, 0], [0,1]], dtype='float') # 4. Propagate uncertainty P_check = F_km.dot(P_check.dot(F_km.T)) + L_km.dot(Q_km.dot(L_km.T)) # 5. Update state estimate using available landmark measurements for i in range(len(r[k])): x_check, P_check = measurement_update(l[i], r[k, i], b[k, i], P_check, x_check) # Set final state predictions for timestep x_est[k, 0] = x_check[0] x_est[k, 1] = x_check[1] x_est[k, 2] = x_check[2] P_est[k, :, :] = P_check ``` Let's plot the resulting state estimates: ```python e_fig = plt.figure() ax = e_fig.add_subplot(111) ax.plot(x_est[:, 0], x_est[:, 1]) ax.set_xlabel('x [m]') ax.set_ylabel('y [m]') ax.set_title('Estimated trajectory') plt.show() e_fig = plt.figure() ax = e_fig.add_subplot(111) ax.plot(t[:], x_est[:, 2]) ax.set_xlabel('Time [s]') ax.set_ylabel('theta [rad]') ax.set_title('Estimated trajectory') plt.show() ```
(* !!! WARNING: AUTO GENERATED. DO NOT MODIFY !!! *) Require Import Coq.Logic.FunctionalExtensionality. Require Import Coq.Program.Equality. Require Export Metalib.Metatheory. Require Export Metalib.LibLNgen. Require Export syntax_ott. (** NOTE: Auxiliary theorems are hidden in generated documentation. In general, there is a [_rec] version of every lemma involving [open] and [close]. *) (* *********************************************************************** *) (** * Induction principles for nonterminals *) Scheme typ_ind' := Induction for typ Sort Prop. Definition typ_mutind := fun H1 H2 H3 H4 H5 => typ_ind' H1 H2 H3 H4 H5. Scheme typ_rec' := Induction for typ Sort Set. Definition typ_mutrec := fun H1 H2 H3 H4 H5 => typ_rec' H1 H2 H3 H4 H5. Scheme exp_ind' := Induction for exp Sort Prop. Definition exp_mutind := fun H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 => exp_ind' H1 H2 H3 H4 H5 H6 H7 H8 H9 H10. Scheme exp_rec' := Induction for exp Sort Set. Definition exp_mutrec := fun H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 => exp_rec' H1 H2 H3 H4 H5 H6 H7 H8 H9 H10. (* *********************************************************************** *) (** * Close *) Fixpoint close_exp_wrt_exp_rec (n1 : nat) (x1 : var) (e1 : exp) {struct e1} : exp := match e1 with | e_var_f x2 => if (x1 == x2) then (e_var_b n1) else (e_var_f x2) | e_var_b n2 => if (lt_ge_dec n2 n1) then (e_var_b n2) else (e_var_b (S n2)) | e_lit i1 => e_lit i1 | e_abs A1 e2 B1 => e_abs A1 (close_exp_wrt_exp_rec (S n1) x1 e2) B1 | e_app e2 e3 => e_app (close_exp_wrt_exp_rec n1 x1 e2) (close_exp_wrt_exp_rec n1 x1 e3) | e_anno e2 A1 => e_anno (close_exp_wrt_exp_rec n1 x1 e2) A1 | e_add e2 e3 => e_add (close_exp_wrt_exp_rec n1 x1 e2) (close_exp_wrt_exp_rec n1 x1 e3) | e_save e2 A1 B1=> e_save (close_exp_wrt_exp_rec n1 x1 e2) A1 B1 end. Definition close_exp_wrt_exp x1 e1 := close_exp_wrt_exp_rec 0 x1 e1. (* *********************************************************************** *) (** * Size *) Fixpoint size_typ (A1 : typ) {struct A1} : nat := match A1 with | t_int => 1 | t_arrow A2 B1 => 1 + (size_typ A2) + (size_typ B1) | t_dyn => 1 end. Fixpoint size_exp (e1 : exp) {struct e1} : nat := match e1 with | e_var_f x1 => 1 | e_var_b n1 => 1 | e_lit i1 => 1 | e_abs A1 e2 B1 => 1 + (size_typ A1) + (size_exp e2) + (size_typ B1) | e_app e2 e3 => 1 + (size_exp e2) + (size_exp e3) | e_anno e2 A1 => 1 + (size_exp e2) + (size_typ A1) | e_add e2 e3 => 1 + (size_exp e2) + (size_exp e3) | e_save e2 A1 B1 => 1 + (size_exp e2) + (size_typ A1) + (size_typ B1) end. (* *********************************************************************** *) (** * Degree *) (** These define only an upper bound, not a strict upper bound. *) Inductive degree_exp_wrt_exp : nat -> exp -> Prop := | degree_wrt_exp_e_var_f : forall n1 x1, degree_exp_wrt_exp n1 (e_var_f x1) | degree_wrt_exp_e_var_b : forall n1 n2, lt n2 n1 -> degree_exp_wrt_exp n1 (e_var_b n2) | degree_wrt_exp_e_lit : forall n1 i1, degree_exp_wrt_exp n1 (e_lit i1) | degree_wrt_exp_e_abs : forall n1 A1 e1 B1, degree_exp_wrt_exp (S n1) e1 -> degree_exp_wrt_exp n1 (e_abs A1 e1 B1) | degree_wrt_exp_e_app : forall n1 e1 e2, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp n1 e2 -> degree_exp_wrt_exp n1 (e_app e1 e2) | degree_wrt_exp_e_anno : forall n1 e1 A1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp n1 (e_anno e1 A1) | degree_wrt_exp_e_add : forall n1 e1 e2, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp n1 e2 -> degree_exp_wrt_exp n1 (e_add e1 e2) | degree_wrt_exp_e_save : forall n1 e1 A1 B1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp n1 (e_save e1 A1 B1). Scheme degree_exp_wrt_exp_ind' := Induction for degree_exp_wrt_exp Sort Prop. Definition degree_exp_wrt_exp_mutind := fun H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 => degree_exp_wrt_exp_ind' H1 H2 H3 H4 H5 H6 H7 H8 H9 H10. Hint Constructors degree_exp_wrt_exp : core lngen. (* *********************************************************************** *) (** * Local closure (version in [Set], induction principles) *) Inductive lc_set_exp : exp -> Set := | lc_set_e_var_f : forall x1, lc_set_exp (e_var_f x1) | lc_set_e_lit : forall i1, lc_set_exp (e_lit i1) | lc_set_e_abs : forall A1 e1 B1, (forall x1 : var, lc_set_exp (open_exp_wrt_exp e1 (e_var_f x1))) -> lc_set_exp (e_abs A1 e1 B1) | lc_set_e_app : forall e1 e2, lc_set_exp e1 -> lc_set_exp e2 -> lc_set_exp (e_app e1 e2) | lc_set_e_anno : forall e1 A1, lc_set_exp e1 -> lc_set_exp (e_anno e1 A1) | lc_set_e_add : forall e1 e2, lc_set_exp e1 -> lc_set_exp e2 -> lc_set_exp (e_add e1 e2) | lc_set_e_save : forall e1 A1 B1, lc_set_exp e1 -> lc_set_exp (e_save e1 A1 B1). Scheme lc_exp_ind' := Induction for lc_exp Sort Prop. Definition lc_exp_mutind := fun H1 H2 H3 H4 H5 H6 H7 H8 H9 => lc_exp_ind' H1 H2 H3 H4 H5 H6 H7 H8 H9. Scheme lc_set_exp_ind' := Induction for lc_set_exp Sort Prop. Definition lc_set_exp_mutind := fun H1 H2 H3 H4 H5 H6 H7 H8 H9 => lc_set_exp_ind' H1 H2 H3 H4 H5 H6 H7 H8 H9. Scheme lc_set_exp_rec' := Induction for lc_set_exp Sort Set. Definition lc_set_exp_mutrec := fun H1 H2 H3 H4 H5 H6 H7 H8 H9 => lc_set_exp_rec' H1 H2 H3 H4 H5 H6 H7 H8 H9. Hint Constructors lc_exp : core lngen. Hint Constructors lc_set_exp : core lngen. (* *********************************************************************** *) (** * Body *) Definition body_exp_wrt_exp e1 := forall x1, lc_exp (open_exp_wrt_exp e1 (e_var_f x1)). Hint Unfold body_exp_wrt_exp : core. (* *********************************************************************** *) (** * Tactic support *) (** Additional hint declarations. *) Hint Resolve @plus_le_compat : lngen. (** Redefine some tactics. *) Ltac default_case_split ::= first [ progress destruct_notin | progress destruct_sum | progress safe_f_equal ]. (* *********************************************************************** *) (** * Theorems about [size] *) Ltac default_auto ::= auto with arith lngen; tauto. Ltac default_autorewrite ::= fail. (* begin hide *) Lemma size_typ_min_mutual : (forall A1, 1 <= size_typ A1). Proof. apply_mutual_ind typ_mutind; default_simp. Qed. (* end hide *) Lemma size_typ_min : forall A1, 1 <= size_typ A1. Proof. pose proof size_typ_min_mutual as H; intuition eauto. Qed. Hint Resolve size_typ_min : lngen. (* begin hide *) Lemma size_exp_min_mutual : (forall e1, 1 <= size_exp e1). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma size_exp_min : forall e1, 1 <= size_exp e1. Proof. pose proof size_exp_min_mutual as H; intuition eauto. Qed. Hint Resolve size_exp_min : lngen. (* begin hide *) Lemma size_exp_close_exp_wrt_exp_rec_mutual : (forall e1 x1 n1, size_exp (close_exp_wrt_exp_rec n1 x1 e1) = size_exp e1). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma size_exp_close_exp_wrt_exp_rec : forall e1 x1 n1, size_exp (close_exp_wrt_exp_rec n1 x1 e1) = size_exp e1. Proof. pose proof size_exp_close_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve size_exp_close_exp_wrt_exp_rec : lngen. Hint Rewrite size_exp_close_exp_wrt_exp_rec using solve [auto] : lngen. (* end hide *) Lemma size_exp_close_exp_wrt_exp : forall e1 x1, size_exp (close_exp_wrt_exp x1 e1) = size_exp e1. Proof. unfold close_exp_wrt_exp; default_simp. Qed. Hint Resolve size_exp_close_exp_wrt_exp : lngen. Hint Rewrite size_exp_close_exp_wrt_exp using solve [auto] : lngen. (* begin hide *) Lemma size_exp_open_exp_wrt_exp_rec_mutual : (forall e1 e2 n1, size_exp e1 <= size_exp (open_exp_wrt_exp_rec n1 e2 e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma size_exp_open_exp_wrt_exp_rec : forall e1 e2 n1, size_exp e1 <= size_exp (open_exp_wrt_exp_rec n1 e2 e1). Proof. pose proof size_exp_open_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve size_exp_open_exp_wrt_exp_rec : lngen. (* end hide *) Lemma size_exp_open_exp_wrt_exp : forall e1 e2, size_exp e1 <= size_exp (open_exp_wrt_exp e1 e2). Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve size_exp_open_exp_wrt_exp : lngen. (* begin hide *) Lemma size_exp_open_exp_wrt_exp_rec_var_mutual : (forall e1 x1 n1, size_exp (open_exp_wrt_exp_rec n1 (e_var_f x1) e1) = size_exp e1). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma size_exp_open_exp_wrt_exp_rec_var : forall e1 x1 n1, size_exp (open_exp_wrt_exp_rec n1 (e_var_f x1) e1) = size_exp e1. Proof. pose proof size_exp_open_exp_wrt_exp_rec_var_mutual as H; intuition eauto. Qed. Hint Resolve size_exp_open_exp_wrt_exp_rec_var : lngen. Hint Rewrite size_exp_open_exp_wrt_exp_rec_var using solve [auto] : lngen. (* end hide *) Lemma size_exp_open_exp_wrt_exp_var : forall e1 x1, size_exp (open_exp_wrt_exp e1 (e_var_f x1)) = size_exp e1. Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve size_exp_open_exp_wrt_exp_var : lngen. Hint Rewrite size_exp_open_exp_wrt_exp_var using solve [auto] : lngen. (* *********************************************************************** *) (** * Theorems about [degree] *) Ltac default_auto ::= auto with lngen; tauto. Ltac default_autorewrite ::= fail. (* begin hide *) Lemma degree_exp_wrt_exp_S_mutual : (forall n1 e1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp (S n1) e1). Proof. apply_mutual_ind degree_exp_wrt_exp_mutind; default_simp. Qed. (* end hide *) Lemma degree_exp_wrt_exp_S : forall n1 e1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp (S n1) e1. Proof. pose proof degree_exp_wrt_exp_S_mutual as H; intuition eauto. Qed. Hint Resolve degree_exp_wrt_exp_S : lngen. Lemma degree_exp_wrt_exp_O : forall n1 e1, degree_exp_wrt_exp O e1 -> degree_exp_wrt_exp n1 e1. Proof. induction n1; default_simp. Qed. Hint Resolve degree_exp_wrt_exp_O : lngen. (* begin hide *) Lemma degree_exp_wrt_exp_close_exp_wrt_exp_rec_mutual : (forall e1 x1 n1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp (S n1) (close_exp_wrt_exp_rec n1 x1 e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma degree_exp_wrt_exp_close_exp_wrt_exp_rec : forall e1 x1 n1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp (S n1) (close_exp_wrt_exp_rec n1 x1 e1). Proof. pose proof degree_exp_wrt_exp_close_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve degree_exp_wrt_exp_close_exp_wrt_exp_rec : lngen. (* end hide *) Lemma degree_exp_wrt_exp_close_exp_wrt_exp : forall e1 x1, degree_exp_wrt_exp 0 e1 -> degree_exp_wrt_exp 1 (close_exp_wrt_exp x1 e1). Proof. unfold close_exp_wrt_exp; default_simp. Qed. Hint Resolve degree_exp_wrt_exp_close_exp_wrt_exp : lngen. (* begin hide *) Lemma degree_exp_wrt_exp_close_exp_wrt_exp_rec_inv_mutual : (forall e1 x1 n1, degree_exp_wrt_exp (S n1) (close_exp_wrt_exp_rec n1 x1 e1) -> degree_exp_wrt_exp n1 e1). Proof. apply_mutual_ind exp_mutind; default_simp; eauto with lngen. Qed. (* end hide *) (* begin hide *) Lemma degree_exp_wrt_exp_close_exp_wrt_exp_rec_inv : forall e1 x1 n1, degree_exp_wrt_exp (S n1) (close_exp_wrt_exp_rec n1 x1 e1) -> degree_exp_wrt_exp n1 e1. Proof. pose proof degree_exp_wrt_exp_close_exp_wrt_exp_rec_inv_mutual as H; intuition eauto. Qed. Hint Immediate degree_exp_wrt_exp_close_exp_wrt_exp_rec_inv : lngen. (* end hide *) Lemma degree_exp_wrt_exp_close_exp_wrt_exp_inv : forall e1 x1, degree_exp_wrt_exp 1 (close_exp_wrt_exp x1 e1) -> degree_exp_wrt_exp 0 e1. Proof. unfold close_exp_wrt_exp; eauto with lngen. Qed. Hint Immediate degree_exp_wrt_exp_close_exp_wrt_exp_inv : lngen. (* begin hide *) Lemma degree_exp_wrt_exp_open_exp_wrt_exp_rec_mutual : (forall e1 e2 n1, degree_exp_wrt_exp (S n1) e1 -> degree_exp_wrt_exp n1 e2 -> degree_exp_wrt_exp n1 (open_exp_wrt_exp_rec n1 e2 e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma degree_exp_wrt_exp_open_exp_wrt_exp_rec : forall e1 e2 n1, degree_exp_wrt_exp (S n1) e1 -> degree_exp_wrt_exp n1 e2 -> degree_exp_wrt_exp n1 (open_exp_wrt_exp_rec n1 e2 e1). Proof. pose proof degree_exp_wrt_exp_open_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve degree_exp_wrt_exp_open_exp_wrt_exp_rec : lngen. (* end hide *) Lemma degree_exp_wrt_exp_open_exp_wrt_exp : forall e1 e2, degree_exp_wrt_exp 1 e1 -> degree_exp_wrt_exp 0 e2 -> degree_exp_wrt_exp 0 (open_exp_wrt_exp e1 e2). Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve degree_exp_wrt_exp_open_exp_wrt_exp : lngen. (* begin hide *) Lemma degree_exp_wrt_exp_open_exp_wrt_exp_rec_inv_mutual : (forall e1 e2 n1, degree_exp_wrt_exp n1 (open_exp_wrt_exp_rec n1 e2 e1) -> degree_exp_wrt_exp (S n1) e1). Proof. apply_mutual_ind exp_mutind; default_simp; eauto with lngen. Qed. (* end hide *) (* begin hide *) Lemma degree_exp_wrt_exp_open_exp_wrt_exp_rec_inv : forall e1 e2 n1, degree_exp_wrt_exp n1 (open_exp_wrt_exp_rec n1 e2 e1) -> degree_exp_wrt_exp (S n1) e1. Proof. pose proof degree_exp_wrt_exp_open_exp_wrt_exp_rec_inv_mutual as H; intuition eauto. Qed. Hint Immediate degree_exp_wrt_exp_open_exp_wrt_exp_rec_inv : lngen. (* end hide *) Lemma degree_exp_wrt_exp_open_exp_wrt_exp_inv : forall e1 e2, degree_exp_wrt_exp 0 (open_exp_wrt_exp e1 e2) -> degree_exp_wrt_exp 1 e1. Proof. unfold open_exp_wrt_exp; eauto with lngen. Qed. Hint Immediate degree_exp_wrt_exp_open_exp_wrt_exp_inv : lngen. (* *********************************************************************** *) (** * Theorems about [open] and [close] *) Ltac default_auto ::= auto with lngen brute_force; tauto. Ltac default_autorewrite ::= fail. (* begin hide *) Lemma close_exp_wrt_exp_rec_inj_mutual : (forall e1 e2 x1 n1, close_exp_wrt_exp_rec n1 x1 e1 = close_exp_wrt_exp_rec n1 x1 e2 -> e1 = e2). Proof. apply_mutual_ind exp_mutind; intros; match goal with | |- _ = ?term => destruct term end; default_simp; eauto with lngen. Qed. (* end hide *) (* begin hide *) Lemma close_exp_wrt_exp_rec_inj : forall e1 e2 x1 n1, close_exp_wrt_exp_rec n1 x1 e1 = close_exp_wrt_exp_rec n1 x1 e2 -> e1 = e2. Proof. pose proof close_exp_wrt_exp_rec_inj_mutual as H; intuition eauto. Qed. Hint Immediate close_exp_wrt_exp_rec_inj : lngen. (* end hide *) Lemma close_exp_wrt_exp_inj : forall e1 e2 x1, close_exp_wrt_exp x1 e1 = close_exp_wrt_exp x1 e2 -> e1 = e2. Proof. unfold close_exp_wrt_exp; eauto with lngen. Qed. Hint Immediate close_exp_wrt_exp_inj : lngen. (* begin hide *) Lemma close_exp_wrt_exp_rec_open_exp_wrt_exp_rec_mutual : (forall e1 x1 n1, x1 `notin` fv_exp e1 -> close_exp_wrt_exp_rec n1 x1 (open_exp_wrt_exp_rec n1 (e_var_f x1) e1) = e1). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma close_exp_wrt_exp_rec_open_exp_wrt_exp_rec : forall e1 x1 n1, x1 `notin` fv_exp e1 -> close_exp_wrt_exp_rec n1 x1 (open_exp_wrt_exp_rec n1 (e_var_f x1) e1) = e1. Proof. pose proof close_exp_wrt_exp_rec_open_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve close_exp_wrt_exp_rec_open_exp_wrt_exp_rec : lngen. Hint Rewrite close_exp_wrt_exp_rec_open_exp_wrt_exp_rec using solve [auto] : lngen. (* end hide *) Lemma close_exp_wrt_exp_open_exp_wrt_exp : forall e1 x1, x1 `notin` fv_exp e1 -> close_exp_wrt_exp x1 (open_exp_wrt_exp e1 (e_var_f x1)) = e1. Proof. unfold close_exp_wrt_exp; unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve close_exp_wrt_exp_open_exp_wrt_exp : lngen. Hint Rewrite close_exp_wrt_exp_open_exp_wrt_exp using solve [auto] : lngen. (* begin hide *) Lemma open_exp_wrt_exp_rec_close_exp_wrt_exp_rec_mutual : (forall e1 x1 n1, open_exp_wrt_exp_rec n1 (e_var_f x1) (close_exp_wrt_exp_rec n1 x1 e1) = e1). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma open_exp_wrt_exp_rec_close_exp_wrt_exp_rec : forall e1 x1 n1, open_exp_wrt_exp_rec n1 (e_var_f x1) (close_exp_wrt_exp_rec n1 x1 e1) = e1. Proof. pose proof open_exp_wrt_exp_rec_close_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve open_exp_wrt_exp_rec_close_exp_wrt_exp_rec : lngen. Hint Rewrite open_exp_wrt_exp_rec_close_exp_wrt_exp_rec using solve [auto] : lngen. (* end hide *) Lemma open_exp_wrt_exp_close_exp_wrt_exp : forall e1 x1, open_exp_wrt_exp (close_exp_wrt_exp x1 e1) (e_var_f x1) = e1. Proof. unfold close_exp_wrt_exp; unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve open_exp_wrt_exp_close_exp_wrt_exp : lngen. Hint Rewrite open_exp_wrt_exp_close_exp_wrt_exp using solve [auto] : lngen. (* begin hide *) Lemma open_exp_wrt_exp_rec_inj_mutual : (forall e2 e1 x1 n1, x1 `notin` fv_exp e2 -> x1 `notin` fv_exp e1 -> open_exp_wrt_exp_rec n1 (e_var_f x1) e2 = open_exp_wrt_exp_rec n1 (e_var_f x1) e1 -> e2 = e1). Proof. apply_mutual_ind exp_mutind; intros; match goal with | |- _ = ?term => destruct term end; default_simp; eauto with lngen. Qed. (* end hide *) (* begin hide *) Lemma open_exp_wrt_exp_rec_inj : forall e2 e1 x1 n1, x1 `notin` fv_exp e2 -> x1 `notin` fv_exp e1 -> open_exp_wrt_exp_rec n1 (e_var_f x1) e2 = open_exp_wrt_exp_rec n1 (e_var_f x1) e1 -> e2 = e1. Proof. pose proof open_exp_wrt_exp_rec_inj_mutual as H; intuition eauto. Qed. Hint Immediate open_exp_wrt_exp_rec_inj : lngen. (* end hide *) Lemma open_exp_wrt_exp_inj : forall e2 e1 x1, x1 `notin` fv_exp e2 -> x1 `notin` fv_exp e1 -> open_exp_wrt_exp e2 (e_var_f x1) = open_exp_wrt_exp e1 (e_var_f x1) -> e2 = e1. Proof. unfold open_exp_wrt_exp; eauto with lngen. Qed. Hint Immediate open_exp_wrt_exp_inj : lngen. (* *********************************************************************** *) (** * Theorems about [lc] *) Ltac default_auto ::= auto with lngen brute_force; tauto. Ltac default_autorewrite ::= autorewrite with lngen. (* begin hide *) Lemma degree_exp_wrt_exp_of_lc_exp_mutual : (forall e1, lc_exp e1 -> degree_exp_wrt_exp 0 e1). Proof. apply_mutual_ind lc_exp_mutind; intros; let x1 := fresh "x1" in pick_fresh x1; repeat (match goal with | H1 : _, H2 : _ |- _ => specialize H1 with H2 end); default_simp; eauto with lngen. Qed. (* end hide *) Lemma degree_exp_wrt_exp_of_lc_exp : forall e1, lc_exp e1 -> degree_exp_wrt_exp 0 e1. Proof. pose proof degree_exp_wrt_exp_of_lc_exp_mutual as H; intuition eauto. Qed. Hint Resolve degree_exp_wrt_exp_of_lc_exp : lngen. (* begin hide *) Lemma lc_exp_of_degree_size_mutual : forall i1, (forall e1, size_exp e1 = i1 -> degree_exp_wrt_exp 0 e1 -> lc_exp e1). Proof. intros i1; pattern i1; apply lt_wf_rec; clear i1; intros i1 H1; apply_mutual_ind exp_mutind; default_simp; (* non-trivial cases *) constructor; default_simp; eapply_first_lt_hyp; (* instantiate the size *) match goal with | |- _ = _ => reflexivity | _ => idtac end; instantiate; (* everything should be easy now *) default_simp. Qed. (* end hide *) Lemma lc_exp_of_degree : forall e1, degree_exp_wrt_exp 0 e1 -> lc_exp e1. Proof. intros e1; intros; pose proof (lc_exp_of_degree_size_mutual (size_exp e1)); intuition eauto. Qed. Hint Resolve lc_exp_of_degree : lngen. Ltac typ_lc_exists_tac := repeat (match goal with | H : _ |- _ => fail 1 end). Ltac exp_lc_exists_tac := repeat (match goal with | H : _ |- _ => let J1 := fresh in pose proof H as J1; apply degree_exp_wrt_exp_of_lc_exp in J1; clear H end). Lemma lc_e_abs_exists : forall x1 A1 e1 B1, lc_exp (open_exp_wrt_exp e1 (e_var_f x1)) -> lc_exp (e_abs A1 e1 B1). Proof. intros; exp_lc_exists_tac; eauto with lngen. Qed. Hint Extern 1 (lc_exp (e_abs _ _ _)) => let x1 := fresh in pick_fresh x1; apply (lc_e_abs_exists x1) : core. Lemma lc_body_exp_wrt_exp : forall e1 e2, body_exp_wrt_exp e1 -> lc_exp e2 -> lc_exp (open_exp_wrt_exp e1 e2). Proof. unfold body_exp_wrt_exp; default_simp; let x1 := fresh "x" in pick_fresh x1; specialize_all x1; exp_lc_exists_tac; eauto with lngen. Qed. Hint Resolve lc_body_exp_wrt_exp : lngen. Lemma lc_body_e_abs_2 : forall A1 e1 B1, lc_exp (e_abs A1 e1 B1) -> body_exp_wrt_exp e1. Proof. default_simp. Qed. Hint Resolve lc_body_e_abs_2 : lngen. (* begin hide *) Lemma lc_exp_unique_mutual : (forall e1 (proof2 proof3 : lc_exp e1), proof2 = proof3). Proof. apply_mutual_ind lc_exp_mutind; intros; let proof1 := fresh "proof1" in rename_last_into proof1; dependent destruction proof1; f_equal; default_simp; auto using @functional_extensionality_dep with lngen. Qed. (* end hide *) Lemma lc_exp_unique : forall e1 (proof2 proof3 : lc_exp e1), proof2 = proof3. Proof. pose proof lc_exp_unique_mutual as H; intuition eauto. Qed. Hint Resolve lc_exp_unique : lngen. (* begin hide *) Lemma lc_exp_of_lc_set_exp_mutual : (forall e1, lc_set_exp e1 -> lc_exp e1). Proof. apply_mutual_ind lc_set_exp_mutind; default_simp. Qed. (* end hide *) Lemma lc_exp_of_lc_set_exp : forall e1, lc_set_exp e1 -> lc_exp e1. Proof. pose proof lc_exp_of_lc_set_exp_mutual as H; intuition eauto. Qed. Hint Resolve lc_exp_of_lc_set_exp : lngen. (* begin hide *) Lemma lc_set_exp_of_lc_exp_size_mutual : forall i1, (forall e1, size_exp e1 = i1 -> lc_exp e1 -> lc_set_exp e1). Proof. intros i1; pattern i1; apply lt_wf_rec; clear i1; intros i1 H1; apply_mutual_ind exp_mutrec; default_simp; try solve [assert False by default_simp; tauto]; (* non-trivial cases *) constructor; default_simp; try first [apply lc_set_typ_of_lc_typ | apply lc_set_exp_of_lc_exp]; default_simp; eapply_first_lt_hyp; (* instantiate the size *) match goal with | |- _ = _ => reflexivity | _ => idtac end; instantiate; (* everything should be easy now *) default_simp. Qed. (* end hide *) Lemma lc_set_exp_of_lc_exp : forall e1, lc_exp e1 -> lc_set_exp e1. Proof. intros e1; intros; pose proof (lc_set_exp_of_lc_exp_size_mutual (size_exp e1)); intuition eauto. Qed. Hint Resolve lc_set_exp_of_lc_exp : lngen. (* *********************************************************************** *) (** * More theorems about [open] and [close] *) Ltac default_auto ::= auto with lngen; tauto. Ltac default_autorewrite ::= fail. (* begin hide *) Lemma close_exp_wrt_exp_rec_degree_exp_wrt_exp_mutual : (forall e1 x1 n1, degree_exp_wrt_exp n1 e1 -> x1 `notin` fv_exp e1 -> close_exp_wrt_exp_rec n1 x1 e1 = e1). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma close_exp_wrt_exp_rec_degree_exp_wrt_exp : forall e1 x1 n1, degree_exp_wrt_exp n1 e1 -> x1 `notin` fv_exp e1 -> close_exp_wrt_exp_rec n1 x1 e1 = e1. Proof. pose proof close_exp_wrt_exp_rec_degree_exp_wrt_exp_mutual as H; intuition eauto. Qed. Hint Resolve close_exp_wrt_exp_rec_degree_exp_wrt_exp : lngen. Hint Rewrite close_exp_wrt_exp_rec_degree_exp_wrt_exp using solve [auto] : lngen. (* end hide *) Lemma close_exp_wrt_exp_lc_exp : forall e1 x1, lc_exp e1 -> x1 `notin` fv_exp e1 -> close_exp_wrt_exp x1 e1 = e1. Proof. unfold close_exp_wrt_exp; default_simp. Qed. Hint Resolve close_exp_wrt_exp_lc_exp : lngen. Hint Rewrite close_exp_wrt_exp_lc_exp using solve [auto] : lngen. (* begin hide *) Lemma open_exp_wrt_exp_rec_degree_exp_wrt_exp_mutual : (forall e2 e1 n1, degree_exp_wrt_exp n1 e2 -> open_exp_wrt_exp_rec n1 e1 e2 = e2). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma open_exp_wrt_exp_rec_degree_exp_wrt_exp : forall e2 e1 n1, degree_exp_wrt_exp n1 e2 -> open_exp_wrt_exp_rec n1 e1 e2 = e2. Proof. pose proof open_exp_wrt_exp_rec_degree_exp_wrt_exp_mutual as H; intuition eauto. Qed. Hint Resolve open_exp_wrt_exp_rec_degree_exp_wrt_exp : lngen. Hint Rewrite open_exp_wrt_exp_rec_degree_exp_wrt_exp using solve [auto] : lngen. (* end hide *) Lemma open_exp_wrt_exp_lc_exp : forall e2 e1, lc_exp e2 -> open_exp_wrt_exp e2 e1 = e2. Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve open_exp_wrt_exp_lc_exp : lngen. Hint Rewrite open_exp_wrt_exp_lc_exp using solve [auto] : lngen. (* *********************************************************************** *) (** * Theorems about [fv] *) Ltac default_auto ::= auto with set lngen; tauto. Ltac default_autorewrite ::= autorewrite with lngen. (* begin hide *) Lemma fv_exp_close_exp_wrt_exp_rec_mutual : (forall e1 x1 n1, fv_exp (close_exp_wrt_exp_rec n1 x1 e1) [=] remove x1 (fv_exp e1)). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) (* begin hide *) Lemma fv_exp_close_exp_wrt_exp_rec : forall e1 x1 n1, fv_exp (close_exp_wrt_exp_rec n1 x1 e1) [=] remove x1 (fv_exp e1). Proof. pose proof fv_exp_close_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_close_exp_wrt_exp_rec : lngen. Hint Rewrite fv_exp_close_exp_wrt_exp_rec using solve [auto] : lngen. (* end hide *) Lemma fv_exp_close_exp_wrt_exp : forall e1 x1, fv_exp (close_exp_wrt_exp x1 e1) [=] remove x1 (fv_exp e1). Proof. unfold close_exp_wrt_exp; default_simp. Qed. Hint Resolve fv_exp_close_exp_wrt_exp : lngen. Hint Rewrite fv_exp_close_exp_wrt_exp using solve [auto] : lngen. (* begin hide *) Lemma fv_exp_open_exp_wrt_exp_rec_lower_mutual : (forall e1 e2 n1, fv_exp e1 [<=] fv_exp (open_exp_wrt_exp_rec n1 e2 e1)). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) (* begin hide *) Lemma fv_exp_open_exp_wrt_exp_rec_lower : forall e1 e2 n1, fv_exp e1 [<=] fv_exp (open_exp_wrt_exp_rec n1 e2 e1). Proof. pose proof fv_exp_open_exp_wrt_exp_rec_lower_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_open_exp_wrt_exp_rec_lower : lngen. (* end hide *) Lemma fv_exp_open_exp_wrt_exp_lower : forall e1 e2, fv_exp e1 [<=] fv_exp (open_exp_wrt_exp e1 e2). Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve fv_exp_open_exp_wrt_exp_lower : lngen. (* begin hide *) Lemma fv_exp_open_exp_wrt_exp_rec_upper_mutual : (forall e1 e2 n1, fv_exp (open_exp_wrt_exp_rec n1 e2 e1) [<=] fv_exp e2 `union` fv_exp e1). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) (* begin hide *) Lemma fv_exp_open_exp_wrt_exp_rec_upper : forall e1 e2 n1, fv_exp (open_exp_wrt_exp_rec n1 e2 e1) [<=] fv_exp e2 `union` fv_exp e1. Proof. pose proof fv_exp_open_exp_wrt_exp_rec_upper_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_open_exp_wrt_exp_rec_upper : lngen. (* end hide *) Lemma fv_exp_open_exp_wrt_exp_upper : forall e1 e2, fv_exp (open_exp_wrt_exp e1 e2) [<=] fv_exp e2 `union` fv_exp e1. Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve fv_exp_open_exp_wrt_exp_upper : lngen. (* begin hide *) Lemma fv_exp_subst_exp_fresh_mutual : (forall e1 e2 x1, x1 `notin` fv_exp e1 -> fv_exp (subst_exp e2 x1 e1) [=] fv_exp e1). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) Lemma fv_exp_subst_exp_fresh : forall e1 e2 x1, x1 `notin` fv_exp e1 -> fv_exp (subst_exp e2 x1 e1) [=] fv_exp e1. Proof. pose proof fv_exp_subst_exp_fresh_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_subst_exp_fresh : lngen. Hint Rewrite fv_exp_subst_exp_fresh using solve [auto] : lngen. (* begin hide *) Lemma fv_exp_subst_exp_lower_mutual : (forall e1 e2 x1, remove x1 (fv_exp e1) [<=] fv_exp (subst_exp e2 x1 e1)). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) Lemma fv_exp_subst_exp_lower : forall e1 e2 x1, remove x1 (fv_exp e1) [<=] fv_exp (subst_exp e2 x1 e1). Proof. pose proof fv_exp_subst_exp_lower_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_subst_exp_lower : lngen. (* begin hide *) Lemma fv_exp_subst_exp_notin_mutual : (forall e1 e2 x1 x2, x2 `notin` fv_exp e1 -> x2 `notin` fv_exp e2 -> x2 `notin` fv_exp (subst_exp e2 x1 e1)). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) Lemma fv_exp_subst_exp_notin : forall e1 e2 x1 x2, x2 `notin` fv_exp e1 -> x2 `notin` fv_exp e2 -> x2 `notin` fv_exp (subst_exp e2 x1 e1). Proof. pose proof fv_exp_subst_exp_notin_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_subst_exp_notin : lngen. (* begin hide *) Lemma fv_exp_subst_exp_upper_mutual : (forall e1 e2 x1, fv_exp (subst_exp e2 x1 e1) [<=] fv_exp e2 `union` remove x1 (fv_exp e1)). Proof. apply_mutual_ind exp_mutind; default_simp; fsetdec. Qed. (* end hide *) Lemma fv_exp_subst_exp_upper : forall e1 e2 x1, fv_exp (subst_exp e2 x1 e1) [<=] fv_exp e2 `union` remove x1 (fv_exp e1). Proof. pose proof fv_exp_subst_exp_upper_mutual as H; intuition eauto. Qed. Hint Resolve fv_exp_subst_exp_upper : lngen. (* *********************************************************************** *) (** * Theorems about [subst] *) Ltac default_auto ::= auto with lngen brute_force; tauto. Ltac default_autorewrite ::= autorewrite with lngen. (* begin hide *) Lemma subst_exp_close_exp_wrt_exp_rec_mutual : (forall e2 e1 x1 x2 n1, degree_exp_wrt_exp n1 e1 -> x1 <> x2 -> x2 `notin` fv_exp e1 -> subst_exp e1 x1 (close_exp_wrt_exp_rec n1 x2 e2) = close_exp_wrt_exp_rec n1 x2 (subst_exp e1 x1 e2)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_close_exp_wrt_exp_rec : forall e2 e1 x1 x2 n1, degree_exp_wrt_exp n1 e1 -> x1 <> x2 -> x2 `notin` fv_exp e1 -> subst_exp e1 x1 (close_exp_wrt_exp_rec n1 x2 e2) = close_exp_wrt_exp_rec n1 x2 (subst_exp e1 x1 e2). Proof. pose proof subst_exp_close_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_close_exp_wrt_exp_rec : lngen. Lemma subst_exp_close_exp_wrt_exp : forall e2 e1 x1 x2, lc_exp e1 -> x1 <> x2 -> x2 `notin` fv_exp e1 -> subst_exp e1 x1 (close_exp_wrt_exp x2 e2) = close_exp_wrt_exp x2 (subst_exp e1 x1 e2). Proof. unfold close_exp_wrt_exp; default_simp. Qed. Hint Resolve subst_exp_close_exp_wrt_exp : lngen. (* begin hide *) Lemma subst_exp_degree_exp_wrt_exp_mutual : (forall e1 e2 x1 n1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp n1 e2 -> degree_exp_wrt_exp n1 (subst_exp e2 x1 e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_degree_exp_wrt_exp : forall e1 e2 x1 n1, degree_exp_wrt_exp n1 e1 -> degree_exp_wrt_exp n1 e2 -> degree_exp_wrt_exp n1 (subst_exp e2 x1 e1). Proof. pose proof subst_exp_degree_exp_wrt_exp_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_degree_exp_wrt_exp : lngen. (* begin hide *) Lemma subst_exp_fresh_eq_mutual : (forall e2 e1 x1, x1 `notin` fv_exp e2 -> subst_exp e1 x1 e2 = e2). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_fresh_eq : forall e2 e1 x1, x1 `notin` fv_exp e2 -> subst_exp e1 x1 e2 = e2. Proof. pose proof subst_exp_fresh_eq_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_fresh_eq : lngen. Hint Rewrite subst_exp_fresh_eq using solve [auto] : lngen. (* begin hide *) Lemma subst_exp_fresh_same_mutual : (forall e2 e1 x1, x1 `notin` fv_exp e1 -> x1 `notin` fv_exp (subst_exp e1 x1 e2)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_fresh_same : forall e2 e1 x1, x1 `notin` fv_exp e1 -> x1 `notin` fv_exp (subst_exp e1 x1 e2). Proof. pose proof subst_exp_fresh_same_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_fresh_same : lngen. (* begin hide *) Lemma subst_exp_fresh_mutual : (forall e2 e1 x1 x2, x1 `notin` fv_exp e2 -> x1 `notin` fv_exp e1 -> x1 `notin` fv_exp (subst_exp e1 x2 e2)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_fresh : forall e2 e1 x1 x2, x1 `notin` fv_exp e2 -> x1 `notin` fv_exp e1 -> x1 `notin` fv_exp (subst_exp e1 x2 e2). Proof. pose proof subst_exp_fresh_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_fresh : lngen. Lemma subst_exp_lc_exp : forall e1 e2 x1, lc_exp e1 -> lc_exp e2 -> lc_exp (subst_exp e2 x1 e1). Proof. default_simp. Qed. Hint Resolve subst_exp_lc_exp : lngen. (* begin hide *) Lemma subst_exp_open_exp_wrt_exp_rec_mutual : (forall e3 e1 e2 x1 n1, lc_exp e1 -> subst_exp e1 x1 (open_exp_wrt_exp_rec n1 e2 e3) = open_exp_wrt_exp_rec n1 (subst_exp e1 x1 e2) (subst_exp e1 x1 e3)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma subst_exp_open_exp_wrt_exp_rec : forall e3 e1 e2 x1 n1, lc_exp e1 -> subst_exp e1 x1 (open_exp_wrt_exp_rec n1 e2 e3) = open_exp_wrt_exp_rec n1 (subst_exp e1 x1 e2) (subst_exp e1 x1 e3). Proof. pose proof subst_exp_open_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_open_exp_wrt_exp_rec : lngen. (* end hide *) Lemma subst_exp_open_exp_wrt_exp : forall e3 e1 e2 x1, lc_exp e1 -> subst_exp e1 x1 (open_exp_wrt_exp e3 e2) = open_exp_wrt_exp (subst_exp e1 x1 e3) (subst_exp e1 x1 e2). Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve subst_exp_open_exp_wrt_exp : lngen. Lemma subst_exp_open_exp_wrt_exp_var : forall e2 e1 x1 x2, x1 <> x2 -> lc_exp e1 -> open_exp_wrt_exp (subst_exp e1 x1 e2) (e_var_f x2) = subst_exp e1 x1 (open_exp_wrt_exp e2 (e_var_f x2)). Proof. intros; rewrite subst_exp_open_exp_wrt_exp; default_simp. Qed. Hint Resolve subst_exp_open_exp_wrt_exp_var : lngen. (* begin hide *) Lemma subst_exp_spec_rec_mutual : (forall e1 e2 x1 n1, subst_exp e2 x1 e1 = open_exp_wrt_exp_rec n1 e2 (close_exp_wrt_exp_rec n1 x1 e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) (* begin hide *) Lemma subst_exp_spec_rec : forall e1 e2 x1 n1, subst_exp e2 x1 e1 = open_exp_wrt_exp_rec n1 e2 (close_exp_wrt_exp_rec n1 x1 e1). Proof. pose proof subst_exp_spec_rec_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_spec_rec : lngen. (* end hide *) Lemma subst_exp_spec : forall e1 e2 x1, subst_exp e2 x1 e1 = open_exp_wrt_exp (close_exp_wrt_exp x1 e1) e2. Proof. unfold close_exp_wrt_exp; unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve subst_exp_spec : lngen. (* begin hide *) Lemma subst_exp_subst_exp_mutual : (forall e1 e2 e3 x2 x1, x2 `notin` fv_exp e2 -> x2 <> x1 -> subst_exp e2 x1 (subst_exp e3 x2 e1) = subst_exp (subst_exp e2 x1 e3) x2 (subst_exp e2 x1 e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_subst_exp : forall e1 e2 e3 x2 x1, x2 `notin` fv_exp e2 -> x2 <> x1 -> subst_exp e2 x1 (subst_exp e3 x2 e1) = subst_exp (subst_exp e2 x1 e3) x2 (subst_exp e2 x1 e1). Proof. pose proof subst_exp_subst_exp_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_subst_exp : lngen. (* begin hide *) Lemma subst_exp_close_exp_wrt_exp_rec_open_exp_wrt_exp_rec_mutual : (forall e2 e1 x1 x2 n1, x2 `notin` fv_exp e2 -> x2 `notin` fv_exp e1 -> x2 <> x1 -> degree_exp_wrt_exp n1 e1 -> subst_exp e1 x1 e2 = close_exp_wrt_exp_rec n1 x2 (subst_exp e1 x1 (open_exp_wrt_exp_rec n1 (e_var_f x2) e2))). Proof. apply_mutual_ind exp_mutrec; default_simp. Qed. (* end hide *) (* begin hide *) Lemma subst_exp_close_exp_wrt_exp_rec_open_exp_wrt_exp_rec : forall e2 e1 x1 x2 n1, x2 `notin` fv_exp e2 -> x2 `notin` fv_exp e1 -> x2 <> x1 -> degree_exp_wrt_exp n1 e1 -> subst_exp e1 x1 e2 = close_exp_wrt_exp_rec n1 x2 (subst_exp e1 x1 (open_exp_wrt_exp_rec n1 (e_var_f x2) e2)). Proof. pose proof subst_exp_close_exp_wrt_exp_rec_open_exp_wrt_exp_rec_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_close_exp_wrt_exp_rec_open_exp_wrt_exp_rec : lngen. (* end hide *) Lemma subst_exp_close_exp_wrt_exp_open_exp_wrt_exp : forall e2 e1 x1 x2, x2 `notin` fv_exp e2 -> x2 `notin` fv_exp e1 -> x2 <> x1 -> lc_exp e1 -> subst_exp e1 x1 e2 = close_exp_wrt_exp x2 (subst_exp e1 x1 (open_exp_wrt_exp e2 (e_var_f x2))). Proof. unfold close_exp_wrt_exp; unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve subst_exp_close_exp_wrt_exp_open_exp_wrt_exp : lngen. Lemma subst_exp_e_abs : forall x2 A1 e2 B1 e1 x1, lc_exp e1 -> x2 `notin` fv_exp e1 `union` fv_exp e2 `union` singleton x1 -> subst_exp e1 x1 (e_abs A1 e2 B1) = e_abs (A1) (close_exp_wrt_exp x2 (subst_exp e1 x1 (open_exp_wrt_exp e2 (e_var_f x2)))) (B1). Proof. default_simp. Qed. Hint Resolve subst_exp_e_abs : lngen. (* begin hide *) Lemma subst_exp_intro_rec_mutual : (forall e1 x1 e2 n1, x1 `notin` fv_exp e1 -> open_exp_wrt_exp_rec n1 e2 e1 = subst_exp e2 x1 (open_exp_wrt_exp_rec n1 (e_var_f x1) e1)). Proof. apply_mutual_ind exp_mutind; default_simp. Qed. (* end hide *) Lemma subst_exp_intro_rec : forall e1 x1 e2 n1, x1 `notin` fv_exp e1 -> open_exp_wrt_exp_rec n1 e2 e1 = subst_exp e2 x1 (open_exp_wrt_exp_rec n1 (e_var_f x1) e1). Proof. pose proof subst_exp_intro_rec_mutual as H; intuition eauto. Qed. Hint Resolve subst_exp_intro_rec : lngen. Hint Rewrite subst_exp_intro_rec using solve [auto] : lngen. Lemma subst_exp_intro : forall x1 e1 e2, x1 `notin` fv_exp e1 -> open_exp_wrt_exp e1 e2 = subst_exp e2 x1 (open_exp_wrt_exp e1 (e_var_f x1)). Proof. unfold open_exp_wrt_exp; default_simp. Qed. Hint Resolve subst_exp_intro : lngen. (* *********************************************************************** *) (** * "Restore" tactics *) Ltac default_auto ::= auto; tauto. Ltac default_autorewrite ::= fail.
Second Division 2 : 1937 – 38 , 1959 – 60
[GOAL] L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j G' : ℕ → Type w inst✝ : (i : ℕ) → Structure L (G' i) f' : (n : ℕ) → G' n ↪[L] G' (n + 1) m n : ℕ h : m ≤ n ⊢ ↑(natLERec f' m n h) = fun a => Nat.leRecOn h (fun k => ↑(f' k)) a [PROOFSTEP] obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h [GOAL] case intro L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j G' : ℕ → Type w inst✝ : (i : ℕ) → Structure L (G' i) f' : (n : ℕ) → G' n ↪[L] G' (n + 1) m k : ℕ h : m ≤ m + k ⊢ ↑(natLERec f' m (m + k) h) = fun a => Nat.leRecOn h (fun k => ↑(f' k)) a [PROOFSTEP] ext x [GOAL] case intro.h L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j G' : ℕ → Type w inst✝ : (i : ℕ) → Structure L (G' i) f' : (n : ℕ) → G' n ↪[L] G' (n + 1) m k : ℕ h : m ≤ m + k x : G' m ⊢ ↑(natLERec f' m (m + k) h) x = Nat.leRecOn h (fun k => ↑(f' k)) x [PROOFSTEP] induction' k with k ih [GOAL] case intro.h.zero L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j G' : ℕ → Type w inst✝ : (i : ℕ) → Structure L (G' i) f' : (n : ℕ) → G' n ↪[L] G' (n + 1) m k : ℕ h✝ : m ≤ m + k x : G' m h : m ≤ m + Nat.zero ⊢ ↑(natLERec f' m (m + Nat.zero) h) x = Nat.leRecOn h (fun k => ↑(f' k)) x [PROOFSTEP] rw [natLERec, Nat.leRecOn_self, Embedding.refl_apply, Nat.leRecOn_self] [GOAL] case intro.h.succ L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j G' : ℕ → Type w inst✝ : (i : ℕ) → Structure L (G' i) f' : (n : ℕ) → G' n ↪[L] G' (n + 1) m k✝ : ℕ h✝ : m ≤ m + k✝ x : G' m k : ℕ ih : ∀ (h : m ≤ m + k), ↑(natLERec f' m (m + k) h) x = Nat.leRecOn h (fun k => ↑(f' k)) x h : m ≤ m + Nat.succ k ⊢ ↑(natLERec f' m (m + Nat.succ k) h) x = Nat.leRecOn h (fun k => ↑(f' k)) x [PROOFSTEP] rw [Nat.leRecOn_succ le_self_add, natLERec, Nat.leRecOn_succ le_self_add, ← natLERec, Embedding.comp_apply, ih] [GOAL] L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j G' : ℕ → Type w inst✝ : (i : ℕ) → Structure L (G' i) f' : (n : ℕ) → G' n ↪[L] G' (n + 1) i✝ j✝ k✝ : ℕ hij : i✝ ≤ j✝ hjk : j✝ ≤ k✝ ⊢ ∀ (x : G' i✝), ↑(natLERec f' j✝ k✝ hjk) (↑(natLERec f' i✝ j✝ hij) x) = ↑(natLERec f' i✝ k✝ (_ : i✝ ≤ k✝)) x [PROOFSTEP] simp [Nat.leRecOn_trans hij hjk] [GOAL] L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝ : DirectedSystem G fun i j h => ↑(f i j h) α : Type u_1 i : ι x : α → G i ⊢ unify f (fun a => Structure.Sigma.mk f i (x a)) i (_ : ∀ (j : ι), j ∈ range (Sigma.fst ∘ fun a => Structure.Sigma.mk f i (x a)) → j ≤ i) = x [PROOFSTEP] ext a [GOAL] case h L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝ : DirectedSystem G fun i j h => ↑(f i j h) α : Type u_1 i : ι x : α → G i a : α ⊢ unify f (fun a => Structure.Sigma.mk f i (x a)) i (_ : ∀ (j : ι), j ∈ range (Sigma.fst ∘ fun a => Structure.Sigma.mk f i (x a)) → j ≤ i) a = x a [PROOFSTEP] rw [unify] [GOAL] case h L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝ : DirectedSystem G fun i j h => ↑(f i j h) α : Type u_1 i : ι x : α → G i a : α ⊢ ↑(f (Structure.Sigma.mk f i (x a)).fst i (_ : (Structure.Sigma.mk f i (x a)).fst ≤ i)) (Structure.Sigma.mk f i (x a)).snd = x a [PROOFSTEP] apply DirectedSystem.map_self [GOAL] L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝ : DirectedSystem G fun i j h => ↑(f i j h) α : Type u_1 x : α → Σˣ f i j : ι ij : i ≤ j h : i ∈ upperBounds (range (Sigma.fst ∘ x)) ⊢ ↑(f i j ij) ∘ unify f x i h = unify f x j (_ : ∀ (k : ι), k ∈ range (Sigma.fst ∘ x) → k ≤ j) [PROOFSTEP] ext a [GOAL] case h L : Language ι : Type v inst✝² : Preorder ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝ : DirectedSystem G fun i j h => ↑(f i j h) α : Type u_1 x : α → Σˣ f i j : ι ij : i ≤ j h : i ∈ upperBounds (range (Sigma.fst ∘ x)) a : α ⊢ (↑(f i j ij) ∘ unify f x i h) a = unify f x j (_ : ∀ (k : ι), k ∈ range (Sigma.fst ∘ x) → k ≤ j) a [PROOFSTEP] simp [unify, DirectedSystem.map_map] [GOAL] L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ⊢ match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y [PROOFSTEP] obtain ⟨ijk, hijijk, hjkijk⟩ := directed_of (· ≤ ·) ij jk [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y [PROOFSTEP] refine' ⟨ijk, le_trans hiij hijijk, le_trans hkjk hjkijk, _⟩ [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ↑(f i ijk (_ : i ≤ ijk)) x = ↑(f k ijk (_ : k ≤ ijk)) z [PROOFSTEP] rw [← DirectedSystem.map_map, hij, DirectedSystem.map_map] [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ↑(f j ijk (_ : j ≤ ijk)) y = ↑(f k ijk (_ : k ≤ ijk)) z case intro.intro.hjk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ij ≤ ijk case intro.intro.hjk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ij ≤ ijk case intro.intro.hjk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ij ≤ ijk [PROOFSTEP] symm [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ↑(f k ijk (_ : k ≤ ijk)) z = ↑(f j ijk (_ : j ≤ ijk)) y [PROOFSTEP] rw [← DirectedSystem.map_map, ← hjk, DirectedSystem.map_map] [GOAL] case intro.intro.hjk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ jk ≤ ijk [PROOFSTEP] assumption [GOAL] case intro.intro.hjk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : IsDirected ι fun x x_1 => x ≤ x_1 x✝⁴ x✝³ x✝² : Σˣ f i : ι x : (fun i => G i) i j : ι y : (fun i => G i) j x✝¹ : match { fst := i, snd := x } with | { fst := i, snd := x } => match { fst := j, snd := y } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y k : ι z : (fun i => G i) k x✝ : match { fst := j, snd := y } with | { fst := i, snd := x } => match { fst := k, snd := z } with | { fst := j, snd := y } => ∃ k ik jk, ↑(f i k ik) x = ↑(f j k jk) y ij : ι hiij : i ≤ ij hjij : j ≤ ij hij : ↑(f i ij hiij) x = ↑(f j ij hjij) y jk : ι hjjk : j ≤ jk hkjk : k ≤ jk hjk : ↑(f j jk hjjk) y = ↑(f k jk hkjk) z ijk : ι hijijk : ij ≤ ijk hjkijk : jk ≤ ijk ⊢ ij ≤ ijk [PROOFSTEP] assumption [GOAL] L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) x y : Σˣ f i : ι hx : x.fst ≤ i hy : y.fst ≤ i ⊢ x ≈ y ↔ ↑(f x.fst i hx) x.snd = ↑(f y.fst i hy) y.snd [PROOFSTEP] cases x [GOAL] case mk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) y : Σˣ f i : ι hy : y.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hx : { fst := fst✝, snd := snd✝ }.fst ≤ i ⊢ { fst := fst✝, snd := snd✝ } ≈ y ↔ ↑(f { fst := fst✝, snd := snd✝ }.fst i hx) { fst := fst✝, snd := snd✝ }.snd = ↑(f y.fst i hy) y.snd [PROOFSTEP] cases y [GOAL] case mk.mk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i ⊢ { fst := fst✝¹, snd := snd✝¹ } ≈ { fst := fst✝, snd := snd✝ } ↔ ↑(f { fst := fst✝¹, snd := snd✝¹ }.fst i hx) { fst := fst✝¹, snd := snd✝¹ }.snd = ↑(f { fst := fst✝, snd := snd✝ }.fst i hy) { fst := fst✝, snd := snd✝ }.snd [PROOFSTEP] refine' ⟨fun xy => _, fun xy => ⟨i, hx, hy, xy⟩⟩ [GOAL] case mk.mk L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i xy : { fst := fst✝¹, snd := snd✝¹ } ≈ { fst := fst✝, snd := snd✝ } ⊢ ↑(f { fst := fst✝¹, snd := snd✝¹ }.fst i hx) { fst := fst✝¹, snd := snd✝¹ }.snd = ↑(f { fst := fst✝, snd := snd✝ }.fst i hy) { fst := fst✝, snd := snd✝ }.snd [PROOFSTEP] obtain ⟨j, _, _, h⟩ := xy [GOAL] case mk.mk.intro.intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i j : ι w✝¹ : fst✝¹ ≤ j w✝ : fst✝ ≤ j h : ↑(f fst✝¹ j w✝¹) snd✝¹ = ↑(f fst✝ j w✝) snd✝ ⊢ ↑(f { fst := fst✝¹, snd := snd✝¹ }.fst i hx) { fst := fst✝¹, snd := snd✝¹ }.snd = ↑(f { fst := fst✝, snd := snd✝ }.fst i hy) { fst := fst✝, snd := snd✝ }.snd [PROOFSTEP] obtain ⟨k, ik, jk⟩ := directed_of (· ≤ ·) i j [GOAL] case mk.mk.intro.intro.intro.intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i j : ι w✝¹ : fst✝¹ ≤ j w✝ : fst✝ ≤ j h : ↑(f fst✝¹ j w✝¹) snd✝¹ = ↑(f fst✝ j w✝) snd✝ k : ι ik : i ≤ k jk : j ≤ k ⊢ ↑(f { fst := fst✝¹, snd := snd✝¹ }.fst i hx) { fst := fst✝¹, snd := snd✝¹ }.snd = ↑(f { fst := fst✝, snd := snd✝ }.fst i hy) { fst := fst✝, snd := snd✝ }.snd [PROOFSTEP] have h := congr_arg (f j k jk) h [GOAL] case mk.mk.intro.intro.intro.intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i j : ι w✝¹ : fst✝¹ ≤ j w✝ : fst✝ ≤ j h✝ : ↑(f fst✝¹ j w✝¹) snd✝¹ = ↑(f fst✝ j w✝) snd✝ k : ι ik : i ≤ k jk : j ≤ k h : ↑(f j k jk) (↑(f fst✝¹ j w✝¹) snd✝¹) = ↑(f j k jk) (↑(f fst✝ j w✝) snd✝) ⊢ ↑(f { fst := fst✝¹, snd := snd✝¹ }.fst i hx) { fst := fst✝¹, snd := snd✝¹ }.snd = ↑(f { fst := fst✝, snd := snd✝ }.fst i hy) { fst := fst✝, snd := snd✝ }.snd [PROOFSTEP] apply (f i k ik).injective [GOAL] case mk.mk.intro.intro.intro.intro.intro.a L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i j : ι w✝¹ : fst✝¹ ≤ j w✝ : fst✝ ≤ j h✝ : ↑(f fst✝¹ j w✝¹) snd✝¹ = ↑(f fst✝ j w✝) snd✝ k : ι ik : i ≤ k jk : j ≤ k h : ↑(f j k jk) (↑(f fst✝¹ j w✝¹) snd✝¹) = ↑(f j k jk) (↑(f fst✝ j w✝) snd✝) ⊢ ↑(f i k ik) (↑(f { fst := fst✝¹, snd := snd✝¹ }.fst i hx) { fst := fst✝¹, snd := snd✝¹ }.snd) = ↑(f i k ik) (↑(f { fst := fst✝, snd := snd✝ }.fst i hy) { fst := fst✝, snd := snd✝ }.snd) [PROOFSTEP] rw [DirectedSystem.map_map, DirectedSystem.map_map] at * [GOAL] case mk.mk.intro.intro.intro.intro.intro.a L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) i fst✝¹ : ι snd✝¹ : (fun i => G i) fst✝¹ hx : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ i fst✝ : ι snd✝ : (fun i => G i) fst✝ hy : { fst := fst✝, snd := snd✝ }.fst ≤ i j : ι w✝¹ : fst✝¹ ≤ j w✝ : fst✝ ≤ j h✝ : ↑(f fst✝¹ j w✝¹) snd✝¹ = ↑(f fst✝ j w✝) snd✝ k : ι ik : i ≤ k jk : j ≤ k h : ↑(f fst✝¹ k (_ : fst✝¹ ≤ k)) snd✝¹ = ↑(f fst✝ k (_ : fst✝ ≤ k)) snd✝ ⊢ ↑(f { fst := fst✝¹, snd := snd✝¹ }.fst k (_ : { fst := fst✝¹, snd := snd✝¹ }.fst ≤ k)) { fst := fst✝¹, snd := snd✝¹ }.snd = ↑(f { fst := fst✝, snd := snd✝ }.fst k (_ : { fst := fst✝, snd := snd✝ }.fst ≤ k)) { fst := fst✝, snd := snd✝ }.snd [PROOFSTEP] exact h [GOAL] L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) n : ℕ F : Functions L n x : Fin n → Σˣ f i j : ι hi : i ∈ upperBounds (range (Sigma.fst ∘ x)) hj : j ∈ upperBounds (range (Sigma.fst ∘ x)) ⊢ Structure.Sigma.mk f i (funMap F (unify f x i hi)) ≈ Structure.Sigma.mk f j (funMap F (unify f x j hj)) [PROOFSTEP] obtain ⟨k, ik, jk⟩ := directed_of (· ≤ ·) i j [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) n : ℕ F : Functions L n x : Fin n → Σˣ f i j : ι hi : i ∈ upperBounds (range (Sigma.fst ∘ x)) hj : j ∈ upperBounds (range (Sigma.fst ∘ x)) k : ι ik : i ≤ k jk : j ≤ k ⊢ Structure.Sigma.mk f i (funMap F (unify f x i hi)) ≈ Structure.Sigma.mk f j (funMap F (unify f x j hj)) [PROOFSTEP] refine' ⟨k, ik, jk, _⟩ [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) n : ℕ F : Functions L n x : Fin n → Σˣ f i j : ι hi : i ∈ upperBounds (range (Sigma.fst ∘ x)) hj : j ∈ upperBounds (range (Sigma.fst ∘ x)) k : ι ik : i ≤ k jk : j ≤ k ⊢ ↑(f i k ik) (funMap F (unify f x i hi)) = ↑(f j k jk) (funMap F (unify f x j hj)) [PROOFSTEP] rw [(f i k ik).map_fun, (f j k jk).map_fun, comp_unify, comp_unify] [GOAL] L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) n : ℕ R : Relations L n x : Fin n → Σˣ f i j : ι hi : i ∈ upperBounds (range (Sigma.fst ∘ x)) hj : j ∈ upperBounds (range (Sigma.fst ∘ x)) ⊢ RelMap R (unify f x i hi) = RelMap R (unify f x j hj) [PROOFSTEP] obtain ⟨k, ik, jk⟩ := directed_of (· ≤ ·) i j [GOAL] case intro.intro L : Language ι : Type v inst✝³ : Preorder ι G : ι → Type w inst✝² : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝ : DirectedSystem G fun i j h => ↑(f i j h) n : ℕ R : Relations L n x : Fin n → Σˣ f i j : ι hi : i ∈ upperBounds (range (Sigma.fst ∘ x)) hj : j ∈ upperBounds (range (Sigma.fst ∘ x)) k : ι ik : i ≤ k jk : j ≤ k ⊢ RelMap R (unify f x i hi) = RelMap R (unify f x j hj) [PROOFSTEP] rw [← (f i k ik).map_rel, comp_unify, ← (f j k jk).map_rel, comp_unify] [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x y : α → Σˣ f xy : x ≈ y ⊢ ∃ i hx hy, unify f x i hx = unify f y i hy [PROOFSTEP] obtain ⟨i, hi⟩ := Fintype.bddAbove_range (Sum.elim (fun a => (x a).1) fun a => (y a).1) [GOAL] case intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x y : α → Σˣ f xy : x ≈ y i : ι hi : i ∈ upperBounds (range (Sum.elim (fun a => (x a).fst) fun a => (y a).fst)) ⊢ ∃ i hx hy, unify f x i hx = unify f y i hy [PROOFSTEP] rw [Sum.elim_range, upperBounds_union] at hi [GOAL] case intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x y : α → Σˣ f xy : x ≈ y i : ι hi : i ∈ upperBounds (range fun a => (x a).fst) ∩ upperBounds (range fun a => (y a).fst) ⊢ ∃ i hx hy, unify f x i hx = unify f y i hy [PROOFSTEP] simp_rw [← Function.comp_apply (f := Sigma.fst)] at hi [GOAL] case intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x y : α → Σˣ f xy : x ≈ y i : ι hi : i ∈ upperBounds (range fun a => (Sigma.fst ∘ x) a) ∩ upperBounds (range fun a => (Sigma.fst ∘ y) a) ⊢ ∃ i hx hy, unify f x i hx = unify f y i hy [PROOFSTEP] exact ⟨i, hi.1, hi.2, funext fun a => (equiv_iff G f _ _).1 (xy a)⟩ [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n x y : Fin n → Σˣ f xy : x ≈ y ⊢ funMap F x ≈ funMap F y [PROOFSTEP] obtain ⟨i, hx, hy, h⟩ := exists_unify_eq G f xy [GOAL] case intro.intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n x y : Fin n → Σˣ f xy : x ≈ y i : ι hx : i ∈ upperBounds (range (Sigma.fst ∘ x)) hy : i ∈ upperBounds (range (Sigma.fst ∘ y)) h : unify f x i hx = unify f y i hy ⊢ funMap F x ≈ funMap F y [PROOFSTEP] refine' Setoid.trans (funMap_equiv_unify G f F x i hx) (Setoid.trans _ (Setoid.symm (funMap_equiv_unify G f F y i hy))) [GOAL] case intro.intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n x y : Fin n → Σˣ f xy : x ≈ y i : ι hx : i ∈ upperBounds (range (Sigma.fst ∘ x)) hy : i ∈ upperBounds (range (Sigma.fst ∘ y)) h : unify f x i hx = unify f y i hy ⊢ Structure.Sigma.mk f i (funMap F (unify f x i hx)) ≈ Structure.Sigma.mk f i (funMap F (unify f y i hy)) [PROOFSTEP] rw [h] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n x y : Fin n → Σˣ f xy : x ≈ y ⊢ RelMap R x = RelMap R y [PROOFSTEP] obtain ⟨i, hx, hy, h⟩ := exists_unify_eq G f xy [GOAL] case intro.intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n x y : Fin n → Σˣ f xy : x ≈ y i : ι hx : i ∈ upperBounds (range (Sigma.fst ∘ x)) hy : i ∈ upperBounds (range (Sigma.fst ∘ y)) h : unify f x i hx = unify f y i hy ⊢ RelMap R x = RelMap R y [PROOFSTEP] refine' _root_.trans (relMap_equiv_unify G f R x i hx) (_root_.trans _ (symm (relMap_equiv_unify G f R y i hy))) [GOAL] case intro.intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n x y : Fin n → Σˣ f xy : x ≈ y i : ι hx : i ∈ upperBounds (range (Sigma.fst ∘ x)) hy : i ∈ upperBounds (range (Sigma.fst ∘ y)) h : unify f x i hx = unify f y i hy ⊢ RelMap R (unify f x i hx) = RelMap R (unify f y i hy) [PROOFSTEP] rw [h] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n i : ι x : Fin n → G i ⊢ (funMap F fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (x a))) = Quotient.mk (setoid G f) (Structure.Sigma.mk f i (funMap F x)) [PROOFSTEP] simp [Function.comp_apply, funMap_quotient_mk', Quotient.eq'] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n i : ι x : Fin n → G i ⊢ (funMap F fun i_1 => Structure.Sigma.mk f i (x i_1)) ≈ Structure.Sigma.mk f i (funMap F x) [PROOFSTEP] obtain ⟨k, ik, jk⟩ := directed_of (· ≤ ·) i (Classical.choose (Fintype.bddAbove_range fun _ : Fin n => i)) [GOAL] case intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n i : ι x : Fin n → G i k : ι ik : i ≤ k jk : Classical.choose (_ : BddAbove (range fun x => i)) ≤ k ⊢ (funMap F fun i_1 => Structure.Sigma.mk f i (x i_1)) ≈ Structure.Sigma.mk f i (funMap F x) [PROOFSTEP] refine' ⟨k, jk, ik, _⟩ [GOAL] case intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n i : ι x : Fin n → G i k : ι ik : i ≤ k jk : Classical.choose (_ : BddAbove (range fun x => i)) ≤ k ⊢ ↑(f (Classical.choose (_ : BddAbove (range fun a => (Structure.Sigma.mk f i (x a)).fst))) k jk) (funMap F (unify f (fun i_1 => Structure.Sigma.mk f i (x i_1)) (Classical.choose (_ : BddAbove (range fun a => (Structure.Sigma.mk f i (x a)).fst))) (_ : Classical.choose (_ : BddAbove (range fun a => (Structure.Sigma.mk f i (x a)).fst)) ∈ upperBounds (range fun a => (Structure.Sigma.mk f i (x a)).fst)))) = ↑(f i k ik) (funMap F x) [PROOFSTEP] simp only [Embedding.map_fun, comp_unify] [GOAL] case intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ F : Functions L n i : ι x : Fin n → G i k : ι ik : i ≤ k jk : Classical.choose (_ : BddAbove (range fun x => i)) ≤ k ⊢ funMap F (unify f (fun i_1 => Structure.Sigma.mk f i (x i_1)) k (_ : ∀ (k_1 : ι), k_1 ∈ range (Sigma.fst ∘ fun i_1 => Structure.Sigma.mk f i (x i_1)) → k_1 ≤ k)) = funMap F (↑(f i k ik) ∘ x) [PROOFSTEP] rfl [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n i : ι x : Fin n → G i ⊢ (RelMap R fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (x a))) = RelMap R x [PROOFSTEP] rw [relMap_quotient_mk'] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n i : ι x : Fin n → G i ⊢ (RelMap R fun a => Structure.Sigma.mk f i (x a)) = RelMap R x [PROOFSTEP] obtain ⟨k, _, _⟩ := directed_of (· ≤ ·) i (Classical.choose (Fintype.bddAbove_range fun _ : Fin n => i)) [GOAL] case intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n i : ι x : Fin n → G i k : ι left✝ : i ≤ k right✝ : Classical.choose (_ : BddAbove (range fun x => i)) ≤ k ⊢ (RelMap R fun a => Structure.Sigma.mk f i (x a)) = RelMap R x [PROOFSTEP] rw [relMap_equiv_unify G f R (fun a => .mk f i (x a)) i] [GOAL] case intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n i : ι x : Fin n → G i k : ι left✝ : i ≤ k right✝ : Classical.choose (_ : BddAbove (range fun x => i)) ≤ k ⊢ RelMap R (unify f (fun a => Structure.Sigma.mk f i (x a)) i ?intro.intro) = RelMap R x case intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι n : ℕ R : Relations L n i : ι x : Fin n → G i k : ι left✝ : i ≤ k right✝ : Classical.choose (_ : BddAbove (range fun x => i)) ≤ k ⊢ i ∈ upperBounds (range (Sigma.fst ∘ fun a => Structure.Sigma.mk f i (x a))) [PROOFSTEP] rw [unify_sigma_mk_self] [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f ⊢ ∃ i y, x = fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a)) [PROOFSTEP] obtain ⟨i, hi⟩ := Fintype.bddAbove_range fun a => (x a).out.1 [GOAL] case intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) ⊢ ∃ i y, x = fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a)) [PROOFSTEP] refine' ⟨i, unify f (Quotient.out ∘ x) i hi, _⟩ [GOAL] case intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) ⊢ x = fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (unify f (Quotient.out ∘ x) i hi a)) [PROOFSTEP] ext a [GOAL] case intro.h L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α ⊢ x a = Quotient.mk (setoid G f) (Structure.Sigma.mk f i (unify f (Quotient.out ∘ x) i hi a)) [PROOFSTEP] rw [Quotient.eq_mk_iff_out, unify] [GOAL] case intro.h L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α ⊢ Quotient.out (x a) ≈ Structure.Sigma.mk f i (↑(f ((Quotient.out ∘ x) a).fst i (_ : ((Quotient.out ∘ x) a).fst ≤ i)) ((Quotient.out ∘ x) a).snd) [PROOFSTEP] generalize_proofs r [GOAL] case intro.h L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α r : ((Quotient.out ∘ x) a).fst ≤ i ⊢ Quotient.out (x a) ≈ Structure.Sigma.mk f i (↑(f ((Quotient.out ∘ x) a).fst i r) ((Quotient.out ∘ x) a).snd) [PROOFSTEP] change _ ≈ .mk f i (f (Quotient.out (x a)).fst i r (Quotient.out (x a)).snd) [GOAL] case intro.h L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α r : ((Quotient.out ∘ x) a).fst ≤ i ⊢ Quotient.out (x a) ≈ Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd) [PROOFSTEP] have : (.mk f i (f (Quotient.out (x a)).fst i r (Quotient.out (x a)).snd) : Σˣ f).fst ≤ i := le_rfl [GOAL] case intro.h L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α r : ((Quotient.out ∘ x) a).fst ≤ i this : (Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd)).fst ≤ i ⊢ Quotient.out (x a) ≈ Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd) [PROOFSTEP] rw [equiv_iff G f (i := i) (hi _) this] [GOAL] case intro.h L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α r : ((Quotient.out ∘ x) a).fst ≤ i this : (Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd)).fst ≤ i ⊢ ↑(f (Quotient.out (x a)).fst i (_ : (Quotient.out (x a)).fst ≤ i)) (Quotient.out (x a)).snd = ↑(f (Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd)).fst i this) (Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd)).snd [PROOFSTEP] simp only [DirectedSystem.map_self] [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι α : Type u_1 inst✝ : Fintype α x : α → DirectLimit G f i : ι hi : i ∈ upperBounds (range fun a => (Quotient.out (x a)).fst) a : α r : ((Quotient.out ∘ x) a).fst ≤ i this : (Structure.Sigma.mk f i (↑(f (Quotient.out (x a)).fst i r) (Quotient.out (x a)).snd)).fst ≤ i ⊢ (Quotient.out (x a)).fst ∈ range fun a => (Quotient.out (x a)).fst [PROOFSTEP] exact ⟨a, rfl⟩ [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι x y : G i h : (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) x = (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) y ⊢ x = y [PROOFSTEP] rw [Quotient.eq] at h [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι x y : G i h : Structure.Sigma.mk f i x ≈ Structure.Sigma.mk f i y ⊢ x = y [PROOFSTEP] obtain ⟨j, h1, _, h3⟩ := h [GOAL] case intro.intro.intro L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι x y : G i j : ι h1 w✝ : i ≤ j h3 : ↑(f i j h1) x = ↑(f i j w✝) y ⊢ x = y [PROOFSTEP] exact (f i j h1).injective h3 [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι n✝ : ℕ F : Functions L n✝ x : Fin n✝ → G i ⊢ Function.Embedding.toFun { toFun := fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a), inj' := (_ : ∀ (x y : G i), (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) x = (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) y → x = y) } (funMap F x) = funMap F ({ toFun := fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a), inj' := (_ : ∀ (x y : G i), (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) x = (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) y → x = y) }.toFun ∘ x) [PROOFSTEP] simp [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι n✝ : ℕ F : Functions L n✝ x : Fin n✝ → G i ⊢ Quotient.mk (setoid G f) (Structure.Sigma.mk f i (funMap F x)) = funMap F ((fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) ∘ x) [PROOFSTEP] rw [← funMap_quotient_mk'_sigma_mk'] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι n✝ : ℕ F : Functions L n✝ x : Fin n✝ → G i ⊢ (funMap F fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (x a))) = funMap F ((fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) ∘ x) [PROOFSTEP] rfl [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι ⊢ ∀ {n : ℕ} (r : Relations L n) (x : Fin n → G i), RelMap r ({ toFun := fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a), inj' := (_ : ∀ (x y : G i), (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) x = (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) y → x = y) }.toFun ∘ x) ↔ RelMap r x [PROOFSTEP] intro n R x [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι n : ℕ R : Relations L n x : Fin n → G i ⊢ RelMap R ({ toFun := fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a), inj' := (_ : ∀ (x y : G i), (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) x = (fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i a)) y → x = y) }.toFun ∘ x) ↔ RelMap R x [PROOFSTEP] change RelMap R (fun a => (⟦.mk f i (x a)⟧ : DirectLimit G f)) ↔ _ [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i : ι n : ℕ R : Relations L n x : Fin n → G i ⊢ (RelMap R fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (x a))) ↔ RelMap R x [PROOFSTEP] simp only [relMap_quotient_mk'_sigma_mk'] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i j : ι hij : i ≤ j x : G i ⊢ ↑(of L ι G f j) (↑(f i j hij) x) = ↑(of L ι G f i) x [PROOFSTEP] rw [of_apply, of_apply, Quotient.eq] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i j : ι hij : i ≤ j x : G i ⊢ Structure.Sigma.mk f j (↑(f i j hij) x) ≈ Structure.Sigma.mk f i x [PROOFSTEP] refine' Setoid.symm ⟨j, hij, refl j, _⟩ [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι i j : ι hij : i ≤ j x : G i ⊢ ↑(f i j hij) x = ↑(f j j (_ : j ≤ j)) (↑(f i j hij) x) [PROOFSTEP] simp only [DirectedSystem.map_self] [GOAL] L : Language ι : Type v inst✝⁴ : Preorder ι G : ι → Type w inst✝³ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝² : IsDirected ι fun x x_1 => x ≤ x_1 inst✝¹ : DirectedSystem G fun i j h => ↑(f i j h) inst✝ : Nonempty ι z : DirectLimit G f ⊢ ↑(of L ι G f (Quotient.out z).fst) (Quotient.out z).snd = z [PROOFSTEP] simp [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : Σˣ f xy : x ≈ y ⊢ (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y [PROOFSTEP] simp [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : Σˣ f xy : x ≈ y ⊢ ↑(g x.fst) x.snd = ↑(g y.fst) y.snd [PROOFSTEP] obtain ⟨i, hx, hy⟩ := directed_of (· ≤ ·) x.1 y.1 [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : Σˣ f xy : x ≈ y i : ι hx : x.fst ≤ i hy : y.fst ≤ i ⊢ ↑(g x.fst) x.snd = ↑(g y.fst) y.snd [PROOFSTEP] rw [← Hg x.1 i hx, ← Hg y.1 i hy] [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : Σˣ f xy : x ≈ y i : ι hx : x.fst ≤ i hy : y.fst ≤ i ⊢ ↑(g i) (↑(f x.fst i hx) x.snd) = ↑(g i) (↑(f y.fst i hy) y.snd) [PROOFSTEP] exact congr_arg _ ((equiv_iff ..).1 xy) [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : DirectLimit G f xy : Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y ⊢ x = y [PROOFSTEP] rw [← Quotient.out_eq x, ← Quotient.out_eq y, Quotient.lift_mk, Quotient.lift_mk] at xy [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : DirectLimit G f xy : ↑(g (Quotient.out x).fst) (Quotient.out x).snd = ↑(g (Quotient.out y).fst) (Quotient.out y).snd ⊢ x = y [PROOFSTEP] obtain ⟨i, hx, hy⟩ := directed_of (· ≤ ·) x.out.1 y.out.1 [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : DirectLimit G f xy : ↑(g (Quotient.out x).fst) (Quotient.out x).snd = ↑(g (Quotient.out y).fst) (Quotient.out y).snd i : ι hx : (Quotient.out x).fst ≤ i hy : (Quotient.out y).fst ≤ i ⊢ x = y [PROOFSTEP] rw [← Hg x.out.1 i hx, ← Hg y.out.1 i hy] at xy [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : DirectLimit G f i : ι hx : (Quotient.out x).fst ≤ i hy : (Quotient.out y).fst ≤ i xy : ↑(g i) (↑(f (Quotient.out x).fst i hx) (Quotient.out x).snd) = ↑(g i) (↑(f (Quotient.out y).fst i hy) (Quotient.out y).snd) ⊢ x = y [PROOFSTEP] rw [← Quotient.out_eq x, ← Quotient.out_eq y, Quotient.eq, equiv_iff G f hx hy] [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x x y : DirectLimit G f i : ι hx : (Quotient.out x).fst ≤ i hy : (Quotient.out y).fst ≤ i xy : ↑(g i) (↑(f (Quotient.out x).fst i hx) (Quotient.out x).snd) = ↑(g i) (↑(f (Quotient.out y).fst i hy) (Quotient.out y).snd) ⊢ ↑(f (Quotient.out x).fst i hx) (Quotient.out x).snd = ↑(f (Quotient.out y).fst i hy) (Quotient.out y).snd [PROOFSTEP] exact (g i).injective xy [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ F : Functions L n✝ x : Fin n✝ → DirectLimit G f ⊢ Function.Embedding.toFun { toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) } (funMap F x) = funMap F ({ toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) }.toFun ∘ x) [PROOFSTEP] obtain ⟨i, y, rfl⟩ := exists_quotient_mk'_sigma_mk'_eq G f x [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ F : Functions L n✝ i : ι y : Fin n✝ → G i ⊢ Function.Embedding.toFun { toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) } (funMap F fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a))) = funMap F ({ toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) }.toFun ∘ fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a))) [PROOFSTEP] change _ = funMap F (Quotient.lift _ _ ∘ Quotient.mk _ ∘ Structure.Sigma.mk f i ∘ y) [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ F : Functions L n✝ i : ι y : Fin n✝ → G i ⊢ Function.Embedding.toFun { toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) } (funMap F fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a))) = funMap F (Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) ∘ Quotient.mk (setoid G f) ∘ Structure.Sigma.mk f i ∘ y) [PROOFSTEP] rw [funMap_quotient_mk'_sigma_mk', ← Function.comp.assoc, Quotient.lift_comp_mk] [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ F : Functions L n✝ i : ι y : Fin n✝ → G i ⊢ Function.Embedding.toFun { toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) } (Quotient.mk (setoid G f) (Structure.Sigma.mk f i (funMap F fun a => y a))) = funMap F ((fun x => ↑(g x.fst) x.snd) ∘ Structure.Sigma.mk f i ∘ y) [PROOFSTEP] simp only [Quotient.lift_mk, Embedding.map_fun] [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ F : Functions L n✝ i : ι y : Fin n✝ → G i ⊢ funMap F (↑(g i) ∘ fun a => y a) = funMap F ((fun x => ↑(g x.fst) x.snd) ∘ Structure.Sigma.mk f i ∘ y) [PROOFSTEP] rfl [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ R : Relations L n✝ x : Fin n✝ → DirectLimit G f ⊢ RelMap R ({ toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) }.toFun ∘ x) ↔ RelMap R x [PROOFSTEP] obtain ⟨i, y, rfl⟩ := exists_quotient_mk'_sigma_mk'_eq G f x [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ R : Relations L n✝ i : ι y : Fin n✝ → G i ⊢ RelMap R ({ toFun := Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y), inj' := (_ : ∀ (x y : DirectLimit G f), Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) x = Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) y → x = y) }.toFun ∘ fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a))) ↔ RelMap R fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a)) [PROOFSTEP] change RelMap R (Quotient.lift _ _ ∘ Quotient.mk _ ∘ Structure.Sigma.mk f i ∘ y) ↔ _ [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ R : Relations L n✝ i : ι y : Fin n✝ → G i ⊢ RelMap R (Quotient.lift (fun x => ↑(g x.fst) x.snd) (_ : ∀ (x y : Σˣ f), x ≈ y → (fun x => ↑(g x.fst) x.snd) x = (fun x => ↑(g x.fst) x.snd) y) ∘ Quotient.mk (setoid G f) ∘ Structure.Sigma.mk f i ∘ y) ↔ RelMap R fun a => Quotient.mk (setoid G f) (Structure.Sigma.mk f i (y a)) [PROOFSTEP] rw [relMap_quotient_mk'_sigma_mk' G f, ← (g i).map_rel R y, ← Function.comp.assoc, Quotient.lift_comp_mk] [GOAL] case intro.intro L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x n✝ : ℕ R : Relations L n✝ i : ι y : Fin n✝ → G i ⊢ RelMap R ((fun x => ↑(g x.fst) x.snd) ∘ Structure.Sigma.mk f i ∘ y) ↔ RelMap R (↑(g i) ∘ y) [PROOFSTEP] rfl [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x i : ι x : G i ⊢ ↑(lift L ι G f g Hg) (Quotient.mk (setoid G f) (Structure.Sigma.mk f i x)) = ↑(g i) x [PROOFSTEP] change (lift L ι G f g Hg).toFun ⟦.mk f i x⟧ = _ [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x i : ι x : G i ⊢ Function.Embedding.toFun (lift L ι G f g Hg).toEmbedding (Quotient.mk (setoid G f) (Structure.Sigma.mk f i x)) = ↑(g i) x [PROOFSTEP] simp only [lift, Quotient.lift_mk] [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x i : ι x : G i ⊢ ↑(lift L ι G f g Hg) (↑(of L ι G f i) x) = ↑(g i) x [PROOFSTEP] simp [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x F : DirectLimit G f ↪[L] P x✝ : DirectLimit G f i j : ι hij : i ≤ j x : G i ⊢ ↑((fun i => Embedding.comp F (of L ι G f i)) j) (↑(f i j hij) x) = ↑((fun i => Embedding.comp F (of L ι G f i)) i) x [PROOFSTEP] rw [F.comp_apply, F.comp_apply, of_f] [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x F : DirectLimit G f ↪[L] P x✝ : DirectLimit G f i : ι x : G i ⊢ ↑F (↑(of L ι G f i) x) = ↑(lift L ι G f (fun i => Embedding.comp F (of L ι G f i)) (_ : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑((fun i => Embedding.comp F (of L ι G f i)) j) (↑(f i j hij) x) = ↑((fun i => Embedding.comp F (of L ι G f i)) i) x)) (↑(of L ι G f i) x) [PROOFSTEP] rw [lift_of] [GOAL] L : Language ι : Type v inst✝⁵ : Preorder ι G : ι → Type w inst✝⁴ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : DirectedSystem G fun i j h => ↑(f i j h) inst✝¹ : Nonempty ι P : Type u₁ inst✝ : Structure L P g : (i : ι) → G i ↪[L] P Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), ↑(g j) (↑(f i j hij) x) = ↑(g i) x F : DirectLimit G f ↪[L] P x✝ : DirectLimit G f i : ι x : G i ⊢ ↑F (↑(of L ι G f i) x) = ↑(Embedding.comp F (of L ι G f i)) x [PROOFSTEP] rfl [GOAL] L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) ⊢ CG L (DirectLimit G f) [PROOFSTEP] refine' ⟨⟨⋃ i, DirectLimit.of L ι G f i '' Classical.choose (h i).out, _, _⟩⟩ [GOAL] case refine'_1 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) ⊢ Set.Countable (⋃ (i : ι), ↑(of L ι G f i) '' Classical.choose (_ : Substructure.CG ⊤)) [PROOFSTEP] exact Set.countable_iUnion fun i => Set.Countable.image (Classical.choose_spec (h i).out).1 _ [GOAL] case refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) ⊢ LowerAdjoint.toFun (Substructure.closure L) (⋃ (i : ι), ↑(of L ι G f i) '' Classical.choose (_ : Substructure.CG ⊤)) = ⊤ [PROOFSTEP] rw [eq_top_iff, Substructure.closure_unionᵢ] [GOAL] case refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) ⊢ ⊤ ≤ ⨆ (i : ι), LowerAdjoint.toFun (Substructure.closure L) (↑(of L ι G f i) '' Classical.choose (_ : Substructure.CG ⊤)) [PROOFSTEP] simp_rw [← Embedding.coe_toHom, Substructure.closure_image] [GOAL] case refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) ⊢ ⊤ ≤ ⨆ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) [PROOFSTEP] rw [le_iSup_iff] [GOAL] case refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) ⊢ ∀ (b : Substructure L (DirectLimit G f)), (∀ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) ≤ b) → ⊤ ≤ b [PROOFSTEP] intro S hS x _ [GOAL] case refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) S : Substructure L (DirectLimit G f) hS : ∀ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) ≤ S x : DirectLimit G f a✝ : x ∈ ⊤ ⊢ x ∈ S [PROOFSTEP] let out := Quotient.out (s := DirectLimit.setoid G f) [GOAL] case refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) S : Substructure L (DirectLimit G f) hS : ∀ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) ≤ S x : DirectLimit G f a✝ : x ∈ ⊤ out : Quotient (setoid G f) → Σˣ f := Quotient.out ⊢ x ∈ S [PROOFSTEP] refine' hS (out x).1 ⟨(out x).2, _, _⟩ [GOAL] case refine'_2.refine'_1 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) S : Substructure L (DirectLimit G f) hS : ∀ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) ≤ S x : DirectLimit G f a✝ : x ∈ ⊤ out : Quotient (setoid G f) → Σˣ f := Quotient.out ⊢ (out x).snd ∈ ↑(LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) [PROOFSTEP] rw [(Classical.choose_spec (h (out x).1).out).2] [GOAL] case refine'_2.refine'_1 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) S : Substructure L (DirectLimit G f) hS : ∀ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) ≤ S x : DirectLimit G f a✝ : x ∈ ⊤ out : Quotient (setoid G f) → Σˣ f := Quotient.out ⊢ (out x).snd ∈ ↑⊤ [PROOFSTEP] trivial [GOAL] case refine'_2.refine'_2 L : Language ι✝ : Type v inst✝¹¹ : Preorder ι✝ G✝ : ι✝ → Type w inst✝¹⁰ : (i : ι✝) → Structure L (G✝ i) f✝ : (i j : ι✝) → i ≤ j → G✝ i ↪[L] G✝ j inst✝⁹ : IsDirected ι✝ fun x x_1 => x ≤ x_1 inst✝⁸ : DirectedSystem G✝ fun i j h => ↑(f✝ i j h) inst✝⁷ : Nonempty ι✝ P : Type u₁ inst✝⁶ : Structure L P g : (i : ι✝) → G✝ i ↪[L] P Hg : ∀ (i j : ι✝) (hij : i ≤ j) (x : G✝ i), ↑(g j) (↑(f✝ i j hij) x) = ↑(g i) x ι : Type u_1 inst✝⁵ : Encodable ι inst✝⁴ : Preorder ι inst✝³ : IsDirected ι fun x x_1 => x ≤ x_1 inst✝² : Nonempty ι G : ι → Type w inst✝¹ : (i : ι) → Structure L (G i) f : (i j : ι) → i ≤ j → G i ↪[L] G j h : ∀ (i : ι), CG L (G i) inst✝ : DirectedSystem G fun i j h => ↑(f i j h) S : Substructure L (DirectLimit G f) hS : ∀ (i : ι), Substructure.map (Embedding.toHom (of L ι G f i)) (LowerAdjoint.toFun (Substructure.closure L) (Classical.choose (_ : Substructure.CG ⊤))) ≤ S x : DirectLimit G f a✝ : x ∈ ⊤ out : Quotient (setoid G f) → Σˣ f := Quotient.out ⊢ ↑(Embedding.toHom (of L ι G f (out x).fst)) (out x).snd = x [PROOFSTEP] simp only [Embedding.coe_toHom, DirectLimit.of_apply, Sigma.eta, Quotient.out_eq]
{- Test that some library functions don't cause "Maximum call stack size exceeded" errors. So far, only Prelude.List.++ is tested. -} module Main -- Until length and replicate are tail recursive, we roll our own for this test. lengthPlus : Nat -> List a -> Nat lengthPlus n [] = n lengthPlus n (x::xs) = lengthPlus (S n) xs tailRecLength : List a -> Nat tailRecLength = lengthPlus Z replicateOnto : List a -> Nat -> a -> List a replicateOnto acc Z x = acc replicateOnto acc (S n) x = replicateOnto (x :: acc) n x tailRecReplicate : Nat -> a -> List a tailRecReplicate = replicateOnto [] main : IO () main = putStrLn $ show $ tailRecLength $ tailRecReplicate 10000 () ++ [()]
/** @file */ #ifndef __CCL_F1D_H_INCLUDED__ #define __CCL_F1D_H_INCLUDED__ #include <gsl/gsl_spline.h> CCL_BEGIN_DECLS typedef enum ccl_f1d_extrap_t { ccl_f1d_extrap_0 = 0, // No extrapolation ccl_f1d_extrap_const = 410, // Constant extrapolation ccl_f1d_extrap_linx_liny = 411, // Linear x, linear y ccl_f1d_extrap_linx_logy = 412, // Linear x, log y ccl_f1d_extrap_logx_liny = 413, // Log x, linear y ccl_f1d_extrap_logx_logy = 414, // Log x, log y } ccl_f1d_extrap_t; /* * Spline wrapper * Used to take care of evaluations outside the supported range */ typedef struct { gsl_spline *spline; double y0,yf; //Constant values to use beyond interpolation limit ccl_f1d_extrap_t extrap_lo_type; ccl_f1d_extrap_t extrap_hi_type; double x_ini, x_end; //Interpolation limits double y_ini, y_end; double der_lo; double der_hi; } ccl_f1d_t; ccl_f1d_t *ccl_f1d_t_new(int n,double *x,double *y,double y0,double yf, ccl_f1d_extrap_t extrap_lo_type, ccl_f1d_extrap_t extrap_hi_type, int *status); double ccl_f1d_t_eval(ccl_f1d_t *spl,double x); void ccl_f1d_t_free(ccl_f1d_t *spl); CCL_END_DECLS #endif
This time of the year isn’t just known for the eggnog, christmas trees, presents and good cheer. Some of the most anticipated movies of the year are released. Take a look at the list the Ferrvor Team put together for the movies to checkout in theaters this holiday season. Who doesn’t love a good movie? Especially on Christmas Day, when all the stores are closed and there’s nothing else to do. Here are a few of the top movies coming out during the holidays.
module FresnelOptics const VecI = AbstractVector # Input Vector const VecO = AbstractVector # Output Vector const VecB = AbstractVector # Buffer Vector const VecIO = AbstractVector # In/Out Vector const MatI = AbstractMatrix # Input Matrix const MatO = AbstractMatrix # Output Matrix const MatB = AbstractMatrix # Buffer Matrix const MatIO = AbstractMatrix # In/Out Matrix const 𝚷 = 2.0 * π using LinearAlgebra.BLAS: gemv! include("./utils/la.jl") include("./fresnel.jl") include("./lorentz.jl") include("./dielectric.jl") include("./layers.jl") end # module
# Factorization Factorization is the process of restating an expression as the *product* of two expressions (in other words, expressions multiplied together). For example, you can make the value **16** by performing the following multiplications of integer numbers: - 1 x 16 - 2 x 8 - 4 x 4 Another way of saying this is that 1, 2, 4, 8, and 16 are all factors of 16. ## Factors of Polynomial Expressions We can apply the same logic to polynomial expressions. For example, consider the following monomial expression: \begin{equation}-6x^{2}y^{3} \end{equation} You can get this value by performing the following multiplication: \begin{equation}(2xy^{2})(-3xy) \end{equation} Run the following Python code to test this with arbitrary ***x*** and ***y*** values: ```python from random import randint x = randint(1,100) y = randint(1,100) (2*x*y**2)*(-3*x*y) == -6*x**2*y**3 ``` So, we can say that **2xy<sup>2</sup>** and **-3xy** are both factors of **-6x<sup>2</sup>y<sup>3</sup>**. This also applies to polynomials with more than one term. For example, consider the following expression: \begin{equation}(x + 2)(2x^{2} - 3y + 2) = 2x^{3} + 4x^{2} - 3xy + 2x - 6y + 4 \end{equation} Based on this, **x+2** and **2x<sup>2</sup> - 3y + 2** are both factors of **2x<sup>3</sup> + 4x<sup>2</sup> - 3xy + 2x - 6y + 4**. (and if you don't believe me, you can try this with random values for x and y with the following Python code): ```python from random import randint x = randint(1,100) y = randint(1,100) (x + 2)*(2*x**2 - 3*y + 2) == 2*x**3 + 4*x**2 - 3*x*y + 2*x - 6*y + 4 ``` ## Greatest Common Factor Of course, these may not be the only factors of **-6x<sup>2</sup>y<sup>3</sup>**, just as 8 and 2 are not the only factors of 16. Additionally, 2 and 8 aren't just factors of 16; they're factors of other numbers too - for example, they're both factors of 24 (because 2 x 12 = 24 and 8 x 3 = 24). Which leads us to the question, what is the highest number that is a factor of both 16 and 24? Well, let's look at all the numbers that multiply evenly into 12 and all the numbers that multiply evenly into 24: | 16 | 24 | |--------|--------| | 1 x 16 | 1 x 24 | | 2 x **8** | 2 x 12 | | | 3 x **8** | | 4 x 4 | 4 x 6 | The highest value that is a multiple of both 16 and 24 is **8**, so 8 is the *Greatest Common Factor* (or GCF) of 16 and 24. OK, let's apply that logic to the following expressions: \begin{equation}15x^{2}y\;\;\;\;\;\;\;\;9xy^{3}\end{equation} So what's the greatest common factor of these two expressions? It helps to break the expressions into their consitituent components. Let's deal with the coefficients first; we have 15 and 9. The highest value that divides evenly into both of these is **3** (3 x 5 = 15 and 3 x 3 = 9). Now let's look at the ***x*** terms; we have x<sup>2</sup> and x. The highest value that divides evenly into both is these is **x** (*x* goes into *x* once and into *x*<sup>2</sup> *x* times). Finally, for our ***y*** terms, we have y and y<sup>3</sup>. The highest value that divides evenly into both is these is **y** (*y* goes into *y* once and into *y*<sup>3</sup> *y&bull;y* times). Putting all of that together, the GCF of both of our expression is: \begin{equation}3xy\end{equation} An easy shortcut to identifying the GCF of an expression that includes variables with exponentials is that it will always consist of: - The *largest* numeric factor of the numeric coefficients in the polynomial expressions (in this case 3) - The *smallest* exponential of each variable (in this case, x and y, which technically are x<sup>1</sup> and y<sup>1</sup>. You can check your answer by dividing the original expressions by the GCF to find the coefficent expressions for the GCF (in other words, how many times the GCF divides into the original expression). The result, when multiplied by the GCF will always produce the original expression. So in this case, we need to perform the following divisions: \begin{equation}\frac{15x^{2}y}{3xy}\;\;\;\;\;\;\;\;\frac{9xy^{3}}{3xy}\end{equation} These fractions simplify to **5x** and **3y<sup>2</sup>**, giving us the following calculations to prove our factorization: \begin{equation}3xy(5x) = 15x^{2}y\end{equation} \begin{equation}3xy(3y^{2}) = 9xy^{3}\end{equation} Let's try both of those in Python: ```python from random import randint x = randint(1,100) y = randint(1,100) print((3*x*y)*(5*x) == 15*x**2*y) print((3*x*y)*(3*y**2) == 9*x*y**3) ``` ## Distributing Factors Let's look at another example. Here is a binomial expression: \begin{equation}6x + 15y \end{equation} To factor this, we need to find an expression that divides equally into both of these expressions. In this case, we can use **3** to factor the coefficents, because 3 &bull; 2x = 6x and 3&bull; 5y = 15y, so we can write our original expression as: \begin{equation}6x + 15y = 3(2x) + 3(5y) \end{equation} Now, remember the distributive property? It enables us to multiply each term of an expression by the same factor to calculate the product of the expression multiplied by the factor. We can *factor-out* the common factor in this expression to distribute it like this: \begin{equation}6x + 15y = 3(2x) + 3(5y) = \mathbf{3(2x + 5y)} \end{equation} Let's prove to ourselves that these all evaluate to the same thing: ```python from random import randint x = randint(1,100) y = randint(1,100) (6*x + 15*y) == (3*(2*x) + 3*(5*y)) == (3*(2*x + 5*y)) ``` For something a little more complex, let's return to our previous example. Suppose we want to add our original 15x<sup>2</sup>y and 9xy<sup>3</sup> expressions: \begin{equation}15x^{2}y + 9xy^{3}\end{equation} We've already calculated the common factor, so we know that: \begin{equation}3xy(5x) = 15x^{2}y\end{equation} \begin{equation}3xy(3y^{2}) = 9xy^{3}\end{equation} Now we can factor-out the common factor to produce a single expression: \begin{equation}15x^{2}y + 9xy^{3} = \mathbf{3xy(5x + 3y^{2})}\end{equation} And here's the Python test code: ```python from random import randint x = randint(1,100) y = randint(1,100) (15*x**2*y + 9*x*y**3) == (3*x*y*(5*x + 3*y**2)) ``` So you might be wondering what's so great about being able to distribute the common factor like this. The answer is that it can often be useful to apply a common factor to multiple terms in order to solve seemingly complex problems. For example, consider this: \begin{equation}x^{2} + y^{2} + z^{2} = 127\end{equation} Now solve this equation: \begin{equation}a = 5x^{2} + 5y^{2} + 5z^{2}\end{equation} At first glance, this seems tricky because there are three unknown variables, and even though we know that their squares add up to 127, we don't know their individual values. However, we can distribute the common factor and apply what we *do* know. Let's restate the problem like this: \begin{equation}a = 5(x^{2} + y^{2} + z^{2})\end{equation} Now it becomes easier to solve, because we know that the expression in parenthesis is equal to 127, so actually our equation is: \begin{equation}a = 5(127)\end{equation} So ***a*** is 5 times 127, which is 635 ## Formulae for Factoring Squares There are some useful ways that you can employ factoring to deal with expressions that contain squared values (that is, values with an exponential of 2). ### Differences of Squares Consider the following expression: \begin{equation}x^{2} - 9\end{equation} The constant *9* is 3<sup>2</sup>, so we could rewrite this as: \begin{equation}x^{2} - 3^{2}\end{equation} Whenever you need to subtract one squared term from another, you can use an approach called the *difference of squares*, whereby we can factor *a<sup>2</sup> - b<sup>2</sup>* as *(a - b)(a + b)*; so we can rewrite the expression as: \begin{equation}(x - 3)(x + 3)\end{equation} Run the code below to check this: ```python from random import randint x = randint(1,100) (x**2 - 9) == (x - 3)*(x + 3) ``` ### Perfect Squares A *perfect square* is a number multiplied by itself, for example 3 multipled by 3 is 9, so 9 is a perfect square. When working with equations, the ability to factor between polynomial expressions and binomial perfect square expressions can be a useful tool. For example, consider this expression: \begin{equation}x^{2} + 10x + 25\end{equation} We can use 5 as a common factor to rewrite this as: \begin{equation}(x + 5)(x + 5)\end{equation} So what happened here? Well, first we found a common factor for our coefficients: 5 goes into 10 twice and into 25 five times (in other words, squared). Then we just expressed this factoring as a multiplication of two identical binomials *(x + 5)(x + 5)*. Remember the rule for multiplication of polynomials is to multiple each term in the first polynomial by each term in the second polynomial and then add the results; so you can do this to verify the factorization: - x &bull; x = x<sup>2</sup> - x &bull; 5 = 5x - 5 &bull; x = 5x - 5 &bull; 5 = 25 When you combine the two 5x terms we get back to our original expression of x<sup>2</sup> + 10x + 25. Now we have an expression multipled by itself; in other words, a perfect square. We can therefore rewrite this as: \begin{equation}(x + 5)^{2}\end{equation} Factorization of perfect squares is a useful technique, as you'll see when we start to tackle quadratic equations in the next section. In fact, it's so useful that it's worth memorizing its formula: \begin{equation}(a + b)^{2} = a^{2} + b^{2}+ 2ab \end{equation} In our example, the *a* terms is ***x*** and the *b* terms is ***5***, and in standard form, our equation *x<sup>2</sup> + 10x + 25* is actually *a<sup>2</sup> + 2ab + b<sup>2</sup>*. The operations are all additions, so the order isn't actually important! Run the following code with random values for *a* and *b* to verify that the formula works: ```python from random import randint a = randint(1,100) b = randint(1,100) a**2 + b**2 + (2*a*b) == (a + b)**2 ```
""" A function to uniformly select a random agent from a collection """ function selectRandomAgent(agents) agents[rand(1:end)] end """ A function that unifromly select an agent from a subgroup of agents that have a minimum amount of tokens. It could be useful to select an agent that is capable of making a deposit """ function selectRandomAgentWithMinBalance(agents, min) filteredAgents = filter(a -> a.balance > min, agents) selectRandomAgent(filteredAgents) end
theory ResMap imports WellTypedExp GenSubEnv begin (* resource map *) datatype 'a p_stack = NilStack | ConsStack string 'a "'a p_stack" type_synonym res_map = "perm_use_env p_stack" definition add_mem where "add_mem s x v = ConsStack x v s" fun rem_mem where "rem_mem NilStack x = NilStack" | "rem_mem (ConsStack x v s') x' = (if x = x' then rem_mem s' x' else ConsStack x v (rem_mem s' x'))" fun lookup_mem where "lookup_mem NilStack x' = None" | "lookup_mem (ConsStack x v s') x' = (if x = x' then Some (v, s') else lookup_mem s' x')" definition lookup_res where "lookup_res s x = (case lookup_mem s x of None \<Rightarrow> empty_use_env | Some (v, s') \<Rightarrow> v)" definition sub_res_map where "sub_res_map s rs_map = (\<forall> x. (s x = None) = (lookup_mem rs_map x = None))" (* simple lemmas *) lemma lookup_rem_mem_none1: "lookup_mem (rem_mem rs_map x) x = None" apply (induct rs_map) apply (auto) done lemma lookup_rem_mem_none2: "\<lbrakk> lookup_mem rs_map y = None \<rbrakk> \<Longrightarrow> lookup_mem (rem_mem rs_map x) y = None" apply (induct rs_map) apply (auto) done lemma lookup_add_mem_same: "lookup_res (add_mem rs_map x r_s) x = r_s" apply (simp add: lookup_res_def) apply (simp add: add_mem_def) done lemma lookup_add_mem_diff: "\<lbrakk> x \<noteq> y \<rbrakk> \<Longrightarrow> lookup_res (add_mem rs_map x r_s) y = lookup_res rs_map y" apply (simp add: lookup_res_def) apply (simp add: add_mem_def) done lemma lookup_rem_mem_same: "lookup_res (rem_mem rs_map x) x = empty_use_env" apply (induct rs_map) apply (auto) apply (simp add: lookup_res_def) apply (simp add: lookup_res_def) done lemma lookup_rem_mem_diff: "\<lbrakk> x \<noteq> y \<rbrakk> \<Longrightarrow> lookup_res (rem_mem rs_map x) y = lookup_res rs_map y" apply (induct rs_map) apply (auto) apply (simp add: lookup_res_def) apply (simp add: lookup_res_def) done (* - res map equalities *) lemma almost_comm_rem_add_mem: "\<lbrakk> x \<noteq> y \<rbrakk> \<Longrightarrow> rem_mem (add_mem s x v) y = add_mem (rem_mem s y) x v" apply (induct s) apply (simp add: add_mem_def) apply (simp add: add_mem_def) done lemma ignore_rem_add_mem: "rem_mem (add_mem s x v) x = rem_mem s x " apply (simp add: add_mem_def) done (* lemma ignore_rem_res_map: "\<lbrakk> lookup_res rs_map x = empty_use_env \<rbrakk> \<Longrightarrow> rem_mem rs_map x = rs_map" apply (case_tac "\<forall> y. rem_mem rs_map x y = rs_map y") apply (auto) apply (simp add: rem_res_map_def) apply (simp add: set_res_map_def) apply (case_tac "x = y") apply (auto) done lemma partial_rem_set_res_map: "rem_res_map (set_res_map rs_map x r_s) x = rem_res_map rs_map x" apply (simp add: rem_res_map_def) apply (simp add: set_res_map_def) apply (auto) done*) (* - sub res map lemmas *) lemma add_sub_res_map_rev: "\<lbrakk> sub_res_map s (add_mem rs_map x r_s); lookup_mem (rs_map :: perm_use_env p_stack) x = None \<rbrakk> \<Longrightarrow> sub_res_map (rem_env s x) rs_map" (* we want to prove that if s + rs_map were exactly matched, they will remain exactly matched even after adding x to rs_map. *) apply (simp add: sub_res_map_def) apply (auto) apply (simp add: rem_env_def) apply (case_tac "x = xa") apply (auto) apply (simp add: add_mem_def) apply (simp add: rem_env_def) apply (auto) apply (simp add: add_mem_def) done (* lemma add_sub_res_map_rev: "\<lbrakk> sub_res_map s (add_mem rs_map x r_s); lookup_mem (rs_map :: perm_use_env p_stack) x = None \<rbrakk> \<Longrightarrow> sub_res_map s rs_map" (* we want to prove that if s + rs_map were exactly matched, they will remain exactly matched even after adding x to rs_map. *) apply (simp add: sub_res_map_def) apply (auto) apply (case_tac "x = xa") apply (auto) apply (case_tac "lookup_res rs_map xa = empty_use_env") apply (cut_tac rs_map="rs_map" and x="x" and r_s="r_s" and y="xa" in lookup_add_mem_diff) apply (auto) apply (simp add: lookup_res_def) apply (simp add: emp apply (erule_tac x="xa" in allE) apply (auto) apply (simp add: add_mem_def) apply (case_tac "x = xa") apply (auto) done*) (* lemma rem_compl_res_map: "\<lbrakk> compl_res_map s rs_map \<rbrakk> \<Longrightarrow> compl_res_map s (rem_mem rs_map x)" apply (simp add: sub_res_map_def) apply (auto) apply (case_tac "x = xa") apply (simp add: lookup_rem_mem_none1) apply (simp add: lookup_rem_mem_none2) done lemma add_rem_sub_res_map: "\<lbrakk> sub_res_map (add_env s x v) rs_map \<rbrakk> \<Longrightarrow> sub_res_map s (rem_mem rs_map x)" apply (simp add: sub_res_map_def) apply (simp add: add_env_def) apply (auto) apply (erule_tac x="xa" in allE) apply (case_tac "x = xa") apply (auto) apply (simp add: lookup_rem_mem_none1) apply (simp add: lookup_rem_mem_none2) done*) lemma add_sub_res_map: "\<lbrakk> sub_res_map s rs_map \<rbrakk> \<Longrightarrow> sub_res_map (add_env s x v) (add_mem rs_map x r_s) " apply (simp add: sub_res_map_def) apply (simp add: add_env_def) apply (simp add: add_mem_def) done (* ## NEW RES MAP DEFINITION ## *) type_synonym nres_map = "string \<Rightarrow> perm_use_env option" definition full_nres_map where "full_nres_map s s_map = (\<forall> x. (s x = None) = (s_map x = None))" definition nres_lookup where "nres_lookup rs_map x = (case rs_map x of None \<Rightarrow> empty_use_env | Some r_s \<Rightarrow> r_s )" lemma nres_add_same: "nres_lookup (add_env rs_map x r_s) x = r_s" apply (simp add: nres_lookup_def) apply (simp add: add_env_def) done lemma nres_add_diff: "\<lbrakk> x \<noteq> y \<rbrakk> \<Longrightarrow> nres_lookup (add_env rs_map x r_s) y = nres_lookup rs_map y" apply (simp add: nres_lookup_def) apply (simp add: add_env_def) done lemma nres_rem_same: "nres_lookup (rem_env rs_map x) x = empty_use_env" apply (simp add: nres_lookup_def) apply (simp add: rem_env_def) done lemma nres_rem_diff: "\<lbrakk> x \<noteq> y \<rbrakk> \<Longrightarrow> nres_lookup (rem_env rs_map x) y = nres_lookup rs_map y" apply (simp add: nres_lookup_def) apply (simp add: rem_env_def) done lemma add_full_nres_map: "\<lbrakk> full_nres_map s rs_map \<rbrakk> \<Longrightarrow> full_nres_map (add_env s x v) (add_env rs_map x r_s)" apply (simp add: add_env_def) apply (simp add: full_nres_map_def) done definition sub_nres_map where "sub_nres_map s s_map = (\<forall> x. sub_use_env s (nres_lookup s_map x))" lemma add_sub_nres_map2: "\<lbrakk> sub_nres_map s rs_map; s x = None \<rbrakk> \<Longrightarrow> sub_nres_map (add_env s x v) rs_map " apply (simp add: sub_nres_map_def) apply (auto) apply (erule_tac x="xa" in allE) apply (rule_tac s="s" in contain_sub_use_env) apply (simp) apply (rule_tac add_contain_env) apply (simp) done lemma add_sub_nres_map1: "\<lbrakk> sub_nres_map s rs_map; sub_use_env s r_s \<rbrakk> \<Longrightarrow> sub_nres_map s (add_env rs_map x r_s) " apply (simp add: sub_nres_map_def) apply (auto) apply (case_tac "x = xa") apply (cut_tac rs_map="rs_map" and x="x" and r_s="r_s" in nres_add_same) apply (auto) apply (cut_tac rs_map="rs_map" and x="x" and r_s="r_s" in nres_add_diff) apply (auto) done lemma dist_add_sub_nres_map: "\<lbrakk> sub_nres_map s rs_map; sub_use_env s r_s \<rbrakk> \<Longrightarrow> sub_nres_map (add_env s x v) (add_env rs_map x r_s) " apply (simp add: sub_nres_map_def) apply (auto) apply (case_tac "x = xa") apply (cut_tac rs_map="rs_map" and x="x" and r_s="r_s" in nres_add_same) apply (auto) apply (rule_tac add_sub_use_env) apply (simp) apply (cut_tac rs_map="rs_map" and x="x" and r_s="r_s" in nres_add_diff) apply (auto) apply (rule_tac add_sub_use_env) apply (simp) done end
! closing missinging DSO objects subroutine bl_proffortfuncstart(str) character*(*) str end subroutine bl_proffortfuncstop(str) character*(*) str end
# Taylor problem 5.32 last revised: 12-Jan-2019 by Dick Furnstahl [[email protected]] **Replace ### by appropriate expressions.** The equation for an underdamped oscillator, such as a mass on the end of a spring, takes the form $\begin{align} x(t) = e^{-\beta t} [B_1 \cos(\omega_1 t) + B_2 \sin(\omega_1 t)] \end{align}$ where $\begin{align} \omega_1 = \sqrt{\omega_0^2 - \beta^2} \end{align}$ and the mass is released from rest at position $x_0$ at $t=0$. **Goal: plot $x(t)$ for $0 \leq t \leq 20$, with $x_0 = 1$, $\omega_0=1$, and $\beta = 0.$, 0.02, 0.1, 0.3, and 1.** ```python import numpy as np import matplotlib.pyplot as plt ``` ```python def underdamped(t, beta, omega_0=1, x_0=1): """Solution x(t) for an underdamped harmonic oscillator.""" omega_1 = np.sqrt(omega_0**2 - beta**2) B_1 = 2 B_2 = 5 return np.exp(-beta*t) \ * ( B_1 * np.cos(omega_1*t) + B_2 * np.sin(omega_1*t) ) ``` ```python t_pts = np.arange(0., 20., .01) betas = [0., 0.02, 0.1, 0.3, 0.9999] fig = plt.figure(figsize=(10,6)) # look up "python enumerate" to find out how this works! for i, beta in enumerate(betas): ax = fig.add_subplot(2, 3, i+1) ax.plot(t_pts, underdamped(t_pts, beta), color='blue') ax.set_title(rf'$\beta = {beta:.2f}$') ax.set_xlabel('t') ax.set_ylabel('x(t)') ax.set_ylim(-1.1,1.1) ax.axhline(0., color='black', alpha=0.3) # lightened black zero line fig.tight_layout() ### add code to print the figure ``` ## Bonus: Widgetized! ```python from ipywidgets import interact, fixed import ipywidgets as widgets omega_0 = 1. def plot_beta(beta): """Plot function for underdamped harmonic oscillator.""" t_pts = np.arange(0., 20., .01) fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(t_pts, underdamped(t_pts, beta), color='blue') ax.set_title(rf'$\beta = {beta:.2f}$') ax.set_xlabel('t') ax.set_ylabel('x(t)') ax.set_ylim(-1.1,1.1) ax.axhline(0., color='black', alpha=0.3) fig.tight_layout() max_value = omega_0 - 0.0001 interact(plot_beta, beta=widgets.FloatSlider(min=0., max=max_value, step=0.01, value=0., readout_format='.2f', continuous_update=False)); ``` interactive(children=(FloatSlider(value=0.0, continuous_update=False, description='beta', max=0.9999, step=0.0… Now let's allow for complex numbers! This will enable us to take $\beta > \omega_0$. ```python # numpy.lib.scimath version of sqrt handles complex numbers. # numpy exp, cos, and sin already can. import numpy.lib.scimath as smath def all_beta(t, beta, omega_0=1, x_0=1): """Solution x(t) for damped harmonic oscillator, allowing for overdamped as well as underdamped solution. """ omega_1 = smath.sqrt(omega_0**2 - beta**2) return np.real( x_0 * np.exp(-beta*t) \ * (np.cos(omega_1*t) + (beta/omega_1)*np.sin(omega_1*t)) ) ``` ```python from ipywidgets import interact, fixed import ipywidgets as widgets omega_0 = 1. def plot_all_beta(beta): """Plot of x(t) for damped harmonic oscillator, allowing for overdamped as well as underdamped cases.""" t_pts = np.arange(0., 20., .01) fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(t_pts, all_beta(t_pts, beta), color='blue') ax.set_title(rf'$\beta = {beta:.2f}$') ax.set_xlabel('t') ax.set_ylabel('x(t)') ax.set_ylim(-1.1,1.1) ax.axhline(0., color='black', alpha=0.3) fig.tight_layout() interact(plot_all_beta, beta=widgets.FloatSlider(min=0., max=2, step=0.01, value=0., readout_format='.2f', continuous_update=False)); ``` interactive(children=(FloatSlider(value=0.0, continuous_update=False, description='beta', max=2.0, step=0.01),… ```python ```
#ifndef DART_COMMON_H #define DART_COMMON_H // Automatically detect libraries if possible. #if defined(__has_include) # if !defined(DART_HAS_RAPIDJSON) # define DART_HAS_RAPIDJSON __has_include(<rapidjson/reader.h>) && __has_include(<rapidjson/writer.h>) # endif # ifndef DART_HAS_YAML # define DART_HAS_YAML __has_include(<yaml.h>) # endif #endif /*----- System Includes -----*/ #include <map> #include <vector> #include <math.h> #include <gsl/gsl> #include <errno.h> #include <cstdlib> #include <stdarg.h> #include <limits.h> #include <algorithm> #if DART_HAS_RAPIDJSON #include <rapidjson/reader.h> #include <rapidjson/writer.h> #include <rapidjson/document.h> #include <rapidjson/error/en.h> #endif #if DART_HAS_YAML #include <yaml.h> #endif /*----- Local Includes -----*/ #include "shim.h" #include "meta.h" #include "support/ptrs.h" #include "support/ordered.h" /*----- System Includes with Compiler Flags -----*/ // Current version of sajson emits unused parameter // warnings on Clang. #ifdef DART_USE_SAJSON #if DART_USING_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wunused-parameter" #endif #include <sajson.h> #if DART_USING_CLANG #pragma clang diagnostic pop #endif #endif /*----- Macro Definitions -----*/ #define DART_FROM_THIS \ reinterpret_cast<gsl::byte const*>(this) #define DART_FROM_THIS_MUT \ reinterpret_cast<gsl::byte*>(this) /*----- Global Declarations -----*/ namespace dart { template <class Object> class basic_object; template <class Array> class basic_array; template <class String> class basic_string; template <class Number> class basic_number; template <class Boolean> class basic_flag; template <class Null> class basic_null; template <template <class> class RefCount> class basic_heap; template <template <class> class RefCount> class basic_buffer; template <template <class> class RefCount> class basic_packet; struct type_error : std::logic_error { type_error(char const* msg) : logic_error(msg) {} }; struct state_error : std::runtime_error { state_error(char const* msg) : runtime_error(msg) {} }; struct parse_error : std::runtime_error { parse_error(char const* msg) : runtime_error(msg) {} }; struct validation_error : std::runtime_error { validation_error(char const* msg) : runtime_error(msg) {} }; namespace detail { template <class T> struct is_dart_type : std::false_type {}; template <template <class> class RC> struct is_dart_type<dart::basic_heap<RC>> : std::true_type {}; template <template <class> class RC> struct is_dart_type<dart::basic_buffer<RC>> : std::true_type {}; template <template <class> class RC> struct is_dart_type<dart::basic_packet<RC>> : std::true_type {}; template <class T> struct is_wrapper_type : std::false_type {}; template <class T> struct is_wrapper_type<dart::basic_object<T>> : std::true_type {}; template <class T> struct is_wrapper_type<dart::basic_array<T>> : std::true_type {}; template <class T> struct is_wrapper_type<dart::basic_string<T>> : std::true_type {}; template <class T> struct is_wrapper_type<dart::basic_number<T>> : std::true_type {}; template <class T> struct is_wrapper_type<dart::basic_flag<T>> : std::true_type {}; template <class T> struct is_wrapper_type<dart::basic_null<T>> : std::true_type {}; template <class T> struct is_dart_api_type : std::false_type {}; template <template <class> class RC> struct is_dart_api_type<dart::basic_heap<RC>> : std::true_type {}; template <template <class> class RC> struct is_dart_api_type<dart::basic_buffer<RC>> : std::true_type {}; template <template <class> class RC> struct is_dart_api_type<dart::basic_packet<RC>> : std::true_type {}; template <class T> struct is_dart_api_type<dart::basic_object<T>> : std::true_type {}; template <class T> struct is_dart_api_type<dart::basic_array<T>> : std::true_type {}; template <class T> struct is_dart_api_type<dart::basic_string<T>> : std::true_type {}; template <class T> struct is_dart_api_type<dart::basic_number<T>> : std::true_type {}; template <class T> struct is_dart_api_type<dart::basic_flag<T>> : std::true_type {}; template <class T> struct is_dart_api_type<dart::basic_null<T>> : std::true_type {}; template <class T> struct maybe_cast_return { template <class U, class = std::enable_if_t< std::is_pointer<U>::value || is_dart_type<U>::value > > static U detect(int); template <class U> static shim::optional<U> detect(...); using type = decltype(detect<T>(0)); }; template <class T> using maybe_cast_return_t = typename maybe_cast_return<T>::type; /** * @brief * Enum encodes the type of an individual packet instance. * * @details * Internally, dart::packet manages a much larger set of types that encode ancillary information * such as precision, signedness, alignment, size, however, all internal types map onto one of those * contained in dart::packet::type, and all public API functions conceptually interact with objects * of these types. */ enum class type : uint8_t { object, array, string, integer, decimal, boolean, null }; /** * @brief * Low-level type information that encodes information about the underlying machine-type, * like precision, signedness, etc. */ enum class raw_type : uint8_t { object, array, string, small_string, big_string, short_integer, integer, long_integer, decimal, long_decimal, boolean, null }; /** * @brief * Used internally in scenarios where two dart types aren't contained within * some existing data structure, but they need to be paired together. */ template <class Packet> struct basic_pair { /*----- Lifecycle Functions -----*/ basic_pair() = default; template <class P, class = std::enable_if_t< std::is_convertible< P, Packet >::value > > basic_pair(P&& key, P&& value) : key(std::forward<P>(key)), value(std::forward<P>(value)) {} basic_pair(basic_pair const&) = default; basic_pair(basic_pair&&) = default; ~basic_pair() = default; /*----- Operators -----*/ basic_pair& operator =(basic_pair const&) = default; basic_pair& operator =(basic_pair&&) = default; /*----- Members -----*/ Packet key, value; }; template <template <class> class RefCount> using heap_pair = basic_pair<basic_heap<RefCount>>; template <template <class> class RefCount> using buffer_pair = basic_pair<basic_buffer<RefCount>>; template <template <class> class RefCount> using packet_pair = basic_pair<basic_packet<RefCount>>; /** * @brief * Helper-struct for sorting `dart::packet`s within `std::map`s. */ template <template <class> class RefCount> struct dart_comparator { using is_transparent = shim::string_view; bool operator ()(shim::string_view lhs, shim::string_view rhs) const; // Comparison between some packet type and a string template <template <template <class> class> class Packet> bool operator ()(Packet<RefCount> const& lhs, shim::string_view rhs) const; template <template <template <class> class> class Packet> bool operator ()(shim::string_view lhs, Packet<RefCount> const& rhs) const; // Comparison between a key-value pair of some packet type and a string template <template <template <class> class> class Packet> bool operator ()(basic_pair<Packet<RefCount>> const& lhs, shim::string_view rhs) const; template <template <template <class> class> class Packet> bool operator ()(shim::string_view lhs, basic_pair<Packet<RefCount>> const& rhs) const; // Comparison between two, potentially disparate, packet types template < template <template <class> class> class LhsPacket, template <template <class> class> class RhsPacket > bool operator ()(LhsPacket<RefCount> const& lhs, RhsPacket<RefCount> const& rhs) const; // Comparison between a key-value pair of some packet type and some, // potentially disparate, packet type template < template <template <class> class> class LhsPacket, template <template <class> class> class RhsPacket > bool operator ()(basic_pair<LhsPacket<RefCount>> const& lhs, RhsPacket<RefCount> const& rhs) const; template < template <template <class> class> class LhsPacket, template <template <class> class> class RhsPacket > bool operator ()(LhsPacket<RefCount> const& lhs, basic_pair<RhsPacket<RefCount>> const& rhs) const; // Comparison between a key-value pair of some packet type and // a key-value pair of some, potentially disparate, packet type. template < template <template <class> class> class LhsPacket, template <template <class> class> class RhsPacket > bool operator ()(basic_pair<LhsPacket<RefCount>> const& lhs, basic_pair<RhsPacket<RefCount>> const& rhs) const; }; struct dynamic_string_layout { bool operator ==(dynamic_string_layout const& other) const noexcept { if (len != other.len) return false; else return !strcmp(ptr.get(), other.ptr.get()); } bool operator !=(dynamic_string_layout const& other) const noexcept { return !(*this == other); } std::shared_ptr<char> ptr; size_t len; }; struct inline_string_layout { bool operator ==(inline_string_layout const& other) const noexcept { if (left != other.left) return false; else return !strcmp(buffer.data(), other.buffer.data()); } bool operator !=(inline_string_layout const& other) const noexcept { return !(*this == other); } std::array<char, sizeof(dynamic_string_layout) - sizeof(uint8_t)> buffer; uint8_t left; }; /** * @brief * Helper-struct for safely comparing objects of any type. */ struct typeless_comparator { template <class Lhs, class Rhs> bool operator ()(Lhs&& lhs, Rhs&& rhs) const noexcept; }; template <template <class> class RefCount> using buffer_refcount_type = shareable_ptr<RefCount<gsl::byte const>>; class prefix_entry; template <class> struct table_layout { using offset_type = uint32_t; static constexpr auto max_offset = std::numeric_limits<offset_type>::max(); alignas(4) little_order<offset_type> offset; alignas(4) little_order<uint8_t> type; }; template <> struct table_layout<prefix_entry> { using offset_type = uint32_t; using prefix_type = uint16_t; static constexpr auto max_offset = std::numeric_limits<offset_type>::max(); alignas(4) little_order<uint32_t> offset; alignas(1) little_order<uint8_t> type; alignas(1) little_order<uint8_t> len; alignas(2) prefix_type prefix; }; /** * @brief * Macro customizes functionality usually provided by assert(). * * @details * Not strictly necessary, but tries to provide a bit more context and * information as to why I just murdered the user's program (in production, no doubt). * * @remarks * Don't actually know if Doxygen lets you document macros, guess we'll see. */ template <class T> class vtable_entry { public: /*----- Lifecycle Functions -----*/ vtable_entry(detail::raw_type type, uint32_t offset); vtable_entry(vtable_entry const&) = default; /*----- Operators -----*/ vtable_entry& operator =(vtable_entry const&) = default; /*----- Public API -----*/ raw_type get_type() const noexcept; uint32_t get_offset() const noexcept; // This sucks, but we need it for dart::buffer::inject void adjust_offset(std::ptrdiff_t diff) noexcept; protected: /*----- Protected Members -----*/ table_layout<T> layout; }; /** * @brief * Class represents an entry in the vtable of an object. * * @details * Class wraps memory that is stored in little endian byte order, * irrespective of the native ordering of the host machine. * In other words, attempt to subvert its API at your peril. * * @remarks * Although class inherts from vtable_entry, and can be safely * be used as such, it remains a standard layout type due to some * hackery with its internals. */ class prefix_entry : public vtable_entry<prefix_entry> { public: /*----- Public Types -----*/ using prefix_type = table_layout<prefix_entry>::prefix_type; /*----- Lifecycle Functions -----*/ inline prefix_entry(detail::raw_type type, uint32_t offset, shim::string_view prefix) noexcept; prefix_entry(prefix_entry const&) = default; /*----- Operators -----*/ prefix_entry& operator =(prefix_entry const&) = default; /*----- Public API -----*/ inline int prefix_compare(shim::string_view str) const noexcept; private: /*----- Private Helpers -----*/ inline int compare_impl(char const* const str, size_t const len) const noexcept; /*----- Private Types -----*/ using storage_t = std::aligned_storage_t<sizeof(prefix_type), 4>; }; using object_entry = prefix_entry; using array_entry = vtable_entry<void>; using object_layout = table_layout<prefix_entry>; using array_layout = table_layout<void>; static_assert(std::is_standard_layout<array_entry>::value, "dart library is misconfigured"); static_assert(std::is_standard_layout<object_entry>::value, "dart library is misconfigured"); // Aliases for STL structures. template <template <class> class RefCount> using packet_elements = std::vector<refcount::owner_indirection_t<basic_heap, RefCount>>; template <template <class> class RefCount> using packet_fields = std::map< refcount::owner_indirection_t<basic_heap, RefCount>, refcount::owner_indirection_t<basic_heap, RefCount>, refcount::owner_indirection_t<dart_comparator, RefCount> >; /** * @brief * Struct represents the minimum context required to perform * an operation on a dart::buffer object. * * @details * At its core, this is what dart::buffer "is". * It just provides a nice API, and some memory safety around * this structure, which is why it's so fast. */ struct raw_element { raw_type type; gsl::byte const* buffer; }; /** * @brief * Struct is the lowest level abstraction for safe iteration over a dart::buffer * object/array. * * @details * Struct holds onto the context for what vtable entry it's currently on, * where the base of its aggregate is, and how to dereference itself. * * @remarks * ll_iterator holds onto more state than I'd like, but it's kind of unavoidable * given the fact that the vtable provides offsets from the base of the aggregate * itself and the fact that we may be iterating over values OR pairs of values. */ template <template <class> class RefCount> struct ll_iterator { /*----- Types -----*/ using value_type = raw_element; using loading_function = value_type (gsl::byte const*, size_t idx); /*----- Lifecycle Functions -----*/ ll_iterator() = delete; ll_iterator(size_t idx, gsl::byte const* base, loading_function* load_func) noexcept : idx(idx), base(base), load_func(load_func) {} ll_iterator(ll_iterator const&) = default; ll_iterator(ll_iterator&&) noexcept = default; ~ll_iterator() = default; /*----- Operators -----*/ ll_iterator& operator =(ll_iterator const&) = default; ll_iterator& operator =(ll_iterator&&) noexcept = default; bool operator ==(ll_iterator const& other) const noexcept; bool operator !=(ll_iterator const& other) const noexcept; auto operator ++() noexcept -> ll_iterator&; auto operator --() noexcept -> ll_iterator&; auto operator ++(int) noexcept -> ll_iterator; auto operator --(int) noexcept -> ll_iterator; auto operator *() const noexcept -> value_type; /*----- Members -----*/ size_t idx; gsl::byte const* base; loading_function* load_func; }; /** * @brief * Struct is the lowest level abstraction for safe iteration over a dart::heap * object/array. * * @details * Struct simply wraps an STL iterator of some type, and a way to dereference it. */ template <template <class> class RefCount> struct dn_iterator { /*----- Types -----*/ using value_type = basic_heap<RefCount>; using reference = value_type const&; using fields_deref_func = reference (typename packet_fields<RefCount>::const_iterator const&); using elements_deref_func = reference (typename packet_elements<RefCount>::const_iterator const&); struct fields_layout { fields_deref_func* deref; typename packet_fields<RefCount>::const_iterator it; }; struct elements_layout { elements_deref_func* deref; typename packet_elements<RefCount>::const_iterator it; }; using implerator = shim::variant<fields_layout, elements_layout>; /*----- Lifecycle Functions -----*/ dn_iterator() = delete; dn_iterator(typename packet_fields<RefCount>::const_iterator it, fields_deref_func* func) noexcept : impl(fields_layout {func, it}) {} dn_iterator(typename packet_elements<RefCount>::const_iterator it, elements_deref_func* func) noexcept : impl(elements_layout {func, it}) {} dn_iterator(dn_iterator const&) = default; dn_iterator(dn_iterator&&) noexcept = default; ~dn_iterator() = default; /*----- Operators -----*/ dn_iterator& operator =(dn_iterator const&) = default; dn_iterator& operator =(dn_iterator&&) noexcept = default; bool operator ==(dn_iterator const& other) const noexcept; bool operator !=(dn_iterator const& other) const noexcept; auto operator ++() noexcept -> dn_iterator&; auto operator --() noexcept -> dn_iterator&; auto operator ++(int) noexcept -> dn_iterator; auto operator --(int) noexcept -> dn_iterator; auto operator *() const noexcept -> reference; /*----- Members -----*/ implerator impl; }; template <template <class> class RefCount> using dynamic_iterator = refcount::owner_indirection_t<dn_iterator, RefCount>; /** * @brief * Class is the lowest level abstraction for safe interaction with * a dart::buffer object. * * @details * Class wraps memory that is stored in little endian byte order, * irrespective of the native ordering of the host machine. * In other words, attempt to subvert its API at your peril. */ template <template <class> class RefCount> class object { public: /*----- Lifecycle Functions -----*/ object() = delete; // JSON Constructors #ifdef DART_USE_SAJSON explicit object(sajson::value fields) noexcept; #endif #if DART_HAS_RAPIDJSON explicit object(rapidjson::Value const& fields) noexcept; #endif // Direct constructors explicit object(gsl::span<packet_pair<RefCount>> pairs) noexcept; explicit object(packet_fields<RefCount> const* fields) noexcept; // Special constructors object(object const* base, object const* incoming) noexcept; template <class Key> object(object const* base, gsl::span<Key const*> key_ptrs) noexcept; object(object const&) = delete; ~object() = delete; /*----- Operators -----*/ object& operator =(object const&) = delete; /*----- Public API -----*/ template <bool silent> bool is_valid(size_t bytes) const noexcept(silent); size_t size() const noexcept; size_t get_sizeof() const noexcept; auto begin() const noexcept -> ll_iterator<RefCount>; auto key_begin() const noexcept -> ll_iterator<RefCount>; auto end() const noexcept -> ll_iterator<RefCount>; auto key_end() const noexcept -> ll_iterator<RefCount>; template <class Callback> auto get_key(shim::string_view const key, Callback&& cb) const noexcept -> raw_element; auto get_it(shim::string_view const key) const noexcept -> ll_iterator<RefCount>; auto get_key_it(shim::string_view const key) const noexcept -> ll_iterator<RefCount>; auto get_value(shim::string_view const key) const noexcept -> raw_element; auto at_value(shim::string_view const key) const -> raw_element; static auto load_key(gsl::byte const* base, size_t idx) noexcept -> typename ll_iterator<RefCount>::value_type; static auto load_value(gsl::byte const* base, size_t idx) noexcept -> typename ll_iterator<RefCount>::value_type; /*----- Public Members -----*/ static constexpr auto alignment = sizeof(int64_t); private: /*----- Private Helpers -----*/ size_t realign(size_t guess, size_t offset) noexcept; template <class Callback> auto get_value_impl(shim::string_view const key, Callback&& cb) const -> raw_element; object_entry* vtable() noexcept; object_entry const* vtable() const noexcept; gsl::byte* raw_vtable() noexcept; gsl::byte const* raw_vtable() const noexcept; /*----- Private Members -----*/ alignas(4) little_order<uint32_t> bytes; alignas(4) little_order<uint32_t> elems; static constexpr auto header_len = sizeof(bytes) + sizeof(elems); }; static_assert(std::is_standard_layout<object<std::shared_ptr>>::value, "dart library is misconfigured"); /** * @brief * Class is the lowest level abstraction for safe interaction with * a dart::buffer array. * * @details * Class wraps memory that is stored in little endian byte order, * irrespective of the native ordering of the host machine. * In other words, attempt to subvert its API at your peril. */ template <template <class> class RefCount> class array { public: /*----- Lifecycle Functions -----*/ array() = delete; #ifdef DART_USE_SAJSON explicit array(sajson::value elems) noexcept; #endif #if DART_HAS_RAPIDJSON explicit array(rapidjson::Value const& elems) noexcept; #endif array(packet_elements<RefCount> const* elems) noexcept; array(array const&) = delete; ~array() = delete; /*----- Operators -----*/ array& operator =(array const&) = delete; /*----- Public API -----*/ template <bool silent> bool is_valid(size_t bytes) const noexcept(silent); size_t size() const noexcept; size_t get_sizeof() const noexcept; auto begin() const noexcept -> ll_iterator<RefCount>; auto end() const noexcept -> ll_iterator<RefCount>; auto get_elem(size_t index) const noexcept -> raw_element; auto at_elem(size_t index) const -> raw_element; static auto load_elem(gsl::byte const* base, size_t idx) noexcept -> typename ll_iterator<RefCount>::value_type; /*----- Public Members -----*/ static constexpr auto alignment = sizeof(int64_t); private: /*----- Private Helpers -----*/ auto get_elem_impl(size_t index, bool throw_if_absent) const -> raw_element; array_entry* vtable() noexcept; array_entry const* vtable() const noexcept; gsl::byte* raw_vtable() noexcept; gsl::byte const* raw_vtable() const noexcept; /*----- Private Members -----*/ alignas(4) little_order<uint32_t> bytes; alignas(4) little_order<uint32_t> elems; static constexpr auto header_len = sizeof(bytes) + sizeof(elems); }; static_assert(std::is_standard_layout<array<std::shared_ptr>>::value, "dart library is misconfigured"); /** * @brief * Class is the lowest level abstraction for safe interaction with * a dart::buffer string. * * @details * Class wraps memory that is stored in little endian byte order, * irrespective of the native ordering of the host machine. * In other words, attempt to subvert its API at your peril. */ template <class SizeType> class basic_string { public: /*----- Public Types -----*/ using size_type = SizeType; /*----- Lifecycle Functions -----*/ basic_string() = delete; explicit basic_string(shim::string_view strv) noexcept; explicit basic_string(char const* str, size_t len) noexcept; basic_string(basic_string const&) = delete; ~basic_string() = delete; /*----- Operators -----*/ basic_string& operator =(basic_string const&) = delete; /*----- Public API -----*/ template <bool silent> bool is_valid(size_t bytes) const noexcept(silent); size_t size() const noexcept; size_t get_sizeof() const noexcept; shim::string_view get_strv() const noexcept; static size_t static_sizeof(size_type len) noexcept; /*----- Public Members -----*/ static constexpr auto alignment = sizeof(size_type); private: /*----- Private Helpers -----*/ char* data() noexcept; char const* data() const noexcept; /*----- Private Members -----*/ alignas(alignment) little_order<size_type> len; static constexpr auto header_len = sizeof(len); }; using string = basic_string<uint16_t>; using big_string = basic_string<uint32_t>; static_assert(std::is_standard_layout<string>::value, "dart library is misconfigured"); static_assert(std::is_standard_layout<big_string>::value, "dart library is misconfigured"); /** * @brief * Class is the lowest level abstraction for safe interaction with * a dart::buffer primitive value. * * @details * Class wraps memory that is stored in little endian byte order, * irrespective of the native ordering of the host machine. * In other words, attempt to subvert its API at your peril. */ template <class T> class primitive { public: /*----- Lifecycle Functions -----*/ primitive() = delete; explicit primitive(T data) noexcept : data(data) {} primitive(primitive const&) = delete; ~primitive() = delete; /*---- Operators -----*/ primitive& operator =(primitive const&) = delete; /*----- Public API -----*/ template <bool silent> bool is_valid(size_t bytes) const noexcept(silent); size_t get_sizeof() const noexcept; T get_data() const noexcept; static size_t static_sizeof() noexcept; /*----- Public Members -----*/ static constexpr auto alignment = sizeof(T); private: /*----- Private Members -----*/ alignas(alignment) little_order<T> data; static constexpr auto header_len = sizeof(data); }; static_assert(std::is_standard_layout<primitive<int>>::value, "dart library is misconfigured"); template <template <class> class RefCount> struct buffer_builder { using buffer = basic_buffer<RefCount>; template <class Span> static auto build_buffer(Span pairs) -> buffer; static auto merge_buffers(buffer const& base, buffer const& incoming) -> buffer; template <class Spannable> static auto project_keys(buffer const& base, Spannable const& keys) -> buffer; template <class Callback> static void each_unique_pair(object<RefCount> const* base, object<RefCount> const* incoming, Callback&& cb); template <class Key, class Callback> static void project_each_pair(object<RefCount> const* base, gsl::span<Key const*> key_ptrs, Callback&& cb); template <class Span> static size_t max_bytes(Span pairs); }; // Used for tag dispatch from factory functions. struct view_tag {}; struct object_tag { static constexpr auto alignment = object<std::shared_ptr>::alignment; }; struct array_tag { static constexpr auto alignment = array<std::shared_ptr>::alignment; }; struct string_tag { static constexpr auto alignment = big_string::alignment; }; struct small_string_tag : string_tag { static constexpr auto alignment = string::alignment; }; struct big_string_tag : string_tag { static constexpr auto alignment = string_tag::alignment; }; struct integer_tag { static constexpr auto alignment = primitive<int64_t>::alignment; }; struct short_integer_tag : integer_tag { static constexpr auto alignment = primitive<int16_t>::alignment; }; struct medium_integer_tag : integer_tag { static constexpr auto alignment = primitive<int32_t>::alignment; }; struct long_integer_tag : integer_tag { static constexpr auto alignment = integer_tag::alignment; }; struct decimal_tag { static constexpr auto alignment = primitive<double>::alignment; }; struct short_decimal_tag : decimal_tag { static constexpr auto alignment = primitive<float>::alignment; }; struct long_decimal_tag : decimal_tag { static constexpr auto alignment = decimal_tag::alignment; }; struct boolean_tag { static constexpr auto alignment = primitive<bool>::alignment; }; struct null_tag { static constexpr auto alignment = 1; }; /** * @brief * Function converts between internal type information and * user-facing type information. * * @details * Dart internally has to encode significantly more complicated * type information than it publicly exposes, so this function * works as a an efficient go-between for the two. */ inline type simplify_type(raw_type type) noexcept { switch (type) { case raw_type::object: return detail::type::object; case raw_type::array: return detail::type::array; case raw_type::small_string: case raw_type::string: case raw_type::big_string: return detail::type::string; case raw_type::short_integer: case raw_type::integer: case raw_type::long_integer: return detail::type::integer; case raw_type::decimal: case raw_type::long_decimal: return detail::type::decimal; case raw_type::boolean: return detail::type::boolean; default: DART_ASSERT(type == raw_type::null); return detail::type::null; } } inline bool valid_type(raw_type type) noexcept { switch (type) { case raw_type::object: case raw_type::array: case raw_type::string: case raw_type::small_string: case raw_type::big_string: case raw_type::short_integer: case raw_type::integer: case raw_type::long_integer: case raw_type::decimal: case raw_type::long_decimal: case raw_type::boolean: case raw_type::null: return true; default: return false; } } /** * @brief * Function provides a "safe" bridge between the high level * and low level object apis. * * @details * Don't pass it null. * Tries its damndest not to invoke UB, but god knows. */ template <template <class> class RefCount> object<RefCount> const* get_object(raw_element raw) { if (simplify_type(raw.type) == type::object) { DART_ASSERT(raw.buffer != nullptr); return shim::launder(reinterpret_cast<object<RefCount> const*>(raw.buffer)); } else { throw type_error("dart::buffer is not a finalized object and cannot be accessed as such"); } } /** * @brief * Function provides a "safe" bridge between the high level * and low level array apis. * * @details * Don't pass it null. * Tries its damndest not to invoke UB, but god knows. */ template <template <class> class RefCount> array<RefCount> const* get_array(raw_element raw) { if (simplify_type(raw.type) == type::array) { DART_ASSERT(raw.buffer != nullptr); return shim::launder(reinterpret_cast<array<RefCount> const*>(raw.buffer)); } else { throw type_error("dart::buffer is not a finalized array and cannot be accessed as such"); } } /** * @brief * Function provides a "safe" bridge between the high level * and low level string apis. * * @details * Don't pass it null. * Tries its damndest not to invoke UB, but god knows. */ inline string const* get_string(raw_element raw) { if (raw.type == raw_type::small_string || raw.type == raw_type::string) { DART_ASSERT(raw.buffer != nullptr); return shim::launder(reinterpret_cast<string const*>(raw.buffer)); } else { throw type_error("dart::buffer is not a finalized string and cannot be accessed as such"); } } /** * @brief * Function provides a "safe" bridge between the high level * and low level string apis. * * @details * Don't pass it null. * Tries its damndest not to invoke UB, but god knows. */ inline big_string const* get_big_string(raw_element raw) { if (raw.type == raw_type::big_string) { DART_ASSERT(raw.buffer != nullptr); return shim::launder(reinterpret_cast<big_string const*>(raw.buffer)); } else { throw type_error("dart::buffer is not a finalized string and cannot be accessed as such"); } } /** * @brief * Function provides a "safe" bridge between the high level * and low level primitive apis. * * @details * Don't pass it null. * Tries its damndest not to invoke UB, but god knows. */ template <class T> primitive<T> const* get_primitive(raw_element raw) { auto simple = simplify_type(raw.type); if (simple == type::integer || simple == type::decimal || simple == type::boolean) { DART_ASSERT(raw.buffer != nullptr); return shim::launder(reinterpret_cast<primitive<T> const*>(raw.buffer)); } else { throw type_error("dart::buffer is not a finalized primitive and cannot be accessed as such"); } } template <template <class> class RefCount, class Callback> auto aggregate_deref(Callback&& cb, raw_element raw) -> std::common_type_t< decltype(std::forward<Callback>(cb)(std::declval<object<RefCount>&>())), decltype(std::forward<Callback>(cb)(std::declval<array<RefCount>&>())) > { switch (raw.type) { case raw_type::object: return std::forward<Callback>(cb)(*get_object<RefCount>(raw)); case raw_type::array: return std::forward<Callback>(cb)(*get_array<RefCount>(raw)); default: throw type_error("dart::buffer is not a finalized aggregate and cannot be accessed as such"); } } template <class Callback> auto string_deref(Callback&& cb, raw_element raw) -> std::common_type_t< decltype(std::forward<Callback>(cb)(std::declval<string&>())), decltype(std::forward<Callback>(cb)(std::declval<big_string&>())) > { switch (raw.type) { case raw_type::small_string: case raw_type::string: return std::forward<Callback>(cb)(*get_string(raw)); case raw_type::big_string: return std::forward<Callback>(cb)(*get_big_string(raw)); default: throw type_error("dart::buffer is not a finalized string and cannot be accessed as such"); } } template <class Callback> auto integer_deref(Callback&& cb, raw_element raw) -> std::common_type_t< decltype(std::forward<Callback>(cb)(std::declval<primitive<int16_t>&>())), decltype(std::forward<Callback>(cb)(std::declval<primitive<int32_t>&>())), decltype(std::forward<Callback>(cb)(std::declval<primitive<int64_t>&>())) > { switch (raw.type) { case raw_type::short_integer: return std::forward<Callback>(cb)(*get_primitive<int16_t>(raw)); case raw_type::integer: return std::forward<Callback>(cb)(*get_primitive<int32_t>(raw)); case raw_type::long_integer: return std::forward<Callback>(cb)(*get_primitive<int64_t>(raw)); default: throw type_error("dart::buffer is not a finalized integer and cannot be accessed as such"); } } template <class Callback> auto decimal_deref(Callback&& cb, raw_element raw) -> std::common_type_t< decltype(std::forward<Callback>(cb)(std::declval<primitive<float>&>())), decltype(std::forward<Callback>(cb)(std::declval<primitive<double>&>())) > { switch (raw.type) { case raw_type::decimal: return std::forward<Callback>(cb)(*get_primitive<float>(raw)); case raw_type::long_decimal: return std::forward<Callback>(cb)(*get_primitive<double>(raw)); default: throw type_error("dart::buffer is not a finalized decimal and cannot be accessed as such"); } } template <class Callback> auto match_generic(Callback&& cb, raw_type raw) -> std::common_type_t< decltype(std::forward<Callback>(cb)(object_tag {})), decltype(std::forward<Callback>(cb)(array_tag {})), decltype(std::forward<Callback>(cb)(small_string_tag {})), decltype(std::forward<Callback>(cb)(big_string_tag {})), decltype(std::forward<Callback>(cb)(short_integer_tag {})), decltype(std::forward<Callback>(cb)(medium_integer_tag {})), decltype(std::forward<Callback>(cb)(long_integer_tag {})), decltype(std::forward<Callback>(cb)(short_decimal_tag {})), decltype(std::forward<Callback>(cb)(long_decimal_tag {})), decltype(std::forward<Callback>(cb)(boolean_tag {})), decltype(std::forward<Callback>(cb)(null_tag {})) > { switch (raw) { case raw_type::object: return std::forward<Callback>(cb)(object_tag {}); case raw_type::array: return std::forward<Callback>(cb)(array_tag {}); case raw_type::small_string: case raw_type::string: return std::forward<Callback>(cb)(small_string_tag {}); case raw_type::big_string: return std::forward<Callback>(cb)(big_string_tag {}); case raw_type::short_integer: return std::forward<Callback>(cb)(short_integer_tag {}); case raw_type::integer: return std::forward<Callback>(cb)(medium_integer_tag {}); case raw_type::long_integer: return std::forward<Callback>(cb)(long_integer_tag {}); case raw_type::decimal: return std::forward<Callback>(cb)(short_decimal_tag {}); case raw_type::long_decimal: return std::forward<Callback>(cb)(long_decimal_tag {}); case raw_type::boolean: return std::forward<Callback>(cb)(boolean_tag {}); default: DART_ASSERT(raw == raw_type::null); return std::forward<Callback>(cb)(null_tag {}); } } template <template <class> class RefCount, class Callback> auto generic_deref(Callback&& cb, raw_element raw) -> std::common_type_t< decltype(aggregate_deref<RefCount>(std::forward<Callback>(cb), raw)), decltype(string_deref(std::forward<Callback>(cb), raw)), decltype(integer_deref(std::forward<Callback>(cb), raw)), decltype(decimal_deref(std::forward<Callback>(cb), raw)), decltype(std::forward<Callback>(cb)(std::declval<primitive<bool>&>())) > { switch (raw.type) { case raw_type::object: case raw_type::array: return aggregate_deref<RefCount>(std::forward<Callback>(cb), raw); case raw_type::small_string: case raw_type::string: case raw_type::big_string: return string_deref(std::forward<Callback>(cb), raw); case raw_type::short_integer: case raw_type::integer: case raw_type::long_integer: return integer_deref(std::forward<Callback>(cb), raw); case raw_type::decimal: case raw_type::long_decimal: return decimal_deref(std::forward<Callback>(cb), raw); case raw_type::boolean: return std::forward<Callback>(cb)(*get_primitive<bool>(raw)); default: DART_ASSERT(raw.type == raw_type::null); throw type_error("dart::buffer is null, and has no value to access"); } } // Returns the native alignment requirements of the given type. template <template <class> class RefCount> constexpr size_t alignment_of(raw_type type) noexcept { return match_generic([] (auto v) { return decltype(v)::alignment; }, type); } // Function takes a pointer and returns a pointer to the "next" (greater than OR equal to) boundary // conforming to the native alignment of the given type. // Assumes that all alignment requests are for powers of two. template <template <class> class RefCount, class T> constexpr T* align_pointer(T* ptr, raw_type type) noexcept { // Get the required alignment for a pointer of this type. auto alignment = alignment_of<RefCount>(type); // Bump forward to the next boundary of the given alignment requirement. uintptr_t offset = reinterpret_cast<uintptr_t>(ptr); return reinterpret_cast<T*>((offset + (alignment - 1)) & ~(alignment - 1)); } template <template <class> class RefCount, class T> constexpr T pad_bytes(T bytes, raw_type type) noexcept { // Get the required alignment for a pointer of this type. auto alignment = alignment_of<RefCount>(type); // Pad the given bytes to ensure its end lands on an alignment boundary. return (bytes + (alignment - 1)) & ~(alignment - 1); } template <template <class> class RefCount> size_t find_sizeof(raw_element elem) noexcept { if (elem.type != raw_type::null) { return generic_deref<RefCount>([] (auto& v) { return v.get_sizeof(); }, elem); } else { return 0; } } template <bool silent, template <class> class RefCount> bool valid_buffer(raw_element elem, size_t bytes) noexcept(silent) { // Null is a special case because it occupies zero space in the network buffer // Check if the given element has a valid type. // If we're validating against corrupted garbage it likely won't if (elem.type == raw_type::null) return true; else if (!valid_type(elem.type)) return false; // Call through to our implementation return generic_deref<RefCount>([=] (auto& v) { return v.template is_valid<silent>(bytes); }, elem); } template <template <class> class RefCount> constexpr size_t sso_bytes() { return basic_heap<RefCount>::sso_bytes; } template <template <class> class RefCount> raw_type identify_string(shim::string_view base, shim::string_view app = "") noexcept { auto total = base.size() + app.size(); if (total > std::numeric_limits<uint16_t>::max()) { return detail::raw_type::big_string; } else if (total > sso_bytes<RefCount>()) { return detail::raw_type::string; } else { return detail::raw_type::small_string; } } constexpr raw_type identify_integer(int64_t val) noexcept { if (val > INT32_MAX || val < INT32_MIN) return raw_type::long_integer; else if (val > INT16_MAX || val < INT16_MIN) return raw_type::integer; else return raw_type::short_integer; } // Returns the smallest floating point type capable of precisely representing the given // value. constexpr raw_type identify_decimal(double val) noexcept { // XXX: I'm not impressed by this check either, but I can't find any legit way // to check if a double will be precisely representable as a float. if (val != static_cast<float>(val)) return raw_type::long_decimal; else return raw_type::decimal; } // Dart is header-only, so I think the scenarios where the ABI stability of // symbol mangling will be relevant are relatively few. #if DART_USING_GCC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wnoexcept-type" #elif DART_USING_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wc++17-compat-mangling" #pragma clang diagnostic ignored "-Wc++1z-compat" #endif template <class Packet, class T> T safe_optional_access(Packet const& that, T opt, bool (Packet::* guard) () const noexcept, T (Packet::* accessor) () const) { if (!(that.*guard)()) { return opt; } else try { return (that.*accessor)(); } catch (...) { return opt; } } #if DART_USING_GCC #pragma GCC diagnostic pop #elif DART_USING_CLANG #pragma clang diagnostic pop #endif template <template <class> class RefCount, class Owner = buffer_refcount_type<RefCount>, class Callback> Owner aligned_alloc(size_t bytes, raw_type type, Callback&& cb) { // Make an aligned allocation. gsl::byte* tmp; int retval = shim::aligned_alloc(reinterpret_cast<void**>(&tmp), alignment_of<RefCount>(type), bytes); if (retval) throw std::bad_alloc(); // Associate it with an owner in case anything goes wrong. Owner ref {tmp, +[] (gsl::byte const* ptr) { shim::aligned_free(const_cast<gsl::byte*>(ptr)); }}; // Hand out mutable access and return. cb(tmp); return ref; } template <template <class> class RefCount, size_t static_elems = 8, class Spannable, class Callback> decltype(auto) sort_spannable(Spannable const& elems, Callback&& cb) { // XXX: This is necessary because I'm supporting an ANCIENT version of gsl-lite that // doesn't contain the nested type alias value_type, only element_type // Modern versions of gsl-lite, and Microsoft GSL, and std::span, include a value_type // As a fix, meta::spannable_value_type_t returns value_type if it exists, // next element_type if it exists, // and finally meta::nonesuch if neither alias exists using value_type = meta::spannable_value_type_t<Spannable>; static_assert( !std::is_same< value_type, meta::nonesuch >::value, "Sort spannable only supports types that conform to the std::span interface" ); // Check if we can perform the sorting statically. dart_comparator<RefCount> comp; auto const size = static_cast<size_t>(elems.size()); if (size <= static_elems) { // We've got enough static space, setup a local array. std::array<value_type const*, static_elems> ptrs; std::transform(std::begin(elems), std::end(elems), std::begin(ptrs), [] (auto& e) { return &e; }); // Sort the pointers and pass back to the user. std::sort(ptrs.data(), ptrs.data() + size, [&] (auto* lhs, auto* rhs) { return comp(*lhs, *rhs); }); return cb(gsl::make_span(ptrs.data(), size)); } else { // Dynamic fallback. std::vector<value_type const*> ptrs(size, nullptr); std::transform(std::begin(elems), std::end(elems), std::begin(ptrs), [] (auto& e) { return &e; }); // Sort and pass back. std::sort(std::begin(ptrs), std::end(ptrs), [&] (auto* lhs, auto* rhs) { return comp(*lhs, *rhs); }); return cb(gsl::make_span(ptrs)); } } #ifdef DART_USE_SAJSON // FIXME: Find somewhere better to put these functions. template <template <class> class RefCount> raw_type json_identify(sajson::value curr_val) { switch (curr_val.get_type()) { case sajson::TYPE_OBJECT: return raw_type::object; case sajson::TYPE_ARRAY: return raw_type::array; case sajson::TYPE_STRING: // Figure out what type of string we've been given. return identify_string<RefCount>({curr_val.as_cstring(), curr_val.get_string_length()}); case sajson::TYPE_INTEGER: return identify_integer(curr_val.get_integer_value()); case sajson::TYPE_DOUBLE: return identify_decimal(curr_val.get_double_value()); case sajson::TYPE_FALSE: case sajson::TYPE_TRUE: return raw_type::boolean; default: DART_ASSERT(curr_val.get_type() == sajson::TYPE_NULL); return raw_type::null; } } template <template <class> class RefCount> size_t json_lower(gsl::byte* buffer, sajson::value curr_val) { auto raw = json_identify<RefCount>(curr_val); switch (raw) { case raw_type::object: new(buffer) object<RefCount>(curr_val); break; case raw_type::array: new(buffer) array<RefCount>(curr_val); break; case raw_type::small_string: case raw_type::string: new(buffer) string(curr_val.as_cstring(), curr_val.get_string_length()); break; case raw_type::big_string: new(buffer) big_string(curr_val.as_cstring(), curr_val.get_string_length()); break; case raw_type::short_integer: new(buffer) primitive<int16_t>(curr_val.get_integer_value()); break; case raw_type::integer: new(buffer) primitive<int32_t>(curr_val.get_integer_value()); break; case raw_type::long_integer: new(buffer) primitive<int64_t>(curr_val.get_integer_value()); break; case raw_type::decimal: new(buffer) primitive<float>(curr_val.get_double_value()); break; case raw_type::long_decimal: new(buffer) primitive<double>(curr_val.get_double_value()); break; case raw_type::boolean: new(buffer) detail::primitive<bool>((curr_val.get_type() == sajson::TYPE_TRUE) ? true : false); break; default: DART_ASSERT(curr_val.get_type() == sajson::TYPE_NULL); break; } return detail::find_sizeof<RefCount>({raw, buffer}); } #endif #if DART_HAS_RAPIDJSON // FIXME: Find somewhere better to put these functions. template <template <class> class RefCount> raw_type json_identify(rapidjson::Value const& curr_val) { switch (curr_val.GetType()) { case rapidjson::kObjectType: return raw_type::object; case rapidjson::kArrayType: return raw_type::array; case rapidjson::kStringType: // Figure out what type of string we've been given. return identify_string<RefCount>({curr_val.GetString(), curr_val.GetStringLength()}); case rapidjson::kNumberType: // Figure out what type of number we've been given. if (curr_val.IsInt64()) return identify_integer(curr_val.GetInt64()); else return identify_decimal(curr_val.GetDouble()); case rapidjson::kTrueType: case rapidjson::kFalseType: return raw_type::boolean; default: DART_ASSERT(curr_val.IsNull()); return raw_type::null; } } template <template <class> class RefCount> size_t json_lower(gsl::byte* buffer, rapidjson::Value const& curr_val) { auto raw = json_identify<RefCount>(curr_val); switch (raw) { case raw_type::object: new(buffer) object<RefCount>(curr_val); break; case raw_type::array: new(buffer) array<RefCount>(curr_val); break; case raw_type::small_string: case raw_type::string: new(buffer) string(curr_val.GetString(), curr_val.GetStringLength()); break; case raw_type::big_string: new(buffer) big_string(curr_val.GetString(), curr_val.GetStringLength()); break; case raw_type::short_integer: new(buffer) primitive<int16_t>(curr_val.GetInt()); break; case raw_type::integer: new(buffer) primitive<int32_t>(curr_val.GetInt()); break; case raw_type::long_integer: new(buffer) primitive<int64_t>(curr_val.GetInt64()); break; case raw_type::decimal: new(buffer) primitive<float>(curr_val.GetFloat()); break; case raw_type::long_decimal: new(buffer) primitive<double>(curr_val.GetDouble()); break; case raw_type::boolean: new(buffer) detail::primitive<bool>(curr_val.GetBool()); break; default: DART_ASSERT(curr_val.IsNull()); break; } return detail::find_sizeof<RefCount>({raw, buffer}); } #endif // Helper function handles the edge case where we're working with // a view type, and we need to cast it back to an owner, ONLY IF // we are an owner ourselves. template <class MaybeView, class View> decltype(auto) view_return_indirection(View&& view) { return shim::compose_together( [] (auto&& v, std::true_type) -> decltype(auto) { return std::forward<decltype(v)>(v); }, [] (auto&& v, std::false_type) -> decltype(auto) { return std::forward<decltype(v)>(v).as_owner(); } )(std::forward<View>(view), std::is_same<std::decay_t<MaybeView>, std::decay_t<View>> {}); } template <class Packet> Packet get_nested_impl(Packet haystack, shim::string_view needle, char separator) { // Spin through the provided needle until we reach the end, or hit a leaf. auto start = needle.begin(); typename Packet::view curr = haystack; while (start < needle.end() && curr.is_object()) { // Tokenize up the needle and drag the current packet through each one. auto stop = std::find(start, needle.end(), separator); curr = curr[needle.substr(start - needle.begin(), stop - start)]; // Prepare for next iteration. stop == needle.end() ? start = stop : start = stop + 1; } // If we finished, find our final value, otherwise return null. if (start < needle.end()) return Packet::make_null(); else return view_return_indirection<Packet>(curr); } template <class Packet> std::vector<Packet> keys_impl(Packet const& that) { std::vector<Packet> packets; packets.reserve(that.size()); for (auto it = that.key_begin(); it != that.key_end(); ++it) { packets.push_back(*it); } return packets; } template <class Packet> std::vector<Packet> values_impl(Packet const& that) { std::vector<Packet> packets; packets.reserve(that.size()); for (auto entry : that) packets.push_back(std::move(entry)); return packets; } template <class T> decltype(auto) maybe_dereference(T&& maybeptr, std::true_type) { return *std::forward<T>(maybeptr); } template <class T> decltype(auto) maybe_dereference(T&& maybeptr, std::false_type) { return std::forward<T>(maybeptr); } } } // Include main header file for all implementation files. #include "../dart.h" #include "common.tcc" #endif
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import linear_algebra.affine_space.affine_map import topology.continuous_function.basic import topology.algebra.module.basic /-! # Continuous affine maps. This file defines a type of bundled continuous affine maps. Note that the definition and basic properties established here require minimal assumptions, and do not even assume compatibility between the topological and algebraic structures. Of course it is necessary to assume some compatibility in order to obtain a useful theory. Such a theory is developed elsewhere for affine spaces modelled on _normed_ vector spaces, but not yet for general topological affine spaces (since we have not defined these yet). ## Main definitions: * `continuous_affine_map` ## Notation: We introduce the notation `P →A[R] Q` for `continuous_affine_map R P Q`. Note that this is parallel to the notation `E →L[R] F` for `continuous_linear_map R E F`. -/ /-- A continuous map of affine spaces. -/ structure continuous_affine_map (R : Type*) {V W : Type*} (P Q : Type*) [ring R] [add_comm_group V] [module R V] [topological_space P] [add_torsor V P] [add_comm_group W] [module R W] [topological_space Q] [add_torsor W Q] extends P →ᵃ[R] Q := (cont : continuous to_fun) notation P ` →A[`:25 R `] ` Q := continuous_affine_map R P Q namespace continuous_affine_map variables {R V W P Q : Type*} [ring R] variables [add_comm_group V] [module R V] [topological_space P] [add_torsor V P] variables [add_comm_group W] [module R W] [topological_space Q] [add_torsor W Q] include V W instance : has_coe (P →A[R] Q) (P →ᵃ[R] Q) := ⟨to_affine_map⟩ lemma to_affine_map_injective {f g : P →A[R] Q} (h : (f : P →ᵃ[R] Q) = (g : P →ᵃ[R] Q)) : f = g := by { cases f, cases g, congr' } instance : continuous_map_class (P →A[R] Q) P Q := { coe := λ f, f.to_affine_map, coe_injective' := λ f g h, to_affine_map_injective $ fun_like.coe_injective h, map_continuous := cont } /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun` directly. -/ instance : has_coe_to_fun (P →A[R] Q) (λ _, P → Q) := fun_like.has_coe_to_fun lemma to_fun_eq_coe (f : P →A[R] Q) : f.to_fun = ⇑f := rfl lemma coe_injective : @function.injective (P →A[R] Q) (P → Q) coe_fn := fun_like.coe_injective @[ext] lemma ext {f g : P →A[R] Q} (h : ∀ x, f x = g x) : f = g := fun_like.ext _ _ h lemma ext_iff {f g : P →A[R] Q} : f = g ↔ ∀ x, f x = g x := fun_like.ext_iff lemma congr_fun {f g : P →A[R] Q} (h : f = g) (x : P) : f x = g x := fun_like.congr_fun h _ /-- Forgetting its algebraic properties, a continuous affine map is a continuous map. -/ def to_continuous_map (f : P →A[R] Q) : C(P, Q) := ⟨f, f.cont⟩ instance : has_coe (P →A[R] Q) (C(P, Q)) := ⟨to_continuous_map⟩ @[simp] lemma to_affine_map_eq_coe (f : P →A[R] Q) : f.to_affine_map = ↑f := rfl @[simp] lemma to_continuous_map_coe (f : P →A[R] Q) : f.to_continuous_map = ↑f := rfl @[simp, norm_cast] @[simp, norm_cast] lemma coe_to_continuous_map (f : P →A[R] Q) : ((f : C(P, Q)) : P → Q) = f := rfl lemma to_continuous_map_injective {f g : P →A[R] Q} (h : (f : C(P, Q)) = (g : C(P, Q))) : f = g := by { ext a, exact continuous_map.congr_fun h a, } @[norm_cast] lemma coe_affine_map_mk (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →A[R] Q) : P →ᵃ[R] Q) = f := rfl @[norm_cast] lemma coe_continuous_map_mk (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →A[R] Q) : C(P, Q)) = ⟨f, h⟩ := rfl @[simp] lemma coe_mk (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →A[R] Q) : P → Q) = f := rfl @[simp] lemma mk_coe (f : P →A[R] Q) (h) : (⟨(f : P →ᵃ[R] Q), h⟩ : P →A[R] Q) = f := by { ext, refl, } @[continuity] protected lemma continuous (f : P →A[R] Q) : continuous f := f.2 variables (R P) /-- The constant map is a continuous affine map. -/ def const (q : Q) : P →A[R] Q := { to_fun := affine_map.const R P q, cont := continuous_const, .. affine_map.const R P q, } @[simp] lemma coe_const (q : Q) : (const R P q : P → Q) = function.const P q := rfl noncomputable instance : inhabited (P →A[R] Q) := ⟨const R P $ nonempty.some (by apply_instance : nonempty Q)⟩ variables {R P} {W₂ Q₂ : Type*} variables [add_comm_group W₂] [module R W₂] [topological_space Q₂] [add_torsor W₂ Q₂] include W₂ /-- The composition of morphisms is a morphism. -/ def comp (f : Q →A[R] Q₂) (g : P →A[R] Q) : P →A[R] Q₂ := { cont := f.cont.comp g.cont, .. (f : Q →ᵃ[R] Q₂).comp (g : P →ᵃ[R] Q), } @[simp, norm_cast] lemma coe_comp (f : Q →A[R] Q₂) (g : P →A[R] Q) : (f.comp g : P → Q₂) = (f : Q → Q₂) ∘ (g : P → Q) := rfl lemma comp_apply (f : Q →A[R] Q₂) (g : P →A[R] Q) (x : P) : f.comp g x = f (g x) := rfl omit W₂ section module_valued_maps variables {S : Type*} variables [topological_space W] instance : has_zero (P →A[R] W) := ⟨continuous_affine_map.const R P 0⟩ @[norm_cast, simp] lemma coe_zero : ((0 : P →A[R] W) : P → W) = 0 := rfl lemma zero_apply (x : P) : (0 : P →A[R] W) x = 0 := rfl section mul_action variables [monoid S] [distrib_mul_action S W] [smul_comm_class R S W] variables [has_continuous_const_smul S W] instance : has_smul S (P →A[R] W) := { smul := λ t f, { cont := f.continuous.const_smul t, .. (t • (f : P →ᵃ[R] W)) } } @[norm_cast, simp] lemma coe_smul (t : S) (f : P →A[R] W) : ⇑(t • f) = t • f := rfl lemma smul_apply (t : S) (f : P →A[R] W) (x : P) : (t • f) x = t • (f x) := rfl instance [distrib_mul_action Sᵐᵒᵖ W] [is_central_scalar S W] : is_central_scalar S (P →A[R] W) := { op_smul_eq_smul := λ t f, ext $ λ _, op_smul_eq_smul _ _ } instance : mul_action S (P →A[R] W) := function.injective.mul_action _ coe_injective coe_smul end mul_action variables [topological_add_group W] instance : has_add (P →A[R] W) := { add := λ f g, { cont := f.continuous.add g.continuous, .. ((f : P →ᵃ[R] W) + (g : P →ᵃ[R] W)) }, } @[norm_cast, simp] lemma coe_add (f g : P →A[R] W) : ⇑(f + g) = f + g := rfl lemma add_apply (f g : P →A[R] W) (x : P) : (f + g) x = f x + g x := rfl instance : has_sub (P →A[R] W) := { sub := λ f g, { cont := f.continuous.sub g.continuous, .. ((f : P →ᵃ[R] W) - (g : P →ᵃ[R] W)) }, } @[norm_cast, simp] lemma coe_sub (f g : P →A[R] W) : ⇑(f - g) = f - g := rfl lemma sub_apply (f g : P →A[R] W) (x : P) : (f - g) x = f x - g x := rfl instance : has_neg (P →A[R] W) := { neg := λ f, { cont := f.continuous.neg, .. (-(f : P →ᵃ[R] W)) }, } @[norm_cast, simp] lemma coe_neg (f : P →A[R] W) : ⇑(-f) = -f := rfl lemma neg_apply (f : P →A[R] W) (x : P) : (-f) x = -(f x) := rfl instance : add_comm_group (P →A[R] W) := coe_injective.add_comm_group _ coe_zero coe_add coe_neg coe_sub (λ _ _, coe_smul _ _) (λ _ _, coe_smul _ _) instance [monoid S] [distrib_mul_action S W] [smul_comm_class R S W] [has_continuous_const_smul S W] : distrib_mul_action S (P →A[R] W) := function.injective.distrib_mul_action ⟨λ f, f.to_affine_map.to_fun, rfl, coe_add⟩ coe_injective coe_smul instance [semiring S] [module S W] [smul_comm_class R S W] [has_continuous_const_smul S W] : module S (P →A[R] W) := function.injective.module S ⟨λ f, f.to_affine_map.to_fun, rfl, coe_add⟩ coe_injective coe_smul end module_valued_maps end continuous_affine_map namespace continuous_linear_map variables {R V W : Type*} [ring R] variables [add_comm_group V] [module R V] [topological_space V] variables [add_comm_group W] [module R W] [topological_space W] /-- A continuous linear map can be regarded as a continuous affine map. -/ def to_continuous_affine_map (f : V →L[R] W) : V →A[R] W := { to_fun := f, linear := f, map_vadd' := by simp, cont := f.cont, } @[simp] lemma coe_to_continuous_affine_map (f : V →L[R] W) : ⇑f.to_continuous_affine_map = f := rfl @[simp] lemma to_continuous_affine_map_map_zero (f : V →L[R] W) : f.to_continuous_affine_map 0 = 0 := by simp end continuous_linear_map
% Example main source file. \documentclass{abertayhons} \addbibresource{refs.bib} \usepackage{hyperref} % \blindtext is used in various places to generate some example text; % in your real dissertation you won't need this package. \usepackage{blindtext} \begin{document} \frontmatter \title{The construction of a \LaTeX\ class for Abertay honours dissertations} \author{Adam Sampson} \degree{BSc (Hons) Underwater Basket Weaving} \year{2018} \school{School of Design and Informatics} \maketitle \tablematter \tableofcontents \listoffigures \listoftables \frontmatter \begin{acknowledgements} \Blindtext[1] \end{acknowledgements} \begin{abstract} \Blindtext[2] \end{abstract} \mainmatter \chapter{Introduction} The \LaTeX\ system is pretty good for formatting %dissertations~\citep{wblatex}. \blindtext As shown by~\cite{llvm}, the LLVM compiler framework is also really cool. \blindtext \blindtext The implementation of this algorithm is shown in~\autoref{fig:somecode}. \begin{figure} % See the "listings" package for fancier code formatting. \begin{verbatim} // Work out the point in the complex plane that // corresponds to this pixel in the output image. complex<double> c(left + (x * (right - left) / WIDTH), top + (y * (bottom - top) / HEIGHT)); // Start off z at (0, 0). complex<double> z(0.0, 0.0); \end{verbatim} \caption{Some code.} \label{fig:somecode} \end{figure} \Blindtext \section{Research Question} \Blindtext[1] \section{Objectives} \blinditemize \chapter{Literature Review} \Blindtext \chapter{Methodology} \blindmathpaper \chapter{Results} \Blindtext \chapter{Discussion} \Blindtext \chapter{Conclusion and Future Work} \section{Conclusion} \Blindtext \section{Future Work} \Blindtext \appendix \chapter{Table of Tables of Tables} \Blindtext[2] \chapter{Survey Responses} \Blindtext[7] \printbibliography \end{document}
Formal statement is: lemma tendsto_add_zero: fixes f g :: "_ \<Rightarrow> 'b::topological_monoid_add" shows "(f \<longlongrightarrow> 0) F \<Longrightarrow> (g \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. f x + g x) \<longlongrightarrow> 0) F" Informal statement is: If $f$ and $g$ converge to $0$ in the filter $F$, then $f + g$ converges to $0$ in $F$.
[STATEMENT] lemma vc_sound: "vc C Q \<Longrightarrow> finite (support Q) \<Longrightarrow> finite (varacom C) \<Longrightarrow> fst ` (set upds) \<inter> varacom C = {} \<Longrightarrow> distinct (map fst upds) \<Longrightarrow> \<turnstile>\<^sub>1 {%l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> %l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)) [PROOF STEP] proof(induction C arbitrary: Q upds) [PROOF STATE] proof (state) goal (6 subgoals): 1. \<And>Q upds. \<lbrakk>vc SKIP Q; finite (support Q); finite (varacom SKIP); lesvars upds \<inter> varacom SKIP = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre SKIP Q l s \<and> preList upds SKIP l s} strip SKIP { time SKIP \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre SKIP Q l s \<longrightarrow> Q l (postQ SKIP s)) 2. \<And>x1 x2 Q upds. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) 3. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 4. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 5. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 6. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] case (Askip Q upds) [PROOF STATE] proof (state) this: vc SKIP Q finite (support Q) finite (varacom SKIP) lesvars upds \<inter> varacom SKIP = {} distinct (map fst upds) goal (6 subgoals): 1. \<And>Q upds. \<lbrakk>vc SKIP Q; finite (support Q); finite (varacom SKIP); lesvars upds \<inter> varacom SKIP = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre SKIP Q l s \<and> preList upds SKIP l s} strip SKIP { time SKIP \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre SKIP Q l s \<longrightarrow> Q l (postQ SKIP s)) 2. \<And>x1 x2 Q upds. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) 3. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 4. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 5. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 6. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: vc SKIP Q finite (support Q) finite (varacom SKIP) lesvars upds \<inter> varacom SKIP = {} distinct (map fst upds) [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: vc SKIP Q finite (support Q) finite (varacom SKIP) lesvars upds \<inter> varacom SKIP = {} distinct (map fst upds) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre SKIP Q l s \<and> preList upds SKIP l s} strip SKIP { time SKIP \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre SKIP Q l s \<longrightarrow> Q l (postQ SKIP s)) [PROOF STEP] apply(auto) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. Q l s \<and> preList upds SKIP l s} SKIP { \<lambda>a. Suc 0 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule weaken_post[where Q="%l s. Q l s \<and> preList upds Askip l s"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. Q l s \<and> preList upds SKIP l s} SKIP { \<lambda>a. Suc 0 \<Down> \<lambda>l s. Q l s \<and> preList upds SKIP l s} 2. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<forall>l s. Q l s \<and> preList upds SKIP l s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] apply(simp add: Skip) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<forall>l s. Q l s \<and> preList upds SKIP l s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] using ListAskip [PROOF STATE] proof (prove) using this: preList ?xs SKIP ?l ?s = postList ?xs ?l ?s goal (1 subgoal): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<forall>l s. Q l s \<and> preList upds SKIP l s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] by fast [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre SKIP Q l s \<and> preList upds SKIP l s} strip SKIP { time SKIP \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre SKIP Q l s \<longrightarrow> Q l (postQ SKIP s)) goal (5 subgoals): 1. \<And>x1 x2 Q upds. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) 2. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 3. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 4. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 5. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] next [PROOF STATE] proof (state) goal (5 subgoals): 1. \<And>x1 x2 Q upds. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) 2. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 3. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 4. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 5. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] case (Aassign x1 x2 Q upds) [PROOF STATE] proof (state) this: vc (x1 ::= x2) Q finite (support Q) finite (varacom (x1 ::= x2)) lesvars upds \<inter> varacom (x1 ::= x2) = {} distinct (map fst upds) goal (5 subgoals): 1. \<And>x1 x2 Q upds. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) 2. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 3. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 4. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 5. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: vc (x1 ::= x2) Q finite (support Q) finite (varacom (x1 ::= x2)) lesvars upds \<inter> varacom (x1 ::= x2) = {} distinct (map fst upds) [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: vc (x1 ::= x2) Q finite (support Q) finite (varacom (x1 ::= x2)) lesvars upds \<inter> varacom (x1 ::= x2) = {} distinct (map fst upds) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) [PROOF STEP] apply(safe) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<And>l s. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds); pre (x1 ::= x2) Q l s\<rbrakk> \<Longrightarrow> Q l (postQ (x1 ::= x2) s) [PROOF STEP] apply(auto simp add: Assign)[1] [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. Q l (s[x2/x1]) \<and> preList upds (x1 ::= x2) l s} x1 ::= x2 { \<lambda>a. Suc 0 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<And>l s. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds); pre (x1 ::= x2) Q l s\<rbrakk> \<Longrightarrow> Q l (postQ (x1 ::= x2) s) [PROOF STEP] apply(rule weaken_post[where Q="%l s. Q l s \<and> postList upds l s"]) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. Q l (s[x2/x1]) \<and> preList upds (x1 ::= x2) l s} x1 ::= x2 { \<lambda>a. Suc 0 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<forall>l s. Q l s \<and> postList upds l s \<longrightarrow> Q l s \<and> postList upds l s 3. \<And>l s. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds); pre (x1 ::= x2) Q l s\<rbrakk> \<Longrightarrow> Q l (postQ (x1 ::= x2) s) [PROOF STEP] apply(simp only: ListAassign) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. Q l (s[x2/x1]) \<and> postList upds l (s[x2/x1])} x1 ::= x2 { \<lambda>a. Suc 0 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<forall>l s. Q l s \<and> postList upds l s \<longrightarrow> Q l s \<and> postList upds l s 3. \<And>l s. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds); pre (x1 ::= x2) Q l s\<rbrakk> \<Longrightarrow> Q l (postQ (x1 ::= x2) s) [PROOF STEP] apply(rule Assign) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>finite (support Q); distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<forall>l s. Q l s \<and> postList upds l s \<longrightarrow> Q l s \<and> postList upds l s 2. \<And>l s. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds); pre (x1 ::= x2) Q l s\<rbrakk> \<Longrightarrow> Q l (postQ (x1 ::= x2) s) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. \<lbrakk>vc (x1 ::= x2) Q; finite (support Q); finite (varacom (x1 ::= x2)); lesvars upds \<inter> varacom (x1 ::= x2) = {}; distinct (map fst upds); pre (x1 ::= x2) Q l s\<rbrakk> \<Longrightarrow> Q l (postQ (x1 ::= x2) s) [PROOF STEP] apply(simp only: postQ.simps pre.simps) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre (x1 ::= x2) Q l s \<and> preList upds (x1 ::= x2) l s} strip (x1 ::= x2) { time (x1 ::= x2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (x1 ::= x2) Q l s \<longrightarrow> Q l (postQ (x1 ::= x2) s)) goal (4 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 3. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 4. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] next [PROOF STATE] proof (state) goal (4 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 3. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 4. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] case (Aif b C1 C2 Q upds ) [PROOF STATE] proof (state) this: \<lbrakk>vc C1 ?Q; finite (support ?Q); finite (varacom C1); lesvars ?upds \<inter> varacom C1 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 ?Q l s \<and> preList ?upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C1 ?Q l s \<longrightarrow> ?Q l (postQ C1 s)) \<lbrakk>vc C2 ?Q; finite (support ?Q); finite (varacom C2); lesvars ?upds \<inter> varacom C2 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 ?Q l s \<and> preList ?upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C2 ?Q l s \<longrightarrow> ?Q l (postQ C2 s)) vc (IF b THEN C1 ELSE C2) Q finite (support Q) finite (varacom (IF b THEN C1 ELSE C2)) lesvars upds \<inter> varacom (IF b THEN C1 ELSE C2) = {} distinct (map fst upds) goal (4 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (IF x1 THEN C1 ELSE C2) Q; finite (support Q); finite (varacom (IF x1 THEN C1 ELSE C2)); lesvars upds \<inter> varacom (IF x1 THEN C1 ELSE C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<and> preList upds (IF x1 THEN C1 ELSE C2) l s} strip (IF x1 THEN C1 ELSE C2) { time (IF x1 THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF x1 THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF x1 THEN C1 ELSE C2) s)) 3. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 4. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<lbrakk>vc C1 ?Q; finite (support ?Q); finite (varacom C1); lesvars ?upds \<inter> varacom C1 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 ?Q l s \<and> preList ?upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C1 ?Q l s \<longrightarrow> ?Q l (postQ C1 s)) \<lbrakk>vc C2 ?Q; finite (support ?Q); finite (varacom C2); lesvars ?upds \<inter> varacom C2 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 ?Q l s \<and> preList ?upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C2 ?Q l s \<longrightarrow> ?Q l (postQ C2 s)) vc (IF b THEN C1 ELSE C2) Q finite (support Q) finite (varacom (IF b THEN C1 ELSE C2)) lesvars upds \<inter> varacom (IF b THEN C1 ELSE C2) = {} distinct (map fst upds) [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: \<lbrakk>vc C1 ?Q; finite (support ?Q); finite (varacom C1); lesvars ?upds \<inter> varacom C1 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 ?Q l s \<and> preList ?upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C1 ?Q l s \<longrightarrow> ?Q l (postQ C1 s)) \<lbrakk>vc C2 ?Q; finite (support ?Q); finite (varacom C2); lesvars ?upds \<inter> varacom C2 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 ?Q l s \<and> preList ?upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C2 ?Q l s \<longrightarrow> ?Q l (postQ C2 s)) vc (IF b THEN C1 ELSE C2) Q finite (support Q) finite (varacom (IF b THEN C1 ELSE C2)) lesvars upds \<inter> varacom (IF b THEN C1 ELSE C2) = {} distinct (map fst upds) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF b THEN C1 ELSE C2) Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s} strip (IF b THEN C1 ELSE C2) { time (IF b THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF b THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF b THEN C1 ELSE C2) s)) [PROOF STEP] apply(auto simp add: Assign) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. (bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)} IF b THEN strip C1 ELSE strip C2 { \<lambda>a. if bval b a then 1 + time C1 a else 1 + time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); bval b s; pre C1 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C1 s) 3. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); \<not> bval b s; pre C2 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C2 s) [PROOF STEP] apply(rule If2[where e="\<lambda>a. if bval b a then time C1 a else time C2 a"]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. ((bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)) \<and> bval b s} strip C1 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. ((bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)) \<and> \<not> bval b s} strip C2 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 3. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); (bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)\<rbrakk> \<Longrightarrow> (if bval b s then time C1 s else time C2 s) + 1 = (if bval b s then 1 + time C1 s else 1 + time C2 s) 4. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); bval b s; pre C1 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C1 s) 5. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); \<not> bval b s; pre C2 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C2 s) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. ((bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)) \<and> bval b s} strip C1 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(simp cong: rev_conj_cong) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s} strip C1 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule ub_cost[where e'="time C1"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<exists>k>0. \<forall>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s \<longrightarrow> time C1 s \<le> k * (if bval b s then time C1 s else time C2 s) 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<exists>k>0. \<forall>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s \<longrightarrow> 0 < time C1 s \<longrightarrow> Suc 0 \<le> k 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(auto)[1] [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule strengthen_pre[where P="%l s. pre C1 Q l s \<and> preList upds C1 l s"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<forall>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds C1 l s 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] using ListAif1 [PROOF STATE] proof (prove) using this: bval ?b ?s \<Longrightarrow> preList ?upds (IF ?b THEN ?C1.0 ELSE ?C2.0) ?l ?s = preList ?upds ?C1.0 ?l ?s goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<forall>l s. pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds C1 l s 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply fast [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule Aif(1)[THEN conjunct1]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> vc C1 Q 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> finite (support Q) 3. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> finite (varacom C1) 4. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> lesvars upds \<inter> varacom C1 = {} 5. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> distinct (map fst upds) [PROOF STEP] apply(auto) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. ((bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)) \<and> \<not> bval b s} strip C2 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); (bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)\<rbrakk> \<Longrightarrow> (if bval b s then time C1 s else time C2 s) + 1 = (if bval b s then 1 + time C1 s else 1 + time C2 s) 3. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); bval b s; pre C1 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C1 s) 4. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); \<not> bval b s; pre C2 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C2 s) [PROOF STEP] subgoal [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. ((bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)) \<and> \<not> bval b s} strip C2 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(simp cong: rev_conj_cong) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s} strip C2 { \<lambda>a. if bval b a then time C1 a else time C2 a \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule ub_cost[where e'="time C2"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<exists>k>0. \<forall>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s \<longrightarrow> time C2 s \<le> k * (if bval b s then time C1 s else time C2 s) 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] (* k=1 and *) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<exists>k>0. \<forall>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s \<longrightarrow> time C2 s \<le> k * (if bval b s then time C1 s else time C2 s) 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<exists>k>0. \<forall>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s \<longrightarrow> 0 < time C2 s \<longrightarrow> Suc 0 \<le> k 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(auto)[1] [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule strengthen_pre[where P="%l s. pre C2 Q l s \<and> preList upds C2 l s"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<forall>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds C2 l s 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] using ListAif2 [PROOF STATE] proof (prove) using this: \<not> bval ?b ?s \<Longrightarrow> preList ?upds (IF ?b THEN ?C1.0 ELSE ?C2.0) ?l ?s = preList ?upds ?C2.0 ?l ?s goal (2 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<forall>l s. pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s \<and> \<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds C2 l s 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply fast [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule Aif(2)[THEN conjunct1]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> vc C2 Q 2. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> finite (support Q) 3. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> finite (varacom C2) 4. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> lesvars upds \<inter> varacom C2 = {} 5. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2)\<rbrakk> \<Longrightarrow> distinct (map fst upds) [PROOF STEP] apply(auto) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); (bval b s \<longrightarrow> pre C1 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s) \<and> (\<not> bval b s \<longrightarrow> pre C2 Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s)\<rbrakk> \<Longrightarrow> (if bval b s then time C1 s else time C2 s) + 1 = (if bval b s then 1 + time C1 s else 1 + time C2 s) 2. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); bval b s; pre C1 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C1 s) 3. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); \<not> bval b s; pre C2 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C2 s) [PROOF STEP] apply auto [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); bval b s; pre C1 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C1 s) 2. \<And>l s. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); finite (support Q); lesvars upds \<inter> (varacom C1 \<union> varacom C2) = {}; distinct (map fst upds); vc C1 Q; vc C2 Q; finite (varacom C1); finite (varacom C2); \<not> bval b s; pre C2 Q l s\<rbrakk> \<Longrightarrow> Q l (postQ C2 s) [PROOF STEP] apply fast+ [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre (IF b THEN C1 ELSE C2) Q l s \<and> preList upds (IF b THEN C1 ELSE C2) l s} strip (IF b THEN C1 ELSE C2) { time (IF b THEN C1 ELSE C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (IF b THEN C1 ELSE C2) Q l s \<longrightarrow> Q l (postQ (IF b THEN C1 ELSE C2) s)) goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] next [PROOF STATE] proof (state) goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] case (Aconseq P' Qannot eannot C Q upds) [PROOF STATE] proof (state) this: \<lbrakk>vc C ?Q; finite (support ?Q); finite (varacom C); lesvars ?upds \<inter> varacom C = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C ?Q l s \<and> preList ?upds C l s} strip C { time C \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C ?Q l s \<longrightarrow> ?Q l (postQ C s)) vc ({P'/Qannot/eannot} CONSEQ C) Q finite (support Q) finite (varacom ({P'/Qannot/eannot} CONSEQ C)) lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} distinct (map fst upds) goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<lbrakk>vc C ?Q; finite (support ?Q); finite (varacom C); lesvars ?upds \<inter> varacom C = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C ?Q l s \<and> preList ?upds C l s} strip C { time C \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C ?Q l s \<longrightarrow> ?Q l (postQ C s)) vc ({P'/Qannot/eannot} CONSEQ C) Q finite (support Q) finite (varacom ({P'/Qannot/eannot} CONSEQ C)) lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} distinct (map fst upds) [PROOF STEP] obtain k where k: "k>0" and ih1: "vc C Qannot" and ih1': " (\<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)))" [PROOF STATE] proof (prove) using this: \<lbrakk>vc C ?Q; finite (support ?Q); finite (varacom C); lesvars ?upds \<inter> varacom C = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C ?Q l s \<and> preList ?upds C l s} strip C { time C \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C ?Q l s \<longrightarrow> ?Q l (postQ C s)) vc ({P'/Qannot/eannot} CONSEQ C) Q finite (support Q) finite (varacom ({P'/Qannot/eannot} CONSEQ C)) lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} distinct (map fst upds) goal (1 subgoal): 1. (\<And>k. \<lbrakk>0 < k; vc C Qannot; \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: 0 < k vc C Qannot \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)) goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have ih2': "\<forall>l s. pre C Qannot l s \<longrightarrow> Qannot l (postQ C s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. pre C Qannot l s \<longrightarrow> Qannot l (postQ C s) [PROOF STEP] apply(rule Aconseq(1)[THEN conjunct2]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C Qannot 2. finite (support Qannot) 3. finite (varacom C) 4. lesvars ?upds1 \<inter> varacom C = {} 5. distinct (map fst ?upds1) [PROOF STEP] using Aconseq(2-6) [PROOF STATE] proof (prove) using this: vc ({P'/Qannot/eannot} CONSEQ C) Q finite (support Q) finite (varacom ({P'/Qannot/eannot} CONSEQ C)) lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} distinct (map fst upds) goal (5 subgoals): 1. vc C Qannot 2. finite (support Qannot) 3. finite (varacom C) 4. lesvars ?upds1 \<inter> varacom C = {} 5. distinct (map fst ?upds1) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<forall>l s. pre C Qannot l s \<longrightarrow> Qannot l (postQ C s) goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have G1: "\<turnstile>\<^sub>1 {\<lambda>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip C { eannot \<Down> \<lambda>l s. Q l s \<and> postList upds l s}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip C { eannot \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] proof (rule conseq[rotated]) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<turnstile>\<^sub>1 {?P} strip C { ?e \<Down> ?Q} 2. \<exists>k>0. \<forall>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<longrightarrow> ?e s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. ?P l' s \<and> (?Q l' t \<longrightarrow> Q l t \<and> postList upds l t)) [PROOF STEP] show "\<turnstile>\<^sub>1 {\<lambda>l s. pre C Qannot l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Qannot l s \<and> postList upds l s}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre C Qannot l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Qannot l s \<and> postList upds l s} [PROOF STEP] apply(rule Aconseq(1)[THEN conjunct1]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C Qannot 2. finite (support Qannot) 3. finite (varacom C) 4. lesvars upds \<inter> varacom C = {} 5. distinct (map fst upds) [PROOF STEP] using Aconseq(2-6) [PROOF STATE] proof (prove) using this: vc ({P'/Qannot/eannot} CONSEQ C) Q finite (support Q) finite (varacom ({P'/Qannot/eannot} CONSEQ C)) lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} distinct (map fst upds) goal (5 subgoals): 1. vc C Qannot 2. finite (support Qannot) 3. finite (varacom C) 4. lesvars upds \<inter> varacom C = {} 5. distinct (map fst upds) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre C Qannot l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Qannot l s \<and> postList upds l s} goal (1 subgoal): 1. \<exists>k>0. \<forall>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t)) [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>k>0. \<forall>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t)) [PROOF STEP] show "\<exists>k>0. \<forall>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>k>0. \<forall>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t)) [PROOF STEP] proof(rule exI[where x=k], safe) [PROOF STATE] proof (state) goal (3 subgoals): 1. 0 < k 2. \<And>l s. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> time C s \<le> k * eannot s 3. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] fix l s [PROOF STATE] proof (state) goal (3 subgoals): 1. 0 < k 2. \<And>l s. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> time C s \<le> k * eannot s 3. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] assume P': "P' l s" and prelist: "preList upds ({P'/Qannot/eannot} CONSEQ C) l s" [PROOF STATE] proof (state) this: P' l s preList upds ({P'/Qannot/eannot} CONSEQ C) l s goal (3 subgoals): 1. 0 < k 2. \<And>l s. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> time C s \<le> k * eannot s 3. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: P' l s preList upds ({P'/Qannot/eannot} CONSEQ C) l s [PROOF STEP] show "time C s \<le> k * eannot s" [PROOF STATE] proof (prove) using this: P' l s preList upds ({P'/Qannot/eannot} CONSEQ C) l s goal (1 subgoal): 1. time C s \<le> k * eannot s [PROOF STEP] using ih1' [PROOF STATE] proof (prove) using this: P' l s preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)) goal (1 subgoal): 1. time C s \<le> k * eannot s [PROOF STEP] by simp [PROOF STATE] proof (state) this: time C s \<le> k * eannot s goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] fix t \<comment> \<open>we now have to construct a logical environment, that both * satisfies the annotated postcondition Qannot (we obtain it from the first IH) * lets the updates come true (we have to show that resetting these logical variables does not interfere with the other variables)\<close> [PROOF STATE] proof (state) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] from ih1' P' [PROOF STATE] proof (chain) picking this: \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)) P' l s [PROOF STEP] have satQan:"(\<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t))" [PROOF STATE] proof (prove) using this: \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)) P' l s goal (1 subgoal): 1. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t) [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t) [PROOF STEP] obtain l' where i': "pre C Qannot l' s" and ii': "(Qannot l' t \<longrightarrow> Q l t)" [PROOF STATE] proof (prove) using this: \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t) goal (1 subgoal): 1. (\<And>l'. \<lbrakk>pre C Qannot l' s; Qannot l' t \<longrightarrow> Q l t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: pre C Qannot l' s Qannot l' t \<longrightarrow> Q l t goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] let ?upds' = "(map (%(x,e). (x,preT C e s)) upds)" [PROOF STATE] proof (state) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] let ?l'' = "(ListUpdateE l' ?upds')" [PROOF STATE] proof (state) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] { [PROOF STATE] proof (state) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] fix l s n x [PROOF STATE] proof (state) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] assume "x \<in> fst ` (set upds)" [PROOF STATE] proof (state) this: x \<in> lesvars upds goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: x \<in> lesvars upds [PROOF STEP] have "x \<notin> support (pre C Qannot)" [PROOF STATE] proof (prove) using this: x \<in> lesvars upds goal (1 subgoal): 1. x \<notin> support (pre C Qannot) [PROOF STEP] using Aconseq(5) support_pre [PROOF STATE] proof (prove) using this: x \<in> lesvars upds lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} support (pre ?C ?Q) \<subseteq> support ?Q \<union> varacom ?C goal (1 subgoal): 1. x \<notin> support (pre C Qannot) [PROOF STEP] by auto [PROOF STATE] proof (state) this: x \<notin> support (pre C Qannot) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] from assn2_lupd[OF this] [PROOF STATE] proof (chain) picking this: pre C Qannot (?l(x := ?n)) = pre C Qannot ?l [PROOF STEP] have "pre C Qannot (l(x := n)) = pre C Qannot l" [PROOF STATE] proof (prove) using this: pre C Qannot (?l(x := ?n)) = pre C Qannot ?l goal (1 subgoal): 1. pre C Qannot (l(x := n)) = pre C Qannot l [PROOF STEP] . [PROOF STATE] proof (state) this: pre C Qannot (l(x := n)) = pre C Qannot l goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] } [PROOF STATE] proof (state) this: ?x2 \<in> lesvars upds \<Longrightarrow> pre C Qannot (?la2(?x2 := ?n2)) = pre C Qannot ?la2 goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] note U2=this [PROOF STATE] proof (state) this: ?x2 \<in> lesvars upds \<Longrightarrow> pre C Qannot (?la2(?x2 := ?n2)) = pre C Qannot ?la2 goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] { [PROOF STATE] proof (state) this: ?x2 \<in> lesvars upds \<Longrightarrow> pre C Qannot (?la2(?x2 := ?n2)) = pre C Qannot ?la2 goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] fix l s n x [PROOF STATE] proof (state) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] assume "x \<in> fst ` (set upds)" [PROOF STATE] proof (state) this: x \<in> lesvars upds goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: x \<in> lesvars upds [PROOF STEP] have "x \<notin> support Qannot" [PROOF STATE] proof (prove) using this: x \<in> lesvars upds goal (1 subgoal): 1. x \<notin> support Qannot [PROOF STEP] using Aconseq(5) [PROOF STATE] proof (prove) using this: x \<in> lesvars upds lesvars upds \<inter> varacom ({P'/Qannot/eannot} CONSEQ C) = {} goal (1 subgoal): 1. x \<notin> support Qannot [PROOF STEP] by auto [PROOF STATE] proof (state) this: x \<notin> support Qannot goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] from assn2_lupd[OF this] [PROOF STATE] proof (chain) picking this: Qannot (?l(x := ?n)) = Qannot ?l [PROOF STEP] have "Qannot (l(x := n)) = Qannot l" [PROOF STATE] proof (prove) using this: Qannot (?l(x := ?n)) = Qannot ?l goal (1 subgoal): 1. Qannot (l(x := n)) = Qannot l [PROOF STEP] . [PROOF STATE] proof (state) this: Qannot (l(x := n)) = Qannot l goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] } [PROOF STATE] proof (state) this: ?x2 \<in> lesvars upds \<Longrightarrow> Qannot (?la2(?x2 := ?n2)) = Qannot ?la2 goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] note K2=this [PROOF STATE] proof (state) this: ?x2 \<in> lesvars upds \<Longrightarrow> Qannot (?la2(?x2 := ?n2)) = Qannot ?la2 goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] have "pre C Qannot ?l'' = pre C Qannot l' " [PROOF STATE] proof (prove) goal (1 subgoal): 1. pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = pre C Qannot l' [PROOF STEP] apply(rule allg_E[where ?upds="set upds"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>l s n x. x \<in> lesvars upds \<Longrightarrow> pre C Qannot (l(x := n)) = pre C Qannot l 2. lesvars (map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C e s)) upds) \<subseteq> lesvars upds [PROOF STEP] apply(rule U2) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>l s n x. x \<in> lesvars upds \<Longrightarrow> x \<in> lesvars upds 2. lesvars (map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C e s)) upds) \<subseteq> lesvars upds [PROOF STEP] by force+ [PROOF STATE] proof (state) this: pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = pre C Qannot l' goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] with i' [PROOF STATE] proof (chain) picking this: pre C Qannot l' s pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = pre C Qannot l' [PROOF STEP] have i'': "pre C Qannot ?l'' s" [PROOF STATE] proof (prove) using this: pre C Qannot l' s pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = pre C Qannot l' goal (1 subgoal): 1. pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) s [PROOF STEP] by simp [PROOF STATE] proof (state) this: pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) s goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] have "Qannot ?l'' = Qannot l'" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = Qannot l' [PROOF STEP] apply(rule allg_E[where ?upds="set upds"]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>l s n x. x \<in> lesvars upds \<Longrightarrow> Qannot (l(x := n)) = Qannot l 2. lesvars (map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C e s)) upds) \<subseteq> lesvars upds [PROOF STEP] apply(rule K2) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>l s n x. x \<in> lesvars upds \<Longrightarrow> x \<in> lesvars upds 2. lesvars (map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C e s)) upds) \<subseteq> lesvars upds [PROOF STEP] by force+ [PROOF STATE] proof (state) this: Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = Qannot l' goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = Qannot l' [PROOF STEP] have K: "(%l' s. Qannot l' t \<longrightarrow> Q l t) ?l'' s = (%l' s. Qannot l' t \<longrightarrow> Q l t) l' s" [PROOF STATE] proof (prove) using this: Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) = Qannot l' goal (1 subgoal): 1. (Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t) = (Qannot l' t \<longrightarrow> Q l t) [PROOF STEP] by simp [PROOF STATE] proof (state) this: (Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t) = (Qannot l' t \<longrightarrow> Q l t) goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] with ii' [PROOF STATE] proof (chain) picking this: Qannot l' t \<longrightarrow> Q l t (Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t) = (Qannot l' t \<longrightarrow> Q l t) [PROOF STEP] have ii'': "(Qannot ?l'' t \<longrightarrow> Q l t)" [PROOF STATE] proof (prove) using this: Qannot l' t \<longrightarrow> Q l t (Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t) = (Qannot l' t \<longrightarrow> Q l t) goal (1 subgoal): 1. Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t [PROOF STEP] by simp [PROOF STATE] proof (state) this: Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] have xs_upds: "map fst ?upds' = map fst upds" [PROOF STATE] proof (prove) goal (1 subgoal): 1. map fst (map (\<lambda>(x, e). (x, preT C e s)) upds) = map fst upds [PROOF STEP] by auto [PROOF STATE] proof (state) this: map fst (map (\<lambda>(x, e). (x, preT C e s)) upds) = map fst upds goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] have resets: "\<And>x. x \<in> set ?upds' \<Longrightarrow> ListUpdateE l' ?upds' (fst x) = snd x" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) (fst x) = snd x [PROOF STEP] apply(rule ListUpdateE_updates) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> distinct (map fst (map (\<lambda>(x, e). (x, preT C e s)) upds)) 2. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) [PROOF STEP] apply(simp only: xs_upds) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> distinct (map fst upds) 2. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) [PROOF STEP] using Aconseq(6) [PROOF STATE] proof (prove) using this: distinct (map fst upds) goal (2 subgoals): 1. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> distinct (map fst upds) 2. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>x. x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: ?x \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) (fst ?x) = snd ?x goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] have A: "preList upds C ?l'' s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. preList upds C (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) s [PROOF STEP] proof (rule preListpreSet,safe,goal_cases) [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>a b. (a, b) \<in> set upds \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) a = preT C b s [PROOF STEP] case (1 x e) [PROOF STATE] proof (state) this: (x, e) \<in> set upds goal (1 subgoal): 1. \<And>a b. (a, b) \<in> set upds \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) a = preT C b s [PROOF STEP] then [PROOF STATE] proof (chain) picking this: (x, e) \<in> set upds [PROOF STEP] have "(x, preT C e s) \<in> set ?upds'" [PROOF STATE] proof (prove) using this: (x, e) \<in> set upds goal (1 subgoal): 1. (x, preT C e s) \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: (x, preT C e s) \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) goal (1 subgoal): 1. \<And>a b. (a, b) \<in> set upds \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) a = preT C b s [PROOF STEP] from resets[OF this, simplified] [PROOF STATE] proof (chain) picking this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = preT C e s [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = preT C e s goal (1 subgoal): 1. ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = preT C e s [PROOF STEP] . [PROOF STATE] proof (state) this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = preT C e s goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: preList upds C (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) s goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] have B: "Qannot ?l'' t \<Longrightarrow> postList upds ?l'' t \<Longrightarrow> postList upds l t" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> postList upds l t [PROOF STEP] proof (rule postListpostSet, safe, goal_cases) [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] case (1 x e) [PROOF STATE] proof (state) this: Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t (x, e) \<in> set upds goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] from postSetpostList[OF 1(2)] [PROOF STATE] proof (chain) picking this: postSet (set upds) (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t [PROOF STEP] have g: "postSet (set upds) ?l'' t" [PROOF STATE] proof (prove) using this: postSet (set upds) (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t goal (1 subgoal): 1. postSet (set upds) (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t [PROOF STEP] . [PROOF STATE] proof (state) this: postSet (set upds) (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] with 1(3) [PROOF STATE] proof (chain) picking this: (x, e) \<in> set upds postSet (set upds) (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t [PROOF STEP] have A: "?l'' x = e t" [PROOF STATE] proof (prove) using this: (x, e) \<in> set upds postSet (set upds) (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t goal (1 subgoal): 1. ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = e t [PROOF STEP] by fast [PROOF STATE] proof (state) this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = e t goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] from 1(3) resets[of "(x,preT C e s)"] [PROOF STATE] proof (chain) picking this: (x, e) \<in> set upds (x, preT C e s) \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) (fst (x, preT C e s)) = snd (x, preT C e s) [PROOF STEP] have B: "?l'' x = snd (x, preT C e s)" [PROOF STATE] proof (prove) using this: (x, e) \<in> set upds (x, preT C e s) \<in> set (map (\<lambda>(x, e). (x, preT C e s)) upds) \<Longrightarrow> ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) (fst (x, preT C e s)) = snd (x, preT C e s) goal (1 subgoal): 1. ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = snd (x, preT C e s) [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = snd (x, preT C e s) goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] from A B [PROOF STATE] proof (chain) picking this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = e t ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = snd (x, preT C e s) [PROOF STEP] have X: "e t = preT C e s" [PROOF STATE] proof (prove) using this: ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = e t ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds) x = snd (x, preT C e s) goal (1 subgoal): 1. e t = preT C e s [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: e t = preT C e s goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] from preSetpreList[OF prelist] [PROOF STATE] proof (chain) picking this: preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s [PROOF STEP] have "preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s" [PROOF STATE] proof (prove) using this: preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s goal (1 subgoal): 1. preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s [PROOF STEP] . [PROOF STATE] proof (state) this: preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] with 1(3) [PROOF STATE] proof (chain) picking this: (x, e) \<in> set upds preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s [PROOF STEP] have Y: "l x = preT C e s" [PROOF STATE] proof (prove) using this: (x, e) \<in> set upds preSet (set upds) ({P'/Qannot/eannot} CONSEQ C) l s goal (1 subgoal): 1. l x = preT C e s [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>(x, e) \<in> set upds; preSet (set upds) C l s\<rbrakk> \<Longrightarrow> l x = preT C e s [PROOF STEP] by fast [PROOF STATE] proof (state) this: l x = preT C e s goal (1 subgoal): 1. \<And>a b. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> l a = b t [PROOF STEP] from X Y [PROOF STATE] proof (chain) picking this: e t = preT C e s l x = preT C e s [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: e t = preT C e s l x = preT C e s goal (1 subgoal): 1. l x = e t [PROOF STEP] by simp [PROOF STATE] proof (state) this: l x = e t goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> postList upds l t goal (2 subgoals): 1. 0 < k 2. \<And>l s t. \<lbrakk>P' l s; preList upds ({P'/Qannot/eannot} CONSEQ C) l s\<rbrakk> \<Longrightarrow> \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] show "\<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) [PROOF STEP] apply(rule exI[where x="?l''"], safe) [PROOF STATE] proof (prove) goal (4 subgoals): 1. pre C Qannot (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) s 2. preList upds C (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) s 3. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> Q l t 4. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> postList upds l t [PROOF STEP] using i'' A ii'' B [PROOF STATE] proof (prove) using this: pre C Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) s preList upds C (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) s Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t \<longrightarrow> Q l t \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(x, e). (x, preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> postList upds l t goal (4 subgoals): 1. pre C Qannot (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) s 2. preList upds C (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) s 3. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> Q l t 4. \<lbrakk>Qannot (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t; postList upds (ListUpdateE l' (map (\<lambda>(l', e). (l', preT C e s)) upds)) t\<rbrakk> \<Longrightarrow> postList upds l t [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t) goal (1 subgoal): 1. 0 < k [PROOF STEP] qed fact [PROOF STATE] proof (state) this: \<exists>k>0. \<forall>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. (pre C Qannot l' s \<and> preList upds C l' s) \<and> (Qannot l' t \<and> postList upds l' t \<longrightarrow> Q l t \<and> postList upds l t)) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip C { eannot \<Down> \<lambda>l s. Q l s \<and> postList upds l s} goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have G2: "\<And>l s. P' l s \<Longrightarrow> Q l (postQ C s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. P' l s \<Longrightarrow> Q l (postQ C s) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. P' l s \<Longrightarrow> Q l (postQ C s) [PROOF STEP] fix l s [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. P' l s \<Longrightarrow> Q l (postQ C s) [PROOF STEP] assume "P' l s" [PROOF STATE] proof (state) this: P' l s goal (1 subgoal): 1. \<And>l s. P' l s \<Longrightarrow> Q l (postQ C s) [PROOF STEP] with ih1' ih2' [PROOF STATE] proof (chain) picking this: \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)) \<forall>l s. pre C Qannot l s \<longrightarrow> Qannot l (postQ C s) P' l s [PROOF STEP] show "Q l (postQ C s)" [PROOF STATE] proof (prove) using this: \<forall>l s. P' l s \<longrightarrow> time C s \<le> k * eannot s \<and> (\<forall>t. \<exists>l'. pre C Qannot l' s \<and> (Qannot l' t \<longrightarrow> Q l t)) \<forall>l s. pre C Qannot l s \<longrightarrow> Qannot l (postQ C s) P' l s goal (1 subgoal): 1. Q l (postQ C s) [PROOF STEP] by blast [PROOF STATE] proof (state) this: Q l (postQ C s) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: P' ?l ?s \<Longrightarrow> Q ?l (postQ C ?s) goal (3 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 x3 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1/x2/x3} CONSEQ C) Q; finite (support Q); finite (varacom ({x1/x2/x3} CONSEQ C)); lesvars upds \<inter> varacom ({x1/x2/x3} CONSEQ C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<and> preList upds ({x1/x2/x3} CONSEQ C) l s} strip ({x1/x2/x3} CONSEQ C) { time ({x1/x2/x3} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1/x2/x3} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({x1/x2/x3} CONSEQ C) s)) 3. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre ({P'/Qannot/eannot} CONSEQ C) Q l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip ({P'/Qannot/eannot} CONSEQ C) { time ({P'/Qannot/eannot} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({P'/Qannot/eannot} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({P'/Qannot/eannot} CONSEQ C) s)) [PROOF STEP] using G1 G2 [PROOF STATE] proof (prove) using this: \<turnstile>\<^sub>1 {\<lambda>l s. P' l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip C { eannot \<Down> \<lambda>l s. Q l s \<and> postList upds l s} P' ?l ?s \<Longrightarrow> Q ?l (postQ C ?s) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre ({P'/Qannot/eannot} CONSEQ C) Q l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip ({P'/Qannot/eannot} CONSEQ C) { time ({P'/Qannot/eannot} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({P'/Qannot/eannot} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({P'/Qannot/eannot} CONSEQ C) s)) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre ({P'/Qannot/eannot} CONSEQ C) Q l s \<and> preList upds ({P'/Qannot/eannot} CONSEQ C) l s} strip ({P'/Qannot/eannot} CONSEQ C) { time ({P'/Qannot/eannot} CONSEQ C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({P'/Qannot/eannot} CONSEQ C) Q l s \<longrightarrow> Q l (postQ ({P'/Qannot/eannot} CONSEQ C) s)) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] next [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] case (Aseq C1 C2 Q upds) [PROOF STATE] proof (state) this: \<lbrakk>vc C1 ?Q; finite (support ?Q); finite (varacom C1); lesvars ?upds \<inter> varacom C1 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 ?Q l s \<and> preList ?upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C1 ?Q l s \<longrightarrow> ?Q l (postQ C1 s)) \<lbrakk>vc C2 ?Q; finite (support ?Q); finite (varacom C2); lesvars ?upds \<inter> varacom C2 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 ?Q l s \<and> preList ?upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C2 ?Q l s \<longrightarrow> ?Q l (postQ C2 s)) vc (C1;; C2) Q finite (support Q) finite (varacom (C1;; C2)) lesvars upds \<inter> varacom (C1;; C2) = {} distinct (map fst upds) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?P = "(\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;;C2) l s )" [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?P' = "support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds" [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have finite_varacom: "finite (varacom (C1;; C2))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. finite (varacom (C1;; C2)) [PROOF STEP] by fact [PROOF STATE] proof (state) this: finite (varacom (C1;; C2)) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have sup_L: "support (preList upds (C1;;C2)) \<subseteq> lesvars upds" [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (preList upds (C1;; C2)) \<subseteq> lesvars upds [PROOF STEP] apply(rule support_preList) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done \<comment> \<open>choose a fresh logical variable ?y in order to pull through the cost of the second command\<close> [PROOF STATE] proof (state) this: support (preList upds (C1;; C2)) \<subseteq> lesvars upds goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?y = "SOME x. x \<notin> ?P'" [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have fP': "finite (?P')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) [PROOF STEP] using finite_varacom Aseq(4,5) [PROOF STATE] proof (prove) using this: finite (varacom (C1;; C2)) finite (support Q) finite (varacom (C1;; C2)) goal (1 subgoal): 1. finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] from fP' [PROOF STATE] proof (chain) picking this: finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) [PROOF STEP] have "\<exists>x. x \<notin> ?P'" [PROOF STATE] proof (prove) using this: finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) goal (1 subgoal): 1. \<exists>x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] using infinite_UNIV_listI [PROOF STATE] proof (prove) using this: finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) infinite UNIV goal (1 subgoal): 1. \<exists>x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] using ex_new_if_finite [PROOF STATE] proof (prove) using this: finite (support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) infinite UNIV \<lbrakk>infinite UNIV; finite ?A\<rbrakk> \<Longrightarrow> \<exists>a. a \<notin> ?A goal (1 subgoal): 1. \<exists>x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] by metis [PROOF STATE] proof (state) this: \<exists>x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] hence ynP': "?y \<notin> ?P'" [PROOF STATE] proof (prove) using this: \<exists>x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (1 subgoal): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] by (rule someI_ex) [PROOF STATE] proof (state) this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] hence ysupC1: "?y \<notin> varacom C1" [PROOF STATE] proof (prove) using this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (1 subgoal): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> varacom C1 [PROOF STEP] using support_pre [PROOF STATE] proof (prove) using this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds support (pre ?C ?Q) \<subseteq> support ?Q \<union> varacom ?C goal (1 subgoal): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> varacom C1 [PROOF STEP] by auto [PROOF STATE] proof (state) this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> varacom C1 goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have sup_B: "support ?P \<subseteq> ?P'" [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] apply(rule subset_trans[OF support_and]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (pre (C1;; C2) Q) \<union> support (preList upds (C1;; C2)) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (pre C1 (pre C2 Q)) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds \<and> support (preList upds (C1;; C2)) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] using support_pre sup_L [PROOF STATE] proof (prove) using this: support (pre ?C ?Q) \<subseteq> support ?Q \<union> varacom ?C support (preList upds (C1;; C2)) \<subseteq> lesvars upds goal (1 subgoal): 1. support (pre C1 (pre C2 Q)) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds \<and> support (preList upds (C1;; C2)) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] by blast \<comment> \<open>we show the first goal: we can deduce the desired Hoare Triple\<close> [PROOF STATE] proof (state) this: support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have C1: "\<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip C1;; strip C2 { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip C1;; strip C2 { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] proof (rule Seq[rotated]) \<comment> \<open>start from the back: we can simply use the IH for C2, and solve the side conditions automatically\<close> [PROOF STATE] proof (state) goal (5 subgoals): 1. \<turnstile>\<^sub>1 {?P\<^sub>2} strip C2 { ?e2.0 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} 2. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 3. ?x \<notin> support ?P\<^sub>2 4. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 5. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. ?P\<^sub>2 l s \<and> ?e2.0 s \<le> l ?x} [PROOF STEP] show "\<turnstile>\<^sub>1 {(%l s. pre C2 Q l s \<and> preList upds C2 l s )} strip C2 { time C2 \<Down> (%l s. Q l s \<and> postList upds l s)}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] apply(rule Aseq(2)[THEN conjunct1]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C2 Q 2. finite (support Q) 3. finite (varacom C2) 4. lesvars upds \<inter> varacom C2 = {} 5. distinct (map fst upds) [PROOF STEP] using Aseq(3-7) [PROOF STATE] proof (prove) using this: vc (C1;; C2) Q finite (support Q) finite (varacom (C1;; C2)) lesvars upds \<inter> varacom (C1;; C2) = {} distinct (map fst upds) goal (5 subgoals): 1. vc C2 Q 2. finite (support Q) 3. finite (varacom C2) 4. lesvars upds \<inter> varacom C2 = {} 5. distinct (map fst upds) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} goal (4 subgoals): 1. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. ?x \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 4. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l ?x} [PROOF STEP] next \<comment> \<open>prepare the new updates: pull them through C2 and save the new execution time of C2 in ?y\<close> [PROOF STATE] proof (state) goal (4 subgoals): 1. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. ?x \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 4. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l ?x} [PROOF STEP] let ?upds = "map (\<lambda>a. case a of (x,e) \<Rightarrow> (x, preT C2 e )) upds" [PROOF STATE] proof (state) goal (4 subgoals): 1. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. ?x \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 4. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l ?x} [PROOF STEP] let ?upds' = "(?y,time C2)#?upds" [PROOF STATE] proof (state) goal (4 subgoals): 1. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. ?x \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 4. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l ?x} [PROOF STEP] have dst_upds': "distinct (map fst ?upds')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. distinct (map fst ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds)) [PROOF STEP] using ynP' Aseq(7) [PROOF STATE] proof (prove) using this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds distinct (map fst upds) goal (1 subgoal): 1. distinct (map fst ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds)) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>(SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> support Q \<and> (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C1 \<and> (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C2 \<and> (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> lesvars upds; distinct (map fst upds)\<rbrakk> \<Longrightarrow> (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> (\<lambda>x. fst (case x of (x, e) \<Rightarrow> (x, preT C2 e))) ` set upds \<and> distinct (map (fst \<circ> (\<lambda>(x, e). (x, preT C2 e))) upds) [PROOF STEP] apply safe [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>a b. \<lbrakk>distinct (map fst upds); (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> support Q; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C1; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C2; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> lesvars upds; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) = fst (a, preT C2 b); (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>distinct (map fst upds); (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> support Q; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C1; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C2; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> lesvars upds\<rbrakk> \<Longrightarrow> distinct (map (fst \<circ> (\<lambda>(x, e). (x, preT C2 e))) upds) [PROOF STEP] using image_iff [PROOF STATE] proof (prove) using this: (?z \<in> ?f ` ?A) = (\<exists>x\<in>?A. ?z = ?f x) goal (2 subgoals): 1. \<And>a b. \<lbrakk>distinct (map fst upds); (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> support Q; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C1; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C2; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> lesvars upds; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) = fst (a, preT C2 b); (a, b) \<in> set upds\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>distinct (map fst upds); (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> support Q; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C1; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C2; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> lesvars upds\<rbrakk> \<Longrightarrow> distinct (map (fst \<circ> (\<lambda>(x, e). (x, preT C2 e))) upds) [PROOF STEP] apply fastforce [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>distinct (map fst upds); (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> support Q; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C1; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> varacom C2; (SOME x. x \<notin> support Q \<and> x \<notin> varacom C1 \<and> x \<notin> varacom C2 \<and> x \<notin> lesvars upds) \<notin> lesvars upds\<rbrakk> \<Longrightarrow> distinct (map (fst \<circ> (\<lambda>(x, e). (x, preT C2 e))) upds) [PROOF STEP] by (simp add: case_prod_beta' distinct_conv_nth) \<comment> \<open>now use the first induction hypothesis (specialised with the augmented upds list, and the weakest precondition of Q through C as post condition)\<close> [PROOF STATE] proof (state) this: distinct (map fst ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds)) goal (4 subgoals): 1. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. ?x \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 4. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l ?x} [PROOF STEP] have IH1s: "\<turnstile>\<^sub>1 {\<lambda>l s. pre C1 (pre C2 Q) l s \<and> preList ?upds' C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. pre C2 Q l s \<and> postList ?upds' l s}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 (pre C2 Q) l s \<and> preList ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. pre C2 Q l s \<and> postList ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) l s} [PROOF STEP] apply(rule Aseq(1)[THEN conjunct1]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C1 (pre C2 Q) 2. finite (support (pre C2 Q)) 3. finite (varacom C1) 4. lesvars ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) \<inter> varacom C1 = {} 5. distinct (map fst ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds)) [PROOF STEP] using Aseq(3-7) ysupC1 dst_upds' [PROOF STATE] proof (prove) using this: vc (C1;; C2) Q finite (support Q) finite (varacom (C1;; C2)) lesvars upds \<inter> varacom (C1;; C2) = {} distinct (map fst upds) (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> varacom C1 distinct (map fst ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds)) goal (5 subgoals): 1. vc C1 (pre C2 Q) 2. finite (support (pre C2 Q)) 3. finite (varacom C1) 4. lesvars ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) \<inter> varacom C1 = {} 5. distinct (map fst ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds)) [PROOF STEP] by auto \<comment> \<open>glue it together with a consequence rule, side conditions are automatic\<close> [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 (pre C2 Q) l s \<and> preList ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. pre C2 Q l s \<and> postList ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) l s} goal (4 subgoals): 1. ?x \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. ?x \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> ?e1.0 s + ?e2' s \<le> time (C1;; C2) s 4. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?x = ?e2' s} strip C1 { ?e1.0 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l ?x} [PROOF STEP] show " \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l ?y = preT C1 (time C2) s} strip C1 { time C1 \<Down> \<lambda>l s. (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) l s \<and> time C2 s \<le> l ?y}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) = preT C1 (time C2) s} strip C1 { time C1 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds)} [PROOF STEP] apply(rule conseq_old[OF _ IH1s]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<exists>k>0. \<forall>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) = preT C1 (time C2) s \<longrightarrow> (pre C1 (pre C2 Q) l s \<and> preList ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) C1 l s) \<and> time C1 s \<le> k * time C1 s 2. \<forall>l s. pre C2 Q l s \<and> postList ((SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds, time C2) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, preT C2 e)) upds) l s \<longrightarrow> (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) [PROOF STEP] by (auto simp: preList_Seq postList_preList) [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. (pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<and> l (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) = preT C1 (time C2) s} strip C1 { time C1 \<Down> \<lambda>l s. (pre C2 Q l s \<and> preList upds C2 l s) \<and> time C2 s \<le> l (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds)} goal (3 subgoals): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> time C1 s + preT C1 (time C2) s \<le> time (C1;; C2) s [PROOF STEP] next \<comment> \<open>solve some side conditions showing that, ?y is indeed fresh\<close> [PROOF STATE] proof (state) goal (3 subgoals): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) 2. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 3. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> time C1 s + preT C1 (time C2) s \<le> time (C1;; C2) s [PROOF STEP] show "?y \<notin> support ?P" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) [PROOF STEP] using sup_B ynP' [PROOF STATE] proof (prove) using this: support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (1 subgoal): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) [PROOF STEP] by auto [PROOF STATE] proof (state) this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s) goal (2 subgoals): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 2. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> time C1 s + preT C1 (time C2) s \<le> time (C1;; C2) s [PROOF STEP] have F: "support (preList upds C2) \<subseteq> lesvars upds" [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (preList upds C2) \<subseteq> lesvars upds [PROOF STEP] apply(rule support_preList) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: support (preList upds C2) \<subseteq> lesvars upds goal (2 subgoals): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 2. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> time C1 s + preT C1 (time C2) s \<le> time (C1;; C2) s [PROOF STEP] have "support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) \<subseteq> ?P'" [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] apply(rule subset_trans[OF support_and]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (pre C2 Q) \<union> support (preList upds C2) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] using F support_pre [PROOF STATE] proof (prove) using this: support (preList upds C2) \<subseteq> lesvars upds support (pre ?C ?Q) \<subseteq> support ?Q \<union> varacom ?C goal (1 subgoal): 1. support (pre C2 Q) \<union> support (preList upds C2) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] by blast [PROOF STATE] proof (state) this: support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (2 subgoals): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) 2. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> time C1 s + preT C1 (time C2) s \<le> time (C1;; C2) s [PROOF STEP] with ynP' [PROOF STATE] proof (chain) picking this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds [PROOF STEP] show "?y \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s)" [PROOF STATE] proof (prove) using this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) \<subseteq> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds goal (1 subgoal): 1. (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) [PROOF STEP] by blast [PROOF STATE] proof (state) this: (SOME x. x \<notin> support Q \<union> varacom C1 \<union> varacom C2 \<union> lesvars upds) \<notin> support (\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s) goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s \<Longrightarrow> time C1 s + preT C1 (time C2) s \<le> time (C1;; C2) s [PROOF STEP] qed simp \<comment> \<open>we show the second goal: weakest precondition implies, that Q holds after the execution of C1 and C2\<close> [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip C1;; strip C2 { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have C2: "\<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s) [PROOF STEP] fix l s [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s) [PROOF STEP] assume p: "pre (C1;; C2) Q l s" [PROOF STATE] proof (state) this: pre (C1;; C2) Q l s goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s) [PROOF STEP] have A: "\<forall>l s. pre C1 (pre C2 Q ) l s \<longrightarrow> pre C2 Q l (postQ C1 s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. pre C1 (pre C2 Q) l s \<longrightarrow> pre C2 Q l (postQ C1 s) [PROOF STEP] apply(rule Aseq(1)[where upds="[]", THEN conjunct2]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C1 (pre C2 Q) 2. finite (support (pre C2 Q)) 3. finite (varacom C1) 4. lesvars [] \<inter> varacom C1 = {} 5. distinct (map fst []) [PROOF STEP] using Aseq [PROOF STATE] proof (prove) using this: \<lbrakk>vc C1 ?Q; finite (support ?Q); finite (varacom C1); lesvars ?upds \<inter> varacom C1 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 ?Q l s \<and> preList ?upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C1 ?Q l s \<longrightarrow> ?Q l (postQ C1 s)) \<lbrakk>vc C2 ?Q; finite (support ?Q); finite (varacom C2); lesvars ?upds \<inter> varacom C2 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 ?Q l s \<and> preList ?upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C2 ?Q l s \<longrightarrow> ?Q l (postQ C2 s)) vc (C1;; C2) Q finite (support Q) finite (varacom (C1;; C2)) lesvars upds \<inter> varacom (C1;; C2) = {} distinct (map fst upds) goal (5 subgoals): 1. vc C1 (pre C2 Q) 2. finite (support (pre C2 Q)) 3. finite (varacom C1) 4. lesvars [] \<inter> varacom C1 = {} 5. distinct (map fst []) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<forall>l s. pre C1 (pre C2 Q) l s \<longrightarrow> pre C2 Q l (postQ C1 s) goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s) [PROOF STEP] have B: "(\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s) [PROOF STEP] apply(rule Aseq(2)[where upds="[]", THEN conjunct2]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C2 Q 2. finite (support Q) 3. finite (varacom C2) 4. lesvars [] \<inter> varacom C2 = {} 5. distinct (map fst []) [PROOF STEP] using Aseq [PROOF STATE] proof (prove) using this: \<lbrakk>vc C1 ?Q; finite (support ?Q); finite (varacom C1); lesvars ?upds \<inter> varacom C1 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 ?Q l s \<and> preList ?upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C1 ?Q l s \<longrightarrow> ?Q l (postQ C1 s)) \<lbrakk>vc C2 ?Q; finite (support ?Q); finite (varacom C2); lesvars ?upds \<inter> varacom C2 = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 ?Q l s \<and> preList ?upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C2 ?Q l s \<longrightarrow> ?Q l (postQ C2 s)) vc (C1;; C2) Q finite (support Q) finite (varacom (C1;; C2)) lesvars upds \<inter> varacom (C1;; C2) = {} distinct (map fst upds) goal (5 subgoals): 1. vc C2 Q 2. finite (support Q) 3. finite (varacom C2) 4. lesvars [] \<inter> varacom C2 = {} 5. distinct (map fst []) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s) goal (1 subgoal): 1. \<And>l s. pre (C1;; C2) Q l s \<Longrightarrow> Q l (postQ (C1;; C2) s) [PROOF STEP] from p A B [PROOF STATE] proof (chain) picking this: pre (C1;; C2) Q l s \<forall>l s. pre C1 (pre C2 Q) l s \<longrightarrow> pre C2 Q l (postQ C1 s) \<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s) [PROOF STEP] show "Q l (postQ (C1;; C2) s)" [PROOF STATE] proof (prove) using this: pre (C1;; C2) Q l s \<forall>l s. pre C1 (pre C2 Q) l s \<longrightarrow> pre C2 Q l (postQ C1 s) \<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s) goal (1 subgoal): 1. Q l (postQ (C1;; C2) s) [PROOF STEP] by simp [PROOF STATE] proof (state) this: Q l (postQ (C1;; C2) s) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: pre (C1;; C2) Q ?l ?s \<Longrightarrow> Q ?l (postQ (C1;; C2) ?s) goal (2 subgoals): 1. \<And>C1 C2 Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C1 Q; finite (support Q); finite (varacom C1); lesvars upds \<inter> varacom C1 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C1 Q l s \<and> preList upds C1 l s} strip C1 { time C1 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C1 Q l s \<longrightarrow> Q l (postQ C1 s)); \<And>Q upds. \<lbrakk>vc C2 Q; finite (support Q); finite (varacom C2); lesvars upds \<inter> varacom C2 = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C2 Q l s \<and> preList upds C2 l s} strip C2 { time C2 \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C2 Q l s \<longrightarrow> Q l (postQ C2 s)); vc (C1;; C2) Q; finite (support Q); finite (varacom (C1;; C2)); lesvars upds \<inter> varacom (C1;; C2) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) 2. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) [PROOF STEP] using C1 C2 [PROOF STATE] proof (prove) using this: \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip C1;; strip C2 { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} pre (C1;; C2) Q ?l ?s \<Longrightarrow> Q ?l (postQ (C1;; C2) ?s) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre (C1;; C2) Q l s \<and> preList upds (C1;; C2) l s} strip (C1;; C2) { time (C1;; C2) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre (C1;; C2) Q l s \<longrightarrow> Q l (postQ (C1;; C2) s)) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] case (Awhile A b C Q upds) \<comment> \<open>Let us first see, what we got from the induction hypothesis:\<close> [PROOF STATE] proof (state) this: \<lbrakk>vc C ?Q; finite (support ?Q); finite (varacom C); lesvars ?upds \<inter> varacom C = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C ?Q l s \<and> preList ?upds C l s} strip C { time C \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C ?Q l s \<longrightarrow> ?Q l (postQ C s)) vc ({A} WHILE b DO C) Q finite (support Q) finite (varacom ({A} WHILE b DO C)) lesvars upds \<inter> varacom ({A} WHILE b DO C) = {} distinct (map fst upds) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] obtain I S E where [simp]: "A = (I,(S,(E)))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>I S E. A = (I, S, E) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using prod_cases3 [PROOF STATE] proof (prove) using this: (\<And>a b c. ?y = (a, b, c) \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis goal (1 subgoal): 1. (\<And>I S E. A = (I, S, E) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: A = (I, S, E) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] with \<open>vc (Awhile A b C) Q\<close> [PROOF STATE] proof (chain) picking this: vc ({A} WHILE b DO C) Q A = (I, S, E) [PROOF STEP] have "vc (Awhile (I,S,E) b C) Q" [PROOF STATE] proof (prove) using this: vc ({A} WHILE b DO C) Q A = (I, S, E) goal (1 subgoal): 1. vc ({(I, S, E)} WHILE b DO C) Q [PROOF STEP] by blast [PROOF STATE] proof (state) this: vc ({(I, S, E)} WHILE b DO C) Q goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: vc ({(I, S, E)} WHILE b DO C) Q [PROOF STEP] have vc: "vc C I" and pre2: "\<And>l s. I l s \<Longrightarrow> \<not> bval b s \<Longrightarrow> Q l s \<and> 1 \<le> E s \<and> S s = s" and IQ2: "\<And>l s. I l s \<Longrightarrow> bval b s \<Longrightarrow> pre C I l s \<and> 1 + preT C E s + time C s \<le> E s \<and> S s = S (postQ C s)" [PROOF STATE] proof (prove) using this: vc ({(I, S, E)} WHILE b DO C) Q goal (1 subgoal): 1. vc C I &&& (\<And>l s. \<lbrakk>I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l s \<and> 1 \<le> E s \<and> S s = s) &&& (\<And>l s. \<lbrakk>I l s; bval b s\<rbrakk> \<Longrightarrow> pre C I l s \<and> 1 + preT C E s + time C s \<le> E s \<and> S s = S (postQ C s)) [PROOF STEP] by auto \<comment> \<open>the logical variable x represents the number of loop unfoldings\<close> [PROOF STATE] proof (state) this: vc C I \<lbrakk>I ?l ?s; \<not> bval b ?s\<rbrakk> \<Longrightarrow> Q ?l ?s \<and> 1 \<le> E ?s \<and> S ?s = ?s \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] from IQ2 [PROOF STATE] proof (chain) picking this: \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) [PROOF STEP] have IQ_in: "\<And>l s. I l s \<Longrightarrow> bval b s \<Longrightarrow> S s = S (postQ C s)" [PROOF STATE] proof (prove) using this: \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; bval b s\<rbrakk> \<Longrightarrow> S s = S (postQ C s) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> S ?s = S (postQ C ?s) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have inv_impl: "\<And>l s. I l s \<Longrightarrow> bval b s \<Longrightarrow> pre C I l s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; bval b s\<rbrakk> \<Longrightarrow> pre C I l s [PROOF STEP] using IQ2 [PROOF STATE] proof (prove) using this: \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; bval b s\<rbrakk> \<Longrightarrow> pre C I l s [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have yC: " lesvars upds \<inter> varacom C = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lesvars upds \<inter> varacom C = {} [PROOF STEP] using Awhile(5) [PROOF STATE] proof (prove) using this: lesvars upds \<inter> varacom ({A} WHILE b DO C) = {} goal (1 subgoal): 1. lesvars upds \<inter> varacom C = {} [PROOF STEP] by auto [PROOF STATE] proof (state) this: lesvars upds \<inter> varacom C = {} goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?upds = "map (%(x,e). (x, %s. e (S s))) upds" [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?INV = "%l s. I l s \<and> postList ?upds l s" [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have "lesvars upds \<inter> support I = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lesvars upds \<inter> support I = {} [PROOF STEP] using Awhile(5) [PROOF STATE] proof (prove) using this: lesvars upds \<inter> varacom ({A} WHILE b DO C) = {} goal (1 subgoal): 1. lesvars upds \<inter> support I = {} [PROOF STEP] by auto \<comment> \<open>we need a fresh variable ?z to remember the time bound of the tail of the loop\<close> [PROOF STATE] proof (state) this: lesvars upds \<inter> support I = {} goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?P="lesvars upds \<union> varacom ({A} WHILE b DO C)" [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?z="SOME z::lvname. z \<notin> ?P" [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have "finite ?P" [PROOF STATE] proof (prove) goal (1 subgoal): 1. finite (lesvars upds \<union> varacom ({A} WHILE b DO C)) [PROOF STEP] using Awhile [PROOF STATE] proof (prove) using this: \<lbrakk>vc C ?Q; finite (support ?Q); finite (varacom C); lesvars ?upds \<inter> varacom C = {}; distinct (map fst ?upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C ?Q l s \<and> preList ?upds C l s} strip C { time C \<Down> \<lambda>l s. ?Q l s \<and> postList ?upds l s} \<and> (\<forall>l s. pre C ?Q l s \<longrightarrow> ?Q l (postQ C s)) vc ({A} WHILE b DO C) Q finite (support Q) finite (varacom ({A} WHILE b DO C)) lesvars upds \<inter> varacom ({A} WHILE b DO C) = {} distinct (map fst upds) goal (1 subgoal): 1. finite (lesvars upds \<union> varacom ({A} WHILE b DO C)) [PROOF STEP] by auto [PROOF STATE] proof (state) this: finite (lesvars upds \<union> varacom ({A} WHILE b DO C)) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] hence "\<exists>z. z\<notin>?P" [PROOF STATE] proof (prove) using this: finite (lesvars upds \<union> varacom ({A} WHILE b DO C)) goal (1 subgoal): 1. \<exists>z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) [PROOF STEP] using infinite_UNIV_listI [PROOF STATE] proof (prove) using this: finite (lesvars upds \<union> varacom ({A} WHILE b DO C)) infinite UNIV goal (1 subgoal): 1. \<exists>z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) [PROOF STEP] using ex_new_if_finite [PROOF STATE] proof (prove) using this: finite (lesvars upds \<union> varacom ({A} WHILE b DO C)) infinite UNIV \<lbrakk>infinite UNIV; finite ?A\<rbrakk> \<Longrightarrow> \<exists>a. a \<notin> ?A goal (1 subgoal): 1. \<exists>z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) [PROOF STEP] by metis [PROOF STATE] proof (state) this: \<exists>z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] hence znP: "?z \<notin> ?P" [PROOF STATE] proof (prove) using this: \<exists>z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) [PROOF STEP] by (rule someI_ex) [PROOF STATE] proof (state) this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] from znP [PROOF STATE] proof (chain) picking this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) [PROOF STEP] have (* znx: "?z\<noteq>x" and *) zny: "?z \<notin> lesvars upds" and zI: "?z \<notin> support I" and blb: "?z \<notin> varacom C" [PROOF STATE] proof (prove) using this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds &&& (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support I &&& (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> varacom C [PROOF STEP] by (simp_all) [PROOF STATE] proof (state) this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support I (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> varacom C goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] from Awhile(4,6) [PROOF STATE] proof (chain) picking this: finite (varacom ({A} WHILE b DO C)) distinct (map fst upds) [PROOF STEP] have 23: "finite (varacom C)" and 26: "finite (support I)" [PROOF STATE] proof (prove) using this: finite (varacom ({A} WHILE b DO C)) distinct (map fst upds) goal (1 subgoal): 1. finite (varacom C) &&& finite (support I) [PROOF STEP] by auto [PROOF STATE] proof (state) this: finite (varacom C) finite (support I) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have "\<forall>l s. pre C I l s \<longrightarrow> I l (postQ C s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. pre C I l s \<longrightarrow> I l (postQ C s) [PROOF STEP] apply(rule Awhile(1)[THEN conjunct2]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C I 2. finite (support I) 3. finite (varacom C) 4. lesvars ?upds1 \<inter> varacom C = {} 5. distinct (map fst ?upds1) [PROOF STEP] by(fact)+ [PROOF STATE] proof (state) this: \<forall>l s. pre C I l s \<longrightarrow> I l (postQ C s) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] hence step: "\<And>l s. pre C I l s \<Longrightarrow> I l (postQ C s)" [PROOF STATE] proof (prove) using this: \<forall>l s. pre C I l s \<longrightarrow> I l (postQ C s) goal (1 subgoal): 1. \<And>l s. pre C I l s \<Longrightarrow> I l (postQ C s) [PROOF STEP] by simp \<comment> \<open>we adapt the updates, by pulling them through the loop body and remembering the time bound of the tail of the loop\<close> [PROOF STATE] proof (state) this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?upds = "map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds" [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have fua: "lesvars ?upds = lesvars upds" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) = lesvars upds [PROOF STEP] by force [PROOF STATE] proof (state) this: lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) = lesvars upds goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] let ?upds' = "(?z,E) # ?upds" [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have g: "\<And>e. e \<circ> S = (%s. e (S s))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>e. e \<circ> S = (\<lambda>s. e (S s)) [PROOF STEP] by auto \<comment> \<open>show that the Hoare Rule is derivable\<close> [PROOF STATE] proof (state) this: ?e \<circ> S = (\<lambda>s. ?e (S s)) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have G1: "\<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s} WHILE b DO strip C { E \<Down> \<lambda>l s. Q l s \<and> postList upds l s}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s} WHILE b DO strip C { E \<Down> \<lambda>l s. Q l s \<and> postList upds l s} [PROOF STEP] proof(rule conseq_old) [PROOF STATE] proof (state) goal (3 subgoals): 1. \<exists>k>0. \<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> ?P l s \<and> ?e' s \<le> k * E s 2. \<turnstile>\<^sub>1 {?P} WHILE b DO strip C { ?e' \<Down> ?Q} 3. \<forall>l s. ?Q l s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] show "\<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> postList ?upds l s} WHILE b DO strip C { E \<Down> \<lambda>l s. (I l s \<and> postList ?upds l s) \<and> \<not>bval b s }" \<comment> \<open>We use the While Rule and then have to show, that ...\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s} WHILE b DO strip C { E \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s} [PROOF STEP] proof(rule While, goal_cases) \<comment> \<open>A) the loop body preserves the loop invariant\<close> [PROOF STATE] proof (state) goal (4 subgoals): 1. \<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> ?e' s = l ?y} strip C { ?e'' \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l ?y} 2. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + ?e' s + ?e'' s \<le> E s 3. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 4. ?y \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] have "lesvars ?upds' \<inter> varacom C = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lesvars ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) \<inter> varacom C = {} [PROOF STEP] using yC blb [PROOF STATE] proof (prove) using this: lesvars upds \<inter> varacom C = {} (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> varacom C goal (1 subgoal): 1. lesvars ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) \<inter> varacom C = {} [PROOF STEP] by(auto) [PROOF STATE] proof (state) this: lesvars ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) \<inter> varacom C = {} goal (4 subgoals): 1. \<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> ?e' s = l ?y} strip C { ?e'' \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l ?y} 2. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + ?e' s + ?e'' s \<le> E s 3. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 4. ?y \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] have z: "(fst \<circ> (\<lambda>(x, e). (x, \<lambda>s. e (S s)))) = fst" [PROOF STATE] proof (prove) goal (1 subgoal): 1. fst \<circ> (\<lambda>(x, e). (x, \<lambda>s. e (S s))) = fst [PROOF STEP] by auto [PROOF STATE] proof (state) this: fst \<circ> (\<lambda>(x, e). (x, \<lambda>s. e (S s))) = fst goal (4 subgoals): 1. \<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> ?e' s = l ?y} strip C { ?e'' \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l ?y} 2. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + ?e' s + ?e'' s \<le> E s 3. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 4. ?y \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] have "distinct (map fst ?upds')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. distinct (map fst ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) [PROOF STEP] using Awhile(6) zny [PROOF STATE] proof (prove) using this: distinct (map fst upds) (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds goal (1 subgoal): 1. distinct (map fst ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) [PROOF STEP] by (auto simp add: z) \<comment> \<open>for showing preservation of the invariant, use the consequence rule ...\<close> [PROOF STATE] proof (state) this: distinct (map fst ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) goal (4 subgoals): 1. \<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> ?e' s = l ?y} strip C { ?e'' \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l ?y} 2. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + ?e' s + ?e'' s \<le> E s 3. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 4. ?y \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] show "\<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList ?upds l s) \<and> bval b s \<and> preT C E s = l ?z} strip C { time C \<Down> \<lambda>l s. (I l s \<and> postList ?upds l s) \<and> E s \<le> l ?z}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C))} strip C { time C \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C))} [PROOF STEP] proof (rule conseq_old) \<comment> \<open>... and employ the induction hypothesis, ...\<close> [PROOF STATE] proof (state) goal (3 subgoals): 1. \<exists>k>0. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<longrightarrow> ?P l s \<and> ?e' s \<le> k * time C s 2. \<turnstile>\<^sub>1 {?P} strip C { ?e' \<Down> ?Q} 3. \<forall>l s. ?Q l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) [PROOF STEP] show " \<turnstile>\<^sub>1 {\<lambda>l s. pre C I l s \<and> preList ?upds' C l s} strip C { time C \<Down> \<lambda>l s. I l s \<and> postList ?upds' l s}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s} strip C { time C \<Down> \<lambda>l s. I l s \<and> postList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s} [PROOF STEP] apply(rule Awhile.IH[THEN conjunct1]) [PROOF STATE] proof (prove) goal (5 subgoals): 1. vc C I 2. finite (support I) 3. finite (varacom C) 4. lesvars ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, \<lambda>s. e (S s))) upds) \<inter> varacom C = {} 5. distinct (map fst ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>a. case a of (x, e) \<Rightarrow> (x, \<lambda>s. e (S s))) upds)) [PROOF STEP] by fact+ [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s} strip C { time C \<Down> \<lambda>l s. I l s \<and> postList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s} goal (2 subgoals): 1. \<exists>k>0. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<longrightarrow> (pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s) \<and> time C s \<le> k * time C s 2. \<forall>l s. I l s \<and> postList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) [PROOF STEP] next \<comment> \<open>finally we have to prove the side condition.\<close> [PROOF STATE] proof (state) goal (2 subgoals): 1. \<exists>k>0. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<longrightarrow> (pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s) \<and> time C s \<le> k * time C s 2. \<forall>l s. I l s \<and> postList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) [PROOF STEP] show "\<exists>k>0. \<forall>l s. (I l s \<and> postList ?upds l s) \<and> bval b s \<and> preT C E s = l ?z \<longrightarrow> (pre C I l s \<and> preList ?upds' C l s) \<and> time C s \<le> k * time C s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>k>0. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<longrightarrow> (pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s) \<and> time C s \<le> k * time C s [PROOF STEP] apply(rule exI[where x=1]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 < 1 \<and> (\<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<longrightarrow> (pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s) \<and> time C s \<le> 1 * time C s) [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) \<longrightarrow> pre C I l s \<and> preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s [PROOF STEP] proof (safe, goal_cases) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> pre C I l s 2. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s [PROOF STEP] case (2 l s) [PROOF STATE] proof (state) this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) goal (2 subgoals): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> pre C I l s 2. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s [PROOF STEP] note upds_invariant=postpreList_inv[OF IQ_in[OF 2(1)]] [PROOF STATE] proof (state) this: bval b s \<Longrightarrow> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) ?upds) ?l s = preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) ?upds) C ?l s goal (2 subgoals): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> pre C I l s 2. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s [PROOF STEP] from 2 upds_invariant [PROOF STATE] proof (chain) picking this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) bval b s \<Longrightarrow> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) ?upds) ?l s = preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) ?upds) C ?l s [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) bval b s \<Longrightarrow> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) ?upds) ?l s = preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) ?upds) C ?l s goal (1 subgoal): 1. preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s [PROOF STEP] by auto [PROOF STATE] proof (state) this: preList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> pre C I l s [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> pre C I l s [PROOF STEP] case (1 l s) [PROOF STATE] proof (state) this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s; bval b s; preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C)\<rbrakk> \<Longrightarrow> pre C I l s [PROOF STEP] then [PROOF STATE] proof (chain) picking this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) goal (1 subgoal): 1. pre C I l s [PROOF STEP] using inv_impl [PROOF STATE] proof (prove) using this: I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s bval b s preT C E s = l (SOME z. z \<notin> lesvars upds \<and> z \<notin> support I \<and> z \<notin> varacom C) \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s goal (1 subgoal): 1. pre C I l s [PROOF STEP] by auto [PROOF STATE] proof (state) this: pre C I l s goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>k>0. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<longrightarrow> (pre C I l s \<and> preList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) C l s) \<and> time C s \<le> k * time C s goal (1 subgoal): 1. \<forall>l s. I l s \<and> postList ((SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C), E) # map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) [PROOF STEP] qed auto [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> bval b s \<and> preT C E s = l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C))} strip C { time C \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> l (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C))} goal (3 subgoals): 1. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + preT C E s + time C s \<le> E s 2. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 3. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] next \<comment> \<open>B) the invariant with number of loop unfoldings greater than 0 implies true loop guard and running time is correctly bounded\<close> [PROOF STATE] proof (state) goal (3 subgoals): 1. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + preT C E s + time C s \<le> E s 2. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 3. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] show "\<forall>l s. bval b s \<and> I l s \<and> postList ?upds l s \<longrightarrow> 1 + preT C E s + time C s \<le> E s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + preT C E s + time C s \<le> E s [PROOF STEP] proof (clarify, goal_cases) [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. \<lbrakk>bval b s; I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s\<rbrakk> \<Longrightarrow> 1 + preT C E s + time C s \<le> E s [PROOF STEP] case (1 l s) [PROOF STATE] proof (state) this: bval b s I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s goal (1 subgoal): 1. \<And>l s. \<lbrakk>bval b s; I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s\<rbrakk> \<Longrightarrow> 1 + preT C E s + time C s \<le> E s [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. 1 + preT C E s + time C s \<le> E s [PROOF STEP] using IQ2 1(1,2) [PROOF STATE] proof (prove) using this: \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) bval b s I l s goal (1 subgoal): 1. 1 + preT C E s + time C s \<le> E s [PROOF STEP] by auto [PROOF STATE] proof (state) this: 1 + preT C E s + time C s \<le> E s goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<forall>l s. bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 + preT C E s + time C s \<le> E s goal (2 subgoals): 1. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 2. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] next \<comment> \<open>C) the invariant with number of loop unfoldings equal to 0 implies false loop guard and running time is correctly bounded\<close> [PROOF STATE] proof (state) goal (2 subgoals): 1. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s 2. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] show "\<forall>l s. \<not> bval b s \<and> I l s \<and> postList ?upds l s \<longrightarrow> 1 \<le> E s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s [PROOF STEP] proof (clarify, goal_cases) [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. \<lbrakk>\<not> bval b s; I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s\<rbrakk> \<Longrightarrow> 1 \<le> E s [PROOF STEP] case (1 l s) [PROOF STATE] proof (state) this: \<not> bval b s I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s goal (1 subgoal): 1. \<And>l s. \<lbrakk>\<not> bval b s; I l s; postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s\<rbrakk> \<Longrightarrow> 1 \<le> E s [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<not> bval b s I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: \<not> bval b s I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s goal (1 subgoal): 1. 1 \<le> E s [PROOF STEP] using pre2 1(2) [PROOF STATE] proof (prove) using this: \<not> bval b s I l s postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<lbrakk>I ?l ?s; \<not> bval b ?s\<rbrakk> \<Longrightarrow> Q ?l ?s \<and> 1 \<le> E ?s \<and> S ?s = ?s I l s goal (1 subgoal): 1. 1 \<le> E s [PROOF STEP] by auto [PROOF STATE] proof (state) this: 1 \<le> E s goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<forall>l s. \<not> bval b s \<and> I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s \<longrightarrow> 1 \<le> E s goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] next \<comment> \<open>D) ?z is indeed a fresh variable\<close> [PROOF STATE] proof (state) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] have pff: "?z \<notin> lesvars ?upds" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) [PROOF STEP] apply(simp only: fua) [PROOF STATE] proof (prove) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars upds [PROOF STEP] by fact [PROOF STATE] proof (state) this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] have "support (\<lambda>l s. I l s \<and> postList ?upds l s) \<subseteq> support I \<union> support (postList ?upds)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> support (postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) [PROOF STEP] by(rule support_and) [PROOF STATE] proof (state) this: support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> support (postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] also [PROOF STATE] proof (state) this: support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> support (postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] have "support (postList ?upds) \<subseteq> lesvars ?upds" [PROOF STATE] proof (prove) goal (1 subgoal): 1. support (postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) \<subseteq> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) [PROOF STEP] apply(rule support_postList) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: support (postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds)) \<subseteq> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: (\<And>x y. x \<subseteq> y \<Longrightarrow> support I \<union> x \<subseteq> support I \<union> y) \<Longrightarrow> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) [PROOF STEP] have "support (\<lambda>l s. I l s \<and> postList ?upds l s) \<subseteq> support I \<union> lesvars ?upds" [PROOF STATE] proof (prove) using this: (\<And>x y. x \<subseteq> y \<Longrightarrow> support I \<union> x \<subseteq> support I \<union> y) \<Longrightarrow> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) goal (1 subgoal): 1. support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) [PROOF STEP] by blast [PROOF STATE] proof (state) this: support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] thus "?z \<notin> support (\<lambda>l s. I l s \<and> postList ?upds l s)" [PROOF STATE] proof (prove) using this: support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<subseteq> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) [PROOF STEP] apply(rule contra_subsetD) [PROOF STATE] proof (prove) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) [PROOF STEP] using zI pff [PROOF STATE] proof (prove) using this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support I (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) goal (1 subgoal): 1. (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support I \<union> lesvars (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) [PROOF STEP] by(simp) [PROOF STATE] proof (state) this: (SOME z. z \<notin> lesvars upds \<union> varacom ({A} WHILE b DO C)) \<notin> support (\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s} WHILE b DO strip C { E \<Down> \<lambda>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s} goal (2 subgoals): 1. \<exists>k>0. \<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> k * E s 2. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] next [PROOF STATE] proof (state) goal (2 subgoals): 1. \<exists>k>0. \<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> k * E s 2. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] show "\<exists>k>0. \<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> k * E s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>k>0. \<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> k * E s [PROOF STEP] apply(rule exI[where x=1]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 < 1 \<and> (\<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> 1 * E s) [PROOF STEP] apply(auto) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; preList upds ({(I, S, E)} WHILE b DO C) l s\<rbrakk> \<Longrightarrow> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s [PROOF STEP] apply(simp only: postList_preList[symmetric] ) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, preT ({(I, S, E)} WHILE b DO C) e)) upds) l s\<rbrakk> \<Longrightarrow> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s [PROOF STEP] apply (auto) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. \<lbrakk>I l s; postList (map (\<lambda>(x, e). (x, e \<circ> S)) upds) l s\<rbrakk> \<Longrightarrow> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s [PROOF STEP] apply(simp only: g) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done [PROOF STATE] proof (state) this: \<exists>k>0. \<forall>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s \<longrightarrow> (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> E s \<le> k * E s goal (1 subgoal): 1. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] show "\<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] using pre2 [PROOF STATE] proof (prove) using this: \<lbrakk>I ?l ?s; \<not> bval b ?s\<rbrakk> \<Longrightarrow> Q ?l ?s \<and> 1 \<le> E ?s \<and> S ?s = ?s goal (1 subgoal): 1. \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s [PROOF STEP] by(induct upds, auto) [PROOF STATE] proof (state) this: \<forall>l s. (I l s \<and> postList (map (\<lambda>(x, e). (x, \<lambda>s. e (S s))) upds) l s) \<and> \<not> bval b s \<longrightarrow> Q l s \<and> postList upds l s goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s} WHILE b DO strip C { E \<Down> \<lambda>l s. Q l s \<and> postList upds l s} goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] have G2: "\<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] fix l s [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] assume "pre ({A} WHILE b DO C) Q l s" [PROOF STATE] proof (state) this: pre ({A} WHILE b DO C) Q l s goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: pre ({A} WHILE b DO C) Q l s [PROOF STEP] have I: "I l s" [PROOF STATE] proof (prove) using this: pre ({A} WHILE b DO C) Q l s goal (1 subgoal): 1. I l s [PROOF STEP] by simp [PROOF STATE] proof (state) this: I l s goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] { [PROOF STATE] proof (state) this: I l s goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] fix n [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] have "E s = n \<Longrightarrow> I l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>E s = n; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] proof (induct n arbitrary: s l rule: less_induct) [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x s l. \<lbrakk>\<And>y s l. \<lbrakk>y < x; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = x; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] case (less n) [PROOF STATE] proof (state) this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s goal (1 subgoal): 1. \<And>x s l. \<lbrakk>\<And>y s l. \<lbrakk>y < x; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = x; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s goal (1 subgoal): 1. Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] proof (cases "bval b s") [PROOF STATE] proof (state) goal (2 subgoals): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) 2. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] case True [PROOF STATE] proof (state) this: bval b s goal (2 subgoals): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) 2. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with less IQ2 [PROOF STATE] proof (chain) picking this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) bval b s [PROOF STEP] have "pre C I l s" and S: "S s = S (postQ C s)" and t: "1 + preT C E s + time C s \<le> E s" [PROOF STATE] proof (prove) using this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s \<lbrakk>I ?l ?s; bval b ?s\<rbrakk> \<Longrightarrow> pre C I ?l ?s \<and> 1 + preT C E ?s + time C ?s \<le> E ?s \<and> S ?s = S (postQ C ?s) bval b s goal (1 subgoal): 1. pre C I l s &&& S s = S (postQ C s) &&& 1 + preT C E s + time C s \<le> E s [PROOF STEP] by auto [PROOF STATE] proof (state) this: pre C I l s S s = S (postQ C s) 1 + preT C E s + time C s \<le> E s goal (2 subgoals): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) 2. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with step [PROOF STATE] proof (chain) picking this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) pre C I l s S s = S (postQ C s) 1 + preT C E s + time C s \<le> E s [PROOF STEP] have I': "I l (postQ C s)" and "1 + E (postQ C s) + time C s \<le> E s" [PROOF STATE] proof (prove) using this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) pre C I l s S s = S (postQ C s) 1 + preT C E s + time C s \<le> E s goal (1 subgoal): 1. I l (postQ C s) &&& 1 + E (postQ C s) + time C s \<le> E s [PROOF STEP] using TQ [PROOF STATE] proof (prove) using this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) pre C I l s S s = S (postQ C s) 1 + preT C E s + time C s \<le> E s preT ?C ?e ?s = ?e (postQ ?C ?s) goal (1 subgoal): 1. I l (postQ C s) &&& 1 + E (postQ C s) + time C s \<le> E s [PROOF STEP] by auto [PROOF STATE] proof (state) this: I l (postQ C s) 1 + E (postQ C s) + time C s \<le> E s goal (2 subgoals): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) 2. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with less [PROOF STATE] proof (chain) picking this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s I l (postQ C s) 1 + E (postQ C s) + time C s \<le> E s [PROOF STEP] have "E (postQ C s) < n" [PROOF STATE] proof (prove) using this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) E s = n I l s I l (postQ C s) 1 + E (postQ C s) + time C s \<le> E s goal (1 subgoal): 1. E (postQ C s) < n [PROOF STEP] by auto [PROOF STATE] proof (state) this: E (postQ C s) < n goal (2 subgoals): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) 2. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with less(1) I' [PROOF STATE] proof (chain) picking this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) I l (postQ C s) E (postQ C s) < n [PROOF STEP] have "Q l (postQ ({A} WHILE b DO C) (postQ C s))" [PROOF STATE] proof (prove) using this: \<lbrakk>?y1 < n; E ?s1 = ?y1; I ?l1 ?s1\<rbrakk> \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) I l (postQ C s) E (postQ C s) < n goal (1 subgoal): 1. Q l (postQ ({A} WHILE b DO C) (postQ C s)) [PROOF STEP] by auto [PROOF STATE] proof (state) this: Q l (postQ ({A} WHILE b DO C) (postQ C s)) goal (2 subgoals): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) 2. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with step [PROOF STATE] proof (chain) picking this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) Q l (postQ ({A} WHILE b DO C) (postQ C s)) [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) Q l (postQ ({A} WHILE b DO C) (postQ C s)) goal (1 subgoal): 1. Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] using S [PROOF STATE] proof (prove) using this: pre C I ?l ?s \<Longrightarrow> I ?l (postQ C ?s) Q l (postQ ({A} WHILE b DO C) (postQ C s)) S s = S (postQ C s) goal (1 subgoal): 1. Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] by simp [PROOF STATE] proof (state) this: Q l (postQ ({A} WHILE b DO C) s) goal (1 subgoal): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] case False [PROOF STATE] proof (state) this: \<not> bval b s goal (1 subgoal): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with pre2 less(3) [PROOF STATE] proof (chain) picking this: \<lbrakk>I ?l ?s; \<not> bval b ?s\<rbrakk> \<Longrightarrow> Q ?l ?s \<and> 1 \<le> E ?s \<and> S ?s = ?s I l s \<not> bval b s [PROOF STEP] have "Q l s" "S s = s" [PROOF STATE] proof (prove) using this: \<lbrakk>I ?l ?s; \<not> bval b ?s\<rbrakk> \<Longrightarrow> Q ?l ?s \<and> 1 \<le> E ?s \<and> S ?s = ?s I l s \<not> bval b s goal (1 subgoal): 1. Q l s &&& S s = s [PROOF STEP] by auto [PROOF STATE] proof (state) this: Q l s S s = s goal (1 subgoal): 1. \<lbrakk>\<And>y s l. \<lbrakk>y < n; E s = y; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s); E s = n; I l s; \<not> bval b s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: Q l s S s = s [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: Q l s S s = s goal (1 subgoal): 1. Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] by simp [PROOF STATE] proof (state) this: Q l (postQ ({A} WHILE b DO C) s) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: Q l (postQ ({A} WHILE b DO C) s) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<lbrakk>E s = n; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] } [PROOF STATE] proof (state) this: \<lbrakk>E s = ?n3; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) goal (1 subgoal): 1. \<And>l s. pre ({A} WHILE b DO C) Q l s \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] with I [PROOF STATE] proof (chain) picking this: I l s \<lbrakk>E s = ?n3; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] show "Q l (postQ ({A} WHILE b DO C) s)" [PROOF STATE] proof (prove) using this: I l s \<lbrakk>E s = ?n3; I l s\<rbrakk> \<Longrightarrow> Q l (postQ ({A} WHILE b DO C) s) goal (1 subgoal): 1. Q l (postQ ({A} WHILE b DO C) s) [PROOF STEP] by simp [PROOF STATE] proof (state) this: Q l (postQ ({A} WHILE b DO C) s) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: pre ({A} WHILE b DO C) Q ?l1 ?s1 \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) goal (1 subgoal): 1. \<And>x1 x2 C Q upds. \<lbrakk>\<And>Q upds. \<lbrakk>vc C Q; finite (support Q); finite (varacom C); lesvars upds \<inter> varacom C = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre C Q l s \<and> preList upds C l s} strip C { time C \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre C Q l s \<longrightarrow> Q l (postQ C s)); vc ({x1} WHILE x2 DO C) Q; finite (support Q); finite (varacom ({x1} WHILE x2 DO C)); lesvars upds \<inter> varacom ({x1} WHILE x2 DO C) = {}; distinct (map fst upds)\<rbrakk> \<Longrightarrow> \<turnstile>\<^sub>1 {\<lambda>l s. pre ({x1} WHILE x2 DO C) Q l s \<and> preList upds ({x1} WHILE x2 DO C) l s} strip ({x1} WHILE x2 DO C) { time ({x1} WHILE x2 DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({x1} WHILE x2 DO C) Q l s \<longrightarrow> Q l (postQ ({x1} WHILE x2 DO C) s)) [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre ({A} WHILE b DO C) Q l s \<and> preList upds ({A} WHILE b DO C) l s} strip ({A} WHILE b DO C) { time ({A} WHILE b DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({A} WHILE b DO C) Q l s \<longrightarrow> Q l (postQ ({A} WHILE b DO C) s)) [PROOF STEP] using G1 G2 [PROOF STATE] proof (prove) using this: \<turnstile>\<^sub>1 {\<lambda>l s. I l s \<and> preList upds ({(I, S, E)} WHILE b DO C) l s} WHILE b DO strip C { E \<Down> \<lambda>l s. Q l s \<and> postList upds l s} pre ({A} WHILE b DO C) Q ?l1 ?s1 \<Longrightarrow> Q ?l1 (postQ ({A} WHILE b DO C) ?s1) goal (1 subgoal): 1. \<turnstile>\<^sub>1 {\<lambda>l s. pre ({A} WHILE b DO C) Q l s \<and> preList upds ({A} WHILE b DO C) l s} strip ({A} WHILE b DO C) { time ({A} WHILE b DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({A} WHILE b DO C) Q l s \<longrightarrow> Q l (postQ ({A} WHILE b DO C) s)) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<turnstile>\<^sub>1 {\<lambda>l s. pre ({A} WHILE b DO C) Q l s \<and> preList upds ({A} WHILE b DO C) l s} strip ({A} WHILE b DO C) { time ({A} WHILE b DO C) \<Down> \<lambda>l s. Q l s \<and> postList upds l s} \<and> (\<forall>l s. pre ({A} WHILE b DO C) Q l s \<longrightarrow> Q l (postQ ({A} WHILE b DO C) s)) goal: No subgoals! [PROOF STEP] qed
data Vect : Nat -> Type -> Type where Nil : Vect Z a (::) : a -> Vect k a -> Vect (S k) a %name Vect xs, ys, zs zipWith : (a -> b -> c) -> Vect n a -> Vect n b -> Vect n c
module Js.DOM.Element import Js.Object %default total %access export public export data Element = MkElement Ptr Class Element where ptr (MkElement p) = p
Expressing yourself by sharing photos on Instagram is a buzz especially when the service is backed up by Facebook. It has already added its presence in Social Media. Instagram app is available on Android and iPhone only, as of now. Instagram also works the same way as the Twitter works but the only difference is that your status is expressed with photos clicked by you. Related Post: How to take Cloud Backup from major cloud services and FTP. Since, it is supported on limited mobile operating systems it is less used by mobile users. But, I must say you should join Instagram and experience photo sharing. Today I would be sharing ways on how can you access Instagram on web. Instagram is being used more for the Photo contest and social media campaigns these days. Even I have seen few images which I am sure it is not clicked by mobile camera, but they upload it by third-party applications uploading directly from the computer. Apart from that, you can even search in Instagram or know the stats of the users using the service. How can you use Instagram on your PC? Gramfeed: gives an interactive Instagram UI which helps you to manage your friends photos likes and check out familiar photos which are active. It also shows the maps which helps to know from where the photo is being clicked. It provides you grid view if you want to see the photos in one go or you can select it in normal view which helps you to check out the photos with time format. Ink361: is another Instagram third-party service, which helps you to give the full view of the photos uploaded by other users like you see in Instagram. Ink361 shows their ad in between of other images which irritates using the service sometimes as Instagram does not provide any ad placement on mobile service. The geo tagging feature is more useful than Gramfeed. Related Post: Learning from Red Bull Stratos – How to create Buzz! Instagram for Chrome: this one is the best browser based application which gives the exact feel of using Instagram on the mobile. All the features are similar to the Instagram app on the mobile. But you can use this app in only Google Chrome browser. Luxogram: This service is still in a beta phase. But will give all the needed features of Instagram. The photo feed gets updates as and when your friends add up the photos. When you move the cursor on the photo you will see the details of the photo and the update status. You can even like by double clicking the photo. Let me know your experience using these web applications. Feel free to drop your comments. « Things to keep in mind before downloading Windows 8?
Ecological Landscape Design is a landscape design landscape designer that provides consultation and design services for residential clients. Their goal is to enhance their clients lives by creating beautiful, functional landscapes that reflect who their clients are and where they live. The designs minimize the environmental impact of landscaping projects, create habitat and strengthen our sense of place. They use local and reused or recycled construction materials. The plant palette includes California natives, Mediterranean species, edible and useful plants. They employ rain harvesting techniques, pervious pavements and many more sustainable approaches.
//============================================================================== // Copyright 2003 - 2013 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2013 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #include <nt2/trigonometric/include/functions/sinc.hpp> #include <nt2/sdk/functor/meta/call.hpp> #include <nt2/sdk/unit/module.hpp> #include <nt2/sdk/unit/tests/relation.hpp> #include <nt2/sdk/unit/tests/type_expr.hpp> #include <nt2/sdk/unit/tests/ulp.hpp> #include <nt2/sdk/unit/module.hpp> #include <boost/simd/sdk/config.hpp> #include <nt2/include/constants/eps.hpp> #include <nt2/include/constants/mindenormal.hpp> #include <nt2/include/constants/one.hpp> #include <nt2/include/constants/pi.hpp> #include <nt2/include/constants/zero.hpp> #include <nt2/include/constants/inf.hpp> #include <nt2/include/constants/minf.hpp> #include <nt2/include/constants/nan.hpp> #include <nt2/include/constants/pio_2.hpp> #include <nt2/include/constants/pio_4.hpp> NT2_TEST_CASE_TPL( sinc_real, NT2_REAL_TYPES) { using nt2::sinc; using nt2::tag::sinc_; NT2_TEST_TYPE_IS(typename nt2::meta::call<sinc_(T)>::type,T); typedef T wished_r_t; // return type conformity test NT2_TEST_TYPE_IS(T, wished_r_t); // specific values tests #ifndef BOOST_SIMD_NO_INVALIDS NT2_TEST_ULP_EQUAL(sinc(nt2::Inf<T>()), nt2::Zero<T>(), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Minf<T>()), nt2::Zero<T>(), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Nan<T>()), nt2::Nan<T>(), 0.5); #endif NT2_TEST_ULP_EQUAL(sinc(-nt2::Pio_2<T>()), T(2)/(nt2::Pi<T>()), 0.5); NT2_TEST_ULP_EQUAL(sinc(-nt2::Pio_4<T>()), nt2::sin(nt2::Pio_4<T>())/(nt2::Pio_4<T>()), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Pio_2<T>()), T(2)/(nt2::Pi<T>()), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Pio_4<T>()), nt2::sin(nt2::Pio_4<T>())/(nt2::Pio_4<T>()), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Eps<T>()), nt2::One<T>(), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Mindenormal<T>()), nt2::One<T>(), 0.5); NT2_TEST_ULP_EQUAL(sinc(nt2::Zero<T>()), nt2::One<T>(), 0.5); }
{- This file contains: - The equivalence "James X ≃ Ω Σ X" for any connected pointed type X. (KANG Rongji, Feb. 2022) -} {-# OPTIONS --safe #-} module Cubical.HITs.James.LoopSuspEquiv where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.Fiberwise open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Pointed open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.HITs.Pushout open import Cubical.HITs.Pushout.Flattening open import Cubical.HITs.Susp open import Cubical.HITs.James.Base renaming (James to JamesContruction ; James∙ to JamesContruction∙) open import Cubical.HITs.Truncation open import Cubical.Homotopy.Connected open import Cubical.Homotopy.Loopspace private variable ℓ : Level module _ ((X , x₀) : Pointed ℓ) where private James = JamesContruction (X , x₀) James∙ = JamesContruction∙ (X , x₀) Total : Type ℓ Total = Pushout {A = X × James} snd (λ (x , xs) → x ∷ xs) private flipSquare : (xs : James)(i j : I) → James flipSquare xs i j = hcomp (λ k → λ { (i = i0) → unit xs (j ∨ k) ; (i = i1) → unit (x₀ ∷ xs) j ; (j = i0) → unit xs (i ∨ k) ; (j = i1) → x₀ ∷ (unit xs i) }) (unit (unit xs i) j) square1 : (x : X)(xs : James)(i j : I) → Total square1 x xs i j = hfill (λ j → λ { (i = i0) → push (x , xs) (~ j) ; (i = i1) → push (x₀ , x ∷ xs) (~ j) }) (inS (inr (unit (x ∷ xs) i))) j square2 : (xs : James)(i j : I) → Total square2 xs i j = hcomp (λ k → λ { (i = i0) → push (x₀ , xs) (~ k) ; (i = i1) → square1 x₀ xs j k ; (j = i0) → push (x₀ , xs) (~ k) ; (j = i1) → push (x₀ , unit xs i) (~ k) }) (inr (flipSquare xs i j)) center : Total center = inl [] pathL : (xs : James) → center ≡ inl xs pathL [] = refl pathL (x ∷ xs) = pathL xs ∙ (λ i → square1 x xs i i1) pathL (unit xs i) j = hcomp (λ k → λ { (i = i0) → pathL xs j ; (i = i1) → compPath-filler (pathL xs) (λ i → square1 x₀ xs i i1) k j ; (j = i0) → inl [] ; (j = i1) → square2 xs i k }) (pathL xs j) isContrTotal : isContr Total isContrTotal .fst = center isContrTotal .snd (inl xs) = pathL xs isContrTotal .snd (inr xs) = pathL xs ∙∙ push (x₀ , xs) ∙∙ (λ i → inr (unit xs (~ i))) isContrTotal .snd (push (x , xs) i) j = hcomp (λ k → λ { (i = i0) → compPath-filler' (pathL xs) (λ i → square1 x xs i i1) (~ j) (~ k) ; (i = i1) → doubleCompPath-filler (pathL (x ∷ xs)) (push (x₀ , x ∷ xs)) (λ i → inr (unit (x ∷ xs) (~ i))) k j ; (j = i0) → pathL (x ∷ xs) (~ k) ; (j = i1) → square1 x xs (~ k) (~ i) }) (push (x₀ , x ∷ xs) (i ∧ j)) module _ (conn : isConnected 2 X) where private isEquivx₀∷ : isEquiv {A = James} (x₀ ∷_) isEquivx₀∷ = subst isEquiv (λ i xs → unit xs i) (idIsEquiv _) ∣isEquiv∣ : hLevelTrunc 2 X → Type ℓ ∣isEquiv∣ x = rec isSetHProp (λ x → isEquiv {A = James} (x ∷_) , isPropIsEquiv _) x .fst isEquiv∷ : (x : X) → isEquiv {A = James} (x ∷_) isEquiv∷ x = subst ∣isEquiv∣ (sym (conn .snd ∣ x₀ ∣) ∙ (conn .snd ∣ x ∣)) isEquivx₀∷ Code : Susp X → Type ℓ Code north = James Code south = James Code (merid x i) = ua (_ , isEquiv∷ x) i private open FlatteningLemma (λ _ → tt) (λ _ → tt) (λ tt → James) (λ tt → James) (λ x → _ , isEquiv∷ x) Total≃ : Pushout Σf Σg ≃ Total Total≃ = pushoutEquiv _ _ _ _ (idEquiv _) (ΣUnit _) (ΣUnit _) refl refl PushoutSuspCode : (x : PushoutSusp X) → E x ≃ Code (PushoutSusp→Susp x) PushoutSuspCode (inl tt) = idEquiv _ PushoutSuspCode (inr tt) = idEquiv _ PushoutSuspCode (push x i) = idEquiv _ ΣCode≃' : _ ≃ Σ _ Code ΣCode≃' = Σ-cong-equiv PushoutSusp≃Susp PushoutSuspCode ΣCode≃ : Total ≃ Σ _ Code ΣCode≃ = compEquiv (invEquiv Total≃) (compEquiv (invEquiv flatten) ΣCode≃') isContrΣCode : isContr (Σ _ Code) isContrΣCode = isOfHLevelRespectEquiv _ ΣCode≃ isContrTotal ΩΣ≃J : Ω (Susp∙ X) .fst ≃ James ΩΣ≃J = recognizeId Code [] isContrΣCode _ ΩΣ≃∙J : Ω (Susp∙ X) ≃∙ James∙ ΩΣ≃∙J = ΩΣ≃J , refl J≃ΩΣ : James ≃ Ω (Susp∙ X) .fst J≃ΩΣ = invEquiv ΩΣ≃J J≃∙ΩΣ : James∙ ≃∙ Ω (Susp∙ X) J≃∙ΩΣ = invEquiv∙ ΩΣ≃∙J
r=0.57 https://sandbox.dams.library.ucdavis.edu/fcrepo/rest/collection/sherry-lehmann/catalogs/d7xg6k/media/images/d7xg6k-003/svc:tesseract/full/full/0.57/default.jpg Accept:application/hocr+xml
A new member to Davis Wiki, he seemingly knows way too much about Davis. He is in fact a Chico state student and native to Northern California. He is currently an Anthropology major and Jack in the Box employee.
\input{clio/fig-scalability-tail} \input{clio/fig-throughput-latency} \section{Evaluation} \label{sec:clio:results} Our evaluation reveals the scalability, throughput, median and tail latency, energy and resource consumption of \sys. %, and how it compares with state-of-the-art systems. We compare \sys's end-to-end performance with industry-grade NICs (ASIC) and well-tuned RDMA-based software systems. All \sys's results are FPGA-based, which would be improved with ASIC implementation. %Nonetheless, \sys\ significantly outperforms RDMA on scalability and tail latency, while being similar on other measurements. \ulinebfpara{Environment.} We evaluated \sys\ in our local cluster of four \CN{}s and four \MN{}s (Xilinx ZCU106 boards), %\footnote{Unfortunately, our process of purchasing and setting up a bigger cluster was significantly delayed because of COVID-19}, all connected to an Nvidia 40\Gbps\ VPI switch. Each \CN\ is a Dell PowerEdge R740 server equipped with a Xeon Gold 5128 CPU and a 40\Gbps\ Nvidia ConnectX-3 NIC, with two of them also having an Nvidia BlueField SmartNIC~\cite{BlueField}. We also include results from CloudLab~\cite{CloudLab} with the Nvidia ConnectX-5 NIC. \subsection{Basic Microbenchmark Performance} \input{clio/fig-alloc-breakdown-photo-radix} \input{clio/fig-radix-kv-mv-df} \ulinebfpara{Scalability.} We first compare the scalability of \sys\ and RDMA. Figure~\ref{fig-conn} measures the latency of \sys\ and RDMA as the number of client processes increases. For RDMA, each process uses its own QP. Since \sys\ is connectionless, it scales perfectly with the number of processes. RDMA scales poorly with its QP, and the problem persists with newer generations of RNIC, which is also confirmed by our previous works~\cite{Pythia,Storm}. Figure~\ref{fig-pte-mr} evaluates the scalability with respect to PTEs and memory regions. For the memory region test, we register multiple MRs using the same physical memory for RDMA. For \sys, we map a large range of VAs (up to 4\TB) to a small physical memory space, as our testbed only has 2\GB\ physical memory. However, the number of PTEs and the amount of processing needed are the same for \sysboard\ as if it had a real 4\TB\ physical memory. Thus, this workload stress tests \sysboard's scalability. %For \sys\ (which gets rid of the MR concept), we use multiple processes to share the same memory, %resulting in one PTE per process. RDMA's performance starts to degrade when there are more than $2^8$ (local cluster) or $2^{12}$ (CloudLab), and the scalability wrt MR is worse than wrt PTE. In fact, RDMA fails to run beyond $2^{18}$ MRs. In contrast, \sys\ scales well and never fails (at least up to 4\TB\ memory). It has two levels of latency that are both stable: a lower latency below $2^4$ for TLB hit and a higher latency above $2^4$ for TLB miss (which always involves one DRAM access). A \sysboard\ could use a larger TLB if optimal performance is desired. These experiments confirm that \textbf{\sys\ can handle thousands of concurrent clients and TBs of memory}. \ulinebfpara{Latency variation.} Figure~\ref{fig-miss-hit} plots the latency of reading/writing 16\,B data when the operation results in a TLB hit, a TLB miss, a first-access page fault, and MR miss (for RDMA only, when the MR metadata is not in RNIC). RDMA's performance degrades significantly with misses. Its page fault handling is extremely slow (16.8\ms). We confirm the same effect on CloudLab with the newer ConnectX-5 NICs. \sys\ only incurs a small TLB miss cost and \textbf{no additional cost of page fault handling}. We also include a projection of \sys's latency if it was to be implemented using a real ASIC-based \sysboard. Specifically, we collect the latency breakdown of time spent on the network wire and at \CN, time spent on third-party FPGA IPs, number of cycles on FPGA, and time on accessing on-board DRAM. We maintain the first two parts, scale the FPGA part to ASIC's frequency (2\,GHz), use DDR access time collected on our server to replace the access time to on-board DRAM (which goes through a slow board memory controller). This estimation is conservative, as a real ASIC implementation of the third-party IPs would make the total latency lower. Our estimated read latency is better than RDMA, while write latency is worse. We suspect the reason being Nvidia RNIC's optimization of replying a write before it is fully written to DRAM, which \sys\ could also potentially adopt. Figure~\ref{fig-tail-latency} plots the request latency CDF of continuously running read/write 16\,B data while not triggering page faults. Even without page faults, \sys\ has much less latency variation and a much shorter tail than RDMA. %Thanks to our bounded address translation and deterministic hardware design, \sys\ has much less latency variation and a much shorter tail than RDMA. \input{clio/fig-energy-fpgautil} \ulinebfpara{Read/write throughput.} We measure \sys's throughput by varying the number of concurrent client threads (Figure~\ref{fig-read-write-throughput}). \sys's default asynchronous APIs quickly reach the line rate of our testbed (9.4\Gbps\ maximum throughput). Its synchronous APIs could also reach line rate fairly quickly. Figure~\ref{fig-onboard-throughput} measures the maximum throughput of \sys's FPGA implementation without the bottleneck of the board's 10\Gbps\ port, by generating traffic on board. Both read and write can reach more than 110\Gbps\ when request size is large. Read throughput is lower than write when request size is smaller. We found the throughput bottleneck to be the third-party non-pipelined DMA IP (which could potentially be improved). \ulinebfpara{Comparison with other systems.} We compare \sys\ with native one-sided RDMA, Clover~\cite{Tsai20-ATC}, HERD~\cite{Kalia14-RDMAKV}, and LegoOS~\cite{Shan18-OSDI}. We ran HERD on both CPU and BlueField (HERD-BF). %Native RDMA can be considered as a baseline (optimal performance but low-level, restrictive interface). Clover is a passive disaggregated persistent memory system which we adapted as a passive disaggregated memory (PDM) system. HERD is an RDMA-based system that supports a key-value interface with an RPC-like architecture. LegoOS builds its virtual memory system in software at \MN. %It uses one RDMA read for its read and one RDMA write plus one %it can be considered as a software-based active disaggregated memory system. \sys's performance is similar to HERD and close to native RDMA. %\sys's write performance is better than Clover and similar to HERD. %but has a constant overhead over native RDMA. Clover's write is the worst because it uses at least 2 RTTs for writes to deliver its consistency guarantees without any processing power at \MN{}s. HERD-BF's latency is much higher than when HERD runs on CPU due to the slow communication between BlueField's ConnectX-5 chip and ARM processor chip. LegoOS's latency is almost two times higher than \sys's when request size is small. In addition, from our experiment, LegoOS can only reach a peak throughput of 77\Gbps, while \sys\ can reach 110\Gbps. LegoOS' performance overhead comes from its software approach, demonstrating the necessity of a hardware-based solution like \sys. %due to the slow communication between BlueField's Connect-X5 chip and ARM processor %chip.. %\sys's write overhead can be attributed to \fixme{XXX}. \ulinebfpara{Allocation performance.} Figure~\ref{fig-alloc-free} shows \sys's VA and PA allocation and RDMA's MR registration performance. %Physical memory allocation includes the time to perform an allocation with the buddy algorithm and to insert the allocated address into the free page list. %It is very fast, indicating that our asynchronous free physical page generation could keep up with most workloads' page fault speed. %Virtual memory allocation and free (measured from client on \CN) are slower, \sys's PA allocation takes less than 20\mus, and the VA allocation is much faster than RDMA MR registration, although both get slower with larger allocation/registration size. %since these operations involve the costly crossing between FPGA and ARM. %They are also slower with larger sizes, as searching the VMA tree for a big free region takes more time. Figure~\ref{fig-alloc-conflict} shows the number of retries at allocation time with three allocation sizes as the physical memory fills up. %running at on-board ARM processor. %The hash-based page table is proportional to the physical memory size. %Hence higher its utilization, higher the overflow probability therefore higher number of retries. %The page table has 2\x\ extra slots by default. There is no retry when memory is below half utilized. Even when memory is close to full, there are at most 60 retries per allocation request, with roughly 0.5\ms\ per retry. This confirms that our design of avoiding hash overflows at allocation time is practical. %co-design of overflow-free hash-based page table and allocation retry scheme is practical. \ulinebfpara{Close look at \sysboard{} components.} To further understand \sys's performance, % and to determine the reason for worse large-read performance, we profile different parts of \sys's processing for read and write of 4\,B to 1\KB. \syslib\ adds a very small overhead (250\ns\ in total), thanks to our efficient threading model and network stack implementation. Figure~\ref{fig-lat-break} shows the latency breakdown at \sysboard. Time to fetch data from DRAM (DDRAccess) and to transfer it over the wire (WireDelay) are the main contributor to read latency, especially with large read size. Both could be largely improved in a real \sysboard\ with better memory controller and higher frequency. TLB miss (which takes one DRAM read) is the other main part of the latencies. \subsection{Application Performance} \ulinebfpara{Image Compression.} We run a workload where each client compresses and decompresses 1000 256*256-pixel images with increasing number of concurrently running clients. Figure~\ref{fig-photo} shows the total runtime per client. We compare \sys\ with RDMA, with both performing computation at the \CN\ side and the RDMA using one-sided operations instead of \sys\ APIs to read/write images in remote memory. \sys's performance stays the same as the number of clients increase. RDMA's performance does not scale because it requires each client to register a different MR to have protected memory accesses. With more MRs, RDMA runs into the case where the RNIC cannot hold all the MR metadata and many accesses would involve a slow read to host main memory. \ulinebfpara{Radix Tree.} Figure~\ref{fig-radix} shows the latency of searching a key in pre-populated radix trees when varying the tree size. We again compare with RDMA which uses one-sided read operations to perform the tree traversal task. RDMA's performance is worse than \sys, because it requires multiple RTTs to traverse the tree, while \sys\ only needs one RTT for each pointer chasing (each tree level). In addition, RDMA also scales worse than \sys. \ulinebfpara{Key-value store.} Figure~\ref{fig-kvstore} evaluates \syskv\ using the YCSB benchmark~\cite{YCSB} and compares it to Clover, HERD, and HERD-BF. We run two \CN{}s and 8 threads per \CN. We use 100K key-value entries and run 100K operations per test, with YCSB's default key-value size of 1\KB. %where the key size is 8 bytes and the value size is 1\KB. The accesses to keys follow the Zipf distribution ($\theta=0.99$). We use three YCSB workloads with different {\em get-set} ratios: 100\% {\em get} (workload C), 5\% {\em set} (B), and 50\% {\em set} (A). \syskv\ performs the best. HERD running on BlueField performs the worst, mainly because BlueField's slower crossing between its NIC chip and ARM chip. Figures~\ref{fig-ycsb-mn} shows the throughput of \syskv\ when varying the number of MNs. Similar to our \sys\ scalability results, \syskv\ can reach a CN’s maximum throughput and can handle concurrent get/set requests even under contention. These results are similar to or better than previous FPGA-based and RDMA-based key-value stores that are fine-tuned for just key-value workloads (Table 3 in \cite{KVDIRECT}), while we got our results without any performance tuning. \ulinebfpara{Multi-version data store.} %\subsubsection{Multi-Version Data Store} We evaluate \sysmv\ by varying the number of \CN{}s that concurrently access data objects (of 16\,B) on an \MN\ using workloads of 50\% read (of different versions) and 50\% write under uniform and Zipf distribution of objects (Figure~\ref{fig-mvstore}). \sysmv's read and write have the same performance, and reading any version has the same performance, since we use an array-based version design. %Running multiple \MN{}s have similar performance and we omit for space. \ulinebfpara{Data analytics.} We run a simple workload which first \texttt{select} rows in a table whose field-A matches a value (\eg, gender is female) and calculate \texttt{avg} of field-B (\eg, final score) of all the rows. Finally, it calculates the histogram of the selected rows (\eg, score distribution), which can be presented to the user together with the avg value. %(\eg, how female students' scores compare to the whole class). \sys\ executes the first two steps at \MN\ offloads and the final step at \CN, while RDMA always reads rows to \CN\ and then does each operation. Figure~\ref{fig-dataframe} plots the total run time as the select ratio decreases (fewer rows selected). % When the select ratio is high, \sys\ and RDMA send a similar amount of data across the network, % and as the CPU computation is faster than our FPGA implementation for these operations, \sys's overall performance is worse than RDMA. When the select ratio is low, \sys\ transfers much less data than RDMA, resulting in its better performance. %To put \sys\ in respective with other existing RDMA-based and FPGA-based key-value stores that we couldn't directly compare with (\eg, close-sourced), we compare %\syskv's latency results with reported latencies in ~\cite{KVDIRECT}. %\syskv\ has {\bf lower end-to-end latency than all these existing systems}. %then sends the data to \CN, which shuffles the data and sends the shuffled %data back to \MN\ for aggregation. \subsection{CapEx, Energy, and FPGA Utilization} \label{sec:clio:results-cost} We estimate the cost of server and \sysboard\ using market prices of different hardware units. When using 1\TB\ DRAM, a server-based \MN\ costs 1.1-1.5\x\ and consumes 1.9-2.7\x\ power compared to \sysboard. These numbers become 1.4-2.5\x\ and 5.1-8.6\x\ with OptaneDimm~\cite{optane-dcpm}, which we expect to be the more likely remote memory media in future systems. We measure the total energy used for running YCSB workloads by collecting the total CPU (or FPGA) cycles and the Watt of a CPU core~\cite{gold5128}, ARM processor~\cite{armpower}, and FPGA (measured). We omit the energy used by DRAM and NICs in all the calculations. Clover, a system that centers its design around low cost, has slightly higher energy than \sys. Even though there is no processing at \MN{}s for Clover, its \CN{}s use more cycles to process and manage memory. HERD consumes 1.6\x\ to 3\x\ more energy than \sys, mainly because of its CPU overhead at \MN{}s. Surprisingly, HERD-BF consumes the most energy, even though it is a low-power ARM-based SmartNIC. This is because of its worse performance and longer total runtime. Figure~\ref{fig-fpga-resource} compares the FPGA utilization among Clio, StRoM's RoCEv2~\cite{StRoM}, and Tonic's selective ack stack~\cite{TONIC}. %With our design that is tailored to save resources, %\sys\ consumes roughly one third of the total resources. Both StRoM and Tonic include only a network stack but they consume more resources than \sys. Within \sys, the virtual memory (VirtMem) and the network stack (NetStack) consume a small fraction of the total resources, with the rest being vendor IPs (PHY, MAC, DDR4, and interconnect). %To put things in perspective, we implement a Go-back-N network stack which supports 1K connections. It uses 2.5\x\ more logic than what our current network stack consumes. Overall, our efficient hardware implementation leaves most FPGA resources available for application offloads.
If $f$ is a complex power series such that $f(z) \neq 0$ for all $z$ with $|z| < r$, then the radius of convergence of $f^{-1}$ is at least $\min(r, \text{radius of convergence of } f)$. Moreover, if $|z| < \text{radius of convergence of } f$ and $|z| < r$, then $f^{-1}(z) = 1/f(z)$.
// Copyright (c) 2005 - 2015 Marc de Kamps // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> #include <TwoDLib.hpp> #include <vector> #include <iostream> using namespace std; using namespace TwoDLib; BOOST_AUTO_TEST_CASE(CellCreationTest) { vector<double> vec_v(4); vector<double> vec_w(4); vec_v[0] = 0.; vec_v[1] = 1.; vec_v[2] = 1.; vec_v[3] = 0.; vec_w[0] = 0.; vec_w[1] = 0.; vec_w[2] = 1.; vec_w[3] = 1.; Quadrilateral quad(vec_v, vec_w); BOOST_REQUIRE( quad.SignedArea() == 1); BOOST_REQUIRE( quad.IsClockwise() == -1); vec_v[0] = 0.; vec_v[1] = 0.; vec_v[2] = 1.; vec_v[3] = 1.; vec_w[0] = 0.; vec_w[1] = 1.; vec_w[2] = 1.; vec_w[3] = 0.; Quadrilateral quad2(vec_v, vec_w); BOOST_REQUIRE( quad2.SignedArea() == -1); BOOST_REQUIRE( quad2.IsClockwise() == 1); } BOOST_AUTO_TEST_CASE(InsideClockWise){ vector<double> vec_v(4); vector<double> vec_w(4); vec_v[0] = 0.; vec_v[1] = 0.; vec_v[2] = 1.; vec_v[3] = 1.; vec_w[0] = 0.; vec_w[1] = 1.; vec_w[2] = 1.; vec_w[3] = 0.; Quadrilateral quad(vec_v, vec_w); Point p(0.5,0.5); BOOST_REQUIRE( quad.IsInside(p) == true ); Point p1(-0.5,0.5); BOOST_REQUIRE(quad.IsInside(p1) == false); Point p2(0.5,1.5); BOOST_REQUIRE(quad.IsInside(p2) == false); Point p3(1.5,0.5); BOOST_REQUIRE(quad.IsInside(p3) == false); Point p4(0.5,-0.5); BOOST_REQUIRE(quad.IsInside(p4) == false); } BOOST_AUTO_TEST_CASE(InsideAntiClockWise){ vector<double> vec_v(4); vector<double> vec_w(4); vec_v[0] = 0.; vec_v[1] = 1.; vec_v[2] = 1.; vec_v[3] = 0.; vec_w[0] = 0.; vec_w[1] = 0.; vec_w[2] = 1.; vec_w[3] = 1.; Quadrilateral quad(vec_v, vec_w); Point p(0.5,0.5); BOOST_REQUIRE( quad.IsInside(p) == true ); Point p1(-0.5,0.5); BOOST_REQUIRE(quad.IsInside(p1) == false); Point p2(0.5,1.5); BOOST_REQUIRE(quad.IsInside(p2) == false); Point p3(1.5,0.5); BOOST_REQUIRE(quad.IsInside(p3) == false); Point p4(0.5,-0.5); BOOST_REQUIRE(quad.IsInside(p4) == false); } BOOST_AUTO_TEST_CASE(InsideConcave){ vector<double> vec_v(4); vector<double> vec_w(4); vec_v[0] = -1.; vec_v[1] = 0.; vec_v[2] = 1.; vec_v[3] = 0.; vec_w[0] = -0.5; vec_w[1] = 0.; vec_w[2] = -0.5; vec_w[3] = 1.; Quadrilateral quad(vec_v, vec_w); Point p(0.0,0.5); BOOST_REQUIRE( quad.IsInside(p) == true ); Point p1(-1.,0.); BOOST_REQUIRE(quad.IsInside(p1) == false); Point p2( 1.,0.); BOOST_REQUIRE(quad.IsInside(p2) == false); Point p3(0.,-0.1); BOOST_REQUIRE(quad.IsInside(p3) == false); Point p4(0., 1.1); BOOST_REQUIRE(quad.IsInside(p4) == false); } BOOST_AUTO_TEST_CASE(Split){ vector<double> v(Quadrilateral::_nr_points); v[0] = 0; v[1] = 1; v[2] = 0; v[3] = -1; vector<double> w(Quadrilateral::_nr_points); w[0] = 0; w[1] = -0.5; w[2] = 1.0; w[3] = -0.5; Quadrilateral quad(v,w); pair<Triangle,Triangle> ts = quad.Split(); Triangle t1 = ts.first; Point p1 = t1.Points()[0]; Point p2 = t1.Points()[1]; Point p3 = t1.Points()[2]; BOOST_REQUIRE( p1[0] == 0 && p1[1] == 0); BOOST_REQUIRE( p2[0] == 0 && p2[1] == 1); BOOST_REQUIRE( p3[0] == 1 && p3[1] == -0.5); Triangle t2 = ts.second; p1 = t2.Points()[0]; p2 = t2.Points()[1]; p3 = t2.Points()[2]; BOOST_REQUIRE( p1[0] == 0 && p1[1] == 0); BOOST_REQUIRE( p2[0] == 0 && p2[1] == 1); BOOST_REQUIRE( p3[0] == -1 && p3[1] == -0.5); // Now rotate the points. Same triangles should be produced v[1] = 0; v[2] = 1; v[3] = 0; v[0] = -1; w[1] = 0; w[2] = -0.5; w[3] = 1.0; w[0] = -0.5; Quadrilateral quad2(v,w); pair<Triangle,Triangle> ts2 = quad2.Split(); Triangle t3 = ts2.first; p1 = t3.Points()[0]; p2 = t3.Points()[1]; p3 = t3.Points()[2]; BOOST_REQUIRE( p1[0] == 0 && p1[1] == 0); BOOST_REQUIRE( p2[0] == 0 && p2[1] == 1); BOOST_REQUIRE( p3[0] == -1 && p3[1] == -0.5); Triangle t4 = ts2.second; p1 = t4.Points()[0]; p2 = t4.Points()[1]; p3 = t4.Points()[2]; BOOST_REQUIRE( p1[0] == 0 && p1[1] == 0); BOOST_REQUIRE( p2[0] == 0 && p2[1] == 1); BOOST_REQUIRE( p3[0] == 1 && p3[1] == -0.5); } BOOST_AUTO_TEST_CASE(CentroidTest){ vector<double> vec_v(4); vector<double> vec_w(4); vec_v[0] = 0.; vec_v[1] = 0.; vec_v[2] = 1.; vec_v[3] = 1.; vec_w[0] = 0.; vec_w[1] = 1.; vec_w[2] = 1.; vec_w[3] = 0.; Quadrilateral quad(vec_v, vec_w); Point centre = quad.Centroid(); BOOST_REQUIRE(centre[0] == 0.5); BOOST_REQUIRE(centre[1] == 0.5); }
Cel-Sci market cap history and chart from 2006 to 2018. Market capitalization (or market value) is the most commonly used method of measuring the size of a publicly traded company and is calculated by multiplying the current stock price by the number of diluted shares outstanding. Cel-Sci market cap as of April 19, 2019 is $0.2B.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* 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 Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V6.1 *) (* Oct 1st 1996 *) (* *) (****************************************************************************) (* Group.v *) (****************************************************************************) Require Export Monoid. Set Implicit Arguments. Unset Strict Implicit. (* The Type of Groups *) Section group_laws. Variable A : Monoid. Definition Inverses_rel (x y : A) := x +_M y =_S Munit A. Variable inv : Map A A. Definition Group_invl := forall x : A, Inverses_rel (inv x) x. Definition Group_invr := forall x : A, Inverses_rel x (inv x). End group_laws. Structure Group : Type := {Gmon :> Monoid; Ginv : Map Gmon Gmon; Prf_ginv_l : Group_invl Ginv; Prf_ginv_r : Group_invr Ginv}.
setwd(file.path(Sys.getenv("MESSAGE_IX_PATH"), "tutorial")) suppressPackageStartupMessages(library(optparse, quietly=TRUE)) # cli option_list = list( make_option(c("--props"), type="character", help=paste("testdb props path"), metavar="character") ); opt_parser = OptionParser(option_list=option_list); opt = parse_args(opt_parser); source(file.path(Sys.getenv("IXMP_R_PATH"), "ixmp.R")) mp = ixPlatform(dbprops=opt$props) # test not message model <- "canning problem" scenario <- "standard" scen <- mp$Scenario(model, scenario) scen$check_out() scen$init_var('z', NULL, NULL) scen$commit('foo') scen$solve(model='transport_ixmp') stopifnot(scen$var('z')['level'] == 153.675)
The standard 18-hole walking rates are €40 on weekdays, €48 on weekends (carts are €15). Junior and 9-hole rates are offered, as are season passes. Hole measurements are in meters.
= = Final years , abolition , and collecting = =
module Ensembles export Ensemble, workheatlist, erasure_rate, loadparas, save_ensemble, load_ensemble import YAML import Base.+ import JLD2 using ..Force using ..UpdateMethods using ..Configurations using ..Trajectories: lastx struct Ensemble{T <: AbstractForce} nsample :: Integer force :: T heun :: Heun initlist :: Vector{<:AbstractFloat} configurations :: Vector{Configuration} end function +(e1::Ensemble{T}, e2::Ensemble{T}) where T @assert e1.force == e2.force @assert e1.heun == e2.heun Ensemble( e1.nsample + e2.nsample, e1.force, e1.heun, [e1.initlist; e2.initlist], [e1.configurations; e2.configurations] ) end function load_ens(files::Vector{String})::Ensemble sum(load_configuration(f) for f in files) end function workheatlist(ens::Ensemble) worklist = [conf.workheat.work for conf in ens.configurations] heatlist = [conf.workheat.heat for conf in ens.configurations] return worklist, heatlist end function erasure_rate end function erasure_rate(ens::Ensemble)::Real endlist = [lastx(conf.traj) for conf in ens.configurations] erased_num = (x->erased(ens.force, x)).(endlist) |> sum erased_num / ens.nsample end function loadparas(filename="para.yml") paras = nothing open(filename) do file paras = YAML.load(file) end paras end function save_ensemble(ens::Ensemble, filename) @JLD2.save filename ens end function load_ensemble(filename)::Ensemble @JLD2.load filename ens return ens end end
Brenda Pressley, a native of Columbia, South Carolina, has performed in virtually every facet of the entertainment industry. The daughter of Arzelle C. Pressley and the late Bowen W. Pressley, she has credited her success to the unwavering support and guidance of her family, friends, and teachers. Thanks to this support system Brenda has never lost sight of her dreams. An Eau Claire High School graduate, she became interested in a theatrical career while attending the University of South Carolina. Brenda participated in the university’s production of Purlie, Sweet Charity, and Hair. Her summers were spent working in professional dinner theater and summer stock. In 1979, Brenda moved to New York City, where she was cast in And Still I Rise, written and directed by Maya Angelou. By 1988, she was a recipient of the George London Grant which is awarded to accomplished performing artists. Pressley has appeared on Broadway in the original company of Dreamgirls, directed by the theatrical legend Michael Bennett. She was also cast in the long running blockbuster Cats and The Moony Shapiro Songbook. Off-Broadway credits include productions of Marvin’s Room, Blues In The Night, and And The World Goes ‘Round – The Songs of Kander and Ebb for which she received a 1991 Outer Critics Circle Award. For the latter production, Brenda can be heard on the RCA Victor original cast recording. In regional theaters, she starred in the world premiere of The Old Settler at the McCarter Theater and again at the Freedom Theater where her performance garnered the 2000 Barymore Award for Best Actress. Additional productions for Pressley include roles in Jar The Floor at Syracuse Stage, Blues For An Alabama Sky at The Old Globe Theater and Cincinnati Playhouse. On television, Brenda co-starred with Oprah Winfrey in the ABC series Brewster Place. Other credits include parts in Law & Order, Law & Order: Special Victims Unit, Headlines, New York Undercover, Educating Matt Waters, HBO Life Stories, Daddy’s Girl, Here and Now, Ghostwriter, All My Children, Loving, and One Life To Live. She has been featured in national and regional commercials. Film credits, for Pressley, include scenes in Cradle Will Rock, written and directed by Tim Robbins; Twisted; and It Could Happen To You.
[STATEMENT] lemma after_summary_Sum_fun: "finite MM \<Longrightarrow> after_summary (\<Sum>M\<in>MM. f M) A = (\<Sum>M\<in>MM. after_summary (f M) A)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. finite MM \<Longrightarrow> after_summary (sum f MM) A = (\<Sum>M\<in>MM. after_summary (f M) A) [PROOF STEP] by (induct MM rule: finite_induct) (auto simp: after_summary_union)
[GOAL] α : Type u β : Type v γ : Type w p : α → Prop a : α l : List α x✝ : ∃ x, x ∈ a :: l ∧ p x x : α h : x ∈ a :: l px : p x ⊢ p a ∨ ∃ x, x ∈ l ∧ p x [PROOFSTEP] simp only [find?, mem_cons] at h [GOAL] α : Type u β : Type v γ : Type w p : α → Prop a : α l : List α x✝ : ∃ x, x ∈ a :: l ∧ p x x : α px : p x h : x = a ∨ x ∈ l ⊢ p a ∨ ∃ x, x ∈ l ∧ p x [PROOFSTEP] cases' h with h h [GOAL] case inl α : Type u β : Type v γ : Type w p : α → Prop a : α l : List α x✝ : ∃ x, x ∈ a :: l ∧ p x x : α px : p x h : x = a ⊢ p a ∨ ∃ x, x ∈ l ∧ p x [PROOFSTEP] cases h [GOAL] case inl.refl α : Type u β : Type v γ : Type w p : α → Prop a : α l : List α x✝ : ∃ x, x ∈ a :: l ∧ p x px : p a ⊢ p a ∨ ∃ x, x ∈ l ∧ p x [PROOFSTEP] exact Or.inl px [GOAL] case inr α : Type u β : Type v γ : Type w p : α → Prop a : α l : List α x✝ : ∃ x, x ∈ a :: l ∧ p x x : α px : p x h : x ∈ l ⊢ p a ∨ ∃ x, x ∈ l ∧ p x [PROOFSTEP] exact Or.inr ⟨x, h, px⟩
```python # Required to load webpages from IPython.display import IFrame ``` [Table of contents](../toc.ipynb) # SciPy * Scipy extends numpy with powerful modules in * optimization, * interpolation, * linear algebra, * fourier transformation, * signal processing, * image processing, * file input output, and many more. * Please find here the scipy reference for a complete feature list [https://docs.scipy.org/doc/scipy/reference/](https://docs.scipy.org/doc/scipy/reference/). We will take a look at some features of scipy in the latter. Please explore the rich content of this package later on. ## Optimization * Scipy's optimization module provides many optimization methods like least squares, gradient methods, BFGS, global optimization, and many more. * Please find a detailed tutorial here [https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html](https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html). * Next, we will apply one of the optimization algorithms in a simple example. A common function to test optimization algorithms is the Rosenbrock function for $N$ variables: $f(\boldsymbol{x}) = \sum\limits_{i=2}^N 100 \left(x_{i+1} - x_i^2\right)^2 + \left(1 - x_i^2 \right)^2$. The optimum is at $x_i=1$, where $f(\boldsymbol{x})=0$ ```python import numpy as np from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt from matplotlib import cm %matplotlib inline ``` ```python def rosen(x): """The Rosenbrock function""" return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1]**2.0)**2.0) ``` We need to generate some data in a mesh grid. ```python X = np.arange(-2, 2, 0.2) Y = np.arange(-2, 2, 0.2) X, Y = np.meshgrid(X, Y) data = np.vstack([X.reshape(X.size), Y.reshape(Y.size)]) ``` Let's evaluate the Rosenbrock function at the grid points. ```python Z = rosen(data) ``` And we will plot the function in a 3D plot. ```python fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_surface(X, Y, Z.reshape(X.shape), cmap='bwr') ax.view_init(40, 230) ``` Now, let us check that the true minimum value is at (1, 1). ```python rosen(np.array([1, 1])) ``` 0.0 Finally, we will call scipy optimize and find the minimum with Nelder Mead algorithm. ```python from scipy.optimize import minimize x0 = np.array([1.3, 0.7]) res = minimize(rosen, x0, method='nelder-mead', options={'xatol': 1e-8, 'disp': True}) print(res.x) ``` Optimization terminated successfully. Current function value: 0.000000 Iterations: 72 Function evaluations: 142 [1. 1.] Many more optimization examples are to find in scipy optimize tutorial [https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html](https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html). ```python IFrame(src='https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html', width=1000, height=600) ``` ## Interpolation * Interpolation of data is very often required, for instance to replace NaNs or to fill missing values in data records. * Scipy comes with * 1D interpolation, * multivariate data interpolation * spline, and * radial basis function interpolation. * Please find here the link to interpolation tutorials [https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html](https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html). ```python from scipy.interpolate import interp1d x = np.linspace(10, 20, 15) y = np.sin(x) + np.cos(x**2 / 10) f = interp1d(x, y, kind="linear") f1 = interp1d(x, y, kind="cubic") ``` ```python x_fine = np.linspace(10, 20, 200) plt.plot(x, y, 'ko', x_fine, f(x_fine), 'b--', x_fine, f1(x_fine), 'r--') plt.legend(["Data", "Linear", "Cubic"]) plt.show() ``` ## Signal processing The signal processing module is very powerful and we will have a look at its tutorial [https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html](https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html) for a quick overview. ```python IFrame(src='https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html', width=1000, height=600) ``` ## Linear algebra * In addition to numpy, scipy has its own linear algebra module. * It offers more functionality than numpy's linear algebra module and is based on BLAS/LAPACK support, which makes it faster. * The respective tutorial is here located [https://docs.scipy.org/doc/scipy/reference/tutorial/linalg.html](https://docs.scipy.org/doc/scipy/reference/tutorial/linalg.html). ```python IFrame(src='https://docs.scipy.org/doc/scipy/reference/tutorial/linalg.html', width=1000, height=600) ``` ### Total least squares as linear algebra application We will now implement a total least squares estimator [[Markovsky2007]](../references.bib) with help of scipy's singular value decomposition (svd). The total least squares estimator provides a solution for the errors in variables problem, where model inputs and outputs are corrupted by noise. The model becomes $A X \approx B$, where $A \in \mathbb{R}^{m \times n}$ and $B \in \mathbb{R}^{m \times d}$ are input and output data, and $X$ is the unknown parameter vector. More specifically, the total least squares regression becomes $\widehat{A}X = \widehat{B}$, $\widehat{A} := A + \Delta A$, $\widehat{B} := B + \Delta B$. The estimator can be written as pseudo code as follows. $C = [A B] = U \Sigma V^\top$, where $U \Sigma V^\top$ is the svd of $C$. $V:= \left[\begin{align}V_{11} &V_{12} \\ V_{21} & V_{22}\end{align}\right]$, $\widehat{X} = -V_{12} V_{22}^{-1}$. In Python, the implementation could be like this function. ```python from scipy import linalg def tls(A, B): m, n = A.shape C = np.hstack((A, B)) U, S, V = linalg.svd(C) V12 = V.T[0:n, n:] V22 = V.T[n:, n:] X = -V12 / V22 return X ``` Now we create some data where input and output are appended with noise. ```python A = np.random.rand(100, 2) X = np.array([[3], [-7]]) B = A @ X A += np.random.randn(100, 2) * 0.1 B += np.random.randn(100, 1) * 0.1 ``` The total least squares solution becomes ```python tls(A, B) ``` array([[ 2.84623341], [-6.99453565]]) And this solution is closer to correct value $X = [3 , -7]^\top$ than ordinary least squares. ```python linalg.solve((A.T @ A), (A.T @ B)) ``` array([[ 2.36782022], [-6.38173796]]) Finally, next function shows a "self" written least squares estimator, which uses QR decomposition and back substitution. This implementation is numerically robust in contrast to normal equations $A ^\top A X = A^\top B$. Please find more explanation in [[Golub2013]](../references.bib) and in section 3.11 of [[Burg2012]](../references.bib). ```python def ls(A, B): Q, R = linalg.qr(A, mode="economic") z = Q.T @ B return linalg.solve_triangular(R, z) ``` ```python ls(A, B) ``` array([[ 2.36782022], [-6.38173796]]) ## Integration * Scipy's integration can be used for general equations as well as for ordinary differential equations. * The integration tutorial is linked here [https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html](https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html). ### Solving a differential equation Here, we want to use an ode solver to simulate the differential equation (ode) $y'' + y' + 4 y = 0$. To evaluate this second order ode, we need to convert it into a set of first order ode. The trick is to use this substitution: $x_0 = y$, $x_1 = y'$, which yields $\begin{align} x'_0 &= x_1 \\ x'_1 &= -4 x_0 - x_1 \end{align}$ The implementation in Python becomes. ```python def equation(t, x): return [x[1], -4 * x[0] - x[1]] ``` ```python from scipy.integrate import solve_ivp ``` ```python time_span = [0, 20] init = [1, 0] time = np.arange(0, 20, 0.01) sol = solve_ivp(equation, time_span, init, t_eval=time) ``` ```python plt.plot(time, sol.y[0, :]) plt.plot(time, sol.y[1, :]) plt.legend(["$y$", "$y'$"]) plt.xlabel("Time") plt.show() ```
\section{Conclusion}\label{sec:concl} We have proposed a new OpenMath JSON encoding that facilitates the content-oriented communication of mathematical objects and formulae in the web applications and web services area. Our encoding combines the advantages of existing approaches, alleviates their problems, and enables validation via a JSON schema we provide. To support development with the new encoding, we supply a JSON validation service and a JSON/XML encoding translation service. In the future we hope that the OpenMath Society will canonicalize a JSON encoding for OpenMath using our proposal as a basis. \paragraph*{Acknowledgements} The authors gratefully acknowledge fruitful discussions with the OpenMath Community. The work reported here was supported by the OpenDreamKit Horizon 2020 European Research Infrastructures project (\#676541) and DFG project RA-18723-1 OAF. %%% Local Variables: %%% mode: latex %%% TeX-master: "paper" %%% End: % LocalWords: sec:concl canonicalize
module Data.Linear.Vector import public Data.Fin import Data.IOArray.Prims %default total unsafePrimIO : PrimIO a -> a unsafePrimIO = unsafePerformIO . primIO export data Vector : Nat -> Type -> Type where UnsafeFromPrimArray : ArrayData a -> Vector n a export newVector : {n : Nat} -> a -> Vector n a newVector x = UnsafeFromPrimArray . unsafePrimIO $ prim__newArray (cast n) x export readVector : Vector n a -> Fin n -> a readVector (UnsafeFromPrimArray xs) i = unsafePrimIO $ prim__arrayGet xs (cast (finToNat i)) public export interface LVector (f : Nat -> Type -> Type) where withVector : {n : Nat} -> a -> (1 _ : ((1 _ : f n a) -> b)) -> b read : (1 _ : f n a) -> Fin n -> Res a (const (f n a)) write : (1 _ : f n a) -> Fin n -> a -> f n a modify : (1 _ : f n a) -> Fin n -> (a -> a) -> f n a export LVector Vector where withVector x f = let xs := unsafePrimIO $ prim__newArray (cast n) x in f $ UnsafeFromPrimArray xs read (UnsafeFromPrimArray xs) i = unsafePrimIO (prim__arrayGet xs (cast (finToNat i))) # UnsafeFromPrimArray xs write (UnsafeFromPrimArray xs) i x = unsafePrimIO $ prim__arraySet xs (cast (finToNat i)) x `prim__io_bind` const (prim__io_pure (UnsafeFromPrimArray xs)) modify (UnsafeFromPrimArray xs) i f = let i' := cast (finToNat i) in unsafePrimIO $ (prim__arrayGet xs i' `prim__io_bind` prim__arraySet xs i' . f) `prim__io_bind` const (prim__io_pure (UnsafeFromPrimArray xs))
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import analysis.specific_limits.basic import topology.metric_space.isometry import topology.instances.ennreal /-! # Hausdorff distance The Hausdorff distance on subsets of a metric (or emetric) space. Given two subsets `s` and `t` of a metric space, their Hausdorff distance is the smallest `d` such that any point `s` is within `d` of a point in `t`, and conversely. This quantity is often infinite (think of `s` bounded and `t` unbounded), and therefore better expressed in the setting of emetric spaces. ## Main definitions This files introduces: * `inf_edist x s`, the infimum edistance of a point `x` to a set `s` in an emetric space * `Hausdorff_edist s t`, the Hausdorff edistance of two sets in an emetric space * Versions of these notions on metric spaces, called respectively `inf_dist` and `Hausdorff_dist` * `thickening δ s`, the open thickening by radius `δ` of a set `s` in a pseudo emetric space. * `cthickening δ s`, the closed thickening by radius `δ` of a set `s` in a pseudo emetric space. -/ noncomputable theory open_locale classical nnreal ennreal topological_space universes u v w open classical set function topological_space filter namespace emetric section inf_edist variables {α : Type u} {β : Type v} [pseudo_emetric_space α] [pseudo_emetric_space β] {x y : α} {s t : set α} {Φ : α → β} /-! ### Distance of a point to a set as a function into `ℝ≥0∞`. -/ /-- The minimal edistance of a point to a set -/ def inf_edist (x : α) (s : set α) : ℝ≥0∞ := ⨅ y ∈ s, edist x y @[simp] lemma inf_edist_empty : inf_edist x ∅ = ∞ := infi_emptyset lemma le_inf_edist {d} : d ≤ inf_edist x s ↔ ∀ y ∈ s, d ≤ edist x y := by simp only [inf_edist, le_infi_iff] /-- The edist to a union is the minimum of the edists -/ @[simp] lemma inf_edist_union : inf_edist x (s ∪ t) = inf_edist x s ⊓ inf_edist x t := infi_union /-- The edist to a singleton is the edistance to the single point of this singleton -/ @[simp] lemma inf_edist_singleton : inf_edist x {y} = edist x y := infi_singleton /-- The edist to a set is bounded above by the edist to any of its points -/ lemma inf_edist_le_edist_of_mem (h : y ∈ s) : inf_edist x s ≤ edist x y := infi₂_le _ h /-- If a point `x` belongs to `s`, then its edist to `s` vanishes -/ lemma inf_edist_zero_of_mem (h : x ∈ s) : inf_edist x s = 0 := nonpos_iff_eq_zero.1 $ @edist_self _ _ x ▸ inf_edist_le_edist_of_mem h /-- The edist is monotonous with respect to inclusion -/ lemma inf_edist_le_inf_edist_of_subset (h : s ⊆ t) : inf_edist x t ≤ inf_edist x s := infi_le_infi_of_subset h /-- The edist to a set is `< r` iff there exists a point in the set at edistance `< r` -/ lemma inf_edist_lt_iff {r : ℝ≥0∞} : inf_edist x s < r ↔ ∃ y ∈ s, edist x y < r := by simp_rw [inf_edist, infi_lt_iff] /-- The edist of `x` to `s` is bounded by the sum of the edist of `y` to `s` and the edist from `x` to `y` -/ lemma inf_edist_le_inf_edist_add_edist : inf_edist x s ≤ inf_edist y s + edist x y := calc (⨅ z ∈ s, edist x z) ≤ ⨅ z ∈ s, edist y z + edist x y : infi₂_mono $ λ z hz, (edist_triangle _ _ _).trans_eq (add_comm _ _) ... = (⨅ z ∈ s, edist y z) + edist x y : by simp only [ennreal.infi_add] /-- The edist to a set depends continuously on the point -/ @[continuity] lemma continuous_inf_edist : continuous (λx, inf_edist x s) := continuous_of_le_add_edist 1 (by simp) $ by simp only [one_mul, inf_edist_le_inf_edist_add_edist, forall_2_true_iff] /-- The edist to a set and to its closure coincide -/ lemma inf_edist_closure : inf_edist x (closure s) = inf_edist x s := begin refine le_antisymm (inf_edist_le_inf_edist_of_subset subset_closure) _, refine ennreal.le_of_forall_pos_le_add (λε εpos h, _), have ε0 : 0 < (ε / 2 : ℝ≥0∞) := by simpa [pos_iff_ne_zero] using εpos, have : inf_edist x (closure s) < inf_edist x (closure s) + ε/2, from ennreal.lt_add_right h.ne ε0.ne', rcases inf_edist_lt_iff.mp this with ⟨y, ycs, hy⟩, -- y : α, ycs : y ∈ closure s, hy : edist x y < inf_edist x (closure s) + ↑ε / 2 rcases emetric.mem_closure_iff.1 ycs (ε/2) ε0 with ⟨z, zs, dyz⟩, -- z : α, zs : z ∈ s, dyz : edist y z < ↑ε / 2 calc inf_edist x s ≤ edist x z : inf_edist_le_edist_of_mem zs ... ≤ edist x y + edist y z : edist_triangle _ _ _ ... ≤ (inf_edist x (closure s) + ε / 2) + (ε/2) : add_le_add (le_of_lt hy) (le_of_lt dyz) ... = inf_edist x (closure s) + ↑ε : by rw [add_assoc, ennreal.add_halves] end /-- A point belongs to the closure of `s` iff its infimum edistance to this set vanishes -/ lemma mem_closure_iff_inf_edist_zero : x ∈ closure s ↔ inf_edist x s = 0 := ⟨λ h, by { rw ← inf_edist_closure, exact inf_edist_zero_of_mem h }, λ h, emetric.mem_closure_iff.2 $ λ ε εpos, inf_edist_lt_iff.mp $ by rwa h⟩ /-- Given a closed set `s`, a point belongs to `s` iff its infimum edistance to this set vanishes -/ lemma mem_iff_inf_edist_zero_of_closed (h : is_closed s) : x ∈ s ↔ inf_edist x s = 0 := begin convert ← mem_closure_iff_inf_edist_zero, exact h.closure_eq end lemma disjoint_closed_ball_of_lt_inf_edist {r : ℝ≥0∞} (h : r < inf_edist x s) : disjoint (closed_ball x r) s := begin rw disjoint_left, assume y hy h'y, apply lt_irrefl (inf_edist x s), calc inf_edist x s ≤ edist x y : inf_edist_le_edist_of_mem h'y ... ≤ r : by rwa [mem_closed_ball, edist_comm] at hy ... < inf_edist x s : h end /-- The infimum edistance is invariant under isometries -/ lemma inf_edist_image (hΦ : isometry Φ) : inf_edist (Φ x) (Φ '' t) = inf_edist x t := by simp only [inf_edist, infi_image, hΦ.edist_eq] lemma _root_.is_open.exists_Union_is_closed {U : set α} (hU : is_open U) : ∃ F : ℕ → set α, (∀ n, is_closed (F n)) ∧ (∀ n, F n ⊆ U) ∧ ((⋃ n, F n) = U) ∧ monotone F := begin obtain ⟨a, a_pos, a_lt_one⟩ : ∃ (a : ℝ≥0∞), 0 < a ∧ a < 1 := exists_between (ennreal.zero_lt_one), let F := λ (n : ℕ), (λ x, inf_edist x Uᶜ) ⁻¹' (Ici (a^n)), have F_subset : ∀ n, F n ⊆ U, { assume n x hx, have : inf_edist x Uᶜ ≠ 0 := ((ennreal.pow_pos a_pos _).trans_le hx).ne', contrapose! this, exact inf_edist_zero_of_mem this }, refine ⟨F, λ n, is_closed.preimage continuous_inf_edist is_closed_Ici, F_subset, _, _⟩, show monotone F, { assume m n hmn x hx, simp only [mem_Ici, mem_preimage] at hx ⊢, apply le_trans (ennreal.pow_le_pow_of_le_one a_lt_one.le hmn) hx }, show (⋃ n, F n) = U, { refine subset.antisymm (by simp only [Union_subset_iff, F_subset, forall_const]) (λ x hx, _), have : ¬(x ∈ Uᶜ), by simpa using hx, rw mem_iff_inf_edist_zero_of_closed hU.is_closed_compl at this, have B : 0 < inf_edist x Uᶜ, by simpa [pos_iff_ne_zero] using this, have : filter.tendsto (λ n, a^n) at_top (𝓝 0) := ennreal.tendsto_pow_at_top_nhds_0_of_lt_1 a_lt_one, rcases ((tendsto_order.1 this).2 _ B).exists with ⟨n, hn⟩, simp only [mem_Union, mem_Ici, mem_preimage], exact ⟨n, hn.le⟩ }, end lemma _root_.is_compact.exists_inf_edist_eq_edist (hs : is_compact s) (hne : s.nonempty) (x : α) : ∃ y ∈ s, inf_edist x s = edist x y := begin have A : continuous (λ y, edist x y) := continuous_const.edist continuous_id, obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, ∀ z, z ∈ s → edist x y ≤ edist x z := hs.exists_forall_le hne A.continuous_on, exact ⟨y, ys, le_antisymm (inf_edist_le_edist_of_mem ys) (by rwa le_inf_edist)⟩ end end inf_edist --section /-! ### The Hausdorff distance as a function into `ℝ≥0∞`. -/ /-- The Hausdorff edistance between two sets is the smallest `r` such that each set is contained in the `r`-neighborhood of the other one -/ @[irreducible] def Hausdorff_edist {α : Type u} [pseudo_emetric_space α] (s t : set α) : ℝ≥0∞ := (⨆ x ∈ s, inf_edist x t) ⊔ (⨆ y ∈ t, inf_edist y s) lemma Hausdorff_edist_def {α : Type u} [pseudo_emetric_space α] (s t : set α) : Hausdorff_edist s t = (⨆ x ∈ s, inf_edist x t) ⊔ (⨆ y ∈ t, inf_edist y s) := by rw Hausdorff_edist section Hausdorff_edist variables {α : Type u} {β : Type v} [pseudo_emetric_space α] [pseudo_emetric_space β] {x y : α} {s t u : set α} {Φ : α → β} /-- The Hausdorff edistance of a set to itself vanishes -/ @[simp] lemma Hausdorff_edist_self : Hausdorff_edist s s = 0 := begin simp only [Hausdorff_edist_def, sup_idem, ennreal.supr_eq_zero], exact λ x hx, inf_edist_zero_of_mem hx end /-- The Haudorff edistances of `s` to `t` and of `t` to `s` coincide -/ lemma Hausdorff_edist_comm : Hausdorff_edist s t = Hausdorff_edist t s := by unfold Hausdorff_edist; apply sup_comm /-- Bounding the Hausdorff edistance by bounding the edistance of any point in each set to the other set -/ lemma Hausdorff_edist_le_of_inf_edist {r : ℝ≥0∞} (H1 : ∀x ∈ s, inf_edist x t ≤ r) (H2 : ∀x ∈ t, inf_edist x s ≤ r) : Hausdorff_edist s t ≤ r := begin simp only [Hausdorff_edist, sup_le_iff, supr_le_iff], exact ⟨H1, H2⟩ end /-- Bounding the Hausdorff edistance by exhibiting, for any point in each set, another point in the other set at controlled distance -/ lemma Hausdorff_edist_le_of_mem_edist {r : ℝ≥0∞} (H1 : ∀x ∈ s, ∃y ∈ t, edist x y ≤ r) (H2 : ∀x ∈ t, ∃y ∈ s, edist x y ≤ r) : Hausdorff_edist s t ≤ r := begin refine Hausdorff_edist_le_of_inf_edist _ _, { assume x xs, rcases H1 x xs with ⟨y, yt, hy⟩, exact le_trans (inf_edist_le_edist_of_mem yt) hy }, { assume x xt, rcases H2 x xt with ⟨y, ys, hy⟩, exact le_trans (inf_edist_le_edist_of_mem ys) hy } end /-- The distance to a set is controlled by the Hausdorff distance -/ lemma inf_edist_le_Hausdorff_edist_of_mem (h : x ∈ s) : inf_edist x t ≤ Hausdorff_edist s t := begin rw Hausdorff_edist_def, refine le_trans _ le_sup_left, exact le_supr₂ x h end /-- If the Hausdorff distance is `<r`, then any point in one of the sets has a corresponding point at distance `<r` in the other set -/ lemma exists_edist_lt_of_Hausdorff_edist_lt {r : ℝ≥0∞} (h : x ∈ s) (H : Hausdorff_edist s t < r) : ∃ y ∈ t, edist x y < r := inf_edist_lt_iff.mp $ calc inf_edist x t ≤ Hausdorff_edist s t : inf_edist_le_Hausdorff_edist_of_mem h ... < r : H /-- The distance from `x` to `s` or `t` is controlled in terms of the Hausdorff distance between `s` and `t` -/ lemma inf_edist_le_inf_edist_add_Hausdorff_edist : inf_edist x t ≤ inf_edist x s + Hausdorff_edist s t := ennreal.le_of_forall_pos_le_add $ λε εpos h, begin have ε0 : (ε / 2 : ℝ≥0∞) ≠ 0 := by simpa [pos_iff_ne_zero] using εpos, have : inf_edist x s < inf_edist x s + ε/2 := ennreal.lt_add_right (ennreal.add_lt_top.1 h).1.ne ε0, rcases inf_edist_lt_iff.mp this with ⟨y, ys, dxy⟩, -- y : α, ys : y ∈ s, dxy : edist x y < inf_edist x s + ↑ε / 2 have : Hausdorff_edist s t < Hausdorff_edist s t + ε/2 := ennreal.lt_add_right (ennreal.add_lt_top.1 h).2.ne ε0, rcases exists_edist_lt_of_Hausdorff_edist_lt ys this with ⟨z, zt, dyz⟩, -- z : α, zt : z ∈ t, dyz : edist y z < Hausdorff_edist s t + ↑ε / 2 calc inf_edist x t ≤ edist x z : inf_edist_le_edist_of_mem zt ... ≤ edist x y + edist y z : edist_triangle _ _ _ ... ≤ (inf_edist x s + ε/2) + (Hausdorff_edist s t + ε/2) : add_le_add dxy.le dyz.le ... = inf_edist x s + Hausdorff_edist s t + ε : by simp [ennreal.add_halves, add_comm, add_left_comm] end /-- The Hausdorff edistance is invariant under eisometries -/ lemma Hausdorff_edist_image (h : isometry Φ) : Hausdorff_edist (Φ '' s) (Φ '' t) = Hausdorff_edist s t := by simp only [Hausdorff_edist_def, supr_image, inf_edist_image h] /-- The Hausdorff distance is controlled by the diameter of the union -/ lemma Hausdorff_edist_le_ediam (hs : s.nonempty) (ht : t.nonempty) : Hausdorff_edist s t ≤ diam (s ∪ t) := begin rcases hs with ⟨x, xs⟩, rcases ht with ⟨y, yt⟩, refine Hausdorff_edist_le_of_mem_edist _ _, { intros z hz, exact ⟨y, yt, edist_le_diam_of_mem (subset_union_left _ _ hz) (subset_union_right _ _ yt)⟩ }, { intros z hz, exact ⟨x, xs, edist_le_diam_of_mem (subset_union_right _ _ hz) (subset_union_left _ _ xs)⟩ } end /-- The Hausdorff distance satisfies the triangular inequality -/ lemma Hausdorff_edist_triangle : Hausdorff_edist s u ≤ Hausdorff_edist s t + Hausdorff_edist t u := begin rw Hausdorff_edist_def, simp only [sup_le_iff, supr_le_iff], split, show ∀x ∈ s, inf_edist x u ≤ Hausdorff_edist s t + Hausdorff_edist t u, from λx xs, calc inf_edist x u ≤ inf_edist x t + Hausdorff_edist t u : inf_edist_le_inf_edist_add_Hausdorff_edist ... ≤ Hausdorff_edist s t + Hausdorff_edist t u : add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem xs) _, show ∀x ∈ u, inf_edist x s ≤ Hausdorff_edist s t + Hausdorff_edist t u, from λx xu, calc inf_edist x s ≤ inf_edist x t + Hausdorff_edist t s : inf_edist_le_inf_edist_add_Hausdorff_edist ... ≤ Hausdorff_edist u t + Hausdorff_edist t s : add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem xu) _ ... = Hausdorff_edist s t + Hausdorff_edist t u : by simp [Hausdorff_edist_comm, add_comm] end /-- Two sets are at zero Hausdorff edistance if and only if they have the same closure -/ lemma Hausdorff_edist_zero_iff_closure_eq_closure : Hausdorff_edist s t = 0 ↔ closure s = closure t := calc Hausdorff_edist s t = 0 ↔ s ⊆ closure t ∧ t ⊆ closure s : by simp only [Hausdorff_edist_def, ennreal.sup_eq_zero, ennreal.supr_eq_zero, ← mem_closure_iff_inf_edist_zero, subset_def] ... ↔ closure s = closure t : ⟨λ h, subset.antisymm (closure_minimal h.1 is_closed_closure) (closure_minimal h.2 is_closed_closure), λ h, ⟨h ▸ subset_closure, h.symm ▸ subset_closure⟩⟩ /-- The Hausdorff edistance between a set and its closure vanishes -/ @[simp, priority 1100] lemma Hausdorff_edist_self_closure : Hausdorff_edist s (closure s) = 0 := by rw [Hausdorff_edist_zero_iff_closure_eq_closure, closure_closure] /-- Replacing a set by its closure does not change the Hausdorff edistance. -/ @[simp] lemma Hausdorff_edist_closure₁ : Hausdorff_edist (closure s) t = Hausdorff_edist s t := begin refine le_antisymm _ _, { calc _ ≤ Hausdorff_edist (closure s) s + Hausdorff_edist s t : Hausdorff_edist_triangle ... = Hausdorff_edist s t : by simp [Hausdorff_edist_comm] }, { calc _ ≤ Hausdorff_edist s (closure s) + Hausdorff_edist (closure s) t : Hausdorff_edist_triangle ... = Hausdorff_edist (closure s) t : by simp } end /-- Replacing a set by its closure does not change the Hausdorff edistance. -/ @[simp] lemma Hausdorff_edist_closure₂ : Hausdorff_edist s (closure t) = Hausdorff_edist s t := by simp [@Hausdorff_edist_comm _ _ s _] /-- The Hausdorff edistance between sets or their closures is the same -/ @[simp] lemma Hausdorff_edist_closure : Hausdorff_edist (closure s) (closure t) = Hausdorff_edist s t := by simp /-- Two closed sets are at zero Hausdorff edistance if and only if they coincide -/ lemma Hausdorff_edist_zero_iff_eq_of_closed (hs : is_closed s) (ht : is_closed t) : Hausdorff_edist s t = 0 ↔ s = t := by rw [Hausdorff_edist_zero_iff_closure_eq_closure, hs.closure_eq, ht.closure_eq] /-- The Haudorff edistance to the empty set is infinite -/ lemma Hausdorff_edist_empty (ne : s.nonempty) : Hausdorff_edist s ∅ = ∞ := begin rcases ne with ⟨x, xs⟩, have : inf_edist x ∅ ≤ Hausdorff_edist s ∅ := inf_edist_le_Hausdorff_edist_of_mem xs, simpa using this, end /-- If a set is at finite Hausdorff edistance of a nonempty set, it is nonempty -/ lemma nonempty_of_Hausdorff_edist_ne_top (hs : s.nonempty) (fin : Hausdorff_edist s t ≠ ⊤) : t.nonempty := t.eq_empty_or_nonempty.elim (λ ht, (fin $ ht.symm ▸ Hausdorff_edist_empty hs).elim) id lemma empty_or_nonempty_of_Hausdorff_edist_ne_top (fin : Hausdorff_edist s t ≠ ⊤) : s = ∅ ∧ t = ∅ ∨ s.nonempty ∧ t.nonempty := begin cases s.eq_empty_or_nonempty with hs hs, { cases t.eq_empty_or_nonempty with ht ht, { exact or.inl ⟨hs, ht⟩ }, { rw Hausdorff_edist_comm at fin, exact or.inr ⟨nonempty_of_Hausdorff_edist_ne_top ht fin, ht⟩ } }, { exact or.inr ⟨hs, nonempty_of_Hausdorff_edist_ne_top hs fin⟩ } end end Hausdorff_edist -- section end emetric --namespace /-! Now, we turn to the same notions in metric spaces. To avoid the difficulties related to `Inf` and `Sup` on `ℝ` (which is only conditionally complete), we use the notions in `ℝ≥0∞` formulated in terms of the edistance, and coerce them to `ℝ`. Then their properties follow readily from the corresponding properties in `ℝ≥0∞`, modulo some tedious rewriting of inequalities from one to the other. -/ namespace metric section variables {α : Type u} {β : Type v} [pseudo_metric_space α] [pseudo_metric_space β] {s t u : set α} {x y : α} {Φ : α → β} open emetric /-! ### Distance of a point to a set as a function into `ℝ`. -/ /-- The minimal distance of a point to a set -/ def inf_dist (x : α) (s : set α) : ℝ := ennreal.to_real (inf_edist x s) /-- the minimal distance is always nonnegative -/ lemma inf_dist_nonneg : 0 ≤ inf_dist x s := by simp [inf_dist] /-- the minimal distance to the empty set is 0 (if you want to have the more reasonable value ∞ instead, use `inf_edist`, which takes values in ℝ≥0∞) -/ @[simp] lemma inf_dist_empty : inf_dist x ∅ = 0 := by simp [inf_dist] /-- In a metric space, the minimal edistance to a nonempty set is finite -/ lemma inf_edist_ne_top (h : s.nonempty) : inf_edist x s ≠ ⊤ := begin rcases h with ⟨y, hy⟩, apply lt_top_iff_ne_top.1, calc inf_edist x s ≤ edist x y : inf_edist_le_edist_of_mem hy ... < ⊤ : lt_top_iff_ne_top.2 (edist_ne_top _ _) end /-- The minimal distance of a point to a set containing it vanishes -/ lemma inf_dist_zero_of_mem (h : x ∈ s) : inf_dist x s = 0 := by simp [inf_edist_zero_of_mem h, inf_dist] /-- The minimal distance to a singleton is the distance to the unique point in this singleton -/ @[simp] lemma inf_dist_singleton : inf_dist x {y} = dist x y := by simp [inf_dist, inf_edist, dist_edist] /-- The minimal distance to a set is bounded by the distance to any point in this set -/ lemma inf_dist_le_dist_of_mem (h : y ∈ s) : inf_dist x s ≤ dist x y := begin rw [dist_edist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ⟨_, h⟩) (edist_ne_top _ _)], exact inf_edist_le_edist_of_mem h end /-- The minimal distance is monotonous with respect to inclusion -/ lemma inf_dist_le_inf_dist_of_subset (h : s ⊆ t) (hs : s.nonempty) : inf_dist x t ≤ inf_dist x s := begin have ht : t.nonempty := hs.mono h, rw [inf_dist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ht) (inf_edist_ne_top hs)], exact inf_edist_le_inf_edist_of_subset h end /-- The minimal distance to a set is `< r` iff there exists a point in this set at distance `< r` -/ lemma inf_dist_lt_iff {r : ℝ} (hs : s.nonempty) : inf_dist x s < r ↔ ∃ y ∈ s, dist x y < r := by simp_rw [inf_dist, ← ennreal.lt_of_real_iff_to_real_lt (inf_edist_ne_top hs), inf_edist_lt_iff, ennreal.lt_of_real_iff_to_real_lt (edist_ne_top _ _), ← dist_edist] /-- The minimal distance from `x` to `s` is bounded by the distance from `y` to `s`, modulo the distance between `x` and `y` -/ lemma inf_dist_le_inf_dist_add_dist : inf_dist x s ≤ inf_dist y s + dist x y := begin cases s.eq_empty_or_nonempty with hs hs, { simp [hs, dist_nonneg] }, { rw [inf_dist, inf_dist, dist_edist, ← ennreal.to_real_add (inf_edist_ne_top hs) (edist_ne_top _ _), ennreal.to_real_le_to_real (inf_edist_ne_top hs)], { exact inf_edist_le_inf_edist_add_edist }, { simp [ennreal.add_eq_top, inf_edist_ne_top hs, edist_ne_top] }} end lemma not_mem_of_dist_lt_inf_dist (h : dist x y < inf_dist x s) : y ∉ s := λ hy, h.not_le $ inf_dist_le_dist_of_mem hy lemma disjoint_ball_inf_dist : disjoint (ball x (inf_dist x s)) s := disjoint_left.2 $ λ y hy, not_mem_of_dist_lt_inf_dist $ calc dist x y = dist y x : dist_comm _ _ ... < inf_dist x s : hy lemma disjoint_closed_ball_of_lt_inf_dist {r : ℝ} (h : r < inf_dist x s) : disjoint (closed_ball x r) s := disjoint_ball_inf_dist.mono_left $ closed_ball_subset_ball h variable (s) /-- The minimal distance to a set is Lipschitz in point with constant 1 -/ lemma lipschitz_inf_dist_pt : lipschitz_with 1 (λx, inf_dist x s) := lipschitz_with.of_le_add $ λ x y, inf_dist_le_inf_dist_add_dist /-- The minimal distance to a set is uniformly continuous in point -/ /-- The minimal distance to a set is continuous in point -/ @[continuity] lemma continuous_inf_dist_pt : continuous (λx, inf_dist x s) := (uniform_continuous_inf_dist_pt s).continuous variable {s} /-- The minimal distance to a set and its closure coincide -/ lemma inf_dist_eq_closure : inf_dist x (closure s) = inf_dist x s := by simp [inf_dist, inf_edist_closure] /-- If a point belongs to the closure of `s`, then its infimum distance to `s` equals zero. The converse is true provided that `s` is nonempty, see `mem_closure_iff_inf_dist_zero`. -/ lemma inf_dist_zero_of_mem_closure (hx : x ∈ closure s) : inf_dist x s = 0 := by { rw ← inf_dist_eq_closure, exact inf_dist_zero_of_mem hx } /-- A point belongs to the closure of `s` iff its infimum distance to this set vanishes -/ lemma mem_closure_iff_inf_dist_zero (h : s.nonempty) : x ∈ closure s ↔ inf_dist x s = 0 := by simp [mem_closure_iff_inf_edist_zero, inf_dist, ennreal.to_real_eq_zero_iff, inf_edist_ne_top h] /-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes -/ lemma _root_.is_closed.mem_iff_inf_dist_zero (h : is_closed s) (hs : s.nonempty) : x ∈ s ↔ inf_dist x s = 0 := by rw [←mem_closure_iff_inf_dist_zero hs, h.closure_eq] /-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes -/ lemma _root_.is_closed.not_mem_iff_inf_dist_pos (h : is_closed s) (hs : s.nonempty) : x ∉ s ↔ 0 < inf_dist x s := begin rw ← not_iff_not, push_neg, simp [h.mem_iff_inf_dist_zero hs, le_antisymm_iff, inf_dist_nonneg], end /-- The infimum distance is invariant under isometries -/ lemma inf_dist_image (hΦ : isometry Φ) : inf_dist (Φ x) (Φ '' t) = inf_dist x t := by simp [inf_dist, inf_edist_image hΦ] lemma inf_dist_inter_closed_ball_of_mem (h : y ∈ s) : inf_dist x (s ∩ closed_ball x (dist y x)) = inf_dist x s := begin replace h : y ∈ s ∩ closed_ball x (dist y x) := ⟨h, mem_closed_ball.2 le_rfl⟩, refine le_antisymm _ (inf_dist_le_inf_dist_of_subset (inter_subset_left _ _) ⟨y, h⟩), refine not_lt.1 (λ hlt, _), rcases (inf_dist_lt_iff ⟨y, h.1⟩).mp hlt with ⟨z, hzs, hz⟩, cases le_or_lt (dist z x) (dist y x) with hle hlt, { exact hz.not_le (inf_dist_le_dist_of_mem ⟨hzs, hle⟩) }, { rw [dist_comm z, dist_comm y] at hlt, exact (hlt.trans hz).not_le (inf_dist_le_dist_of_mem h) } end lemma _root_.is_compact.exists_inf_dist_eq_dist (h : is_compact s) (hne : s.nonempty) (x : α) : ∃ y ∈ s, inf_dist x s = dist x y := let ⟨y, hys, hy⟩ := h.exists_inf_edist_eq_edist hne x in ⟨y, hys, by rw [inf_dist, dist_edist, hy]⟩ lemma _root_.is_closed.exists_inf_dist_eq_dist [proper_space α] (h : is_closed s) (hne : s.nonempty) (x : α) : ∃ y ∈ s, inf_dist x s = dist x y := begin rcases hne with ⟨z, hz⟩, rw ← inf_dist_inter_closed_ball_of_mem hz, set t := s ∩ closed_ball x (dist z x), have htc : is_compact t := (is_compact_closed_ball x (dist z x)).inter_left h, have htne : t.nonempty := ⟨z, hz, mem_closed_ball.2 le_rfl⟩, obtain ⟨y, ⟨hys, hyx⟩, hyd⟩ : ∃ y ∈ t, inf_dist x t = dist x y := htc.exists_inf_dist_eq_dist htne x, exact ⟨y, hys, hyd⟩ end lemma exists_mem_closure_inf_dist_eq_dist [proper_space α] (hne : s.nonempty) (x : α) : ∃ y ∈ closure s, inf_dist x s = dist x y := by simpa only [inf_dist_eq_closure] using is_closed_closure.exists_inf_dist_eq_dist hne.closure x /-! ### Distance of a point to a set as a function into `ℝ≥0`. -/ /-- The minimal distance of a point to a set as a `ℝ≥0` -/ def inf_nndist (x : α) (s : set α) : ℝ≥0 := ennreal.to_nnreal (inf_edist x s) @[simp] lemma coe_inf_nndist : (inf_nndist x s : ℝ) = inf_dist x s := rfl /-- The minimal distance to a set (as `ℝ≥0`) is Lipschitz in point with constant 1 -/ lemma lipschitz_inf_nndist_pt (s : set α) : lipschitz_with 1 (λx, inf_nndist x s) := lipschitz_with.of_le_add $ λ x y, inf_dist_le_inf_dist_add_dist /-- The minimal distance to a set (as `ℝ≥0`) is uniformly continuous in point -/ lemma uniform_continuous_inf_nndist_pt (s : set α) : uniform_continuous (λx, inf_nndist x s) := (lipschitz_inf_nndist_pt s).uniform_continuous /-- The minimal distance to a set (as `ℝ≥0`) is continuous in point -/ lemma continuous_inf_nndist_pt (s : set α) : continuous (λx, inf_nndist x s) := (uniform_continuous_inf_nndist_pt s).continuous /-! ### The Hausdorff distance as a function into `ℝ`. -/ /-- The Hausdorff distance between two sets is the smallest nonnegative `r` such that each set is included in the `r`-neighborhood of the other. If there is no such `r`, it is defined to be `0`, arbitrarily -/ def Hausdorff_dist (s t : set α) : ℝ := ennreal.to_real (Hausdorff_edist s t) /-- The Hausdorff distance is nonnegative -/ lemma Hausdorff_dist_nonneg : 0 ≤ Hausdorff_dist s t := by simp [Hausdorff_dist] /-- If two sets are nonempty and bounded in a metric space, they are at finite Hausdorff edistance. -/ lemma Hausdorff_edist_ne_top_of_nonempty_of_bounded (hs : s.nonempty) (ht : t.nonempty) (bs : bounded s) (bt : bounded t) : Hausdorff_edist s t ≠ ⊤ := begin rcases hs with ⟨cs, hcs⟩, rcases ht with ⟨ct, hct⟩, rcases (bounded_iff_subset_ball ct).1 bs with ⟨rs, hrs⟩, rcases (bounded_iff_subset_ball cs).1 bt with ⟨rt, hrt⟩, have : Hausdorff_edist s t ≤ ennreal.of_real (max rs rt), { apply Hausdorff_edist_le_of_mem_edist, { assume x xs, existsi [ct, hct], have : dist x ct ≤ max rs rt := le_trans (hrs xs) (le_max_left _ _), rwa [edist_dist, ennreal.of_real_le_of_real_iff], exact le_trans dist_nonneg this }, { assume x xt, existsi [cs, hcs], have : dist x cs ≤ max rs rt := le_trans (hrt xt) (le_max_right _ _), rwa [edist_dist, ennreal.of_real_le_of_real_iff], exact le_trans dist_nonneg this }}, exact ne_top_of_le_ne_top ennreal.of_real_ne_top this end /-- The Hausdorff distance between a set and itself is zero -/ @[simp] lemma Hausdorff_dist_self_zero : Hausdorff_dist s s = 0 := by simp [Hausdorff_dist] /-- The Hausdorff distance from `s` to `t` and from `t` to `s` coincide -/ lemma Hausdorff_dist_comm : Hausdorff_dist s t = Hausdorff_dist t s := by simp [Hausdorff_dist, Hausdorff_edist_comm] /-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable value ∞ instead, use `Hausdorff_edist`, which takes values in ℝ≥0∞) -/ @[simp] lemma Hausdorff_dist_empty : Hausdorff_dist s ∅ = 0 := begin cases s.eq_empty_or_nonempty with h h, { simp [h] }, { simp [Hausdorff_dist, Hausdorff_edist_empty h] } end /-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable value ∞ instead, use `Hausdorff_edist`, which takes values in ℝ≥0∞) -/ @[simp] lemma Hausdorff_dist_empty' : Hausdorff_dist ∅ s = 0 := by simp [Hausdorff_dist_comm] /-- Bounding the Hausdorff distance by bounding the distance of any point in each set to the other set -/ lemma Hausdorff_dist_le_of_inf_dist {r : ℝ} (hr : 0 ≤ r) (H1 : ∀x ∈ s, inf_dist x t ≤ r) (H2 : ∀x ∈ t, inf_dist x s ≤ r) : Hausdorff_dist s t ≤ r := begin by_cases h1 : Hausdorff_edist s t = ⊤, { rwa [Hausdorff_dist, h1, ennreal.top_to_real] }, cases s.eq_empty_or_nonempty with hs hs, { rwa [hs, Hausdorff_dist_empty'] }, cases t.eq_empty_or_nonempty with ht ht, { rwa [ht, Hausdorff_dist_empty] }, have : Hausdorff_edist s t ≤ ennreal.of_real r, { apply Hausdorff_edist_le_of_inf_edist _ _, { assume x hx, have I := H1 x hx, rwa [inf_dist, ← ennreal.to_real_of_real hr, ennreal.to_real_le_to_real (inf_edist_ne_top ht) ennreal.of_real_ne_top] at I }, { assume x hx, have I := H2 x hx, rwa [inf_dist, ← ennreal.to_real_of_real hr, ennreal.to_real_le_to_real (inf_edist_ne_top hs) ennreal.of_real_ne_top] at I }}, rwa [Hausdorff_dist, ← ennreal.to_real_of_real hr, ennreal.to_real_le_to_real h1 ennreal.of_real_ne_top] end /-- Bounding the Hausdorff distance by exhibiting, for any point in each set, another point in the other set at controlled distance -/ lemma Hausdorff_dist_le_of_mem_dist {r : ℝ} (hr : 0 ≤ r) (H1 : ∀x ∈ s, ∃y ∈ t, dist x y ≤ r) (H2 : ∀x ∈ t, ∃y ∈ s, dist x y ≤ r) : Hausdorff_dist s t ≤ r := begin apply Hausdorff_dist_le_of_inf_dist hr, { assume x xs, rcases H1 x xs with ⟨y, yt, hy⟩, exact le_trans (inf_dist_le_dist_of_mem yt) hy }, { assume x xt, rcases H2 x xt with ⟨y, ys, hy⟩, exact le_trans (inf_dist_le_dist_of_mem ys) hy } end /-- The Hausdorff distance is controlled by the diameter of the union -/ lemma Hausdorff_dist_le_diam (hs : s.nonempty) (bs : bounded s) (ht : t.nonempty) (bt : bounded t) : Hausdorff_dist s t ≤ diam (s ∪ t) := begin rcases hs with ⟨x, xs⟩, rcases ht with ⟨y, yt⟩, refine Hausdorff_dist_le_of_mem_dist diam_nonneg _ _, { exact λz hz, ⟨y, yt, dist_le_diam_of_mem (bounded_union.2 ⟨bs, bt⟩) (subset_union_left _ _ hz) (subset_union_right _ _ yt)⟩ }, { exact λz hz, ⟨x, xs, dist_le_diam_of_mem (bounded_union.2 ⟨bs, bt⟩) (subset_union_right _ _ hz) (subset_union_left _ _ xs)⟩ } end /-- The distance to a set is controlled by the Hausdorff distance -/ lemma inf_dist_le_Hausdorff_dist_of_mem (hx : x ∈ s) (fin : Hausdorff_edist s t ≠ ⊤) : inf_dist x t ≤ Hausdorff_dist s t := begin have ht : t.nonempty := nonempty_of_Hausdorff_edist_ne_top ⟨x, hx⟩ fin, rw [Hausdorff_dist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ht) fin], exact inf_edist_le_Hausdorff_edist_of_mem hx end /-- If the Hausdorff distance is `<r`, then any point in one of the sets is at distance `<r` of a point in the other set -/ lemma exists_dist_lt_of_Hausdorff_dist_lt {r : ℝ} (h : x ∈ s) (H : Hausdorff_dist s t < r) (fin : Hausdorff_edist s t ≠ ⊤) : ∃y∈t, dist x y < r := begin have r0 : 0 < r := lt_of_le_of_lt (Hausdorff_dist_nonneg) H, have : Hausdorff_edist s t < ennreal.of_real r, { rwa [Hausdorff_dist, ← ennreal.to_real_of_real (le_of_lt r0), ennreal.to_real_lt_to_real fin (ennreal.of_real_ne_top)] at H }, rcases exists_edist_lt_of_Hausdorff_edist_lt h this with ⟨y, hy, yr⟩, rw [edist_dist, ennreal.of_real_lt_of_real_iff r0] at yr, exact ⟨y, hy, yr⟩ end /-- If the Hausdorff distance is `<r`, then any point in one of the sets is at distance `<r` of a point in the other set -/ lemma exists_dist_lt_of_Hausdorff_dist_lt' {r : ℝ} (h : y ∈ t) (H : Hausdorff_dist s t < r) (fin : Hausdorff_edist s t ≠ ⊤) : ∃x∈s, dist x y < r := begin rw Hausdorff_dist_comm at H, rw Hausdorff_edist_comm at fin, simpa [dist_comm] using exists_dist_lt_of_Hausdorff_dist_lt h H fin end /-- The infimum distance to `s` and `t` are the same, up to the Hausdorff distance between `s` and `t` -/ lemma inf_dist_le_inf_dist_add_Hausdorff_dist (fin : Hausdorff_edist s t ≠ ⊤) : inf_dist x t ≤ inf_dist x s + Hausdorff_dist s t := begin rcases empty_or_nonempty_of_Hausdorff_edist_ne_top fin with ⟨hs,ht⟩|⟨hs,ht⟩, { simp only [hs, ht, Hausdorff_dist_empty, inf_dist_empty, zero_add] }, rw [inf_dist, inf_dist, Hausdorff_dist, ← ennreal.to_real_add (inf_edist_ne_top hs) fin, ennreal.to_real_le_to_real (inf_edist_ne_top ht)], { exact inf_edist_le_inf_edist_add_Hausdorff_edist }, { exact ennreal.add_ne_top.2 ⟨inf_edist_ne_top hs, fin⟩ } end /-- The Hausdorff distance is invariant under isometries -/ lemma Hausdorff_dist_image (h : isometry Φ) : Hausdorff_dist (Φ '' s) (Φ '' t) = Hausdorff_dist s t := by simp [Hausdorff_dist, Hausdorff_edist_image h] /-- The Hausdorff distance satisfies the triangular inequality -/ lemma Hausdorff_dist_triangle (fin : Hausdorff_edist s t ≠ ⊤) : Hausdorff_dist s u ≤ Hausdorff_dist s t + Hausdorff_dist t u := begin by_cases Hausdorff_edist s u = ⊤, { calc Hausdorff_dist s u = 0 + 0 : by simp [Hausdorff_dist, h] ... ≤ Hausdorff_dist s t + Hausdorff_dist t u : add_le_add (Hausdorff_dist_nonneg) (Hausdorff_dist_nonneg) }, { have Dtu : Hausdorff_edist t u < ⊤ := calc Hausdorff_edist t u ≤ Hausdorff_edist t s + Hausdorff_edist s u : Hausdorff_edist_triangle ... = Hausdorff_edist s t + Hausdorff_edist s u : by simp [Hausdorff_edist_comm] ... < ⊤ : lt_top_iff_ne_top.mpr $ ennreal.add_ne_top.mpr ⟨fin, h⟩, rw [Hausdorff_dist, Hausdorff_dist, Hausdorff_dist, ← ennreal.to_real_add fin Dtu.ne, ennreal.to_real_le_to_real h], { exact Hausdorff_edist_triangle }, { simp [ennreal.add_eq_top, lt_top_iff_ne_top.1 Dtu, fin] }} end /-- The Hausdorff distance satisfies the triangular inequality -/ lemma Hausdorff_dist_triangle' (fin : Hausdorff_edist t u ≠ ⊤) : Hausdorff_dist s u ≤ Hausdorff_dist s t + Hausdorff_dist t u := begin rw Hausdorff_edist_comm at fin, have I : Hausdorff_dist u s ≤ Hausdorff_dist u t + Hausdorff_dist t s := Hausdorff_dist_triangle fin, simpa [add_comm, Hausdorff_dist_comm] using I end /-- The Hausdorff distance between a set and its closure vanish -/ @[simp, priority 1100] lemma Hausdorff_dist_self_closure : Hausdorff_dist s (closure s) = 0 := by simp [Hausdorff_dist] /-- Replacing a set by its closure does not change the Hausdorff distance. -/ @[simp] lemma Hausdorff_dist_closure₁ : Hausdorff_dist (closure s) t = Hausdorff_dist s t := by simp [Hausdorff_dist] /-- Replacing a set by its closure does not change the Hausdorff distance. -/ @[simp] lemma Hausdorff_dist_closure₂ : Hausdorff_dist s (closure t) = Hausdorff_dist s t := by simp [Hausdorff_dist] /-- The Hausdorff distance between two sets and their closures coincide -/ @[simp] lemma Hausdorff_dist_closure : Hausdorff_dist (closure s) (closure t) = Hausdorff_dist s t := by simp [Hausdorff_dist] /-- Two sets are at zero Hausdorff distance if and only if they have the same closures -/ lemma Hausdorff_dist_zero_iff_closure_eq_closure (fin : Hausdorff_edist s t ≠ ⊤) : Hausdorff_dist s t = 0 ↔ closure s = closure t := by simp [Hausdorff_edist_zero_iff_closure_eq_closure.symm, Hausdorff_dist, ennreal.to_real_eq_zero_iff, fin] /-- Two closed sets are at zero Hausdorff distance if and only if they coincide -/ lemma _root_.is_closed.Hausdorff_dist_zero_iff_eq (hs : is_closed s) (ht : is_closed t) (fin : Hausdorff_edist s t ≠ ⊤) : Hausdorff_dist s t = 0 ↔ s = t := by simp [←Hausdorff_edist_zero_iff_eq_of_closed hs ht, Hausdorff_dist, ennreal.to_real_eq_zero_iff, fin] end --section section thickening variables {α : Type u} [pseudo_emetric_space α] open emetric /-- The (open) `δ`-thickening `thickening δ E` of a subset `E` in a pseudo emetric space consists of those points that are at distance less than `δ` from some point of `E`. -/ def thickening (δ : ℝ) (E : set α) : set α := {x : α | inf_edist x E < ennreal.of_real δ} /-- The (open) thickening equals the preimage of an open interval under `inf_edist`. -/ lemma thickening_eq_preimage_inf_edist (δ : ℝ) (E : set α) : thickening δ E = (λ x, inf_edist x E) ⁻¹' (Iio (ennreal.of_real δ)) := rfl /-- The (open) thickening is an open set. -/ lemma is_open_thickening {δ : ℝ} {E : set α} : is_open (thickening δ E) := continuous.is_open_preimage continuous_inf_edist _ is_open_Iio /-- The (open) thickening of the empty set is empty. -/ @[simp] lemma thickening_empty (δ : ℝ) : thickening δ (∅ : set α) = ∅ := by simp only [thickening, set_of_false, inf_edist_empty, not_top_lt] /-- The (open) thickening `thickening δ E` of a fixed subset `E` is an increasing function of the thickening radius `δ`. -/ lemma thickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : set α) : thickening δ₁ E ⊆ thickening δ₂ E := preimage_mono (Iio_subset_Iio (ennreal.of_real_le_of_real hle)) /-- The (open) thickening `thickening δ E` with a fixed thickening radius `δ` is an increasing function of the subset `E`. -/ lemma thickening_subset_of_subset (δ : ℝ) {E₁ E₂ : set α} (h : E₁ ⊆ E₂) : thickening δ E₁ ⊆ thickening δ E₂ := λ _ hx, lt_of_le_of_lt (inf_edist_le_inf_edist_of_subset h) hx lemma mem_thickening_iff_exists_edist_lt {δ : ℝ} (E : set α) (x : α) : x ∈ thickening δ E ↔ ∃ z ∈ E, edist x z < ennreal.of_real δ := inf_edist_lt_iff variables {X : Type u} [pseudo_metric_space X] /-- A point in a metric space belongs to the (open) `δ`-thickening of a subset `E` if and only if it is at distance less than `δ` from some point of `E`. -/ lemma mem_thickening_iff {δ : ℝ} (E : set X) (x : X) : x ∈ thickening δ E ↔ (∃ z ∈ E, dist x z < δ) := begin have key_iff : ∀ (z : X), edist x z < ennreal.of_real δ ↔ dist x z < δ, { intros z, rw dist_edist, have d_lt_top : edist x z < ∞, by simp only [edist_dist, ennreal.of_real_lt_top], have key := (@ennreal.of_real_lt_of_real_iff_of_nonneg ((edist x z).to_real) δ (ennreal.to_real_nonneg)), rwa ennreal.of_real_to_real d_lt_top.ne at key, }, simp_rw [mem_thickening_iff_exists_edist_lt, key_iff], end @[simp] lemma thickening_singleton (δ : ℝ) (x : X) : thickening δ ({x} : set X) = ball x δ := by { ext, simp [mem_thickening_iff] } /-- The (open) `δ`-thickening `thickening δ E` of a subset `E` in a metric space equals the union of balls of radius `δ` centered at points of `E`. -/ lemma thickening_eq_bUnion_ball {δ : ℝ} {E : set X} : thickening δ E = ⋃ x ∈ E, ball x δ := by { ext x, rw mem_Union₂, exact mem_thickening_iff E x, } lemma bounded.thickening {δ : ℝ} {E : set X} (h : bounded E) : bounded (thickening δ E) := begin refine bounded_iff_mem_bounded.2 (λ x hx, _), rcases h.subset_ball x with ⟨R, hR⟩, refine (bounded_iff_subset_ball x).2 ⟨R + δ, _⟩, assume y hy, rcases (mem_thickening_iff _ _).1 hy with ⟨z, zE, hz⟩, calc dist y x ≤ dist z x + dist y z : by { rw add_comm, exact dist_triangle _ _ _ } ... ≤ R + δ : add_le_add (hR zE) hz.le end end thickening --section section cthickening variables {α : Type*} [pseudo_emetric_space α] open emetric /-- The closed `δ`-thickening `cthickening δ E` of a subset `E` in a pseudo emetric space consists of those points that are at infimum distance at most `δ` from `E`. -/ def cthickening (δ : ℝ) (E : set α) : set α := {x : α | inf_edist x E ≤ ennreal.of_real δ} lemma mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : set α) (h : y ∈ E) (h' : edist x y ≤ ennreal.of_real δ) : x ∈ cthickening δ E := (inf_edist_le_edist_of_mem h).trans h' lemma mem_cthickening_of_dist_le {α : Type*} [pseudo_metric_space α] (x y : α) (δ : ℝ) (E : set α) (h : y ∈ E) (h' : dist x y ≤ δ) : x ∈ cthickening δ E := begin apply mem_cthickening_of_edist_le x y δ E h, rw edist_dist, exact ennreal.of_real_le_of_real h', end lemma cthickening_eq_preimage_inf_edist (δ : ℝ) (E : set α) : cthickening δ E = (λ x, inf_edist x E) ⁻¹' (Iic (ennreal.of_real δ)) := rfl /-- The closed thickening is a closed set. -/ lemma is_closed_cthickening {δ : ℝ} {E : set α} : is_closed (cthickening δ E) := is_closed.preimage continuous_inf_edist is_closed_Iic /-- The closed thickening of the empty set is empty. -/ @[simp] lemma cthickening_empty (δ : ℝ) : cthickening δ (∅ : set α) = ∅ := by simp only [cthickening, ennreal.of_real_ne_top, set_of_false, inf_edist_empty, top_le_iff] lemma cthickening_of_nonpos {δ : ℝ} (hδ : δ ≤ 0) (E : set α) : cthickening δ E = closure E := by { ext x, simp [mem_closure_iff_inf_edist_zero, cthickening, ennreal.of_real_eq_zero.2 hδ] } /-- The closed thickening with radius zero is the closure of the set. -/ @[simp] lemma cthickening_zero (E : set α) : cthickening 0 E = closure E := cthickening_of_nonpos le_rfl E /-- The closed thickening `cthickening δ E` of a fixed subset `E` is an increasing function of the thickening radius `δ`. -/ lemma cthickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : set α) : cthickening δ₁ E ⊆ cthickening δ₂ E := preimage_mono (Iic_subset_Iic.mpr (ennreal.of_real_le_of_real hle)) @[simp] lemma cthickening_singleton {α : Type*} [pseudo_metric_space α] (x : α) {δ : ℝ} (hδ : 0 ≤ δ) : cthickening δ ({x} : set α) = closed_ball x δ := by { ext y, simp [cthickening, edist_dist, ennreal.of_real_le_of_real_iff hδ] } lemma closed_ball_subset_cthickening_singleton {α : Type*} [pseudo_metric_space α] (x : α) (δ : ℝ) : closed_ball x δ ⊆ cthickening δ ({x} : set α) := begin rcases lt_or_le δ 0 with hδ|hδ, { simp only [closed_ball_eq_empty.mpr hδ, empty_subset] }, { simp only [cthickening_singleton x hδ] } end /-- The closed thickening `cthickening δ E` with a fixed thickening radius `δ` is an increasing function of the subset `E`. -/ lemma cthickening_subset_of_subset (δ : ℝ) {E₁ E₂ : set α} (h : E₁ ⊆ E₂) : cthickening δ E₁ ⊆ cthickening δ E₂ := λ _ hx, le_trans (inf_edist_le_inf_edist_of_subset h) hx lemma cthickening_subset_thickening {δ₁ : ℝ≥0} {δ₂ : ℝ} (hlt : (δ₁ : ℝ) < δ₂) (E : set α) : cthickening δ₁ E ⊆ thickening δ₂ E := λ _ hx, lt_of_le_of_lt hx ((ennreal.of_real_lt_of_real_iff (lt_of_le_of_lt δ₁.prop hlt)).mpr hlt) /-- The closed thickening `cthickening δ₁ E` is contained in the open thickening `thickening δ₂ E` if the radius of the latter is positive and larger. -/ lemma cthickening_subset_thickening' {δ₁ δ₂ : ℝ} (δ₂_pos : 0 < δ₂) (hlt : δ₁ < δ₂) (E : set α) : cthickening δ₁ E ⊆ thickening δ₂ E := λ _ hx, lt_of_le_of_lt hx ((ennreal.of_real_lt_of_real_iff δ₂_pos).mpr hlt) /-- The open thickening `thickening δ E` is contained in the closed thickening `cthickening δ E` with the same radius. -/ lemma thickening_subset_cthickening (δ : ℝ) (E : set α) : thickening δ E ⊆ cthickening δ E := by { intros x hx, rw [thickening, mem_set_of_eq] at hx, exact hx.le, } lemma thickening_subset_cthickening_of_le {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : set α) : thickening δ₁ E ⊆ cthickening δ₂ E := (thickening_subset_cthickening δ₁ E).trans (cthickening_mono hle E) lemma bounded.cthickening {α : Type*} [pseudo_metric_space α] {δ : ℝ} {E : set α} (h : bounded E) : bounded (cthickening δ E) := begin have : bounded (thickening (max (δ + 1) 1) E) := h.thickening, apply bounded.mono _ this, exact cthickening_subset_thickening' (zero_lt_one.trans_le (le_max_right _ _)) ((lt_add_one _).trans_le (le_max_left _ _)) _ end lemma thickening_subset_interior_cthickening (δ : ℝ) (E : set α) : thickening δ E ⊆ interior (cthickening δ E) := (subset_interior_iff_open.mpr (is_open_thickening)).trans (interior_mono (thickening_subset_cthickening δ E)) lemma closure_thickening_subset_cthickening (δ : ℝ) (E : set α) : closure (thickening δ E) ⊆ cthickening δ E := (closure_mono (thickening_subset_cthickening δ E)).trans is_closed_cthickening.closure_subset /-- The closed thickening of a set contains the closure of the set. -/ lemma closure_subset_cthickening (δ : ℝ) (E : set α) : closure E ⊆ cthickening δ E := by { rw ← cthickening_of_nonpos (min_le_right δ 0), exact cthickening_mono (min_le_left δ 0) E, } /-- The (open) thickening of a set contains the closure of the set. -/ lemma closure_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : set α) : closure E ⊆ thickening δ E := by { rw ← cthickening_zero, exact cthickening_subset_thickening' δ_pos δ_pos E, } /-- A set is contained in its own (open) thickening. -/ lemma self_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : set α) : E ⊆ thickening δ E := (@subset_closure _ _ E).trans (closure_subset_thickening δ_pos E) /-- A set is contained in its own closed thickening. -/ lemma self_subset_cthickening {δ : ℝ} (E : set α) : E ⊆ cthickening δ E := subset_closure.trans (closure_subset_cthickening δ E) lemma cthickening_eq_Inter_cthickening' {δ : ℝ} (s : set ℝ) (hsδ : s ⊆ Ioi δ) (hs : ∀ ε, δ < ε → (s ∩ (Ioc δ ε)).nonempty) (E : set α) : cthickening δ E = ⋂ ε ∈ s, cthickening ε E := begin apply subset.antisymm, { exact subset_Inter₂ (λ _ hε, cthickening_mono (le_of_lt (hsδ hε)) E), }, { unfold thickening cthickening, intros x hx, simp only [mem_Inter, mem_set_of_eq] at *, apply ennreal.le_of_forall_pos_le_add, intros η η_pos _, rcases hs (δ + η) (lt_add_of_pos_right _ (nnreal.coe_pos.mpr η_pos)) with ⟨ε, ⟨hsε, hε⟩⟩, apply ((hx ε hsε).trans (ennreal.of_real_le_of_real hε.2)).trans, rw ennreal.coe_nnreal_eq η, exact ennreal.of_real_add_le, }, end lemma cthickening_eq_Inter_cthickening {δ : ℝ} (E : set α) : cthickening δ E = ⋂ (ε : ℝ) (h : δ < ε), cthickening ε E := begin apply cthickening_eq_Inter_cthickening' (Ioi δ) rfl.subset, simp_rw inter_eq_right_iff_subset.mpr Ioc_subset_Ioi_self, exact λ _ hε, nonempty_Ioc.mpr hε, end lemma cthickening_eq_Inter_thickening' {δ : ℝ} (δ_nn : 0 ≤ δ) (s : set ℝ) (hsδ : s ⊆ Ioi δ) (hs : ∀ ε, δ < ε → (s ∩ (Ioc δ ε)).nonempty) (E : set α) : cthickening δ E = ⋂ ε ∈ s, thickening ε E := begin refine (subset_Inter₂ $ λ ε hε, _).antisymm _, { obtain ⟨ε', hsε', hε'⟩ := hs ε (hsδ hε), have ss := cthickening_subset_thickening' (lt_of_le_of_lt δ_nn hε'.1) hε'.1 E, exact ss.trans (thickening_mono hε'.2 E), }, { rw cthickening_eq_Inter_cthickening' s hsδ hs E, exact Inter₂_mono (λ ε hε, thickening_subset_cthickening ε E) } end lemma cthickening_eq_Inter_thickening {δ : ℝ} (δ_nn : 0 ≤ δ) (E : set α) : cthickening δ E = ⋂ (ε : ℝ) (h : δ < ε), thickening ε E := begin apply cthickening_eq_Inter_thickening' δ_nn (Ioi δ) rfl.subset, simp_rw inter_eq_right_iff_subset.mpr Ioc_subset_Ioi_self, exact λ _ hε, nonempty_Ioc.mpr hε, end /-- The closure of a set equals the intersection of its closed thickenings of positive radii accumulating at zero. -/ lemma closure_eq_Inter_cthickening' (E : set α) (s : set ℝ) (hs : ∀ ε, 0 < ε → (s ∩ (Ioc 0 ε)).nonempty) : closure E = ⋂ δ ∈ s, cthickening δ E := begin by_cases hs₀ : s ⊆ Ioi 0, { rw ← cthickening_zero, apply cthickening_eq_Inter_cthickening' _ hs₀ hs, }, obtain ⟨δ, hδs, δ_nonpos⟩ := not_subset.mp hs₀, rw [set.mem_Ioi, not_lt] at δ_nonpos, apply subset.antisymm, { exact subset_Inter₂ (λ ε _, closure_subset_cthickening ε E), }, { rw ← cthickening_of_nonpos δ_nonpos E, exact bInter_subset_of_mem hδs, }, end /-- The closure of a set equals the intersection of its closed thickenings of positive radii. -/ lemma closure_eq_Inter_cthickening (E : set α) : closure E = ⋂ (δ : ℝ) (h : 0 < δ), cthickening δ E := by { rw ← cthickening_zero, exact cthickening_eq_Inter_cthickening E, } /-- The closure of a set equals the intersection of its open thickenings of positive radii accumulating at zero. -/ lemma closure_eq_Inter_thickening' (E : set α) (s : set ℝ) (hs₀ : s ⊆ Ioi 0) (hs : ∀ ε, 0 < ε → (s ∩ (Ioc 0 ε)).nonempty) : closure E = ⋂ δ ∈ s, thickening δ E := by { rw ← cthickening_zero, apply cthickening_eq_Inter_thickening' le_rfl _ hs₀ hs, } /-- The closure of a set equals the intersection of its (open) thickenings of positive radii. -/ lemma closure_eq_Inter_thickening (E : set α) : closure E = ⋂ (δ : ℝ) (h : 0 < δ), thickening δ E := by { rw ← cthickening_zero, exact cthickening_eq_Inter_thickening rfl.ge E, } /-- The frontier of the (open) thickening of a set is contained in an `inf_edist` level set. -/ lemma frontier_thickening_subset (E : set α) {δ : ℝ} (δ_pos : 0 < δ) : frontier (thickening δ E) ⊆ {x : α | inf_edist x E = ennreal.of_real δ} := begin have singleton_preim : {x : α | inf_edist x E = ennreal.of_real δ } = (λ x , inf_edist x E) ⁻¹' {ennreal.of_real δ}, { simp only [preimage, mem_singleton_iff] }, rw [thickening_eq_preimage_inf_edist, singleton_preim, ← (frontier_Iio' ⟨(0 : ℝ≥0∞), ennreal.of_real_pos.mpr δ_pos⟩)], exact continuous_inf_edist.frontier_preimage_subset (Iio (ennreal.of_real δ)), end /-- The frontier of the closed thickening of a set is contained in an `inf_edist` level set. -/ lemma frontier_cthickening_subset (E : set α) {δ : ℝ} : frontier (cthickening δ E) ⊆ {x : α | inf_edist x E = ennreal.of_real δ} := begin have singleton_preim : {x : α | inf_edist x E = ennreal.of_real δ } = (λ x , inf_edist x E) ⁻¹' {ennreal.of_real δ}, { simp only [preimage, mem_singleton_iff] }, rw [cthickening_eq_preimage_inf_edist, singleton_preim, ← frontier_Iic' ⟨∞, ennreal.of_real_lt_top⟩], exact continuous_inf_edist.frontier_preimage_subset (Iic (ennreal.of_real δ)), end /-- The closed ball of radius `δ` centered at a point of `E` is included in the closed thickening of `E`. -/ lemma closed_ball_subset_cthickening {α : Type*} [pseudo_metric_space α] {x : α} {E : set α} (hx : x ∈ E) (δ : ℝ) : closed_ball x δ ⊆ cthickening δ E := begin refine (closed_ball_subset_cthickening_singleton _ _).trans (cthickening_subset_of_subset _ _), simpa using hx, end /-- The closed thickening of a compact set `E` is the union of the balls `closed_ball x δ` over `x ∈ E`. -/ lemma _root_.is_compact.cthickening_eq_bUnion_closed_ball {α : Type*} [pseudo_metric_space α] {δ : ℝ} {E : set α} (hE : is_compact E) (hδ : 0 ≤ δ) : cthickening δ E = ⋃ x ∈ E, closed_ball x δ := begin rcases eq_empty_or_nonempty E with rfl|hne, { simp only [cthickening_empty, Union_false, Union_empty] }, refine subset.antisymm (λ x hx, _) (Union₂_subset $ λ x hx, closed_ball_subset_cthickening hx _), obtain ⟨y, yE, hy⟩ : ∃ y ∈ E, emetric.inf_edist x E = edist x y := hE.exists_inf_edist_eq_edist hne _, have D1 : edist x y ≤ ennreal.of_real δ := (le_of_eq hy.symm).trans hx, have D2 : dist x y ≤ δ, { rw edist_dist at D1, exact (ennreal.of_real_le_of_real_iff hδ).1 D1 }, exact mem_bUnion yE D2, end end cthickening --section end metric --namespace
% FT_POSTAMBLE_DEBUG is a helper script for debugging problems with FieldTrip % functions. It is executed at normal termination of the calling function and % disables the "onCleanup" function. % % Use as % ft_preamble debug % .... regular code goes here ... % ft_postamble debug % % See also FT_PREAMBLE, FT_POSTAMBLE, FT_PREAMBLE_DEBUG, DEBUGCLEANUP % these variables are shared by the three debug handlers global Ce9dei2ZOo_debug Ce9dei2ZOo_funname Ce9dei2ZOo_argin Ce9dei2ZOo_ws Ce9dei2ZOo_ns Ce9dei2ZOo_is Ce9dei2ZOo_ds if isfield(cfg, 'verbose') && ischar(cfg.verbose) % restore the previous state of the notifications ft_warning(Ce9dei2ZOo_ws) ft_notice(Ce9dei2ZOo_ns); ft_info(Ce9dei2ZOo_is); ft_debug(Ce9dei2ZOo_ds); end if ~isfield(cfg, 'debug') % do not provide extra debugging facilities return end switch cfg.debug case {'displayonsuccess' 'saveonsuccess'} % do not clean up the global variables yet % these are still needed by the cleanup function otherwise % stack(1) is this script % stack(2) is the calling ft_postamble function % stack(3) is the main FieldTrip function that we are interested in Ce9dei2ZOx_funname = dbstack; Ce9dei2ZOx_funname = Ce9dei2ZOx_funname(3).name; if isequal(Ce9dei2ZOx_funname, Ce9dei2ZOo_funname) % this results in the cleanup function doing nothing Ce9dei2ZOo_debug = 'no'; Ce9dei2ZOo_funname = []; Ce9dei2ZOo_argin = []; else % this happens for nested FieldTrip functions, e.g. when % ft_selectdata is called by another high-level function end end
import numpy as np import cv2 import glob # termination criteria criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001) # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0) objp = np.zeros((7*9,3), np.float32) objp[:,:2] = np.mgrid[0:9,0:7].T.reshape(-1,2)*20 #20 mm of square # Arrays to store object points and image points from all the images. objpoints = [] # 3d point in real world space imgpoints = [] # 2d points in image plane. images = glob.glob('/Users/William/brdfm/biao/*.jpg') for fname in images: gray = cv2.imread(fname, cv2.IMREAD_GRAYSCALE) # Find the chess board corners ret, corners = cv2.findChessboardCorners(gray, (9,7),None) # If found, add object points, image points (after refining them) if ret == True: objpoints.append(objp) corners2 = cv2.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria) imgpoints.append(corners2) # Draw and display the corners 可以取消掉 #img = cv2.drawChessboardCorners(img, (9,7), corners2,ret) #cv2.imshow('img',img) #cv2.waitKey(700) #cv2.destroyAllWindows() ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None) img = cv2.imread('volleyball.jpg') h, w = img.shape[:2] newcameramtx, roi = cv2.getOptimalNewCameraMatrix(mtx, dist, (w,h), 1, (w,h)) # undistort dst = cv2.undistort(img, mtx, dist, None, newcameramtx) # crop the image x, y, w, h = roi dst = dst[y:y+h, x:x+w] cv2.imwrite('calibresult.png', dst) axis = np.float32([[20,0,0], [0,20,0], [0,0,-20]]).reshape(-1,3) for fname in glob.glob('/Users/William/brdfm/biao/*.jpg'): img = cv2.imread(fname) gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) ret, corners = cv2.findChessboardCorners(gray, (9,7),None) if ret == True: corners2 = cv2.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria) # Find the rotation and translation vectors. ret,rvecs, tvecs = cv2.solvePnP(objp, corners2, mtx, dist) # project 3D points to image plane imgpts, jac = cv2.projectPoints(axis, rvecs, tvecs, mtx, dist) img = draw(img,corners2,imgpts) cv2.imshow('img',img) k = cv2.waitKey(0) & 0xFF if k == ord('s'): cv2.imwrite(fname[:6]+'.png', img) cv2.destroyAllWindows()
[GOAL] X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf ⊢ ∃! s, IsGluing (presheafToTypes X T) U sf s [PROOFSTEP] choose index index_spec using fun x : ↑(iSup U) => Opens.mem_iSup.mp x.2 -- Using this data, we can glue our functions together to a single section [GOAL] X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) ⊢ ∃! s, IsGluing (presheafToTypes X T) U sf s [PROOFSTEP] let s : ∀ x : ↑(iSup U), T x := fun x => sf (index x) ⟨x.1, index_spec x⟩ [GOAL] X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } ⊢ ∃! s, IsGluing (presheafToTypes X T) U sf s [PROOFSTEP] refine' ⟨s, _, _⟩ [GOAL] case refine'_1 X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } ⊢ (fun s => IsGluing (presheafToTypes X T) U sf s) s [PROOFSTEP] intro i [GOAL] case refine'_1 X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } i : ι ⊢ ↑((presheafToTypes X T).map (leSupr U i).op) s = sf i [PROOFSTEP] funext x [GOAL] case refine'_1.h X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } i : ι x : { x // x ∈ (Opposite.op (U i)).unop } ⊢ ↑((presheafToTypes X T).map (leSupr U i).op) s x = sf i x [PROOFSTEP] exact congr_fun (hsf (index ⟨x, _⟩) i) ⟨x, ⟨index_spec ⟨x.1, _⟩, x.2⟩⟩ [GOAL] case refine'_2 X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } ⊢ ∀ (y : (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (iSup U)))), (fun s => IsGluing (presheafToTypes X T) U sf s) y → y = s [PROOFSTEP] intro t ht [GOAL] case refine'_2 X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } t : (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (iSup U))) ht : IsGluing (presheafToTypes X T) U sf t ⊢ t = s [PROOFSTEP] funext x [GOAL] case refine'_2.h X : TopCat T : ↑X → Type u ι : Type u U : ι → Opens ↑X sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (U i))) hsf : IsCompatible (presheafToTypes X T) U sf index : { x // x ∈ iSup U } → ι index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x) s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) } t : (forget (Type u)).obj ((presheafToTypes X T).obj (Opposite.op (iSup U))) ht : IsGluing (presheafToTypes X T) U sf t x : { x // x ∈ (Opposite.op (iSup U)).unop } ⊢ t x = s x [PROOFSTEP] exact congr_fun (ht (index x)) ⟨x.1, index_spec x⟩
1 -- @@stderr -- dtrace: invalid probe specifier genunix: probe description :::genunix does not match any probes
The pseudo remainder of two polynomials is the polynomial whose coefficients are the pseudo remainder of the coefficients of the two polynomials.
import .basic namespace polya.field open nterm --@[derive decidable_eq] structure cterm (γ : Type) [const_space γ] : Type := (term : nterm γ) (coeff : γ) (pr : coeff ≠ 0) namespace cterm variables {α : Type} [discrete_field α] variables {γ : Type} [const_space γ] variables [morph γ α] {ρ : dict α} instance : inhabited (cterm γ) := ⟨⟨nterm.const 0, 1, by simp⟩⟩ def to_nterm (x : cterm γ) : nterm γ := x.term * x.coeff def eval (ρ : dict α) (x : cterm γ) : α := nterm.eval ρ x.term * ↑x.coeff @[simp] def eval_to_nterm {x : cterm γ} : nterm.eval ρ x.to_nterm = cterm.eval ρ x := begin simp [to_nterm, nterm.eval, cterm.eval] end theorem eval_to_nterm' : nterm.eval ρ ∘ @cterm.to_nterm γ _ = cterm.eval ρ := begin unfold function.comp, simp [eval_to_nterm] end --TODO theorem eval_def {x : nterm γ} {c : γ} {hc : c ≠ 0} : cterm.eval ρ ⟨x, c, hc⟩ = nterm.eval ρ x * ↑c := rfl theorem eval_add {x : nterm γ} {a b : γ} {ha : a ≠ 0} {hb : b ≠ 0} {hc : a + b ≠ 0} : cterm.eval ρ ⟨x, a + b, hc⟩ = cterm.eval ρ ⟨x, a, ha⟩ + cterm.eval ρ ⟨x, b, hb⟩ := begin simp [eval_def, morph.morph_add, mul_add], end def mul (x : cterm γ) (a : γ) (ha : a ≠ 0) : cterm γ := ⟨x.term, x.coeff * a, by simp [ha, x.pr]⟩ theorem eval_mul {x : cterm γ} {a : γ} {ha : a ≠ 0} : cterm.eval ρ (x.mul a ha) = cterm.eval ρ x * ↑a := begin simp [cterm.eval, morph.morph_mul, mul], ring end theorem eval_mul' {a : γ} {ha : a ≠ 0} : cterm.eval ρ ∘ (λ x : cterm γ, x.mul a ha) = λ x, cterm.eval ρ x * (a : α) := begin unfold function.comp, simp [eval_mul] end theorem eval_sum_mul {xs : list (cterm γ)} {a : γ} {ha : a ≠ 0} : list.sum (list.map (cterm.eval ρ) xs) * ↑a = list.sum (list.map (λ x : cterm γ, cterm.eval ρ (x.mul a ha)) xs) := begin induction xs with x xs ih, { simp }, { repeat {rw [list.map_cons, list.sum_cons]}, rw [eval_mul, add_mul, ih] } end def smerge : list (cterm γ) → list (cterm γ) → list (cterm γ) | (x::xs) (y::ys) := if x.term = y.term then let c := x.coeff + y.coeff in if hc : c = 0 then smerge xs ys else ⟨x.term, c, hc⟩ :: smerge xs ys else if x.term < y.term then x :: smerge xs (y::ys) else y :: smerge (x::xs) ys | xs [] := xs | [] ys := ys lemma smerge_nil_left {ys : list (cterm γ)} : smerge [] ys = ys := begin induction ys with y ys ih, { unfold smerge }, { unfold smerge } end lemma smerge_nil_right {xs : list (cterm γ)} : smerge xs [] = xs := begin induction xs with x xs ih, { unfold smerge }, { unfold smerge } end lemma smerge_def1 {x y : cterm γ} {xs ys : list (cterm γ)} : x.term = y.term → x.coeff + y.coeff = 0 → smerge (x::xs) (y::ys) = smerge xs ys := by intros h1 h2; simp [smerge, h1, h2] lemma smerge_def2 {x y : cterm γ} {xs ys : list (cterm γ)} : x.term = y.term → Π (hc : x.coeff + y.coeff ≠ 0), smerge (x::xs) (y::ys) = ⟨x.term, x.coeff + y.coeff, hc⟩ :: smerge xs ys := by intros h1 h2; simp [smerge, h1, h2] lemma smerge_def3 {x y : cterm γ} {xs ys : list (cterm γ)} : x.term ≠ y.term → x.term < y.term → smerge (x::xs) (y::ys) = x :: smerge xs (y :: ys) := by intros h1 h2; simp [smerge, h1, h2] lemma smerge_def4 {x y : cterm γ} {xs ys : list (cterm γ)} : x.term ≠ y.term → ¬ x.term < y.term → smerge (x::xs) (y::ys) = y :: smerge (x::xs) ys := by intros h1 h2; simp [smerge, h1, h2] theorem eval_smerge (xs ys : list (cterm γ)) : list.sum (list.map (cterm.eval ρ) (smerge xs ys)) = list.sum (list.map (cterm.eval ρ) xs) + list.sum (list.map (cterm.eval ρ) ys) := begin revert ys, induction xs with x xs ihx, { intro ys, simp [smerge_nil_left] }, { intro ys, induction ys with y ys ihy, { simp [smerge_nil_right] }, { by_cases h1 : x.term = y.term, { by_cases h2 : x.coeff + y.coeff = 0, { have : eval ρ x = - eval ρ y, by { rw add_eq_zero_iff_eq_neg at h2, unfold cterm.eval, rw [h1, h2, morph.morph_neg], ring }, rw [smerge_def1 h1 h2, ihx], repeat {rw [list.map_cons, list.sum_cons]}, rw this, ring }, { rw smerge_def2 h1 h2, cases x with x n, cases y with y m, simp only [] at h1, rw h1 at *, repeat {rw [list.map_cons, list.sum_cons]}, rw [eval_add, ihx ys], { simp }, repeat {assumption }}}, { by_cases h2 : x.term < y.term, { rw smerge_def3 h1 h2, repeat {rw [list.map_cons, list.sum_cons]}, rw [ihx (y::ys), list.map_cons, list.sum_cons], ring}, { rw smerge_def4 h1 h2, repeat {rw [list.map_cons, list.sum_cons]}, rw [ihy, list.map_cons, list.sum_cons], ring}}}} end end cterm structure sterm (γ : Type) [const_space γ] : Type := (terms : list (cterm γ)) namespace sterm variables {α : Type} [discrete_field α] variables {γ : Type} [const_space γ] variables [morph γ α] {ρ : dict α} def of_const (a : γ) : sterm γ := if ha : a = 0 then { terms := [] } else { terms := [⟨1, a, ha⟩] } def singleton (x : nterm γ) : sterm γ := { terms := [⟨x, 1, by simp⟩] } def eval (ρ : dict α) (S : sterm γ) : α := list.sum (S.terms.map (cterm.eval ρ)) theorem eval_of_const (a : γ) : sterm.eval ρ (of_const a) = ↑a := begin by_cases ha : a = 0; simp [of_const, sterm.eval, cterm.eval, ha] end theorem eval_singleton (x : nterm γ) : sterm.eval ρ (singleton x) = nterm.eval ρ x := begin by_cases hx : nterm.eval ρ x = 0, repeat {simp [singleton, sterm.eval, cterm.eval, hx]} end --mul def add (S T : sterm γ) : sterm γ := { terms := cterm.smerge S.terms T.terms, } --pow def mul (S : sterm γ) (a : γ) : sterm γ := if ha : a = 0 then { terms := [] } else { terms := S.terms.map (λ x, cterm.mul x a ha), } instance : has_add (sterm γ) := ⟨add⟩ theorem add_terms {S T : sterm γ} : (S + T).terms = cterm.smerge S.terms T.terms := by simp [has_add.add, add] theorem eval_add {S T : sterm γ} : sterm.eval ρ (S + T) = sterm.eval ρ S + sterm.eval ρ T := begin unfold sterm.eval, rw [add_terms, cterm.eval_smerge] end theorem eval_mul {S : sterm γ} {a : γ} : sterm.eval ρ (S.mul a) = sterm.eval ρ S * ↑a := begin by_cases ha : a = 0, { simp [mul, eval, ha] }, { unfold sterm.eval, unfold mul, rw cterm.eval_sum_mul, { simp [ha] }, { exact ha }} end def to_nterm (S : sterm γ) : nterm γ := match S.terms with | [] := 0 | [x] := x.to_nterm | (x0::xs) := have h0 : x0.coeff⁻¹ ≠ 0, by simp [x0.pr], ( nterm.sum (xs.map (λ x, (x.mul x0.coeff⁻¹ h0).to_nterm)) + x0.term * 1 ) * x0.coeff end theorem eval_to_nterm {S : sterm γ} : sterm.eval ρ S = nterm.eval ρ S.to_nterm := begin cases S with xs, cases xs with x0 xs, { simp [eval, to_nterm] }, cases xs with x1 xs, { simp [eval, to_nterm] }, unfold eval, unfold to_nterm, rw [nterm.eval_mul, nterm.eval_add, nterm.eval_sum, nterm.eval_const], rw [← list.map_map cterm.to_nterm, list.map_map _ cterm.to_nterm, cterm.eval_to_nterm', list.map_map, ← cterm.eval_sum_mul], rw [add_mul, mul_assoc, ← morph.morph_mul, inv_mul_cancel, morph.morph_one', mul_one], swap, by simp [x0.pr], rw [list.map_cons, list.sum_cons], rw [nterm.eval_mul, nterm.eval_one, mul_one], unfold cterm.eval, apply add_comm end def of_nterm : nterm γ → sterm γ | (nterm.add x y) := of_nterm x + of_nterm y | (nterm.mul x (nterm.const a)) := (of_nterm x).mul a | (nterm.const a) := of_const a | x := singleton x theorem eval_of_nterm {x : nterm γ} : sterm.eval ρ (of_nterm x) = nterm.eval ρ x := begin induction x with i c x y ihx ihy x y ihx ihy x n ihx, { simp [of_nterm, eval_singleton] }, { simp [of_nterm, eval_of_const, nterm.eval] }, { simp [of_nterm, eval_add, nterm.eval, ihx, ihy] }, { cases y; try {simp [of_nterm, eval_singleton]}, simp [eval_mul, nterm.eval, ihx] }, { simp [of_nterm, eval_singleton] } end end sterm end polya.field
###################################################################### # Complex numbers `is_element/CC` := (x) -> type(x,constant): `is_equal/CC` := (x,y) -> evalb(simplify(y-x) = 0): `is_leq/CC` := NULL; `is_leq_lex/CC` := proc(x,y) local z; z := simplify(y - x); if is(Re(z) > 0) then return true; elif is(Re(z) < 0) then return false; elif is(Im(z) > 0) then return true; elif is(Im(z) < 0) then return false; fi; return true; end: `random_element/CC` := proc() rand(-720..720)()/(360) + rand(-720..720)()/(360) * I; end: `list_elements/CC` := NULL; `count_elements/CC` := NULL; ###################################################################### # C(N) is the vector space CC^N `is_element/C` := (N::posint) -> (x) -> type(x,[constant$N]); `is_equal/C` := (N::posint) -> (x,y) -> evalb(simplify(x -~ y) = [0$N]); `is_leq/C` := NULL; `is_leq_lex/C` := (N::posint) -> proc(x,y) local i,z; for i from 1 to n do z := simplify(y[i] - x[i]); if is(Re(z) > 0) then return true; elif is(Re(z) < 0) then return false; elif is(Im(z) > 0) then return true; elif is(Im(z) < 0) then return false; fi; od; return true; end: `is_zero/C` := (N::posint) -> (x) -> evalb(simplify(x) = [0$N]); `norm_2/C` := (N::posint) -> proc(x) local i; sqrt(add(abs(x[i])^2,i=1..N)); end: `dot/C` := (N::posint) -> proc(x,y) local i; add(x[i]*conjugate(y[i]),i=1..N); end: `d_2/C` := (N::posint) -> (x,y) -> `norm_2/C`(N)(x -~ y); `random_element/C` := (N::posint) -> proc() local i; [seq(`random_element/CC`(),i=1..N)] end; `list_elements/C` := NULL; `count_elements/C` := NULL;
function X = stack2vecs(S) %STACK2VECS Convert stack to observation-by-features matrix. % Usage: % X = stack2vecs(S) % % Args: % S: 4-d array of size [h, w, c, n] % % Returns: % X: 2-d array of size [n, (h * w * c)] % % See also: vecs2stack if ndims(S) == 3; S = permute(S,[1 2 4 3]); end X = reshape(S,[],size(S,4))'; end
[STATEMENT] lemma arr_Set_arr_ParD: assumes "arr_Set \<alpha> T" shows "arr_Par \<alpha> T" and "\<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. arr_Par \<alpha> T &&& \<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr> [PROOF STEP] proof- [PROOF STATE] proof (state) goal (2 subgoals): 1. arr_Par \<alpha> T 2. \<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr> [PROOF STEP] interpret arr_Set \<alpha> T [PROOF STATE] proof (prove) goal (1 subgoal): 1. arr_Set \<alpha> T [PROOF STEP] by (rule assms) [PROOF STATE] proof (state) goal (2 subgoals): 1. arr_Par \<alpha> T 2. \<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr> [PROOF STEP] show "arr_Par \<alpha> T" and "\<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. arr_Par \<alpha> T &&& \<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr> [PROOF STEP] by (rule arr_Par_axioms) (auto simp: dg_Set_cs_simps) [PROOF STATE] proof (state) this: arr_Par \<alpha> T \<D>\<^sub>\<circ> (T\<lparr>ArrVal\<rparr>) = T\<lparr>ArrDom\<rparr> goal: No subgoals! [PROOF STEP] qed
%\chapter{Linux driver} The Linux SocketCAN driver can be build as \verb|ctucanfd.ko|. Device configuration is specified via device tree entry with the following structure: \begin{verbatim} CTU_CAN_FD_0: CTU_CAN_FD@43c30000 { compatible = "ctu,canfd-2"; /* platform-dependent registers address */ reg = <0x43c30000 0x10000>; /* platform-dependent interrupt configuration */ interrupt-parent = <&intc>; interrupts = <0 30 4>; /* CAN clock source */ clocks = <&clkc 15>; }; \end{verbatim} General information about SocketCAN may be found in Linux kernel documentation \cite{doc:socketcan}. % TODO: ref % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Initialization} The core is reset on probe (after the module is loaded or the device appears in the device tree) and on device bring-up. Most of the initialization is done on device bring-up (\verb|ctucan_open|), probe mainly collects device info, initializes internal structures and checks that the device is compatible (via DEVICE\_ID and VERSION registers). % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Mode configuration} Following modes defined in Linux kernel are supported and may be selectively turned on and off: \begin{itemize} \item Oneshot (via retransmit limit) \item Bus error reporting \item Listen only \item Triple sampling \item FD mode \item Presume ACK \item FD non-iso \item \textit{loopback is not supported} (see \ref{sec:linux:unsupported-features}) \end{itemize} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Bitrate configuration} Nominal and data bitrate setting is performed in \verb|ctucan_set_bittiming| and \verb|ctucan_set_data_bittiming|, respectively. Although the bitrate setting is also performed on device bring-up (\verb|ctucan_chip_start|), it is necessary to perform it early, because the timing values calculated in the kernel might require adjusting. This way the adjustments are observable immediately instead of until after chip start. The kernel timing calculation functions have only constraints on \textit{tseg1}, which is \textit{prop\_seg} + \textit{phase1\_seg} combined. \textit{tseg1} is then split in half and stored into \textit{prog\_seg} and \textit{phase\_seg1}. In CTU CAN FD, \textit{PROP} is 7 bits wide but \textit{PH1} only 6, so the values must be re-distributed. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Frame RX} % TODO: diagram %ISR -> schedule NAPI queue ...> \verb|ctucan_rx_poll| -> loop(\verb|ctucan_rx|) -> \verb|napi_complete()| When NAPI polling is scheduled, the \verb|ctucan_rx_poll| routine continually processes RX frames (via \verb|ctucan_rx|) until either there is no frame in hardware RX FIFO (in which case the NAPI queue is marked as complete) or a maximum quota is reached. Before the NAPI polling is scheduled, RXBNEI (and DOI) interrupts have to be disabled (but not masked). They are re-enabled when all frames are read after the NAPI queue is marked as complete. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Frame TX} % TODO: diagram The core has several TX buffers with adjustable priority. For the purposes of SocketCAN, they are used in FIFO fashion by rotating the priorities on each completed TX frame. ID of next empty buffer is kept in \verb|txb_head|, ID of the first full buffer (awaiting completion) in \verb|txb_tail| (modulo the number of buffers). TXB\#0 has the highest priority, each subsequent buffer has priority one lower. \begin{figure} \centering \begin{subfigure}[t]{0.32\textwidth} \begin{tabular}{lc|c|c|c} TXB\# & 0 & 1 & 2 & 3 \\\hline Seq & A & B & C & \\ Prio & 7 & 6 & 5 & 4 \\\hline & & T & & H \\ \end{tabular} \caption{3 frames are queued.} \end{subfigure} ~% \noindent \begin{subfigure}[t]{0.32\textwidth} \begin{tabular}{lc|c|c|c} TXB\# & 0 & 1 & 2 & 3 \\\hline Seq & & B & C & \\ Prio & 4 & 7 & 6 & 5 \\\hline & & T & & H \\ \end{tabular} \caption{Frame A was successfully sent and the priorities were rotated.} \end{subfigure} ~% \noindent \begin{subfigure}[t]{0.32\textwidth} \begin{tabular}{lc|c|c|c|c} TXB\# & 0 & 1 & 2 & 3 & 0' \\\hline Seq & E & B & C & D & \\ Prio & 4 & 7 & 6 & 5 & \\\hline & & T & & & H \\ \end{tabular} \cprotect\caption{2 new frames (D, E) were enqueued. Notice that the priorities did not have to be adjusted. \verb|txb_head| now contains the value 5 which indicates TXB\#0, but allows us to detect that all buffers are full.} \end{subfigure} \cprotect\caption{TXB priority rotation example. Empty Seq means the buffer is empty. Higher priority number means higher priority. H and T mark \verb|txb_head| and \verb|txb_tail|, respectively.} \end{figure} The network subsystem submits TX frames via \verb|ctucan_start_xmit|. There should be at least one TXB in state TX\_ETY, otherwise an error is reported and handled gracefully (the TX queue is stopped). Because the buffers are managed in FIFO fashion, it is assumed that the buffer with ID \verb|txb_head| is empty and the frame is inserted there. If all TX buffers are now full, the TX queue is stopped. The driver gets to know about TX buffer state change via TXBHCI. In this interrupt handler (\verb|ctucan_tx_interrupt|), it is again assumed that the buffers come into a final (completed) state in FIFO order. This assumption holds even if the transmission is aborted or retransmit limit is set. If the next buffer is in a final state, we process it. Otherwise, we must: \begin{enumerate} \item Clear the TXBHCI interrupt -- because it was probably set again for the next buffers we were processing \item Check the next buffer \textbf{again} -- because the TXBHCI might have been set just before we cleared it, but after we have checked the buffer the first time). If it is in a final state, we repeat the whole process. \end{enumerate} We also know the upper bound of the number of TX buffers to handle: the number of frames currently queued in the controller (\verb|txb_head| $-$ \verb|txb_tail|). No more buffers than this are tested (saves bus access for the final buffer). % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Unsupported features} \label{sec:linux:unsupported-features} \begin{itemize} \item HW frame filters \item Self-test mode (a.k.a. internal loopback) \item Timestamp recording for RX and TX frames \item Time-based transmission \item Setting of error counters from userspace \end{itemize} There is no infrastructure for HW frame filters in Linux kernel, because SW filters are more flexible and claimed to be sufficient performance-wise \cite{linux:socketcan}. Thus no support for HW filtering is planned for the Linux driver. Self-test mode, as implemented by the core (at the moment of writing), does not meet the requirements for self-test mode in Linux. That may, however, change in further releases. Support for hardware-assisted frame timestamping is planned for future releases. Kernel API for time-based transmission should be merged in v4.19 and the driver might add support for this in later releases. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Error handling} \subsection{TX Frame drop} In oneshot mode, when a TX frame is dropped (TXB ends up in TX\_ERR mode), the \verb|tx_dropped| statistics counter is incremented. The same happens for TX\_ABT mode, although buffer abort is never issued from the driver and hence this should never happen. \subsection{Bus errors} \textsc{Error Passive}, \textsc{Error Warning} and \textsc{Bus Off} situations are reported to userspace via appropriate generated error frames (see \cite{linux:socketcan}). Bus errors (situations leading to transmission of an error frame) and Arbitration Lost events are received via BEI and ALI (if enabled via BERR mode flag) and also reported to userspace via generated error frames. \subsection{RX overrun} Reporting RX FIFO overrun is likewise handled via generated error frame. However, special care is needed when dealing with DOI. DOI must be disabled together with RXBNE when NAPI polling is scheduled. Furthermore, when clearing the overrun flag, both Data Overrun Flag and interrupt status must be cleared, in this order. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(* Title: ZF/ArithSimp.thy Author: Lawrence C Paulson, Cambridge University Computer Laboratory Copyright 2000 University of Cambridge *) section\<open>Arithmetic with simplification\<close> theory ArithSimp imports Arith begin ML_file \<open>~~/src/Provers/Arith/cancel_numerals.ML\<close> ML_file \<open>~~/src/Provers/Arith/combine_numerals.ML\<close> ML_file \<open>arith_data.ML\<close> subsection\<open>Difference\<close> lemma diff_self_eq_0 [simp]: "m #- m = 0" apply (subgoal_tac "natify (m) #- natify (m) = 0") apply (rule_tac [2] natify_in_nat [THEN nat_induct], auto) done (**Addition is the inverse of subtraction**) (*We need m:nat even if we replace the RHS by natify(m), for consider e.g. n=2, m=omega; then n + (m-n) = 2 + (0-2) = 2 \<noteq> 0 = natify(m).*) lemma add_diff_inverse: "\<lbrakk>n \<le> m; m:nat\<rbrakk> \<Longrightarrow> n #+ (m#-n) = m" apply (frule lt_nat_in_nat, erule nat_succI) apply (erule rev_mp) apply (rule_tac m = m and n = n in diff_induct, auto) done lemma add_diff_inverse2: "\<lbrakk>n \<le> m; m:nat\<rbrakk> \<Longrightarrow> (m#-n) #+ n = m" apply (frule lt_nat_in_nat, erule nat_succI) apply (simp (no_asm_simp) add: add_commute add_diff_inverse) done (*Proof is IDENTICAL to that of add_diff_inverse*) lemma diff_succ: "\<lbrakk>n \<le> m; m:nat\<rbrakk> \<Longrightarrow> succ(m) #- n = succ(m#-n)" apply (frule lt_nat_in_nat, erule nat_succI) apply (erule rev_mp) apply (rule_tac m = m and n = n in diff_induct) apply (simp_all (no_asm_simp)) done lemma zero_less_diff [simp]: "\<lbrakk>m: nat; n: nat\<rbrakk> \<Longrightarrow> 0 < (n #- m) \<longleftrightarrow> m<n" apply (rule_tac m = m and n = n in diff_induct) apply (simp_all (no_asm_simp)) done (** Difference distributes over multiplication **) lemma diff_mult_distrib: "(m #- n) #* k = (m #* k) #- (n #* k)" apply (subgoal_tac " (natify (m) #- natify (n)) #* natify (k) = (natify (m) #* natify (k)) #- (natify (n) #* natify (k))") apply (rule_tac [2] m = "natify (m) " and n = "natify (n) " in diff_induct) apply (simp_all add: diff_cancel) done lemma diff_mult_distrib2: "k #* (m #- n) = (k #* m) #- (k #* n)" apply (simp (no_asm) add: mult_commute [of k] diff_mult_distrib) done subsection\<open>Remainder\<close> (*We need m:nat even with natify*) lemma div_termination: "\<lbrakk>0<n; n \<le> m; m:nat\<rbrakk> \<Longrightarrow> m #- n < m" apply (frule lt_nat_in_nat, erule nat_succI) apply (erule rev_mp) apply (erule rev_mp) apply (rule_tac m = m and n = n in diff_induct) apply (simp_all (no_asm_simp) add: diff_le_self) done (*for mod and div*) lemmas div_rls = nat_typechecks Ord_transrec_type apply_funtype div_termination [THEN ltD] nat_into_Ord not_lt_iff_le [THEN iffD1] lemma raw_mod_type: "\<lbrakk>m:nat; n:nat\<rbrakk> \<Longrightarrow> raw_mod (m, n) \<in> nat" unfolding raw_mod_def apply (rule Ord_transrec_type) apply (auto simp add: nat_into_Ord [THEN Ord_0_lt_iff]) apply (blast intro: div_rls) done lemma mod_type [TC,iff]: "m mod n \<in> nat" unfolding mod_def apply (simp (no_asm) add: mod_def raw_mod_type) done (** Aribtrary definitions for division by zero. Useful to simplify certain equations **) lemma DIVISION_BY_ZERO_DIV: "a div 0 = 0" unfolding div_def apply (rule raw_div_def [THEN def_transrec, THEN trans]) apply (simp (no_asm_simp)) done (*NOT for adding to default simpset*) lemma DIVISION_BY_ZERO_MOD: "a mod 0 = natify(a)" unfolding mod_def apply (rule raw_mod_def [THEN def_transrec, THEN trans]) apply (simp (no_asm_simp)) done (*NOT for adding to default simpset*) lemma raw_mod_less: "m<n \<Longrightarrow> raw_mod (m,n) = m" apply (rule raw_mod_def [THEN def_transrec, THEN trans]) apply (simp (no_asm_simp) add: div_termination [THEN ltD]) done lemma mod_less [simp]: "\<lbrakk>m<n; n \<in> nat\<rbrakk> \<Longrightarrow> m mod n = m" apply (frule lt_nat_in_nat, assumption) apply (simp (no_asm_simp) add: mod_def raw_mod_less) done lemma raw_mod_geq: "\<lbrakk>0<n; n \<le> m; m:nat\<rbrakk> \<Longrightarrow> raw_mod (m, n) = raw_mod (m#-n, n)" apply (frule lt_nat_in_nat, erule nat_succI) apply (rule raw_mod_def [THEN def_transrec, THEN trans]) apply (simp (no_asm_simp) add: div_termination [THEN ltD] not_lt_iff_le [THEN iffD2], blast) done lemma mod_geq: "\<lbrakk>n \<le> m; m:nat\<rbrakk> \<Longrightarrow> m mod n = (m#-n) mod n" apply (frule lt_nat_in_nat, erule nat_succI) apply (case_tac "n=0") apply (simp add: DIVISION_BY_ZERO_MOD) apply (simp add: mod_def raw_mod_geq nat_into_Ord [THEN Ord_0_lt_iff]) done subsection\<open>Division\<close> lemma raw_div_type: "\<lbrakk>m:nat; n:nat\<rbrakk> \<Longrightarrow> raw_div (m, n) \<in> nat" unfolding raw_div_def apply (rule Ord_transrec_type) apply (auto simp add: nat_into_Ord [THEN Ord_0_lt_iff]) apply (blast intro: div_rls) done lemma div_type [TC,iff]: "m div n \<in> nat" unfolding div_def apply (simp (no_asm) add: div_def raw_div_type) done lemma raw_div_less: "m<n \<Longrightarrow> raw_div (m,n) = 0" apply (rule raw_div_def [THEN def_transrec, THEN trans]) apply (simp (no_asm_simp) add: div_termination [THEN ltD]) done lemma div_less [simp]: "\<lbrakk>m<n; n \<in> nat\<rbrakk> \<Longrightarrow> m div n = 0" apply (frule lt_nat_in_nat, assumption) apply (simp (no_asm_simp) add: div_def raw_div_less) done lemma raw_div_geq: "\<lbrakk>0<n; n \<le> m; m:nat\<rbrakk> \<Longrightarrow> raw_div(m,n) = succ(raw_div(m#-n, n))" apply (subgoal_tac "n \<noteq> 0") prefer 2 apply blast apply (frule lt_nat_in_nat, erule nat_succI) apply (rule raw_div_def [THEN def_transrec, THEN trans]) apply (simp (no_asm_simp) add: div_termination [THEN ltD] not_lt_iff_le [THEN iffD2] ) done lemma div_geq [simp]: "\<lbrakk>0<n; n \<le> m; m:nat\<rbrakk> \<Longrightarrow> m div n = succ ((m#-n) div n)" apply (frule lt_nat_in_nat, erule nat_succI) apply (simp (no_asm_simp) add: div_def raw_div_geq) done declare div_less [simp] div_geq [simp] (*A key result*) lemma mod_div_lemma: "\<lbrakk>m: nat; n: nat\<rbrakk> \<Longrightarrow> (m div n)#*n #+ m mod n = m" apply (case_tac "n=0") apply (simp add: DIVISION_BY_ZERO_MOD) apply (simp add: nat_into_Ord [THEN Ord_0_lt_iff]) apply (erule complete_induct) apply (case_tac "x<n") txt\<open>case x<n\<close> apply (simp (no_asm_simp)) txt\<open>case \<^term>\<open>n \<le> x\<close>\<close> apply (simp add: not_lt_iff_le add_assoc mod_geq div_termination [THEN ltD] add_diff_inverse) done lemma mod_div_equality_natify: "(m div n)#*n #+ m mod n = natify(m)" apply (subgoal_tac " (natify (m) div natify (n))#*natify (n) #+ natify (m) mod natify (n) = natify (m) ") apply force apply (subst mod_div_lemma, auto) done lemma mod_div_equality: "m: nat \<Longrightarrow> (m div n)#*n #+ m mod n = m" apply (simp (no_asm_simp) add: mod_div_equality_natify) done subsection\<open>Further Facts about Remainder\<close> text\<open>(mainly for mutilated chess board)\<close> lemma mod_succ_lemma: "\<lbrakk>0<n; m:nat; n:nat\<rbrakk> \<Longrightarrow> succ(m) mod n = (if succ(m mod n) = n then 0 else succ(m mod n))" apply (erule complete_induct) apply (case_tac "succ (x) <n") txt\<open>case succ(x) < n\<close> apply (simp (no_asm_simp) add: nat_le_refl [THEN lt_trans] succ_neq_self) apply (simp add: ltD [THEN mem_imp_not_eq]) txt\<open>case \<^term>\<open>n \<le> succ(x)\<close>\<close> apply (simp add: mod_geq not_lt_iff_le) apply (erule leE) apply (simp (no_asm_simp) add: mod_geq div_termination [THEN ltD] diff_succ) txt\<open>equality case\<close> apply (simp add: diff_self_eq_0) done lemma mod_succ: "n:nat \<Longrightarrow> succ(m) mod n = (if succ(m mod n) = n then 0 else succ(m mod n))" apply (case_tac "n=0") apply (simp (no_asm_simp) add: natify_succ DIVISION_BY_ZERO_MOD) apply (subgoal_tac "natify (succ (m)) mod n = (if succ (natify (m) mod n) = n then 0 else succ (natify (m) mod n))") prefer 2 apply (subst natify_succ) apply (rule mod_succ_lemma) apply (auto simp del: natify_succ simp add: nat_into_Ord [THEN Ord_0_lt_iff]) done lemma mod_less_divisor: "\<lbrakk>0<n; n:nat\<rbrakk> \<Longrightarrow> m mod n < n" apply (subgoal_tac "natify (m) mod n < n") apply (rule_tac [2] i = "natify (m) " in complete_induct) apply (case_tac [3] "x<n", auto) txt\<open>case \<^term>\<open>n \<le> x\<close>\<close> apply (simp add: mod_geq not_lt_iff_le div_termination [THEN ltD]) done lemma mod_1_eq [simp]: "m mod 1 = 0" by (cut_tac n = 1 in mod_less_divisor, auto) lemma mod2_cases: "b<2 \<Longrightarrow> k mod 2 = b | k mod 2 = (if b=1 then 0 else 1)" apply (subgoal_tac "k mod 2: 2") prefer 2 apply (simp add: mod_less_divisor [THEN ltD]) apply (drule ltD, auto) done lemma mod2_succ_succ [simp]: "succ(succ(m)) mod 2 = m mod 2" apply (subgoal_tac "m mod 2: 2") prefer 2 apply (simp add: mod_less_divisor [THEN ltD]) apply (auto simp add: mod_succ) done lemma mod2_add_more [simp]: "(m#+m#+n) mod 2 = n mod 2" apply (subgoal_tac " (natify (m) #+natify (m) #+n) mod 2 = n mod 2") apply (rule_tac [2] n = "natify (m) " in nat_induct) apply auto done lemma mod2_add_self [simp]: "(m#+m) mod 2 = 0" by (cut_tac n = 0 in mod2_add_more, auto) subsection\<open>Additional theorems about \<open>\<le>\<close>\<close> lemma add_le_self: "m:nat \<Longrightarrow> m \<le> (m #+ n)" apply (simp (no_asm_simp)) done lemma add_le_self2: "m:nat \<Longrightarrow> m \<le> (n #+ m)" apply (simp (no_asm_simp)) done (*** Monotonicity of Multiplication ***) lemma mult_le_mono1: "\<lbrakk>i \<le> j; j:nat\<rbrakk> \<Longrightarrow> (i#*k) \<le> (j#*k)" apply (subgoal_tac "natify (i) #*natify (k) \<le> j#*natify (k) ") apply (frule_tac [2] lt_nat_in_nat) apply (rule_tac [3] n = "natify (k) " in nat_induct) apply (simp_all add: add_le_mono) done (* @{text"\<le>"} monotonicity, BOTH arguments*) lemma mult_le_mono: "\<lbrakk>i \<le> j; k \<le> l; j:nat; l:nat\<rbrakk> \<Longrightarrow> i#*k \<le> j#*l" apply (rule mult_le_mono1 [THEN le_trans], assumption+) apply (subst mult_commute, subst mult_commute, rule mult_le_mono1, assumption+) done (*strict, in 1st argument; proof is by induction on k>0. I can't see how to relax the typing conditions.*) lemma mult_lt_mono2: "\<lbrakk>i<j; 0<k; j:nat; k:nat\<rbrakk> \<Longrightarrow> k#*i < k#*j" apply (erule zero_lt_natE) apply (frule_tac [2] lt_nat_in_nat) apply (simp_all (no_asm_simp)) apply (induct_tac "x") apply (simp_all (no_asm_simp) add: add_lt_mono) done lemma mult_lt_mono1: "\<lbrakk>i<j; 0<k; j:nat; k:nat\<rbrakk> \<Longrightarrow> i#*k < j#*k" apply (simp (no_asm_simp) add: mult_lt_mono2 mult_commute [of _ k]) done lemma add_eq_0_iff [iff]: "m#+n = 0 \<longleftrightarrow> natify(m)=0 \<and> natify(n)=0" apply (subgoal_tac "natify (m) #+ natify (n) = 0 \<longleftrightarrow> natify (m) =0 \<and> natify (n) =0") apply (rule_tac [2] n = "natify (m) " in natE) apply (rule_tac [4] n = "natify (n) " in natE) apply auto done lemma zero_lt_mult_iff [iff]: "0 < m#*n \<longleftrightarrow> 0 < natify(m) \<and> 0 < natify(n)" apply (subgoal_tac "0 < natify (m) #*natify (n) \<longleftrightarrow> 0 < natify (m) \<and> 0 < natify (n) ") apply (rule_tac [2] n = "natify (m) " in natE) apply (rule_tac [4] n = "natify (n) " in natE) apply (rule_tac [3] n = "natify (n) " in natE) apply auto done lemma mult_eq_1_iff [iff]: "m#*n = 1 \<longleftrightarrow> natify(m)=1 \<and> natify(n)=1" apply (subgoal_tac "natify (m) #* natify (n) = 1 \<longleftrightarrow> natify (m) =1 \<and> natify (n) =1") apply (rule_tac [2] n = "natify (m) " in natE) apply (rule_tac [4] n = "natify (n) " in natE) apply auto done lemma mult_is_zero: "\<lbrakk>m: nat; n: nat\<rbrakk> \<Longrightarrow> (m #* n = 0) \<longleftrightarrow> (m = 0 | n = 0)" apply auto apply (erule natE) apply (erule_tac [2] natE, auto) done lemma mult_is_zero_natify [iff]: "(m #* n = 0) \<longleftrightarrow> (natify(m) = 0 | natify(n) = 0)" apply (cut_tac m = "natify (m) " and n = "natify (n) " in mult_is_zero) apply auto done subsection\<open>Cancellation Laws for Common Factors in Comparisons\<close> lemma mult_less_cancel_lemma: "\<lbrakk>k: nat; m: nat; n: nat\<rbrakk> \<Longrightarrow> (m#*k < n#*k) \<longleftrightarrow> (0<k \<and> m<n)" apply (safe intro!: mult_lt_mono1) apply (erule natE, auto) apply (rule not_le_iff_lt [THEN iffD1]) apply (drule_tac [3] not_le_iff_lt [THEN [2] rev_iffD2]) prefer 5 apply (blast intro: mult_le_mono1, auto) done lemma mult_less_cancel2 [simp]: "(m#*k < n#*k) \<longleftrightarrow> (0 < natify(k) \<and> natify(m) < natify(n))" apply (rule iff_trans) apply (rule_tac [2] mult_less_cancel_lemma, auto) done lemma mult_less_cancel1 [simp]: "(k#*m < k#*n) \<longleftrightarrow> (0 < natify(k) \<and> natify(m) < natify(n))" apply (simp (no_asm) add: mult_less_cancel2 mult_commute [of k]) done lemma mult_le_cancel2 [simp]: "(m#*k \<le> n#*k) \<longleftrightarrow> (0 < natify(k) \<longrightarrow> natify(m) \<le> natify(n))" apply (simp (no_asm_simp) add: not_lt_iff_le [THEN iff_sym]) apply auto done lemma mult_le_cancel1 [simp]: "(k#*m \<le> k#*n) \<longleftrightarrow> (0 < natify(k) \<longrightarrow> natify(m) \<le> natify(n))" apply (simp (no_asm_simp) add: not_lt_iff_le [THEN iff_sym]) apply auto done lemma mult_le_cancel_le1: "k \<in> nat \<Longrightarrow> k #* m \<le> k \<longleftrightarrow> (0 < k \<longrightarrow> natify(m) \<le> 1)" by (cut_tac k = k and m = m and n = 1 in mult_le_cancel1, auto) lemma Ord_eq_iff_le: "\<lbrakk>Ord(m); Ord(n)\<rbrakk> \<Longrightarrow> m=n \<longleftrightarrow> (m \<le> n \<and> n \<le> m)" by (blast intro: le_anti_sym) lemma mult_cancel2_lemma: "\<lbrakk>k: nat; m: nat; n: nat\<rbrakk> \<Longrightarrow> (m#*k = n#*k) \<longleftrightarrow> (m=n | k=0)" apply (simp (no_asm_simp) add: Ord_eq_iff_le [of "m#*k"] Ord_eq_iff_le [of m]) apply (auto simp add: Ord_0_lt_iff) done lemma mult_cancel2 [simp]: "(m#*k = n#*k) \<longleftrightarrow> (natify(m) = natify(n) | natify(k) = 0)" apply (rule iff_trans) apply (rule_tac [2] mult_cancel2_lemma, auto) done lemma mult_cancel1 [simp]: "(k#*m = k#*n) \<longleftrightarrow> (natify(m) = natify(n) | natify(k) = 0)" apply (simp (no_asm) add: mult_cancel2 mult_commute [of k]) done (** Cancellation law for division **) lemma div_cancel_raw: "\<lbrakk>0<n; 0<k; k:nat; m:nat; n:nat\<rbrakk> \<Longrightarrow> (k#*m) div (k#*n) = m div n" apply (erule_tac i = m in complete_induct) apply (case_tac "x<n") apply (simp add: div_less zero_lt_mult_iff mult_lt_mono2) apply (simp add: not_lt_iff_le zero_lt_mult_iff le_refl [THEN mult_le_mono] div_geq diff_mult_distrib2 [symmetric] div_termination [THEN ltD]) done lemma div_cancel: "\<lbrakk>0 < natify(n); 0 < natify(k)\<rbrakk> \<Longrightarrow> (k#*m) div (k#*n) = m div n" apply (cut_tac k = "natify (k) " and m = "natify (m)" and n = "natify (n)" in div_cancel_raw) apply auto done subsection\<open>More Lemmas about Remainder\<close> lemma mult_mod_distrib_raw: "\<lbrakk>k:nat; m:nat; n:nat\<rbrakk> \<Longrightarrow> (k#*m) mod (k#*n) = k #* (m mod n)" apply (case_tac "k=0") apply (simp add: DIVISION_BY_ZERO_MOD) apply (case_tac "n=0") apply (simp add: DIVISION_BY_ZERO_MOD) apply (simp add: nat_into_Ord [THEN Ord_0_lt_iff]) apply (erule_tac i = m in complete_induct) apply (case_tac "x<n") apply (simp (no_asm_simp) add: mod_less zero_lt_mult_iff mult_lt_mono2) apply (simp add: not_lt_iff_le zero_lt_mult_iff le_refl [THEN mult_le_mono] mod_geq diff_mult_distrib2 [symmetric] div_termination [THEN ltD]) done lemma mod_mult_distrib2: "k #* (m mod n) = (k#*m) mod (k#*n)" apply (cut_tac k = "natify (k) " and m = "natify (m)" and n = "natify (n)" in mult_mod_distrib_raw) apply auto done lemma mult_mod_distrib: "(m mod n) #* k = (m#*k) mod (n#*k)" apply (simp (no_asm) add: mult_commute mod_mult_distrib2) done lemma mod_add_self2_raw: "n \<in> nat \<Longrightarrow> (m #+ n) mod n = m mod n" apply (subgoal_tac " (n #+ m) mod n = (n #+ m #- n) mod n") apply (simp add: add_commute) apply (subst mod_geq [symmetric], auto) done lemma mod_add_self2 [simp]: "(m #+ n) mod n = m mod n" apply (cut_tac n = "natify (n) " in mod_add_self2_raw) apply auto done lemma mod_add_self1 [simp]: "(n#+m) mod n = m mod n" apply (simp (no_asm_simp) add: add_commute mod_add_self2) done lemma mod_mult_self1_raw: "k \<in> nat \<Longrightarrow> (m #+ k#*n) mod n = m mod n" apply (erule nat_induct) apply (simp_all (no_asm_simp) add: add_left_commute [of _ n]) done lemma mod_mult_self1 [simp]: "(m #+ k#*n) mod n = m mod n" apply (cut_tac k = "natify (k) " in mod_mult_self1_raw) apply auto done lemma mod_mult_self2 [simp]: "(m #+ n#*k) mod n = m mod n" apply (simp (no_asm) add: mult_commute mod_mult_self1) done (*Lemma for gcd*) lemma mult_eq_self_implies_10: "m = m#*n \<Longrightarrow> natify(n)=1 | m=0" apply (subgoal_tac "m: nat") prefer 2 apply (erule ssubst) apply simp apply (rule disjCI) apply (drule sym) apply (rule Ord_linear_lt [of "natify(n)" 1]) apply simp_all apply (subgoal_tac "m #* n = 0", simp) apply (subst mult_natify2 [symmetric]) apply (simp del: mult_natify2) apply (drule nat_into_Ord [THEN Ord_0_lt, THEN [2] mult_lt_mono2], auto) done lemma less_imp_succ_add [rule_format]: "\<lbrakk>m<n; n: nat\<rbrakk> \<Longrightarrow> \<exists>k\<in>nat. n = succ(m#+k)" apply (frule lt_nat_in_nat, assumption) apply (erule rev_mp) apply (induct_tac "n") apply (simp_all (no_asm) add: le_iff) apply (blast elim!: leE intro!: add_0_right [symmetric] add_succ_right [symmetric]) done lemma less_iff_succ_add: "\<lbrakk>m: nat; n: nat\<rbrakk> \<Longrightarrow> (m<n) \<longleftrightarrow> (\<exists>k\<in>nat. n = succ(m#+k))" by (auto intro: less_imp_succ_add) lemma add_lt_elim2: "\<lbrakk>a #+ d = b #+ c; a < b; b \<in> nat; c \<in> nat; d \<in> nat\<rbrakk> \<Longrightarrow> c < d" by (drule less_imp_succ_add, auto) lemma add_le_elim2: "\<lbrakk>a #+ d = b #+ c; a \<le> b; b \<in> nat; c \<in> nat; d \<in> nat\<rbrakk> \<Longrightarrow> c \<le> d" by (drule less_imp_succ_add, auto) subsubsection\<open>More Lemmas About Difference\<close> lemma diff_is_0_lemma: "\<lbrakk>m: nat; n: nat\<rbrakk> \<Longrightarrow> m #- n = 0 \<longleftrightarrow> m \<le> n" apply (rule_tac m = m and n = n in diff_induct, simp_all) done lemma diff_is_0_iff: "m #- n = 0 \<longleftrightarrow> natify(m) \<le> natify(n)" by (simp add: diff_is_0_lemma [symmetric]) lemma nat_lt_imp_diff_eq_0: "\<lbrakk>a:nat; b:nat; a<b\<rbrakk> \<Longrightarrow> a #- b = 0" by (simp add: diff_is_0_iff le_iff) lemma raw_nat_diff_split: "\<lbrakk>a:nat; b:nat\<rbrakk> \<Longrightarrow> (P(a #- b)) \<longleftrightarrow> ((a < b \<longrightarrow>P(0)) \<and> (\<forall>d\<in>nat. a = b #+ d \<longrightarrow> P(d)))" apply (case_tac "a < b") apply (force simp add: nat_lt_imp_diff_eq_0) apply (rule iffI, force, simp) apply (drule_tac x="a#-b" in bspec) apply (simp_all add: Ordinal.not_lt_iff_le add_diff_inverse) done lemma nat_diff_split: "(P(a #- b)) \<longleftrightarrow> (natify(a) < natify(b) \<longrightarrow>P(0)) \<and> (\<forall>d\<in>nat. natify(a) = b #+ d \<longrightarrow> P(d))" apply (cut_tac P=P and a="natify(a)" and b="natify(b)" in raw_nat_diff_split) apply simp_all done text\<open>Difference and less-than\<close> lemma diff_lt_imp_lt: "\<lbrakk>(k#-i) < (k#-j); i\<in>nat; j\<in>nat; k\<in>nat\<rbrakk> \<Longrightarrow> j<i" apply (erule rev_mp) apply (simp split: nat_diff_split, auto) apply (blast intro: add_le_self lt_trans1) apply (rule not_le_iff_lt [THEN iffD1], auto) apply (subgoal_tac "i #+ da < j #+ d", force) apply (blast intro: add_le_lt_mono) done lemma lt_imp_diff_lt: "\<lbrakk>j<i; i\<le>k; k\<in>nat\<rbrakk> \<Longrightarrow> (k#-i) < (k#-j)" apply (frule le_in_nat, assumption) apply (frule lt_nat_in_nat, assumption) apply (simp split: nat_diff_split, auto) apply (blast intro: lt_asym lt_trans2) apply (blast intro: lt_irrefl lt_trans2) apply (rule not_le_iff_lt [THEN iffD1], auto) apply (subgoal_tac "j #+ d < i #+ da", force) apply (blast intro: add_lt_le_mono) done lemma diff_lt_iff_lt: "\<lbrakk>i\<le>k; j\<in>nat; k\<in>nat\<rbrakk> \<Longrightarrow> (k#-i) < (k#-j) \<longleftrightarrow> j<i" apply (frule le_in_nat, assumption) apply (blast intro: lt_imp_diff_lt diff_lt_imp_lt) done end
Ross utilized his many hockey connections throughout Canada and the United States to sign players . Even so , the team started poorly . Early in the first season the University of Toronto hockey team was in Boston for matches against local universities . The team 's manager , Conn Smythe , who later owned and managed the Toronto Maple Leafs , said that his team could easily defeat the Bruins — Ross 's team had won only two of their first fifteen NHL games . This began a feud between Smythe and Ross which lasted for over 40 years , until Ross ' death ; while mostly confined to newspaper reports , they refused to speak to each other at NHL Board of Governor meetings . The Bruins finished their first season with six wins in thirty games , one of the worst records in the history of the league . Several records were set over the course of the season ; the three home wins are tied for the second fewest ever , and an eleven @-@ game losing streak from December 8 , 1924 , until February 17 , 1925 , set a record for longest losing streak , surpassed in 2004 and now second longest in history . With 17 wins in 36 games the following season , the team greatly improved , and finished one point out of a playoff spot .
We understand that medical emergencies do occur outside of normal business hours and are very stressful for all parties involved. We want to be as supportive as possible but it is physically and mentally impossible to be on call 24 hours a day, seven days a week. Most minor medical emergencies can be managed in a general practice setting but major, life threatening conditions are more likely to have a positive outcome when the patient is cared for in a facility that focuses on emergency care, equipped and staffed with personnel trained and experienced in treating such conditions. Open 24 hours, including holidays and weekends.
[STATEMENT] lemma image_block_set_constant_size: "size (B) = size (blocks_image B f)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. size B = size (blocks_image B f) [PROOF STEP] by (simp add: blocks_image_def)
% NOTE: DO NOT REMOVE THIS LINE XMAKEFILE_TOOL_CHAIN_CONFIGURATION function toolChainConfiguration = arduinouno() %ARDUINOUNO Defines a tool chain configuration % Copyright 2012 The MathWorks, Inc. try hSetup = realtime.setup.PackageInfo; spPkg = hSetup.getSpPkgInfo('Arduino Uno'); arduinoRootDir = hSetup.getTpPkgRootDir('ARDUINO', spPkg); catch me toolChainConfiguration = {}; return; end % General toolChainConfiguration.Configuration = 'Arduinouno'; toolChainConfiguration.Version = '2.0'; toolChainConfiguration.Description = 'MS Visual Studio'; toolChainConfiguration.Operational = true; toolChainConfiguration.Decorator = 'linkfoundation.xmakefile.decorator.eclipseDecorator'; % Make toolChainConfiguration.MakePath = @(src) fullfile(arduinoRootDir, 'hardware', 'tools', 'avr', 'utils', 'bin', 'make'); toolChainConfiguration.MakeFlags = '-f "[|||MW_XMK_GENERATED_FILE_NAME[R]|||]" [|||MW_XMK_ACTIVE_BUILD_ACTION_REF|||]'; toolChainConfiguration.MakeInclude = ''; % Compiler toolChainConfiguration.CompilerPath = @(src) fullfile(arduinoRootDir, 'hardware', 'tools', 'avr', 'bin', 'avr-gcc'); toolChainConfiguration.CompilerFlags = '-c -x none'; toolChainConfiguration.SourceExtensions = '.c,.cpp'; toolChainConfiguration.HeaderExtensions = '.h'; toolChainConfiguration.ObjectExtension = '.o'; % Linker toolChainConfiguration.LinkerPath = @(src) fullfile(arduinoRootDir, 'hardware', 'tools', 'avr', 'bin', 'avr-gcc'); toolChainConfiguration.LinkerFlags = '-o [|||MW_XMK_GENERATED_TARGET_REF|||]'; toolChainConfiguration.LibraryExtensions = '.lib,.a'; toolChainConfiguration.TargetExtension = '.elf'; toolChainConfiguration.TargetNamePrefix = ''; toolChainConfiguration.TargetNamePostfix = ''; % Archiver toolChainConfiguration.ArchiverPath = @(src) fullfile(arduinoRootDir, 'hardware', 'tools', 'avr', 'bin', 'avr-ar'); toolChainConfiguration.ArchiverFlags = '-crs $(TARGET_FILE)'; toolChainConfiguration.ArchiveExtension = '.a'; toolChainConfiguration.ArchiveNamePrefix = 'lib'; toolChainConfiguration.ArchiveNamePostfix = ''; % Pre-build toolChainConfiguration.PrebuildEnable = false; toolChainConfiguration.PrebuildToolPath = ''; toolChainConfiguration.PrebuildFlags = ''; % Post-build toolChainConfiguration.PostbuildEnable = true; toolChainConfiguration.PostbuildToolPath = @(src) fullfile(arduinoRootDir, 'hardware', 'tools', 'avr', 'bin', 'avr-objcopy'); toolChainConfiguration.PostbuildFlags = '-O ihex -R .eeprom $(TARGET) [|||MW_XMK_MODEL_NAME|||].hex'; % Execute toolChainConfiguration.ExecuteDefault = false; toolChainConfiguration.ExecuteToolPath = ''; toolChainConfiguration.ExecuteFlags = ''; % Directories toolChainConfiguration.DerivedPath = '[|||MW_XMK_SOURCE_PATH_REF|||]'; toolChainConfiguration.OutputPath = ''; % Custom toolChainConfiguration.Custom1 = ''; toolChainConfiguration.Custom2 = ''; toolChainConfiguration.Custom3 = ''; toolChainConfiguration.Custom4 = ''; toolChainConfiguration.Custom5 = ''; end % LocalWords: XMAKEFILE Uno linkfoundation xmakefile avr utils XMK crs ihex % LocalWords: eeprom
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.data.int.basic import Mathlib.category_theory.graded_object import Mathlib.category_theory.differential_object import Mathlib.PostPort universes v u u_1 namespace Mathlib /-! # Chain complexes We define a chain complex in `V` as a differential `ℤ`-graded object in `V`. This is fancy language for the obvious definition, and it seems we can use it straightforwardly: ``` example (C : chain_complex V) : C.X 5 ⟶ C.X 6 := C.d 5 ``` -/ /-- A `homological_complex V b` for `b : β` is a (co)chain complex graded by `β`, with differential in grading `b`. (We use the somewhat cumbersome `homological_complex` to avoid the name conflict with `ℂ`.) -/ def homological_complex (V : Type u) [category_theory.category V] [category_theory.limits.has_zero_morphisms V] {β : Type} [add_comm_group β] (b : β) := category_theory.differential_object (category_theory.graded_object_with_shift b V) /-- A chain complex in `V` is "just" a differential `ℤ`-graded object in `V`, with differential graded `-1`. -/ def chain_complex (V : Type u) [category_theory.category V] [category_theory.limits.has_zero_morphisms V] := homological_complex V (-1) /-- A cochain complex in `V` is "just" a differential `ℤ`-graded object in `V`, with differential graded `+1`. -/ def cochain_complex (V : Type u) [category_theory.category V] [category_theory.limits.has_zero_morphisms V] := homological_complex V 1 -- The chain groups of a chain complex `C` are accessed as `C.X i`, -- and the differentials as `C.d i : C.X i ⟶ C.X (i-1)`. namespace homological_complex @[simp] theorem d_squared {V : Type u} [category_theory.category V] [category_theory.limits.has_zero_morphisms V] {β : Type} [add_comm_group β] {b : β} (C : homological_complex V b) (i : β) : category_theory.differential_object.d C i ≫ category_theory.differential_object.d C (i + b) = 0 := sorry /-- A convenience lemma for morphisms of cochain complexes, picking out one component of the commutation relation. -/ -- I haven't been able to get this to work with projection notation: `f.comm_at i` @[simp] theorem comm_at {V : Type u} [category_theory.category V] [category_theory.limits.has_zero_morphisms V] {β : Type} [add_comm_group β] {b : β} {C : homological_complex V b} {D : homological_complex V b} (f : C ⟶ D) (i : β) : category_theory.differential_object.d C i ≫ category_theory.differential_object.hom.f f (i + b) = category_theory.differential_object.hom.f f i ≫ category_theory.differential_object.d D i := sorry @[simp] theorem comm {V : Type u} [category_theory.category V] [category_theory.limits.has_zero_morphisms V] {β : Type} [add_comm_group β] {b : β} {C : homological_complex V b} {D : homological_complex V b} (f : C ⟶ D) : category_theory.differential_object.d C ≫ category_theory.functor.map (category_theory.equivalence.functor (category_theory.shift (category_theory.graded_object_with_shift b V) ^ 1)) (category_theory.differential_object.hom.f f) = category_theory.differential_object.hom.f f ≫ category_theory.differential_object.d D := category_theory.differential_object.hom.comm (category_theory.graded_object_with_shift b V) (category_theory.graded_object.category_of_graded_objects β) (category_theory.graded_object.has_zero_morphisms β) (category_theory.graded_object.has_shift b) C D f /-- The forgetful functor from cochain complexes to graded objects, forgetting the differential. -/ def forget (V : Type u) [category_theory.category V] [category_theory.limits.has_zero_morphisms V] {β : Type} [add_comm_group β] {b : β} : homological_complex V b ⥤ category_theory.graded_object β V := category_theory.differential_object.forget (category_theory.graded_object_with_shift b V) protected instance inhabited {β : Type} [add_comm_group β] {b : β} : Inhabited (homological_complex (category_theory.discrete PUnit) b) := { default := 0 } end Mathlib
Business Tianjin Magazine - News Noetic & Untitled Black. Nov 7. Buy tickets! Noetic & Untitled Black. Nov 7. Buy tickets! Multiple award winning and constantly topical Sidi Larbi Cherkaoui created Noetic, along with a distinguished team comprising sculptor Antony Gormley, fashion designer duo Les Hommes, and composer Szymon Brzóska. The creation explores man's instinctive need to structure every detail of our existence, and our longing to break free of the rules and discover what lies beyond them. With at times mechanical, at times flowing, classical movements, the dancers construct, change and deconstruct reality. Untitled Black by Sharon Eyal/Gai Behar is pure, multi-layered, emotional choreography. Through its atmospheric and futuristic movement, embedded in a structure of strong composition, it takes us into a fantastic parallel universe. Live music by DJ Ori Lichtik plays an important role. Untitled Black has been created specifically for GöteborgsOperans Danskompani and eight dancers from Batsheva Dance Company.
If $f$ is a function from a first-countable space $X$ to a topological space $Y$, and if $f$ is sequentially continuous, then $f$ is continuous.
library(tidyverse) irs_data <- read.csv("irs.csv") Poverty <- irs_data %>% group_by(Year, Name) %>% mutate(Number_Total_exemptions = as.numeric(gsub(",","", Total.exemptions)), Number_Poor_exemptions = as.numeric(gsub(",","", Poor.exemptions))) %>% select(Year, Name, Number_Total_exemptions, Number_Poor_exemptions) top_5_poverty_states <- Poverty %>% filter(Name == "Mississippi" | Name == "Louisiana" | Name == "New Mexico" | Name == "Kentucky" | Name == "Arkansas") chart2 <- ggplot(data = top_5_poverty_states)+ geom_col(mapping = aes(x = Year, y = Number_Poor_exemptions, fill = Name))+ labs(title = "Poor Exemptions Indicating Poverty in Top 5 Poorest States ", subtitle = "From 1990 - 2018", x = "Year", y = "# of Poor Exemptions")+ facet_wrap(~Name)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AGUJournalTemplate.tex: this template file is for articles formatted with LaTeX % % This file includes commands and instructions % given in the order necessary to produce a final output that will % satisfy AGU requirements, including customized APA reference formatting. % % You may copy this file and give it your % article name, and enter your text. % % % Step 1: Set the \documentclass % % %% To submit your paper: \documentclass[draft]{agujournal2019} \usepackage{amsmath} \usepackage{amssymb} \usepackage{url} %this package should fix any errors with URLs in refs. \usepackage{lineno} \usepackage[inline]{trackchanges} %for better track changes. finalnew option will compile document with changes incorporated. \usepackage{soul} \linenumbers %%%%%%% % As of 2018 we recommend use of the TrackChanges package to mark revisions. % The trackchanges package adds five new LaTeX commands: % % \note[editor]{The note} % \annote[editor]{Text to annotate}{The note} % \add[editor]{Text to add} % \remove[editor]{Text to remove} % \change[editor]{Text to remove}{Text to add} % % complete documentation is here: http://trackchanges.sourceforge.net/ %%%%%%% \draftfalse %% Enter journal name below. %% Choose from this list of Journals: % % JGR: Atmospheres % JGR: Biogeosciences % JGR: Earth Surface % JGR: Oceans % JGR: Planets % JGR: Solid Earth % JGR: Space Physics % Global Biogeochemical Cycles % Geophysical Research Letters % Paleoceanography and Paleoclimatology % Radio Science % Reviews of Geophysics % Tectonics % Space Weather % Water Resources Research % Geochemistry, Geophysics, Geosystems % Journal of Advances in Modeling Earth Systems (JAMES) % Earth's Future % Earth and Space Science % Geohealth % % ie, \journalname{Water Resources Research} \journalname{JGR: Solid Earth} \begin{document} %% ------------------------------------------------------------------------ %% % Title % % (A title should be specific, informative, and brief. Use % abbreviations only if they are defined in the abstract. Titles that % start with general keywords then specific terms are optimized in % searches) % %% ------------------------------------------------------------------------ %% % Example: \title{This is a test title} \title{Depth and thickness of tectonic tremor in the northeastern Olympic Peninsula} %% ------------------------------------------------------------------------ %% % % AUTHORS AND AFFILIATIONS % %% ------------------------------------------------------------------------ %% % Authors are individuals who have significantly contributed to the % research and preparation of the article. Group authors are allowed, if % each author in the group is separately identified in an appendix.) % List authors by first name or initial followed by last name and % separated by commas. Use \affil{} to number affiliations, and % \thanks{} for author notes. % Additional author notes should be indicated with \thanks{} (for % example, for current addresses). % Example: \authors{A. B. Author\affil{1}\thanks{Current address, Antartica}, B. C. Author\affil{2,3}, and D. E. % Author\affil{3,4}\thanks{Also funded by Monsanto.}} \authors{A. Ducellier\affil{1}, K. C. Creager\affil{1}} % \affiliation{1}{First Affiliation} % \affiliation{2}{Second Affiliation} % \affiliation{3}{Third Affiliation} % \affiliation{4}{Fourth Affiliation} \affiliation{1}{University of Washington} %(repeat as many times as is necessary) %% Corresponding Author: % Corresponding author mailing address and e-mail address: % (include name and email addresses of the corresponding author. More % than one corresponding author is allowed in this LaTeX file and for % publication; but only one corresponding author is allowed in our % editorial system.) % Example: \correspondingauthor{First and Last Name}{[email protected]} \correspondingauthor{Ariane Ducellier}{[email protected]} %% Keypoints, final entry on title page. % List up to three key points (at least one is required) % Key Points summarize the main points and conclusions of the article % Each must be 140 characters or fewer with no special characters or punctuation and must be complete sentences % Example: % \begin{keypoints} % \item List up to three key points (at least one is required) % \item Key Points summarize the main points and conclusions of the article % \item Each must be 140 characters or fewer with no special characters or punctuation and must be complete sentences % \end{keypoints} \begin{keypoints} \item We use seismic data from small-aperture arrays in the Olympic Peninsula, and tremor epicenters determined by a previous study. \item We compute the depth of the tremor from S minus P times determined from stacking horizontal-to-vertical cross-correlations of seismic data. \item Tremor is located close to the plate boundary in a region no more than 2-3 kilometers thick. \end{keypoints} %% ------------------------------------------------------------------------ %% % % ABSTRACT and PLAIN LANGUAGE SUMMARY % % A good Abstract will begin with a short description of the problem % being addressed, briefly describe the new data or analyses, then % briefly states the main conclusion(s) and how they are supported and % uncertainties. % The Plain Language Summary should be written for a broad audience, % including journalists and the science-interested public, that will not have % a background in your field. % % A Plain Language Summary is required in GRL, JGR: Planets, JGR: Biogeosciences, % JGR: Oceans, G-Cubed, Reviews of Geophysics, and JAMES. % see http://sharingscience.agu.org/creating-plain-language-summary/) % %% ------------------------------------------------------------------------ %% %% \begin{abstract} starts the second page \begin{abstract} Tectonic tremor has been explained as a swarm of low-frequency earthquakes, which are located on a narrow fault at the plate boundary. However, due to the lack of clear impulsive phases in the tremor signal, it is difficult to determine the depth of the tremor source with great precision. The thickness of the tremor region is also not well constrained. The tremor may be located on a narrow fault as the low-frequency earthquakes appear to be, or distributed over a few kilometers wide low shear-wave velocity layer in the upper oceanic crust, which is thought to be a region with high pore-fluid pressure. Lag times of peaks in the cross-correlation of the horizontal and vertical components of tremor seismograms, recorded by small-aperture arrays in the Olympic Peninsula, Washington, are interpreted to be S minus P times. Tremor depths are estimated from these S minus P times using epicenters from a previous study using a multibeam backprojection method. The tremor is located close to the plate boundary in a region no more than 2-3 kilometers thick and is very close to the depths of low-frequency earthquakes. The tremor is distributed over a wider depth range than the low-frequency earthquakes. However, due to the uncertainty on the depth, it is difficult to conclude whether the source of the tremor is located at the top of the subducting oceanic crust, in the lower continental crust just above the plate boundary, or in a narrow zone at the plate boundary. \end{abstract} \section*{Plain Language Summary} Tectonic tremor is a long, low amplitude seismic signal, with emergent onsets, and an absence of clear impulsive phases. It has been explained as a swarm of low-frequency earthquakes, which are located on a narrow fault at the plate boundary. It is therefore assumed that the source of the tectonic tremor is located close to the plate boundary. However, due to the lack of clear impulsive phases in the tremor signal, it is difficult to determine the depth of the tremor source and the distance of the source to the plate interface with great precision. The thickness of the tremor region is not well constrained either. The tremor may be located on a narrow fault like the low-frequency earthquakes, or distributed through a few kilometers wide low shear-wave velocity layer in the upper oceanic crust, which is thought to be a region with high pore-fluid pressure. In this paper, we show that the tremor is located close to the plate boundary in a region no more than 2-3 kilometers thick and is very close to the depths of low-frequency earthquakes. Knowing the depth of the tremor source will help understand the mechanism that produces the tremor. %% ------------------------------------------------------------------------ %% % % TEXT % %% ------------------------------------------------------------------------ %% %%% Suggested section heads: % \section{Introduction} % % The main text should start with an introduction. Except for short % manuscripts (such as comments and replies), the text should be divided % into sections, each with its own heading. % Headings should be sentence fragments and do not begin with a % lowercase letter or number. Examples of good headings are: % \section{Materials and Methods} % Here is text on Materials and Methods. % % \subsection{A descriptive heading about methods} % More about Methods. % % \section{Data} (Or section title might be a descriptive heading about data) % % \section{Results} (Or section title might be a descriptive heading about the % results) % % \section{Conclusions} \section{Introduction} Tremor is a long (several seconds to many minutes), low amplitude seismic signal, with emergent onsets, and an absence of clear impulsive phases. Tectonic tremor has been explained as a swarm of small, low-frequency earthquakes (LFEs) ~\cite{SHE_2007_nature}, that is small magnitude earthquakes (M $\sim$ 1) where frequency content (1-10 Hz) is lower than for ordinary small earthquakes (up to 20 Hz). The source of the LFEs is located on or near the plate boundary, and their focal mechanisms represent shear slip on a low-angle thrust fault dipping in the same direction as the plate interface ~\cite{IDE_2007_GRL, ROY_2014}. The polarization of tremor in northern Cascadia is also consistent with slip on the pate boundary in the direction of relative plate motion ~\cite{WEC_2007}. Due to the lack of clear impulsive phases in the tremor signal, it is difficult to determine the depth of the tremor source with the same precision. In subduction zones such as Nankai and Cascadia, tectonic tremor observations are spatially and temporally correlated with geodetically observed slow slip ~\cite{OBA_2002, ROG_2003}. Due to this correlation, these paired phenomena have been called Episodic Tremor and Slip (ETS). \\ The occurrence of tremor seems to be linked to low effective normal stress or high fluid pressure near the location of the tremor. Indeed, ~\citeA{SHE_2006} have observed a high P-wave to S-wave velocity ratio in the subducting oceanic crust near the location of the LFEs in western Shikoku, Japan. In Cascadia, ~\citeA{AUD_2009} have computed teleseismic receiver functions in Vancouver Island, and analyzed the delay times between the forward-scattered P-to-S, and back-scattered P-to-S and S-to-S conversions at two seismic reflectors identified as the top and bottom of the oceanic crust. It allowed them to compute the P-to-S velocity ratio of the oceanic crust layer and the S-wave velocity contrast at both interfaces. The very low Poisson's ratio of the layer could not be explained by the mineral composition, and they interpreted it as evidence for high pore-fluid pressure. The link between tremor and high pore fluid pressure is also supported by the influence of tidal cycles on the variations of tremor occurrence. \citeA{NAK_2008} noticed that tremor swarms often exhibit occurrences with a periodicity of about 12 or 24 h, and concluded that they are probably related to Earth tides. Their occurrence is also well correlated with time evolution of Coulomb failure stress (CFS) and CFS rate. However, tremor occurrences are advanced by a few hours relative to CFS, from which they conclude that a simple Coulomb threshold model is not sufficient to explain tremor occurrence. This discrepancy can be explained by using a rate- and state-dependent friction law. ~\citeA{THO_2009} have also observed that tremor occurrence on the deep San Andreas fault are correlated with small, tidal shear stress changes. They explain it by a very weak fault zone with low effective normal stress, probably due to near-lithostatic pore pressures at the depth of the tremor source region. \\ Two scenarii could explain the generation of tectonic tremor by highly pressured fluids ~\cite{SHE_2006}. A first possibility is that tremor is generated by the movement of fluids at depth, either by hydraulic fracturing or by coupling between the rock and fluid flow. The accompanying slip could be triggered by the same fluid movement that generates the tremor or, alternatively, the fluid flow could be a response to changes in stress and strain induced by the accompanying slip. The second possibility is that tremor is generated by slow otherwise aseismic shear slip on the plate interface as slip locally accelerates owing to the effects of geometric or physical irregularities on the plate interface. Fluids would then play an auxiliary role, altering the conditions on the plate interface to enable transient slip events, without generating seismic waves directly. \\ The source of the fluids could be the dehydration of hydrous minerals within the subducting oceanic crust ~\cite{SHE_2006}. ~\citeA{FAG_2011} computed the equilibrium mineral assemblages at different P-T conditions, and compared it to the P-T path of the subducting oceanic crust in Shikoku and Cascadia. They noted that for most of the P-T path, there are no dehydration reactions and the slab remains fluid-absent, except for depths between 30 and 35 km for Shikoku, and depths between 30 and 40 km for Cascadia, where the mineral model predicts significant water release. These depth ranges coincide with the depth range where tremor has been observed. They concluded that abundant tremor activity requires metamorphic conditions where localized dehydration occurs during subduction, which explains why the generation of tectonic tremor is restricted to a small range of depth along the plate boundary. In subduction zones where dehydration reactions are more widely distributed, there would be a more diffuse pattern of tremor activity that would be harder to detect. \\ Large amounts of fluids could be available at the fore-arc mantle corner. First, the bending of the subducting plate at the ocean trench may introduce water in the upper oceanic mantle, resulting in extensive serpentinization ~\cite{HYN_2015}. Second, the serpentinization of the fore-arc mantle corner may decrease the vertical permeability of the boundary between the oceanic plate and the overriding continental crust while keeping a high permeability parallel to the fault. It would thus channel all the fluid updip in the subducting oceanic crust, and explain the sharp velocity contrast observed by ~\citeA{AUD_2009} on top of the oceanic crust layer. At greater depth, the large volume reduction and water release accompanying eclogitization in the subducted oceanic crust, and the large volume expansion accompanying serpentinization in the mantle wedge, could increase the permeability of the plate boundary through fracture generation. A possible cause of ETS events could thus be periodic cycles of steady pore-fluid pressure build-up from dehydration of subducted oceanic crust, fluid release from fracturing of the interface during ETS, and subsequent precipitation sealing of the plate boundary ~\cite{AUD_2009}. \\ Whereas the position of the subduction zone ETS does not seem to coincide with a specific temperature or dehydration reaction ~\cite{PEA_2009}, there seems to be a good coincidence between the location of the fore-arc mantle corner, and the location of ETS ~\cite{HYN_2015}. The generation of slow slip and tectonic tremor could then be related to the presence of quartz in the overriding continental crust. Using receiver functions of teleseismic body waves, and data from the literature, ~\citeA{AUD_2014} observed that the recurrence time of slow earthquakes increases linearly with the Vp / Vs ratio of the forearc crust. They also noticed that along a margin-perpendicular profile from northern Cascadia, the Vp / Vs ratio of the forearc, and the recurrence time of ETS events, decrease with increasing depth. Likewise, ~\citeA{HYN_2015} pointed out that the deep fore-arc crust has a very low Poisson's ratio (less than 0.22), and that the only mineral with a very low Poisson's ratio is quartz (about 0.1), which led them to conclude that there may be a significant amount of quartz (about 10\% by volume) in the deep fore-arc crust above the fore-arc mantle. ~\citeA{AUD_2014} explained the presence of quartz in the forearc by the enrichment of forearc minerals in fluid-dissolved silica derived from the dehydration of the down-going slab. As the solubility of silica increases with temperature, fluids generated at depth and rising up the subduction channel should be rich in silica ~\cite{HYN_2015}. \\ Quartz veins have indeed been observed in exhumed subduction zones. For instance, ~\citeA{FAG_2014} have studied an exhumed shear zone representing the subduction megathrust before its incorporation into the accretionary prism. They focused their study on a 30 m high by 80 m long cliff exposure where foliation has developed as a result of shearing along the subduction thrust interface. They identified two groups of quartz veins, foliation-parallel veins, and discordant veins, that must have formed for an extended time before, during, and after foliation development. They interpret the foliation-parallel veins as having been formed by viscous shear flow, and note that the shear stain rate due to the flow may be high enough to accommodate a slow slip strain rate of $~10^{-9} s^{-1}$, for a typical subduction thrust thickness of 30 m ~\cite{ROW_2013}. They interpret the discordant veins as having been formed by brittle deformation caused by locally elevated fluid pressure. The size of the structures where brittle deformation is observed (meters to hundreds of meters) is compatible with the size of the asperity rupturing during an LFE. Tremor and slow slip may thus be a manifestation of brittle-viscous deformation in the shear zone. \\ However, several constraints remain to be explained. ~\citeA{AUD_2014} estimated that the fluid flux required for the formation of quartz veins was two orders of magnitude greater than the fluid production rates estimated from the dehydration of the slab. They hypothesized that silica-saturated fluids may originate from the complete serpentinization of the mantle near the wedge corner. They suggested that higher temperature and quartz content at depth may lead to faster dissolution - precipitation processes and more frequent slip events. Their model could also explain the global variation in recurrence time, with mafic silica-poor regions having longer ETS recurrence times than felsic silica-rich regions. \\ Moreover, the zone with high low Poisson's ratio observed by ~\citeA{HYN_2015} has a large vertical extent (about 10 kilometers). If the whole zone is associated with quartz deposition and tectonic tremor generation, we should also observe a large vertical distribution of the source of the tremor. ~\citeA{KAO_2006} have used a Source Scanning Algorithm to detect and locate tremor, and have indeed located tremor in the continental crust, with a wide depth range of over 40 km. They noted that this wide depth range could not arise from either analysis uncertainties or a systematic bias in the velocity model they used. Uncertainties on the location of the tremor have been estimated by ~\citeA{IDE_2012} at about 1.5 km in epicenter and 4.5 km in depth. A follow-up study by ~\citeA{KAO_2009} gave a thickness of the tremor zone of 5-10 km. This depth range is inconsistent with the depth of the LFEs, which have been located on a thin band at or near the plate interface with a rupture mechanism that corresponds to the thrust dip angle ~\cite{IDE_2007_GRL}. In the Olympic Peninsula, LFE families have been identified and located by ~\citeA{CHE_2017_JGR,CHE_2017_G3}, and all LFE families were located near the plate interface. Further study is thus needed to narrow the uncertainty on the depth of the source of the tremor, and verify whether tremor occurs in a wider zone than LFEs. \\ Several methods have been developed to detect and locate tectonic tremor or LFEs using the cross-correlation of seismic signals. The main idea is to find similar waveforms in two different seismic signals, which could correspond to a single tremor or LFE recorded at two different stations, or two different tremors or LFEs with the same source location but occurring at two different times and recorded by the same station. A first method consists in comparing the envelopes of seismograms at different stations ~\cite{OBA_2002, WEC_2008}, or directly the seismograms at different stations ~\cite{RUB_2013}. For instance, ~\citeA{WEC_2008} computed the cross-correlations of envelope seismograms for a set of 20 stations in western Washington and southern Vancouver Island. Then, they performed a grid search over all possible source locations to determine which one minimizes the difference between the maximum cross-correlation and the value of the correlogram at the lag time corresponding to the S-wave travel time difference between two stations. \\ A second method is based on the assumption that repeating tremor or LFEs with sources located nearby in space will have similar waveforms ~\cite{BOS_2012, ROY_2014, SHE_2006, SHE_2007_nature}. For instance, ~\citeA{BOS_2012} looked for LFEs by computing autocorrelations of 6-second long windows for each component of 7 stations in Vancouver Island. They then classified their LFE detections into 140 families. By stacking all waveforms of a given family, they obtained an LFE template for each family. They extended their templates by adding more stations and computing cross-correlations between station data and template waveforms. They used P- and S-travel-time picks to obtain a hypocenter for each LFE template. By observing the polarizations of the P- and S-waveforms of the LFE templates, they computed focal mechanisms and obtained a mixture of strike slip and thrust mechanisms, corresponding to a compressive stress field consistent with thrust faulting parallel to the plate interface. Further study showed that the average double couple solution is generally consistent with shallow thrusting in the direction of plate motion \cite{ROY_2014}. \\ Finally, a third method uses seismograms recorded across small-aperture arrays ~\cite{GHO_2010_GRL, LAR_2009}. For instance, ~\citeA{LAR_2009} stacked seismograms over all stations of the array for each component, and for three arrays in Cascadia. They then computed the cross-correlation between the horizontal and the vertical component, and found a distinct and persistent peak at a positive lag time, corresponding to the time between P-wave arrival on the vertical channel and S-wave arrival on the horizontal channels. Using a standard layered Earth model, and horizontal slowness estimated from array analysis, they computed the depths of the tremor sources. They located the sources near or at the plate interface, with a much better depth resolution than previous methods based on seismic signal envelopes, source scanning algorithm, or small-aperture arrays. They concluded that at least some of the tremor consisted in the repetition of LFEs as was the case in Shikoku. A drawback of the method was that it could be applied only to tremor located beneath an array, and coming from only one place for an extended period of time. \\ In this study, we extend on the method used by ~\citeA{LAR_2009} using the cross-correlation between horizontal and vertical components of seismic recordings to estimate the depth of the source of the tectonic tremor, and the depth extent of the region from which tremor originates. If indeed tremor is made of swarms of LFEs, and both represent the regions of deformation during ETS events, we would expect the thickness of the tremor to be the same as the thickness of the LFEs. If not, tremor may be occurring where LFEs are harder to detect because they are either smaller in amplitude, or spread out over continuous space and not as clearly repeating. \section{Data} The data were collected during the 2009-2011 Array of Arrays experiment. Eight small-aperture arrays were installed in the northeastern part of the Olympic Peninsula, Washington. The aperture of the arrays was about 1 km, and station spacing was a few hundred meters. Arrays typically had ten 3-component seismometers, augmented by an additional 10 vertical-only sensors during the 2010 ETS event. The arrays were around 5 to 10 km apart from each other (Figure 1). Most of the arrays recorded data for most of a year, between June 2009 to September 2010, and captured the main August 2010 ETS event. The arrays also recorded the August 2011 ETS event with a slightly reduced number of stations. ~\citeA{GHO_2012} used a multibeam backprojection (MBBP) technique to detect and locate tremor. They bandpass filtered the vertical component between 5 and 9 Hz and divided the data into one-minute-long time windows. They performed beam forming of vertical component data in the frequency domain at each array to determine the slowness vectors, and backprojected the slownesses through a 3-D wavespeed model ~\cite{PRE_2003} to locate the source of the tremor for each time window. This produced 28902 tremor epicenters for one-minute-long time windows during June, 2009 - September, 2010 and 5600 epicenters during August - September, 2011. \begin{figure} \noindent\includegraphics[width=\textwidth, trim={0cm 2.5cm 0cm 9.5cm},clip]{figures/arrays_location.eps} \caption{Map showing the location of the eight arrays (black triangles) used in this study and tremor locations (grey dots) located using these arrays ~\cite{GHO_2012}. Inset shows the study area with the box marking the area covered in the main map. Contours represent a model of the depth of the plate interface ~\cite{MCC_2006}.} \label{pngfiguresample} \end{figure} \section{Method} For each array, and every 5 km by 5 km grid cell located within 25 km, we analyze the one-minute-long time windows corresponding to all the tremor epicenters located within the grid cell. For each three-component seismic station and each channel, we detrended the data, tapered the first and last 5 seconds with a Hann window, removed the instrument response, bandpass filtered between 2 and 8 Hz, and resampled the data to 20 Hz. All these preprocessing operations were done with the Python package obspy. For each seismic station and each one-minute-long time window, we cross correlated the vertical component with the East-West component and with the North-South component. Then, we stacked the cross correlation functions over all the seismic stations of the array. We call this stack $S_{i j} (\tau)$ for time lag $\tau$, the $i$-th channel ($i$=1 or 2 for the North or East channel) and the $j$-th one-minute-long time window for a given epicenter grid/array pair. At each step of this method we experimented with a linear stack, a $n$th-root stack, and a phase-weighted stack ~\cite{SCH_1997} and found that the phase-weighted stack worked best. So, all the stacks discussed here used the phase-weighted method. Figure 2 shows an example of the envelopes of $S_{i j} (\tau)$ for the Big Skidder array for the 110 one-minute-long time windows when tremor was detected in the 5 km by 5 km grid cell located 7 kilometers southwest of the array. For all time windows, there is a peak in the envelopes of the cross-correlation $S_{i j} (\tau)$ at $\tau = 0 s$ (not shown in the figure). Additionally, for about 40\% of the time windows, we also see another peak in the envelopes of the cross-correlation $S_{i j} (\tau)$ at about $\tau = 4.5 s$. As the energy of the P-waves is expected to be higher on the vertical component, and the energy of the S-waves to be higher on the horizontal components, we interpret this peak to correspond to the time lag between the arrival of the direct P- and S-waves. This peak is only seen for the positive time lag, and no peak is seen in the negative part of the cross-correlation. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={0cm 0cm 0cm 0cm},clip]{figures/BS_-05_-05_PWS_PWS_cluster_ccwin.eps} \caption{Envelopes of the stacked cross-correlation functions for the Big Skidder array for the 110 one-minute long time windows when tremor was detected in a 5 km by 5 km grid cell located 7 kilometers southwest of the array. Top shows time windows (black) that fit the stack well. Bottom shows time windows (blue) that do not fit the stack well. Left panel is the cross-correlation of the EW component with the vertical component, and right panel is the cross-correlation of the NS component with the vertical component. The cross-correlation functions have been cut between 2 and 8 seconds to focus on the time lags around the peaks.} \label{pngfiguresample} \end{figure} Only about half of the envelopes of the cross-correlation functions have a distinct peak that coincides with the peak in the stacked cross-correlation. The other cross-correlation functions show either a distinct peak at another time lag, or no clearly visible peak. This may be either because the tremor epicenter was mislocated, or because the signal-to-noise ratio is too low. \\ To determine which time window to use for further consideration we compute the theoretical value of the time lag between the P- and S-wave arrivals if the source was located on the plate boundary. We then look for the lag time corresponding to the peak of the absolute value of the stack within 1 second of the theoretical lag time. We do this nine times for each combination of 3 stacking methods acting on the stack of stations for each array and on the stacks across each of the one-minute time windows. The stacking methods are a linear stack, a $n$th-root stack or a phase-weighted stack. We define $T_{min}$ to be the minimum of these 9 lag times minus 1 s and $T_{max}$ to be the maximum of these 9 times plus 1 s. We limit the rest of our analysis to the time window $\left[ T_{min} ; T_{max} \right]$. We define $\tau_{max}$ to be the time corresponding to the peak absolute value of the phase-weighted stack within these time limits. $\tau_{max}$ turns out to also be the time corresponding to the maximum of the stacked correlations within a fixed wide window from 3-8 s for all the array / grid pairs except for one (BH, grid that is 7 km to the southeast). This suggests that there is very little, if any, bias in our method forcing our final observed S minus P times towards their theoretical values. \\ To improve the signal-to-noise ratio of the peak in the stacked cross-correlation, we divided the one-minute-long time windows into two clusters, the ones that match the stacked cross-correlations well, and the ones that do not. In order to do the clustering, we stacked the stacked cross-correlation functions, $S_{i j} (\tau)$, over all the one-minute-long time windows to obtain $S_i (\tau)$. For each one-minute time window $j$ we cross-correlated $S_i (\tau)$ with $S_{i j} (\tau)$ to obtain $S^c_{i j} (\tau)$. We want to verify whether the waveform $S_{i j} (\tau)$ around the peak $\tau_{max}$ matches well with the stack $S_i (\tau)$. For the cross-correlation between $S_{i j} (\tau)$ and $S_i (\tau)$, we keep only the values of lag times $\tau$ between $T_{min}$ and $T_{max}$. For each $i$ and $j$ we determine 3 numbers from $S^c_{i j} (\tau)$: its value at zero lag time, its maximum absolute value and the time lag at which it takes its maximum absolute value, and we determine one number from $S_{i j} (\tau)$: the ratio of its maximum absolute value $S_{i j} (\tau) _{max}$ to its rms. We considered lag times $\tau$ from 12 to 14 seconds to compute the value of the rms of the $S_{i j} (\tau)$. Each one-minute-long time window is thus associated with eight values of quality criteria, four for each of the the East and North channels. We then classified each one-minute-long time window into two different clusters, based on the value of these criteria, using a K-means clustering algorithm (function sklearn.cluster.KMeans from the Python library SciKitLearn). The K-means procedure is as follows: We choose to have 2 clusters, then we arbitrarily choose a center for each cluster. We put each one-minute-long time window into the cluster to which it is closest (based on the values of the eight criteria). Once all one-minute-long time windows have been put in a cluster, we recompute the mean of the eight criteria for each cluster, and iterate the procedure until convergence. On average, about 35\% of the time windows fit well with the stack and are kept in the first cluster, while 65\% do not fit well with the stack and are removed. For each cluster, we then stacked the envelopes of the cross-correlation functions over all the one-minute-long time windows belonging to that cluster using a phase-weighted stack. We tried using more than 2 clusters, but it did not improve the final stack of the best cluster. Figure 3 shows the stack of the envelopes of the $S_{i j} (\tau)$ over the time windows $j$ that correspond to cluster 0 (red) and cluster 1 (blue). The clustering has greatly improved the amplitude of the peak for cluster 1, and made the peak nearly disappear for cluster 0. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={0cm 0cm 0cm 0cm},clip]{figures/BS_-05_-05_PWS_PWS_cluster_stackcc.eps} \caption{Stack of the cross-correlation functions over all the 110 time windows from Figure 2. The black line is the stack $S_i (\tau)$ over all time windows of the stack of cross-correlation functions over all stations within the array. The red line on the left panels is the stack over all the time windows in cluster 0 of the envelopes of the stack of cross-correlation functions over stations within the array. This corresponds to time windows that do not fit well with the stack. The blue lines on the right panels are the same as the red lines, except it uses time windows in cluster 1 (which contains the time windows that fit well with the stack). Top panels are the cross-correlation of the EW component with the vertical component, and bottom panels are the cross-correlation of the NS component with the vertical component. The stacked cross-correlation function has been cut between 2 and 8 seconds to focus on the time lags around the peak.} \label{pngfiguresample} \end{figure} We did this analysis for grid cells located in a 50 km by 50 km area centered on each of the eight arrays. We thus consider up to 11 * 11 * 8 = 968 values of the time lag between the direct P-wave and S-wave. We assumed that the epicenter is at the center of the grid and determined the depth that satisfies that epicenter and the observed S-minus-P time. The velocity models are taken from the 3D velocity model from ~\citeA{MER_2020}. For each array, we looked for the closest grid point (in terms of latitude and longitude) in the 3D model by ~\citeA{MER_2020} and used the corresponding layered model of compressional and shear wave speeds to compute the tremor depth. We thus used 8 different 1D velocity models corresponding to the 8 arrays. This allows us to take into account the substantial variations of the Poisson's ratio in the East-West direction. \\ \section{Results} To obtain robust results, we limit our analysis to grid cells where there are at least 30 one-minute-long time windows in the best cluster. We assumed that the location of the tremor source is fixed during the one-minute-long time window where we compute the cross-correlation of the seismic signal. However, during an ETS event, rapid tremor streaks have been observed to propagate up-dip or down-dip at velocities ranging on average between 30 and 110 km/h ~\cite{GHO_2010_G3}, which corresponds to a maximum source displacement of 0.9 km updip or downdip during the 30 seconds duration before and after the middle of the time window. The change in predicted S-minus-P time caused by changing source location by 0.9 km in the up- or down-dip direction is small for tremor along strike from the array or in the down dip direction. However, the change in this lag time for tremor sources up-dip from the arrays exceeds one quarter of the dominant period of the tremor signal (period= 0.33 s) for tremor sources more than 18 km updip from an array. Thus, tremors beyond 18 km updip of an array may not add coherently during rapid tremor migrations. This method works best if the P-wave is cleanly recorded on the vertical component and the S-wave on the horizontals, so generally speaking the results are more robust for near vertical ray paths. \\ Finally, the data from some of the arrays are very noisy, which makes it hard to see a signal emerging when stacking over the one-minute-long time windows. We chose to keep only the locations for which the ratio between the maximum value of the stack of the envelopes of the cross-correlation functions to the root mean square is higher than 5. We compute the root mean square in cluster 1 for a time lag between 12 and 14 s because we do not expect any reflected wave to arrive that late after a direct wave. The corresponding stack of the envelopes of the cross-correlation functions are shown in Figure 4 for the East-West component and the North-South component. The grey dashed vertical line shows the theoretical time lag between the arrival of the direct P-wave and the arrival of the direct S-wave using the corresponding 1D velocity model for this array and the plate boundary model from ~\citeA{PRE_2003}, the grey solid line corresponds to the moment centroid of the stack. There is a good agreement between the timing of the centroid and the theoretical time lag for most of the locations of the source of the tremor. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={2.5cm 0.5cm 5cm 1cm},clip]{figures/BS_PWS_PWS_0.eps} \caption{Stack of the envelopes of the cross-correlation signals for different positions of the tremor source relative to the Big Skidder array showing the cross-correlation between the East-West and the vertical components (red lines) and between the North-South and vertical components (blue lines). The theoretical S-minus-P times (grey dashed line for the Preston model) are generally in good agreement with the centroids in cross-correlation functions (grey solid line). The location of the tremor varies from west to east (left to right) and from south to north (bottom to top). The numbers next to each graph indicate the number of one-minute-long time windows in the best cluster. For clarity, we plotted only the part of the cross-correlation signal corresponding to time lags between 2 and 8 seconds.} \label{pngfiguresample} \end{figure} To compute the depth, we select the EW or the NS component with the larger maximum value of the peak. We focus on the part of the stack of the envelopes of the cross-correlation functions located between 2 seconds before and 2 seconds after the time lag $\tau_{max}$ corresponding to the peak obtained earlier. We computed the moment centroid of this part of the stack and assumed that it was equal to the time lag between the arrivals of the direct P-wave and the direct S-wave. We then computed the corresponding depth of the source of the tremor for all the locations of the source of the tremor. To verify the effect of the width of the time window for which we compute the moment centroid, we compute the centroid and the corresponding depth of the source for widths equal to 2 seconds, 4 seconds, and 6 seconds. We compute the variations in depths when decreasing the width from 4 seconds to 2 seconds. 87\% of the differences in depth are under 2 kilometers. The median difference is 0.064 km, so there is no bias towards shallower or deeper depths when we decrease the width of the time window. When we compute the variations in depths when increasing the width from 4 seconds to 6 seconds, 84\% of the differences in depth are under 2 kilometers and the median difference is 0.054 km. The corresponding stacks of the envelopes are shown in Figure 4 and Figures S1 to S7 in the supplementary material. For the two arrays Cat Lake and Lost Cause, there are very few source-array locations that have both enough tremor and a high ratio between the peak and the root mean square. Moreover, for the locations where we have a peak, the peak is often not very clear and stretched along the time axis. We did not use data from these two arrays. For the Port Angeles array, there is only a clear peak for a near vertical incidence of the seismic waves. We choose to keep this array in the analysis in order to have two additional data points in the westernmost region of the study area. \\ To estimate the uncertainty on the depth of the source of the tremor, we computed the width of the stack of the envelopes of the cross-correlation functions at half the maximum of the peak. We then computed the associated depth difference using the 1D velocity model. As we computed the envelopes of the cross-correlation functions before stacking, the peak is large and also the associated uncertainty on the depth. Nevertheless, about 75\% of the data points have an uncertainty under 8km (Figure 5). The uncertainties are higher for the Burnt Hill array, and are almost always lower than 8km for the five other arrays. We tried different stacking methods, both for the stacking of the correlation functions over all the seismic stations of a given array, and for the stacking of the envelopes of those stacks over the one-minute-long time windows when tremor is detected. We experimented with a linear stack, a $n$th-root stack, and a phase-weighted stack, and found that using a phase-weighted stack for both the stacking over the stations and the stacking over one-minute-long time windows gave the lower uncertainty on the tremor depth. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={1cm 5cm 3.5cm 4cm},clip]{figures/uncertainty_PWS_PWS.eps} \caption{Map of the uncertainty on the depth of the tremor based on the width of the stack of the envelopes of the cross-correlation functions for arrays Burnt Hill (squares), Big Skidder (stars), Danz Ranch (inverted triangles), Gold Creek (large circles), Port Angeles (diamonds), and Three Bumps (hexagons).} \label{pngfiguresample} \end{figure} In the following, we kept only the data points for which the maximum amplitude of the stack is higher than 0.05. Figures 6 and 7 show respectively a map and three cross-sections of the depth of the source of the tremor. Figure 8 shows a map of the distance between the source of the tremor and the plate boundary from the Preston model, alongside with the depth of the low-frequency earthquake families observed by ~\citeA{SWE_2019} and ~\citeA{CHE_2017_JGR,CHE_2017_G3}. There is a good agreement between the depth of the source of the tremor, the depth of the low-frequency earthquake families, and the depth of the plate boundary. On the cross-section figures, we compare the distance of the source of the tremor to the plate boundary for different locations of the cross-section. We note that the depth of the tremor matches well the depth of the low-frequency earthquakes. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={1cm 5cm 3.5cm 4cm},clip]{figures/depth_PWS_PWS.eps} \caption{Map of the depth of the source of the tremor and of the low-frequency earthquake families (small filled circles) identified by ~\citeA{SWE_2019} and ~\citeA{CHE_2017_JGR,CHE_2017_G3}. The three black lines indicate the positions of the cross-sections shown in Figure 7. Tremor depths are from arrays Burnt Hill (squares), Big Skidder (stars), Danz Ranch (inverted triangles), Gold Creek (large circles), Port Angeles (diamonds), and Three Bumps (hexagons)} \label{pngfiguresample} \end{figure} \begin{figure} \noindent\includegraphics[width=5cm, trim={4.5cm 0.5cm 6cm 0cm},clip, angle=270]{figures/section_strike_PWS_PWS.eps} \caption{Cross-sections showing depth of the tremor and of the low-frequency earthquake families (small filled circles) identified by ~\citeA{SWE_2019} and ~\citeA{CHE_2017_JGR,CHE_2017_G3} for cross sections A-A' , B-B', and C-C' shown in Figure 6. The black line corresponds to the plate boundary profile of ~\citeA{MCC_2006} along the southern most black line shown on Figure 6, and the dashed line to the plate boundary profile of ~\citeA{PRE_2003}. The color bar shows the distance of the tremor and the low-frequency earthquakes along the strike. Only tremor and low-frequency earthquakes less than 10 km away from the profile line are shown. Tremor depths are from arrays Burnt Hill (squares), Big Skidder (stars), Danz Ranch (inverted triangles), Gold Creek (large circles), Port Angeles (diamonds), and Three Bumps (hexagons).} \label{pngfiguresample} \end{figure} \begin{figure} \noindent\includegraphics[width=\textwidth, trim={1cm 5cm 3.5cm 4cm},clip]{figures/d_to_pb_PWS_PWS_P.eps} \caption{Map of the distance between the plate boundary (from the Preston model) of the tremor and of the low-frequency earthquake families (filled circles) identified by ~\citeA{SWE_2019} and ~\citeA{CHE_2017_JGR,CHE_2017_G3}). Tremor located below the plate boundary is blue, and above is red. Tremor depths are from arrays Burnt Hill (squares), Big Skidder (stars), Danz Ranch (inverted triangles), Gold Creek (large circles), Port Angeles (diamonds), and Three Bumps (hexagons).} \label{pngfiguresample} \end{figure} \section{Discussion} Previous studies have shown evidence for seismic anisotropy near the slab interface ~\cite{NIK_2009} and in the overriding continental crust ~\cite{CAS_1996}. If the source of the tremor is located in or under the anisotropic layer, the time lag between the arrival of the direct P-wave and the arrival of the direct S-wave could be different depending on whether we consider the East-West component or the North-South component. To verify whether possible anisotropy could affect our results, we computed the time difference between the timing of the maximum of the stack of the envelopes of the stacked cross-correlation functions between the East-West component and the vertical component, and between the North-South component and the vertical component. We also computed the associated difference in depth of the source of the tremor (see Figure 9) for all arrays and all locations of the tremor. The difference in time is generally less than 0.25 s while the difference in depth is generally less than 2 kilometers, which is similar to the uncertainty on the tremor depth. As the time difference between the East-West component and the North-South component due to anisotropy is expected to vary depending on the relative position of the array compared to the source of the tremor, we also plotted the time difference as a function of the distance from source to array, and as a function of the azimuth, as well as the corresponding depth difference (Figure 9). The time difference does not increase with the distance from the source to the array, and there is no seismic path orientation that gives bigger time difference. Thus, seismic anisotropy does not seem to have a significant effect on the time lags between the arrival of the direct P-wave and the arrival of the direct S-wave, and can be neglected. ~\citeA{NIK_2009} observed anisotropy in the low-velocity layer beneath station GNW, located in the eastern Olympic Peninsula, south of the eight seismic arrays used in this study. If the tremor is located above the low-velocity layer, we do not expect this source of seismic anisotropy to introduce a significant effect on our measured time lags. ~\citeA{NIK_2009} locate the low-velocity layer above the plate boundary, in the lower continental crust, which is shallower than the location given by ~\citeA{BOS_2013}, who locates the low-velocity layer in the upper oceanic crust. However, even if a low-velocity layer with 5 \% anisotropy is located in the lower continental crust as indicated by ~\citeA{NIK_2009}, the resulting difference in time lags should not be more than a few tenths of a second, and the resulting difference in depth should not be more than 2 kilometers. ~\citeA{CAS_1996} observed anisotropy in the continental crust, especially in the upper 20 kilometers to the north of our arrays. However, the anisotropy resulted in time delays of the seismic waves of no more than 0.32s for deep earthquakes (40-60 km depth) and not more than 0.20s for shallow earthquakes (15-30 km depth). The corresponding difference in tremor depth is similar to the uncertainty. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={0cm 0cm 0cm 0cm},clip]{figures/PWS_PWS_0.eps} \caption{Left: S-minus-P times measured from envelopes of cross-correlation functions on the East-West component minus those from the North-South component. Right: Corresponding difference in inferred tremor depths. These are plotted as histograms (top), versus epicentral distance between tremors and arrays (middle) and tremor to array azimuth. There is no systematic signal that might be caused by anisotropy.} \label{pngfiguresample} \end{figure} Several approximations have been made to compute the tremor depth. First, we stacked over all the tremor in 5km by 5km grid cell. The depth difference corresponding to epicentral tremor locations at the center versus the edge of a cell varies from about 1 to 2 km for cells near the array to cells 25 km from an array. Second, the Vp / Vs ratio is not very well known. A variation of about 1\% of the Vp / Vs ratio used to compute the depth would lead to a variation of about 1-1.5 km of the corresponding tremor depth (Figure 10). \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={0cm 0cm 0cm 0cm},clip]{figures/PWS_PWS.eps} \caption{Variations of the depth of the tremor and we decrease the Vp / Vs ratio of 1\% (left) and when we increase the Vp / Vs ratio of 1\% (right). A change in the Vp / Vs ratio corresponds to a change in the theoretical time lag between direct P-wave and direct S-wave if the source is located on the plate boundary. Thus, it changes the time interval over which we compute the centroid of the stacked envelopes, and thus the time lag we use to compute the depth.} \label{pngfiguresample} \end{figure} As proposed by ~\citeA{KAO_2009}, the source of the tremor could be distributed inside a layer that is 15 or more kilometers thick. We have assumed that all the tremor within a given grid cell originate from the same depth, and averaged over all the data to get the tremor depth. However, instead of being located on the same plane near the plate boundary, the tremor may be scattered over a layer surrounding the plate boundary. To compute the thickness of this layer, for each location of the array and the source of the tremor, we computed for each one-minute-long time window for which the cross-correlation function matches well the stacked cross-correlation the time lag between the time corresponding to the maximum absolute value for the cross-correlation function and the time corresponding to the maximum absolute value for the stacked cross-correlation. We thus obtained a distribution of time lags and the corresponding distribution of depths, and we tried to estimate the scale of the interval over which the depths vary. An example of time lags distribution is shown in Figure S8 of the supplementary material. Using the standard deviation could lead to overestimate the width of the interval, and the corresponding thickness of the tremor layer, as the standard deviation is very sensitive to outliers. Instead, we use the Qn estimator of ~\citeA{ROU_1993}, which is a more robust estimator of scale, similar to the median absolute deviation (MAD). Qn is equal to the $k$th order statistic of the $\begin{pmatrix} n \\ 2 \end{pmatrix}$ interpoint distances where $n$ is the number of points, and $k = \begin{pmatrix} h \\ 2 \end{pmatrix}$ with $h = \left[ \frac{n}{2} \right] + 1$ and $\left[ x \right]$ denote the integer part of $x$. As the MAD, the Qn estimator is not very sensitive to outliers, and it has the advantage of being suitable for asymmetric distributions, contrary to the MAD, which attaches equal importance to positive and negative deviations from the median. We then used the scale of the interval over which the tremor depth varies as an estimate of the thickness of the tremor layer (see Figure 11). The average thickness of the tremor zone is about 1.6 km, while nearly all the values of the thickness are less than 3km, which is substantially lower than the depth extent from ~\citeA{KAO_2009}. The smallest values for the thickness are about 0.8-2 kilometers. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={1cm 5cm 3.5cm 4cm},clip]{figures/Q_PWS_PWS.eps} \caption{Map of the thickness of the tremor layer estimated from scatter of individual 1-minute tremor windows. Tremor widths are from arrays Burnt Hill (squares), Big Skidder (stars), Danz Ranch (inverted triangles), Gold Creek (large circles), Port Angeles (diamonds), and Three Bumps (hexagons).} \label{pngfiguresample} \end{figure} Another way of estimating the thickness of the tremor zone is to fit a plane with a linear regression from all the values of the depth and compute the residuals from the regression (Figure 12). The Qn estimator of scale ~\cite{ROU_1993} for the error between the tremor depth and the fitted plane is only 1.3 km. \\ \begin{figure} \noindent\includegraphics[width=\textwidth, trim={1cm 5cm 3.5cm 4cm},clip]{figures/error_PWS_PWS.eps} \caption{Map of the residuals from the linear regression fitting all the depths to a plane. Residuals are from arrays Burnt Hill (squares), Big Skidder (stars), Danz Ranch (inverted triangles), Gold Creek (large circles), Port Angeles (diamonds), and Three Bumps (hexagons).} \label{pngfiguresample} \end{figure} In Table 1, we report the values of the median, the median absolute deviation (MAD), and the Qn estimator of scale for the difference between the depth of the tremor and the low-frequency earthquakes and the depth of the plate boundary, for the McCrory model and for the Preston model. Small negative values of the median correspond to tremor and low-frequency earthquakes located a little bit above the plate boundary. The depth range of the tremor (Qn = 1.3 km) is larger than the depth range of the low-frequency earthquake families from ~\citeA{CHE_2017_JGR,CHE_2017_G3} (Qn = 0.9 km). It is a also larger than the thickness of the flow channel where ~\citeA{SAM_2021} suggest that the LFEs are generated (0.5 to 1.5 km). However, this may be due to the uncertainty on the determination of the tremor depth. The tremor and low-frequency earthquakes are slightly closer to the plate boundary for the Preston model than for the McCrory model. This may be because the P-wave velocity model of ~\citeA{PRE_2003} was used as the initial velocity model by ~\citeA{MER_2020} to compute the full P- and S-wave velocity model that we use to get tremor depth from S minus P times. The Preston P-wave velocity model was also used by ~\citeA{CHE_2017_JGR,CHE_2017_G3} to locate the low-frequency earthquake families. \\ \begin{table} \caption{Summary of distances to plate boundary} \centering \begin{tabular}{l c c c} \hline & Median & MAD & Qn \\ \hline Tremor depth - Preston depth & - 0.207 km & 2.623 km & 1.313 km \\ Tremor depth - McCrory depth & - 0.850 km & 2.429 km & 1.390 km \\ LFE families depth - Preston depth & - 0.189 km & 1.312 km & 0.871 km \\ LFE families depth - McCrory depth & - 0.495 km & 1.805 km & 0.988 km \\ \hline \end{tabular} \end{table} \section{Conclusion} We developed a method to estimate the depth of the source of the tectonic tremor, and the depth extent of the region from which the tremor originates, using S minus P times determined from lag times of stacked cross-correlations of horizontal and vertical components of seismic recordings from small aperture arrays in the Olympic Peninsula, Washington. We found that the source of the tremor is located close to the plate boundary in a region no more than 2-3 kilometers thick. The source of the tremor is thus distributed over a slightly wider depth range than the low-frequency earthquakes. However, due to the depth uncertainty, it is difficult to conclude whether the tremor is located near the top of the subducting oceanic crust, in the lower continental crust just above the plate boundary, in a layer distributed above and below the plate boundary, or confined to a very narrow plate boundary. The location of the tremor relative to the low-velocity layer also observed near the plate boundary also remains uncertain. Tremor and LFE depths are consistent with filling a volume in the upper subducted crust that is characterized by high fluid pressure and very low S-wave velocities described as the preferred model by ~\citeA{BOS_2013}. \\ %% % Numbered lines in equations: % To add line numbers to lines in equations, % \begin{linenomath*} % \begin{equation} % \end{equation} % \end{linenomath*} %% Enter Figures and Tables near as possible to where they are first mentioned: % % DO NOT USE \psfrag or \subfigure commands. % % Figure captions go below the figure. % Table titles go above tables; other caption information % should be placed in last line of the table, using % \multicolumn2l{$^a$ This is a table note.} % %---------------- % EXAMPLE FIGURES % % \begin{figure} % \includegraphics{example.png} % \caption{caption} % \end{figure} % % Giving latex a width will help it to scale the figure properly. A simple trick is to use \textwidth. Try this if large figures run off the side of the page. % \begin{figure} % \noindent\includegraphics[width=\textwidth]{anothersample.png} %\caption{caption} %\label{pngfiguresample} %\end{figure} % % % If you get an error about an unknown bounding box, try specifying the width and height of the figure with the natwidth and natheight options. This is common when trying to add a PDF figure without pdflatex. % \begin{figure} % \noindent\includegraphics[natwidth=800px,natheight=600px]{samplefigure.pdf} %\caption{caption} %\label{pdffiguresample} %\end{figure} % % % PDFLatex does not seem to be able to process EPS figures. You may want to try the epstopdf package. % % % --------------- % EXAMPLE TABLE % % \begin{table} % \caption{Time of the Transition Between Phase 1 and Phase 2$^{a}$} % \centering % \begin{tabular}{l c} % \hline % Run & Time (min) \\ % \hline % $l1$ & 260 \\ % $l2$ & 300 \\ % $l3$ & 340 \\ % $h1$ & 270 \\ % $h2$ & 250 \\ % $h3$ & 380 \\ % $r1$ & 370 \\ % $r2$ & 390 \\ % \hline % \multicolumn{2}{l}{$^{a}$Footnote text here.} % \end{tabular} % \end{table} %% SIDEWAYS FIGURE and TABLE % AGU prefers the use of {sidewaystable} over {landscapetable} as it causes fewer problems. % % \begin{sidewaysfigure} % \includegraphics[width=20pc]{figsamp} % \caption{caption here} % \label{newfig} % \end{sidewaysfigure} % % \begin{sidewaystable} % \caption{Caption here} % \label{tab:signif_gap_clos} % \begin{tabular}{ccc} % one&two&three\\ % four&five&six % \end{tabular} % \end{sidewaystable} %% If using numbered lines, please surround equations with \begin{linenomath*}...\end{linenomath*} %\begin{linenomath*} %\begin{equation} %y|{f} \sim g(m, \sigma), %\end{equation} %\end{linenomath*} %%% End of body of article %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Optional Appendix goes here % % The \appendix command resets counters and redefines section heads % % After typing \appendix % %\section{Here Is Appendix Title} % will show % A: Here Is Appendix Title % %\appendix %\section{Here is a sample appendix} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Optional Glossary, Notation or Acronym section goes here: % %%%%%%%%%%%%%% % Glossary is only allowed in Reviews of Geophysics % \begin{glossary} % \term{Term} % Term Definition here % \term{Term} % Term Definition here % \term{Term} % Term Definition here % \end{glossary} % %%%%%%%%%%%%%% % Acronyms % \begin{acronyms} % \acro{Acronym} % Definition here % \acro{EMOS} % Ensemble model output statistics % \acro{ECMWF} % Centre for Medium-Range Weather Forecasts % \end{acronyms} % %%%%%%%%%%%%%% % Notation % \begin{notation} % \notation{$a+b$} Notation Definition here % \notation{$e=mc^2$} % Equation in German-born physicist Albert Einstein's theory of special % relativity that showed that the increased relativistic mass ($m$) of a % body comes from the energy of motion of the body—that is, its kinetic % energy ($E$)—divided by the speed of light squared ($c^2$). % \end{notation} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ACKNOWLEDGMENTS % % The acknowledgments must list: % % >>>> A statement that indicates to the reader where the data % supporting the conclusions can be obtained (for example, in the % references, tables, supporting information, and other databases). % % All funding sources related to this work from all authors % % Any real or perceived financial conflicts of interests for any % author % % Other affiliations for any author that may be perceived as % having a conflict of interest with respect to the results of this % paper. % % % It is also the appropriate place to thank colleagues and other contributors. % AGU does not normally allow dedications. \acknowledgments The authors would like to thank A. Ghosh for sharing his tremor catalog. We also would like to thank Charles Sammis and an anonymous reviewer whose reviews have helped improve the paper. This project was funded by NSF grant EAR-1358512. A.D. would like to thank the Integral Environmental Big Data Research Fund from the College of the Environment of University of Washington, which funded cloud computing resources to carry out the data analyses. The seismic recordings used for this analysis can be downloaded from the IRIS website using network code XG, 2009-2011. Most of the figures were done using GMT ~\cite{WES_1991}. The Python scripts used to analyze the data and make the figures can be found on the first author's Github account, accessible through Zenodo ~\cite{ariane_ducellier_2021_5725990}. %% ------------------------------------------------------------------------ %% %% References and Citations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \bibliography{<name of your .bib file>} don't specify the file extension % % don't specify bibliographystyle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bibliography{bibliography} %Reference citation instructions and examples: % % Please use ONLY \cite and \citeA for reference citations. % \cite for parenthetical references % ...as shown in recent studies (Simpson et al., 2019) % \citeA for in-text citations % ...Simpson et al. (2019) have shown... % % %...as shown by \citeA{jskilby}. %...as shown by \citeA{lewin76}, \citeA{carson86}, \citeA{bartoldy02}, and \citeA{rinaldi03}. %...has been shown \cite{jskilbye}. %...has been shown \cite{lewin76,carson86,bartoldy02,rinaldi03}. %... \cite <i.e.>[]{lewin76,carson86,bartoldy02,rinaldi03}. %...has been shown by \cite <e.g.,>[and others]{lewin76}. % % apacite uses < > for prenotes and [ ] for postnotes % DO NOT use other cite commands (e.g., \citet, \citep, \citeyear, \nocite, \citealp, etc.). % \end{document} More Information and Advice: %% ------------------------------------------------------------------------ %% % % SECTION HEADS % %% ------------------------------------------------------------------------ %% % Capitalize the first letter of each word (except for % prepositions, conjunctions, and articles that are % three or fewer letters). % AGU follows standard outline style; therefore, there cannot be a section 1 without % a section 2, or a section 2.3.1 without a section 2.3.2. % Please make sure your section numbers are balanced. % --------------- % Level 1 head % % Use the \section{} command to identify level 1 heads; % type the appropriate head wording between the curly % brackets, as shown below. % %An example: %\section{Level 1 Head: Introduction} % % --------------- % Level 2 head % % Use the \subsection{} command to identify level 2 heads. %An example: %\subsection{Level 2 Head} % % --------------- % Level 3 head % % Use the \subsubsection{} command to identify level 3 heads %An example: %\subsubsection{Level 3 Head} % %--------------- % Level 4 head % % Use the \subsubsubsection{} command to identify level 3 heads % An example: %\subsubsubsection{Level 4 Head} An example. % %% ------------------------------------------------------------------------ %% % % IN-TEXT LISTS % %% ------------------------------------------------------------------------ %% % % Do not use bulleted lists; enumerated lists are okay. % \begin{enumerate} % \item % \item % \item % \end{enumerate} % %% ------------------------------------------------------------------------ %% % % EQUATIONS % %% ------------------------------------------------------------------------ %% % Single-line equations are centered. % Equation arrays will appear left-aligned. Math coded inside display math mode \[ ...\] will not be numbered, e.g.,: \[ x^2=y^2 + z^2\] Math coded inside \begin{equation} and \end{equation} will be automatically numbered, e.g.,: \begin{equation} x^2=y^2 + z^2 \end{equation} % To create multiline equations, use the % \begin{eqnarray} and \end{eqnarray} environment % as demonstrated below. \begin{eqnarray} x_{1} & = & (x - x_{0}) \cos \Theta \nonumber \\ && + (y - y_{0}) \sin \Theta \nonumber \\ y_{1} & = & -(x - x_{0}) \sin \Theta \nonumber \\ && + (y - y_{0}) \cos \Theta. \end{eqnarray} %If you don't want an equation number, use the star form: %\begin{eqnarray*}...\end{eqnarray*} % Break each line at a sign of operation % (+, -, etc.) if possible, with the sign of operation % on the new line. % Indent second and subsequent lines to align with % the first character following the equal sign on the % first line. % Use an \hspace{} command to insert horizontal space % into your equation if necessary. Place an appropriate % unit of measure between the curly braces, e.g. % \hspace{1in}; you may have to experiment to achieve % the correct amount of space. %% ------------------------------------------------------------------------ %% % % EQUATION NUMBERING: COUNTER % %% ------------------------------------------------------------------------ %% % You may change equation numbering by resetting % the equation counter or by explicitly numbering % an equation. % To explicitly number an equation, type \eqnum{} % (with the desired number between the brackets) % after the \begin{equation} or \begin{eqnarray} % command. The \eqnum{} command will affect only % the equation it appears with; LaTeX will number % any equations appearing later in the manuscript % according to the equation counter. % % If you have a multiline equation that needs only % one equation number, use a \nonumber command in % front of the double backslashes (\\) as shown in % the multiline equation above. % If you are using line numbers, remember to surround % equations with \begin{linenomath*}...\end{linenomath*} % To add line numbers to lines in equations: % \begin{linenomath*} % \begin{equation} % \end{equation} % \end{linenomath*}
from typing import Dict, List import numpy as np import tensorflow as tf from typeguard import check_argument_types from neuralmonkey.decorators import tensor from neuralmonkey.logging import warn from neuralmonkey.model.model_part import GenericModelPart from neuralmonkey.runners.base_runner import BaseRunner from neuralmonkey.experiment import Experiment class TensorRunner(BaseRunner[GenericModelPart]): """Runner class for printing tensors from a model. Use this runner if you want to retrieve a specific tensor from the model using a given dataset. The runner generates an output data series which will contain the tensors in a dictionary of numpy arrays. """ # pylint: disable=too-few-public-methods # Pylint issue here: https://github.com/PyCQA/pylint/issues/2607 class Executable(BaseRunner.Executable["TensorRunner"]): def collect_results(self, results: List[Dict]) -> None: if len(results) > 1 and self.executor.select_session is None: sessions = [] for res_dict in results: sessions.append(self._fetch_values_from_session(res_dict)) # one call returns a list of dicts. we need to add another # list dimension in between, so it'll become a 2D list of # dicts with dimensions (batch, session, tensor_name) the # ``sessions`` structure is of 'shape' (session, batch, # tensor_name) so it should be sufficient to transpose it: batched = list(zip(*sessions)) else: batched = self._fetch_values_from_session(results[0]) self.set_result(outputs=batched, losses=[], scalar_summaries=None, histogram_summaries=None, image_summaries=None) def _fetch_values_from_session(self, sess_results: Dict) -> List: transposed = {} for name, val in sess_results.items(): batch_dim = self.executor.batch_ids[name] perm = [batch_dim] for dim in range(len(val.shape)): if dim != batch_dim: perm.append(dim) transposed_val = np.transpose(val, perm) transposed[name] = transposed_val # now we have dict of tensors in batch. we need # to have a batch of dicts with the batch dim removed batched = [dict(zip(transposed, col)) for col in zip(*transposed.values())] if self.executor.single_tensor: # extract the only item from each dict batched = [next(iter(d.values())) for d in batched] return batched # pylint: enable=too-few-public-methods # pylint: disable=too-many-arguments def __init__(self, output_series: str, modelparts: List[GenericModelPart], tensors: List[str], batch_dims: List[int], tensors_by_name: List[str], batch_dims_by_name: List[int], select_session: int = None, single_tensor: bool = False) -> None: """Construct a new ``TensorRunner`` object. Note that at this time, one must specify the toplevel objects so that it is ensured that the graph is built. The reason for this behavior is that the graph is constructed lazily and therefore if the tensors to store are provided by indirect reference (name), the system does not know early enough that it needs to create them. Args: output_series: The name of the generated output data series. modelparts: A list of ``GenericModelPart`` objects that hold the tensors that will be retrieved. tensors: A list of names of tensors that should be retrieved. batch_dims_by_ref: A list of integers that correspond to the batch dimension in each wanted tensor. tensors_by_name: A list of tensor names to fetch. If a tensor is not in the graph, a warning is generated and the tensor is ignored. batch_dims_by_name: A list of integers that correspond to the batch dimension in each wanted tensor specified by name. select_session: An optional integer specifying the session to use in case of ensembling. When not used, tensors from all sessions are stored. In case of a single session, this option has no effect. single_tensor: If `True`, it is assumed that only one tensor is to be fetched, and the execution result will consist of this tensor only. If `False`, the result will be a dict mapping tensor names to NumPy arrays. """ check_argument_types() if not modelparts: raise ValueError("At least one model part is expected") BaseRunner[GenericModelPart].__init__( self, output_series, modelparts[0]) if len(modelparts) != len(tensors): raise ValueError("TensorRunner: 'modelparts' and 'tensors' lists " "must have the same length") total_tensors = len(tensors_by_name) + len(tensors) if single_tensor and total_tensors > 1: raise ValueError("single_tensor is True, but {} tensors were given" .format(total_tensors)) self._names = tensors_by_name self._modelparts = modelparts self._tensors = tensors self._batch_dims_name = batch_dims_by_name self.batch_dims = batch_dims self.select_session = select_session self.single_tensor = single_tensor self.batch_ids = {} # type: Dict[str, int] # pylint: enable=too-many-arguments @tensor def fetches(self) -> Dict[str, tf.Tensor]: fetches = {} # type: Dict[str, tf.Tensor] for name, bid in zip(self._names, self._batch_dims_name): try: fetches[name] = ( Experiment.get_current().graph.get_tensor_by_name(name)) self.batch_ids[name] = bid except KeyError: warn(("The tensor of name '{}' is not present in the " "graph.").format(name)) for mpart, tname, bid in zip(self._modelparts, self._tensors, self.batch_dims): if not hasattr(mpart, tname): raise ValueError("Model part {} does not have a tensor called " "{}.".format(mpart, tname)) tensorval = getattr(mpart, tname) fetches[tensorval.name] = tensorval self.batch_ids[tensorval.name] = bid return fetches @property def loss_names(self) -> List[str]: return [] class RepresentationRunner(TensorRunner): """Runner printing out representation from an encoder. Use this runner to get input / other data representation out from one of Neural Monkey encoders. """ def __init__(self, output_series: str, encoder: GenericModelPart, attribute: str = "output", select_session: int = None) -> None: """Initialize the representation runner. Args: output_series: Name of the output series with vectors. encoder: The encoder to use. This can be any ``GenericModelPart`` object. attribute: The name of the encoder attribute that contains the data. used_session: Id of the TensorFlow session used in case of model ensembles. """ check_argument_types() if attribute not in dir(encoder): warn("The encoder '{}' seems not to have the specified " "attribute '{}'".format(encoder, attribute)) TensorRunner.__init__( self, output_series, modelparts=[encoder], tensors=[attribute], batch_dims=[0], tensors_by_name=[], batch_dims_by_name=[], select_session=select_session, single_tensor=True)
using DataFrames, StatsBase """ function comp_refs(dat...; nmask = 100, nthread=7) --- This is to compare several references for imputation on a same target. The last file in `dat` is the target. All the files before this are references. ## Data required - Genotypes in `final report` format of the 3 platforms. - Map files for 3 the 3 platforms ## Methods - Select shared loci - Random mask 100, by defaut, loci of the target platform - Impute with two references in turn. - Compare the call rates of the two imputation. - Make a report. """ function comp_refs(dat...; nmask = 100, window=300) length(dat) < 2 && (@error "Specify at least one ref, one target") tgt = dat[end] refs = dat[1:end-1] tbim = read_bim("$tgt.bim") lstsnp = begin shared = Set(tbim.snp) for r in refs tt = read_bim("$r.bim") shared = intersect(shared, Set(tt.snp)) end sample(collect(shared), nmask, replace=false) end smpl = Set(lstsnp) dir, _ = splitdir(tgt) # sample SNP to be masked open("$dir/mask.snp", "w") do io for snp in tbim.snp snp ∈ smpl && println(io, snp) end end #- plink extract for later comparison @info "Extract $nmask SNP test set" run(pipeline(`$plink --sheep --bfile $tgt --extract $dir/mask.snp --recode vcf-iid --out $dir/mask`, devnull)) @info "Prepare $tgt.vcf.gz with $nmask SNP removed" run(pipeline(`$plink --sheep --bfile $tgt --exclude $dir/mask.snp --recode vcf-iid bgz --out $tgt`, devnull)) @info "Impute the references about their few missing genotypes" for r in refs @info "Prepare reference $r" run(pipeline(`$plink --sheep --bfile $r --recode vcf-iid bgz --out $r`, devnull)) run(pipeline(`java -jar $beagle window=$window ne=$nsNe gt=$r.vcf.gz out=$r-p`, `grep Window`)) end # p for phased @info "Impute $tgt with each of the references" for r in refs @info "Impute with $r-p" run(pipeline(`java -jar $beagle window=$window ne=$nsNe ref=$r-p.vcf.gz gt=$tgt.vcf.gz out=$r-i`, `grep Window`)) run(pipeline(`$plink --sheep --vcf $r-i.vcf.gz --extract $dir/mask.snp --make-bed --recode vcf-iid --out $r-m`, devnull)) end for r in refs @info "Imputation results with $r" comp_vcf("$r-m.vcf", "$dir/mask.vcf") end end """ function comp_vcf(va, vb) --- Compare two plain (not zipped) VCF files of their alleles line by line. Return proportion of agreed allles and genotypes. """ function comp_vcf(va, vb) @info join(["Comparing", "- $va", "- $vb"], "\n") fa = open(va, "r") fb = open(vb, "r") mg = ma = 0 # m:misimputed; g:genotype; a:allele # skip headers n1 = n2 = 0 for line in eachline(fa) if line[2] ≠ '#' n1 = length(split(line)) break end end for line in eachline(fb) if line[2] ≠ '#' n2 = length(split(line)) break end end n1 ≠ n2 && @error "Not same ID set" nid = n1 - 9 nms = nlc = 0 for la in eachline(fa) nlc += 1 ta = split(la) tb = split(readline(fb)) snpa, snpb = (ta[3], tb[3]) snpa ≠ snpb && @error "Not same SNP set" a1, a2 = (ta[4][1], ta[5][1]) b1, b2 = (tb[4][1], tb[5][1]) flip = a1 ≠ b1 || a2 ≠ b2 flip && @warn "$snpa minor allele flipped" for i in 10:n1 a, b, x, y = Int.((ta[i][1], ta[i][3], tb[i][1], tb[i][3])) if x == 46 || y == 46 || a == 46 || b == 46 nms += 1 # Int('.') = 46 else if flip (a ≠ y) && (ma += 1) (b ≠ x) && (ma += 1) else (a ≠ x) && (ma += 1) (b ≠ y) && (ma += 1) end ((a + b) ≠ (x + y)) && (mg += 1) end end end # report println(lpad(" Total ID: ", 40), nid) println(lpad(" Total SNP: ", 40), nlc) println(lpad(" Genotypes missing: ", 40), nms/nid/nlc) println(lpad("Genotypes misimputed: ", 40), mg/nid/nlc) println(lpad(" Alleles misimputed: ", 40), ma/nid/nlc/2) close(fa) close(fb) end """ function read_map(mp) --- ## Description This read a map of 3 columns: - SNP name - Chromosome number - Base pair position into a dataframe. ## Note Only the first appeared SNP will be included in the map. Its other repeat(s) will be omitted. """ function read_map(mp) SNP = Set{String}() df = DataFrame(snp=String[], chr=Int8[], bp=Int32[]) for line in eachline(mp) snp, chr, bp = split(line) chr = parse(Int8, chr) bp = parse(Int32, bp) if snp ∉ SNP # remove duplicate push!(df, [snp chr bp]) push!(SNP, snp) end end df end """ function read_bim(bim) --- To read a plink bim file, assuming all chromosomes are integer. The 6 columns: 1. Chromosome 2. SNP name 3. Morgen 4. BP position 5. Allele 1 6. Allele 2 """ function read_bim(bim) df = DataFrame(chr=Int8[], snp=String[], mgn=Float64[], # morgen bp=Int32[], a1=Char[], a2=Char[]) for line in eachline(bim) chr, snp, mgn, bp, a1, a2 = split(line) chr = parse(Int8, chr) mgn = parse(Float64, mgn) bp = parse(Int32, bp) push!(df, [chr snp mgn bp a1[1] a2[1]]) end df end """ make_bed(dir, lmap, target) --- ## Description This function will merge the genotypes files of GSGT ver-2 format in `dir` into one `vcf` file according linkage map `lmap`. ## dir In the future, put all the files from a same platform in the same folder. This folder should contains the genotype files of GSGT ver-2 format. Nothing else. ## lmap This file contains 3 columns: 1. SNP name 2. Chromsome number. Here they 1-26 autosomes only. 3. Base pair position. The SNP are ordered on their chromosome numbers and bp positions. ## Example NSG.make_bed("dat/raw/a17k", "dat/maps/a17k.map", "dat/plink/a17k") Above will merge all the files in `dat/raw/a17k` into `dat/plink/a17k.{bed,bim,fam}`. """ function make_bed(dir, lmap, target) title("Merge files in $dir into $target.bed") item("Check parameters") if !isdir(dir) warning("$dir doesn't exist") return end dir = abspath(dir) files = readdir(dir, join=true) if length(files) == 0 warning("No file in $dir") end if !isfile(lmap) warning("Map $lmap doesn't exist") return end lmap = abspath(lmap) target = begin # check files to be saved pt, target = splitdir(target) if length(pt) == 0 warning("You are saving the bed files in the current dir") pt = pwd() else pt = abspath(pt) isdir(pt) || mkpath(pt) end joinpath(pt, target) end done("OK") item("Create beagle files") tmap = read_map(lmap) ID, GT = read_fr(files...) temp = mktempdir(".") write_bgl(tmap, ID, GT, temp) item("Create VCF files") for chr in 1:26 run(pipeline(`java -jar $bin_dir/beagle2vcf.jar $chr $temp/$chr.mrk $temp/$chr.bgl -`, "$temp/$chr.vcf")) end cp("$temp/1.vcf", "$target.vcf", force = true) open("$target.vcf", "a") do io for chr in 2:26 for line in eachline("$temp/$chr.vcf") line[1] ≠ '#' && println(io, line) end end end done() item("Make $target.bed") _ = read(run(`$plink --sheep --vcf $target.vcf --const-fid --out $target`), String) rm(temp, recursive=true, force=true) done() end """ function write_bgl(lmp, ID, GT, dir) --- Write linkage map `lmp`, ID vector `ID`, and genotype dictionary `GT` into Beagle files in `dir. """ function write_bgl(lmp, ID, GT, dir) CHR = lmp.chr[1] BP = -1 mrk = open("$dir/$CHR.mrk", "w") bgl = open("$dir/$CHR.bgl", "w") print(bgl, "I\tid\t") println(bgl, join(repeat(1:length(ID), inner=2), '\t')) for (snp, chr, bp) in eachrow(lmp) bp == BP && continue BP = bp if chr != CHR CHR = chr close(mrk) close(bgl) mrk = open("$dir/$chr.mrk", "w") bgl = open("$dir/$chr.bgl", "w") print(bgl, "I\tid\t") println(bgl, join(repeat(ID, inner=2), '\t')) end if haskey(GT, snp) alleles = Set(collect(GT[snp])) setdiff!(alleles, '-') # remove missing values length(alleles) !=2 && continue print(bgl, "M $snp ") println(bgl, join(collect(GT[snp]), ' ')) println(mrk, "$snp $bp ", join(alleles, ' ')) end end close(mrk) close(bgl) end """ function read_fr(files...) --- read `ID` vector and genotypes dictionary `GT`(`SNP => alleles`) for the `files...`, which are of final report format. """ function read_fr(files...) ID = String[] GT = Dict{String, String}() for f in files open(f, "r") do io for line in eachline(io) # skip header (line == "[Data]") && break end line = readline(io) # ID line append!(ID, split(line)) for line in eachline(io) t = split(line) if haskey(GT, t[1]) GT[t[1]] *= join(t[2:end]) else GT[t[1]] = join(t[2:end]) end end end end if length(unique(length.(values(GT)))) > 1 @error "The final report files are of different format" end ID, GT end
```python from sympy import symbols, Function, solve from sympy import diff, sin, exp ``` ```python x, y, c1, c2, c3, n = symbols('x y c1 c2 c3 n') y = Function('y') ``` ```python print(diff((x - c1 - c2*n-c3*n*n)**2, c1)) print(diff((x - c1 - c2*n-c3*n*n)**2, c2)) print(diff((x - c1 - c2*n-c3*n*n)**2, c3)) ``` 2*c1 + 2*c2*n + 2*c3*n**2 - 2*x -2*n*(-c1 - c2*n - c3*n**2 + x) -2*n**2*(-c1 - c2*n - c3*n**2 + x) ```python ```
[STATEMENT] lemma \<psi>_nonneg [intro]: "\<psi> x \<ge> 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 \<le> \<psi> x [PROOF STEP] unfolding \<psi>_def sum_upto_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 \<le> sum mangoldt {i. 0 < i \<and> real i \<le> x} [PROOF STEP] by (intro sum_nonneg mangoldt_nonneg)
#include <iostream> #include <fstream> #include <string> #include <boost/algorithm/string.hpp> #include <vector> using std::cout; using std::string; using std::ifstream; using std::istream; using std::ostream; /* ** Aufgabe 21 ** ** Fname Vname GebDatum Gehalt Plz ** string string YYYYMMTT double int ** ** Wir speichern ein excel file in obiger Auslegung als .csv file ** und lesen es mit C++ ein und geben den Inhalt am Bildschirm aus. ** */ class ma { string fName; string vName; int gebDatum; double gehalt; int plz; public: friend istream& operator>> (istream& is, ma& dt); friend ostream& operator<< (ostream& os, ma& dt); }; istream& operator>> (istream& is, ma& dt) { std::vector<string> sv; string i; if (std::getline(is, i)) { boost::split(sv, i, boost::is_any_of(";")); // , boost::token_compress_on); dt.fName = sv[0]; dt.vName = sv[1]; dt.gebDatum = std::stoi(sv[2]); dt.gehalt = std::stod(sv[3]); dt.plz = std::stoi(sv[4]); } return is; } ostream& operator<< (ostream& os, ma& a) { return os << a.fName << " " << a.vName << " " << a.gebDatum << " " << a.gehalt << " " << a.plz << std::endl; } int main() { std::ifstream fi("C:\\Users\\Hans Brabenetz\\Documents\\Book1.csv"); ma m; std::vector<ma> vm; while (fi >> m) vm.push_back(m); for (auto a : vm) cout << a; return 0; }
[STATEMENT] lemma opset_insert: assumes "opset (insert x ops) deps" shows "opset ops deps" [PROOF STATE] proof (prove) goal (1 subgoal): 1. opset ops deps [PROOF STEP] using assms opset_subset [PROOF STATE] proof (prove) using this: opset (insert x ops) deps \<lbrakk>opset ?Y ?deps; ?X \<subseteq> ?Y\<rbrakk> \<Longrightarrow> opset ?X ?deps goal (1 subgoal): 1. opset ops deps [PROOF STEP] by blast
lemma filterlim_pow_at_bot_odd: fixes f :: "real \<Rightarrow> real" shows "0 < n \<Longrightarrow> LIM x F. f x :> at_bot \<Longrightarrow> odd n \<Longrightarrow> LIM x F. (f x)^n :> at_bot"
"""Operations which handle numpy and tensorflow.compat.v1 automatically.""" import numpy as np from .. import config from ..backend import is_tensor, tf def istensorlist(values): return any(map(is_tensor, values)) def convert_to_array(value): """Convert a list to numpy array or tensorflow tensor.""" if istensorlist(value): return tf.convert_to_tensor(value, dtype=config.real(tf)) value = np.array(value) if value.dtype != config.real(np): return value.astype(config.real(np)) return value def hstack(tup): if not is_tensor(tup[0]) and tup[0] == []: tup = list(tup) if istensorlist(tup[1:]): tup[0] = tf.convert_to_tensor([], dtype=config.real(tf)) else: tup[0] = np.array([], dtype=config.real(np)) return tf.concat(tup, 0) if is_tensor(tup[0]) else np.hstack(tup) def roll(a, shift, axis): return tf.roll(a, shift, axis) if is_tensor(a) else np.roll(a, shift, axis=axis) def zero_padding(array, pad_width): # SparseTensor if isinstance(array, (list, tuple)) and len(array) == 3: indices, values, dense_shape = array indices = [(i + pad_width[0][0], j + pad_width[1][0]) for i, j in indices] dense_shape = ( dense_shape[0] + sum(pad_width[0]), dense_shape[1] + sum(pad_width[1]), ) return indices, values, dense_shape if is_tensor(array): return tf.pad(array, tf.constant(pad_width)) return np.pad(array, pad_width)
/- Copyright (c) 2022 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Devon Tuma -/ import set_theory.cardinal.basic import computational_monads.oracle_comp /-! # Support of an Oracle Computation This file defines the support of an `oracle_comp`, a `set` of possible outputs of the computation. We assume that oracle queries could return any possible value in their range. This aligns with `pmf.support` for the distribution semantics of `oracle_comp.eval_dist`. For `return` we set the support to be the singleton set of the return value. For `>>=` we set the support to be the union over the support of the first computation of the support of the second computation with that output as its input. For `query` we simply set the support to be the set of all elements in the oracle's output type. -/ namespace oracle_comp open oracle_spec variables {α β γ : Type} {spec: oracle_spec} (a : α) (oa : oracle_comp spec α) (ob : α → oracle_comp spec β) (i : spec.ι) (t : spec.domain i) (u : spec.range i) (x : α) (y : β) /-- Set of possible outputs of the computation, allowing for any possible output of the queries. This will generally correspond to the support of `eval_dist` (see `support_eval_dist`), but is slightly more general since it doesn't require α finite range. -/ def support : Π {α : Type} (oa : oracle_comp spec α), set α | _ (pure' α a) := {a} | _ (bind' α β oa ob) := ⋃ α ∈ oa.support, (ob α).support | _ (query i t) := ⊤ variable (spec) @[simp] lemma support_return : (return a : oracle_comp spec α).support = {a} := rfl lemma mem_support_return_iff : x ∈ (return a : oracle_comp spec α).support ↔ x = a := iff.rfl lemma mem_support_return_self : x ∈ (return x : oracle_comp spec α).support := set.mem_singleton x lemma support_pure' : (pure' α a : oracle_comp spec α).support = {a} := rfl lemma mem_support_pure'_iff : x ∈ (pure' α a : oracle_comp spec α).support ↔ x = a := iff.rfl lemma mem_support_pure'_self : x ∈ (pure' α x : oracle_comp spec α).support := set.mem_singleton x lemma support_pure : (pure a : oracle_comp spec α).support = {a} := rfl lemma mem_support_pure_iff : x ∈ (pure a : oracle_comp spec α).support ↔ x = a := iff.rfl lemma mem_support_pure_self : x ∈ (pure x : oracle_comp spec α).support := set.mem_singleton x variable {spec} @[simp] lemma support_bind : (oa >>= ob).support = ⋃ α ∈ oa.support, (ob α).support := rfl lemma mem_support_bind_iff : y ∈ (oa >>= ob).support ↔ ∃ x ∈ oa.support, y ∈ (ob x).support := by simp_rw [support_bind, set.mem_Union] lemma support_bind' : (bind' α β oa ob).support = ⋃ α ∈ oa.support, (ob α).support := rfl lemma mem_support_bind'_iff : y ∈ (bind' α β oa ob).support ↔ ∃ x ∈ oa.support, y ∈ (ob x).support := by simp_rw [support_bind', set.mem_Union] @[simp] lemma support_query : (query i t).support = ⊤ := rfl lemma mem_support_query : u ∈ (query i t).support := set.mem_univ u /-- If the range of `spec` is a `fintype` then the support is a finite set. -/ theorem support_finite (oa : oracle_comp spec α) : oa.support.finite := begin induction oa with α a α β oa ob hoa hob i t, { exact set.finite_singleton a }, { exact hoa.bind (λ a _, hob a)}, { exact set.finite_univ } end noncomputable instance support.coe_sort_fintype (oa : oracle_comp spec α) : fintype ↥(oa.support) := (support_finite oa).fintype /-- Since the range of oracles in an `oracle_spec` are required to be nonempty, we naturally get that the `support` of an `oracle_comp` is nonempty. -/ theorem support_nonempty (oa : oracle_comp spec α) : oa.support.nonempty := begin induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t, { exact set.singleton_nonempty a }, { simp only [bind'_eq_bind, support_bind, set.nonempty_bUnion, exists_prop], exact let ⟨a, ha⟩ := hoa in ⟨a, ha, hob a⟩ }, { simp only [support_query, set.top_eq_univ, set.univ_nonempty] } end instance support.coe_sort_inhabited (oa : oracle_comp spec α) : inhabited ↥(oa.support) := begin induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t, { exact ⟨⟨a, mem_support_pure_self spec a⟩⟩ }, { refine ⟨⟨(hob hoa.1).1.1, _⟩⟩, simp only [subtype.val_eq_coe, bind'_eq_bind, support_bind, set.mem_Union, exists_prop], exact ⟨hoa.1.1, hoa.1.2, (hob hoa.1).1.2⟩ }, { exact ⟨⟨default, mem_support_query i t default⟩⟩ } end lemma support_eq_singleton_iff_forall : oa.support = {x} ↔ ∀ x' ∈ oa.support, x' = x := by simp only [set.eq_singleton_iff_nonempty_unique_mem, oa.support_nonempty, true_and] lemma support_eq_singleton_iff_subset : oa.support = {x} ↔ oa.support ⊆ {x} := by simp only [support_eq_singleton_iff_forall, set.subset_singleton_iff] /-- Should be able to automatically derive the support for most simple computations -/ example : do{ β ← coin, β' ← coin, x ← if β then return 0 else return 1, y ← return (if β' then 1 else 0), z ← if β then return x else return (y - y), return (x * y * z) }.support = {0} := by simp end oracle_comp
! ! Written by Leandro Martínez, 2009-2011. ! Copyright (c) 2009-2018, Leandro Martínez, Jose Mario Martinez, ! Ernesto G. Birgin. ! ! Module that contains some ahestetic output definitions ! module ahestetic character(len=13), parameter :: dash1_line = "( 80('-') )",& dash2_line = "(/,80('-') )",& dash3_line = "(/,80('-'),/)" character(len=13), parameter :: hash1_line = "( 80('#') )",& hash2_line = "(/,80('#') )",& hash3_line = "(/,80('#'),/)" character(len=31), parameter :: prog1_line = "(' Packing:|0 ',tr60,'100%|' )",& prog2_line = "(' Moving:|0 ',tr60,'100%|' )" end module ahestetic
~ quaternions are represented as a vector(4) ~ r + xi + yj + zk => [r, x, y, z] function quaternion_rotation(theta, v) st = sin(theta/2) return [cos(theta/2), st*v[0], st*v[1], st*v[2]] end function quaternion_add(x, y) return x + y end function quaternion_negate(x) return -x end function quaternion_subtract(x, y) return x - y end function quaternion_multiply(x, y) return [ x[0]*y[0] - x[1]*y[1] - x[2]*y[2] - x[3]*y[3], \ x[0]*y[1] + x[1]*y[0] + x[2]*y[3] - x[3]*y[2], \ x[0]*y[2] + x[2]*y[0] + x[3]*y[1] - x[1]*y[3], \ x[0]*y[3] + x[3]*y[0] + x[1]*y[2] - x[2]*y[1] ] end function quaternion_conjugate(x) return [x[0], -x[1], -x[2], -x[3]] end function quaternion_normalize(x) return x/sqrt(x*x) end function quaternion_inverse(x) return quaternion_conjugate(x)/(x*x) end function quaternion_divide(x, y) return quaternion_multiply(x, quaternion_inverse(y)) end function quaternion_rotate(x, y) return quaternion_multiply(quaternion_multiply(x, y), quaternion_inverse(x)) end function quaternion_from_matrix(m) if m[2,2] < 0 then if m[0,0] > m[1,1] then t = 1 + m[0,0] - m[1,1] - m[2,2] q = [m[2,1] - m[1,2], t, m[1,0] + m[0,1], m[0,2] + m[2,0]] else t = 1 - m[0,0] + m[1,1] - m[2,2] q = [m[0,2] - m[2,0], m[1,0] + m[0,1], t, m[2,1] + m[1,2]] end else if m[0,0] < -m[1,1] then t = 1 - m[0,0] - m[1,1] + m[2,2] q = [m[1,0] - m[0,1], m[0,2] + m[2,0], m[2,1] + m[1,2], t] else t = 1 + m[0,0] + m[1,1] + m[2,2] q = [t, m[2,1] - m[1,2], m[0,2] - m[2,0], m[1,0] - m[0,1]] end return q/(2*sqrt(t)) end function quaternion_to_matrix(q) return [ 1 - 2*q[2]*q[2] - 2*q[3]*q[3], 2*q[1]*q[2] - 2*q[3]*q[0], 2*q[1]*q[3] + 2*q[2]*q[0] 2*q[1]*q[2] + 2*q[3]*q[0], 1 - 2*q[1]*q[1] - 2*q[3]*q[3], 2*q[2]*q[3] - 2*q[1]*q[0] 2*q[1]*q[3] - 2*q[2]*q[0], 2*q[2]*q[3] + 2*q[1]*q[0], 1 - 2*q[1]*q[1] - 2*q[2]*q[2] ] end function quaternion_slerp(xa, ya, t) x = quaternion_normalize(xa) y = quaternion_normalize(ya) dot = x*y if dot < 0 then x = -x dot = -dot end if dot > 0.9995 then return quaternion_normalize((1-t)*x + t*y) end theta0 = acos(dot) theta = t*theta0 st = sin(theta) st0 = sin(theta0) s0 = cos(theta) - dot*st/st0 s1 = st/st0 return s0*x + s1*y end
So Foley banks are not lending as freely these days huh? The credit crunch that seized the Alabama economy recently is gone and they are starting to lend again. But even with this lending the economy is still reeling and headed for even more dire straits. If you are one of those in Foley AL who is caught in its clutches and have debts piling up, you may want to think about Foley consolidation loans. Who has the best Foley debt consolidation services? Foley consolidation services offer a way of taking multiple debts and taking them all and wrapping them together into one payment. So if you have 5 different Foley loans, each with a different interest rate and length, a Foley debt consolidation loan will pay these off and then you will be left with one Foley loan with a total on the loan of all the paid off loans. The best part is that these types of Foley consolidation loans typically have lower interest rates than the ones you are getting rid of. What is the best place in Alabama to find Foley credit consolidation lenders? Search online for the best debt consolidation lenders in Foley AL. The reason the best place to find Foley debt consolidation lenders in Alabama is because you will be able to find the right Foley lender for you. Your local Foley banks may not specialize in the right Foley consolidation loans for you or have Alabama lending standards that are too stringent. By searching for the best Alabama debt consolidation loans online, you can assure yourself of getting the right Foley loan. As I said above, prior to the credit crunch we had basically "easy money" whereby the Foley banks were encouraged to lend to pretty much anyone in Alabama with a pulse. As the economy tanked and their Foley debts mounted, a large portion of these people who got easy credit are now looking for Foley credit card consolidation programs. These Foley loans can be obtained but they are just like any other Foley loan. Your Alabama credit rating, your ability to repay the Foley loan, an availability of collateral to secure the loan and the current Foley bank policies on Alabama lending will determine if you get a Foley consolidation loan or not. Where Is The Best Foley Loan Consolidation Service? As I discussed above, the typical Foley loan consolidation service usually has a lower interest rate than the standard Alabama loan that is putting you in the poor house. Be aware that just because you are in trouble with your Foley monthly payments, does not mean that you will automatically get Foley loan consolidation. Where Can I find The Best Foley Debt Consolidation Help? I spoke of collateral before and this is a big aspect of why Foley debt consolidation lenders may give you Foley loan consolidation. Unsecured Foley loans are the riskiest loans to give by a Alabama lender. This is because if the Foley loan is defaulted on, the bank cannot get the money back. By requiring collateral to provide security on a loan (as some Foley banks do for Foley debt consolidation loans) the bank reduces their risk for the loan. A secured Foley loan allows the lender to offer the loan to you and then to offer the Foley loan at a reduced interest rate. Be careful to make sure you pay off the Foley credit card consolidation loan on time. If you were required to put up collateral and you default, the Foley bank will take that collateral as a way to recoup their loss. At MyCDC.org, we offer the highest quality Foley credit card consolidation programs that are available online throughout the USA. Mycdc offers this online by providing you with a custom Foley credit card consolidation plan that will help you to consolidate your unsecured debts, and also fit your budget, while helping you to reach your goal of Financial FREEDOM! Foley Consolidation Loans -- Our online credit card consolidation service will consolidate debt without the need of a loan. Your custom Foley credit card consolidation program will consolidate your debts by negotiating with creditors to get YOU a lower repayment amount without the RISK of any type of high interest Alabama debt consolidation loans! Foley Customer Service -- MyCDC.org is committed to using the highest level of Customer Service in the credit card consolidation industry. Once enrolled in a credit card consolidation program, a trained, personal debt counselor will be assigned to your account. Your debt counselor will review your debts and financial situation and develop a custom credit card consolidation solution based on YOUR personal Foley debt situation and needs.
function [ fea, out ] = ex_poisson1( varargin ) %EX_POISSON1 1D Poisson equation example. % % [ FEA, OUT ] = EX_POISSON1( VARARGIN ) Poisson equation on a line with a % constant source term equal to 1, homogenous boundary conditions, and % exact solution (-x^2+x)/2. Accepts the following property/value pairs. % % Input Value/{Default} Description % ----------------------------------------------------------------------------------- % hmax scalar {1/10} Grid cell size % sfun string {sflag1} Finite element shape function % iphys scalar 0/{1} Use physics mode to define problem (=1) % or directly define fea.eqn/bdr fields (=0) % or use core assembly functions (<0) % iplot scalar 0/{1} Plot solution (=1) % . % Output Value/(Size) Description % ----------------------------------------------------------------------------------- % fea struct Problem definition struct % out struct Output struct % Copyright 2013-2022 Precise Simulation, Ltd. cOptDef = { 'hmax', 1/10; 'sfun', 'sflag1'; 'refsol', '(-x^2+x)/2'; 'fsrc', '1'; 'iphys', 1; 'icub', 2; 'iplot', 1; 'tol', 2e-2; 'fid', 1 }; [got,opt] = parseopt(cOptDef,varargin{:}); fid = opt.fid; % Grid generation. if( opt.hmax>0 ) nx = round( 1/opt.hmax ); fea.grid = linegrid( nx, 0, 1 ); else % Scrambled testing grid. fea.grid.p = [ 0 1/10 4/10 1/3 1 1-1/3 ]; fea.grid.c = [ 1 4 2 6 3 ; 2 3 4 5 6 ]; fea.grid.a = [ 0 2 1 4 3 ; 2 4 3 0 5 ]; fea.grid.b = [ 1 1 1 -1 ; 4 2 2 1 ]'; fea.grid.s = ones(1,5); end n_bdr = 2; % Number of boundaries. % Problem definition. fea.sdim = { 'x' }; % Coordinate name. switch opt.iphys case 0 % Directly define fea.eqn/bdr fields. fea.dvar = { 'u' }; % Dependent variable name. fea.sfun = { opt.sfun }; % Shape function. % Define equation system. fea.eqn.a.form = { [2;2] }; % First row indicates test function space (2=x-derivative), % second row indicates trial function space (2=x-derivative). fea.eqn.a.coef = { 1 }; % Coefficient used in assembling stiffness matrix. fea.eqn.f.form = { 1 }; % Test function space to evaluate in right hand side (1=function values). fea.eqn.f.coef = { opt.fsrc }; % Coefficient used in right hand side. % Define boundary conditions. if( strcmp(opt.sfun(end-1:end),'H3') ) % Prescribed derivatives at end points for Hermite elements. fea.bdr.d = {{ 0 0 ; 1/2 -1/2 }}; else fea.bdr.d = cell(1,n_bdr); [fea.bdr.d{:}] = deal(0); % Assign zero to all boundaries (homogenous Dirichlet conditions). end fea.bdr.n = cell(1,n_bdr); % No Neumann boundaries ('fea.bdr.n' empty). % Parse and solve problem. fea = parseprob(fea); % Check and parse problem struct. fea.sol.u = solvestat(fea,'fid',fid,'icub',opt.icub); % Call to stationary solver. case 1 % Use physics mode. fea = addphys(fea,@poisson); % Add Poisson equation physics mode. fea.phys.poi.sfun = { opt.sfun }; % Set shape function. fea.phys.poi.eqn.coef{3,4} = { opt.fsrc }; % Set source term coefficient. fea.phys.poi.bdr.coef{1,end} = repmat({0},1,n_bdr); % Set Dirichlet boundary coefficient to zero. fea = parsephys(fea); % Check and parse physics modes. if( strcmp(opt.sfun(end-1:end),'H3') ) % Prescribed derivatives at end points for Hermite elements. fea.bdr.d = {{ 0 0 ; 1/2 -1/2 }}; end % Parse and solve problem. fea = parseprob(fea); % Check and parse problem struct. fea.sol.u = solvestat(fea,'fid',fid,'icub',opt.icub); % Call to stationary solver. otherwise % Use core assembly functions. fea.dvar = { 'u' }; % Dependent variable name. fea.sfun = { opt.sfun }; % Shape function. fea = parseprob(fea); % Check and parse problem struct. % Assemble stiffness matrix. form = [2;2]; sfun = {opt.sfun;opt.sfun}; coefa = 1; sind = 1; i_cub = opt.icub; [vRowInds,vColInds,vAvals,n_rows,n_cols] = ... assemblea(form,sfun,coefa,i_cub,fea.grid.p,fea.grid.c,fea.grid.a,fea.grid.s,[]); A = sparse(vRowInds,vColInds,vAvals,n_rows,n_cols); % Check and compare with finite difference stencil. if (strcmp(opt.sfun,'sflag1')) h = 1/nx; n = nx+1; e = ones(n,1); A_ref = 1/h*spdiags([-e 2*e -e], -1:1, n, n); A_ref(1) = A_ref(1)/2; A_ref(end) = A_ref(end)/2; err = norm(A(:)-A_ref(:)); if err>opt.tol out.err = err; out.pass = -1; return end end form = 1; sfun = sfun{1}; coeff = 1; f = assemblef(form,sfun,coeff,i_cub,fea.grid.p,fea.grid.c,fea.grid.a,fea.grid.s,[]); % Check and compare with finite difference stencil. if (strcmp(opt.sfun,'sflag1')) f_ref = coeff*h*ones(n,1); f_ref([1 end]) = coeff*1/2*h; err = norm(f-f_ref); if err>1e-6 out.err = err; out.pass = -2; return end end % Set homogenous Dirichlet boundary conditions on first and last dof/node. bind = [1 nx+1]; A = A'; %' A(:,bind) = 0; % Zero out Dirichlet BC rows. for i=1:length(bind) % Loop to set diagonal entry to 1. i_a = bind(i); A(i_a,i_a) = 1; end A = A'; %' f(bind) = 0; % Set corresponding source term entries to Dirichlet BC values. % Solve problem. fea.sol.u = A\f; end % Postprocessing. if ( opt.iplot>0 ) x = linspace( 0, 1, 41 ); u = evalexpr( 'u', x, fea )'; figure subplot(3,1,1) plot( x, u ) axis( [0 1 0 0.2]) grid on title('Solution u') subplot(3,1,2) ux = (-x.^2+x)/2; plot( x, ux ) axis( [0 1 0 0.2]) grid on title('Exact solution') subplot(3,1,3) plot( x, abs(ux-u) ) title('Error') end % Error checking. xi = [1/2; 1/2]; s_err = ['abs(',opt.refsol,'-u)']; err = evalexpr0(s_err,xi,1,1:size(fea.grid.c,2),[],fea); ref = evalexpr0('u',xi,1,1:size(fea.grid.c,2),[],fea); err = sqrt(sum(err.^2)/sum(ref.^2)); if( ~isempty(fid) ) fprintf(fid,'\nL2 Error: %e\n',err) fprintf(fid,'\n\n') end out.err = err; out.tol = opt.tol; out.pass = out.err<out.tol; if ( nargout==0 ) clear fea out end
subroutine pest_decay !! ~ ~ ~ PURPOSE ~ ~ ~ !! this subroutine calculates degradation of pesticide in the soil and on !! the plants !! ~ ~ ~ INCOMING VARIABLES ~ ~ ~ !! name |units |definition !! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ !! decay_f(:) |none |exponential of the rate constant for !! |degradation of the pesticide on foliage !! decay_s(:) |none |exponential of the rate constant for !! |degradation of the pesticide in soil !! ihru |none |HRU number use pesticide_data_module use hru_module, only : hru, ihru use constituent_mass_module use soil_module use plant_module use output_ls_pesticide_module implicit none integer :: j !none |hru number integer :: k !none |seqential pesticide number being simulated integer :: ipest_db !none |pesticide number from pesticide data base integer :: l !none |layer number real :: pest_init !kg/ha |amount of pesticide present at beginning of day real :: pest_end !kg/ha |amount of pesticide present at end of day real :: pst_decay_s !kg/ha |amount of pesticide decay in soil during day j = ihru if (cs_db%num_pests == 0) return do k = 1, cs_db%num_pests hpestb_d(j)%pest(k)%decay_s = 0. hpestb_d(j)%pest(k)%decay_f = 0. ipest_db = cs_db%pest_num(k) if (ipest_db > 0) then pst_decay_s = 0. !! calculate degradation in soil do l = 1, soil(j)%nly pest_init = cs_soil(j)%ly(l)%pest(k) if (pest_init > 1.e-12) then pest_end = pest_init * pestcp(ipest_db)%decay_s cs_soil(j)%ly(l)%pest(k) = pest_end pst_decay_s = pst_decay_s + (pest_init - pest_end) end if end do hpestb_d(j)%pest(k)%decay_s = pst_decay_s !! calculate degradation on plant foliage pest_init = cs_pl(j)%pest(k) if (pest_init > 1.e-12) then pest_end = pest_init * pestcp(ipest_db)%decay_f cs_pl(j)%pest(k) = pest_end hpestb_d(j)%pest(k)%decay_f = pest_init - pest_end end if end if end do return end subroutine pest_decay
function xa = binom ( x, xx, npl, m, nt ) %*****************************************************************************80 % %% BINOM: binomial expansion series for the (-1/M) power of a Chebyshev series. % % Discussion: % % This routine uses a certain number of terms of the binomial expansion % series to estimate the (-1/M) power of a given Chebyshev series. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 21 September 2011 % % Author: % % Original FORTRAN77 version by Roger Broucke. % MATLAB version by John Burkardt. % % Reference: % % Roger Broucke, % Algorithm 446: % Ten Subroutines for the Manipulation of Chebyshev Series, % Communications of the ACM, % October 1973, Volume 16, Number 4, pages 254-256. % % Parameters: % % Input, real X(NPL), the given Chebyshev series. % % Input, real XX(NPL), an initial estimate for % the Chebyshev series for the input function raised to the (-1/M) power. % % Input, integer NPL, the number of terms in the % Chebyshev series. % % Input, integer M, defines the exponent, (-1/M). % 0 < M. % % Input, integer NT, the number of terms of the binomial % series to be used. % % Output, real XA(NPL), the estimated Chebyshev series % for the input function raised to the (-1/M) power. % xa = zeros ( npl, 1 ); dm = m; alfa = - 1.0 / dm; ww(1:npl) = x(1:npl); for k = 1 : m w2 = mltply ( ww, xx, npl ); ww(1:npl) = w2(1:npl); end ww(1) = ww(1) - 2.0; xa(1) = 2.0; xa(2:npl) = 0.0; w3(1) = 2.0; w3(2:npl) = 0.0; for k = 2 : nt dkmm = k - 1; dkm2 = k - 2; coef = ( alfa - dkm2 ) / dkmm; w2 = mltply ( w3, ww, npl ); w3(1:npl) = w2(1:npl) * coef; xa(1:npl) = xa(1:npl) + w3(1:npl); end w2 = mltply ( xa, xx, npl ); xa(1:npl) = w2(1:npl); return end
module AutoPreallocation using Cassette using LinearAlgebra: LinearAlgebra export avoid_allocations, record_allocations, freeze, preallocate, reinitialize!, @no_prealloc include("record_types.jl") include("recording.jl") include("replaying.jl") include("inference_fixes.jl") include("no_prealloc.jl") include("preallocate.jl") end # module