Global functions¶
Decompose a difference between submonoids as submonoids¶
If we have two translations of submonoids \(b+\mathbb{N}G\) and \(b+\mathbb{N}G'\) where \(G' \supseteq G\) as a face, then there is an algorithm to represent the difference \((b+\mathbb{N}G) \setminus (b+\mathbb{N}G)'\) as a union of finitely many translations of submonoids \(\bigcup_{i=1}^{m}a_{i}+\mathbb{N}F_{i}\) where \(G \subseteq F_{i}\) for any \(i \in \{1,2, \cdots, m\}\). This algorithm was implemented as pair_difference()
. More details on this algorithm can be found in Yu, 2020 or Matusevich and Yu, 2020.
- stdpairs.pair_difference(pair_a, pair_b)¶
Given two pairs
pair_a
andpair_b
representing \((a,F)\) and \((b,G)\) such that \(F \subseteq G\), return a collection \(C\) such that \((a+\mathbb{N}F) \setminus (b+\mathbb{N}G) = \bigcup_{(c,H) \in C}(c+\mathbb{N}H)\). This is an implementation of Theorem 4.1 in https://arxiv.org/abs/2005.10968INPUT:
pair_a
,pair_b
–ProperPair
objects.pair_a.face()
must containpair_b.face()
as a subtuple.
OUTPUT:
A
dictionary
object whose keys are face, and whose values areProperPair
objects having the same face with its key.
EXAMPLE:
sage: from stdpairs import AffineMonoid, MonomialIdeal, ProperPair, pair_difference sage: Q = AffineMonoid(matrix(ZZ, [[2,0,1],[0,1,1]])) sage: I = MonomialIdeal(matrix(ZZ,0),Q) sage: P= ProperPair(matrix(ZZ,[[0],[0]]), (0,1,2), I ) sage: T= ProperPair(matrix(ZZ,[[0],[2]]), (0,1,2), I ) sage: diff_PT = pair_difference(P,T) sage: diff_PT.keys() dict_keys([(0,)]) sage: sorted(diff_PT[(0,)],key=str) [([[0], [0]]^T,[[2], [0]]), ([[0], [1]]^T,[[2], [0]]), ([[1], [1]]^T,[[2], [0]]), ([[1], [2]]^T,[[2], [0]])]
Find a prime ideal corresponding to a face¶
- stdpairs.prime_ideal(face, affine_monoid)¶
Given a
tuple
objectface
representing face ofaffine_monoid
, return monomial idealother
, return the prime monomial ideal corresponding to the face.OUTPUT:
A
MonomialIdeal
object representing a prime monomial ideal corresponding to theface
.
EXAMPLE:
sage: from stdpairs import AffineMonoid, prime_ideal sage: Q=AffineMonoid(matrix(ZZ,[[1,2],[0,2]])) sage: prime_ideal((0,),Q) An ideal whose generating set is [[2] [2]] sage: prime_ideal((1,),Q) An ideal whose generating set is [[1] [0]]
Division of pairs¶
- stdpairs.div_pairs(pair_a, pair_b)¶
Given two pairs
pair_a
andpair_b
representing \((a,F)\) and \((b,G)\) respectively, this method returns a set of monomials \(c\) such that \(a+c+\mathbb{N}F \subseteq b+\mathbb{N}G\) as a matrix.INPUT:
pair_a
,``pair_b`` –ProperPair
objects.
OUTPUT:
A
sage.matrix.matrix_integer_dense
object whose columns are minimal solutions of \(a+c+\mathbb{N}F \subseteq b+\mathbb{N}G\).
EXAMPLE:
sage: from stdpairs import AffineMonoid, MonomialIdeal, ProperPair, div_pairs sage: A = matrix(ZZ,[[0,1,1,0],[0,0,1,1],[1,1,1,1]]) sage: Q = AffineMonoid(A) sage: I = MonomialIdeal(matrix(ZZ,[[2,2,2],[0,1,2],[2,2,2]]),Q) sage: P = ProperPair(matrix(ZZ,[[1], [1], [1]]), (0,), I) sage: T = ProperPair(matrix(ZZ,[[1], [1], [1]]), (3,), I) sage: div_pairs(P,T) [] sage: TT = ProperPair(matrix(ZZ,[[1], [1], [1]]), (0,3), I) sage: div_pairs(P,TT) [0] [0] [0]
Interface using Macaulay2
¶
Using MonomialSubalgebra class in Macualay2, one can translate MonomialIdeal
object in this package into MonomialSubalgebra object in Macualay2 via methods below.
- stdpairs.from_macaulay2(var_name)¶
Given a
macaulay2
type objectmac2_mon_subalg
which saves the MonomialSubalgebra object, this method returnsAffineMonoid
object corresponding to the MonomialSubalgebra.INPUT:
var_name
– Astring
object which equal to the variable name of a MonomialSubalgebra class variable created byNormaliz
package in Macaulay2.
OUTPUT:
An
AffineMonoid
object.
EXAMPLE:
sage: from stdpairs import from_macaulay2 sage: R = macaulay2.eval('ZZ[x,y,z]') sage: temp=macaulay2.needsPackage('"Normaliz"') sage: temp=macaulay2.eval('S=createMonomialSubalgebra {x^5*y, y*z^2, z^3}') sage: Q = from_macaulay2('S') sage: Q An affine semigroup whose generating set is [[5 0 0] [1 1 0] [0 2 3]]
- stdpairs.to_macaulay2(monomial_ideal, ring_name='R', ideal_name='I', std_cover_name='SC')¶
Given a
MonomialIdeal
objectmonomial_ideal
, this method returns adictionary
object containing the ambient monoid, the given monomial ideal, and its standard cover asstring
objects. Users can access thoseMacaulay2
variables usingring_name
,ideal_name
, andstd_cover_name
. Notes that the ambient monoid and the monomial ideal will be delivered asmacaulay2
type object, especially with MonomialSubalgebra type. See MonomialSubalgebra for detail. The standard cover will be delivered as alist
object in Macaulay 2. Also, this method will executesmonomial_ideal.standard_cover()
if it was not executed previously.INPUT:
monomial_ideal
– AMonomialIdeal
type object.
OUTPUT:
A
dictionary
object as below.
{ 'AffineSemigroupRing':mac2_mon_subalg, 'MonomialIdeal':mac2_mon_sub_alg_ideal, 'StandardCover':mac2_std_cover}
where
mac2_mon_subalg
,mac2_mon_sub_alg_ideal
, andmac2_std_cover
arestring
object.EXAMPLE:
sage: from stdpairs import AffineMonoid,MonomialIdeal, to_macaulay2 sage: Q=AffineMonoid(matrix(ZZ,[[0,1,1,0],[0,0,1,1],[1,1,1,1]])) sage: I=MonomialIdeal(matrix(ZZ,[[2,2,2],[0,1,2],[2,2,2]]),Q) sage: S=to_macaulay2(I) sage: S {'AffineSemigroupRing': ZZ[c, a*c, a*b*c, b*c] <BLANKLINE> monomial subalgebra of PolyRing, 'MonomialIdeal': 2 2 2 2 2 2 2 {a c , a b*c , a b c } <BLANKLINE> List, 'StandardCover': {{1, {c, b*c}}, {a*c, {c, b*c}}, {a*b*c, {c, b*c}}} <BLANKLINE> List} sage: # To access values in dictionary via Macaulay2, sage: mac_ring=macaulay2.eval("R") sage: mac_ideal=macaulay2.eval("I") sage: mac_sc=macaulay2.eval("SC")
Save and load via string
¶
SageMath
provide a global function writing and reading objects as a binary file by pickling. However, it may not work in case Sage code for the package is dramatically changed. To avoid such a catastrophy, we provides some global functions which may save and load your calculation about the monomial ideal objects easily.
- stdpairs.txt_to_affinemonoid(text_info)¶
Given a string
text_info
generated by a methodsave_txt()
of anAffineMonoid
object, this method returns anAffineMonoid
object which is the same as the originalAffineMonoid
object.INPUT:
text_info
– Astring
objct generated by the methodAffineMonoid.save_txt()
.
OUTPUT:
An
AffineMonoid
object.
EXAMPLE:
sage: from stdpairs import AffineMonoid, txt_to_affinemonoid sage: R = AffineMonoid(matrix(ZZ, [[2,0,1],[0,1,1]])) sage: R.save_txt() 'Q\n2,0,1|0,1,1\n' sage: L = txt_to_affinemonoid('Q\n2,0,1|0,1,1\n') sage: R == L True
- stdpairs.txt_to_monomialideal(text_info)¶
Given a string
text_info
generated byMonomialIdeal.save_txt()
method, returns anMonomialIdeal
object which is the same as the originalMonomialIdeal
object.INPUT:
text_info
– Astring
objct generated by the methodMonomialIdeal.save_txt()
.
OUTPUT:
An
MonomialIdeal
object.
EXAMPLE:
sage: from stdpairs import AffineMonoid, MonomialIdeal, txt_to_monomialideal sage: Q = AffineMonoid(matrix(ZZ, [[1,2],[0,2]])) sage: I = MonomialIdeal(matrix(ZZ,[[3],[2]]),Q) sage: I.irreducible_decomposition() [An ideal whose generating set is [[1] [0]], An ideal whose generating set is [[2] [2]]] sage: str_I = I.save_txt() sage: J = txt_to_monomialideal(str_I) sage: J == I True sage: J.standard_cover() {(0,): [([[0], [0]]^T,[[1], [0]])], (1,): [([[0], [0]]^T,[[2], [2]])]} sage: #This does not require re-calculation.