diff --git a/experimental/InjectiveResolutions/src/InjectiveResolutions.jl b/experimental/InjectiveResolutions/src/InjectiveResolutions.jl index cd554bc1fda3..10239b817878 100644 --- a/experimental/InjectiveResolutions/src/InjectiveResolutions.jl +++ b/experimental/InjectiveResolutions/src/InjectiveResolutions.jl @@ -1,11 +1,37 @@ ## Functions visible on the outside -export mod_quotient +export get_monoid_algebra export irreducible_res -export get_all_ass_primes -export quotient_by_ideal - -## Data -export FaceQ +export injective_res + +# export mod_quotient +# export get_all_ass_primes +# export quotient_by_ideal +# export shifted_module +# export compute_shift +# export face_to_prime +# export get_faces_of_polyhedral_cone +# export get_bounding_hyperplanes +# export get_prime_of_face +# export get_polyhedral_cone +# export get_zonotope +# export mod_quotient_2 +# export ZF_basis +# export coefficients_incl +# export mod_saturate +# export irreducible_hull +# export generators_W_H +# export rational_to_integer_vector +# export get_hyperplane_H_presentation + +# # Data +# export FaceQ +# export IrrSum +# export IndecInj +# export IrrSum +# export MonoidAlgebra +# export InjMod +# export HyperplaneQ +# export MonoidAlgebraModule ######################### # some composite types @@ -14,8 +40,12 @@ export FaceQ struct FaceQ # face of semigroup prime::Ideal poly::Polyhedron #face of Q corresponding to prime - A::Matrix{Int64} - b::Vector{Int64} +end + +struct HyperplaneQ # a hyperplane bounding the cone RR_{\geq 0}Q + hyperplane::Polyhedron + A::Matrix{Int} + b::Vector{Int} end struct IrrHull # irreducible hull @@ -42,110 +72,181 @@ struct IrrRes # irreducible resolution (including all computed data and the coch cochainComplex::ComplexOfMorphisms # if sequence not exact return trivial cochain_complex (M0 -> M0) end -##computes system of inequalities for polyhedron {r*a : r >= 0}, a \in ZZ^2 -##INPUT: vector a in ZZ^2 -##OUTPUT: matrix A, vector b such that Ax <= b for all x on hyperplane through a -function compute_inequalities(a::Vector{Int}) - num_variables = length(a) - num_inequalities = 2 * num_variables +struct MonoidAlgebra # monoid algebra with associated data + algebra::Union{MPolyRing, MPolyQuoRing} + cone::Polyhedron + faces::Vector{FaceQ} + hyperplanes::Vector{HyperplaneQ} + # normal::Bool + pointed::Bool #cone pointed + zonotope::Tuple{Polyhedron,Vector{Int}} +end - A = zeros(Int, num_inequalities, num_variables) - b = zeros(Int, num_inequalities) - if !is_zero(a) - A[1,1] = -1 - A[1,2] = 0 - A[2,1] = 0 - A[2,2] = -1 - A[3,1] = a[2] - A[3,2] = -a[1] - A[4,1] = -a[2] - A[4,2] = a[1] - else - A[1,1] = -1 - A[1,2] = 0 - A[2,1] = 0 - A[2,2] = -1 - A[3,1] = 1 - A[3,2] = 0 - A[4,1] = 0 - A[4,2] = 1 - end - return A, b +struct MonoidAlgebraIdeal + monoid_algebra::MonoidAlgebra + ideal::Ideal end -@doc raw" - get_face_to_prime(P_F::Ideal) +struct MonoidAlgebraModule + baseAlgebra::MonoidAlgebra + mod::SubquoModule +end - Given a homogeneous prime ideal, return the corresponding face F +struct InjMod + monoidAlgebra::MonoidAlgebra + indecInjectives::Vector{IndecInj} +end - INPUT: prime ideal p_F - OUTPUT: list [face F, matrix A, vector b] such that F is defined by Ax <= b -" -function get_face_to_prime(P_F::Ideal) - R_Q = base_ring(P_F) - #get generators of k[F] = k[Q]/P_F - Q_F,_ = quo(R_Q,P_F) - G_F = gens(Q_F) - L_F = (P_F,[]) - for g in G_F - if !is_zero(g) - push!(L_F[2], degree(Vector{Int},g)) +struct InjRes + injMods::Vector{InjMod} + cochainMaps::Vector{MatElem} + upto::Int + irrRes::IrrRes + shift::Vector{Int} +end + +# given a graded polynomial ring or a quotient, return the MonoidAlgebra if it is one +# INPUT: MpolyRing or MPolyQuoRing k_Q +# OUTPUT: MonoidAlgebra(...) +function get_monoid_algebra(k_Q::Union{MPolyRing, MPolyQuoRing}) + #check if monoid algebra + @req is_zm_graded(k_Q) "Not ZZ^d-graded." + gg_Q = grading_group(k_Q) + @req is_free(gg_Q) && is_abelian(gg_Q) "Not a monoid algebra." + + # polyhedral cone RR_{\geq 0}Q + C_Q = get_polyhedral_cone(k_Q) + P_Q = polyhedron(C_Q) # C_Q as polyhedron + G_Q,c = get_zonotope(P_Q) + return MonoidAlgebra(k_Q,P_Q,get_faces_of_polyhedral_cone(k_Q,G_Q,P_Q),get_bounding_hyperplanes(P_Q),is_pointed(C_Q),(G_Q,c)) +end + +function ideal(kQ::MonoidAlgebra,gens::Vector{T}) where T <: Union{MPolyRingElem,MPolyQuoRingElem} + if length(gens) == 0 + return MonoidAlgebraIdeal(kQ,ideal(kQ.algebra,elem_type(base_ring(kQ.algebra))[])) + end + for g in gens + kQ.algebra == parent(g) || error("Base rings do not match.") + end + return MonoidAlgebraIdeal(kQ,ideal(kQ.algebra,gens)) +end + +function quotient_ring_as_module(I::MonoidAlgebraIdeal) + return MonoidAlgebraModule(I.monoid_algebra,quotient_ring_as_module(I.ideal)) +end + +# given a face F of a the cone of a monoid algebra, return the prime k{Q\F} +function get_prime_of_face(k_Q::Union{MPolyRing, MPolyQuoRing},G_Q::Polyhedron,F::Polyhedron) + gens_PF = [] + for lp in lattice_points(G_Q) + if dim(intersect(convex_hull(lp),F))== -1 + a_v = Vector{ZZRingElem}() + for a_p in lp + push!(a_v,a_p) + end + push!(gens_PF,monomial_basis(k_Q,a_v)[1]) end end - - #get corresponding face defining it by a system of inequalities - F_poly = [] - m = length(gens(grading_group(R_Q))) - C = convex_hull(zeros(Int, m)) - A = Nothing - b = Nothing - for a in L_F[2] - A,b = compute_inequalities(a) - C_a = polyhedron(A,b) - C = C + C_a - push!(F_poly,[C,A,b]) + return ideal(k_Q,gens_PF) +end + + +# given a QQ^d vector v, this function returns a vector w that lies on the ray through v and the origin +# INPUT: rational d-vector +# OUTPUT: integer d-vector +function rational_to_integer_vector(v::Union{Vector{QQFieldElem},AbstractVector{Rational}}) + denominators = [denominator(x) for x in v] + lcm_denominators = lcm(denominators) + + return [Int(numerator(x*lcm_denominators)) for x in v] +end + +# given a monoid algebra, this function returns the corresponding polyhedral cone +# INPUT: monoid algebra k[Q] +# OUTPUT: polyhedral cone \RR_{\geq 0}Q +function get_polyhedral_cone(R::Union{MPolyDecRing,MPolyQuoRing}) + D = [degree(Vector{Int},g) for g in gens(R)] + return positive_hull(D) +end + +# (works more general for polyhedra) +# given a polyhedral cone, this function returns its faces +# INPUT: polyhedral cone C +# OUTPUT: set of faces of C +function get_faces_of_polyhedral_cone(k_Q:: Union{MPolyRing, MPolyQuoRing}, G_Q::Polyhedron,P::Polyhedron) + P_faces = Vector{Polyhedron}() + for i=0:dim(P) in + append!(P_faces, faces(P,i)) end - if L_F[2] == Any[] - A = zeros(Int, m,m) - b = zeros(Int, m) - push!(F_poly,[C,A,b]) + return [FaceQ(get_prime_of_face(k_Q,G_Q,F),F) for F in P_faces] +end + +# given a polyhedral cone, this function returns the hyperplanes bounding it +# INPUT: polyhedral cone C +# OUTPUT: set of hyperplanes bounding C +function get_bounding_hyperplanes(P::Polyhedron) + hyperplanes = Vector{HyperplaneQ}() + for f in facets(Polyhedron,P) + hyperplane = polyhedron(affine_hull(f)[1]) + A,b = get_hyperplane_H_presentation(hyperplane) + push!(hyperplanes,HyperplaneQ(hyperplane,A,b)) end - return F_poly + return hyperplanes end -##get all prime ideals P_F associated to M -##INPUT: ideal I -##OUTPUT: list of all minimal associated primes + the maximal ideal and the corresponding face F as a polyhedron -function get_all_ass_primes(I) - R_Q = base_ring(I) - I_m = ideal(R_Q,gens(R_Q)) #maximal ideal - F_m = get_face_to_prime(I_m)[1] - P_F = [FaceQ(I_m,F_m[1],F_m[2],F_m[3])] - MP = minimal_primes(I) - for mp in MP - p_f = get_face_to_prime(mp)[1] - push!(P_F,FaceQ(mp,p_f[1],p_f[2],p_f[3])) +# given a polyhedral cone, return the zonotope as in Lemma 3.10 in [HM2004] +# INPUT: polyhedral cone C +# OUTPUT: zonotope, sum of primitive integer vector ong rays of C +function get_zonotope(P::Polyhedron) + d = ambient_dim(P) + P_rays = [rational_to_integer_vector(Vector(r)) for r in rays(P)] + + c = zeros(Int,d) + zonotope = convex_hull(zeros(Int,d)) + for r in P_rays + zonotope = zonotope + convex_hull([zeros(Int,1,d);reshape(r,1,length(r))]) + c = c + r end - return P_F + return zonotope,c end +# given a hyperplane, return the H-presentation of it +# INPUT: hyperplane h +# OUTPUT: matrix A, vector b corresponding to Ax \leq b which defines h +function get_hyperplane_H_presentation(h::Polyhedron) + aff_hull = affine_hull(h).Obj.pm_polytope.AFFINE_HULL + _M = Matrix{Rational}(aff_hull) + M = hcat(map(row -> reshape(rational_to_integer_vector(row),1,:),eachrow(_M))...) + A = [M[:,2:n_columns(M)];-M[:,2:n_columns(M)]] + b = [M[:,1];-M[:1]] + return A,b +end -##Let W = k{Q\(a + F - Q)} and let H be a hyperplane containing F as a subset. -##Calculates generators of k{(a + H_+^°)\cap Q}. -##INPUT: semigroup Q_P as a polyhedron -# zonotope G_Q of Q_P as in Lemma 3.10 -# list of facets Fs of Q_P as polyhedron -# hyperplane h bounding Q as FaceQ -# a \in \ZZ^d -##OUTPUT: finite set B such that (x^b : b \in B) equals k{(a + H_+^°)\cap Q} -function generators_W_H(Q_P::Polyhedron,G::Polyhedron,Fs::Vector{Polyhedron{QQFieldElem}},H::FaceQ,a::Vector{Int}) - F = intersect(H.poly,Q_P) +# given an ideal of R and a ZZ^d-vector a, return the module R/I shifted by a +# INPUT: ideal I, ZZ^d-vector a +# OUTPUT: R/I(-a) the module R/I shifted by a +function shifted_module(I::MonoidAlgebraIdeal,shift::Vector) + S = I.monoid_algebra.algebra + m_shift = monomial_basis(S,shift)[1] + I_shifted = ideal(S,[m_shift])*I.ideal + _M = quotient_ring_as_module(I_shifted) + return MonoidAlgebraModule(I.monoid_algebra, sub(_M,[m_shift*_M[1]])[1]) +end + +# computes the generators of k{(a + H_+^°)\cap Q} +# Algorithm 3.11 in HM2004 +# INPUT: MonoidAlgebra kQ +# HyperplaneQ H that bounding the polyhedral cone RR_{\geq 0}kQ +# vector a in \ZZ^d +# OUTPUT: finite set B such that (x^b : b \in B) equals k{(a + H_+^°)\cap Q} +function generators_W_H(kQ::MonoidAlgebra, H::HyperplaneQ, a::Vector{Int}) + F = intersect(H.hyperplane,kQ.cone) #get faces of Q intersecting F only at 0 in Q D = [] - for f in Fs - if dim(intersect(f,F)) == 0 - push!(D,f) + for f in kQ.faces + if dim(intersect(f.poly,F)) == 0 + push!(D,f.poly) end end @@ -154,7 +255,7 @@ function generators_W_H(Q_P::Polyhedron,G::Polyhedron,Fs::Vector{Polyhedron{QQFi for d in D I = intersect(PaF,d) #(a + RR H)\cap RR_+D if dim(I) >= 0 - push!(B,lattice_points(I + G)) + push!(B,lattice_points(I + kQ.zonotope[1])) end end @@ -179,7 +280,7 @@ end integer i OUTPUT: list of ZZ^d graded degrees of Bass numbers up to cohomological degree i " -function compute_bass_numbers(I,i) +function compute_bass_numbers(I::Ideal,i::Int) R_Q = base_ring(I) I_R = modulus(R_Q) if is_zero(I_R) #R_Q polynomial ring @@ -195,7 +296,7 @@ function compute_bass_numbers(I,i) # module R_Q/I as a subquotient of S^1 M_mod = quotient_ring_as_module(quo(R_Q,I)[1]) - D = [] + D = Vector{Vector{Int}}() for j=0:i in E = Nothing try @@ -205,8 +306,7 @@ function compute_bass_numbers(I,i) E = Nothing end else - G_E = gens(E) - for g in G_E + for g in gens(E) push!(D,degree(Vector{Int},g)) end end @@ -218,7 +318,7 @@ end ##INPUT: list of points in ZZ^d ## polyhedron P_Q ##OUTPUT: true if all points lie in P_Q -function points_in_Q(bass,P_Q) +function points_in_Q(bass::Vector{Vector{Int}},P_Q::Polyhedron) for b in bass if !is_subset(convex_hull(b),P_Q) return false @@ -231,14 +331,12 @@ end ##INPUT: monomial ideal I ## integer i up to which cohomological degree Bass numbers are considered ##OUTPUT: ZZ^d degree of shift -function compute_shift(I,i,c,P_Q) - n_bass = compute_bass_numbers(I,i) +function compute_shift(I::MonoidAlgebraIdeal,i::Int) + n_bass = compute_bass_numbers(I.ideal,i) + c = I.monoid_algebra.zonotope[2] j = 0 - while !points_in_Q(n_bass,P_Q) - bass_ = [] - for a_bass in n_bass - push!(bass_,a_bass+c) - end + while !points_in_Q(n_bass,I.monoid_algebra.cone) + bass_ = [a_bass + c for a_bass in n_bass] n_bass = bass_ j = j +1 end @@ -250,23 +348,17 @@ end # Ideal I #OUTPUT: SubquoModule (0 :_M I) function mod_quotient(M::SubquoModule,I::Ideal) - T = typeof(M[1]) M_I,_ = quotient_by_ideal(I) #base_ring(I)/I as module m = M_I[1] #generator of M_I H = hom(M_I,M) - Q_gens = Vector{T}() - for g in gens(H[1]) - h_g = element_to_homomorphism(g) - b_g = h_g(m) - push!(Q_gens,b_g) - end + Q_gens = [element_to_homomorphism(g)(m) for g in gens(H[1])] return sub(M,Q_gens) end #same as mod_quotient except that the result is generated by non-zero elements function mod_quotient_2(M::SubquoModule,I::Ideal) - T = typeof(M[1]) + T = elem_type(M) M_I,_ = quotient_by_ideal(I) #base_ring(I)/I as module m = M_I[1] #generator of M_I H = hom(M_I,M) @@ -307,7 +399,7 @@ end # prime ideal P_F = k{Q\F} #OUTPUT: k[ZF]-basis of localization (0 :_M P_F)[ZF] function ZF_basis(M::SubquoModule,PF::Ideal) - T = typeof(M[1]) + T = elem_type(M) N = M h_N = identity_map(N) B = Vector{T}() @@ -327,10 +419,12 @@ function ZF_basis(M::SubquoModule,PF::Ideal) end #Compute coefficients as in algorithm 3.5 -#INPUT: SubquoModule M -# SubquoModule Mxy = (0 :_M P_F) -# homomorphism (inclusion) Mxy -> M -# k[ZF]-basis computed as in ZF_basis(_,_) +#INPUT: SubquoModule N +# SubquoModule Mp = (0 :_M P_F) +# homomorphism (inclusion) incl_Np: Mxy -> M +# k[ZF]-basis Bp computed as in ZF_basis(_,_) +# prime ideal pr +#OUTPUT: k[ZF]-basis computed as in ZF_basis(_,_) function coefficients_incl(N::SubquoModule,Np::SubquoModule,incl_Np::SubQuoHom,Bp::Vector,pr::Ideal) R_N = base_ring(N) if is_zero(modulus(R_N)) @@ -338,7 +432,7 @@ function coefficients_incl(N::SubquoModule,Np::SubquoModule,incl_Np::SubQuoHom,B else R_poly = base_ring(R_N) end - T = typeof(zero(R_N)) + T = elem_type(R_N) lambda_out = Vector{Vector{T}}() p_F = ideal_in_poly_ring(pr) i = 1 @@ -389,10 +483,7 @@ function ideal_in_poly_ring(I::Ideal) return I else S = base_ring(R_I) - G = [] - for g in gens(I) - push!(G,monomial_basis(S,degree(g))[1]) - end + G = [monomial_basis(S,degree(g))[1] for g in gens(I)] return ideal(S,G) end end @@ -405,11 +496,7 @@ function quotient_by_ideal(I::Ideal) R_I = base_ring(I) F = graded_free_module(R_I,1) f = F[1] - T = typeof(f) - V = Vector{T}() - for g in gens(I) - push!(V,g*f) - end + V = [g*f for g in gens(I)] return quo(F,V) end @@ -464,24 +551,25 @@ end list of hyperplanes H bounding Q as tuples (polyhedron,A,b) OUTPUT: irreducible resolution of M given by a list of of k[Q]-modules and homomorphisms in between """ -function irreducible_res(M::SubquoModule,P::Vector{FaceQ},P_Q::Polyhedron,G::Polyhedron,F::Vector{Polyhedron{QQFieldElem}},H::Vector{FaceQ}) - Mi = M # current module in resolution +# function irreducible_res(M::SubquoModule,P::Vector{FaceQ},P_Q::Polyhedron,G::Polyhedron,F::Vector{Polyhedron{QQFieldElem}},H::Vector{FaceQ}) +function irreducible_res(M::MonoidAlgebraModule) + kQ = M.baseAlgebra + Mi = M.mod # current module in resolution gi = identity_map(Mi) #initilalize res_Wi = Vector{IrrSum}() res_Mi = [Mi] #cokernels res_hi = Vector{SubQuoHom}() res_fi = Vector{SubQuoHom}() res_gi = [gi] #quotient maps - R_Q = base_ring(M) while !is_zero(Mi) #until cokernel Mi is zero - W_bar = irreducible_hull(Mi,P) + W_bar = irreducible_hull(Mi,kQ.faces) irreducible_ideals = [] #list of irreducible ideals constituting an irreducible hull (sum) for k=1: length(W_bar.faces) B_i = [] - for h in H - if is_subset(W_bar.faces[k].poly,h.poly) - B_h = generators_W_H(P_Q,G,F,h,W_bar.vectors[k][2]) + for h in kQ.hyperplanes + if is_subset(W_bar.faces[k].poly,h.hyperplane) + B_h = generators_W_H(kQ,h,W_bar.vectors[k][2]) push!(B_i,B_h) end end @@ -493,17 +581,17 @@ function irreducible_res(M::SubquoModule,P::Vector{FaceQ},P_Q::Polyhedron,G::Pol for a in bb push!(a_v,a) end - push!(G_W, monomial_basis(R_Q,a_v)[1]) + push!(G_W, monomial_basis(kQ.algebra,a_v)[1]) end end - push!(irreducible_ideals,ideal(R_Q,G_W)) + push!(irreducible_ideals,ideal(kQ.algebra,G_W)) end faces_ = map(p -> p.prime,W_bar.faces) vectors = map(x -> x[2],W_bar.vectors) indec_injectives = map((x,y) -> IndecInj(x,y),faces_,vectors) - irreducible_comp = map(I -> quotient_by_ideal(I)[1],irreducible_ideals) + irreducible_comp = map(I -> quotient_ring_as_module(I),irreducible_ideals) d_sum(x,y) = direct_sum(x,y,task=:none) Wi = foldl(d_sum,irreducible_comp) fi = hom(Mi,Wi,W_bar.lambda) @@ -526,7 +614,7 @@ function irreducible_res(M::SubquoModule,P::Vector{FaceQ},P_Q::Polyhedron,G::Pol push!(res_Mi,Mi) push!(res_gi,gi) end - C = cochain_complex([identity_map(M)]) # default value if sequence not exact + C = cochain_complex([identity_map(M.mod)]) # default value if sequence not exact try C = cochain_complex(res_hi) catch; @@ -534,6 +622,25 @@ function irreducible_res(M::SubquoModule,P::Vector{FaceQ},P_Q::Polyhedron,G::Pol return IrrRes(res_Wi,res_hi,res_gi,res_fi,res_Mi,C) end +# compute a minimal injective resolution up to cohomological degree i +# INPUT: MonoidAlgebraIdeal I +# positive integer i +# OUTPUT: injective resolution of R/I up to cohomological degree I +function injective_res(I::MonoidAlgebraIdeal, i::Int) + kQ = I.monoid_algebra + a_shift = compute_shift(I,i) + irrRes = irreducible_res(shifted_module(I,a_shift)) + inj_modules = Vector{InjMod}() + irr_sums = irrRes.irrSums + for component in irr_sums + shifted_comp = map(indec -> IndecInj(indec.prime,indec.vector - a_shift),component.components) + push!(inj_modules,InjMod(kQ,shifted_comp)) + end + cochain_maps = [matrix(cm) for cm in irrRes.cochainMaps] + cochain_maps[1] = map(a_ij -> kQ.algebra(monomial_basis(kQ.algebra,degree(Vector{Int},a_ij)-a_shift)[1]),cochain_maps[1]) + return InjRes(inj_modules,cochain_maps,i,irrRes,a_shift) +end + ##fix SubquoModule with one or more "zero"-relations function fix_module(M::SubquoModule) R = base_ring(M) @@ -571,3 +678,77 @@ function equal_mod_ZF(a::RingElem,b::RingElem,p_F::Ideal) return false end end + +##computes system of inequalities for polyhedron {r*a : r >= 0}, a \in ZZ^2 +##INPUT: vector a in ZZ^2 +##OUTPUT: matrix A, vector b such that Ax <= b for all x on hyperplane through a +function compute_inequalities(a::Vector{Int}) + num_variables = length(a) + num_inequalities = 2 * num_variables + + A = zeros(Int, num_inequalities, num_variables) + b = zeros(Int, num_inequalities) + if !is_zero(a) + A[1,1] = -1 + A[1,2] = 0 + A[2,1] = 0 + A[2,2] = -1 + A[3,1] = a[2] + A[3,2] = -a[1] + A[4,1] = -a[2] + A[4,2] = a[1] + else + A[1,1] = -1 + A[1,2] = 0 + A[2,1] = 0 + A[2,2] = -1 + A[3,1] = 1 + A[3,2] = 0 + A[4,1] = 0 + A[4,2] = 1 + end + return A, b +end + +@doc raw" + get_face_to_prime(P_F::Ideal) + + Given a homogeneous prime ideal, return the corresponding face F + + INPUT: prime ideal p_F + OUTPUT: list [face F, matrix A, vector b] such that F is defined by Ax <= b +" +function get_face_to_prime(P_F::Ideal) + R_Q = base_ring(P_F) + + #get generators of k[F] = k[Q]/P_F + Q_F,_ = quo(R_Q,P_F) + L_F = [degree(Vector{Int},g) for g in filter(!is_zero, gens(Q_F))] + + #get corresponding face defining it by a system of inequalities + m = length(gens(grading_group(R_Q))) + C = convex_hull(zeros(Int, m)) + + for a in L_F + A,b = compute_inequalities(a) + C_a = polyhedron(A,b) + C = C + C_a + return FaceQ(P_F,C,A,b) + end + + #return trivial A,b if L_F is empty + A = zeros(Int, m,m) + b = zeros(Int, m) + return FaceQ(P_F,C,A,b) +end + +##get all prime ideals P_F associated to M +##INPUT: ideal I +##OUTPUT: list of all minimal associated primes + the maximal ideal and the corresponding face F as a polyhedron +function get_all_ass_primes(I) + R_Q = base_ring(I) + I_m = ideal(R_Q,gens(R_Q)) #maximal ideal + + MP = minimal_primes(I) #only minimal primes... + return [get_face_to_prime(I_m); [get_face_to_prime(mp) for mp in MP]] +end diff --git a/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1.jl b/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1.jl index 638c22ef2d6d..66ea7454349f 100644 --- a/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1.jl +++ b/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1.jl @@ -1,66 +1,36 @@ -#--------------------------------------- -#------------ preliminary definitions - # definition of polynomial ring k[x,y] R_Q,(x,y) = graded_polynomial_ring(QQ,["x","y"];weights = [[1,0],[0,1]]) +# get MonoidAlgebra +kQ = get_monoid_algebra(R_Q) -## faces of Q as polyhedron -# F1 = cone((1,0)) -A1 = [-1 0; 1 0;0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -# F2 = cone((0,1)) -A2 = [-1 0; 0 -1; 0 1] -b2 = [0,0,0] -F2 = polyhedron(A2,b2) - -## hyperplanes bounding Q as polyhedron -A_H1 = [-1 0;1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -A_H2 = [0 -1;0 1] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) # semigroup Q as polyhedron -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] - -### primitive integer vectors along rays of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;1 0]) -G = R1 + R2 # zonotope as im Lemma 3.10. (HM2004) -c = [1,1] # ZZ^d degree of sum R1 + R2 - - -#------------------------------------------------- -#--------- Example 1 (Example 11.3. in MS2005) -#------------------------------------------------- - -I = ideal(R_Q,[x^4,x^2*y^2,y^4]) -M,_ = quotient_by_ideal(I) -P = get_all_ass_primes(I) +# define ideal over monoid algebra +I = ideal(kQ,[x^4,x^2*y^2,y^4]) -#compute an irreducible resolution -res = irreducible_res(M,P,P_Q,G,F,H) +# irreducible resolution of M = kQ/I +M = quotient_ring_as_module(I) +irr_res = irreducible_res(M) -res.irrSums[1].components +# compute injective resolution up to cohomological degree 2 +inj_res = injective_res(I,2) -res.irrSums[2].components +inj_res.injMods[1].indecInjectives +inj_res.injMods[2].indecInjectives +inj_res.injMods[3].indecInjectives -matrix(res.cochainMaps[1]) +inj_res.cochainMaps[1] +inj_res.cochainMaps[2] +inj_res.cochainMaps[3] -matrix(res.cochainMaps[2]) +## irreducible resolution that is the Q-graded part of the minimal injective resolution above (shifted) +irr_res_2 = inj_res.irrRes #check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_surjective(res.inclusions[2]) \ No newline at end of file +length(irr_res_2.irrSums) +image(irr_res_2.cochainMaps[1])[1] == kernel(irr_res_2.cochainMaps[2])[1] +image(irr_res_2.cochainMaps[2])[1] == kernel(irr_res_2.cochainMaps[3])[1] +is_injective(irr_res_2.inclusions[1]) +is_injective(irr_res_2.inclusions[2]) +is_injective(irr_res_2.inclusions[3]) +is_surjective(irr_res_2.inclusions[3]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1_shifted.jl b/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1_shifted.jl deleted file mode 100644 index 49b18758933a..000000000000 --- a/experimental/InjectiveResolutions/src/examples/polynomialRing/poly_ring_1_shifted.jl +++ /dev/null @@ -1,80 +0,0 @@ - -#--------------------------------------- -#------------ preliminary definitions - -# definition of polynomial ring k[x,y] -R_Q,(x,y) = graded_polynomial_ring(QQ,["x","y"];weights = [[1,0],[0,1]]) - - -##### faces of Q as polyhedron -# F1 = cone((1,0)) -A1 = [-1 0; 1 0;0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -# F2 = cone((0,1)) -A2 = [-1 0; 0 -1; 0 1] -b2 = [0,0,0] -F2 = polyhedron(A2,b2) - -##### hyperplanes bounding Q as polyhedron -A_H1 = [-1 0;1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -A_H2 = [0 -1;0 1] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) # semigroup Q as polyhedron -# H = [(H1,A_H1,b_H1),(H2,A_H2,b_H2)] #hyperplanes bounding -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] - -### primitive integer vectors along rays of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;1 0]) -G = R1 + R2 # zonotope as im Lemma 3.10. (HM2004) -c = [1,1] # ZZ^d degree of sum R1 + R2 - - - - -#------------------------------------------------- -#--------- Example 1 shifted by (1,1) -#--------- (Example 11.3. in MS2005) -#------------------------------------------------- - -I = ideal(R_Q,[x^4,x^2*y^2,y^4]) -c = [1,1] -m_c = monomial_basis(R_Q,c)[1] -I_c = ideal(R_Q,[m_c])*I -M_I_c,_ = quotient_by_ideal(I_c) -M_c,_ = sub(M_I_c,[m_c*M_I_c[1]]) -P = get_all_ass_primes(I) - -#compute irreducible resolution -res = irreducible_res(M_c,P,P_Q,G,F,H) - -res.irrSums[1].components - -res.irrSums[2].components - -res.irrSums[3].components - -matrix(res.cochainMaps[1]) - -matrix(res.cochainMaps[2]) - -matrix(res.cochainMaps[3]) - -#check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -image(res.cochainMaps[2])[1] == kernel(res.cochainMaps[3])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_injective(res.inclusions[3]) -is_surjective(res.inclusions[3]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1.jl index 59537fefa9e7..94bc24dd3dab 100644 --- a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1.jl +++ b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1.jl @@ -1,75 +1,51 @@ - -#--------------------------------------- -#------------ preliminary definitions - - -# definition of semigroup ring +# definition of monoid algebra as quotient of polynomial ring S,(x,y,z) = graded_polynomial_ring(QQ,["x","y","z"]; weights = [[0,1],[1,1],[2,1]]) J = ideal(S,[x*z-y^2]) R_Q,phi = quo(S,J) +x,y,z = gens(R_Q) -##define all faces of Q as polyhedron using systems of linear inequalities -#F0 = cone{(0,0)} -A0 = [1 0;-1 0;0 1;0 -1] -b0 = [0,0,0,0] -F0 = polyhedron(A0,b0) - -#F1 = cone{(0,1)} -A1 = [1 0; -1 0; 0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -#F2 = cone{(2,1)} -A2 = [1 -2; -1 2; -1 0; 0 -1] -b2 = [0,0,0,0] -F2 = polyhedron(A2,b2) - -##define hyperplanes bounding Q as polyhedron -#H_1 hyperplane bounding Q (intersects F1 non-trivially) -A_H1 = [1 0;-1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -#H_2 hyperplane bounding Q (intersects F2 non-trivially) -A_H2 = [1 -2; -1 2] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] #hyperplanes bounding Q - -## define zonotope of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;2 1]) -G = R1 + R2 - - +# get MonoidAlgebra +kQ = get_monoid_algebra(R_Q) -#------------------------------------------------- -#--------- Example 1 -#------------------------------------------------- +# define ideal over monoid algebra +I = ideal(kQ,[x^2*z,x^4*y]) -I = ideal(R_Q,[x^2*z,x^4*y]) -M0,_ = quotient_by_ideal(I) -P = get_all_ass_primes(I) +# irreducible resolution of M = kQ/I +M = quotient_ring_as_module(I) +irr_res = irreducible_res(M) -# compute irreducible resolution -res = irreducible_res(M0,P,P_Q,G,F,H) +# minimal injective resolution of kQ/I up to cohomological degree 3 +inj_res = injective_res(I,3) -res.irrSums[1].components +inj_res.injMods[1].indecInjectives +inj_res.injMods[2].indecInjectives +inj_res.injMods[3].indecInjectives +inj_res.injMods[4].indecInjectives +inj_res.injMods[5].indecInjectives +inj_res.injMods[6].indecInjectives -res.irrSums[2].components +inj_res.cochainMaps[1] +inj_res.cochainMaps[2] +inj_res.cochainMaps[3] +inj_res.cochainMaps[4] +inj_res.cochainMaps[5] +inj_res.cochainMaps[6] -matrix(res.cochainMaps[1]) -matrix(res.cochainMaps[2]) +# irreducible resolution that is the Q-graded part of the minimal injective resolution above (shifted) +irr_res_3 = inj_res.irrRes # check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_surjective(res.inclusions[2]) \ No newline at end of file +length(irr_res_3.irrSums) +image(irr_res_3.cochainMaps[1])[1] == kernel(irr_res_3.cochainMaps[2])[1] +image(irr_res_3.cochainMaps[2])[1] == kernel(irr_res_3.cochainMaps[3])[1] +image(irr_res_3.cochainMaps[3])[1] == kernel(irr_res_3.cochainMaps[4])[1] +image(irr_res_3.cochainMaps[4])[1] == kernel(irr_res_3.cochainMaps[5])[1] +image(irr_res_3.cochainMaps[5])[1] == kernel(irr_res_3.cochainMaps[6])[1] +is_injective(irr_res_3.inclusions[1]) +is_injective(irr_res_3.inclusions[2]) +is_injective(irr_res_3.inclusions[3]) +is_injective(irr_res_3.inclusions[4]) +is_injective(irr_res_3.inclusions[5]) +is_injective(irr_res_3.inclusions[6]) +is_surjective(irr_res_3.inclusions[6]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1_shifted.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1_shifted.jl deleted file mode 100644 index 22749183615e..000000000000 --- a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_1_shifted.jl +++ /dev/null @@ -1,127 +0,0 @@ -include("code/functions.jl") - - -################################################# -######## definition of semigroup ring -################################################# - -S,(x,y,z) = graded_polynomial_ring(QQ,["x","y","z"]; weights = [[0,1],[1,1],[2,1]]) -J = ideal(S,[x*z-y^2]) -R_Q,phi = quo(S,J) - -##define all faces of Q as polyhedron using systems of linear inequalities -#F0 = cone{(0,0)} -A0 = [1 0;-1 0;0 1;0 -1] -b0 = [0,0,0,0] -F0 = polyhedron(A0,b0) - -#F1 = cone{(0,1)} -A1 = [1 0; -1 0; 0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -#F2 = cone{(2,1)} -A2 = [1 -2; -1 2; -1 0; 0 -1] -b2 = [0,0,0,0] -F2 = polyhedron(A2,b2) - -##define hyperplanes bounding Q as polyhedron -#H_1 hyperplane bounding Q (intersects F1 non-trivially) -A_H1 = [1 0;-1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -#H_2 hyperplane bounding Q (intersects F2 non-trivially) -A_H2 = [1 -2; -1 2] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] #hyperplanes bounding Q - -## define zonotope of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;2 1]) -G = R1 + R2 - - - -############################################################# -##### Beispiel 1 geshiftet um [3,3] -############################################################# -I = ideal(R_Q,[x^2*z,x^4*y]) - -c = [3,3] -m_c = monomial_basis(R_Q,c)[1] # x*y*z -I_c = ideal(R_Q,[m_c])*I -M0,_ = quotient_by_ideal(I_c) -M0_c,_ = sub(M0,[m_c*M0[1]]) #shifted module -P = get_all_ass_primes(I_c) - -#compute irreducible resolution -res = irreducible_res(M0_c,P,P_Q,G,F,H) - -res.irrSums[1].components -# IndecInj(Ideal (x, y, z), [4, 7]) -# IndecInj(Ideal (z, y), [3, 5]) -# IndecInj(Ideal (y, x), [4, 5]) - - -res.irrSums[2].components -# IndecInj(Ideal (x, y, z), [4, 5]) -# IndecInj(Ideal (x, y, z), [3, 6]) -# IndecInj(Ideal (x, y, z), [2, 6]) -# IndecInj(Ideal (z, y), [2, 1]) -# IndecInj(Ideal (y, x), [0, 1]) - -res.irrSums[3].components -# IndecInj(Ideal (x, y, z), [2, 2]) -# IndecInj(Ideal (x, y, z), [2, 5]) -# IndecInj(Ideal (x, y, z), [1, 5]) - -res.irrSums[4].components -# IndecInj(Ideal (x, y, z), [1, 4]) -# IndecInj(Ideal (x, y, z), [0, 4]) - -res.irrSums[5].components -# IndecInj(Ideal (x, y, z), [0, 3]) - -matrix(res.cochainMaps[1]) -# [x*y*z x*y*z x*y*z] - -matrix(res.cochainMaps[2]) -# [ 1 1 1 0 0] -# [ 0 -1 0 1 0] -# [-1 0 0 0 1] - -matrix(res.cochainMaps[3]) -# [ 1 0 0] -# [ 0 1 1] -# [-1 -1 -1] -# [ 0 1 1] -# [ 1 0 0] - -matrix(res.cochainMaps[4]) -# [ 0 0] -# [-1 -1] -# [ 1 1] - -matrix(res.cochainMaps[5]) -# [-1] -# [ 1] - -# check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -image(res.cochainMaps[2])[1] == kernel(res.cochainMaps[3])[1] -image(res.cochainMaps[3])[1] == kernel(res.cochainMaps[4])[1] -image(res.cochainMaps[4])[1] == kernel(res.cochainMaps[5])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_injective(res.inclusions[3]) -is_injective(res.inclusions[4]) -is_injective(res.inclusions[5]) -is_surjective(res.inclusions[5]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_2.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_2.jl new file mode 100644 index 000000000000..d411af1a19e6 --- /dev/null +++ b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_2.jl @@ -0,0 +1,54 @@ +# definition of monoid algebra as quotient of polynomial ring +S, (x, y, z) = graded_polynomial_ring(QQ, ["x", "y", "z"]; weights=[[0, 1], [1, 1], [2, 1]]) +J = ideal(S, [x * z - y^2]) +R_Q, phi = quo(S, J) +x, y, z = gens(R_Q) + +# get MonoidAlgebra +kQ = get_monoid_algebra(R_Q) + +# define ideal over monoid algebra +I = ideal(kQ, [y^3, x^3 * z]) + +# compute irreducible resolution of M = kQ/I +M = quotient_ring_as_module(I) +irr_res = irreducible_res(M) + +# compute injective resolution up to cohomological degree 3 +inj_res = injective_res(I, 3) + +inj_res.injMods[1].indecInjectives +inj_res.injMods[2].indecInjectives +inj_res.injMods[3].indecInjectives +inj_res.injMods[4].indecInjectives +inj_res.injMods[5].indecInjectives +inj_res.injMods[6].indecInjectives +inj_res.injMods[7].indecInjectives + +inj_res.cochainMaps[1] +inj_res.cochainMaps[2] +inj_res.cochainMaps[3] +inj_res.cochainMaps[4] +inj_res.cochainMaps[5] +inj_res.cochainMaps[6] +inj_res.cochainMaps[7] + +# irreducible resolution that is the Q-graded part of the minimal injective resolution above +irr_res_3 = inj_res.irrRes + +# check if irreducible resolution +length(irr_res_3.irrSums) +image(irr_res_3.cochainMaps[1])[1] == kernel(irr_res_3.cochainMaps[2])[1] +image(irr_res_3.cochainMaps[2])[1] == kernel(irr_res_3.cochainMaps[3])[1] +image(irr_res_3.cochainMaps[3])[1] == kernel(irr_res_3.cochainMaps[4])[1] +image(irr_res_3.cochainMaps[4])[1] == kernel(irr_res_3.cochainMaps[5])[1] +image(irr_res_3.cochainMaps[5])[1] == kernel(irr_res_3.cochainMaps[6])[1] +image(irr_res_3.cochainMaps[6])[1] == kernel(irr_res_3.cochainMaps[7])[1] +is_injective(irr_res_3.inclusions[1]) +is_injective(irr_res_3.inclusions[2]) +is_injective(irr_res_3.inclusions[3]) +is_injective(irr_res_3.inclusions[4]) +is_injective(irr_res_3.inclusions[5]) +is_injective(irr_res_3.inclusions[6]) +is_injective(irr_res_3.inclusions[7]) +is_surjective(irr_res_3.inclusions[7]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3.jl index bc36ea543778..fbc525b6fc36 100644 --- a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3.jl +++ b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3.jl @@ -1,80 +1,38 @@ -#--------------------------------------- -#------------ preliminary definitions - - -# definition of semigroup ring +# definition of monoid algebra as quotient of polynomial ring S,(x,y,z) = graded_polynomial_ring(QQ,["x","y","z"]; weights = [[0,1],[1,1],[2,1]]) J = ideal(S,[x*z-y^2]) R_Q,phi = quo(S,J) +x,y,z = gens(R_Q) -##define all faces of Q as polyhedron using systems of linear inequalities -#F0 = cone{(0,0)} -A0 = [1 0;-1 0;0 1;0 -1] -b0 = [0,0,0,0] -F0 = polyhedron(A0,b0) - -#F1 = cone{(0,1)} -A1 = [1 0; -1 0; 0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -#F2 = cone{(2,1)} -A2 = [1 -2; -1 2; -1 0; 0 -1] -b2 = [0,0,0,0] -F2 = polyhedron(A2,b2) - -##define hyperplanes bounding Q as polyhedron -#H_1 hyperplane bounding Q (intersects F1 non-trivially) -A_H1 = [1 0;-1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -#H_2 hyperplane bounding Q (intersects F2 non-trivially) -A_H2 = [1 -2; -1 2] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] #hyperplanes bounding Q - -## define zonotope of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;2 1]) -G = R1 + R2 - - - -#------------------------------------------------- -#--------- Example 3 -#------------------------------------------------- - -I = ideal(R_Q,[y^3,x^3*z]) -M0,_ = quotient_by_ideal(I) -P = get_all_ass_primes(I) - -#compute irreducible resolution -res = irreducible_res(M0,P,P_Q,G,F,H) +# get MonoidAlgebra +kQ = get_monoid_algebra(R_Q) -res.irrSums[1].components +# define ideal over monoid algebra +I_Q = ideal(kQ,[x^2*z]) -res.irrSums[2].components +# compute irreducible resolution of M_Q = kQ/I_Q +M_Q = quotient_ring_as_module(I_Q) +irr_res = irreducible_res(M_Q) -res.irrSums[3].components +# compute injective resolution of kQ/I_Q up to cohomological degree 3 +inj_res = injective_res(I_Q,3) -matrix(res.cochainMaps[1]) +inj_res.injMods[1].indecInjectives +inj_res.injMods[2].indecInjectives +inj_res.injMods[3].indecInjectives -matrix(res.cochainMaps[2]) +inj_res.cochainMaps[1] +inj_res.cochainMaps[2] +inj_res.cochainMaps[3] -matrix(res.cochainMaps[3]) +# get irreducible resolution that is the Q-graded part of the minimal injective resolution above (shifted) +irr_res_3 = inj_res.irrRes # check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -image(res.cochainMaps[2])[1] == kernel(res.cochainMaps[3])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_injective(res.inclusions[3]) -is_surjective(res.inclusions[3]) \ No newline at end of file +length(irr_res_3.irrSums) +image(irr_res_3.cochainMaps[1])[1] == kernel(irr_res_3.cochainMaps[2])[1] +image(irr_res_3.cochainMaps[2])[1] == kernel(irr_res_3.cochainMaps[3])[1] +is_injective(irr_res_3.inclusions[1]) +is_injective(irr_res_3.inclusions[2]) +is_injective(irr_res_3.inclusions[3]) +is_surjective(irr_res_3.inclusions[3]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3_shifted.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3_shifted.jl deleted file mode 100644 index b6470e7af09b..000000000000 --- a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_3_shifted.jl +++ /dev/null @@ -1,103 +0,0 @@ - -#--------------------------------------- -#------------ preliminary definitions - - -# definition of semigroup ring -S,(x,y,z) = graded_polynomial_ring(QQ,["x","y","z"]; weights = [[0,1],[1,1],[2,1]]) -J = ideal(S,[x*z-y^2]) -R_Q,phi = quo(S,J) - -##define all faces of Q as polyhedron using systems of linear inequalities -#F0 = cone{(0,0)} -A0 = [1 0;-1 0;0 1;0 -1] -b0 = [0,0,0,0] -F0 = polyhedron(A0,b0) - -#F1 = cone{(0,1)} -A1 = [1 0; -1 0; 0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -#F2 = cone{(2,1)} -A2 = [1 -2; -1 2; -1 0; 0 -1] -b2 = [0,0,0,0] -F2 = polyhedron(A2,b2) - -##define hyperplanes bounding Q as polyhedron -#H_1 hyperplane bounding Q (intersects F1 non-trivially) -A_H1 = [1 0;-1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -#H_2 hyperplane bounding Q (intersects F2 non-trivially) -A_H2 = [1 -2; -1 2] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] #hyperplanes bounding Q - -## define zonotope of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;2 1]) -G = R1 + R2 - - -#------------------------------------------------- -#--------- Example 3 shifted by (3,3) -#------------------------------------------------- - -I = ideal(R_Q,[y^3,x^3*z]) -compute_bass_numbers(I,3) -c = [3,3] -m_c = monomial_basis(R_Q,c)[1] # x*y*z -I_c = ideal(R_Q,[m_c])*I # ideal(x*y^4*z, x^4*y*z^2) -M0,_ = quotient_by_ideal(I_c) -M0_c,_ = sub(M0,[m_c*M0[1]]) -P = get_all_ass_primes(I_c) - -#compute irreducible resolution -res = irreducible_res(M0_c,P,P_Q,G,F,H) - -res.irrSums[1].components - -res.irrSums[2].components - -res.irrSums[3].components - -res.irrSums[4].components - -res.irrSums[5].components - -res.irrSums[6].components - -matrix(res.cochainMaps[1]) - -matrix(res.cochainMaps[2]) - -matrix(res.cochainMaps[3]) - -matrix(res.cochainMaps[4]) - -matrix(res.cochainMaps[5]) - -matrix(res.cochainMaps[6]) - -# check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -image(res.cochainMaps[2])[1] == kernel(res.cochainMaps[3])[1] -image(res.cochainMaps[3])[1] == kernel(res.cochainMaps[4])[1] -image(res.cochainMaps[4])[1] == kernel(res.cochainMaps[5])[1] -image(res.cochainMaps[5])[1] == kernel(res.cochainMaps[6])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_injective(res.inclusions[3]) -is_injective(res.inclusions[4]) -is_injective(res.inclusions[5]) -is_injective(res.inclusions[6]) -is_surjective(res.inclusions[6]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_4.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_4.jl index a560c8e28090..5f01121b448a 100644 --- a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_4.jl +++ b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_4.jl @@ -1,83 +1,54 @@ -#--------------------------------------- -#------------ preliminary definitions - - -# definition of semigroup ring -S,(x,y,z) = graded_polynomial_ring(QQ,["x","y","z"]; weights = [[0,1],[1,1],[2,1]]) -J = ideal(S,[x*z-y^2]) -R_Q,phi = quo(S,J) - -##define all faces of Q as polyhedron using systems of linear inequalities -#F0 = cone{(0,0)} -A0 = [1 0;-1 0;0 1;0 -1] -b0 = [0,0,0,0] -F0 = polyhedron(A0,b0) - -#F1 = cone{(0,1)} -A1 = [1 0; -1 0; 0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -#F2 = cone{(2,1)} -A2 = [1 -2; -1 2; -1 0; 0 -1] -b2 = [0,0,0,0] -F2 = polyhedron(A2,b2) - -##define hyperplanes bounding Q as polyhedron -#H_1 hyperplane bounding Q (intersects F1 non-trivially) -A_H1 = [1 0;-1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -#H_2 hyperplane bounding Q (intersects F2 non-trivially) -A_H2 = [1 -2; -1 2] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] #hyperplanes bounding Q - -## define zonotope of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;2 1]) -G = R1 + R2 - - -#------------------------------------------------- -#--------- Example 4 -#------------------------------------------------- -I = ideal(R_Q,[x^2*z]) -compute_bass_numbers(I,4) -c = [3,3] -P = get_all_ass_primes(I) -m_c = monomial_basis(R_Q,c)[1] -Ic = ideal(R_Q,[m_c])*I -M0,_ = quotient_by_ideal(Ic) -M0c,_ = sub(M0,[m_c*M0[1]]) - -#compute irreducible resolution -res = irreducible_res(M0c,P,P_Q,G,F,H) - -res.irrSums[1].components - -res.irrSums[2].components - -res.irrSums[3].components - -matrix(res.cochainMaps[1]) - -matrix(res.cochainMaps[2]) - -matrix(res.cochainMaps[3]) +# definition of monoid algebra as quotient of polynomial ring +S, (x, y, z) = graded_polynomial_ring(QQ, ["x", "y", "z"]; weights=[[0, 1], [1, 1], [2, 1]]) +J = ideal(S, [x * z - y^2]) +R_Q, phi = quo(S, J) +x, y, z = gens(R_Q) + +# get MonoidAlgebra +kQ = get_monoid_algebra(R_Q) + +# define ideal over monoid algebra +I = ideal(kQ,[z^2, z*y, x^4]) + +# irreducible resolution of M = R/I +M = quotient_ring_as_module(I) +irr_res = irreducible_res(M) + +# injective resolution of M up to cohomological degree 3 +inj_res = injective_res(I,3) + +inj_res.injMods[1].indecInjectives +inj_res.injMods[2].indecInjectives +inj_res.injMods[3].indecInjectives +inj_res.injMods[4].indecInjectives +inj_res.injMods[5].indecInjectives +inj_res.injMods[6].indecInjectives +inj_res.injMods[7].indecInjectives + +inj_res.cochainMaps[1] +inj_res.cochainMaps[2] +inj_res.cochainMaps[3] +inj_res.cochainMaps[4] +inj_res.cochainMaps[5] +inj_res.cochainMaps[6] +inj_res.cochainMaps[7] + +# irreducible resolution that is the Q-graded part of the minima injective resolution above (shifted) +irr_res_3 = inj_res.irrRes # check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -image(res.cochainMaps[2])[1] == kernel(res.cochainMaps[3])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_injective(res.inclusions[3]) -is_surjective(res.inclusions[3]) \ No newline at end of file +length(irr_res_3.irrSums) +image(irr_res_3.cochainMaps[1])[1] == kernel(irr_res_3.cochainMaps[2])[1] +image(irr_res_3.cochainMaps[2])[1] == kernel(irr_res_3.cochainMaps[3])[1] #false +image(irr_res_3.cochainMaps[3])[1] == kernel(irr_res_3.cochainMaps[4])[1] +image(irr_res_3.cochainMaps[4])[1] == kernel(irr_res_3.cochainMaps[5])[1] +image(irr_res_3.cochainMaps[5])[1] == kernel(irr_res_3.cochainMaps[6])[1] +image(irr_res_3.cochainMaps[6])[1] == kernel(irr_res_3.cochainMaps[7])[1] +is_injective(irr_res_3.inclusions[1]) +is_injective(irr_res_3.inclusions[2]) +is_injective(irr_res_3.inclusions[3]) #false +is_injective(irr_res_3.inclusions[4]) +is_injective(irr_res_3.inclusions[5]) +is_injective(irr_res_3.inclusions[6]) +is_injective(irr_res_3.inclusions[7]) +is_surjective(irr_res_3.inclusions[7]) \ No newline at end of file diff --git a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_5.jl b/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_5.jl deleted file mode 100644 index 480fea698d3e..000000000000 --- a/experimental/InjectiveResolutions/src/examples/semigroupRing/semi_group_5.jl +++ /dev/null @@ -1,111 +0,0 @@ -#--------------------------------------- -#------------ preliminary definitions - - -# definition of semigroup ring -S,(x,y,z) = graded_polynomial_ring(QQ,["x","y","z"]; weights = [[0,1],[1,1],[2,1]]) -J = ideal(S,[x*z-y^2]) -R_Q,phi = quo(S,J) - -##define all faces of Q as polyhedron using systems of linear inequalities -#F0 = cone{(0,0)} -A0 = [1 0;-1 0;0 1;0 -1] -b0 = [0,0,0,0] -F0 = polyhedron(A0,b0) - -#F1 = cone{(0,1)} -A1 = [1 0; -1 0; 0 -1] -b1 = [0,0,0] -F1 = polyhedron(A1,b1) - -#F2 = cone{(2,1)} -A2 = [1 -2; -1 2; -1 0; 0 -1] -b2 = [0,0,0,0] -F2 = polyhedron(A2,b2) - -##define hyperplanes bounding Q as polyhedron -#H_1 hyperplane bounding Q (intersects F1 non-trivially) -A_H1 = [1 0;-1 0] -b_H1 = [0,0] -H1 = polyhedron(A_H1,b_H1) - -#H_2 hyperplane bounding Q (intersects F2 non-trivially) -A_H2 = [1 -2; -1 2] -b_H2 = [0,0] -H2 = polyhedron(A_H2,b_H2) - -F = [F1,F2] #faces bounding Q (facets) -P_Q = convex_hull(F1,F2) -h1 = FaceQ(ideal(R_Q,[zero(R_Q)]),H1,A_H1,b_H1) -h2 = FaceQ(ideal(R_Q,[zero(R_Q)]),H2,A_H2,b_H2) -H = [h1,h2] #hyperplanes bounding Q - -## define zonotope of Q -R1 = convex_hull([0 0;0 1]) -R2 = convex_hull([0 0;2 1]) -G = R1 + R2 - - - -#------------------------------------------------- -#--------- Example 4 -#------------------------------------------------- - -I = ideal(R_Q,[z^2,z*y,x^4]) -m_c = monomial_basis(R_Q,[1,1])[1] -I_c = ideal(R_Q,[m_c])*I #ideal(y*z^2, y^2*z, x^4*y) -M0,_ = quotient_by_ideal(I_c) -M0_c,_ = sub(M0,[m_c*M0[1]]) -P = get_all_ass_primes(I_c) - - -#compute irreducible resolution -res = irreducible_res(M0_c,P,P_Q,G,F,H) - -res.irrSums[1].components -# IndecInj(ideal(x, y, z), [3, 5]) -# IndecInj(ideal(x, y, z), [2, 5]) - -res.irrSums[2].components -# IndecInj(ideal(x, y, z), [2, 1]) -# IndecInj(ideal(x, y, z), [2, 4]) -# IndecInj(ideal(x, y, z), [1, 4]) -# IndecInj(ideal(x, y, z), [0, 4]) - -res.irrSums[3].components -# IndecInj(Ideal (x, y, z), [0, 0]) -# IndecInj(Ideal (x, y, z), [1, 3]) -# IndecInj(Ideal (x, y, z), [0, 3]) - -res.irrSums[4].components -# IndecInj(ideal(x, y, z), [0, 2]) - -matrix(res.cochainMaps[1]) -# [y y] - -matrix(res.cochainMaps[2]) -# [0 1 1 0] -# [0 -1 -1 1] - -matrix(res.cochainMaps[3]) -# [1 0 0] -# [0 1 1] -# [0 -1 -1] -# [0 0 0] - -matrix(res.cochainMaps[4]) -# [ 0] -# [ 1] -# [-1] - - -# check if irreducible resolution -length(res.irrSums) -image(res.cochainMaps[1])[1] == kernel(res.cochainMaps[2])[1] -image(res.cochainMaps[2])[1] == kernel(res.cochainMaps[3])[1] -image(res.cochainMaps[3])[1] == kernel(res.cochainMaps[4])[1] -is_injective(res.inclusions[1]) -is_injective(res.inclusions[2]) -is_injective(res.inclusions[3]) -is_injective(res.inclusions[4]) -is_surjective(res.inclusions[4]) \ No newline at end of file