Pacioli

Java implementation of the Pacioli language

View project onGitHub

Introduction

The matrix language Pacioli adds type safety and dimensional anaylysis to mathematical software. Its parametric type system infers vector and matrix types based on dimensioned vector spaces.

Pacioli programs can be run directly via the command line, compiled to NumPy or MATLAB/GNU Octave, or compiled to JavaScript and deployed via the web.

Examples

Snapshot of a shell model

The shells example illustrates many aspectes of the language. It demonstrates vectors and matrices, units of measurement, deployment via the web, charts and other features.

The shell is computed in Pacioli code using a seperate module for the model. It is displayed on the page with library three.js.

All computations are guaranteed unit correct and derived by the compiler. For example

define triangle area(x, y, z) =
    norm(cross(y - x, z - x)) / 2;

has as derived type

triangle area :: for unit a: (a*Space!, a*Space!, a*Space!) -> a^2

A short introduction to units of measurements in Pacioli is in the tutorial on unit inference. The Kirchhof case on the equilibrium in an eletrical network explains the use of matrices.

The tutorial on matrices gives some details on Pacioli's type system. It is about the power consumption of Nasa's curiosity rover and involves vectors where the units of measurement vary per element.

Working with the web and javascript is explained in the tutorial on 3D and the tutorial on charts

The output example in the section on runtime support below is from the numpy_test sample. This is a small machine learning example using nearest neighbors.

Documentation

Pacioli is described in the manual. The specification lists the available functions.

Download and Installation

Install Pacioli from the GitHub project. You can also view more samples there.

Runtime support

Pacioli guarantees unit correctness at compile time independently from any unit support at runtime. In addition, its own runtime system, the MVM, is completely unit-aware and displays output with units. For example an array that is displayed in NumPy as

[[5.1],
 [3.5],
 [1.4],
 [0.2]]

is displayed by the MVM as

Index             Value
--------------------------
Sepal length    5.10000 cm 
Sepal width     3.50000 cm
Petal length    1.40000 cm
Petal width     0.20000 cm

The runtime support for the various targets is as follows.

  • MVM
    • Completely unit aware. Input and output with units and index names.
    • Uses the Apache Commons Mathematics Library for the numbers.
    • Dynamically typed.
    • Duplicates the compile time unit checks at runtime. Useful as test for the compiler, but unnecessary overhead.
  • NumPy and MATLAB/GNU Octave
    • Unit correct but no units and index names in the output.
    • Zero overhead for units.
  • Javascript
    • Completely unit aware. Input and output with units and index names.
    • Uses numeric.js for the numbers (supports 3D graphics with three.js)
    • The type/unit computation is separated from the numbers.
    • Marginal overhead from units.

License and Status

Pacioli is released under an MIT license. See the file LICENSE in the root directory of the sources.

This Pacioli version is for research purposes. The implementation is reasonably complete. However, it doesn't support many features for input and output yet.

2013-2020 Paul Griffioen