login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxCombinat revision 8 of 8

1 2 3 4 5 6 7 8
Editor: kratt6
Time: 2008/06/12 08:15:32 GMT-7
Note: move species to new page


        

This page demonstrates one of the very early attempts to do something similar to MuPAD? combinat's "decomposable objects" in Aldor/Axiom. Meanwhile, we adopted the point of view of species, as shown on SandBoxSpecies

aldor
#include "axiom.as"
macro CCC == CombinatorialClassCategory; import from Integer; import from List Integer; import from OutputForm;
CombinatorialClassCategory: Category == with { list: Integer -> List %; count: Integer -> Integer; import from NonNegativeInteger; default count(i: Integer): Integer == (#list(i))::Integer; coerce: % -> OutputForm; }
Primitive(n: Integer): CombinatorialClassCategory == add { Rep == Integer; count(i: Integer): Integer == if i=n then 1 else 0; list(i: Integer): List % == if i=n then [per 1] else []; coerce(x: %): OutputForm == message(" ") }
Epsilon: CombinatorialClassCategory == Primitive(0) add;
Atom: CombinatorialClassCategory == Primitive(1) add;
UnionClass(S1: CCC, S2: CCC): CCC == add { Rep == Union(s1: S1, s2: S2); count(i: Integer): Integer == count(i)$S1 + count(i)$S2; import from Rep; import from List S1; import from List S2; list(i: Integer): List % == { result: List % := []; for a in list(i)$S1 repeat result := cons(per union a, result); for b in list(i)$S2 repeat result := cons(per union b, result); result; } coerce(x: %): OutputForm == { (rep x) case s1 => ((rep x).s1)::OutputForm; ((rep x).s2)::OutputForm; } }
CrossClass(S1: CCC, S2: CCC): with { CombinatorialClassCategory } == add { Rep == Record(t1: S1, t2: S2); count(i: Integer): Integer == { result := 0; for k in 1 .. i-1 repeat { result := result + count(k)$S1 * count(i-k)$S2; } result; } import from Rep; import from List S1; import from List S2; list(i: Integer): List % == { result: List % := []; for k in 1..i-1 repeat { for a in list(k)$S1 repeat { for b in list(i-k)$S2 repeat { result := cons(per record(a, b), result); } } } result; } coerce(x: %): OutputForm == { a := ((rep x).t1)::OutputForm; b := ((rep x).t2)::OutputForm; c: List OutputForm := [a, b]; vconcat [hconcat [hspace 1, message("o")], hconcat [hspace 1, message("/"), hspace 1, message("\")], hconcat [a,hspace 3,b]] } }
TreeClass: CombinatorialClassCategory == UnionClass(Atom, CrossClass(TreeClass, TreeClass) ) add;
aldor
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/386348539091125073-25px001.as using 
      AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4: 
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier `Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/zope2/var/LatexWiki/386348539091125073-25px001.as", line 4: import from Integer; ............^ [L4 C13] #9 (Error) No meaning for identifier `Integer'.
"/var/zope2/var/LatexWiki/386348539091125073-25px001.as", line 5: import from List Integer; ............^....^ [L5 C13] #10 (Error) There are no suitable meanings for the operator `List'. [L5 C18] #11 (Error) No meaning for identifier `Integer'.
"/var/zope2/var/LatexWiki/386348539091125073-25px001.as", line 6: import from OutputForm; ............^ [L6 C13] #12 (Error) No meaning for identifier `OutputForm'. [L6 C13] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

axiom
[count(i)$TreeClass for i in 1..7]
TreeClass is not a valid type.

axiom
)set output tex off
axiom
)set output algebra on
(list(5)$TreeClass)::List OutputForm
TreeClass is not a valid type.