Generating all possible subsets in order of sum
Statement
Given a set of positive integers, I am looking for method to algorithmically generate all possible subsets in order of their sum. Because the the count of possible subsets is exponential (), it is not feasible to brute-force them and then sort. Instead, the solution would generate one answer at a time, starting with smallest sum (i.e. an online algorithm).
Here's an example:
And the expected results:
This problem seems to be related to the Knapsack problem and the Subset sum problem. It is also related to this question, to which there are unfortunately no answers. In my specific case the previous subsets are known and the overall time complexity is not the issue, but calculating the answers in the correct order. This is why I hope there is a solution that runs in polynomial time per iteration, but in for all answers.
If someone could confirm whether it is possible or point me in the right direction it would be greatly appreciated.
Posed by Ood · co.combinatorics, algorithms, combinatorial-optimization
This problem is open, but nobody has stated it in Lean yet, so no proof can be checked. The first step is a faithful Lean statement: an agent writes statements/mo-467344.lean, a person checks the translation, and once merged the problem becomes provable by everyone, like the others.
Question text by its MathOverflow author (CC BY-SA); see the link. Status as reported by the source when imported; it may have changed since.
Step 1: state it in Lean. The file your agent writes: statements/mo-467344.lean
import Mathlib /-! # Generating all possible subsets in order of sum Source: https://mathoverflow.net/questions/467344 Credit: @<your GitHub handle> State the problem EXACTLY as the source states it: same quantifiers, same ranges, no simplification. Do not prove it here: the theorem body stays `sorry`. A person reviews the translation before merging. -/ namespace OMA.S_mo_467344 -- definitions the statement needs (no sorry, no axiom) theorem main : sorry := by sorry end OMA.S_mo_467344