Opened 7 years ago

Last modified 6 weeks ago

#18349 new defect

One-fold tensor products: fix repr and document the behavior

Reported by: elixyre Owned by:
Priority: major Milestone: sage-9.6
Component: categories Keywords: tensor, categories
Cc: nthiery Merged in:
Authors: Jean-Baptiste Priez Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Hello every one,

sage: h = SymmetricFunctions(QQ).h()
sage: tensor([h]) # I assume that return h?
Symmetric Functions over Rational Field in the homogeneous basis
sage: h == tensor([h])
False

It must be a little mistake but I don't find the good category code where change that issue.

Change History (9)

comment:1 Changed 7 years ago by elixyre

I suppose the bug is in sage.categories.covariant_functorial_construction.CovariantFunctorialConstruction?._call_ but I don't understand what the code means.

comment:2 follow-up: Changed 7 years ago by nthiery

  • Summary changed from Tensor product to One-fold tensor products: fix repr and document the behavior.

Salut Jean-Baptiste,

h and tensor([h]) are indeed distinct, the latter being a (one-fold) tensor product:

    sage: h = SymmetricFunctions(QQ).h()
    sage: h1 = tensor([h])
    sage: type(h1)
    <class 'sage.combinat.free_module.CombinatorialFreeModule_Tensor_with_category'>

In particular, the basis is indexed by (singleton) tuples of partitions, instead of partitions:

    sage: h1.basis().keys().an_element()
    ([],)
    sage: h.basis().keys().an_element()
    []

Given that a one-fold tensor product of a single space V as above is trivially isomorphic to V, the above behavior may look disappointing at first. Yet making the distinction explicit is on purpose. The rationale is that this enables writing generic code in a uniform way when constructing the tensor product of a list of spaces; otherwise one would need to always special case the singleton list (btw: ideally, we would want to support the empty list as well).

Note that we have the same behavior for e.g. one-fold cartesian products:

    sage: p2 = cartesian_product([Partitions()])
    sage: p2
    The cartesian product of (Partitions,)
    sage: type(p2)
    <class 'sage.sets.cartesian_product.CartesianProduct_with_category'>
    sage: p2.an_element()
    ([],)

This being said, and unlike for cartesian products, the repr of one-fold tensor products, as currently returned by CombinatorialFreeModule_Tensor_with_category._repr_, is indeed very misleading. So I am requalifying this ticket to fix this. Thanks for reporting!

Would you have a suggestion for a good repr in this case?

We also probably want to highlight the above behavior in the documentation of tensor?.

Cheers,

Nicolas

comment:3 Changed 7 years ago by nthiery

  • Summary changed from One-fold tensor products: fix repr and document the behavior. to One-fold tensor products: fix repr and document the behavior

comment:4 in reply to: ↑ 2 Changed 7 years ago by elixyre

Thanks, it seems clear to me now.

Replying to nthiery:

Would you have a suggestion for a good repr in this case?

I don't have any opinion, may be:

sage: h = Sym(QQ).h()
sage: tensor([h])
Tensor:[Symmetric Functions over Rational Field in the homogeneous basis]

?

Replying to nthiery:

We also probably want to highlight the above behavior in the documentation of tensor?.

May be...

In this way, I have an other stupid question, when we have a tensor product:

sage: S = NCSF(QQ).S()
sage: t = tensor([h, S])

There is a friendly way to recover h and S from t?

comment:5 Changed 7 years ago by nthiery

At the price of breaking encapsulation, you can do t._sets. There should be a method t.tensor_factors(). It's probably been implemented by Mark, typically in #15832.

comment:6 Changed 17 months ago by mkoeppe

  • Milestone changed from sage-6.7 to sage-9.3

comment:7 Changed 12 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

comment:8 Changed 6 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:9 Changed 6 weeks ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6
Note: See TracTickets for help on using tickets.