St. Mary's Project
Python Emacs Lisp
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

SSA-Tool: Working with Self-Stabilizing Algorithms in Python

Never mind the above; I haven’t been able to set it up correctly yet. Needing to tangle the file makes it a little complicated. The master branch contains all of the tangled code for the project. Travis CI will be using the master branch.

This is a set of tools for the representation, creation, and evaluation of self-stabilizing algorithms.

I will add more content here soon, but please do see the documentation for the project in src/ It is a literate program written with Org-Babel using the Emacs text editor.


Directory Structure

The project is set up as a traditional Python module:



    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'A utility for the creation and evaluation of self-stabilizing algorithms',
    'author': 'Sean Allred',
    'url': '',
    'download_url': '',
    'author_email': '',
    'version': '0.1',
    'install_requires': ['networkx'],
    'packages': ['ssa'],
    'scripts': [],
    'name': 'ssa',



# code example



#!/usr/bin/env emacs --script

  (let ((old-dir default-directory))
    (cd "~/.emacs.d")
    (cd old-dir)))

(setq python-indent-guess-indent-offset nil)

; (package-install 'org)

(require 'org)
(require 'ob)
(require 'ob-tangle)

(defun string/ends-with (s ending)
      "return non-nil if string S ends with ENDING."
      (cond ((>= (length s) (length ending))
             (let ((elength (length ending)))
               (string= (substring s (- 0 elength)) ending)))
            (t nil)))

(defun directory-files-recursive (directory match maxdepth ignore)
  "List files in DIRECTORY and in its sub-directories.  Return
   files that match the regular expression MATCH but ignore files
   and directories that match IGNORE (IGNORE is tested before
   MATCH).  Recurse only to depth MAXDEPTH.  If zero or negative,
   then do not recurse"
  (let* ((files-list '())
          (directory-files directory t)))
    ;; while we are in the current directory
     (while current-directory-list
       (let ((f (car current-directory-list)))
           ignore ;; make sure it is not nil
           (string-match ignore f))
           ; ignore
            (file-regular-p f)
            (file-readable-p f)
            (string-match match f))
          (setq files-list (cons f files-list)))
           (file-directory-p f)
           (file-readable-p f)
           (not (string-equal ".." (substring f -2)))
           (not (string-equal "." (substring f -1)))
           (> maxdepth 0))
           ;; recurse only if necessary
           (setq files-list (append files-list (directory-files-recursive f match (- maxdepth -1) ignore)))
           (setq files-list (cons f files-list)))
       (setq current-directory-list (cdr current-directory-list)))

(if nil
    (delq nil
           (lambda (file-path)
             (if (string/ends-with file-path "org")
                 (org-babel-tangle-file (message file-path))))
           (directory-files-recursive "." "" 10 "\\(build\\|dist\\)")))
  (mapcar 'org-babel-tangle-file
          (split-string (shell-command-to-string "find . -name '*.org' -type f"))))

pip Install

    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'A utility for the creation and evaluation of self-stabilizing algorithms',
    'author': 'Sean Allred',
    'url': '',
    'download_url': '',
    'author_email': '',
    'version': '0.1',
    'install_requires': ['networkx', 'pygame'],
    'packages': ['ssa'],
    'scripts': [],
    'name': 'ssa',




        $(info No prepared documentation yet)
        $(info See src/
        $(info $(HOME))

        sed -n '/:shebang/,/#+END_SRC/p' \
          | tail -n +2 \
          | sed '$$ d' > tangle.el

tangle: bootstrap
        emacs --script tangle.el

install: tangle
        python install

        rm -rf ssa.egg-info
        rm -rf build
        rm -rf dist

        rm -f tangle.el temp
        find . -name '*.py'  -type f -exec rm -rf {} \;
        find . -name '*.pyc' -type f -exec rm -rf {} \;
        find . -name '*~'    -type f -exec rm -rf {} \;

        $(info At least one test pops open a window with quick, discontinuous movement.)
        $(info If this kind of thing bothers you (e.g. epileptic), do not look at this test.)
        $(info At any rate, these tests are designed to be unattended.)
        $(info Press enter to confirm that you have read this message, or Ctrl-C out.)
        @read response
        $(MAKE) _check

        cd ssa && nosetests --verbose

        $(MAKE) _travis-emacs24-build
        $(MAKE) _travis-emacs24-install
        emacs --version

        $(info Downloading emacs 24)
        wget -O emacs.tgz $(PREBUILT_EMACS)
        $(info Unzipping)
        tar -zxf emacs.tgz

        $(info Installing)
        cd emacs-24.3 && make install


#!/usr/bin/env sh
# -*- mode: sh -*-

python3 "$@"


Dijkstra 1974

A self-stabilizing network is seen as a graph of state machines. Each privilege is realized as a transition from the current state to another state. The state of the graph is passed as input to this state machine. When the input graph matches some predicate, this privilege is set—there is some transition out of this state. This is why the choice of predicate to act upon is arbitrary: you can only move to one other state!

When every node of the graph is in an accepting state with no set predicates, then the graph has stabilized.


  • we consider graphs of finite state machines
  • privileges are boolean functions of the FSM’s state and the states of its neighbors
  • when these functions are true, the privilege is ‘present’

system state

  • each legitimate state must have at least one privilege present
    • even if the action is ‘do nothing’
  • in each legitimate state, every possible action will maintain legitimacy
  • each privilege must be present in at least one legitimate state
  • for any given pair of legitimate states, there exists a transformation between them


regardless of the initial state and regardless of the privilege selected each time for the next move, at least one privilege will always be present and the system is guaranteed to find itself in a legitimate state after a finite number of moves.