
Unicode Logic Kit
io.github.fvossel由 GitHub 帳號 fvossel 發布v0.35.0更新於 Nov 2, 2026
Parse, check, prove and translate logic formulas: first-order, modal, description, higher-order.
概覽
把 Unicode 邏輯工具包包裝成 MCP 工具,讓助理能解析、檢查、證明、反駁與翻譯邏輯公式。
- 可以做什麼
- 解析多種方言與邏輯系統的公式,並檢查良構性與簽章
- 用內建演算與外部證明器後端進行證明、反駁或尋找反模型
- 在邏輯之間翻譯,並把公式輸出為 Unicode、LaTeX、TPTP、Prover9、SMT-LIB 或 JSON
- 在指定的有限結構中求值公式,包括由 SMILES 字串得到的分子結構
- 對 LLM 產生的公式與基準金標資料做評分與比較
- 處理描述邏輯、機率邏輯與規則學習任務
- 適用情境
- 適合助理需要處理形式邏輯的情況:檢查或修復模型產生的公式、執行證明與反模型、在邏輯系統之間翻譯,或針對具體結構驗證公式。
- 執行需求
- 以 Python 套件形式透過 stdio 在本機執行(需 Python 3.10 以上),可用 uvx 或 python -m unicode_logic_kit.mcp 啟動,並需安裝 mcp 附加項目。Z3 隨套件提供。選用後端需另外安裝:cvc5 附加項目、Prover9 或 Vampire 等外部證明器、nanoCoP-M 所需的 Prolog(透過 UFK_NANOCOP_CMD)、owl 附加項目所需的 JVM,以及 HETS 所需的 Docker 或 UFK_HETS_URL。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Unicode Logic Kit,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
unicode-logic-kit
[Tests] [Isabelle live tests] [PyPI] [Docs]
A Python toolkit for logic with Unicode operators — parse, transform, and reason about formulas of classical first-order logic and well beyond it: modal, temporal, hybrid, many-valued, fuzzy, intuitionistic, relevant, second- and third-order, description, dependence/IF, substructural, and a range of further non-classical logics. On top of that sits infrastructure for NL→logic research: one small API a verification loop can drive, one uniform verdict type over a dozen provers, and an evaluation toolbox for scoring LLM-generated formulas against benchmark gold data.
Renamed in 0.31.0. Up to 0.30.0 this package was
unicode-fol-kit(import unicode_fol_kit): first-order logic is one of the logics it handles, not the whole of it.pip install -U unicode-fol-kitstill works — it installs this package and forwards the old import name with aDeprecationWarning— but new code shouldpip install unicode-logic-kitandimport unicode_logic_kit. Nothing else changed its name, theUFK_environment variables included.
Why this kit?
- One facade, seven verbs, built for LLM loops.
api.parse_any(dialect auto-detection over Unicode / TPTP / LaTeX / Prover9 / SMT-LIB — never raises, records every parser's objection),api.check(well-formedness + signature conformance with did-you-mean suggestions),api.equivalent,api.prove,api.countermodel,api.repair(a diagnose→suggest→fix generator whose fixer callback is your LLM),api.translate(logic-to-logic via a comorphism registry). Every result has a JSON-compatibleto_dict(), and the API carries an explicit stability policy. - Logics as values, and a translation that carries its side conditions.
FOL(MSFOL(f))converts a sorted formula and keeps its side axioms (each sort is non-empty, each sorted constant lies in its sort) with the term, as aSentence;api.proveadds them as premises itself, which is the difference between a proof and a spurious countermodel. Each of the nine registry edges declares what it preserves (comorphism.GUARANTEES), which side axioms its image needs and which options it reads; a composed path reports the weakest guarantee on it. There is no implicit coercion between logics on purpose — see Translating between logics for why a translation is not an upcast. - An MCP server out of the box.
pip install unicode-logic-kit[mcp], thenpython -m unicode_logic_kit.mcp(or, with nothing installed,uvx "unicode-logic-kit[mcp]" mcp) exposes the toolkit as thirty-seven Model Context Protocol tools (23 general-purpose, 6 for chemistry, 8 for description logic) — any MCP client (Claude Code/Desktop, agent frameworks, editors) can parse, prove, diagnose and translate without writing Python; the repair loop inverts naturally (the client LLM is the fixer). An error-analysis layer comes along: prediction-vs-gold breakdowns with symbol diffs (compare_formulas), corpus metrics (score_batch), satisfiability of premise sets with model witnesses (check_consistency), normal forms, cross-syntax rendering, truth tables, signature extraction, and DRS→FOL for discourse phenomena. - Model checking against real structures, not just model finding. A
molecule, a knowledge-graph neighbourhood, a scene graph is given — the
question is whether a definition holds of it.
FiniteStructure+evaluate_in_structureanswer that directly: no prenex form, no CNF (both are documented timeout sources elsewhere), quantifiers ranging over indexed candidate sets rather than the whole domain, counting quantifiers counted instead of expanded, and properties that are decidable on a structure but not first-order definable over it (connectivity, ring membership) admitted as computed predicates.unicode_logic_kit.chemturns a SMILES string into such a structure over the ChemLog signature. - Rule learning, both directions, with the silent failures made loud.
unicode_logic_kit.ilpturns those same structures into an ILP task (Popper'sbk.pl/exs.pl/bias.pl) and reads the learned Prolog clause back as a kit formula you can model-check. Two encoding mistakes produce a hypothesis that scores precision 1.00 and means nothing — example-local individual names a learner joins across, and the example argument on every predicate — and both are refused rather than documented, on the way out and on the way back.check_separationasks the question that has to come first: does your reference definition separate the two example sets at all? - Exact probabilistic logic — no sampling, no floats.
prob.entailment_boundsanswers "what does P(bird)=0.9 entail about P(fly)?" with the exact tightest interval (Nilsson's probabilistic entailment as a rational LP over possible worlds, conditionals included);prob.queryanswers ProbLog-style queries over definite programs with independent probabilistic facts under Sato's distribution semantics — every result an exactFraction, every unsupported fragment a loud refusal. - Twenty-five prover backends, one honest
Verdict. The kit's own calculi and semantic searches (resolution — with sound paramodulation/demodulation for equality, no hand-supplied congruence axioms needed —, analytic tableaux with recorded, independently checkable proof objects, modal tableau, finite model finder, bounded Kripke enumeration, QML embedding) are first-class citizens next to Z3, cvc5, Vampire, E, Zipperposition, Twee (equational proofs re-verified by an independent checker before the kit reports them), Prover9, Leo-III, Isabelle, nanoCoP-M (native first-order modal logic, opt-in with a mandatory independent cross-check) and a Dockerized HETS server (CASL export and round-trip import with native many-sortedness, multi-spec DOL library emission, SPASS/darwin behind one name, comorphism provenance in every verdict). Every route returns the sameVerdictwith a semantic status (proved/refuted/unknown/error), a separate why-not-more axis (timeout≠bound_hit≠incomplete≠unsupported), the SZS status, wall time, and JSON-able witnesses. Chains, portfolios (portfolio_prove, parallel with agreement thresholds and a soundness alarm on prover disagreement), and cached batch runs (batch_decide) are built on top. - An evaluation toolbox for NL→FOL work. A graded equivalence ladder (exact → canonical → vocabulary-aligned → solver, with a tri-state solver level and partial credit), AST-level symbol alignment, gold-formula self-audit, and adapters for FOLIO, MALLS, GROVES, WillowNLtoFOL, ProntoQA, ProofWriter, LogicNLI, ProverQA and FraCaS — each with its upstream schema verified at the source and its limitations documented instead of smoothed over. FraCaS is the pure-NLI one: no gold formulas at all, so the translation step is an injected callable and the kit only decides.
- Countermodels that explain themselves.
api.countermodelreturns a machine-readable witness plus a plain-English rendering ("The countermodel has 2 possible worlds. … At world 0 the formula fails."), and refutation actually covers the temporal fragment:Ⓕ P → Pcomes back refuted with a two-world Kripke witness, not "unknown". - Honesty as a contract. No route silently degrades: fuzzy input is refused by classical provers rather than collapsed, an unavailable backend raises instead of vanishing from the chain, incomplete methods report why they stopped, and every proof method has an independent checker.
One parser class, MSFLParser, reads classical logic at the first, second and third
order, each with or without sorts and with or without the modal family
(modal/temporal/epistemic/deontic/hybrid): twelve combinations of three constructor
flags. A fourth flag, fuzzy, puts the Łukasiewicz connectives in place of the two-valued
ones in each of the twelve. Next to them stand team-semantic dependence/IF logic,
intuitionistic linear logic, and the Lambek calculus.
The surface syntax is natural Unicode (∀ ∃ ∧ ∨ ¬ → ↔ ⊕ ⊗ □ ◇ @ ⊸ 𝟙 …) with 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 — the latter backed by Dyckhoff's G4ip, a genuine
terminating decision procedure for propositional intuitionistic logic — and analytic
tableaux), a finite model finder, SMT (Z3) and external-prover (Prover9 / Vampire)
backends, truth tables, and dedicated semantics for every logic. Every proof method has
an independent checker — including check_resolution_proof, which certifies
externally produced resolution derivations (paramodulation steps included) with
its own from-scratch unification, and check_tableau_proof, which re-derives
every α/β/γ/δ step of a recorded tableau with its own substitution and
δ-freshness check.
Formulas import/export to TPTP (incl. header Status/Rating metadata via
parse_tptp_problem), Prover9, SMT-LIB, LaTeX, and JSON.
📖 Documentation
Full guide and API reference: https://unicode-logic-kit.readthedocs.io/
The documentation walks through every logic with runnable examples — start with the Quickstart and Choosing a tool.
Beyond deciding formulas: Model checking (evaluate a formula in a structure you already have — including molecules), Verification (is a definition set coherent, or just too easily satisfied?), Probabilistic logic (exact bounds and queries, no sampling), and MCP (the toolkit, grammar included, as tools for a language model).
Installation
Requires Python 3.10+. Z3 ships with the package. pip install "unicode-logic-kit[cvc5]" adds cvc5 as a second in-process SMT backend (it then
joins the default proving chain right after Z3); [mcp] adds the MCP server
(python -m unicode_logic_kit.mcp); [hf] adds the HuggingFace-evaluate
metric wrapper; [owl] adds owlready2, so dl.owl_reasoner can hand a
description-logic problem to HermiT (needs a JVM on PATH) and decide the
inverse roles and nominals the in-house tableau refuses by name — note that
owlready2 is LGPL-3.0-or-later, unlike this MIT-licensed kit. Prover9, Vampire, E, Zipperposition, Twee, nanoCoP-M
(needs your own ECLiPSe/SWI-Prolog install; $UFK_NANOCOP_CMD), and
Isabelle are optional external tools you install separately to unlock the
corresponding backends, and the HETS backend wants Docker (docker pull spechub2/hets:latest; a running server is discovered on localhost:8000
or via $UFK_HETS_URL) — each is discovered explicitly and reports itself
as unavailable rather than silently disappearing.
Logics at a glance
With a local Isabelle installed, the hol subpackage's shallow embeddings become
proofs: isabelle_decide_modal / isabelle_decide_fol / isabelle_decide_relevant
actually run the prover, and hol.isabelle_substructural replays a Python-found
ILL/Lambek derivation as a machine-checked lemma. The hol.deepshallow subpackage goes
further, emitting — for propositional modal, intuitionistic, Lewis-conditional and
relevant logic, plus a Tier 2 quantified fragment (K frame, constant domain, alethic
□/◇ only) — the deep, maximal-shallow and minimal-shallow embeddings side by
side with machine-checked faithfulness proofs between them (Benzmüller,
arXiv:2502.19311), verified end to end by Isabelle. See
the higher-order guide.
Command line
--mode selects the parser dialect — fol (default), msfol, msfl, fl, modal,
second_order, dependence, linear, lambek — and --to the rendering: tree,
unicode, latex, tptp, prover9, json, dot.
The seven-verb facade is also scriptable via subcommands (--json for
machine-readable output; exit codes encode the verdict):
plus equiv, countermodel, repair, and translate.
Installed, the same command line is the command unicode-logic-kit
(unicode-logic-kit prove "Ⓕ P → P" --dialect modal), and unicode-logic-kit mcp
starts the MCP server.
Building the documentation locally
Citation
If you use this toolkit in academic work, please cite the accompanying preprint:
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
來源:README.md,提交 ec4a339
工具
0版本歷史
4- v0.35.0最新Oct 26, 2026
- v0.34.0Oct 21, 2026
- v0.33.0Oct 11, 2026
- v0.32.0Oct 10, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分