unicode-logic-kit 0.31.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unicode_logic_kit/__init__.py +385 -0
- unicode_logic_kit/__main__.py +520 -0
- unicode_logic_kit/_deadline.py +219 -0
- unicode_logic_kit/ace/__init__.py +126 -0
- unicode_logic_kit/ace/_align.py +135 -0
- unicode_logic_kit/ace/chem_lexicon.py +128 -0
- unicode_logic_kit/ace/drs_reader.py +570 -0
- unicode_logic_kit/ace/mapping.py +666 -0
- unicode_logic_kit/ace/reverse_modal.py +138 -0
- unicode_logic_kit/ace/runner.py +551 -0
- unicode_logic_kit/ace/translate.py +452 -0
- unicode_logic_kit/ace/verbalize.py +1070 -0
- unicode_logic_kit/api.py +1284 -0
- unicode_logic_kit/atp/__init__.py +177 -0
- unicode_logic_kit/atp/_ascii_names.py +113 -0
- unicode_logic_kit/atp/_html.py +72 -0
- unicode_logic_kit/atp/_substructural_input.py +228 -0
- unicode_logic_kit/atp/_tff_problem.py +715 -0
- unicode_logic_kit/atp/_tptp_problem.py +1111 -0
- unicode_logic_kit/atp/_writer_support.py +289 -0
- unicode_logic_kit/atp/clingo_backend.py +1180 -0
- unicode_logic_kit/atp/cvc5_backend.py +1385 -0
- unicode_logic_kit/atp/eprover_backend.py +732 -0
- unicode_logic_kit/atp/finite_domain.py +1055 -0
- unicode_logic_kit/atp/fitch.py +1547 -0
- unicode_logic_kit/atp/fitch_search.py +551 -0
- unicode_logic_kit/atp/hets_backend.py +339 -0
- unicode_logic_kit/atp/hybrid_down.py +120 -0
- unicode_logic_kit/atp/incremental.py +250 -0
- unicode_logic_kit/atp/kripke_enum.py +741 -0
- unicode_logic_kit/atp/lambek.py +436 -0
- unicode_logic_kit/atp/leo3_backend.py +332 -0
- unicode_logic_kit/atp/linear.py +738 -0
- unicode_logic_kit/atp/lj.py +705 -0
- unicode_logic_kit/atp/logic_backends.py +566 -0
- unicode_logic_kit/atp/ltl_tableau.py +1084 -0
- unicode_logic_kit/atp/minizinc_backend.py +1402 -0
- unicode_logic_kit/atp/modal_tableau.py +1382 -0
- unicode_logic_kit/atp/nanocop_backend.py +410 -0
- unicode_logic_kit/atp/portfolio.py +489 -0
- unicode_logic_kit/atp/protocol.py +1803 -0
- unicode_logic_kit/atp/prover9_entailment.py +1153 -0
- unicode_logic_kit/atp/resolution.py +1376 -0
- unicode_logic_kit/atp/resolution_check.py +1114 -0
- unicode_logic_kit/atp/sequent.py +1050 -0
- unicode_logic_kit/atp/tableau.py +921 -0
- unicode_logic_kit/atp/tableau_check.py +543 -0
- unicode_logic_kit/atp/tptp_ncl.py +811 -0
- unicode_logic_kit/atp/tptp_tff.py +1546 -0
- unicode_logic_kit/atp/tstp.py +1333 -0
- unicode_logic_kit/atp/tstp_check.py +1096 -0
- unicode_logic_kit/atp/twee_backend.py +236 -0
- unicode_logic_kit/atp/twee_check.py +711 -0
- unicode_logic_kit/atp/twee_entailment.py +953 -0
- unicode_logic_kit/atp/vampire_entailment.py +540 -0
- unicode_logic_kit/atp/z3_arith.py +470 -0
- unicode_logic_kit/atp/z3_equivalence.py +36 -0
- unicode_logic_kit/atp/z3_fuzzy.py +362 -0
- unicode_logic_kit/atp/z3_input.py +500 -0
- unicode_logic_kit/atp/z3_models.py +208 -0
- unicode_logic_kit/chem/__init__.py +88 -0
- unicode_logic_kit/chem/_naming.py +284 -0
- unicode_logic_kit/chem/cache.py +185 -0
- unicode_logic_kit/chem/interop.py +244 -0
- unicode_logic_kit/chem/mol.py +525 -0
- unicode_logic_kit/chem/signature.py +112 -0
- unicode_logic_kit/comorphism.py +497 -0
- unicode_logic_kit/dl/__init__.py +384 -0
- unicode_logic_kit/dl/classification.py +227 -0
- unicode_logic_kit/dl/concepts.py +632 -0
- unicode_logic_kit/dl/datatypes.py +818 -0
- unicode_logic_kit/dl/owl_functional.py +2433 -0
- unicode_logic_kit/dl/owl_manchester.py +1637 -0
- unicode_logic_kit/dl/owl_reasoner.py +790 -0
- unicode_logic_kit/dl/parser.py +391 -0
- unicode_logic_kit/dl/tableau.py +4048 -0
- unicode_logic_kit/dl/translate.py +2704 -0
- unicode_logic_kit/drt/__init__.py +94 -0
- unicode_logic_kit/drt/export.py +179 -0
- unicode_logic_kit/drt/nodes.py +506 -0
- unicode_logic_kit/drt/parser.py +965 -0
- unicode_logic_kit/drt/resolve.py +195 -0
- unicode_logic_kit/drt/reverse.py +175 -0
- unicode_logic_kit/eval/__init__.py +106 -0
- unicode_logic_kit/eval/batch.py +382 -0
- unicode_logic_kit/eval/canonical.py +663 -0
- unicode_logic_kit/eval/chem_batch.py +606 -0
- unicode_logic_kit/eval/converses.py +200 -0
- unicode_logic_kit/eval/datasets/__init__.py +136 -0
- unicode_logic_kit/eval/datasets/_base.py +263 -0
- unicode_logic_kit/eval/datasets/_proofwriter_proof.py +422 -0
- unicode_logic_kit/eval/datasets/c3po.py +678 -0
- unicode_logic_kit/eval/datasets/folio.py +158 -0
- unicode_logic_kit/eval/datasets/fracas.py +418 -0
- unicode_logic_kit/eval/datasets/groves.py +191 -0
- unicode_logic_kit/eval/datasets/logicbench.py +467 -0
- unicode_logic_kit/eval/datasets/logicnli.py +303 -0
- unicode_logic_kit/eval/datasets/malls.py +133 -0
- unicode_logic_kit/eval/datasets/pfolio.py +594 -0
- unicode_logic_kit/eval/datasets/pmb.py +242 -0
- unicode_logic_kit/eval/datasets/prontoqa.py +611 -0
- unicode_logic_kit/eval/datasets/proofwriter.py +1431 -0
- unicode_logic_kit/eval/datasets/proverqa.py +674 -0
- unicode_logic_kit/eval/datasets/willow.py +478 -0
- unicode_logic_kit/eval/equivalence.py +466 -0
- unicode_logic_kit/eval/exercise_gen.py +533 -0
- unicode_logic_kit/eval/explain.py +791 -0
- unicode_logic_kit/eval/generality.py +750 -0
- unicode_logic_kit/eval/metric_hf.py +458 -0
- unicode_logic_kit/eval/predicate_match.py +343 -0
- unicode_logic_kit/eval/theory_check.py +1170 -0
- unicode_logic_kit/eval/validate.py +306 -0
- unicode_logic_kit/fol/__init__.py +177 -0
- unicode_logic_kit/fol/_atom_keys.py +510 -0
- unicode_logic_kit/fol/_fol_nodes.py +3586 -0
- unicode_logic_kit/fol/_free_parameters.py +105 -0
- unicode_logic_kit/fol/_ho_nodes.py +448 -0
- unicode_logic_kit/fol/_hybrid_nodes.py +308 -0
- unicode_logic_kit/fol/_identifiers.py +1091 -0
- unicode_logic_kit/fol/_lambek_nodes.py +112 -0
- unicode_logic_kit/fol/_linear_nodes.py +352 -0
- unicode_logic_kit/fol/_modal_nodes.py +1467 -0
- unicode_logic_kit/fol/_msfl_nodes.py +2196 -0
- unicode_logic_kit/fol/_numeral_symbols.py +231 -0
- unicode_logic_kit/fol/_so_nodes.py +200 -0
- unicode_logic_kit/fol/_symbol_names.py +81 -0
- unicode_logic_kit/fol/_team_nodes.py +181 -0
- unicode_logic_kit/fol/_tptp_symbols.py +551 -0
- unicode_logic_kit/fol/_truth_constants.py +117 -0
- unicode_logic_kit/fol/casl_export.py +1135 -0
- unicode_logic_kit/fol/casl_import.py +929 -0
- unicode_logic_kit/fol/derivation.py +367 -0
- unicode_logic_kit/fol/dialect_detect.py +70 -0
- unicode_logic_kit/fol/dialect_repair.py +537 -0
- unicode_logic_kit/fol/frames.py +637 -0
- unicode_logic_kit/fol/grammars/terminals.lark +31 -0
- unicode_logic_kit/fol/lambda_tools.py +297 -0
- unicode_logic_kit/fol/latex_input.py +429 -0
- unicode_logic_kit/fol/modal_translation.py +944 -0
- unicode_logic_kit/fol/msflparser.py +1033 -0
- unicode_logic_kit/fol/naming.py +422 -0
- unicode_logic_kit/fol/nodes.py +241 -0
- unicode_logic_kit/fol/normalforms.py +492 -0
- unicode_logic_kit/fol/pal.py +287 -0
- unicode_logic_kit/fol/prolog_export.py +566 -0
- unicode_logic_kit/fol/prolog_input.py +505 -0
- unicode_logic_kit/fol/prover9_input.py +1325 -0
- unicode_logic_kit/fol/qml.py +1760 -0
- unicode_logic_kit/fol/qmltp_input.py +525 -0
- unicode_logic_kit/fol/sanitize.py +221 -0
- unicode_logic_kit/fol/serialize.py +79 -0
- unicode_logic_kit/fol/signature.py +1290 -0
- unicode_logic_kit/fol/simplify_check.py +544 -0
- unicode_logic_kit/fol/spans.py +594 -0
- unicode_logic_kit/fol/tptp_input.py +1503 -0
- unicode_logic_kit/fol/tptp_repair.py +941 -0
- unicode_logic_kit/fol/unification.py +157 -0
- unicode_logic_kit/fol/verbalize.py +263 -0
- unicode_logic_kit/hets/__init__.py +163 -0
- unicode_logic_kit/hets/bridge.py +142 -0
- unicode_logic_kit/hets/client.py +748 -0
- unicode_logic_kit/hets/docker.py +420 -0
- unicode_logic_kit/hets/dol.py +712 -0
- unicode_logic_kit/hets/haskell_json.py +355 -0
- unicode_logic_kit/hets/owl_backend.py +794 -0
- unicode_logic_kit/hets/owl_cli.py +598 -0
- unicode_logic_kit/hets/symbols.py +512 -0
- unicode_logic_kit/hol/__init__.py +140 -0
- unicode_logic_kit/hol/_ho_common.py +323 -0
- unicode_logic_kit/hol/_isabelle_binders.py +125 -0
- unicode_logic_kit/hol/classical.py +812 -0
- unicode_logic_kit/hol/deepshallow/__init__.py +45 -0
- unicode_logic_kit/hol/deepshallow/_common.py +177 -0
- unicode_logic_kit/hol/deepshallow/conditional.py +225 -0
- unicode_logic_kit/hol/deepshallow/intuitionistic.py +181 -0
- unicode_logic_kit/hol/deepshallow/modal.py +217 -0
- unicode_logic_kit/hol/deepshallow/qml.py +406 -0
- unicode_logic_kit/hol/deepshallow/relevant.py +206 -0
- unicode_logic_kit/hol/free.py +753 -0
- unicode_logic_kit/hol/goedel.py +336 -0
- unicode_logic_kit/hol/ho_modal.py +1743 -0
- unicode_logic_kit/hol/intuitionistic.py +403 -0
- unicode_logic_kit/hol/isabelle_conditional.py +593 -0
- unicode_logic_kit/hol/isabelle_modal.py +1908 -0
- unicode_logic_kit/hol/isabelle_relevant.py +412 -0
- unicode_logic_kit/hol/isabelle_runner.py +1147 -0
- unicode_logic_kit/hol/isabelle_substructural.py +884 -0
- unicode_logic_kit/hol/lean.py +1018 -0
- unicode_logic_kit/hol/manyvalued.py +921 -0
- unicode_logic_kit/hol/secondorder.py +687 -0
- unicode_logic_kit/hol/thf_modal.py +941 -0
- unicode_logic_kit/hol/thirdorder.py +397 -0
- unicode_logic_kit/ilp/__init__.py +89 -0
- unicode_logic_kit/ilp/readback.py +389 -0
- unicode_logic_kit/ilp/separation.py +153 -0
- unicode_logic_kit/ilp/task.py +730 -0
- unicode_logic_kit/logic.py +163 -0
- unicode_logic_kit/mcp/__init__.py +28 -0
- unicode_logic_kit/mcp/__main__.py +5 -0
- unicode_logic_kit/mcp/chem_tools.py +1031 -0
- unicode_logic_kit/mcp/server.py +2453 -0
- unicode_logic_kit/mcp/syntax_spec.py +681 -0
- unicode_logic_kit/prob/__init__.py +53 -0
- unicode_logic_kit/prob/_bdd.py +225 -0
- unicode_logic_kit/prob/_column_gen.py +668 -0
- unicode_logic_kit/prob/distribution.py +686 -0
- unicode_logic_kit/prob/nilsson.py +470 -0
- unicode_logic_kit/py.typed +0 -0
- unicode_logic_kit/semantics/__init__.py +137 -0
- unicode_logic_kit/semantics/_modal_reject.py +156 -0
- unicode_logic_kit/semantics/action_models.py +466 -0
- unicode_logic_kit/semantics/asp_models.py +1200 -0
- unicode_logic_kit/semantics/conditional.py +580 -0
- unicode_logic_kit/semantics/dynamic_epistemic.py +95 -0
- unicode_logic_kit/semantics/free_logic.py +913 -0
- unicode_logic_kit/semantics/fuzzy.py +384 -0
- unicode_logic_kit/semantics/fuzzy_kripke.py +442 -0
- unicode_logic_kit/semantics/intuitionistic.py +581 -0
- unicode_logic_kit/semantics/kripke.py +1139 -0
- unicode_logic_kit/semantics/manyvalued.py +580 -0
- unicode_logic_kit/semantics/matrix.py +342 -0
- unicode_logic_kit/semantics/model_eval.py +1135 -0
- unicode_logic_kit/semantics/modelfinder.py +1036 -0
- unicode_logic_kit/semantics/nonmonotonic.py +372 -0
- unicode_logic_kit/semantics/relevant.py +331 -0
- unicode_logic_kit/semantics/secondorder.py +657 -0
- unicode_logic_kit/semantics/structures.py +352 -0
- unicode_logic_kit/semantics/tarski.py +975 -0
- unicode_logic_kit/semantics/team.py +315 -0
- unicode_logic_kit/semantics/team_translation.py +416 -0
- unicode_logic_kit/semantics/thirdorder.py +358 -0
- unicode_logic_kit/semantics/tnorm.py +85 -0
- unicode_logic_kit/semantics/truthtable.py +201 -0
- unicode_logic_kit-0.31.0.dist-info/METADATA +333 -0
- unicode_logic_kit-0.31.0.dist-info/RECORD +237 -0
- unicode_logic_kit-0.31.0.dist-info/WHEEL +4 -0
- unicode_logic_kit-0.31.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
r"""Deep + maximal-shallow + minimal-shallow embeddings of **relevant logic B**
|
|
2
|
+
(simplified Routley–Meyer semantics), with machine-checked faithfulness proofs.
|
|
3
|
+
|
|
4
|
+
An interpretation is ``\<langle>W, N, *, R, V\<rangle>``: worlds ``W``, a set of *normal*
|
|
5
|
+
worlds ``N``, the Routley star ``*`` (involutive, interpreting ``\<not>``), a ternary
|
|
6
|
+
relation ``R`` sourced only at non-normal worlds (interpreting ``\<rightarrow>`` there), and a
|
|
7
|
+
valuation ``V`` — the simplified Priest–Sylvan semantics of
|
|
8
|
+
:mod:`unicode_logic_kit.semantics.relevant`. Truth: ``\<not>A`` at ``x`` is ``A`` false at
|
|
9
|
+
``x*``; ``A \<rightarrow> B`` at a *normal* world is universal (``\<forall>y\<in>W. y \<Turnstile> A \<longrightarrow> y \<Turnstile> B``), at a
|
|
10
|
+
non-normal world via ``R``. Validity is truth at every *normal* world of every
|
|
11
|
+
interpretation whose star is involutive and whose ``R`` is sourced at non-normal
|
|
12
|
+
worlds — sound and complete for **B**. ``\<leftrightarrow>`` desugars to ``(A \<rightarrow> B) \<and> (B \<rightarrow> A)``.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from typing import Optional
|
|
16
|
+
|
|
17
|
+
from unicode_logic_kit.fol.nodes import Node, Atom, Not, And, Or, Implies, Iff, Variable
|
|
18
|
+
from unicode_logic_kit.fol._msfl_nodes import key_text
|
|
19
|
+
from unicode_logic_kit.fol._truth_constants import refuse_truth_constants
|
|
20
|
+
from ._common import AtomConsts, wrap_theory, formula_section, NO_CONSTANT_WHY
|
|
21
|
+
|
|
22
|
+
# --------------------------------------------------------------------------- #
|
|
23
|
+
# Verified theory body (checked verbatim by the Isabelle-gated tests).
|
|
24
|
+
# --------------------------------------------------------------------------- #
|
|
25
|
+
|
|
26
|
+
_REL_BODY = r'''typedecl w \<comment> \<open>worlds\<close>
|
|
27
|
+
typedecl s \<comment> \<open>signature: propositional symbols (shared by all three embeddings)\<close>
|
|
28
|
+
type_synonym wset = "w \<Rightarrow> bool"
|
|
29
|
+
type_synonym nrm = "w \<Rightarrow> bool" \<comment> \<open>the normal worlds N\<close>
|
|
30
|
+
type_synonym star = "w \<Rightarrow> w" \<comment> \<open>the Routley star (interprets negation)\<close>
|
|
31
|
+
type_synonym tern = "w \<Rightarrow> w \<Rightarrow> w \<Rightarrow> bool" \<comment> \<open>the ternary relation R (interprets \<rightarrow>)\<close>
|
|
32
|
+
type_synonym val = "s \<Rightarrow> w \<Rightarrow> bool"
|
|
33
|
+
|
|
34
|
+
definition involutive :: "star \<Rightarrow> bool" where "involutive st \<equiv> \<forall>x. st (st x) = x"
|
|
35
|
+
definition rsource :: "nrm \<Rightarrow> tern \<Rightarrow> bool" where
|
|
36
|
+
"rsource N R \<equiv> \<forall>x y z. R x y z \<longrightarrow> \<not> N x" \<comment> \<open>R sourced only at non-normal worlds\<close>
|
|
37
|
+
|
|
38
|
+
section \<open>Deep embedding: object syntax as a datatype + recursive truth\<close>
|
|
39
|
+
|
|
40
|
+
datatype rpl =
|
|
41
|
+
Atm s | TopD | BotD
|
|
42
|
+
| NegD rpl | AndD rpl rpl | OrD rpl rpl | ImpD rpl rpl
|
|
43
|
+
|
|
44
|
+
primrec truthD :: "wset \<Rightarrow> nrm \<Rightarrow> star \<Rightarrow> tern \<Rightarrow> val \<Rightarrow> w \<Rightarrow> rpl \<Rightarrow> bool" where
|
|
45
|
+
"truthD W N st R V x (Atm p) = V p x"
|
|
46
|
+
| "truthD W N st R V x TopD = True"
|
|
47
|
+
| "truthD W N st R V x BotD = False"
|
|
48
|
+
| "truthD W N st R V x (NegD f) = (\<not> truthD W N st R V (st x) f)"
|
|
49
|
+
| "truthD W N st R V x (AndD f g) = (truthD W N st R V x f \<and> truthD W N st R V x g)"
|
|
50
|
+
| "truthD W N st R V x (OrD f g) = (truthD W N st R V x f \<or> truthD W N st R V x g)"
|
|
51
|
+
| "truthD W N st R V x (ImpD f g) =
|
|
52
|
+
((N x \<longrightarrow> (\<forall>y. W y \<longrightarrow> truthD W N st R V y f \<longrightarrow> truthD W N st R V y g))
|
|
53
|
+
\<and> (\<not> N x \<longrightarrow> (\<forall>y z. R x y z \<longrightarrow> truthD W N st R V y f \<longrightarrow> truthD W N st R V z g)))"
|
|
54
|
+
|
|
55
|
+
definition validD :: "rpl \<Rightarrow> bool" where
|
|
56
|
+
"validD f \<equiv> \<forall>W N st R V. involutive st \<longrightarrow> rsource N R \<longrightarrow>
|
|
57
|
+
(\<forall>x. W x \<longrightarrow> N x \<longrightarrow> truthD W N st R V x f)"
|
|
58
|
+
|
|
59
|
+
section \<open>Maximal (heavyweight) shallow embedding: every parameter explicit\<close>
|
|
60
|
+
|
|
61
|
+
type_synonym sigma = "wset \<Rightarrow> nrm \<Rightarrow> star \<Rightarrow> tern \<Rightarrow> val \<Rightarrow> w \<Rightarrow> bool"
|
|
62
|
+
definition AtmS :: "s \<Rightarrow> sigma" where "AtmS p \<equiv> \<lambda>W N st R V x. V p x"
|
|
63
|
+
definition TopS :: "sigma" where "TopS \<equiv> \<lambda>W N st R V x. True"
|
|
64
|
+
definition BotS :: "sigma" where "BotS \<equiv> \<lambda>W N st R V x. False"
|
|
65
|
+
definition NegS :: "sigma \<Rightarrow> sigma" where
|
|
66
|
+
"NegS f \<equiv> \<lambda>W N st R V x. \<not> f W N st R V (st x)"
|
|
67
|
+
definition AndS :: "sigma \<Rightarrow> sigma \<Rightarrow> sigma" where
|
|
68
|
+
"AndS f g \<equiv> \<lambda>W N st R V x. f W N st R V x \<and> g W N st R V x"
|
|
69
|
+
definition OrS :: "sigma \<Rightarrow> sigma \<Rightarrow> sigma" where
|
|
70
|
+
"OrS f g \<equiv> \<lambda>W N st R V x. f W N st R V x \<or> g W N st R V x"
|
|
71
|
+
definition ImpS :: "sigma \<Rightarrow> sigma \<Rightarrow> sigma" where
|
|
72
|
+
"ImpS f g \<equiv> \<lambda>W N st R V x.
|
|
73
|
+
(N x \<longrightarrow> (\<forall>y. W y \<longrightarrow> f W N st R V y \<longrightarrow> g W N st R V y))
|
|
74
|
+
\<and> (\<not> N x \<longrightarrow> (\<forall>y z. R x y z \<longrightarrow> f W N st R V y \<longrightarrow> g W N st R V z))"
|
|
75
|
+
definition validS :: "sigma \<Rightarrow> bool" where
|
|
76
|
+
"validS f \<equiv> \<forall>W N st R V. involutive st \<longrightarrow> rsource N R \<longrightarrow>
|
|
77
|
+
(\<forall>x. W x \<longrightarrow> N x \<longrightarrow> f W N st R V x)"
|
|
78
|
+
|
|
79
|
+
section \<open>Minimal (lightweight) shallow embedding: N, *, R, V fixed as consts\<close>
|
|
80
|
+
|
|
81
|
+
consts Nrm :: "nrm"
|
|
82
|
+
consts Star :: "star"
|
|
83
|
+
consts Rrel :: "tern"
|
|
84
|
+
consts Vval :: "val"
|
|
85
|
+
type_synonym tau = "w \<Rightarrow> bool"
|
|
86
|
+
definition AtmM :: "s \<Rightarrow> tau" where "AtmM p \<equiv> \<lambda>x. Vval p x"
|
|
87
|
+
definition TopM :: "tau" where "TopM \<equiv> \<lambda>x. True"
|
|
88
|
+
definition BotM :: "tau" where "BotM \<equiv> \<lambda>x. False"
|
|
89
|
+
definition NegM :: "tau \<Rightarrow> tau" where "NegM f \<equiv> \<lambda>x. \<not> f (Star x)"
|
|
90
|
+
definition AndM :: "tau \<Rightarrow> tau \<Rightarrow> tau" where "AndM f g \<equiv> \<lambda>x. f x \<and> g x"
|
|
91
|
+
definition OrM :: "tau \<Rightarrow> tau \<Rightarrow> tau" where "OrM f g \<equiv> \<lambda>x. f x \<or> g x"
|
|
92
|
+
definition ImpM :: "tau \<Rightarrow> tau \<Rightarrow> tau" where
|
|
93
|
+
"ImpM f g \<equiv> \<lambda>x.
|
|
94
|
+
(Nrm x \<longrightarrow> (\<forall>y. f y \<longrightarrow> g y))
|
|
95
|
+
\<and> (\<not> Nrm x \<longrightarrow> (\<forall>y z. Rrel x y z \<longrightarrow> f y \<longrightarrow> g z))"
|
|
96
|
+
definition validM :: "tau \<Rightarrow> bool" where "validM f \<equiv> \<forall>x. Nrm x \<longrightarrow> f x"
|
|
97
|
+
|
|
98
|
+
section \<open>Mappings between the embeddings\<close>
|
|
99
|
+
|
|
100
|
+
primrec dpToMax :: "rpl \<Rightarrow> sigma" where
|
|
101
|
+
"dpToMax (Atm p) = AtmS p"
|
|
102
|
+
| "dpToMax TopD = TopS"
|
|
103
|
+
| "dpToMax BotD = BotS"
|
|
104
|
+
| "dpToMax (NegD f) = NegS (dpToMax f)"
|
|
105
|
+
| "dpToMax (AndD f g) = AndS (dpToMax f) (dpToMax g)"
|
|
106
|
+
| "dpToMax (OrD f g) = OrS (dpToMax f) (dpToMax g)"
|
|
107
|
+
| "dpToMax (ImpD f g) = ImpS (dpToMax f) (dpToMax g)"
|
|
108
|
+
|
|
109
|
+
primrec dpToMin :: "rpl \<Rightarrow> tau" where
|
|
110
|
+
"dpToMin (Atm p) = AtmM p"
|
|
111
|
+
| "dpToMin TopD = TopM"
|
|
112
|
+
| "dpToMin BotD = BotM"
|
|
113
|
+
| "dpToMin (NegD f) = NegM (dpToMin f)"
|
|
114
|
+
| "dpToMin (AndD f g) = AndM (dpToMin f) (dpToMin g)"
|
|
115
|
+
| "dpToMin (OrD f g) = OrM (dpToMin f) (dpToMin g)"
|
|
116
|
+
| "dpToMin (ImpD f g) = ImpM (dpToMin f) (dpToMin g)"
|
|
117
|
+
|
|
118
|
+
section \<open>Faithfulness (machine-checked by Isabelle's kernel)\<close>
|
|
119
|
+
|
|
120
|
+
lemmas maxdefs = AtmS_def TopS_def BotS_def NegS_def AndS_def OrS_def ImpS_def
|
|
121
|
+
lemmas mindefs = AtmM_def TopM_def BotM_def NegM_def AndM_def OrM_def ImpM_def
|
|
122
|
+
|
|
123
|
+
text \<open>Deep truth coincides pointwise with maximal-shallow truth.\<close>
|
|
124
|
+
theorem faithful1a: "truthD W N st R V x f = dpToMax f W N st R V x"
|
|
125
|
+
by (induct f arbitrary: x) (simp_all add: maxdefs)
|
|
126
|
+
|
|
127
|
+
text \<open>Hence deep validity coincides with maximal-shallow validity.\<close>
|
|
128
|
+
theorem faithful1b: "validD f = validS (dpToMax f)"
|
|
129
|
+
by (simp add: validD_def validS_def faithful1a)
|
|
130
|
+
|
|
131
|
+
text \<open>Deep truth in the fixed model coincides with minimal-shallow truth.\<close>
|
|
132
|
+
theorem faithful2: "truthD (\<lambda>_. True) Nrm Star Rrel Vval x f = dpToMin f x"
|
|
133
|
+
by (induct f arbitrary: x) (simp_all add: mindefs)
|
|
134
|
+
|
|
135
|
+
text \<open>Maximal- and minimal-shallow truth coincide in that fixed model.\<close>
|
|
136
|
+
theorem faithful3: "dpToMax f (\<lambda>_. True) Nrm Star Rrel Vval x = dpToMin f x"
|
|
137
|
+
by (induct f arbitrary: x) (simp_all add: maxdefs mindefs)
|
|
138
|
+
|
|
139
|
+
text \<open>Soundness of the minimal embedding for deep validity (under the frame
|
|
140
|
+
assumptions the minimal embedding fixes as consts: involutive star,
|
|
141
|
+
R sourced at non-normal worlds). Validity is truth at NORMAL worlds.\<close>
|
|
142
|
+
theorem sound_min:
|
|
143
|
+
"involutive Star \<Longrightarrow> rsource Nrm Rrel \<Longrightarrow> validD f \<Longrightarrow> validM (dpToMin f)"
|
|
144
|
+
proof -
|
|
145
|
+
assume inv: "involutive Star" and rs: "rsource Nrm Rrel" and *: "validD f"
|
|
146
|
+
have "Nrm x \<longrightarrow> truthD (\<lambda>_. True) Nrm Star Rrel Vval x f" for x
|
|
147
|
+
using * inv rs by (simp add: validD_def)
|
|
148
|
+
then show "validM (dpToMin f)"
|
|
149
|
+
by (simp add: validM_def faithful2)
|
|
150
|
+
qed'''
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
# --------------------------------------------------------------------------- #
|
|
154
|
+
# Encoder + public entry point.
|
|
155
|
+
# --------------------------------------------------------------------------- #
|
|
156
|
+
|
|
157
|
+
_ARROW = {And: "AndD", Or: "OrD", Implies: "ImpD"}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def rel_to_deep(formula: Node, atoms: AtomConsts) -> str:
|
|
161
|
+
r"""Encode a **propositional relevant** formula as a deep ``rpl`` term.
|
|
162
|
+
|
|
163
|
+
Handles atoms, ``\<not> \<and> \<or> \<rightarrow>`` and ``\<leftrightarrow>`` (which desugars to
|
|
164
|
+
``(A \<rightarrow> B) \<and> (B \<rightarrow> A)``, matching :mod:`unicode_logic_kit.semantics.relevant`).
|
|
165
|
+
Raises :class:`NotImplementedError` on any other node (modalities, ``Xor``,
|
|
166
|
+
quantifiers, free variables).
|
|
167
|
+
"""
|
|
168
|
+
if isinstance(formula, Atom):
|
|
169
|
+
refuse_truth_constants([formula], "rel_to_deep", NO_CONSTANT_WHY)
|
|
170
|
+
if any(isinstance(n, Variable) for a in formula.args for n in a.walk()):
|
|
171
|
+
raise NotImplementedError(
|
|
172
|
+
"rel_to_deep: atom with a free variable is first-order; the deep "
|
|
173
|
+
"embedding is propositional.")
|
|
174
|
+
return f"(Atm {atoms.name(key_text(formula))})"
|
|
175
|
+
if isinstance(formula, Not):
|
|
176
|
+
return f"(NegD {rel_to_deep(formula.formula, atoms)})"
|
|
177
|
+
if isinstance(formula, Iff):
|
|
178
|
+
a = rel_to_deep(formula.left, atoms)
|
|
179
|
+
b = rel_to_deep(formula.right, atoms)
|
|
180
|
+
return f"(AndD (ImpD {a} {b}) (ImpD {b} {a}))"
|
|
181
|
+
if type(formula) in _ARROW:
|
|
182
|
+
ctor = _ARROW[type(formula)]
|
|
183
|
+
a = rel_to_deep(formula.left, atoms)
|
|
184
|
+
b = rel_to_deep(formula.right, atoms)
|
|
185
|
+
return f"({ctor} {a} {b})"
|
|
186
|
+
raise NotImplementedError(
|
|
187
|
+
f"rel_to_deep: unsupported node type {type(formula).__name__} "
|
|
188
|
+
"(propositional relevant fragment: atoms, ¬ ∧ ∨ → ↔).")
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def relevant_faithfulness_theory(
|
|
192
|
+
theory_name: str = "RelFaithfulness",
|
|
193
|
+
formula: Optional[Node] = None,
|
|
194
|
+
) -> str:
|
|
195
|
+
r"""Emit the self-contained relevant-B deep/maximal/minimal + faithfulness theory.
|
|
196
|
+
|
|
197
|
+
When ``formula`` is given, its deep encoding is appended as
|
|
198
|
+
``definition example :: rpl``. With a local Isabelle/HOL the theory is verified
|
|
199
|
+
end to end by :func:`unicode_logic_kit.hol.isabelle_runner.check_theory`.
|
|
200
|
+
"""
|
|
201
|
+
extra = ""
|
|
202
|
+
if formula is not None:
|
|
203
|
+
atoms = AtomConsts()
|
|
204
|
+
term = rel_to_deep(formula, atoms)
|
|
205
|
+
extra = formula_section(term, atoms, "rpl")
|
|
206
|
+
return wrap_theory(theory_name, _REL_BODY, extra)
|