Code Monkey home page Code Monkey logo

alignment's Introduction

Alignment

The Alignment repository is a literal Haskell implementation of some of the set-theoretic functions and structures described in the paper The Theory and Practice of Induction by Alignment at https://greenlake.co.uk/.

The Alignment repository is designed with the goal of theoretical correctness rather performance. A fast implementation of practicable inducers is in the AlignmentRepa repository.

Documentation

Some of the sections of the Overview of the paper have been illustrated with a Haskell commentary. The comments provide both (a) code examples for the paper and (b) documentation for the code.

For programmers who are interested in implementing inducers, some of the sections of the paper have been expanded in a Haskell commentary with links to documentation of the code in the repository. The code documentation is gathered together in Haskell code.

Download

The Alignment module requires the Haskell platform to be installed.

Once done, two modules should be installed, old-locale and random. For example, using stack,

stack install old-locale
stack install random

Then download the zip file or use git to get the repository. For example, in Ubuntu -

cd
git clone https://github.com/caiks/Alignment.git

Usage

The Alignment modules are not optimised for performance and are mainly intended to allow experimentation in the Haskell interpreter. Use stack ghci or stack repl for a run-eval-print loop (REPL) environment. Load AlignmentDev to import the modules and define various useful abbreviated functions,

cd Alignment
stack ghci
:set +m
:l AlignmentDev

The Alignment types implement the class type Represent defined in AlignmentUtil which requires them to implement the represent function,

represent :: Show a => a -> String

The represent function returns a String that approximates to a set-theoretic representation of the structure. AlignmentDev defines the abbreviation rp.

For example, to create a regular cartesion histogram of dimension 2 and valency 3 and display the result,

rp $ regcart 3 2
"{({(1,1),(2,1)},1 % 1),({(1,1),(2,2)},1 % 1),({(1,1),(2,3)},1 % 1),({(1,2),(2,1)},1 % 1),({(1,2),(2,2)},1 % 1),({(1,2),(2,3)},1 % 1),({(1,3),(2,1)},1 % 1),({(1,3),(2,2)},1 % 1),({(1,3),(2,3)},1 % 1)}"

Larger structures can be converted to a list and displayed over more than one line,

rpln $ aall $ regcart 3 2
"({(1,1),(2,1)},1 % 1)"
"({(1,1),(2,2)},1 % 1)"
"({(1,1),(2,3)},1 % 1)"
"({(1,2),(2,1)},1 % 1)"
"({(1,2),(2,2)},1 % 1)"
"({(1,2),(2,3)},1 % 1)"
"({(1,3),(2,1)},1 % 1)"
"({(1,3),(2,2)},1 % 1)"
"({(1,3),(2,3)},1 % 1)"

Here is a simple example that calculates the alignment of a regular cartesian, a regular diagonal and the resized sum,

let cc = resize 100 $ regcart 3 2

rpln $ aall cc
"({(1,1),(2,1)},100 % 9)"
"({(1,1),(2,2)},100 % 9)"
"({(1,1),(2,3)},100 % 9)"
"({(1,2),(2,1)},100 % 9)"
"({(1,2),(2,2)},100 % 9)"
"({(1,2),(2,3)},100 % 9)"
"({(1,3),(2,1)},100 % 9)"
"({(1,3),(2,2)},100 % 9)"
"({(1,3),(2,3)},100 % 9)"

let dd = resize 100 $ regdiag 3 2

rpln $ aall dd
"({(1,1),(2,1)},100 % 3)"
"({(1,2),(2,2)},100 % 3)"
"({(1,3),(2,3)},100 % 3)"

let aa = resize 100 $ cc `add` dd

rpln $ aall aa
"({(1,1),(2,1)},200 % 9)"
"({(1,1),(2,2)},50 % 9)"
"({(1,1),(2,3)},50 % 9)"
"({(1,2),(2,1)},50 % 9)"
"({(1,2),(2,2)},200 % 9)"
"({(1,2),(2,3)},50 % 9)"
"({(1,3),(2,1)},50 % 9)"
"({(1,3),(2,2)},50 % 9)"
"({(1,3),(2,3)},200 % 9)"

ind dd == cc
True

ind aa == cc
True

algn cc
0.0

algn aa
22.09885634287619

algn dd
98.71169723276279

alignment's People

Contributors

caiks avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.