WUPSI
Universal Popcorn SCSCP Interface –
The SCSCP Swiss Army Knife
Introduction
WUPSI is a little command line tool that shows the power of the org.symcomp.openmath and org.symcomp.scscp libraries. WUPSI can be used to access several SCSCP servers, perform computations on each of them, possibly in parallel, and exchange data between them, all using OpenMath and SCSCP.
Moreover, since we have both binaries and source code available, it could serve as a good entry point to learn about the possibilities offered by the libraries.
Features
The WUPSI has the following features:
- It can connect to arbitrary many SCSCP servers;
- OpenMath/Popcorn commands entered are sent to a selected server, and the response is returned;
- Results can be transferred between different servers;
- Information on standard OpenMath symbols can be retrieved;
- Computations can be parallelized on different systems;
- Can act as a manual SCSCP server itself – great for debugging clients;
- ...and some more...
Commands
After starting WUPSI you get a command line prompt where the following commands can be issued:
Using SCSCP servers
- connect <host>[:port] as <name>
- connects to the SCSCP Server running on the given host and the given port (defaults to 26133) using the symbolic name name. This name can later be used to access the system.
- use <name>
- switches to the system with the symbolic name name. Commands issued thereafter are evaluated by that system.
- disconnect <name>
- disconnects the WUPSI from the system with the symbolic name name.
- show systems
- shows a list of all connected systems with the associated symbolic names. The currently active system is marked with an asterix.
Using locally stored objects
The WUPSI can not only execute commands on different systems but also has the ability to transport the results from one system to an other by doing variable replacement in the input.
- local <var> := <code>
- evaluates the given code in the active system and assigns the result to the WUPSI-local variable var. Whenever that variable occurs in the input later in that session, it is replaced by the above result.
- alias <var> := <code>
- assigns the given code to the WUPSI-local variable var without any evaluation. Whenever that variable occurs in the input later in that session, it is replaced by the code.
- show locals
- gives a list of all locally stored variables and their values.
OpenMath information
The WUPSI contains some commands to get information on OpenMath symbols.
- describe <cd>
- gives information on the given CD cd as found on openmath.org/cd.
- describe <cd>.<name>
- gives information on the given OpenMath symbol name from the CD cd as found on openmath.org/cd. The examples from the documentation are stored in the WUPSI-local variables $_examplen.
- show examples
- gives a list of all locally stored examples and their values.
Misc
- output format <popcorn|latex|xml>
- switches the format of all output to the given format.
- print <code>
- outputs the given code using the current output format. No evaluation is performed.
- show history
- gives a list of all inputs and outputs of the current session. Note that they can be used in any input with $_inn and $_outn respectively.
- quit
- disconnects all attached systems and quits.
Simple Parallel SCSCP Dispatcher
The WUPSI offers simple poor-mans-parallelization facilities called Simple Parallel SCSCP Dispatcher (SPSD) which can be used to distribute computations on (some) attached systems.
- spsd start as <name>
- internally starts the SPSD and connects it using the symbolic name name.
- spsd add {<name>|*}
- adds the system identified by the symbolic name name to the SPSDs list of systems. To these systems the computations are distributed.
- spsd show
- gives a list of all systems that are attached to the SPSD.
- spsd clear
- removes all previously added systems from the SPSD.
- spsd start server <port>
- opens an SCSP server on the given port allowing SCSCP clients to connect to the SPSD.
Whilst for all the other systems the normal OpenMath symbols are used, there are (currently three) special commands for the SPSD:
- spsd.map(<list>, <expression>)
- maps the expression on every element of the list and returns the list of applications evaluated by the systems attached to the SPSD.
- spsd.zip(<list>, <list>, <expression>)
- as spsd.map, but does a classical zip.
- spsd.all_pairs(<list>, <list>, <expression>)
- as spsd.map but iterates over the cartesian product.
Command Line Options
Every reasonable command line tool should accept a couple of command line options, so does The WUPSI:
- -Q (--quit-on-eof)
- When reading from a file, quit when EOF is reached, otherwise the WUPSI switches to prompt.
- -a (--atomic)
- when reading from a file, treat the whole file as one input, otherwise every line is considered one line of input and interpreted sequentially.
- -c (--connect) <url>[:port] <name>
- connects to system running at specified url and port, assigning the given name.
- -d (--communication-directory) <directory>
-
the WUPSI observes the given directory and reads in<n> files from that directory
and writes the result to out<n> files there. The numbers n must be sequential
integers beginning with 1.
This mode can be used to implement a poor-mans-asynchronous SCSCP connection. - -f (--output-format) <xml|popcorn|latex>
- sets the initial output format.
- -i (--input) <file>
- read input from the file file instead of prompt.
- -o (--output) <file>
- write output to the file file instead of console.
- -q (--quiet)
- print only results and errors.
- -s (--interactive-scscp-server) <port>
- starts an SCSCP server on the given port, where you can answer incoming requests by hand. All other options are ignored.
- -w (--webserver) <port>
- starts a webserver on the given port. This feature is highly experimental and doesn't work properly in the current versions.
Sample Session
This is a little sample session:
WUPSI 1.2-SNAPSHOT -- Wonderful Universal Popcorn SCSCP Interface
(c) 2009 D. Roozemond & P. Horn
WUPSI[n/a]0> connect secret.tu-berlin.de as kant
# connected to 'secret.tu-berlin.de' on port '26133' using symbolic name 'kant'
# Service Info: service Name 'libkant', service version '4.0'
WUPSI[kant]0> integer2.euler(2^256-1)
57805503728904671397642927489340558870867595095716337830124498956098469888000
WUPSI[kant]1> connect 127.0.0.1:26136 as magma
# connected to '127.0.0.1' on port '26136' using symbolic name 'magma'
# Service Info: service Name 'Magma', service version '0.2.0'
WUPSI[magma]1> 3+4*8
35
WUPSI[magma]2> connect 127.0.0.1:26135 as gap
# connected to '127.0.0.1' on port '26135' using symbolic name 'gap'
# Service Info: service Name 'GAP', service version '4.dev'
WUPSI[gap]2> 12*12*12
1728
WUPSI[gap]3> connect 127.0.0.1 as mupad
# connected to '127.0.0.1' on port '26133' using symbolic name 'mupad'
# Service Info: service Name 'MuPAD', service version '1.1.0-mupad-4.5.0'
WUPSI[mupad]3> sum(1 .. infinity, lambda[$x -> 1/$x^2])
pi^2*1//6
WUPSI[mupad]4> local $p := 2^127-1
# Stored this in local variable '$p':
170141183460469231731687303715884105727
WUPSI[mupad]5> show systems
# name, serviceName, serviceVersion, host, port
# kant, libkant, 4.0, muck.math.tu-berlin.de, 26133
# magma, Magma, 0.2.0, 127.0.0.1, 26136
# * mupad, MuPAD, 1.1.0-mupad-4.5.0, 127.0.0.1, 26133
# gap, GAP, 4.dev, 127.0.0.1, 26135
WUPSI[mupad]5> use gap
# switched to system with symbolic name 'gap', service Name 'GAP', service version '4.dev'.
WUPSI[gap]5> local $a := integer2.euler($p)
# Stored this in local variable '$a':
170141183460469231731687303715884105726
WUPSI[gap]6> use magma
# switched to system with symbolic name 'magma', service Name 'Magma', service version '0.2.0'.
WUPSI[magma]6> $p-$a
1
WUPSI[magma]7> show history
# name = value
# $_in0 = integer2.euler(2^256-1)
# $_out0 = 57805503728904671397642927489340558870867595095716337830124498956098469888000
# $_in1 = 3 + 4*8
# $_out1 = 35
# $_in2 = 12*12*12
# $_out2 = 1728
# $_in3 = sum(1 .. infinity, lambda[$x -> 1/$x^2])
# $_out3 = pi^2*1//6
# $_in4 = 2^127-1
# $_out4 = 170141183460469231731687303715884105727
# $_in5 = integer2.euler(170141183460469231731687303715884105727)
# $_out5 = 170141183460469231731687303715884105726
# $_in6 = 170141183460469231731687303715884105727-170141183460469231731687303715884105726
# $_out6 = 1
WUPSI[magma]7> describe arith1.sum
# -- Description for 'arith1.sum' --
An operator taking two arguments, the first being the range of summation, e.g. an integral
interval, the second being the function to be summed. Note that the sum may be over an
infinite interval.
# Example $_example0
sum(1 .. 10, lambda[$x -> 1/$x])
# -- END description for 'arith1.sum' --
WUPSI[magma]7> use mupad
# switched to system with symbolic name 'mupad', service Name 'MuPAD',
# service version '1.1.0-mupad-4.5.0'.
WUPSI[mupad]7> $_example0
7381//2520
WUPSI[mupad]8> spsd start as spsd
# connected to SPSD using symbolic name 'spsd'
# Service Info: service Name 'SPSD', service version '1.1-SNAPSHOT'
WUPSI[spsd]8> use mupad
# switched to system with symbolic name 'mupad', service Name 'MuPAD',
# service version '1.1.0-mupad-4.5.0'.
WUPSI[mupad]8> local $L := list1.map( lambda[$x -> 2^$x-1], [127, 128, 129, 130, 131, 132,
133, 140, 150, 178, 190])
# Stored this in local variable '$L':
[170141183460469231731687303715884105727, 340282366920938463463374607431768211455, 680564733...
841876926926749214863536422911, 1361129467683753853853498429727072845823, 2722258935367507...
707706996859454145691647, 5444517870735015415413993718908291383295, 1088903574147003083082...
7987437816582766591, 1393796574908163946345982392040522594123775, 142724769270595988105828...
5969449495136382746623, 383123885216472214589586756787577295904684780545900543, 1569275433...
846670190958947355801916604025588861116008628223]
WUPSI[mupad]9> use spsd
# switched to system with symbolic name 'spsd', service Name 'SPSD',
# service version '1.1-SNAPSHOT'.
WUPSI[spsd]9> spsd add *
# Adding system 'kant'.
# Adding system 'magma'.
# Cowardly refusing to add SPSD system 'spsd'
# Adding system 'mupad'.
# Adding system 'gap'.
WUPSI[spsd]9> local $LL := spsd.map($L, integer2.euler)
# Stored this in local variable '$LL':
[170141183460469231731687303715884105726, 169875107699410294159549716941399654400, 581927582...
004916421205221005414979612640, 791833580987845895506908728919000000000, 27119081409364525...
45320278240216677456816, 2130814449589208731131236058088995815424, 10803274696870990546240...
110208762211434488, 581260973292210752459947423825920000000000, 70602279453054509863127040...
0000000000000000000, 253989014781997548434459439986749512837204317295605760, 9151689435015...
14978248691569036190108113490116440000000000]
WUPSI[spsd]10> spsd.zip($L, $LL, arith1.minus)
[1, 170407259221528169303824890490368557055, 98637151836960505721528209448556810271, 5692958...
86695907958346589700808072845823, 10350794431055162386718619237468234831, 3313703421145806...
684282757660819295567871, 85761044599040284587877229054371332103, 812535601615953193886034...
968214602594123775, 721224898175414782427015569449495136382746623, 12913487043447466615512...
7316800827783067480463250294783, 654106490345155212710255786765726495912098744676008628223]
Licensing
The WUPSI was written by Peter Horn, University of Kassel, and Dan Roozemond, Technical University Eindhoven as a part of the software developed for the SCIEnce EU project.
The WUPSI is published under the Apache 2 License and thus can be used free of charge.
If you have any suggestions on how to improve WUPSI, please feel free to contact us.