Opened 2 years ago

Last modified 23 months ago

#24171 needs_work enhancement

Formal set membership function

Reported by: rws Owned by:
Priority: major Milestone: sage-8.2
Component: symbolics Keywords:
Cc: vdelecroix Merged in:
Authors: Ralf Stephan Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: u/rws/24171-1 (Commits) Commit: 628f9220672280b526134311efdab819aa3f05c5
Dependencies: #24284 #24378 #24456 Stopgaps:

Description (last modified by rws)

To express solution sets from solvers an expression-is-element-of-set relation is needed. For ease of implementation this can be made a formal function, likely named "contains" or "element_of". It would depend on sets being made coercible into SR.

Change History (31)

comment:1 Changed 2 years ago by rws

  • Description modified (diff)

comment:2 Changed 2 years ago by rws

  • Branch set to u/rws/formal_set_membership_function

comment:3 Changed 2 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to 669ea22318ab33f23f727626eb30e59fa138d253
  • Status changed from new to needs_review

New commits:

669ea2224171: Formal set membership function

comment:4 Changed 2 years ago by tscrim

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 2 years ago by rws

  • 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 2 years ago by git

  • Commit changed from 669ea22318ab33f23f727626eb30e59fa138d253 to af82717b1bfeffbe6fc972686882916b0525b149

Branch pushed to git repo; I updated commit sha1. New commits:

34c977324171: make RealSet inherit from Set_generic
af8271724171: remove RealSet import; SR set coercion doctests

comment:7 Changed 2 years ago by rws

  • Status changed from needs_work to needs_review

comment:8 Changed 2 years ago by git

  • Commit changed from af82717b1bfeffbe6fc972686882916b0525b149 to 592ce8745028ec0659b952e872dfff0a85ef5a5d

Branch pushed to git repo; I updated commit sha1. New commits:

592ce8724171: Py3 fixes

comment:9 Changed 2 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM. Thanks.

comment:10 Changed 2 years ago by rws

Thanks for the review.

comment:11 Changed 2 years ago by vbraun

  • Status changed from positive_review to needs_work

Merge conflictw

comment:12 Changed 2 years ago by git

  • Commit changed from 592ce8745028ec0659b952e872dfff0a85ef5a5d to aa11a3ee31cb75f5acf2e5cef1db52fd2092893b

Branch pushed to git repo; I updated commit sha1. New commits:

aa11a3eMerge branch 'develop' into t/24171/formal_set_membership_function

comment:13 Changed 2 years ago by rws

  • Status changed from needs_work to positive_review

comment:14 Changed 2 years ago by vbraun

  • Status changed from positive_review to needs_work

See patchbot

comment:15 Changed 2 years ago by rws

Actually the fails are due to the blockers #24284 and #24378 but they are not reviewed yet.

comment:16 Changed 2 years ago by rws

  • Branch changed from u/rws/formal_set_membership_function to u/rws/24171

comment:17 Changed 2 years ago by rws

  • 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:

ac6af2624171: Formal set memberhzip function

comment:18 Changed 2 years ago by vbraun

  • Dependencies set to #24284 #24378

comment:19 Changed 2 years ago by rws

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 2 years ago by git

  • Commit changed from ac6af264cb8beed2c7196691003ff93552a9f5b9 to 365ea784a37f3a99202ce2f801ce901d29d36cca

Branch pushed to git repo; I updated commit sha1. New commits:

6559c5e24282: Exclude some functions with arg restrictions from random testing
5db62d3Merge branch 'u/rws/exclude_some_functions_with_arg_restrictions_from_random_testing' of git://trac.sagemath.org/sage into tmp17
365ea7824171: exclude element_of from random testing too

comment:21 Changed 2 years ago by rws

  • Dependencies changed from #24284 #24378 to #24284 #24378 #24443

comment:22 Changed 2 years ago by rws

  • 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 catch-all in Sets(). Is the R interpreter really in the sets category? Is there a better catch-all?

comment:23 follow-up: Changed 2 years ago by rws

BTW RealSet(-oo,oo) in Fields() is False which looks like a bug, right?

comment:24 in reply to: ↑ 23 ; follow-up: Changed 2 years ago by vdelecroix

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 ; follow-up: Changed 2 years ago by rws

Replying to vdelecroix:

... RealSet(-oo,oo) or RealSet(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 ; follow-up: Changed 2 years ago by vdelecroix

Replying to rws:

Replying to vdelecroix:

... RealSet(-oo,oo) or RealSet(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:

  1. rename RealField(prec) -> RealFloatingPointField_mpfr(prec)
  2. rename RealLazyField -> RealComputableField and RLF -> RCF
  3. create a class RealField() to model (abstractly) the set of real numbers
  4. 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 2 years ago by rws

  • Dependencies changed from #24284 #24378 #24443 to #24284 #24378 #24456
  • Status changed from needs_info to needs_work

comment:28 Changed 2 years ago by rws

  • Branch changed from u/rws/24171 to u/rws/24171-1

comment:29 Changed 2 years ago by rws

  • Commit changed from 365ea784a37f3a99202ce2f801ce901d29d36cca to 628f9220672280b526134311efdab819aa3f05c5
  • Status changed from needs_work to needs_review

This now depends on #24456 and has sufficiently changed to need a new review. Could you please?


New commits:

62d2d2124456: class for the field of real numbers
628f92224171: Formal set membership function

comment:30 Changed 2 years ago by rws

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 23 months ago by rws

  • Status changed from needs_review to needs_work
Note: See TracTickets for help on using tickets.