unicode_fol_kit.hol.isabelle_runner¶
Run a local Isabelle to actually discharge the emitted shallow-embedding
theories — turning the unicode_fol_kit.hol exporters from emit into
proven / refuted.
The rest of the toolkit only emits HOL/Isabelle/THF problem files (see the
hol package docstring): it is honest that first-order modal logic, FOL and
SOL are undecidable, so an emission is “a sound problem a prover may discharge”.
This module is the opt-in other half: if a local Isabelle/HOL is installed, it
writes the emitted theory to a scratch session, invokes isabelle build, and
reads the verdict off the build — a real proof, not a promise.
Decision procedure for modal validity (isabelle_decide_modal())¶
The shallow embedding is faithful to the Kripke evaluator
unicode_fol_kit.semantics.kripke.satisfies_modal(), so deciding the emitted
lemma decides the modal formula (for the chosen frame / domain regime):
Prove — emit
lemma <goal>with a proof that brings the frame/domain axioms into scope and tries a battery of methods (using <axioms> by (blast | force | fastforce | auto | meson … | metis …)). Ifisabelle buildexits 0, the lemma is a theorem ⇒ the formula is VALID.Refute — otherwise emit the same lemma followed by
nitpick[expect = genuine]. Nitpick searches for a finite counter-model;expect = genuinemakes the build succeed iff a genuine counter-model is found, so exit 0 here ⇒ the formula is INVALID. The verdict is certified by the exit code; for the propositional alethic fragmentModalVerdict.countermodelthen carries a concrete Kripke counter-model reconstructed from the toolkit’s own evaluator (isabelle builddoes not echo nitpick’s model), and isNonefor fragments the bounded search does not cover — never weakening the verdict.Otherwise the result is UNKNOWN (neither a battery proof nor a finite counter-model within the time/size budget — expected, since the logic is undecidable).
This is sound (Isabelle’s kernel certifies the proof; nitpick reports only genuine counter-models), and necessarily incomplete.
Honesty / soundness boundary¶
A VALID / INVALID verdict is only as meaningful as the embedding’s faithfulness to the chosen semantics. UNKNOWN is a real outcome, not a failure. The runner never claims a decision it did not obtain from the prover.
Platform support¶
Linux and macOS are the primary path: the isabelle binary is invoked
directly (isabelle build -D <dir>) with nothing platform-specific. Windows
is also supported — Isabelle ships its own Cygwin and its CLI is a Bash script, so
there the runner additionally routes the build through contrib/cygwin/bin/bash,
translates the scratch path to a /cygdrive/... path, and (idempotently) sets the
execute bit on the launcher scripts (some installs ship them without it, which makes
the internal exec isabelle java fail with Permission denied). No install path
is ever hard-coded; installations are discovered generically (see below).
Locating Isabelle¶
find_isabelle() looks, in order, at an explicit path, the env vars
UFK_ISABELLE_HOME / ISABELLE_HOME, isabelle on PATH, and a light
scan of standard install locations. isabelle_available() is the cheap
predicate tests gate on (skip when no Isabelle is present).
Functions
|
Build one self-contained Isabelle theory and report whether it loads/proves. |
|
Locate an Isabelle installation, or return |
|
|
|
Decide a classical FOL (or MSFOL) formula's validity by running Isabelle. |
|
Decide a modal formula's validity by running a local Isabelle. |
Classes
|
Outcome of building one scratch theory with |
|
Result of deciding a classical FOL formula's validity through Isabelle. |
|
A located Isabelle/HOL installation and how to invoke its CLI. |
|
Result of deciding a modal formula's validity through Isabelle. |
Exceptions
Raised when an Isabelle install is required but none could be located. |
- exception unicode_fol_kit.hol.isabelle_runner.IsabelleNotAvailable[source]¶
Bases:
RuntimeErrorRaised when an Isabelle install is required but none could be located.
- class unicode_fol_kit.hol.isabelle_runner.IsabelleInstall(home, is_windows, isabelle_exe, cygwin_bash=None, version=None)[source]¶
Bases:
objectA located Isabelle/HOL installation and how to invoke its CLI.
- Parameters:
- class unicode_fol_kit.hol.isabelle_runner.BuildResult(ok, exit_code, output, theory_name, session, elapsed)[source]¶
Bases:
objectOutcome of building one scratch theory with
isabelle build.
- class unicode_fol_kit.hol.isabelle_runner.ModalVerdict(status, frame, mode, method=None, countermodel=None, prove_output='', refute_output='', prove_elapsed=0.0, refute_elapsed=0.0, infra_error=None)[source]¶
Bases:
objectResult of deciding a modal formula’s validity through Isabelle.
statusis one of"valid"(a battery proof closed the lemma),"invalid"(nitpick found a genuine counter-model), or"unknown"(neither, within budget). Truthiness follows validity. On an"unknown"result,infra_erroris set to a short signature when a build failed for an infrastructure reason (syntax/JVM/timeout/…) rather than honest incompleteness — it never changes the status (an infra failure can only land on UNKNOWN).- Parameters:
- class unicode_fol_kit.hol.isabelle_runner.FolVerdict(status, method=None, countermodel=None, prove_output='', refute_output='', prove_elapsed=0.0, refute_elapsed=0.0, infra_error=None)[source]¶
Bases:
objectResult of deciding a classical FOL formula’s validity through Isabelle.
Same VALID / INVALID / UNKNOWN scheme as
ModalVerdict(no frame/mode). Note that FOL is only semi-decidable, so UNKNOWN is common and expected; and equality=/≠is the uninterpreted predicatefeq/fneqofto_isabelle_fol()(no equality axioms are assumed), so e.g.∀x. x = xis not VALID here.- Parameters:
- unicode_fol_kit.hol.isabelle_runner.find_isabelle(isabelle_home=None, *, use_cache=True)[source]¶
Locate an Isabelle installation, or return
Noneif none is found.Search order:
isabelle_homeargument → envUFK_ISABELLE_HOME→ envISABELLE_HOME→isabelleonPATH→ a light scan of standard install locations. The result is cached (keyed by the explicit argument); passuse_cache=Falseto force a fresh lookup.- Parameters:
- Return type:
IsabelleInstall | None
- unicode_fol_kit.hol.isabelle_runner.isabelle_available(isabelle_home=None)[source]¶
Trueiff an Isabelle installation can be located (cheap; cached).
- unicode_fol_kit.hol.isabelle_runner.check_theory(theory_text, theory_name, *, install=None, session=None, session_timeout=120, wall_timeout=None, keep=False)[source]¶
Build one self-contained Isabelle theory and report whether it loads/proves.
Writes
<theory_name>.thyplus aROOT(session ... = HOL + options [timeout] theories <theory_name>) into a scratch directory and runsisabelle buildon it.okisTrueiff the build exits 0 — i.e. every proof in the theory was discharged by Isabelle’s kernel.- Parameters:
theory_text (str) – the full
theory <theory_name> ... endtext. Its declared theory name MUST equaltheory_name.theory_name (str) – the theory / file name (a valid Isabelle identifier).
install (IsabelleInstall | None) – an
IsabelleInstall; located viafind_isabelle()whenNone.session (str | None) – the build session name (default
"S_" + theory_name).session_timeout (int) – per-session Isabelle
timeoutoption, in seconds.wall_timeout (float | None) – hard subprocess timeout; defaults to
session_timeout + 180to cover JVM startup + image load.keep (bool) – keep the scratch directory (for debugging) instead of deleting it.
- Raises:
IsabelleNotAvailable – if no Isabelle installation can be located.
- Return type:
- unicode_fol_kit.hol.isabelle_runner.isabelle_decide_modal(formula, *, frame='K', mode='constant', temporal_closure=True, methods=('blast', 'force', 'fastforce', 'auto', 'meson', 'metis'), refute=True, card='1-4', prove_timeout=60, refute_timeout=60, install=None)[source]¶
Decide a modal formula’s validity by running a local Isabelle.
Emits the Benzmüller shallow embedding of
formula(isabelle_modal_theory(), faithful tosatisfies_modal()) and:tries a proof battery — exit 0 ⇒
VALID;otherwise (
refute) runsnitpick[expect = genuine]— exit 0 ⇒INVALID(certified by the exit code; for the propositional alethic fragmentcountermodelcarries a concrete Kripke model from the toolkit’s evaluator, elseNone);otherwise
UNKNOWN.
- Parameters:
formula (Node) – the modal AST node.
frame (str) – alethic frame system (K/T/S4/S5/KD/KD45) — fixes the axioms on
r.mode (str) – object-quantifier domain regime (constant/possibilist/varying/…).
temporal_closure (bool) – constrain the temporal relation to refl+trans (henceforth).
methods (Sequence[str]) – proof methods tried, in order, as a
by (… | …)battery.refute (bool) – also run nitpick to certify INVALID when the proof battery fails.
card (str) – nitpick cardinality range for the world type
i(e.g."1-4").refute_timeout (int) – per-session Isabelle timeouts (seconds).
install (IsabelleInstall | None) – an
IsabelleInstall; located viafind_isabelle()whenNone.prove_timeout (int)
refute_timeout
- Returns:
A
ModalVerdict.- Raises:
IsabelleNotAvailable – if no Isabelle installation can be located.
ValueError / NotImplementedError – propagated from the emitter for an unsupported frame/mode/operator (e.g.
Until).
- Return type:
- unicode_fol_kit.hol.isabelle_runner.isabelle_decide_fol(formula, *, msfol=False, methods=('blast', 'force', 'fastforce', 'auto', 'meson', 'metis'), refute=True, card='1-4', prove_timeout=60, refute_timeout=60, install=None)[source]¶
Decide a classical FOL (or MSFOL) formula’s validity by running Isabelle.
Emits the uninterpreted-signature embedding (
to_isabelle_fol(), orto_isabelle_msfolwhenmsfol=True) and, exactly likeisabelle_decide_modal():tries a proof battery — exit 0 ⇒
VALID;otherwise (
refute) runsnitpick[expect = genuine]over the individual typei— exit 0 ⇒INVALID;otherwise
UNKNOWN(common — FOL is only semi-decidable).
Sound (Isabelle’s kernel certifies the proof; nitpick reports only genuine finite counter-models) and necessarily incomplete. Equality is uninterpreted (see
FolVerdict).- Parameters:
formula (Node) – the FOL AST node.
msfol (bool) – emit the many-sorted embedding (sorts relativised to guard predicates) instead of plain FOL.
install (IsabelleInstall | None) – as for
isabelle_decide_modal()(cardbounds the individual typei).refute (bool)
card (str)
prove_timeout (int)
refute_timeout (int)
install
- Raises:
IsabelleNotAvailable – if no Isabelle installation can be located.
- Return type: