Opened 5 years ago
Closed 11 months ago
#24171 closed enhancement (fixed)
Formal set membership function
Reported by:  rws  Owned by:  

Priority:  major  Milestone:  sage9.4 
Component:  symbolics  Keywords:  
Cc:  vdelecroix  Merged in:  
Authors:  Ralf Stephan, Matthias Koeppe  Reviewers:  Travis Scrimshaw, Matthias Koeppe 
Report Upstream:  N/A  Work issues:  
Branch:  a8c94ca (Commits, GitHub, GitLab)  Commit:  a8c94cab974c8983dad63c2c6e989936984de49a 
Dependencies:  #31877  Stopgaps: 
Description (last modified by )
To express solution sets from solvers an expressioniselementofset relation is needed. For ease of implementation this can be made a formal function element_of
.
It depends on sets being made coercible into SR. The present ticket plays safe and only does this for finite sets and a few standard infinite sets: NN
, ZZ
, QQ
, AA
; and RealSet
s.
element_of
converts to SymPy's Contains
. This is useful in combination with #31931, which adds SymPy conversions to some of the above sets.
Change History (50)
comment:1 Changed 5 years ago by
 Description modified (diff)
comment:2 Changed 5 years ago by
 Branch set to u/rws/formal_set_membership_function
comment:3 Changed 5 years ago by
 Commit set to 669ea22318ab33f23f727626eb30e59fa138d253
 Status changed from new to needs_review
comment:4 Changed 5 years ago by
I can reproduce this error
********************************************************************** File "src/sage/misc/dev_tools.py", line 438, in sage.misc.dev_tools.import_statements Failed example: load_submodules(sage.sets) Expected: load sage.sets.real_set... succeeded load sage.sets.set_from_iterator... succeeded Got: load sage.sets.set_from_iterator... succeeded
I think why this now fails is because real_set
is now loaded on startup.
comment:5 Changed 5 years ago by
 Status changed from needs_review to needs_work
I think it would be good if RealSet
answered positive to is_Set
, I'm just not sure how to accomplish it correctly. If done it wouldn't need to be loaded at start.
comment:6 Changed 5 years ago by
 Commit changed from 669ea22318ab33f23f727626eb30e59fa138d253 to af82717b1bfeffbe6fc972686882916b0525b149
comment:7 Changed 5 years ago by
 Status changed from needs_work to needs_review
comment:8 Changed 5 years ago by
 Commit changed from af82717b1bfeffbe6fc972686882916b0525b149 to 592ce8745028ec0659b952e872dfff0a85ef5a5d
Branch pushed to git repo; I updated commit sha1. New commits:
592ce87  24171: Py3 fixes

comment:9 Changed 5 years ago by
 Reviewers set to Travis Scrimshaw
 Status changed from needs_review to positive_review
LGTM. Thanks.
comment:10 Changed 5 years ago by
Thanks for the review.
comment:12 Changed 4 years ago by
 Commit changed from 592ce8745028ec0659b952e872dfff0a85ef5a5d to aa11a3ee31cb75f5acf2e5cef1db52fd2092893b
Branch pushed to git repo; I updated commit sha1. New commits:
aa11a3e  Merge branch 'develop' into t/24171/formal_set_membership_function

comment:13 Changed 4 years ago by
 Status changed from needs_work to positive_review
comment:15 Changed 4 years ago by
comment:16 Changed 4 years ago by
 Branch changed from u/rws/formal_set_membership_function to u/rws/24171
comment:17 Changed 4 years ago by
 Commit changed from aa11a3ee31cb75f5acf2e5cef1db52fd2092893b to ac6af264cb8beed2c7196691003ff93552a9f5b9
OK, I added junk to the branch, so what Volker means are the patchbot plugin fails. Also, the rare random fails are now happening frequently so patchbot pass depend on the blockers.
New commits:
ac6af26  24171: Formal set memberhzip function

comment:18 Changed 4 years ago by
 Dependencies set to #24284 #24378
comment:19 Changed 4 years ago by
Actually the reason why #24171 fails the random expression tests is because the here introduced function is yet another function that fails that test.
comment:20 Changed 4 years ago by
 Commit changed from ac6af264cb8beed2c7196691003ff93552a9f5b9 to 365ea784a37f3a99202ce2f801ce901d29d36cca
Branch pushed to git repo; I updated commit sha1. New commits:
6559c5e  24282: Exclude some functions with arg restrictions from random testing

5db62d3  Merge branch 'u/rws/exclude_some_functions_with_arg_restrictions_from_random_testing' of git://trac.sagemath.org/sage into tmp17

365ea78  24171: exclude element_of from random testing too

comment:21 Changed 4 years ago by
 Dependencies changed from #24284 #24378 to #24284 #24378 #24443
comment:22 Changed 4 years ago by
 Cc vdelecroix added
 Status changed from needs_work to needs_info
The following problem appeared: to be able to use a symbolic element_of
function its arguments (1. expression, 2. set/domain) must be convertible to the symbolic ring. One doctest in symbolic/ring.pyx
tests that r
(the R interpreter) does not convert to symbolic. But r
is in Sets()
and so we cannot simply test for x in Sets()
and allow conversion of x
because r
would then be allowed.
So we must test for all kinds of sets, e.g. ZZ in InfiniteEnumeratedSets()
, RR in Fields()
, RealSet(0,1) in SetsWithPartialMaps()
, and Set(range(0,5)) in FiniteSets()
, because we need to catch all of these but cannot use the catchall in Sets()
. Is the R interpreter really in the sets category? Is there a better catchall?
comment:23 followup: ↓ 24 Changed 4 years ago by
BTW RealSet(oo,oo) in Fields()
is False which looks like a bug, right?
comment:24 in reply to: ↑ 23 ; followup: ↓ 25 Changed 4 years ago by
Replying to rws:
BTW
RealSet(oo,oo) in Fields()
is False which looks like a bug, right?
Not to me. RealSet(oo,oo)
or RealSet(0,1)
act as a facade (like in Sets().Facade()
). That is to say, it does not have any proper elements. Making it a field would be rather artificial because the operation +
and *
that might (or might not) exist on the elements is obtained from other parts of Sage.
comment:25 in reply to: ↑ 24 ; followup: ↓ 26 Changed 4 years ago by
Replying to vdelecroix:
...
RealSet(oo,oo)
orRealSet(0,1)
act as a facade ...
Is there an object that can act as the set of real numbers in Sage?
comment:26 in reply to: ↑ 25 ; followup: ↓ 27 Changed 4 years ago by
Replying to rws:
Replying to vdelecroix:
...
RealSet(oo,oo)
orRealSet(0,1)
act as a facade ...Is there an object that can act as the set of real numbers in Sage?
Very sadly, no!
My dream is:
 rename
RealField(prec)
>RealFloatingPointField_mpfr(prec)
 rename
RealLazyField
>RealComputableField
andRLF > RCF
 create a class
RealField()
to model (abstractly) the set of real numbers  rename
RR
>RFPF
The reason for 2./3. is that we want to distinguish between the field of all real numbers (denoted RR
in math literature) and the field of computable numbers (which is a countable subfield). An element of RCF
would simply be a computer program that gives access to the digit expansion of a number. It should provide access to all mathematical constants like pi
, e
, etc and most transcendental functions. A serious problem about RCF
is that the equality is not decidable... but we can not avoid it.
The set of real numbers (my number 3. in the list) would not implement anything serious. It would only act as an abstract set that can be obtained as the metric completion of QQ
. It could be used as a building block for more advanced structures (like manfiolds).
I put 4. apart as it is a serious backward incompatibility.reasons.
comment:27 in reply to: ↑ 26 Changed 4 years ago by
 Dependencies changed from #24284 #24378 #24443 to #24284 #24378 #24456
 Status changed from needs_info to needs_work
comment:28 Changed 4 years ago by
 Branch changed from u/rws/24171 to u/rws/241711
comment:29 Changed 4 years ago by
 Commit changed from 365ea784a37f3a99202ce2f801ce901d29d36cca to 628f9220672280b526134311efdab819aa3f05c5
 Status changed from needs_work to needs_review
comment:30 Changed 4 years ago by
Note that we have no proper check for if something is a subset of the complexes. I ended up allowing conversion of all finite sets and (NN, ZZ, QQ, RealField, RealSet, AA)
to symbolic.
comment:31 Changed 4 years ago by
 Status changed from needs_review to needs_work
comment:32 Changed 11 months ago by
 Branch changed from u/rws/241711 to u/mkoeppe/241711
comment:33 Changed 11 months ago by
 Commit changed from 628f9220672280b526134311efdab819aa3f05c5 to 72565f2720115475272c030db26b1144b87377bb
 Dependencies #24284 #24378 #24456 deleted
 Milestone changed from sage8.2 to sage9.4
comment:34 Changed 11 months ago by
The is_finite
method added here will not be necessary any more with #31877
comment:35 Changed 11 months ago by
 Commit changed from 72565f2720115475272c030db26b1144b87377bb to 5e623bb508d45a0ac79538c93bc115562b6269e0
Branch pushed to git repo; I updated commit sha1. New commits:
4b09685  RealSet: Put it in a suitable subcategory of TopologicalSpaces()

46eed0e  RealSet.ambient: Change to a normal method

51c8152  Merge branch 't/31877/refine_category_of_realset' into t/24171/setmembershiprebased

5e623bb  RealSet.is_finite: Remove, inherited from category

comment:36 Changed 11 months ago by
 Dependencies set to #31877
comment:37 Changed 11 months ago by
 Commit changed from 5e623bb508d45a0ac79538c93bc115562b6269e0 to 7d19916c0fbf2bf76054401df372fbedde7cdbb6
Branch pushed to git repo; I updated commit sha1. New commits:
7d19916  Do not use QQ.completion(oo,oo)  not implemented

comment:38 Changed 11 months ago by
 Commit changed from 7d19916c0fbf2bf76054401df372fbedde7cdbb6 to 5310e04bae60c574eafe491ebcea366e57513822
comment:39 Changed 11 months ago by
 Status changed from needs_work to needs_review
This branch works now as advertised, but a careful review of this design is needed
comment:40 Changed 11 months ago by
We could add more support for other infinite sets later on (e.g., number fields), but this would be good for most (perhaps all?) usecases. I think everything else is good except I don't understand why this line is added (see the diff):
oo = infinity
comment:41 Changed 11 months ago by
that's just a leftover, I'll get rid of it
comment:42 Changed 11 months ago by
 Commit changed from 5310e04bae60c574eafe491ebcea366e57513822 to 43cabe82529c55b1ab3add68304f3b2b73971cba
Branch pushed to git repo; I updated commit sha1. New commits:
43cabe8  Do not use QQ.completion(oo,oo)  not implemented (fixup)

comment:43 Changed 11 months ago by
Thank you. Green bot => positive review. Please add yourself whether you think you are an author and/or reviewer.
comment:44 Changed 11 months ago by
 Commit changed from 43cabe82529c55b1ab3add68304f3b2b73971cba to c793fcc4f9def7070c36785603958c48cf2710b0
Branch pushed to git repo; I updated commit sha1. New commits:
c793fcc  Function_elementof: Remove use of is_Set (fixup)

comment:45 Changed 11 months ago by
 Reviewers changed from Travis Scrimshaw to Travis Scrimshaw, Matthias Koeppe
comment:46 Changed 11 months ago by
 Commit changed from c793fcc4f9def7070c36785603958c48cf2710b0 to a8c94cab974c8983dad63c2c6e989936984de49a
Branch pushed to git repo; I updated commit sha1. New commits:
a8c94ca  Function_elementof: Add conversion to sympy

comment:47 Changed 11 months ago by
 Description modified (diff)
comment:48 Changed 11 months ago by
 Status changed from needs_review to positive_review
comment:49 Changed 11 months ago by
Thanks!
comment:50 Changed 11 months ago by
 Branch changed from u/mkoeppe/241711 to a8c94cab974c8983dad63c2c6e989936984de49a
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
24171: Formal set membership function