sagemath/sage

ConditionSet, ImageSet: Implement formal Set comprehension

rwst opened this issue · 37 comments

rwst commented

In order to be able to express solution sets from SymPy's solveset a set comprehension constructor as equivalent to SymPy's imageset / ConditionSet is needed. As the arguments are symbolic the most natural way to do this would be a formal symbolic function named like set_of_all taking a term argument and a list argument containing element_of(...) function expressions.

This set would convert to a SymPy ImageSet or ConditionSet

Related: ImageManifoldSubset (#31653)

Depends on #24171
Depends on #32013
Depends on #32089
Depends on #32121

CC: @tscrim @mantepse

Component: symbolics

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/24176

rwst commented

Dependencies: #24171

rwst commented

Changed dependencies from #24171 to #24171, pynac-0.7.13

rwst commented
comment:2

Accepting lists requires the function being a GinacFunction.

rwst commented

Commit: 9c77312

rwst commented

Changed dependencies from #24171, pynac-0.7.13 to #24171, #24262

rwst commented

New commits:

669ea2224171: Formal set membership function
34c977324171: make RealSet inherit from Set_generic
af8271724171: remove RealSet import; SR set coercion doctests
592ce8724171: Py3 fixes
82b7c6fMerge branch 'u/rws/formal_set_membership_function' of git://trac.sagemath.org/sage into t/24176/implement_formal_set_comprehension
ae2989524176: check set argument of element_of()
9c7731224176: Implement formal Set comprehension
rwst commented

Changed dependencies from #24171, #24262 to #24171, #24329

rwst commented

Author: Ralf Stephan

Changed commit from 9c77312 to ec39309

Changed dependencies from #24171, #24329 to #24171

comment:8

Rebased on top of rebased #24171


New commits:

72565f224171: Formal set membership function
71bbf3824171: Formal set membership function
6811a7624171: make RealSet inherit from Set_generic
0a66f7824171: remove RealSet import; SR set coercion doctests
e35349a24171: Py3 fixes
26ef67d24176: check set argument of element_of()
ec3930924176: Implement formal Set comprehension

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

51c8152Merge branch 't/31877/refine_category_of_realset' into t/24171/set-membership-rebased
5e623bbRealSet.is_finite: Remove, inherited from category
7d19916Do not use QQ.completion(oo,oo) - not implemented
9b4e22424176: check set argument of element_of()
5310e04Function_elementof: Remove use of is_Set
46d979524171: Formal set membership function
6995d1e24171: make RealSet inherit from Set_generic
a41c5fc24171: remove RealSet import; SR set coercion doctests
2a9c49a24171: Py3 fixes
24789ba24176: Implement formal Set comprehension

Changed commit from ec39309 to 24789ba

comment:10

Rebased on top of updated #24171, which cherry-picked 1 commit from here.

Not sure about the changes on this ticket marked 24171. They are either from a newer or older version of 24171.

comment:11

The fix to RealSet.__bool__ in 6995d1e/2a9c49a can go to #31941 (Make empty RealSet false).

Unclear to me whether 6995d1e (make RealSet inherit from Set_generic) should be done

Description changed:

--- 
+++ 
@@ -1 +1,5 @@
-In order to be able to express solution sets from SymPy's `solveset` a set comprehension constructor as equivalent to SymPy's imageset is needed. As the arguments are symbolic the most natural way to do this would be a formal symbolic function named like `set_of_all` taking a term argument and a list argument containing `element_of(...)` function expressions.
+In order to be able to express solution sets from SymPy's `solveset` a set comprehension constructor as equivalent to SymPy's `imageset` / `ConditionSet` is needed. As the arguments are symbolic the most natural way to do this would be a formal symbolic function named like `set_of_all` taking a term argument and a list argument containing `element_of(...)` function expressions.
+
+This set would convert to a `SymPy` [ImageSet](https://docs.sympy.org/latest/modules/sets.html#sympy.sets.fancysets.ImageSet) or [ConditionSet](https://docs.sympy.org/latest/modules/sets.html#conditionset)
+
+

Description changed:

--- 
+++ 
@@ -2,4 +2,5 @@
 
 This set would convert to a `SymPy` [ImageSet](https://docs.sympy.org/latest/modules/sets.html#sympy.sets.fancysets.ImageSet) or [ConditionSet](https://docs.sympy.org/latest/modules/sets.html#conditionset)
 
+Related: `ImageManifoldSubset` (#31653)
 
comment:14

I think the approach on the current branch may be tied a bit too closely to SR functions.

I think it's better to first implement:

  • ImageSubset (as an abstract subobject of the codomain) for arbitrary Maps -- this would be a generalization of ImageManifoldSubset (#31653). No relation to SR (but by relaxing the code from #24171 that only allows some sets to be coerced to SR, one would be able to coerce it to SR).

  • ConditionSet (as an abstract subobject of a parent in the Sets category) - defined via the element constructor of the parent and an SR expression with truth value.

comment:16

Replying to @mkoeppe:

  • ConditionSet (as an abstract subobject of a parent in the Sets category) - defined via the element constructor of the parent and an SR expression with truth value.

more precisely... an element of CallableSymbolicExpression (see #32008 for making this safer)

Changed dependencies from #24171 to #24171, #32013

Changed dependencies from #24171, #32013 to #24171, #32013, #32089

comment:18

Replying to @mkoeppe:

Replying to @mkoeppe:

  • ConditionSet (as an abstract subobject of a parent in the Sets category) - defined via the element constructor of the parent and an SR expression with truth value.

more precisely... an element of CallableSymbolicExpression (see #32008 for making this safer)

This is now implemented in #32089.

comment:19

ImageSet is essentially the same as the (deprecated?) sage.combinat.combinat.MapCombinatorialClass, except that we would not insist that the map is injective.

comment:20

Opened #32121 Replace MapCombinatorialClass

Changed dependencies from #24171, #32013, #32089 to #24171, #32013, #32089, #32121

comment:22

@mkoeppe: since you put me into the CC list, would this include symbolic roots of polynomials, given by the minimal polynomial?

I am guessing (because I'm not an expert there) that these would really need a special treatment, because one can compute with them quite well.

comment:25

With #32121 merged, this is now finished

Changed author from Ralf Stephan to none

comment:26

Agreed.

Reviewer: Travis Scrimshaw

Changed commit from 24789ba to none

comment:27

Does #32121 provide a possibility to specify the set of roots of a polynomial?