I asked this earlier on math.stackexchange but I think this is a better place for this question.


Computing the intersection of ideals belonging to the same maximal order of a number field $K$ can be reduced to computing the intersection of lattices of the same dimension.


How can I compute the intersection of an ideal with a maximal order of a subfield, where the underlying lattices no longer have the same dimension?


More concretely, given an ideal $\mathfrak{I} \subset \mathcal{O}\_K$ and a subfield $L \subset K$, how can I compute a basis for $\mathfrak{I}\cap\mathcal{O}\_L$?


This is relevant, but only leads me to intersection of lattices of equal rank: <https://math.stackexchange.com/questions/1560411/basis-for-the-intersection-of-two-integer-lattices>



How to compute the intersection of an ideal with the maximal order of a subfield?
This reduces easily to computing the intersection of two $\mathbf{Z}$-lattices (not necessarily of full rank) inside $\mathbf{Q}^n$ for some $n$. If you have two lattices $L, M$ of ranks $r$ and $s$, and you let $A$, $B$ be the $r \times n$, resp. $s \times n$, matrices whose rows are bases of $L$ and $M$ respectively, then you can compute the intersection $L \cap M$ by computing the kernel of the $(r + s) \times n$ integer matrix given by stacking $A$ on top of $B$.


(Mathematically, this is relying on the fact that the map from the abstract direct sum $L \oplus M$, to the sum of $L$ and $M$ as submodules of $\mathbf{Q}^n$, has kernel $\{ (v, -v): v \in L \cap M\}$.)


See the [Sage library code for the "intersection" method of free modules](https://github.com/sagemath/sage/blob/d6c5cd9be78cc448ee4c54bac93385b1244a234c/src/sage/modules/free_module.py#L3002).


