knownInfo (conditionals in categories)

14 views
Skip to first unread message

Ralf Hemmecke

unread,
Dec 8, 2025, 11:32:56 AM12/8/25
to fricas-devel
Unfortunately the compiler does compile the Cat category, but
it cannot compile the domains.

Do I also have to lie about the exports as it is done in other part of
the library, for example here:

https://github.com/fricas/fricas/blob/master/src/algebra/catdef.spad#L329

?

Ralf

-----------------------------------------------------------

)abbrev category CAT Cat
Cat(S: SetCategory): Category == with
if S is Integer then foo: () -> Integer

)abbrev domain DOM1 Dom1
Dom1(S: SetCategory): Cat S with
bar: () -> Integer
== add
if S is Integer then foo(): Integer == 1
bar(): Integer == 1

)abbrev domain DOM2 Dom2
Dom2(S: SetCategory): with
if S is Integer then foo: () -> Integer
bar: () -> Integer
== add
if S is Integer then foo(): Integer == 1
bar(): Integer == 1

Waldek Hebisch

unread,
Dec 21, 2025, 8:51:33 AM12/21/25
to 'Ralf Hemmecke' via FriCAS - computer algebra system
On Mon, Dec 08, 2025 at 05:32:45PM +0100, 'Ralf Hemmecke' via FriCAS - computer algebra system wrote:
> Unfortunately the compiler does compile the Cat category, but
> it cannot compile the domains.
>
> Do I also have to lie about the exports as it is done in other part of the
> library, for example here:
>
> https://github.com/fricas/fricas/blob/master/src/algebra/catdef.spad#L329
>
> ?
>
> Ralf
>
> -----------------------------------------------------------
>
> )abbrev category CAT Cat
> Cat(S: SetCategory): Category == with
> if S is Integer then foo: () -> Integer
^^^^^^^^^^

This is reccuring trouble: compiler does not support 'is' conditions
in domain/category exports. Unfortunately, trouble is detected
only when you try to use such exports. Actually, this limition
is because compiler has trouble performing some reasonings with
such conditions.

BTW: your code seem to compile fine if I replace 'is Integer'
by 'has IntegerNumberSystem'.

--
Waldek Hebisch

Ralf Hemmecke

unread,
Jan 6, 2026, 11:37:23 AM (4 days ago) Jan 6
to fricas...@googlegroups.com, Peter Broadbery
Oh, maybe if it is only a problem for the exports, i.e. in the category
part, I can probably live with that weakness.
Can I still assume that it is only a weakness of the current compiler
and supposed to work in a proper implementation of the (not so specified
;-) ) SPAD language.

At least in the default package of a category, it seems to work.

https://github.com/aldorlang/aldor/blob/master/aldor/aldor/lib/libfoamlib/al/langx.as#L219

Maybe Peter Broadbery knows more about this and how strong the "is" is
in the Aldor language. I seem to remember that "is" was also not fully
supported in Aldor.

I don't know, in which way this IsPackage/TypePackag is used in Aldor

https://github.com/aldorlang/aldor/blob/master/aldor/aldor/lib/libfoamlib/al/langx.as#L219

https://github.com/aldorlang/aldor/blob/master/aldor/lib/axllib/src/al/langx.as#L224

https://github.com/aldorlang/aldor/blob/master/aldor/lib/debuglib/src/dbg_ltools.as#L12

Ralf

Peter Broadbery

unread,
Jan 7, 2026, 5:22:37 AM (3 days ago) Jan 7
to Ralf Hemmecke, fricas...@googlegroups.com
On Tue, 6 Jan 2026 at 16:37, Ralf Hemmecke <ra...@hemmecke.org> wrote:
>
> Oh, maybe if it is only a problem for the exports, i.e. in the category
> part, I can probably live with that weakness.
> Can I still assume that it is only a weakness of the current compiler
> and supposed to work in a proper implementation of the (not so specified
> ;-) ) SPAD language.
>
> At least in the default package of a category, it seems to work.
>
> https://github.com/aldorlang/aldor/blob/master/aldor/aldor/lib/libfoamlib/al/langx.as#L219
>
> Maybe Peter Broadbery knows more about this and how strong the "is" is
> in the Aldor language. I seem to remember that "is" was also not fully
> supported in Aldor.
>
> I don't know, in which way this IsPackage/TypePackag is used in Aldor
>

The Aldor compiler doesn't have specific support for 'is' - There is
only specific support for 'has'. Other conditions are dealt with
by carrying the condition forward, and evaluating at runtime. For a
second example, think of a condition like 'if prime? n' .. on a
ZmodN(n: Int) domain. The compiler won't call arbitrary code, so it
can't do a great deal with the condition except ensure that it is
checked at runtime.

Thus 'foo: A -> B if A is Integer' will be listed as an export of a
domain regardless of A, and to access the export it
would have to be guarded by 'if A is Integer', replacing A as needed.

I would like to improve on that, but there's other things on the path.
The current list is pattern matching, then removing the need to
declare function arguments and return types.

Peter
Reply all
Reply to author
Forward
0 new messages