From b77284d436d51ca790182370bb6131b185c0b436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 12:09:50 +0200 Subject: [PATCH 01/23] Add `hash(::GAPGroupHomomorphism)` --- src/Groups/homomorphisms.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Groups/homomorphisms.jl b/src/Groups/homomorphisms.jl index 023311cd5702..7c5d77bc21a7 100644 --- a/src/Groups/homomorphisms.jl +++ b/src/Groups/homomorphisms.jl @@ -6,7 +6,12 @@ function Base.show(io::IO, x::GAPGroupHomomorphism) end function ==(f::GAPGroupHomomorphism{S,T}, g::GAPGroupHomomorphism{S,T}) where S where T - return f.map == g.map + return f.map == g.map +end + +function Base.hash(f::GAPGroupHomomorphism{S,T}, h::UInt) where S where T + b = 0xdc777737af4c0c7b % UInt + return xor(hash(f.map, hash((S, T), h)), b) end Base.:*(f::GAPGroupHomomorphism{S, T}, g::GAPGroupHomomorphism{T, U}) where S where T where U = compose(f, g) From 454a0e3bb2dbdd1dbd568b3e31ca4ee12a0bb97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 12:10:10 +0200 Subject: [PATCH 02/23] Add `hash(::FreeMod_dec)` --- src/Modules/ModulesGraded.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Modules/ModulesGraded.jl b/src/Modules/ModulesGraded.jl index 37e39288d283..5e95e0c948f3 100644 --- a/src/Modules/ModulesGraded.jl +++ b/src/Modules/ModulesGraded.jl @@ -1644,6 +1644,11 @@ function Base.:(==)(F::FreeMod_dec, G::FreeMod_dec) return forget_decoration(F) == forget_decoration(G) && F.d == G.d end +function Base.hash(F::FreeMod_dec, h::UInt) + b = 0x13d6e1b453cb661a % UInt + return xor(hash(forget_decoration(F), hash(F.d, h)), b) +end + ############################################################################### # FreeModElem_dec constructors ############################################################################### From 0f1130e95e0d78dd20c080e413dcc3d4f7059d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 12:10:23 +0200 Subject: [PATCH 03/23] Add `hash(::PBWAlgIdeal)` --- src/Rings/PBWAlgebra.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Rings/PBWAlgebra.jl b/src/Rings/PBWAlgebra.jl index 582905791c97..dd608c50ff5e 100644 --- a/src/Rings/PBWAlgebra.jl +++ b/src/Rings/PBWAlgebra.jl @@ -1078,6 +1078,10 @@ function Base.:(==)(a::PBWAlgIdeal{D, T, S}, b::PBWAlgIdeal{D, T, S}) where {D, return is_subset(a, b) && is_subset(b, a) end +function Base.hash(a::PBWAlgIdeal{D, T, S}, h::UInt) where {D, T, S} + b = 0x91c65dda1eed350f % UInt + return xor(hash(base_ring(a), hash(D, h)), b) +end #### elimination From ade3c66b8376d47d9987eba579b25d096da274f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 12:10:36 +0200 Subject: [PATCH 04/23] Add `hash(::ModuleFPHom)` --- src/Modules/UngradedModules.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Modules/UngradedModules.jl b/src/Modules/UngradedModules.jl index 5a72d30df850..c10c4ae75c20 100644 --- a/src/Modules/UngradedModules.jl +++ b/src/Modules/UngradedModules.jl @@ -4820,6 +4820,15 @@ function (==)(f::ModuleFPHom, g::ModuleFPHom) end return true end + +function Base.hash(f::ModuleFPHom, h::UInt) + b = 0x535bbdbb2bc54b46 % UInt + h = hash(typeof(f), h) + h = hash(domain(f), h) + h = hash(codomain(f), h) + return xor(h, b) +end + ################################################################### @doc raw""" From 3250427fb873c68c70a103aea7b99aa75b637f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 12:20:54 +0200 Subject: [PATCH 05/23] Add `hash` for `(Affine/Linear)(Halfspace/Hyperplane) --- src/PolyhedralGeometry/iterators.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PolyhedralGeometry/iterators.jl b/src/PolyhedralGeometry/iterators.jl index 2b10980ae026..49594be96d73 100644 --- a/src/PolyhedralGeometry/iterators.jl +++ b/src/PolyhedralGeometry/iterators.jl @@ -188,6 +188,12 @@ Base.:(==)(x::AffineHyperplane, y::AffineHyperplane) = x.a == y.a && x.b == y.b Base.:(==)(x::LinearHyperplane, y::LinearHyperplane) = x.a == y.a +Base.hash(x::T, h::UInt) where {T<:Union{AffineHalfspace,AffineHyperplane}} = + hash((x.a, x.b), hash(T, h)) + +Base.hash(x::T, h::UInt) where {T<:Union{LinearHalfspace,LinearHyperplane}} = + hash(x.a, hash(T, h)) + ################################################################################ for T in [LinearHalfspace, LinearHyperplane] From 25577af44e16f8a383675cf918427206e9b7c01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 12:30:32 +0200 Subject: [PATCH 06/23] Add `hash(::SesquilinearForm)` --- src/Groups/matrices/forms.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Groups/matrices/forms.jl b/src/Groups/matrices/forms.jl index cbcfa36bd59c..340b8479f4cf 100644 --- a/src/Groups/matrices/forms.jl +++ b/src/Groups/matrices/forms.jl @@ -176,7 +176,14 @@ end ######################################################################## #TODO: checking whether two quadratic forms coincide by checking their polynomials is not possible yet. -==(B::SesquilinearForm, C::SesquilinearForm) = gram_matrix(B)==gram_matrix(C) && B.descr==C.descr +==(B::SesquilinearForm, C::SesquilinearForm) = B.descr == C.descr && gram_matrix(B) == gram_matrix(C) + +function Base.hash(f::SesquilinearForm, h::UInt) + b = 0xf64440baac005f8c % UInt + h = hash(f.descr, h) + h = hash(gram_matrix(f), h) + return xor(h, b) +end function base_ring(B::SesquilinearForm) if isdefined(B,:matrix) return base_ring(gram_matrix(B)) From 5e9b5f3ee0a0cfc190116b7b916997fea4827478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 14:45:16 +0200 Subject: [PATCH 07/23] Add `hash(::AbsMPolyMultSet)` --- src/Rings/mpoly-localizations.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Rings/mpoly-localizations.jl b/src/Rings/mpoly-localizations.jl index 6ea2a14dbc3a..ff32268c84e6 100644 --- a/src/Rings/mpoly-localizations.jl +++ b/src/Rings/mpoly-localizations.jl @@ -674,6 +674,13 @@ function ==(T::AbsMPolyMultSet, U::AbsMPolyMultSet) return (issubset(T, U) && issubset(U, T)) end +function Base.hash(T::AbsMPolyMultSet, h::UInt) + b = 0x7ce51a28c47ec5e1 % UInt + h = hash(typeof(T), h) + h = hash(ambient_ring(T), h) + return xor(h, b) +end + function issubset( T::MPolyComplementOfPrimeIdeal{BRT, BRET, RT, RET}, U::MPolyComplementOfPrimeIdeal{BRT, BRET, RT, RET} From 04678828ce360f5ae78d5a3e7231c048136f1165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 15:14:46 +0200 Subject: [PATCH 08/23] Add `hash(::CohomologyClass)` --- .../ToricVarieties/CohomologyClasses/constructors.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl index 8cbe1ebab9a0..e18227767eac 100644 --- a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl @@ -145,11 +145,16 @@ Base.:^(cc::CohomologyClass, p::T) where {T <: IntegerUnion} = CohomologyClass(t ######################## -# 5: Equality +# 5: Equality and hash ######################## Base.:(==)(cc1::CohomologyClass, cc2::CohomologyClass) = toric_variety(cc1) === toric_variety(cc2) && iszero(polynomial(cc1-cc2)) +function Base.hash(cc::CohomologyClass, h::UInt) + b = 0x4de32042e67d89c8 % UInt + h = hash(toric_variety(cc), h) + return xor(h, b) +end ###################### # 6: Display From 53962f389ca3944248e39a2d4388b1f247cd27ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 15:17:53 +0200 Subject: [PATCH 09/23] Add `hash(::ElementOfGSet)` --- src/Groups/gsets.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Groups/gsets.jl b/src/Groups/gsets.jl index 9b0d5d312d8c..cf67f3ea80fb 100644 --- a/src/Groups/gsets.jl +++ b/src/Groups/gsets.jl @@ -213,7 +213,15 @@ function ^(omega::ElementOfGSet, g::T) where {T<:AbstractAlgebra.GroupElem} return ElementOfGSet(Omega, fun(omega.obj, g)) end -==(omega1::ElementOfGSet, omega2::ElementOfGSet) = ((omega1.gset == omega2.gset) && (omega1.obj == omega2.obj)) +==(omega1::ElementOfGSet, omega2::ElementOfGSet) = + ((omega1.gset == omega2.gset) && (omega1.obj == omega2.obj)) + +function Base.hash(omega::ElementOfGSet, h::UInt) + b = 0x4dd1b3e65edeab89 % UInt + h = hash(omega.gset, h) + h = hash(omega.obj, h) + return xor(h, b) +end Base.in(omega::ElementOfGSet, Omega::GSet) = Base.in(omega.obj, Omega) From 252984c5f2bc24ece5d642f0c823862204420958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 15:28:39 +0200 Subject: [PATCH 10/23] Add `hash(::MPolyLocalizedRingHom)` --- src/Rings/mpoly-localizations.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Rings/mpoly-localizations.jl b/src/Rings/mpoly-localizations.jl index ff32268c84e6..df7d14c00eac 100644 --- a/src/Rings/mpoly-localizations.jl +++ b/src/Rings/mpoly-localizations.jl @@ -2897,6 +2897,13 @@ function ==(f::MPolyLocalizedRingHom, g::MPolyLocalizedRingHom) return true end +function Base.hash(f::MPolyLocalizedRingHom, h::UInt) + b = 0xe29cdc1ecb68b7a0 % UInt + h = hash(domain(f), h) + h = hash(codomain(f), h) + return xor(h, b) +end + function divides(a::MPolyLocRingElem, b::MPolyLocRingElem) W = parent(a) W == parent(b) || error("elements do not belong to the same ring") From be883d1be08a8cb1568a5404a18f1f4dd01d49ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 15:29:51 +0200 Subject: [PATCH 11/23] Add `hash(::MPolyQuoLocalizedRingHom)` --- src/Rings/mpolyquo-localizations.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index ea79419c7902..3e6279cab6ba 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -1079,6 +1079,13 @@ function ==(f::MPolyQuoLocalizedRingHom, g::MPolyQuoLocalizedRingHom) return true end +function Base.hash(f::MPolyQuoLocalizedRingHom, h::UInt) + b = 0xd6d389598ad28724 % UInt + h = hash(domain(f), h) + h = hash(codomain(f), h) + return xor(h, b) +end + ### printing function Base.show(io::IO, ::MIME"text/plain", phi::MPolyQuoLocalizedRingHom) R = base_ring(domain(phi)) From f007f4a020e9619d67d90daca988e8b5ad87de31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 15:34:06 +0200 Subject: [PATCH 12/23] Add `hash(::RationalEquivalenceClass)` --- .../ToricVarieties/AlgebraicCycles/constructors.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl index 2a55909d1682..bd19a82e878d 100644 --- a/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl @@ -267,13 +267,19 @@ end #################################################### -# 6: Equality +# 6: Equality and hash #################################################### function Base.:(==)(ac1::RationalEquivalenceClass, ac2::RationalEquivalenceClass) return toric_variety(ac1) === toric_variety(ac2) && iszero(polynomial(ac1-ac2)) end +function Base.hash(ac::RationalEquivalenceClass, h::UInt) + b = 0xb5d4ac6b9084eb6e % UInt + h = hash(toric_variety(ac), h) + return xor(h, b) +end + #################################################### # 7: Display From 8caa177a08e816396894b39350d39943affc62dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:57:16 +0200 Subject: [PATCH 13/23] Enhance `hash(::FreeMod)` and `hash(::AbstractFreeModElem)` --- src/Modules/UngradedModules.jl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Modules/UngradedModules.jl b/src/Modules/UngradedModules.jl index c10c4ae75c20..965ba910b1b3 100644 --- a/src/Modules/UngradedModules.jl +++ b/src/Modules/UngradedModules.jl @@ -181,8 +181,12 @@ function (==)(F::FreeMod, G::FreeMod) end function hash(F::FreeMod, h::UInt) - is_graded(F) && return hash((base_ring(F), rank(F), F.S, F.d), h) - return hash((base_ring(F), rank(F), F.S), h) + b = is_graded(F) ? (0x2d55d561d3f7e215 % UInt) : (0x62ca4181ff3a12f4 % UInt) + h = hash(base_ring(F), h) + h = hash(rank(F), h) + h = hash(F.S, h) + is_graded(F) && (h = hash(F.d, h)) + return xor(h, b) end @doc raw""" @@ -490,7 +494,11 @@ function (==)(a::AbstractFreeModElem, b::AbstractFreeModElem) end function hash(a::AbstractFreeModElem, h::UInt) - return xor(hash(tuple(parent(a), coordinates(a)), h), hash(typeof(a))) + b = 0xaa2ba4a32dd0b431 % UInt + h = hash(typeof(a), h) + h = hash(parent(a), h) + h = hash(coordinates(a), h) + return xor(h, b) end function Base.deepcopy_internal(a::AbstractFreeModElem, dict::IdDict) From 5ae1f6e09872ce5b31a9af7207021915497c9624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:12:36 +0200 Subject: [PATCH 14/23] Add `hash(::SubquoModuleElem)` --- src/Modules/UngradedModules.jl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Modules/UngradedModules.jl b/src/Modules/UngradedModules.jl index 965ba910b1b3..4d77d90fc33a 100644 --- a/src/Modules/UngradedModules.jl +++ b/src/Modules/UngradedModules.jl @@ -3523,32 +3523,39 @@ function +(a::SubquoModuleElem, b::SubquoModuleElem) check_parent(a,b) return SubquoModuleElem(coordinates(a)+coordinates(b), a.parent) end + function -(a::SubquoModuleElem, b::SubquoModuleElem) check_parent(a,b) return SubquoModuleElem(coordinates(a)-coordinates(b), a.parent) end + -(a::SubquoModuleElem) = SubquoModuleElem(-coordinates(a), a.parent) + function *(a::MPolyDecRingElem, b::SubquoModuleElem) if parent(a) !== base_ring(parent(b)) return base_ring(parent(b))(a)*b # this will throw if conversion is not possible end return SubquoModuleElem(a*coordinates(b), b.parent) end + function *(a::MPolyRingElem, b::SubquoModuleElem) if parent(a) !== base_ring(parent(b)) return base_ring(parent(b))(a)*b # this will throw if conversion is not possible end return SubquoModuleElem(a*coordinates(b), b.parent) end + function *(a::RingElem, b::SubquoModuleElem) if parent(a) !== base_ring(parent(b)) return base_ring(parent(b))(a)*b # this will throw if conversion is not possible end return SubquoModuleElem(a*coordinates(b), b.parent) end + *(a::Int, b::SubquoModuleElem) = SubquoModuleElem(a*coordinates(b), b.parent) *(a::Integer, b::SubquoModuleElem) = SubquoModuleElem(a*coordinates(b), b.parent) *(a::QQFieldElem, b::SubquoModuleElem) = SubquoModuleElem(a*coordinates(b), b.parent) + function (==)(a::SubquoModuleElem, b::SubquoModuleElem) if parent(a) !== parent(b) return false @@ -3556,6 +3563,12 @@ function (==)(a::SubquoModuleElem, b::SubquoModuleElem) return iszero(a-b) end +function Base.hash(a::SubquoModuleElem, h::UInt) + b = 0x0361a2f6467e4200 % UInt + h = hash(parent(a), h) + return xor(h, b) +end + function Base.deepcopy_internal(a::SubquoModuleElem, dict::IdDict) return SubquoModuleElem(deepcopy_internal(coordinates(a), dict), a.parent) end From 54b3eed337889c8912ac8f17e250268446e987db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:15:21 +0200 Subject: [PATCH 15/23] Add `hash(::ToricDivisor)` --- .../ToricVarieties/ToricDivisors/constructors.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricDivisors/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricDivisors/constructors.jl index f4febdf63a40..cddeba0fa1be 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricDivisors/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricDivisors/constructors.jl @@ -99,13 +99,20 @@ Base.:*(c::T, td::ToricDivisor) where {T <: IntegerUnion} = toric_divisor(toric_ ###################### -# 5: Equality +# 5: Equality and hash ######################s function Base.:(==)(td1::ToricDivisor, td2::ToricDivisor) return toric_variety(td1) === toric_variety(td2) && coefficients(td1) == coefficients(td2) end +function Base.hash(td::ToricDivisor, h::UInt) + b = 0x92bd6ac4f87d834e % UInt + h = hash(toric_variety(td), h) + h = hash(coefficients(td), h) + return xor(h, b) +end + ###################### # 6: Display From e8a8ab54f63297b237afb5728b0c4bc1d70a3645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:17:49 +0200 Subject: [PATCH 16/23] Add `hash(::ToricDivisorClass)` --- .../ToricVarieties/ToricDivisorClasses/constructors.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl index 17cb26da40f3..1b842c0bf568 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl @@ -100,13 +100,19 @@ Base.:*(c::T, tdc::ToricDivisorClass) where {T <: IntegerUnion} = toric_divisor_ ######################## -# 5: Equality +# 5: Equality and hash ######################## function Base.:(==)(tdc1::ToricDivisorClass, tdc2::ToricDivisorClass) return toric_variety(tdc1) === toric_variety(tdc2) && iszero(divisor_class(tdc1) - divisor_class(tdc2)) end +function Base.hash(tdc::ToricDivisorClass, h::UInt) + b = 0x118eb1fba136490c % UInt + h = hash(toric_variety(tdc), h) + return xor(h, b) +end + ###################### # 6: Display From 5e05adc43929542c8b06164fb7a091beb791f2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:19:39 +0200 Subject: [PATCH 17/23] Add `hash(::ToricLineBundle)` --- .../ToricVarieties/ToricLineBundles/constructors.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl index c219b479d0bb..514b1079b415 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl @@ -174,13 +174,19 @@ Base.:^(l::ToricLineBundle, p::Int) = l^ZZRingElem(p) ######################## -# 5: Equality +# 5: Equality and hash ######################## function Base.:(==)(l1::ToricLineBundle, l2::ToricLineBundle) return toric_variety(l1) === toric_variety(l2) && picard_class(l1) == picard_class(l2) end +function Base.hash(l::ToricLineBundle, h::UInt) + b = 0xa2b0a2cd60a8ffbf % UInt + h = hash(toric_variety(l), h) + return xor(h, b) +end + ######################## # 6: Display From 9d7b9533a2735314eb90baa1b210be1a0a80627a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:21:32 +0200 Subject: [PATCH 18/23] Add `hash(::ToricMorphism)` --- .../ToricVarieties/ToricMorphisms/constructors.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl index c8ba030f0219..cd5eed9ce9b7 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl @@ -220,13 +220,21 @@ end #################################################### -# 6: Equality of toric morphisms +# 6: Equality and hash of toric morphisms #################################################### function Base.:(==)(tm1::ToricMorphism, tm2::ToricMorphism) return domain(tm1) == domain(tm2) && codomain(tm1) == codomain(tm2) && grid_morphism(tm1) == grid_morphism(tm2) end +function Base.hash(tm::ToricMorphism, h::UInt) + b = 0x1a66f927cae2d409 % UInt + h = hash(domain(tm), h) + h = hash(codomain(tm), h) + h = hash(grid_morphism(tm), h) + return xor(h, b) +end + ###################### # 6: Display From 2c8bfd3220a97d86fdac86369964449fb496d396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 11 May 2023 16:28:10 +0200 Subject: [PATCH 19/23] Add `hash(::TropicalSemiringElem)` --- src/TropicalGeometry/semiring.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/TropicalGeometry/semiring.jl b/src/TropicalGeometry/semiring.jl index 097cf689a303..8aeaed32dd39 100644 --- a/src/TropicalGeometry/semiring.jl +++ b/src/TropicalGeometry/semiring.jl @@ -227,7 +227,7 @@ Oscar.isone(x::TropicalSemiringElem) = !isinf(x) && iszero(data(x)) ################################################################################ # -# Equality +# Equality and hash # ################################################################################ @@ -237,6 +237,15 @@ function Base.:(==)(x::TropicalSemiringElem, y::TropicalSemiringElem) return data(x) == data(y) end +function Base.hash(x::TropicalSemiringElem, h::UInt) + b = 0x4df38853cc07aa27 % UInt + h = hash(isinf(x), h) + if !isinf(x) + h = hash(data(x), h) + end + return xor(h, b) +end + ################################################################################ # # Comparison From 3b09a90d626e9d3ff8e2f665f2738737d7c56f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Wed, 17 May 2023 12:30:57 +0200 Subject: [PATCH 20/23] Update `hash` for `MPolyQuoLocalizedRingHom` and `MPolyLocalizedRingHom` --- src/Rings/mpoly-localizations.jl | 3 +++ src/Rings/mpolyquo-localizations.jl | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Rings/mpoly-localizations.jl b/src/Rings/mpoly-localizations.jl index df7d14c00eac..a16170db044b 100644 --- a/src/Rings/mpoly-localizations.jl +++ b/src/Rings/mpoly-localizations.jl @@ -2901,6 +2901,9 @@ function Base.hash(f::MPolyLocalizedRingHom, h::UInt) b = 0xe29cdc1ecb68b7a0 % UInt h = hash(domain(f), h) h = hash(codomain(f), h) + for x in gens(base_ring(domain(f))) + h = hash(f(x), h) + end return xor(h, b) end diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 3e6279cab6ba..e574b4734ab8 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -1083,6 +1083,9 @@ function Base.hash(f::MPolyQuoLocalizedRingHom, h::UInt) b = 0xd6d389598ad28724 % UInt h = hash(domain(f), h) h = hash(codomain(f), h) + for x in gens(base_ring(domain(f))) + h = hash(f(x), h) + end return xor(h, b) end From 14d6e1e4fa65411ea20f4e77db692664e4d9da5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Wed, 7 Jun 2023 14:45:51 +0200 Subject: [PATCH 21/23] Update `==` and `hash` for toric types --- .../ToricVarieties/AlgebraicCycles/constructors.jl | 9 +++++---- .../ToricVarieties/CohomologyClasses/constructors.jl | 11 +++++++---- .../ToricDivisorClasses/constructors.jl | 3 ++- .../ToricVarieties/ToricLineBundles/constructors.jl | 1 + .../ToricVarieties/ToricMorphisms/constructors.jl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl index bd19a82e878d..cb8aff92c627 100644 --- a/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl @@ -271,13 +271,14 @@ end #################################################### function Base.:(==)(ac1::RationalEquivalenceClass, ac2::RationalEquivalenceClass) - return toric_variety(ac1) === toric_variety(ac2) && iszero(polynomial(ac1-ac2)) + return toric_variety(ac1) === toric_variety(ac2) && polynomial(ac1) == polynomial(ac2) end function Base.hash(ac::RationalEquivalenceClass, h::UInt) - b = 0xb5d4ac6b9084eb6e % UInt - h = hash(toric_variety(ac), h) - return xor(h, b) + b = 0xb5d4ac6b9084eb6e % UInt + h = hash(toric_variety(ac), h) + h = hash(polynomial(ac), h) + return xor(h, b) end diff --git a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl index e18227767eac..9dac8d513f03 100644 --- a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl @@ -148,12 +148,15 @@ Base.:^(cc::CohomologyClass, p::T) where {T <: IntegerUnion} = CohomologyClass(t # 5: Equality and hash ######################## -Base.:(==)(cc1::CohomologyClass, cc2::CohomologyClass) = toric_variety(cc1) === toric_variety(cc2) && iszero(polynomial(cc1-cc2)) +function Base.:(==)(cc1::CohomologyClass, cc2::CohomologyClass) + toric_variety(cc1) === toric_variety(cc2) && polynomial(cc1) == polynomial(cc2) +end function Base.hash(cc::CohomologyClass, h::UInt) - b = 0x4de32042e67d89c8 % UInt - h = hash(toric_variety(cc), h) - return xor(h, b) + b = 0x4de32042e67d89c8 % UInt + h = hash(toric_variety(cc), h) + h = hash(polynomial(cc), h) + return xor(h, b) end ###################### diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl index 1b842c0bf568..f65f573b3392 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl @@ -104,12 +104,13 @@ Base.:*(c::T, tdc::ToricDivisorClass) where {T <: IntegerUnion} = toric_divisor_ ######################## function Base.:(==)(tdc1::ToricDivisorClass, tdc2::ToricDivisorClass) - return toric_variety(tdc1) === toric_variety(tdc2) && iszero(divisor_class(tdc1) - divisor_class(tdc2)) + return toric_variety(tdc1) === toric_variety(tdc2) && divisor_class(tdc1) == divisor_class(tdc2) end function Base.hash(tdc::ToricDivisorClass, h::UInt) b = 0x118eb1fba136490c % UInt h = hash(toric_variety(tdc), h) + h = hash(divisor_class(tdc), h) return xor(h, b) end diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl index 514b1079b415..c07780de70f6 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl @@ -184,6 +184,7 @@ end function Base.hash(l::ToricLineBundle, h::UInt) b = 0xa2b0a2cd60a8ffbf % UInt h = hash(toric_variety(l), h) + h = hash(picard_class(l), h) return xor(h, b) end diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl index cd5eed9ce9b7..96b22f64cbd6 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl @@ -237,7 +237,7 @@ end ###################### -# 6: Display +# 7: Display ###################### function Base.show(io::IO, tm::ToricMorphism) From cb08ab61637ef27b60e2004d77ad8b741d859ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Mon, 22 May 2023 15:36:20 +0200 Subject: [PATCH 22/23] Let `hash` for `AbsMPolyMultSet` and `SubquoModuleElem` error --- src/Modules/UngradedModules.jl | 4 +--- src/Rings/mpoly-localizations.jl | 7 ++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Modules/UngradedModules.jl b/src/Modules/UngradedModules.jl index 4d77d90fc33a..5d149a92540f 100644 --- a/src/Modules/UngradedModules.jl +++ b/src/Modules/UngradedModules.jl @@ -3564,9 +3564,7 @@ function (==)(a::SubquoModuleElem, b::SubquoModuleElem) end function Base.hash(a::SubquoModuleElem, h::UInt) - b = 0x0361a2f6467e4200 % UInt - h = hash(parent(a), h) - return xor(h, b) + error("not implemented") end function Base.deepcopy_internal(a::SubquoModuleElem, dict::IdDict) diff --git a/src/Rings/mpoly-localizations.jl b/src/Rings/mpoly-localizations.jl index a16170db044b..311d0e7ddd3d 100644 --- a/src/Rings/mpoly-localizations.jl +++ b/src/Rings/mpoly-localizations.jl @@ -674,11 +674,8 @@ function ==(T::AbsMPolyMultSet, U::AbsMPolyMultSet) return (issubset(T, U) && issubset(U, T)) end -function Base.hash(T::AbsMPolyMultSet, h::UInt) - b = 0x7ce51a28c47ec5e1 % UInt - h = hash(typeof(T), h) - h = hash(ambient_ring(T), h) - return xor(h, b) +function Base.hash(T::AbsMPolyMultSet{BRT, BRET, RT, RET}, h::UInt) where {BRT,BRET,RT,RET} + error("not implemented") end function issubset( From db87017bba79905ac4bdd025238d12de14853483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Wed, 7 Jun 2023 17:39:27 +0200 Subject: [PATCH 23/23] Bump version (this PR is breaking) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2b9645ede965..7c86af9032f9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Oscar" uuid = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13" authors = ["The OSCAR Team "] -version = "0.12.2-DEV" +version = "0.13.0-DEV" [deps] AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"