Skip to main content

Parser and toolkit for first-order logic formulas using Unicode operators

Project description

unicode-fol-kit

A Python toolkit for first-order logic with Unicode operatorsparse, transform, and reason about formulas — with a reasoning layer that reaches well beyond classical FOL into modal, temporal, many-valued, fuzzy, intuitionistic, second-order, description, and a range of non-classical logics.

from unicode_fol_kit import MSFLParser, is_valid

phi = MSFLParser().parse(
    "∀x (Human(x) → Mortal(x)) ∧ Human(socrates) → Mortal(socrates)")
print(is_valid(phi))   # True

One parser class, MSFLParser, has six modes (classical FOL, many-sorted FOL, many-sorted and single-sorted Łukasiewicz fuzzy logic, modal/temporal/epistemic/deontic, and second-order) selected by constructor flags, with natural Unicode surface syntax (∀ ∃ ∧ ∨ ¬ → ↔ ⊕ ⊗ □ ◇ …) and no ASCII fallbacks.

On top of the AST sits a full reasoning stack — four proof methods (a built-in resolution prover, Fitch natural deduction with checker and searcher, the Gentzen sequent calculi LK/LJ, and analytic tableaux), a finite model finder, SMT (Z3) and external-prover (Prover9 / Vampire) backends, truth tables, and dedicated semantics for every logic. Formulas import/export to TPTP, Prover9, SMT-LIB, LaTeX, and JSON.

📖 Documentation

Full guide and API reference: https://unicode-fol-kit.readthedocs.io/

The documentation walks through every logic with runnable examples — start with the Quickstart and Choosing a tool.

Installation

pip install unicode-fol-kit

Requires Python 3.10+. Z3 ships with the package; Prover9, Vampire, and Isabelle are optional external tools you install separately to unlock the corresponding backends.

Logics at a glance

Logic Enable / entry point Decide / reason with
Classical FOL / MSFOL MSFLParser() / many_sorted=True resolution, Z3, Prover9/Vampire, tableaux, Fitch, LK, finite model finder
Fuzzy Łukasiewicz / Gödel / product MSFLParser(fuzzy=True) fuzzy_evaluate, fuzzy_is_valid(…, tnorm=…) (Z3 reals, quantifier grounding)
Modal / temporal / epistemic / deontic MSFLParser(modal=True) satisfies_modal, standard_translation, native is_modal_valid / modal_decide (K…S5, B, KD45)
Quantified modal KripkeModel(domains=…) qml_is_valid per domain regime + frame; THF / Isabelle export
Many-valued K3 / LP / Belnap FDE truth_table, semantics.matrix matrix_is_valid / matrix_entails over any finite TruthMatrix
Intuitionistic int_valid / int_countermodel propositional decision + bounded first-order Kripke search; LJ checker
Second-order MSFLParser(second_order=True) satisfies_so, bounded so_is_valid_finite / so_find_countermodel
Description logic ALC unicode_fol_kit.dl concept_satisfiable / subsumes / abox_consistent (tableau, TBox + ABox)
Free · public-announcement · counterfactual · circumscription semantics.free_logic / dynamic_epistemic / conditional / nonmonotonic dedicated evaluators and (non-monotonic) consequence

With a local Isabelle installed, the hol subpackage's shallow embeddings become proofs: isabelle_decide_modal / isabelle_decide_fol actually run the prover. See the higher-order guide.

Building the documentation locally

pip install -e ".[docs]"
sphinx-build -b html docs docs/_build/html

Citation

If you use this toolkit in academic work, please cite the accompanying preprint:

@misc{vossel2025advancingnaturallanguageformalization,
      title={Advancing Natural Language Formalization to First Order Logic with Fine-tuned LLMs},
      author={Felix Vossel and Till Mossakowski and Björn Gehrke},
      year={2025},
      eprint={2509.22338},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2509.22338},
}

Vossel, F., Mossakowski, T., & Gehrke, B. (2025). Advancing Natural Language Formalization to First Order Logic with Fine-tuned LLMs. arXiv preprint arXiv:2509.22338.

License

MIT

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

unicode_fol_kit-0.10.1.tar.gz (408.2 kB view details)

Uploaded Source

Built Distribution

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

unicode_fol_kit-0.10.1-py3-none-any.whl (303.6 kB view details)

Uploaded Python 3

File details

Details for the file unicode_fol_kit-0.10.1.tar.gz.

File metadata

  • Download URL: unicode_fol_kit-0.10.1.tar.gz
  • Upload date:
  • Size: 408.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for unicode_fol_kit-0.10.1.tar.gz
Algorithm Hash digest
SHA256 9c14092467da7da9786a7f8e6720dcc54d82b091e405a51ba58d01e50dd5839f
MD5 dd5b460346716967bd153db44703cee9
BLAKE2b-256 0e670de75f0f2bbe428a169eae4df8c3cd4af8d1c1d46348d2724f553b4dcba7

See more details on using hashes here.

File details

Details for the file unicode_fol_kit-0.10.1-py3-none-any.whl.

File metadata

File hashes

Hashes for unicode_fol_kit-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3fb7f82ce0e1b21cea4bcabb35fc837306d7f319d88b72a82c66f6b3ab46fadf
MD5 c6d6dcb3237fb3ad042fccda943423d9
BLAKE2b-256 9452b34db73826fa3496002bb01e02a63b179759a1ae3db1c05670953428d7b4

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