A small library for propositional logic and formal systems.
Project description
frege
A small, typed library for various systems of logic.
Install
uv add frege
Quickstart
# TODO
Run the bundled example:
# TODO
uv run python examples/TODO.py
Development
All tasks run through plain uv commands:
uv sync # install the project + dev dependencies
uv run pytest # run tests with coverage
uv run ruff check . # lint
uv run ruff format . # format (use --check in CI)
uv run ty check # type check
uv run python examples/propositional_logic.py
Goals
- Parsing of logical expressions from 'standard' syntax into a typed representation.
- Have:
¬(prefix),∧(left-assoc),→(right-assoc). - Still need
∨(left-assoc, slots between∧and→) to complete propositional syntax. ↔and⊕are non-associative:A ↔ B ↔ Cis ambiguous, so chaining should be rejected (parse exactly two operands). This is a new associativity case the current precedence-climbing parser does not yet handle.
- Have:
- Generation of truth tables from Formulae/Theories
- For normalization (CNF/DNF) the nested-binary tree for the associative
∧/∨becomes awkward; consider flattening to n-ary nodes (And([...])).
- For normalization (CNF/DNF) the nested-binary tree for the associative
- Parsing of latex/mathjax/typst logical expressions
- Support for various notation forms.
- Polish/prefix (
Cpq,Kpq) and postfix/RPN have no associativity or precedence; they are a separate parse mode, not a new operator level. Themode=dispatch andSymbol-driven tokenizer give a seam for anotation=axis.
- Polish/prefix (
- Generation of truth trees for viewing the structure of a logical formula or theory. a. https://en.wikipedia.org/wiki/Method_of_analytic_tableaux
Syllogismclass- Support for Systems of Logic
a. Aristotelian (see Syllogism impl as prerequisite)
b. Classical
c. Propositional
d. First-Order
- Quantifiers
∀x. φ,∃x. φare binders, not binary operators: they bind a variable and grab maximal scope to the right. Forces aTermgrammar (predicatesP(x), functionsf(g(x)), application) below theFormulagrammar. This reshapes the type model:Elementwill sit alongside aTermtype. e. Modal -□/◇are prefix unary, stackable like¬; cheap to add as a new method at the same precedence level. f. Higher order - Addsλbinders and left-associative application; builds on the first-orderTermgrammar. g. Deviant (Intuitionistic, Multi-valued logics, Paraconsistent logics) - Computational representations of Model Theory, Proof Theory, Set Theory and Computability Theory.
- Axiom listing and ability to add/modify/remove them.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
frege-0.1.1.tar.gz
(9.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
frege-0.1.1-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file frege-0.1.1.tar.gz.
File metadata
- Download URL: frege-0.1.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0361bdcd33aa03644b0966034e66f7398b17c57b9cb0ec009850fb77f58e4ef4
|
|
| MD5 |
e89b3eba72beca854c0148c24efdd10c
|
|
| BLAKE2b-256 |
422eb142fdde9c9527e0a65a11972de5e673d3c4733b9ee93d88808f96c835cd
|
File details
Details for the file frege-0.1.1-py3-none-any.whl.
File metadata
- Download URL: frege-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
363ab8f8cc03f7bb1cceafe1e30209b166164bc6157c10a1b9f1cf918b306359
|
|
| MD5 |
b7889c0c704518becf324ce2e80c8120
|
|
| BLAKE2b-256 |
a02a197f31213b9a15b6c7469f53209cd441115a5c58fbed294b1f683149e655
|