[Previous] [Next] [Contents]

[ImplState=stable,TestState=stable,DocState=stable]

combinat::powerset -- power set of a set or list (deprecated)

Introduction

combinat::powerset(set) computes the powerset of the given set set, that is, the set of all subsets of set.

combinat::powerset(list) computes the powerset of the given list list, that is, the set of all sublists of list. In this context, lists are understood as multisets.

combinat::powerset(n) computes the powerset of the set 1,2,...,n.

Call(s)


combinat::powerset(n)
combinat::powerset(set)
combinat::powerset(list)

Parameters

n- a nonnegative integer
set- a set of domain type DOM_SET
list- a list of domain type DOM_LIST

Returns

A set of domain type DOM_SET which contains the computed subsets.

Overloadable:

set

Related Functions

combinat::choose

Details

Example 1

The powerset of the set a,b,c:

>> combinat::warnDeprecated(FALSE):
   combinat::powerset({a, b, c})
     
          {{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}}
        

The function combinat::powerset is deprecated:

>> old_val:=combinat::warnDeprecated(TRUE):
   combinat::powerset({a, b, c});
   combinat::warnDeprecated(old_val):
     
      Warning: combinat::powerset is obsolete.
      Please use 'combinat::subsets' and 'combinat::subwords' instea\
      d. [combinat::powerset]
      
          {{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}}
        

Here is the recommended replacement:

>> combinat::subsets::list({a,b,c})
     
          [{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}]
        

Note that the result is returned as a list.

Example 2

The powerset of the set {1,2,3}:

>> combinat::powerset(3)
     
          {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
        

Here is the recommended replacement:

>> combinat::subsets::list(3)
     
          [{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}]
        

Example 3

Here you can see that lists are treated as multisets. There is no sublist [2, 1] since it is identified with the list [1,2] which is in the powerset.

>> combinat::powerset([2, 1, 2])
     
                 {[], [1], [2], [1, 2], [2, 2], [1, 2, 2]}
        

Here is the recommended replacement:

>> {op(combinat::subwords::list(sort([2, 1, 2])))}
     
                 {[], [1], [2], [1, 2], [2, 2], [1, 2, 2]}
        

[Previous] [Next] [Contents]


MuPAD Combinat, an open source algebraic combinatorics package