ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 16 Jan 2021 11:57:59 +0100Removing all supersets of a given subset from a powerset?https://ask.sagemath.org/question/55296/removing-all-supersets-of-a-given-subset-from-a-powerset/First, my apologies if this is a trivial question. I am working through the powerset of a finite set of positive integers. I also have a predetermined value V. The idea is that as soon as I find a subset S whose elements sum to V or more, I want to remove all supersets of S, so that I don't have to test them. For example, suppose my set is {10,9,6,5} and V=16. When I find S = {10,9} has the property of I want, I can remove all supersets of {10,9} from further consideration. The final result will be just three subsets: {10,9}, {10,6}, and {9,6,5}.
I can do this "by hand" as it were, but is there a method already built-in for this? I've been fiddling around with lattices and posets and lower covers, but I can't get any of the methods to work.
I'd welcome any advice!Sat, 16 Jan 2021 07:24:27 +0100https://ask.sagemath.org/question/55296/removing-all-supersets-of-a-given-subset-from-a-powerset/Comment by FrédéricC for <p>First, my apologies if this is a trivial question. I am working through the powerset of a finite set of positive integers. I also have a predetermined value V. The idea is that as soon as I find a subset S whose elements sum to V or more, I want to remove all supersets of S, so that I don't have to test them. For example, suppose my set is {10,9,6,5} and V=16. When I find S = {10,9} has the property of I want, I can remove all supersets of {10,9} from further consideration. The final result will be just three subsets: {10,9}, {10,6}, and {9,6,5}.</p>
<p>I can do this "by hand" as it were, but is there a method already built-in for this? I've been fiddling around with lattices and posets and lower covers, but I can't get any of the methods to work.</p>
<p>I'd welcome any advice!</p>
https://ask.sagemath.org/question/55296/removing-all-supersets-of-a-given-subset-from-a-powerset/?comment=55297#post-id-55297Maybe using `RecursivelyEnumeratedSet` ?Sat, 16 Jan 2021 08:35:41 +0100https://ask.sagemath.org/question/55296/removing-all-supersets-of-a-given-subset-from-a-powerset/?comment=55297#post-id-55297Comment by FrédéricC for <p>First, my apologies if this is a trivial question. I am working through the powerset of a finite set of positive integers. I also have a predetermined value V. The idea is that as soon as I find a subset S whose elements sum to V or more, I want to remove all supersets of S, so that I don't have to test them. For example, suppose my set is {10,9,6,5} and V=16. When I find S = {10,9} has the property of I want, I can remove all supersets of {10,9} from further consideration. The final result will be just three subsets: {10,9}, {10,6}, and {9,6,5}.</p>
<p>I can do this "by hand" as it were, but is there a method already built-in for this? I've been fiddling around with lattices and posets and lower covers, but I can't get any of the methods to work.</p>
<p>I'd welcome any advice!</p>
https://ask.sagemath.org/question/55296/removing-all-supersets-of-a-given-subset-from-a-powerset/?comment=55302#post-id-55302Adding elements one by one, you need to define a successor function : see https://doc.sagemath.org/html/en/reference/sets/sage/sets/recursively_enumerated_set.htmlSat, 16 Jan 2021 11:57:59 +0100https://ask.sagemath.org/question/55296/removing-all-supersets-of-a-given-subset-from-a-powerset/?comment=55302#post-id-55302