New Category OutputForm

19 views
Skip to first unread message

Prof. Dr. Johannes Grabmeier privat

unread,
Mar 27, 2019, 12:05:42 PM3/27/19
to fricas...@googlegroups.com
Dear all,

I am just adding and correcting feature to basic algebraic domains, e.g.
SAE, LocalAlgebra and Fraction, as for example simplification
is not implemented yet for certain non standard situations, (already
fixed):


(1) -> x : UTS(FRAC INT, 'x, 0)
                                                                                         
Type: Void
(2) -> u := 1+x

   (2)  1 + x
                                                 Type:
UnivariateTaylorSeries(Fraction(Integer),x,0)
(3) -> v := x+x^2

             2
   (3)  x + x
                                                 Type:
UnivariateTaylorSeries(Fraction(Integer),x,0)
(4) -> u/v

         1 + x
   (4)  ------
             2
        x + x
                                       Type:
Fraction(UnivariateTaylorSeries(Fraction(Integer),x,0))
(5) -> uInv := recip u

                 2    3    4    5    6    7    8    9    10      11
   (5)  1 - x + x  - x  + x  - x  + x  - x  + x  - x  + x   + O(x  )
                                      Type:
Union(UnivariateTaylorSeries(Fraction(Integer),x,0),...)

To this end I came to change the output of SAE - and for that I invented
a Category, which easily
allows the user to change the coercion to OutputForm. I suggest to
include that into the system
to be able to use that on several places, e.g. different form of
permutation representations as
Lehmer code (e.g.).

Here is an example:

(101) -> x

           +-+
   (101)  \|2
                    Type:
SimpleAlgebraicExtension(Integer,UnivariatePolynomial(x,Integer),x^2+(-2))
(102) -> x+3

           +-+
   (102)  \|2  + 3
                    Type:
SimpleAlgebraicExtension(Integer,UnivariatePolynomial(x,Integer),x^2+(-2))
(103) -> (x+3)^2

             +-+
   (103)  6 \|2  + 11
                    Type:
SimpleAlgebraicExtension(Integer,UnivariatePolynomial(x,Integer),x^2+(-2))
(104) -> setOutputType("rel")$S

   (104)  "rel"
                                                                                       
Type: String
(105) -> (x+3)^2

                        2
   (105)  6 ζ + 11  |  ζ  - 2  = 0
                    Type:
SimpleAlgebraicExtension(Integer,UnivariatePolynomial(x,Integer),x^2+(-2))
(106) -> setOutputType("poly")$S

   (106)  "poly"
                                                                                       
Type: String
(107) -> (x+3)^2

   (107)  6 x + 11
                    Type:
SimpleAlgebraicExtension(Integer,UnivariatePolynomial(x,Integer),x^2+(-2))


Actually, I even suggest to use the nice "rel" variant as the standard.
Can we in general rely on
UTF greek symbols?

Here is the code of the Category.

-- Copyright (c) 2019 J. Grabmeier
-- All rights reserved.
-- version 1 25.03.2019

)abbrev category OUTTYPE OutputType

++ Author: J. Grabmeier
++ Date Created:
++ Date Last Updated:
++ Basic Functions:
++ Related Constructors:
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description:
++   provides environment for user choosable output types of the objects.
OutputType(opT: List String): Category == with
  --operations
    outputType: () -> String
      ++ setOutputType changes the output type.
    setOutputType: String -> String
      ++ setOutputType changes the output type.
  add
    --if empty? opT then error "OutputType: Argument must be a non empty
list of strings."
    msg: OutputForm := commaSeparate [message(op) for op in opT]
    msg := blankSeparate [message "OutputType: Improper value, correct
values are", msg]
    referenceOutputType: Reference String := ref first opT
    outputType(): String == deref referenceOutputType
    setOutputType(st: String): String ==
      correctType? : Boolean := false
      lb : List Boolean := [st = tp for tp in opT]
      correctType? := correctType? or reduce(_or, lb)
      if correctType?
        then referenceOutputType := ref st
        else print msg
      st

--
Mit freundlichen Grüßen

Johannes Grabmeier

Prof. Dr. Johannes Grabmeier
Köckstraße 1, D-94469 Deggendorf
Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756
Tel. +49-(0)-991-3615-141 (d), Fax: +49-(0)-32224-192688

Prof. Dr. Johannes Grabmeier privat

unread,
Mar 27, 2019, 12:07:01 PM3/27/19
to fricas...@googlegroups.com
sorry, the new category is named OutputType


-------- Weitergeleitete Nachricht --------
Betreff: New Category OutputForm
Datum: Wed, 27 Mar 2019 17:05:33 +0100
Von: Prof. Dr. Johannes Grabmeier privat <joha...@grabmeier.net>
An: fricas...@googlegroups.com

Waldek Hebisch

unread,
Jun 9, 2019, 1:35:28 PM6/9/19
to fricas...@googlegroups.com
Johannes Grabmeier wrote:
>
> I am just adding and correcting feature to basic algebraic domains, e.g.
> SAE, LocalAlgebra and Fraction,

> To this end I came to change the output of SAE - and for that I invented
> a Category, which easily
> allows the user to change the coercion to OutputForm. I suggest to
> include that into the system
> to be able to use that on several places, e.g. different form of
> permutation representations as
> Lehmer code (e.g.).

This is rather unusual code. AFAICS it uses default package
to esentially "inject" extra state into domains. I do not
see why you think we need such extraordinay approach.
Namely, idea of OutputForm was to capture _structure_ of
the output so that different surface forms can be produced
on demand. Things like greek letters, and similar could be
handled at OutputForm level. If needed we can enrich
OutputForm to allow more features.

On more general level, FriCAS is divided into large number of
domians and categories. That way a lot of things can be
changed in one part without affecting other parts. But to
have usable complete system other things need coordination.
In particular, we need consistent way to control output.
Current system is somewhat rigid, but IMO resonably clear.
Designing more flexible system we need to make clear what
protocol is in use, what are responsibilities of domains,
what will be done by "central" code (like OutputForm and
formatters), at which point code should look at user preferences,
etc. Without clear design next people extending system
will not know what to do and likely try different ways,
leading to incomprehensible mess.

IIUC you have an implementation. So as first step in explaining
your design you could post all code needed to reproduce
the examples.

Best wishes

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