size()$CharacterClass

2 views
Skip to first unread message

Qian Yun

unread,
Oct 18, 2023, 6:14:07 AM10/18/23
to fricas-devel
When running test suite with CMUCL, there's one error from finite.input:

testTrue "testLookupIndex(CharacterClass)"

Because it calls "size()$CharacterClass", which is "2^size()$Character",
"2^1114112".

First, for CMUCL it gives error because the exponent exceeds
extensions:*intexp-maximum-exponent* (which is 10000).

That is unreasonably small, we should consider to loosen it.

Second, since we limit number of possible Character in CharacterClass to
be 256, then "size()$CharacterClass" should be "2^256" instead.

- Qian

=====

diff --git a/src/algebra/string.spad b/src/algebra/string.spad
index 51dfebef..bf47ec1b 100644
--- a/src/algebra/string.spad
+++ b/src/algebra/string.spad
@@ -205,6 +205,7 @@ CharacterClass : Join(SetCategory, ConvertibleTo String,
# a == (n := 0; for i in 0..N-1 | a.i repeat n :=
n+1; n)
empty() : % == charClass []
set() : % == empty()
+ size() == 2^N

insert!(c, a) ==
(i := ord c) < N => (a(i) := true; a)
diff --git a/src/lisp/fricas-lisp.lisp b/src/lisp/fricas-lisp.lisp
index b0d8ac44..aded751a 100644
--- a/src/lisp/fricas-lisp.lisp
+++ b/src/lisp/fricas-lisp.lisp
@@ -28,6 +28,7 @@
(defun set-initial-parameters()
(setq debug:*debug-print-length* 1024)
(setq debug:*debug-print-level* 1024)
+ (setq extensions:*intexp-maximum-exponent* 2000000)
(setf *read-default-float-format* 'double-float))

#-:sbcl

Waldek Hebisch

unread,
Oct 18, 2023, 6:41:54 AM10/18/23
to fricas...@googlegroups.com
On Wed, Oct 18, 2023 at 06:14:03PM +0800, Qian Yun wrote:
> When running test suite with CMUCL, there's one error from finite.input:
>
> testTrue "testLookupIndex(CharacterClass)"
>
> Because it calls "size()$CharacterClass", which is "2^size()$Character",
> "2^1114112".
>
> First, for CMUCL it gives error because the exponent exceeds
> extensions:*intexp-maximum-exponent* (which is 10000).

Yes, this is way too small for our needs.


> That is unreasonably small, we should consider to loosen it.
>
> Second, since we limit number of possible Character in CharacterClass to
> be 256, then "size()$CharacterClass" should be "2^256" instead.

Well, it is not clear to me if Character and CharacterClass should be
Finite. At least operations tested by "finite.input" make almost
no sense in this case. Also, when using GCL we support Unicode
in differnent way than with other Lisps (Unicode characters are
_strings_ of bytes). So doing things differently than currently
used patterns is likely to led to failures. So we must accept
that Character and CharacterClass have no sound mathematical
structure. Or maybe invent a new mathematical structure for
them (but it is not clear if the gain justifies the effort).

BTW: For many years I was unable to run CMUCL, it crashed
on my machine doing things that we need. So any support is
from folks that can run it.

--
Waldek Hebisch

Qian Yun

unread,
Oct 18, 2023, 7:01:02 AM10/18/23
to fricas...@googlegroups.com


On 10/18/23 18:41, Waldek Hebisch wrote:
> On Wed, Oct 18, 2023 at 06:14:03PM +0800, Qian Yun wrote:
>> When running test suite with CMUCL, there's one error from finite.input:
>>
>> testTrue "testLookupIndex(CharacterClass)"
>>
>> Because it calls "size()$CharacterClass", which is "2^size()$Character",
>> "2^1114112".
>>
>> First, for CMUCL it gives error because the exponent exceeds
>> extensions:*intexp-maximum-exponent* (which is 10000).
>
> Yes, this is way too small for our needs.

Which value do you suggest to use instead?

>
>> That is unreasonably small, we should consider to loosen it.
>>
>> Second, since we limit number of possible Character in CharacterClass to
>> be 256, then "size()$CharacterClass" should be "2^256" instead.
>
> Well, it is not clear to me if Character and CharacterClass should be
> Finite. At least operations tested by "finite.input" make almost
> no sense in this case. Also, when using GCL we support Unicode
> in differnent way than with other Lisps (Unicode characters are
> _strings_ of bytes). So doing things differently than currently
> used patterns is likely to led to failures. So we must accept
> that Character and CharacterClass have no sound mathematical
> structure. Or maybe invent a new mathematical structure for
> them (but it is not clear if the gain justifies the effort).
>
> BTW: For many years I was unable to run CMUCL, it crashed
> on my machine doing things that we need. So any support is
> from folks that can run it.
>

CMUCL released version 21e 5 months ago, 4 years after 21d.
You may try the release binary.

- Qian

Waldek Hebisch

unread,
Oct 18, 2023, 7:40:25 PM10/18/23
to fricas...@googlegroups.com
On Wed, Oct 18, 2023 at 07:00:58PM +0800, Qian Yun wrote:
>
>
> On 10/18/23 18:41, Waldek Hebisch wrote:
> > On Wed, Oct 18, 2023 at 06:14:03PM +0800, Qian Yun wrote:
> > > When running test suite with CMUCL, there's one error from finite.input:
> > >
> > > testTrue "testLookupIndex(CharacterClass)"
> > >
> > > Because it calls "size()$CharacterClass", which is "2^size()$Character",
> > > "2^1114112".
> > >
> > > First, for CMUCL it gives error because the exponent exceeds
> > > extensions:*intexp-maximum-exponent* (which is 10000).
> >
> > Yes, this is way too small for our needs.
>
> Which value do you suggest to use instead?

Largest that works, say 2^29 or similar. FriCAS may easily
produce numbers having millions of digits, longer calculations
of this sort take way too much time, but same are doable and
final result may be reasonably small. To compute GCD of
univariate polynomials FriCAS encodes them in numbers and
computes GCD of corresponding numbers (this is called heugcd).
So any limit on size of numbers is also limit on size of
univariate polynomials.

Using GMP number of machine words in a single number is
(or at least used to be) bounded by what fits into 32-bit
integer.

--
Waldek Hebisch

Qian Yun

unread,
Oct 19, 2023, 6:28:24 AM10/19/23
to fricas...@googlegroups.com
For CMUCL, (expt 2 x) fails at "most-positive-fixnum" and a little
before that.

In CMUCL "most-positive-fixnum" is "2^29".

So apply the following patch?

- Qian

--- a/src/lisp/fricas-lisp.lisp
+++ b/src/lisp/fricas-lisp.lisp
@@ -28,6 +28,7 @@
(defun set-initial-parameters()
(setq debug:*debug-print-length* 1024)
(setq debug:*debug-print-level* 1024)
+ (setq extensions:*intexp-maximum-exponent* most-positive-fixnum)
(setf *read-default-float-format* 'double-float))

#-:sbcl

Waldek Hebisch

unread,
Oct 19, 2023, 7:06:06 AM10/19/23
to fricas...@googlegroups.com
On Thu, Oct 19, 2023 at 06:28:18PM +0800, Qian Yun wrote:
> For CMUCL, (expt 2 x) fails at "most-positive-fixnum" and a little
> before that.
>
> In CMUCL "most-positive-fixnum" is "2^29".
>
> So apply the following patch?

Yes
>
> - Qian
>
> --- a/src/lisp/fricas-lisp.lisp
> +++ b/src/lisp/fricas-lisp.lisp
> @@ -28,6 +28,7 @@
> (defun set-initial-parameters()
> (setq debug:*debug-print-length* 1024)
> (setq debug:*debug-print-level* 1024)
> + (setq extensions:*intexp-maximum-exponent* most-positive-fixnum)
> (setf *read-default-float-format* 'double-float))
>
> #-:sbcl
>

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages