# HG changeset patch
# User Luis Felipe Tabera Alonso <lftabera@yahoo.es>
# Parent 1c08d131a36f9c3e6a341373a4f257d56916adbe
#8800: doctest coverage of sage/categories/functor and sage/categories/pushout;
diff -r 1c08d131a36f sage/categories/pushout.py
a
|
b
|
|
2686 | 2686 | """ |
2687 | 2687 | Mathematically, Algebraic Closure subsumes Algebraic Extension. |
2688 | 2688 | However, it seems that people do want to work with algebraic |
2689 | | extensions of ``RR``. Therefore, we dont merge with algebraic extension. |
| 2689 | extensions of ``RR``. Therefore, we do not merge with algebraic extension. |
2690 | 2690 | |
2691 | 2691 | TEST:: |
2692 | 2692 | |
… |
… |
|
2851 | 2851 | def pushout(R, S): |
2852 | 2852 | r""" |
2853 | 2853 | Given a pair of Objects R and S, try and construct a |
2854 | | reasonable object $Y$ and return maps such that |
| 2854 | reasonable object Y and return maps such that |
2855 | 2855 | canonically $R \leftarrow Y \rightarrow S$. |
2856 | 2856 | |
2857 | 2857 | ALGORITHM: |
2858 | 2858 | |
2859 | 2859 | This incorporates the idea of functors discussed Sage Days 4. |
2860 | | Every object $R$ can be viewed as an initial object and |
| 2860 | Every object R can be viewed as an initial object and |
2861 | 2861 | a series of functors (e.g. polynomial, quotient, extension, |
2862 | 2862 | completion, vector/matrix, etc.). Call the series of |
2863 | 2863 | increasingly-simple rings (with the associated functors) |
2864 | | the "tower" of $R$. The \code{construction} method is used to |
| 2864 | the "tower" of R. The construction method is used to |
2865 | 2865 | create the tower. |
2866 | 2866 | |
2867 | | Given two objects $R$ and $S$, try and find a common initial |
2868 | | object $Z$. If the towers of $R$ and $S$ meet, let $Z$ be their |
| 2867 | Given two objects R and S, try and find a common initial |
| 2868 | object Z. If the towers of R and S meet, let Z be their |
2869 | 2869 | join. Otherwise, see if the top of one coerces naturally into |
2870 | 2870 | the other. |
2871 | 2871 | |
2872 | | Now we have an initial object and two \emph{ordered} lists of |
| 2872 | Now we have an initial object and two ordered lists of |
2873 | 2873 | functors to apply. We wish to merge these in an unambiguous order, |
2874 | 2874 | popping elements off the top of one or the other tower as we |
2875 | | apply them to $Z$. |
| 2875 | apply them to Z. |
2876 | 2876 | |
2877 | 2877 | - If the functors are distinct types, there is an absolute ordering |
2878 | 2878 | given by the rank attribute. Use this. |
… |
… |
|
2881 | 2881 | |
2882 | 2882 | - If the tops are equal, we (try to) merge them. |
2883 | 2883 | |
2884 | | - If \emph{exactly} one occurs lower in the other tower |
| 2884 | - If exactly one occurs lower in the other tower |
2885 | 2885 | we may unambiguously apply the other (hoping for a later merge). |
2886 | 2886 | |
2887 | 2887 | - If the tops commute, we can apply either first. |
… |
… |
|
2890 | 2890 | |
2891 | 2891 | EXAMPLES: |
2892 | 2892 | |
2893 | | Here our "towers" are $R = Complete_7(Frac(\ZZ)$ and $Frac(Poly_x(\ZZ))$, |
2894 | | which give us $Frac(Poly_x(Complete_7(Frac(\ZZ)))$:: |
| 2893 | Here our "towers" are $R = Complete_7(Frac(\ZZ))$ and $Frac(Poly_x(\ZZ))$, |
| 2894 | which give us $Frac(Poly_x(Complete_7(Frac(\ZZ))))$:: |
2895 | 2895 | |
2896 | 2896 | sage: from sage.categories.pushout import pushout |
2897 | 2897 | sage: pushout(Qp(7), Frac(ZZ['x'])) |