Author Archive for Peter

Tech-Blogposts

I currently stopped writing here, but you may find some (mainly Ruby-related) posts in the metaminded blog.

org.symcomp.java version 1.4 released

We just released a new version of the org.symcomp.java libraries for handling OpenMath and providing SCSCP services. It contains a lot of bugfixes.
For those who love to live on the bleeding edge, we now also have a git repository for the OpenMath part.

The WUPSI

Some days ago, we finally released WUPSI 1.3, the first public release of this Universal Popcorn SCSCP Interface.

Now, I’m busy coding a web interface based on Cappuccino. If you haven’t heard of Cappuccino, I highly suggest having a look at this video. It’s a really impressive piece of software!

News from the SCIEnce

I want to give a quick survey on the/my SCIEnce activities in the last time

POPCORN for OpenMath

Introduction

This is slightly outdated, for a detailed overview see The Popcorn OpenMath Representation.

Whenever you come to manually typing OpenMath (which appears to happen rather frequently in the SCIEnce-Project), it’s rather annoying. On the other hand, there is a widly used kind of syntax for mathematical expressions known from computer-algebra-systems as Maple or MuPAD. The idea of popcorn is to use a derivation of this intuitive syntax and write a converter that creates Openmath from it.
So, e.g., POPCORN translates 1+#a to

<OMA><OMS cd="arith1" name="plus" /><OMI>1</OMI><OMV name="a" /></OMA>

 

transforming something small into something huge — which partly motivates the name. On the other Hand, POPCORN is an acronym for Possibly Only Practicable Convenient OpenMath Replacement Notation.

Important Information

POPCORN is by no means meant to replace OpenMath — it merely offers the possibility to type-the-way-you-think and get syntactically valid OpenMath with the desired meaning. So, it is mainly a rewrite-engine.

Syntax

  • OMI and OMF — Integers and Floats: For integers and floats, POPCORN uses the naive syntax: simply type them: 
    POPCORN OpenMath
    13 <OMI>13</OMI>
    1.234e10 <OMF dec=”1.234E10″ />
    (-2413) <OMI>-2413</OMI>
    (-1.234e-10) <OMF dec=”-1.234E10″ />

    Please note, that currently all negative numbers need to be paranthesized

  • OMSTR — Strings: Strings are encoded by putting them into ” or ‘, currently there is no support for escaping characters:
  • POPCORN OpenMath
    “HALLO” <OMSTR>HALLO</OMSTR>
    ‘Hello World!’ <OMSTR>Hello World!</OMSTR>
  • OMS — Symbols: for the symbols POPCORN uses a C-struct-accessor-inspired syntax: cdname.symbolname:
    POPCORN OpenMath
    arith1.plus <OMS cd=”arith1″ name=”plus” />
    stransc1.sin <OMS cd=”transc1″ name=”sin” />

    Please note, that POPCORN does not ensure, that the cd or the symbol exist in some CD.

  • OMV — Variables: for variables POPCORN uses the # prefix:
  • POPCORN OpenMath
    $X <OMR href=”X” />
    #FunnyVarName <OMV name=”FunnyVarName” />
  • OMR and id — References and id: to encode References, POPCORN uses the $-prefix, to actually set the id of some object, it uses a :id-postfix:
    POPCORN OpenMath
    13:X <OMI id=”X” >13</OMI>
    #X <OMV name=”X” />
    arith1.plus:reff <OMS cd=”arith1″ name=”plus” id=”reff” />
    $reff <OMV name=”reff” />

    Please note, that POPCORN does not validate the existence or uniqueness of references . Neither does it check for circular references.

  • OMA — Application: to encode the application of a symbol to some objects, POPCORN uses the usual f(x)-kind-of-syntax:
    POPCORN OpenMath
    transc1.sin(3.14) <OMA>
    <OMS cd=”transc1″ name=”sin” />
    <OMF dec=”3.14″ /&gt
    </OMA>
    arith1.plus(1,2) <OMA>
    <OMS cd=”arith1″ name=”plus” />
    <OMI>1</OMI>
    <OMI>2</OMI>
    </OMA>
  • OMBIND — Binding: to encode the binding, POPCORN uses the syntax: symbol[va1, ..., varn -> expr]:
    POPCORN OpenMath
    fns1.lambda[#x -> #x + 1] <OMBIND>
    <OMS cd=”fns1″ name=”lambda” />
    <OMBVAR>
    <OMV name=”x” />
    </OMBVAR>
    <OMA>
    <OMS cd=”arith1″ name=”plus” />
    <OMV name=”x” />
    <OMI>1</OMI>
    </OMA>
    </OMBIND>
    fns1.lambda[#x, #y -> #x*#y] <OMBIND>
    <OMS cd=”fns1″ name=”lambda” />
    <OMBVAR>
    <OMV name=”x” />
    <OMV name=”y” />
    </OMBVAR>
    <OMA>
    <OMS cd=”arith1″ name=”times” />
    <OMV name=”x” />
    <OMV name=”y” />
    </OMA>
    </OMBIND>
  • OMATTR — Attribution: to encode the attribution of some expressions, POPCORN uses the syntax: expr{k1 -> v1, ..., kn -> vn}:
    POPCORN OpenMath
    1{‘a’ -> 1} <OMATTR>
    <OMATP>
    <OMSTR>a</OMSTR>
    <OMI>1</OMI>
    </OMATP>
    <OMI>1</OMI>
    </OMATTR>
    (tr1.sin(3.14)){ann.appr -> 0} <OMATTR>
    <OMATP>
    <OMS cd=”ann” name=”appr” />
    <OMI>0</OMI>
    </OMATP>
    <OMA><OMS cd=”tr1″ name=”sin” />
    <OMF dec=”3.14″ /></OMA>
    </OMATTR>
  • Infix-Notation:
    For the assignment-operator :=, the relations <, >, <=, >=, !=, <>, =, and the operators +, -, *, /, ^ there is also an infix-notation available, that maps to the appropriate symbols. in prog1, relation1, and arith1 respectively (the usual operator precedence is used):

    POPCORN OpenMath
    1+2 <OMA><OMS cd=”arith1″ name=”plus” /><OMI>1</OMI><OMI>2</OMI></OMA>
    1<#a <OMA>
    <OMS cd=”relation1″ name=”lt” />
    <OMI>1</OMI>
    <OMV name=”a” />
    </OMA>
    #b := 2 <OMA>
    <OMS cd=”prog1″ name=”assign” />
    <OMV name=”b” />
    <OMI>2</OMI>
    </OMA>
  • Blocks: if you seperate different POPCORN-expressions by ;, they will be wrapped into an prog1.block:
    POPCORN OpenMath
    1+2;
    #a:=2;
    “hello”
    <OMA>
    <OMS cd=”prog1″ name=”block” />
    <OMA><
    OMS cd=”arith1″ name=”plus” />
    <OMI>1</OMI>
    <OMI>2</OMI>
    </OMA>
    <OMA>
    <OMS cd=”prog1″ name=”assign” />
    <OMV name=”a” />
    <OMI>2</OMI>
    </OMA>
    <OMSTR>hello</OMSTR>
    </OMA>
  • Syntactic sugar: if, while, procdef: This is easiest explained by examples:
    POPCORN OpenMath
    if #a <1 then
    “hello”
    else
    “bye”
    endif
    <OMA>
    <OMS cd=”prog1″ name=”if” />
    <OMA>
    <OMS cd=”relation1″ name=”lt” />
    <OMV name=”a” />
    <OMI>1</OMI>
    </OMA>
    <OMSTR>hello</OMSTR>
    <OMSTR>bye</OMSTR>
    </OMA>
    while #a<10 do
    #a := #a + 1
    endwhile
    <OMA>
    <OMS cd=”prog1″ name=”while” />
    <OMA><OMS cd=”relation1″ name=”lt” />
    <OMV name=”a” />
    <OMI>10</OMI>
    </OMA>
    <OMA><OMS cd=”prog1″ name=”assign” />
    <OMV name=”a” />
    <OMA>
    <OMS cd=”arith1″ name=”plus” />
    <OMV name=”a” />
    <OMI>1</OMI>
    </OMA>
    </OMA>
    </OMA>
    procdef #f(#x)
    local #y
    begin
    #y := #x
    endproc
    <OMA>
    <OMS cd=”prog1″ name=”procedure_definition” />
    <OMV name=”f” />
    <OMA>
    <OMS cd=”prog1″ name=”def_arguments” />
    <OMV name=”x” />
    </OMA><
    OMA>
    <OMS cd=”prog1″ name=”procedure_block” />
    <OMA>
    <OMS cd=”prog1″ name=”local_var” />
    <OMV name=”y” />
    </OMA>
    < OMA>
    <OMS cd=”prog1″ name=”assign” />
    <OMV name=”y” />
    <OMV name=”x” />
    </OMA>
    </OMA>
    </OMA>

Introduction

Download

The current version is available for download here as a jar. then you can get things like this:

# java -jar popcorn20080414.jar
Tester for POPCORN (Possibly Only Practicable Convenient OpenMath Replacement Notation)

Enter your POPCORN-Code and type Enter and EOF when done (in general, this is ^D):
>1=2:a+$a-#v/2*8-this.that[#r{animals1.dog->'woof', animals1.cow->'mooh'} -> funnnycd1.symboll(#r+1-#v)]+2
^D
OpenMath:
<OMA>
  <OMS cd="relation1" name="eq"/>
  <OMI>1</OMI>
  <OMA>
    <OMS cd="arith1" name="plus"/>
    <OMI id="a">2</OMI>
    <OMR href="a"/>
    <OMA>
      <OMS cd="arith1" name="unary_minus"/>
      <OMA>
        <OMS cd="arith1" name="times"/>
        <OMV name="v"/>
        <OMA>
          <OMS cd="arith2" name="inverse"/>
          <OMI>2</OMI>
        </OMA>
        <OMI>8</OMI>
      </OMA>
    </OMA>
    <OMA>
      <OMS cd="arith1" name="unary_minus"/>
      <OMBIND>
        <OMS cd="this" name="that"/>
        <OMBVAR>
          <OMATTR>
            <OMATP>
              <OMS cd="animals1" name="dog"/>
              <OMSTR>woof</OMSTR>
              <OMS cd="animals1" name="cow"/>
              <OMSTR>mooh</OMSTR>
            </OMATP>
            <OMV name="r"/>
          </OMATTR>
        </OMBVAR>
        <OMA>
          <OMS cd="funnnycd1" name="symboll"/>
          <OMA>
            <OMS cd="arith1" name="plus"/>
            <OMV name="r"/>
            <OMI>1</OMI>
            <OMA>
              <OMS cd="arith1" name="unary_minus"/>
              <OMV name="v"/>
            </OMA>
          </OMA>
        </OMA>
      </OMBIND>
    </OMA>
    <OMI>2</OMI>
  </OMA>
</OMA>

and off you go… ;) (the indentation was added later to make things clearer).

If you have any questions or concerns, don’t hesitate to contact me.

Doping-Fall in der Mathematik

Kassel, 20.02.2008 In einem bisher einzigartigen Fall gelang der Staatsanwaltschaft Kassel in den frühen Morgenstunden des 19.02.2008 ein Schlag gegen die Doping-Mafia in Nordhessen. Bei dem bisher unauffälligen Mathematiker Peter H. wurden große Mengen leistungsfördernder Substanzen sichergestellt. Ein Polizeisprecher vermutet, dass es sich bei dem Fall nur um die Spitze des Eisbergs handelt: “Doping wurde in der Mathematik bisher stets als Kavaliersdelikt betrachtet.” Ob Herrn H. nun nachträglich auch sein Diplom aberkannt werde, sei derzeit noch nicht abzusehen, aber “für seine Doktorarbeit sehen wir schwarz”.
Die Deutsche Mathematiker-Vereinigung hat bereits eine Zwei-Jahres-Sperre gegen Herrn H. auf den Weg gebracht.

Connecting Computer Algebra Systems

In SCIEnce, we are connecting different Computer Algebra Systems in a standardized way. The protocol used is called SCSCP (Symbolic Computation Software Composability Protocol), and we have some prototypes running. The mathematical objects are marshalled in XML using OpenMath. This is a demo-session in MuPAD:

   *----*    MuPAD Pro 4.5.0 -- The Open Computer Algebra System
  /|   /|
 *----* |    Copyright (c)  1997 - 2008  by SciFace Software
 | *--|-*                   All rights reserved.
 |/   |/
 *----*      Licensed to:   Peter Horn

// load the package
>> package("OpenMath"):

// define some (simple) maths task. hold is required to prevent
// MuPAD from immediately computing the result.
>> A := hold(hold(_plus)(7, 8 ))
hold(_plus)(7, 8 )

// There are scscp-servers running on some remote machines.
// Note: in the setup of the connection, the type of the system is NOT
// specified. They all talk SCSCP.
>> gap := SCSCP("machine1.somewhere.org", 26133):
>> kant := SCSCP("machine2.somewhere-else.org", 26133):
>> mupad := SCSCP("machine3.differentplace.org", 26133):

// now, ask GAP, KANT and the remote MuPAD to compute the task:
>> gap::compute(A)
15

>> kant::compute(A)
15

>> mupad::compute(A)
15

// a slightly more advanced example (extended euclidean algorithm)
>> B := hold(hold(gcdex)(12, 14, 20))
hold(gcdex)(12,14,20)

>> kant::compute(B)
[2, -1, 1, 0]

More to come ;)

OpenMath Package for MuPAD

In the last couple of months I’ve developed an OpenMath Package for MuPAD. OpenMath is a new, extensible standard for representing the semantics of mathematical objects. If you haven’t heard about it before you might want to consult the website — it’s somewhat related to MathML.

A rather early preview of the package can be found here:

It’s organized as a MuPAD package. So if it can be found on the PACKAGEPATH, you can use it like this:

// load the package
>> package("OpenMath")

// generate::OpenMath creates an adt::XML representing the mathematical
// expression
>> generate::OpenMath(1+a)
<OMOBJ xmlns='http://www.openmath.org/OpenMath'>
 <OMA>
   <OMS cd='arith1' name='plus'/>
   <OMV name='a'/>
   <OMI>1</OMI>
 </OMA>
</OMOBJ>

// in OpenMath there are definitions how to represent different
// numbers as Complex...
>> generate::OpenMath(3+4*I)
<OMOBJ xmlns='http://www.openmath.org/OpenMath'>
 <OMA>
   <OMS cd='complex1' name='complex_cartesian'/>
   <OMI>3</OMI>
   <OMI>4</OMI>
 </OMA>
</OMOBJ>

// ...or Rationals.
>> generate::OpenMath(3/4)
<OMOBJ xmlns='http://www.openmath.org/OpenMath'>
 <OMA>
   <OMS cd='nums1' name='rational'/>
   <OMI>3</OMI>
   <OMI>4</OMI>
 </OMA>
</OMOBJ>

// xml2text is a function to get a compact and fast
// string-representation of an adt::XML
>> xml2text(generate::OpenMath(sin(a+1)^2))
"<OMOBJ xmlns='http://www.openmath.org/OpenMath'><OMA><OMS cd='arith1\
' name='power'/><OMA><OMS cd='transc1' name='sin'/><OMA><OMS cd='arit\
h1' name='plus'/><OMV name='a'/><OMI>1</OMI></OMA></OMA><OMI>2</OMI><\
/OMA></OMOBJ>"

// OM::Parser::pase parses either the given file or the passed String
// if the Option 'String' is given
>> OM::Parser::parse(%, String)
OM::XML::OMOBJ([OM::XML::OMA([OM::XML::OMS(table("name" = "power", "c\
d" = "arith1")), OM::XML::OMA([OM::XML::OMS(table("name" = "sin", "cd\
" = "transc1")), OM::XML::OMA([OM::XML::OMS(table("name" = "plus", "c\
d" = "arith1")), OM::XML::OMV(table("name" = "a")), OM::XML::OMI([OM:\
:XML::Data("1")])])]), OM::XML::OMI([OM::XML::Data("2")])])], table("\
xmlns" = "http://www.openmath.org/OpenMath"))

// the result needs to be evaluated to get the proper MuPAD expression
// (This is done to simplify debugging during development.)
>> eval(%)
sin(a + 1)^2

Currently, only a couple of domains (mainly expressions, numbers, polynomials and matrices) are supported.

This is not a stable version to any extend and it you use it in a production environment, you’re insane.

Any feedback is highly appreciated.

Licensing is not copletely clear, yet. I claim that this version is under some BSD-style license.

Commandline-Aliases for all Mac-Apps

I frequently have the problem that I want to open a particular file in a “GUI”-app from the commandline. This can be achieved using the open [-a ApplicationName] filename command, but typing this is annoying. Therefore I added some lines to my .profile:

# Go through the Mac-Applications and define command-line aliases
echo -n Creating aliases for Mac-Applications
for a in /Applications/*.app /Applications/*/*.app /Developer/Applications/*.app /Developer/Applications/*/*.app
do
a=`basename "$a"`
b=`echo "$a" | sed -e /\.app/s/// -e /\ /s///g`;
alias "$b"="open -a \"$a\"";
echo -n '.'
done;
echo done.

So now, I can type e.g. TextEdit muff.txt, which is quite convenient.

Neuer Mac

Neuer Mac Seit gestern steht hier ein neuer MacPro — mit 8 Kernen und 16 GB RAM. Das Ding ist unglaubich flott. Wir haben eben mal 16 Gröbnerbasen-Berechnungen gestartet, und nebenbei noch ein bisschen rumgespielt. Die load ist auf fast 20 hochgegangen, aber keine Anzeichen von Ermüdung.

Und außerdem ist die Maschine auch unter Last unhörbar leise. :)

Nicht so schön war, dass der Rechner zunächst nur 8 der 16GB erkannt hat — den Speicher auf der oberen Riser-Platine hat er schlicht nicht gesehen. Nachdem wir die Bestückung der Riser ausgetauscht haben, hat es dann doch geklappt — das verstehe wer kann.

Geliefert wurde die Maschine von hsd. Die waren zwar sehr günstig, aber den Speicher haben sie nicht eingebaut, sondern in ‘ner Extra-Kiste mitgeschickt. So was muss nicht sein.


About

Archive for Peter.

Longer entries are truncated. Click the headline of an entry to read it in its entirety.

Categories