Skip to content

mojtabaakhbari/LogicLoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LogicLoom

Python PyQt6 License: MIT

LogicLoom is a single-repository project for minimizing boolean expressions. It consists of logicloom_core (the engine and CLI) and logicloom_ui (an open-source desktop GUI that uses the core). The UI is built only for this project and is part of the same repo.

Desktop GUI

LogicLoom Desktop GUI

πŸ“± Android App

LogicLoom Android App


Features

Core

  • Minimal boolean expression output in string or LaTeX format
  • Prime implicant chart data and terminal display
  • Simple CLI with demo mode for quick checks

Desktop UI

  • Variables and minterms input with live validation
  • Prime implicants table (binary and literal forms)
  • Essential prime implicants and PI chart
  • Results as minimal SOP form
  • LaTeX results tab with MathJax

Android App πŸ“±

  • 🎯 Native Android experience with intuitive touch interface
  • πŸ“ Easy input for variables and minterms with mobile-friendly keyboard
  • πŸ“Š Interactive prime implicants table optimized for mobile screens
  • πŸ“± Swipe between different result tabs (PI Chart, Results, LaTeX)
  • πŸ” Zoom and scroll support for complex expressions
  • πŸ“‹ One-tap copy to clipboard for results
  • πŸŒ™ Dark/Light theme support (system default)

Project layout

LogicLoom/
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ apps/
β”‚   └── logicloom.apk        # πŸ“± Pre-built Android app
β”œβ”€β”€ js/
β”‚   └── tex-mml-chtml.js      # MathJax for LaTeX in the UI
β”œβ”€β”€ shots/
β”‚   β”œβ”€β”€ screenshot.png        # Desktop GUI screenshot
β”‚   └── android.jpg           # Android app screenshot
β”œβ”€β”€ logicloom_core/           # Core engine and CLI
β”‚   β”œβ”€β”€ pyproject.toml
β”‚   └── logicloom/
└── logicloom_ui/            # Desktop GUI (open source, uses logicloom_core)
    β”œβ”€β”€ app.py
    β”œβ”€β”€ icon.ico              # Application icon
    β”œβ”€β”€ main_window.py
    β”œβ”€β”€ html_templates.py
    β”œβ”€β”€ validation.py
    β”œβ”€β”€ workers.py
    └── ...

Requirements

  • Python 3.10+
  • PyQt6 (only for the desktop GUI; CLI works without it)

Install and run

From the repository root (so js/ and both packages are available):

git clone https://github.com/mojtabaakhbari/LogicLoom.git
cd LogicLoom

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

pip install -r requirements.txt
pip install -e logicloom_core

CLI

logicloom --vars "A,B,C" --minterms "0,2,3,5" --output both
logicloom --demo --pichart terminal

GUI

python -m logicloom_ui

Android App πŸ“±

πŸŽ‰ Quick Start - Ready to Use!

  1. πŸ“₯ Download the pre-built APK: apps/logicloom.apk
  2. πŸ“² Install on your Android device (enable "Unknown Sources" in settings)
  3. πŸš€ Launch LogicLoom and start simplifying boolean expressions!

πŸ“‹ Android Requirements

  • Android 5.0 (API level 21) or higher
  • ~50MB storage space
  • No additional dependencies required

Or with PYTHONPATH instead of installing the core:

pip install -r requirements.txt
PYTHONPATH=. python -m logicloom_ui

Usage

CLI

Argument Short Description
--vars -v Comma-separated variable names (e.g. A,B,C).
--minterms -m Comma-separated minterm numbers (e.g. 0,1,2,5).
--output β€” Output format: string, latex, or both (default: string).
--all β€” Print all minimal covers (not just the first).
--pichart β€” Print prime implicant chart: terminal or latex.
--pitable β€” Print prime implicants table (binary and literal form): terminal.
--essentials β€” Print essential prime implicants table (binary and literal form): terminal.
--demo β€” Run bundled demo problems (no --vars/--minterms needed).
--version β€” Print version and exit.

Example: logicloom -v "x,y,z" -m "0,2,4,5,6" --output both --all --pitable terminal --essentials terminal --pichart terminal

GUI

  1. Variables β€” e.g. A, B, C or x, y, z
  2. Minterms β€” e.g. 0, 2, 4, 5, 6
  3. Click Compute and use the Prime Implicants, Essentials, PI Chart, Results, and LaTeX Results tabs.

Python API (core)

Setup

from logicloom import LogicGateSimplifier, Term, PIChartData, PIChartRow

# From comma-separated strings (e.g. CLI-style)
simplifier = LogicGateSimplifier.from_strings("x,y,z", "0,2,4,5,6")

# Or from lists
simplifier = LogicGateSimplifier(minterms=[0, 2, 4, 5, 6], variables=["x", "y", "z"])

simplifier.simplify()  # run minimization (required before get_* methods)

Constructor / factory arguments

Call Arguments Description
LogicGateSimplifier(minterms, variables) minterms: list[int], variables: list[str] Build from lists of minterm indices and variable names.
LogicGateSimplifier.from_strings(variables_str, minterms_str) variables_str: str, minterms_str: str Parse comma-separated strings (e.g. "A,B,C", "0,2,5").

Chart data (PI chart)

Get structured data for the prime implicant chart (minterms Γ— prime implicants, with a boolean matrix):

data = simplifier.get_pichart_data()
# data: PIChartData with:
#   - minterm_numbers: list[int | None]   β€” minterm indices
#   - prime_implicants: list[str]         β€” binary forms (e.g. "01-", "1-0")
#   - matrix: list[list[bool]]            β€” matrix[i][j] = PI j covers minterm i

# Pre-rendered chart strings (optional tick character for β€œcovered” cells)
latex_table = simplifier.get_pichart_latex(tick=r"$\checkmark$")   # default LaTeX checkmark
terminal_table = simplifier.get_pichart_terminal(tick="x")         # default "x"

Chart method arguments

Method Argument Type Default Description
get_pichart_latex tick str r"$\checkmark$" String used in LaTeX for each covered (minterm, PI) cell.
get_pichart_terminal tick str "x" Character used in the terminal table for each covered cell.

Prime implicants and essentials tables (terminal)

Print tables of prime implicants or essential prime implicants (binary form and literal form) in a box-drawing terminal layout:

# Prime implicants table (Binary | Literal)
pi_table = simplifier.get_prime_implicants_terminal()
print(pi_table)

# Essential prime implicants table (Binary | Literal)
ess_table = simplifier.get_essentials_terminal()
print(ess_table)

CLI: use --pitable terminal and/or --essentials terminal.

Equations (minimal SOP)

Get all minimal sum-of-products equations (string and LaTeX):

equations = simplifier.get_all_equations()
# list of dicts: [{"string": "F(x,y,z) = ...", "latex": "F(x,y,z) = ..."}, ...]
for eq in equations:
    print(eq["string"])
    print(eq["latex"])

# Single minimal cover as LaTeX only
latex_eq = simplifier.get_equation_latex()

Other public methods and attributes

Method / attribute Arguments Description
simplify() β€” Runs minimization; returns the first minimal cover as list[Term].
get_all_minimal_covers() β€” Returns all minimal covers, each as list[Term].
get_all_equations() β€” Returns all minimal equations as list[dict] with "string" and "latex" keys.
get_equation_latex() β€” Returns the first minimal equation as a single LaTeX string.
get_pichart_data() β€” Returns PIChartData (minterm_numbers, prime_implicants, matrix).
get_pichart_latex(...) tick: str = r"$\checkmark$" Returns the PI chart as a LaTeX tabular string; tick is the mark for covered cells.
get_pichart_terminal(...) tick: str = "x" Returns the PI chart as a plain-text table; tick is the character for covered cells.
get_prime_implicants_terminal() β€” Returns prime implicants table (Binary and Literal columns) as a terminal string.
get_essentials_terminal() β€” Returns essential prime implicants table (Binary and Literal columns) as a terminal string.
variables β€” list[str] β€” variable names.
main_minterms β€” list[Term] β€” input minterms.
prime_implicants β€” set[Term] β€” all prime implicants.
essentials β€” list[Term] β€” essential prime implicants.
pichart β€” list[PIChartRow] β€” chart rows (minterm, prime_implicants, is_remaining).

All get_* methods call simplify() internally if it has not been run yet.

Types

  • Term β€” Binary form (e.g. "01-"), optional number; .to_normal_expression(vars), .to_latex_expression(vars).
  • PIChartData β€” Dataclass: minterm_numbers, prime_implicants, matrix.
  • PIChartRow β€” Dataclass: minterm, prime_implicants, is_remaining.

Author

Mojtaba Akhbari
Email: [email protected]


License

MIT.

About

A powerful Boolean expression minimizer with CLI, desktop GUI, and Android app. Simplify Boolean algebra with visual prime implicant charts and LaTeX export.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages