Tableau and pile in OutputForm

11 views
Skip to first unread message

Prof. Dr. Johannes Grabmeier

unread,
Sep 23, 2024, 2:21:11 AM9/23/24
to fricas...@googlegroups.com
Hi all,

want to improve domain Tableau, e.g. the current output of tableaux.
However, this uses pile of OutputForm, which always starts a new line.
The behaviour of matrices is different. Is there a way to output the
rows of a tableau in pile form (like in matrices), but WITHOUT a new
line as it is the case for matrices. Some magic LISP? pile uses SC,
matric uses MATRIX.

(21) -> t2 := tableau [[0,3,5,7,8],[1,4,6],[2]]

   (21)
   +---+ +---+ +---+ +---+ +---+
   | 0 | | 3 | | 5 | | 7 | | 8 |
   +---+ +---+ +---+ +---+ +---+
   +---+ +---+ +---+
   | 1 | | 4 | | 6 |
   +---+ +---+ +---+
   +---+
   | 2 |
   +---+
                                                                  
Type: Tableau(NonNegativeInteger)
(22) -> [t1, t2]

   (22)
   [
     +---+ +---+ +---+
     | 0 | | 3 | | 5 |
     +---+ +---+ +---+
     +---+ +---+ +---+
     | 1 | | 4 | | 6 |
     +---+ +---+ +---+
     +---+
     | 2 |
     +---+
     ,

     +---+ +---+ +---+ +---+ +---+
     | 0 | | 3 | | 5 | | 7 | | 8 |
     +---+ +---+ +---+ +---+ +---+
     +---+ +---+ +---+
     | 1 | | 4 | | 6 |
     +---+ +---+ +---+
     +---+
     | 2 |
     +---+
     ]

(27) -> m1 := matrix [[0,3,5],[1,4,6],[2,0,0]]

         +0  3  5+
         |       |
   (27)  |1  4  6|
         |       |
         +2  0  0+
Type: Matrix(NonNegativeInteger)
(28) -> m2 := matrix [[0,3,5,7,8],[1,4,6,0,0],[2,0,0,0,0]]

         +0  3  5  7  8+
         |             |
   (28)  |1  4  6  0  0|
         |             |
         +2  0  0  0  0+
Type: Matrix(NonNegativeInteger)
(29) -> [m1,m2]

          +0  3  5+  +0  3  5  7  8+
          |       |  |             |
   (29)  [|1  4  6|, |1  4  6  0  0|]
          |       |  |             |
          +2  0  0+  +2  0  0  0  0+
Type: List(Matrix(NonNegativeInteger))

--
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
Fax: +49-(0)-991-2979592

Ralf Hemmecke

unread,
Sep 23, 2024, 3:20:18 AM9/23/24
to fricas...@googlegroups.com
Maybe this is not what you want, but if you mean to
list the tableaux horizontally, you can use Format2D as follows.

setFormats!([Formatter Format2D] pretend
List(OutputFormatterCategory))$FormattedOutput
)set output formatted on
)set output algebra off
t1 := tableau [[0,3,5],[1,4,6],[2]]
t2 := tableau [[0,3,5,7,8],[1,4,6],[2]]
[t1,t2]

[+---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+]
[| 0 | | 3 | | 5 |, | 0 | | 3 | | 5 | | 7 | | 8 |]
[+---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+]
[+---+ +---+ +---+ +---+ +---+ +---+ ]
[| 1 | | 4 | | 6 | | 1 | | 4 | | 6 | ]
[+---+ +---+ +---+ +---+ +---+ +---+ ]
[+---+ +---+ ]
[| 2 | | 2 | ]
[+---+ +---+ ]

Type: List(Tableau(NonNegativeInteger))


Format2D does not yet respect the set linelength and will (currently)
print the output without breaking it.

Actually, I would claim, that the output of Tableau is broken in another
aspect.

%%% (11) -> t1 := tableau [[0,3,5],[1,4444,6],[2]]


+---+ +---+ +---+
| 0 | | 3 | | 5 |
+---+ +---+ +---+
+---+ +------+ +---+
| 1 | | 4444 | | 6 |
+---+ +------+ +---+
+---+
| 2 |
+---+

Right, it should be more resemble MATRIX, but with frames.
As far as I know the output of MATRIX is done for the algebra output by
a special piece of code. You would have to invent something like MATRIX
but without the outer parentheses to get a grid. PILE is certainly the
wrong OutputForm.

Ralf

Ralf Hemmecke

unread,
Sep 23, 2024, 5:09:15 AM9/23/24
to fricas-devel
On 9/23/24 09:57, Prof. Dr. Johannes Grabmeier wrote:
> hence, it is really the matrix function of OutputForm, which uses an
> appropriate Lisp-function labelled by symbol 'MATRIX.

It is actually still not completely clear what you want to achieve.

As one of the early AXIOM users, you certainly know about the OutputForm
mechanism.

What I wanted to say is that the transformation of a tableau into
OutputForm is IMHO already wrong independent of what the output routine
will be. This pile of lines in which each line is a concatenated (by
spaces) list of the row items has no information of a grid structure as
the MATRIX operator would have.

https://github.com/fricas/fricas/blob/master/src/algebra/tableau.spad#L31

A matrix is represented by a special OutputForm that is represented via
'MATRIX in the first position.

https://github.com/fricas/fricas/blob/master/src/algebra/tableau.spad#L31

Any formatter can then decide what to do with this special form.
If a formatter gets the 'SC (the OutputForm for pile), it is already to
late, since a pile means: put lines on top of each other.

> So, my question is really to the Lisp experts, are there other
> functions in Lisp which provice a pile without a new line. Or: how is
> MATRIX output implemented and how can it be modified for this purpose
> to have a proper output for tableaus.

Honestly, I would be much more happy if the tableau itself would
be output like

+---+------+---+
| 0 | 3 | 5 |
+---+------+---+
| 1 | 4444 | 6 |
+---+ -----+---+
| 2 |
+---+

instead of showing a frame around each element.

Whether it breaks after each comma when several tableaux are put into a
list, is another problem, that can probably be solved by splitting the
code that handles 'MATRIX into something that handles the grid structure
and then puts it into paren to add the parentheses around that grid.
I guess, that would not be a very big change.

I think you can find/modify/adapt the matrix code in
src/interp/i-output.boot around the function "appmat".

Ralf




On 9/23/24 09:57, Prof. Dr. Johannes Grabmeier wrote:
> thanks Ralf for the quick answer! I had solved the other other aspect
> already by using the width of an output form.
>
> The algebra code for matrices traces back to (category:
> TwoDimensionalArrayCategory)
>
> if R has CoercibleTo(OutputForm) then
>
> coerce(m : %) ==
> l : List List OutputForm
> l := [[qelt(m, i, j) :: OutputForm _
> for j in minColIndex(m)..maxColIndex(m)] _
> for i in minRowIndex(m)..maxRowIndex(m)]
> matrix l
>
> hence, it is really the matrix function of OutputForm, which uses an
> appropriate Lisp-function labelled by symbol 'MATRIX. So, my question is
> really to the Lisp experts, are there other functions in Lisp which
> provice a pile without a new line. Or: how is MATRIX output implemented
> and how can it be modified for this purpose to have a proper output for
> tableaus.
>
> Johannes

Prof. Dr. Johannes Grabmeier

unread,
Sep 24, 2024, 4:54:01 AM9/24/24
to fricas...@googlegroups.com
I started to manipulate i-output.boot

by copying the code for appmat to apptableau and changing symbol MATRIX
to TABLEAU, I added a function tableau to OutputForm as matrix there and
then tried to use it for a List List OutputForm:

The following error occured:

   >> System error:
   MAT does not designate a condition class.

So no clue what has to be done next.


The other way I succeeded was to use matrix and fill the empty fields
with an empty space to get a whole matrix. This gives a first reasonable
result as:

(203) -> )set output length 100
(203) -> tableau [[2,44444,3,5],[1,2,5555555],[22222]]

          +       2     44444         3         5+
          |                                      |
   (203)  |       1         2   5555555          |
          |                                      |
          +   22222                              +
Type: Tableau(PositiveInteger)
(204) -> [%, T2, conjugate T2]

+ 0   1   2+
|          |
           +       2     44444         3         5+  + 0   3   4 5  
6+  | 3   7    |
           |                                      | |                 
|  |          |
   (204)  [|       1         2   5555555          |, | 1   7 8       
|, | 4   8    |]
           |                                      | |                 
|  |          |
           +   22222                              +  + 2               
+  | 6        |
|          |
+ 5        +
                                                             Type:
List(Tableau(NonNegativeInteger))


Am 23.09.24 um 14:53 schrieb Prof. Dr. Johannes Grabmeier:
> Am 23.09.24 um 11:09 schrieb Ralf Hemmecke:
>> On 9/23/24 09:57, Prof. Dr. Johannes Grabmeier wrote:
>>> hence, it is really the matrix function of OutputForm, which uses an
>>>  appropriate Lisp-function labelled by symbol 'MATRIX.
>>
>> It is actually still not completely clear what you want to achieve.
>
> this was very clear: a function in LISP/mechanism in OutputForm which
> piles a list of outputs WITHOUT a newline first, as I said, like
> printing a matrix
>
>>
>> As one of the early AXIOM users, you certainly know about the OutputForm
>> mechanism.
>
> I never programmed in BOOT/LiSP, I had hoped that something is there
> already
>
>>
>>    +---+------+---+
>>    | 0  |     3 | 5 |
>>    +---+------+---+
>>    | 1 | 4444 | 6 |
>>    +---+ -----+---+
>>    | 2 |
>>    +---+
>>
> of course the current solution is not good, I already have an output
> without any boxes taking care of the widths of the entries.
>
>
>> I think you can find/modify/adapt the matrix code in
>> src/interp/i-output.boot around the function "appmat".
>
> no idea what exactly is going on there, probably a lot of efford to
> try to understand boot, I glanced at it, but would need much more work-
>
>
> Johannes
Reply all
Reply to author
Forward
0 new messages