Dear FriCAS developers,
1. For the program
---------------------------------------------------- t.spad ---------
DomConstr ==> Union(Symbol, FrConstr, UPConstr)
)abbrev domain FRCONS FrConstr
FrConstr(d : DomConstr) : DomConstr with frConstrArg : () -> DomConstr
== add
frConstrArg() == d
---------------------------------------------------------------------
(where DomConstr is erroneously set instead of SetCategory before `with')
the FriCAS-1.1.6 compiler reports
...
initializing NRLIB FRCONS for FrConstr
compiling into NRLIB FRCONS
>> System error:
The index 2 is too large.
The message does not look helpful for an user.
2. I have a beginner question about a user data type
----------------------------------------------------
I need to define a type DomConstr for the domain construction
descriptions, for a fixed small listed set of standard domain
constructors -- so far, let them be
Integer, Fraction, UP.
For example,
UP'(x, Fr(Int')) : DomConstr
expresses the construction of the domain UP(x, Fraction INT),
where UP', Fr', Int' are the type constructors which yield a domain
construction from other domain constructions and parameters.
Each tag (UP', POLY', Fr, ResidueRingConstr ...) has its particular
argument tuple of the parameters and constructions.
In Haskell, I define this type recursively, and as a disjoint union:
data DomConstr = Basic Symbol | Fr DomConstr | UP' Symbol DomConstr
And the above example of UP'(x, Fr(Int')) : DomConstr expresses as
(UP' x (Fr (Basic Int'))) :: DomConstr
Here Basic, UP', Fr are explicit user data tags.
The user program can build such data in this way, and also analyze them.
Example 1:
f constr = case constr of (UP' _ dom) -> dom
(Fr dom) -> dom
extracts from cons the coefficient domain construction -- if UP' is
at the top, and extracts the argument domain construction -- if Fr is at
the top.
Example 2: extractVariable constr = case constr of (UP' x _) -> Just x
_ -> Nothing
What is an adequate type (domain) description in Spad ?
I am trying
--------------------------------------------------------
category WithConstrSymbol ... Join SetCategory with
constrSymbol : () -> Symbol
-- the syntax needs correction
DomConstr ==> Union(Symbol, FrConstr, UPConstr)
-- instead of disjoint union?
)abbrev domain FRCONS FrConstr
FrConstr(d : DomConstr) : WithConstrSymbol with
frConstrArg : () -> DomConstr
== add
constrSymbol() == "Fr" :: Symbol
frConstrArg() == d
)abbrev domain UPCONS UPConstr
UPConstr(x : Symbol, d : DomConstr) : WithConstrSymbol with
upConstrVar : () -> Symbol
upCoefConstr : () -> DomConstr
== add
constrSymbol() == "UP'" :: Symbol
upConstrVar() == x
upCoefConstr() == d
--------------------------------------------------------
And I am going to build constructions like this:
constr := UPConstr(x, FrCons("Int" :: Symbol))
And to analyse it like this
f(constr) ==
constr case of Fr =>
constr' := frConstrArg constr
process the argument construction constr'
constr case of UP' =>
x := upConstrVar constr
cConstr := upConstrCoef constr
process x and the coefficient domain construction cConstr
This approach looks rather complex, and even requires to introduce a
category.
I thought of SExpression. But, for example,
convert[UP', x, coefConstr'] :: SExpressin
requires of UP', x, constr' to be of the same type. Right?
One neds to union the constructor tags, parameters (like x),
and domain constructions into a certain type U, and to program
processing the data in List U ...
Please, what may be an adequate way?
Thank you in advance for advice,
------
Sergei
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.