Skip to main content

A boolean expression manipulation program that uses zippers for navigation.

Project description

AlgeZip

Github | PyPI

AlgeZip is a command-line demo program for manipulating boolean expressions. Apply various axioms from boolean algebra to transform expressions into equivalent expressions. Choose the subexpression to apply axioms to by moving a "focus" around to navigate the expression. The navigation system is powered by a zipper data structure, hence the name AlgeZip -- using zippers to manipulate a (boolean) algebraic expression.

pip install shape-warrior-t.algezip

The command-line program itself has no external dependencies, but running tests requires pytest.

Once installed, run in the command line with the command algezip.

To run tests, just clone the repository and run pytest in the proper directory.

Example run, showing the equivalence of two different formulations of XOR:

---AlgeZip---
For help, type 'help'

F
^

> help

Focus:
'^' under the current expression denotes the subexpression currently under focus
Use '^', '.', '<', '>' to move focus around (more info under Commands)
Transformations are always applied to the current subexpression under focus

Boolean expression syntax (for giving arguments to 'r!' and 'x'):
F - False, T - True
Single lowercase letters - variables
(!a) - not a, (a & b) - a and b, (a | b) - a or b
No operator precedence -- operations must be explicitly written in brackets
Allowed bracket types (interchangeable, but must be paired correctly): (), [], {}

Commands:
r! a - replace current subexpression under focus with a
^ - move focus to the parent of the current subexpression under focus
. - move focus from (!a) to its only argument a
< - move focus from (a & b) or (a | b) to the left argument a
> - move focus from (a & b) or (a | b) to the right argument b
c - [c]ommutativity -- (a | b) -> (b | a), (a & b) -> (b & a)
i - [i]dentity -- (a | F) -> a, (a & T) -> a
|F - expand via identity -- a -> (a | F)
&T - expand via identity -- a -> (a & T)
d - [d]istributivity -- (a | [b & c]) -> ([a | b] & [a | c]), (a & [b | c]) -> ([a & b] | [a & c])
f - [f]actoring -- ([a | b] & [a | c]) -> (a | [b & c]), ([a & b] | [a & c]) -> (a & [b | c])
v - complements/in[v]erses -- (a | [!a]) -> T, (a & [!a]) -> F
x a - e[x]pand into complements -- T -> (a | [!a]), F -> (a & [!a])
help - print help
q! - quit

F
^

> r! ([a | b] & [{!a} | {!b}])

([a | b] & [{!a} | {!b}])
^^^^^^^^^^^^^^^^^^^^^^^^^

> d

([{a | b} & {!a}] | [{a | b} & {!b}])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> <

([{a | b} & {!a}] | [{a | b} & {!b}])
 ^^^^^^^^^^^^^^^^

> c

([{!a} & {a | b}] | [{a | b} & {!b}])
 ^^^^^^^^^^^^^^^^

> d

([{(!a) & a} | {(!a) & b}] | [{a | b} & {!b}])
 ^^^^^^^^^^^^^^^^^^^^^^^^^

> <

([{(!a) & a} | {(!a) & b}] | [{a | b} & {!b}])
  ^^^^^^^^^^

> c

([{a & (!a)} | {(!a) & b}] | [{a | b} & {!b}])
  ^^^^^^^^^^

> v

([F | {(!a) & b}] | [{a | b} & {!b}])
  ^

> ^

([F | {(!a) & b}] | [{a | b} & {!b}])
 ^^^^^^^^^^^^^^^^

> c

([{(!a) & b} | F] | [{a | b} & {!b}])
 ^^^^^^^^^^^^^^^^

> i

([{!a} & b] | [{a | b} & {!b}])
 ^^^^^^^^^^

> c

([b & {!a}] | [{a | b} & {!b}])
 ^^^^^^^^^^

> ^

([b & {!a}] | [{a | b} & {!b}])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> >

([b & {!a}] | [{a | b} & {!b}])
              ^^^^^^^^^^^^^^^^

> c

([b & {!a}] | [{!b} & {a | b}])
              ^^^^^^^^^^^^^^^^

> d

([b & {!a}] | [{(!b) & a} | {(!b) & b}])
              ^^^^^^^^^^^^^^^^^^^^^^^^^

> >

([b & {!a}] | [{(!b) & a} | {(!b) & b}])
                            ^^^^^^^^^^

> c

([b & {!a}] | [{(!b) & a} | {b & (!b)}])
                            ^^^^^^^^^^

> v

([b & {!a}] | [{(!b) & a} | F])
                            ^

> ^

([b & {!a}] | [{(!b) & a} | F])
              ^^^^^^^^^^^^^^^^

> i

([b & {!a}] | [{!b} & a])
              ^^^^^^^^^^

> c

([b & {!a}] | [a & {!b}])
              ^^^^^^^^^^

> ^

([b & {!a}] | [a & {!b}])
^^^^^^^^^^^^^^^^^^^^^^^^^

> c

([a & {!b}] | [b & {!a}])
^^^^^^^^^^^^^^^^^^^^^^^^^

> q!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shape_warrior_t_algezip-1.0.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shape_warrior_t_algezip-1.0.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file shape_warrior_t_algezip-1.0.0.tar.gz.

File metadata

  • Download URL: shape_warrior_t_algezip-1.0.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for shape_warrior_t_algezip-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f92bc478a94523a63a92d188227d7f301724a32185705e9ef8f2fc96ace5f448
MD5 16d6fd643429401a5f1570976c2936bf
BLAKE2b-256 704fe2db321ae1f1a561f7473f4a3b190b08befdf0f3d5c7588c1046b5a8c05c

See more details on using hashes here.

File details

Details for the file shape_warrior_t_algezip-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for shape_warrior_t_algezip-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e613893d705c7855567cf450091c1452ece0d281920a47aa23e4da0c1506c36f
MD5 094d158e57770b7b1209f265f90d1d8d
BLAKE2b-256 1403e76a6d564311938260a0a7be5c6761e372a511ccaf48644571d4468bcba1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page