There is a natural generalization of the aforementioned dimension-based reasoning to modules $M$ over commutative domains or commutative Noetherian reduced rings.

Let $M$ be a module over a commutative domain $R$ and let $K$ be the fraction field of $R$. We set $\text{rk}(M) \Doteq \dim_K(M \otimes_R K)$.

**Claim.** Let $R$ be a commutative domain. Let $M$ be an $R$-module of finite rank over $R$ and let $N_1, N_2 \subseteq V$ be submodules of $M$. Then we have $\text{rk}(N_1) + \text{rk}(N_2) = \text{rk}(N_1 \cap N_2) + \text{rk}(N_1 + N_2)$.

*Proof.* Let $f: N_1 \oplus N_2 \rightarrow M$ be the $R$-linear map defined by $f(n_1, n_2) = n_1 + n_2$. It suffices to apply the exact functor $(-)\otimes_R K$ to the exact sequence
$0 \rightarrow N_1 \cap N_2 \rightarrow N_1 \oplus N_2 \xrightarrow[]{f} N_1 + N_2 \rightarrow 0$ and then use the Rank-Nullity Theorem.

If $R$ is any commutative reduced Noetherian ring, then its total ring of fractions $K$ is a product $\prod_i K_i$ of finitely many fields $K_i$.
We set $\text{rk}(M) \Doteq (\dim_{K_i}(M \otimes_R K_i))_i$, a finite-dimensional vector with integer coordinates. The same claim will hold true if we replace "domain" by "reduced Noetherian ring" and if vectors are ordered component-wise.

**About the terminology.** Let $R$ be a commutative domain, $M$ a torsion-free module over $R$ and $N$ an $R$-submodule of $M$. Let us call $N$ a *primitive submodule of $M$* if there is no non-invertible element $d \in R$ such that $N = dN'$ for some submodule $N'$ of $M$. If $R$ is moreover Noetherian, then every submodule $N$ is contained a primitive submodule of $M$. If $M$ is free of finite rank and if $R$ is an elementary divisor ring (e.g., a principal ideal domain), then a finitely generated submodule $N$ is a primitive submodule of $M$ if and only if the minimal number of generators of $M/N$ is strictly less that $\text{rk}(M)$, if and only if $N$ has a generating set containing a basis vector of $M$, or *primitive vector of $M$*.
In the theory of orders in quadratic number fields, the terminology *primitive ideal* is standard and has a meaning which is close to our definition.

**About affine submodules.** Let $R$ be any commutative ring with identity and let $M$ be an $R$-module. Let $N_1, N_2$ be two submodules of $M$.
Let $a_1, a_2 \in M$ and set $A_i = a_i + N_i$ for $i = 1,2$. Then $A_1 \cap A_2$ is non-empty if and only if $a_1 - a_2 \in N_1 + N_2$. If $A_1 \cap A_2$ is not empty, then it is an affine $R$-module of the form $s + N_1 \cap N_2$ where $s$ is any element of $A_1 \cap A_2$. From now on, we assume that $R$ is a domain or a reduced Noetherian ring with total ring fractions $K$. In this case, the rank of $N_1 \cap N_2$ is subject to the relation of the above claim. If $M$ is moreover torsion-free of finite rank and $N_1$ and $N_2$ are both finitely generated, then deciding whether $A_1 \cap A_2$ is $\{0\}$ boils down to deciding whether $AX = B$ has a solution $X \in R^n$ for some $m$-by-$n$ matrix $A$ over a field and some $B \in R^n$. This can be handled by linear algebra if $B = 0$. Let us assume now that $R$ is a domain and both $N_1$ and $N_2$ are finitely generated over $R$. Compute a minimal generating set of $V_1 \cap V_2$ is manageable if $R$ is an elementary divisor ring (see also this MO post), e.g., a principal ideal ring. In this case, we can use the Smith Normal Form of $A$ to solve $AX = 0$. If $M$ is free of finite rank over $R$, we can do the same for the equation $AX = B$ under the same assumptions.

As the localization at any prime $\mathfrak{p}$ of a Dedekind ring $R$ is principal ideal domain, we obtain a Smith Normal Form of $A$ over $R_{\mathfrak{p}}$ for any such $\mathfrak{p}$. This yields an algorithm to decide on the existence of solutions for the system $AX = B$: we only need to check existence for the minimal prime ideals containing the *Fitting ideal of $A$*, see [5, Proposition 20.7 and subsequent comment].

**Addendum.** Here is an example of what can be achieved by sage.

```
K = CyclotomicField(4)
R = K.maximal_order() # R = Z[i], the ring of Gaussian integers. The
ring R is Euclidean.
i = K.gen();
# Definition of the intersection problem of two affine planes in R^3
b_1 = vector([4 * i + 6, -7 * i , -19 + 17 * i])
b_2 = vector([-1, 35, 0])
A_1 = Matrix(R, [[ 0, 2 - i], [ 3 - 2 * i, -i ], [ 0, 1 + 7 * i]])
A_2 = Matrix(R, [[ 2 - i, 1 + 2 * i], [ 0, 1 - i], [ 1, 0]])
# Concatenating A_1 with -A_2
A_2 = - A_2
C = [ c for c in A_1.columns() ]
C += [ c for c in A_2.columns() ]
A = Matrix(R, C).transpose();
# Finding one solution
# Note: solve_right() may find a solution with coordinates in the fraction field of R but not in R
# I don't know if in the latter case this indicates that there is no solution.
A.solve_right(b_2 - b_1); # In our example, it finds (7*zeta4 + 8, -3*zeta4 - 2, 0, 0) where zeta4 stands for i.
# Using is_submodule() to check existence of solutions
M = R^3
N = M.submodule(A.transpose()) # This is the submodule generated by the columns of A.
L = M.span(Matrix(R, b_1 - b_2))
ans = L.is_submodule(M);
ans; # The answer is yes, our linear system has at least one solution in R^3.
# Using intersection() to describe the whole solution set
N_1 = M.span(A_1.transpose())
N_2 = M.span(A_2.transpose())
N_1.intersection(N_2); # This is the rank 1 R-module generated by [4*zeta4 + 7 -7*zeta4 - 35 17*zeta4 - 19] in our example
# Using kernel() to describe the whole solution set
kerA = kernel(A.transpose())
solution_dim = len(kerA.basis()) # This is 1 in our example.
basis_vector = kerA.basis()[0];
x_1 = vector([ basis_vector[index] for index in range(0, 2)])
n_1 = Matrix(R, A_1) * x_1; # This vector generates N_1 \cap N_2 over R in our example.
# Using smith_form() to describe the whole solution set
# With the invariant factor matrix and the two change-of-basis matrices
# you can decide whether the linear system has a solution and describe the full set of solutions
A.smith_form();
```

**Edit.** As explained above, the resolution of linear systems of the form $AX = B$ over an arbitrary commutative case is particularly relevant to the question when each module $M_i \, (i = 1, 2)$ is given with an explicit embedding in some free module $R^{k_i}$. I just realized that there exist general theorems by means of which one can decide on the existence and uniqueness of solutions.

MacCoy's Theorem [2, Th. 51] addresses the problem as to whether the system $AX = 0$ has a non-trivial solution $X \in R^n$ for $A$ an $m \times n$ matrix over an arbitrary commutative ring $R$: a non-trivial solution exists if and only if the *determinantal rank* of $A$ is less than $n$.

[3, Proposition 1] shows that $AX = B$ has a solution in $R^n$ if and only if the localized system at $\mathfrak{m}$ has a solution in $R_{\mathfrak{m}}^n$ for every maximal ideal $\mathfrak{m}$ of $R$, an arbitrary commutative ring. [3, Theorem 6] and [4, Theorem 10] give (the same) necessary and sufficient conditions for the existence of solutions of the system $AX = B$ when $R$ is a Prüfer domain, generalizing a result of E. Steinitz [1] established for Dedekind rings.

[1] E. Steinitz, "Rechteckige systeme and moduln in algebraischen zahlkorpern", 1912.

[2] N. MacCoy, "Rings and Ideals", 1948.

[3] P. Camion, L. Levy and H. Mann, "Linear equations over a commutative ring", 1971.

[4] J. Hermida and T. Sanchez-Giralda, "Linear equations and commutative rings", 1986.

[5] D. Eisenbud, "Commutative Algebra with a View Toward Algebraic Geometry", 2004.

subbundleof $M$. $\endgroup$ – R. van Dobben de Bruyn Jul 8 '18 at 22:46