### Navigation

- index
- modules |
- next |
- previous |
- Category Theory »

# Facade Sets

For background, see What is a facade set?.

class `sage.categories.facade_sets.``FacadeSets`(base_category)

  Bases: `sage.categories.category_with_axiom.CategoryWithAxiom_singleton`

  TESTS:

      sage: C = Sets.Finite(); C
      Category of finite sets
      sage: type(C)
      <class 'sage.categories.finite_sets.FiniteSets_with_category'>
      sage: type(C).__base__.__base__
      <class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>

      sage: TestSuite(C).run()

  class `ParentMethods`
    `facade_for`()

      Returns the parents this set is a facade for

      This default implementation assumes that `self` has an attribute `_facade_for`, typically initialized by `Parent.__init__()`. If the attribute is not present, the method raises a NotImplementedError.

      EXAMPLES:

          sage: S = Sets().Facade().example(); S
          An example of facade set: the monoid of positive integers
          sage: S.facade_for()
          (Integer Ring,)

      Check that trac ticket #13801 is corrected:

          sage: class A(Parent):
          ....:     def __init__(self):
          ....:         Parent.__init__(self, category=Sets(), facade=True)
          sage: a = A()
          sage: a.facade_for()
          Traceback (most recent call last):
          ...
          NotImplementedError: this parent did not specify which parents it is a facade for

    `is_parent_of`(element)

      Returns whether `self` is the parent of `element`

      INPUT:

      - `element` – any object

      Since `self` is a facade domain, this actually tests whether the parent of `element` is any of the parent `self` is a facade for.

      EXAMPLES:

          sage: S = Sets().Facade().example(); S
          An example of facade set: the monoid of positive integers
          sage: S.is_parent_of(1)
          True
          sage: S.is_parent_of(1/2)
          False

      This method differs from `__contains__()` in two ways. First, this does not take into account the fact that `self` may be a strict subset of the parent(s) it is a facade for:

          sage: -1 in S, S.is_parent_of(-1)
          (False, True)

      Furthermore, there is no coercion attempted:

          sage: int(1) in S, S.is_parent_of(int(1))
          (True, False)

      Warning

      this implementation does not handle facade parents of facade parents. Is this a feature we want generically?

  `FacadeSets.``example`(choice='subset')

    Returns an example of facade set, as per `Category.example()`.

    INPUT:

    - `choice` – ‘union’ or ‘subset’ (default: ‘subset’).

    EXAMPLES:

        sage: Sets().Facade().example()
        An example of facade set: the monoid of positive integers
        sage: Sets().Facade().example(choice='union')
        An example of a facade set: the integers completed by +-infinity
        sage: Sets().Facade().example(choice='subset')
        An example of facade set: the monoid of positive integers

### Navigation

- index
- modules |
- next |
- previous |
- Category Theory »