1 answer

To find out, you can look in the __cmp__ special method of the object you're interested in. This function returns negative if x<y, zero if x==y, and positive if x>y. Looking in __cmp__ interactively is probably a better idea than browsing the source, because if you do that you may guess wrong about which __cmp__ is being used (like I did!).

So it seems (modulo some details) it's basically comparing the Sequences of the groebner bases, and that appears to fall through to simply sorting the underlying lists of polynomials. I don't know how useful that is, but that looks like what it's doing.

Comments

Oh no, that does not seem useful. Thank you for your response. Now I am doubting that A==B being True even means that the ideals are equal, which I was assuming. Does sage have built in functions for ideal equality and ideal containment? I would like to have a function like equality(A,B) and containment(A,B) whose value being true means A=B as ideal and A is contained in B, respectively? Does such a function exist? I know I can compute reduced Grob bases of both ideals and visually check if they are the same but I would like have a sage function that will check that for me.

IIUC the above logic should get equality right, so if that's all you need you're set. (It'd be a bug if it doesn't!) I'm a little rusty, but I gather you'd like A <= B iff all the terms in the generators of A (or the fewer but more expensive to compute terms in the groebner basis) are contained in B? If so, would something like def containment(A, B): return all(gen in B for gen in A.gens()) or def containment(A, B): return all(gb in B for gb in A.groebner_basis()) work?

Yes, that is right. I just need a function that checks if all the generators of A are contained in the ideal B. Easy enough, and I think your costom function does work but I am wondering if there is a predefined sage function(command) that does this or if I have to define one.

Every time I say that there isn't a predefined function to do something it turns out there is one in an obvious location and I just didn't see it, so to prevent embarrassment I won't say there's not. :^) But I didn't find it on a cursory scan.