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.
Files changed (237) hide show
  1. unicode_logic_kit/__init__.py +385 -0
  2. unicode_logic_kit/__main__.py +520 -0
  3. unicode_logic_kit/_deadline.py +219 -0
  4. unicode_logic_kit/ace/__init__.py +126 -0
  5. unicode_logic_kit/ace/_align.py +135 -0
  6. unicode_logic_kit/ace/chem_lexicon.py +128 -0
  7. unicode_logic_kit/ace/drs_reader.py +570 -0
  8. unicode_logic_kit/ace/mapping.py +666 -0
  9. unicode_logic_kit/ace/reverse_modal.py +138 -0
  10. unicode_logic_kit/ace/runner.py +551 -0
  11. unicode_logic_kit/ace/translate.py +452 -0
  12. unicode_logic_kit/ace/verbalize.py +1070 -0
  13. unicode_logic_kit/api.py +1284 -0
  14. unicode_logic_kit/atp/__init__.py +177 -0
  15. unicode_logic_kit/atp/_ascii_names.py +113 -0
  16. unicode_logic_kit/atp/_html.py +72 -0
  17. unicode_logic_kit/atp/_substructural_input.py +228 -0
  18. unicode_logic_kit/atp/_tff_problem.py +715 -0
  19. unicode_logic_kit/atp/_tptp_problem.py +1111 -0
  20. unicode_logic_kit/atp/_writer_support.py +289 -0
  21. unicode_logic_kit/atp/clingo_backend.py +1180 -0
  22. unicode_logic_kit/atp/cvc5_backend.py +1385 -0
  23. unicode_logic_kit/atp/eprover_backend.py +732 -0
  24. unicode_logic_kit/atp/finite_domain.py +1055 -0
  25. unicode_logic_kit/atp/fitch.py +1547 -0
  26. unicode_logic_kit/atp/fitch_search.py +551 -0
  27. unicode_logic_kit/atp/hets_backend.py +339 -0
  28. unicode_logic_kit/atp/hybrid_down.py +120 -0
  29. unicode_logic_kit/atp/incremental.py +250 -0
  30. unicode_logic_kit/atp/kripke_enum.py +741 -0
  31. unicode_logic_kit/atp/lambek.py +436 -0
  32. unicode_logic_kit/atp/leo3_backend.py +332 -0
  33. unicode_logic_kit/atp/linear.py +738 -0
  34. unicode_logic_kit/atp/lj.py +705 -0
  35. unicode_logic_kit/atp/logic_backends.py +566 -0
  36. unicode_logic_kit/atp/ltl_tableau.py +1084 -0
  37. unicode_logic_kit/atp/minizinc_backend.py +1402 -0
  38. unicode_logic_kit/atp/modal_tableau.py +1382 -0
  39. unicode_logic_kit/atp/nanocop_backend.py +410 -0
  40. unicode_logic_kit/atp/portfolio.py +489 -0
  41. unicode_logic_kit/atp/protocol.py +1803 -0
  42. unicode_logic_kit/atp/prover9_entailment.py +1153 -0
  43. unicode_logic_kit/atp/resolution.py +1376 -0
  44. unicode_logic_kit/atp/resolution_check.py +1114 -0
  45. unicode_logic_kit/atp/sequent.py +1050 -0
  46. unicode_logic_kit/atp/tableau.py +921 -0
  47. unicode_logic_kit/atp/tableau_check.py +543 -0
  48. unicode_logic_kit/atp/tptp_ncl.py +811 -0
  49. unicode_logic_kit/atp/tptp_tff.py +1546 -0
  50. unicode_logic_kit/atp/tstp.py +1333 -0
  51. unicode_logic_kit/atp/tstp_check.py +1096 -0
  52. unicode_logic_kit/atp/twee_backend.py +236 -0
  53. unicode_logic_kit/atp/twee_check.py +711 -0
  54. unicode_logic_kit/atp/twee_entailment.py +953 -0
  55. unicode_logic_kit/atp/vampire_entailment.py +540 -0
  56. unicode_logic_kit/atp/z3_arith.py +470 -0
  57. unicode_logic_kit/atp/z3_equivalence.py +36 -0
  58. unicode_logic_kit/atp/z3_fuzzy.py +362 -0
  59. unicode_logic_kit/atp/z3_input.py +500 -0
  60. unicode_logic_kit/atp/z3_models.py +208 -0
  61. unicode_logic_kit/chem/__init__.py +88 -0
  62. unicode_logic_kit/chem/_naming.py +284 -0
  63. unicode_logic_kit/chem/cache.py +185 -0
  64. unicode_logic_kit/chem/interop.py +244 -0
  65. unicode_logic_kit/chem/mol.py +525 -0
  66. unicode_logic_kit/chem/signature.py +112 -0
  67. unicode_logic_kit/comorphism.py +497 -0
  68. unicode_logic_kit/dl/__init__.py +384 -0
  69. unicode_logic_kit/dl/classification.py +227 -0
  70. unicode_logic_kit/dl/concepts.py +632 -0
  71. unicode_logic_kit/dl/datatypes.py +818 -0
  72. unicode_logic_kit/dl/owl_functional.py +2433 -0
  73. unicode_logic_kit/dl/owl_manchester.py +1637 -0
  74. unicode_logic_kit/dl/owl_reasoner.py +790 -0
  75. unicode_logic_kit/dl/parser.py +391 -0
  76. unicode_logic_kit/dl/tableau.py +4048 -0
  77. unicode_logic_kit/dl/translate.py +2704 -0
  78. unicode_logic_kit/drt/__init__.py +94 -0
  79. unicode_logic_kit/drt/export.py +179 -0
  80. unicode_logic_kit/drt/nodes.py +506 -0
  81. unicode_logic_kit/drt/parser.py +965 -0
  82. unicode_logic_kit/drt/resolve.py +195 -0
  83. unicode_logic_kit/drt/reverse.py +175 -0
  84. unicode_logic_kit/eval/__init__.py +106 -0
  85. unicode_logic_kit/eval/batch.py +382 -0
  86. unicode_logic_kit/eval/canonical.py +663 -0
  87. unicode_logic_kit/eval/chem_batch.py +606 -0
  88. unicode_logic_kit/eval/converses.py +200 -0
  89. unicode_logic_kit/eval/datasets/__init__.py +136 -0
  90. unicode_logic_kit/eval/datasets/_base.py +263 -0
  91. unicode_logic_kit/eval/datasets/_proofwriter_proof.py +422 -0
  92. unicode_logic_kit/eval/datasets/c3po.py +678 -0
  93. unicode_logic_kit/eval/datasets/folio.py +158 -0
  94. unicode_logic_kit/eval/datasets/fracas.py +418 -0
  95. unicode_logic_kit/eval/datasets/groves.py +191 -0
  96. unicode_logic_kit/eval/datasets/logicbench.py +467 -0
  97. unicode_logic_kit/eval/datasets/logicnli.py +303 -0
  98. unicode_logic_kit/eval/datasets/malls.py +133 -0
  99. unicode_logic_kit/eval/datasets/pfolio.py +594 -0
  100. unicode_logic_kit/eval/datasets/pmb.py +242 -0
  101. unicode_logic_kit/eval/datasets/prontoqa.py +611 -0
  102. unicode_logic_kit/eval/datasets/proofwriter.py +1431 -0
  103. unicode_logic_kit/eval/datasets/proverqa.py +674 -0
  104. unicode_logic_kit/eval/datasets/willow.py +478 -0
  105. unicode_logic_kit/eval/equivalence.py +466 -0
  106. unicode_logic_kit/eval/exercise_gen.py +533 -0
  107. unicode_logic_kit/eval/explain.py +791 -0
  108. unicode_logic_kit/eval/generality.py +750 -0
  109. unicode_logic_kit/eval/metric_hf.py +458 -0
  110. unicode_logic_kit/eval/predicate_match.py +343 -0
  111. unicode_logic_kit/eval/theory_check.py +1170 -0
  112. unicode_logic_kit/eval/validate.py +306 -0
  113. unicode_logic_kit/fol/__init__.py +177 -0
  114. unicode_logic_kit/fol/_atom_keys.py +510 -0
  115. unicode_logic_kit/fol/_fol_nodes.py +3586 -0
  116. unicode_logic_kit/fol/_free_parameters.py +105 -0
  117. unicode_logic_kit/fol/_ho_nodes.py +448 -0
  118. unicode_logic_kit/fol/_hybrid_nodes.py +308 -0
  119. unicode_logic_kit/fol/_identifiers.py +1091 -0
  120. unicode_logic_kit/fol/_lambek_nodes.py +112 -0
  121. unicode_logic_kit/fol/_linear_nodes.py +352 -0
  122. unicode_logic_kit/fol/_modal_nodes.py +1467 -0
  123. unicode_logic_kit/fol/_msfl_nodes.py +2196 -0
  124. unicode_logic_kit/fol/_numeral_symbols.py +231 -0
  125. unicode_logic_kit/fol/_so_nodes.py +200 -0
  126. unicode_logic_kit/fol/_symbol_names.py +81 -0
  127. unicode_logic_kit/fol/_team_nodes.py +181 -0
  128. unicode_logic_kit/fol/_tptp_symbols.py +551 -0
  129. unicode_logic_kit/fol/_truth_constants.py +117 -0
  130. unicode_logic_kit/fol/casl_export.py +1135 -0
  131. unicode_logic_kit/fol/casl_import.py +929 -0
  132. unicode_logic_kit/fol/derivation.py +367 -0
  133. unicode_logic_kit/fol/dialect_detect.py +70 -0
  134. unicode_logic_kit/fol/dialect_repair.py +537 -0
  135. unicode_logic_kit/fol/frames.py +637 -0
  136. unicode_logic_kit/fol/grammars/terminals.lark +31 -0
  137. unicode_logic_kit/fol/lambda_tools.py +297 -0
  138. unicode_logic_kit/fol/latex_input.py +429 -0
  139. unicode_logic_kit/fol/modal_translation.py +944 -0
  140. unicode_logic_kit/fol/msflparser.py +1033 -0
  141. unicode_logic_kit/fol/naming.py +422 -0
  142. unicode_logic_kit/fol/nodes.py +241 -0
  143. unicode_logic_kit/fol/normalforms.py +492 -0
  144. unicode_logic_kit/fol/pal.py +287 -0
  145. unicode_logic_kit/fol/prolog_export.py +566 -0
  146. unicode_logic_kit/fol/prolog_input.py +505 -0
  147. unicode_logic_kit/fol/prover9_input.py +1325 -0
  148. unicode_logic_kit/fol/qml.py +1760 -0
  149. unicode_logic_kit/fol/qmltp_input.py +525 -0
  150. unicode_logic_kit/fol/sanitize.py +221 -0
  151. unicode_logic_kit/fol/serialize.py +79 -0
  152. unicode_logic_kit/fol/signature.py +1290 -0
  153. unicode_logic_kit/fol/simplify_check.py +544 -0
  154. unicode_logic_kit/fol/spans.py +594 -0
  155. unicode_logic_kit/fol/tptp_input.py +1503 -0
  156. unicode_logic_kit/fol/tptp_repair.py +941 -0
  157. unicode_logic_kit/fol/unification.py +157 -0
  158. unicode_logic_kit/fol/verbalize.py +263 -0
  159. unicode_logic_kit/hets/__init__.py +163 -0
  160. unicode_logic_kit/hets/bridge.py +142 -0
  161. unicode_logic_kit/hets/client.py +748 -0
  162. unicode_logic_kit/hets/docker.py +420 -0
  163. unicode_logic_kit/hets/dol.py +712 -0
  164. unicode_logic_kit/hets/haskell_json.py +355 -0
  165. unicode_logic_kit/hets/owl_backend.py +794 -0
  166. unicode_logic_kit/hets/owl_cli.py +598 -0
  167. unicode_logic_kit/hets/symbols.py +512 -0
  168. unicode_logic_kit/hol/__init__.py +140 -0
  169. unicode_logic_kit/hol/_ho_common.py +323 -0
  170. unicode_logic_kit/hol/_isabelle_binders.py +125 -0
  171. unicode_logic_kit/hol/classical.py +812 -0
  172. unicode_logic_kit/hol/deepshallow/__init__.py +45 -0
  173. unicode_logic_kit/hol/deepshallow/_common.py +177 -0
  174. unicode_logic_kit/hol/deepshallow/conditional.py +225 -0
  175. unicode_logic_kit/hol/deepshallow/intuitionistic.py +181 -0
  176. unicode_logic_kit/hol/deepshallow/modal.py +217 -0
  177. unicode_logic_kit/hol/deepshallow/qml.py +406 -0
  178. unicode_logic_kit/hol/deepshallow/relevant.py +206 -0
  179. unicode_logic_kit/hol/free.py +753 -0
  180. unicode_logic_kit/hol/goedel.py +336 -0
  181. unicode_logic_kit/hol/ho_modal.py +1743 -0
  182. unicode_logic_kit/hol/intuitionistic.py +403 -0
  183. unicode_logic_kit/hol/isabelle_conditional.py +593 -0
  184. unicode_logic_kit/hol/isabelle_modal.py +1908 -0
  185. unicode_logic_kit/hol/isabelle_relevant.py +412 -0
  186. unicode_logic_kit/hol/isabelle_runner.py +1147 -0
  187. unicode_logic_kit/hol/isabelle_substructural.py +884 -0
  188. unicode_logic_kit/hol/lean.py +1018 -0
  189. unicode_logic_kit/hol/manyvalued.py +921 -0
  190. unicode_logic_kit/hol/secondorder.py +687 -0
  191. unicode_logic_kit/hol/thf_modal.py +941 -0
  192. unicode_logic_kit/hol/thirdorder.py +397 -0
  193. unicode_logic_kit/ilp/__init__.py +89 -0
  194. unicode_logic_kit/ilp/readback.py +389 -0
  195. unicode_logic_kit/ilp/separation.py +153 -0
  196. unicode_logic_kit/ilp/task.py +730 -0
  197. unicode_logic_kit/logic.py +163 -0
  198. unicode_logic_kit/mcp/__init__.py +28 -0
  199. unicode_logic_kit/mcp/__main__.py +5 -0
  200. unicode_logic_kit/mcp/chem_tools.py +1031 -0
  201. unicode_logic_kit/mcp/server.py +2453 -0
  202. unicode_logic_kit/mcp/syntax_spec.py +681 -0
  203. unicode_logic_kit/prob/__init__.py +53 -0
  204. unicode_logic_kit/prob/_bdd.py +225 -0
  205. unicode_logic_kit/prob/_column_gen.py +668 -0
  206. unicode_logic_kit/prob/distribution.py +686 -0
  207. unicode_logic_kit/prob/nilsson.py +470 -0
  208. unicode_logic_kit/py.typed +0 -0
  209. unicode_logic_kit/semantics/__init__.py +137 -0
  210. unicode_logic_kit/semantics/_modal_reject.py +156 -0
  211. unicode_logic_kit/semantics/action_models.py +466 -0
  212. unicode_logic_kit/semantics/asp_models.py +1200 -0
  213. unicode_logic_kit/semantics/conditional.py +580 -0
  214. unicode_logic_kit/semantics/dynamic_epistemic.py +95 -0
  215. unicode_logic_kit/semantics/free_logic.py +913 -0
  216. unicode_logic_kit/semantics/fuzzy.py +384 -0
  217. unicode_logic_kit/semantics/fuzzy_kripke.py +442 -0
  218. unicode_logic_kit/semantics/intuitionistic.py +581 -0
  219. unicode_logic_kit/semantics/kripke.py +1139 -0
  220. unicode_logic_kit/semantics/manyvalued.py +580 -0
  221. unicode_logic_kit/semantics/matrix.py +342 -0
  222. unicode_logic_kit/semantics/model_eval.py +1135 -0
  223. unicode_logic_kit/semantics/modelfinder.py +1036 -0
  224. unicode_logic_kit/semantics/nonmonotonic.py +372 -0
  225. unicode_logic_kit/semantics/relevant.py +331 -0
  226. unicode_logic_kit/semantics/secondorder.py +657 -0
  227. unicode_logic_kit/semantics/structures.py +352 -0
  228. unicode_logic_kit/semantics/tarski.py +975 -0
  229. unicode_logic_kit/semantics/team.py +315 -0
  230. unicode_logic_kit/semantics/team_translation.py +416 -0
  231. unicode_logic_kit/semantics/thirdorder.py +358 -0
  232. unicode_logic_kit/semantics/tnorm.py +85 -0
  233. unicode_logic_kit/semantics/truthtable.py +201 -0
  234. unicode_logic_kit-0.31.0.dist-info/METADATA +333 -0
  235. unicode_logic_kit-0.31.0.dist-info/RECORD +237 -0
  236. unicode_logic_kit-0.31.0.dist-info/WHEEL +4 -0
  237. unicode_logic_kit-0.31.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,336 @@
1
+ r"""Gödel's ontological argument, as the third-order modal machinery's proving ground.
2
+
3
+ Gödel's argument for the existence of a God-like being is the standard worked
4
+ example of THIRD-ORDER MODAL logic, because it cannot be stated in anything
5
+ less: its axioms are about a predicate ``Positive`` whose argument is a
6
+ PROPERTY, inside modal operators. That makes it the sharpest available test of
7
+ :mod:`unicode_logic_kit.fol` third-order modal syntax and
8
+ :mod:`unicode_logic_kit.hol.ho_modal`'s embedding — the axioms are written here in
9
+ the kit's own Unicode syntax, exported by the kit's own emitter, and discharged
10
+ by a real prover; nothing about it is special-cased.
11
+
12
+ **Two variants, one conjunct apart.** ::
13
+
14
+ D2 (Scott) Ess(P, x) ↔ P(x) ∧ ∀Q (Q(x) → □∀y (P(y) → Q(y)))
15
+ D2 (Gödel) Ess(P, x) ↔ ∀Q (Q(x) → □∀y (P(y) → Q(y)))
16
+
17
+ Everything else is identical. Scott's reading is the one that is usually
18
+ presented; Gödel's own notes lack the ``P(x)`` conjunct, and that omission is
19
+ fatal — first noticed mechanically by Benzmüller and Woltzenlogel Paleo (2013).
20
+ Without it, the EMPTY property is vacuously an essence of everything (there is
21
+ no ``y`` with ``⊥(y)``, so ``□∀y (⊥(y) → Q(y))`` holds outright), and necessary
22
+ existence then demands that the empty property be instantiated in every
23
+ accessible world. Both halves of that are proved here, from the axioms, by the
24
+ prover — not asserted.
25
+
26
+ What the two theories establish, each as a lemma the prover discharges:
27
+
28
+ *Scott's version* — ``T1`` every positive property is possibly instantiated;
29
+ ``C`` a God-like being is possible; ``T2`` God-likeness is an essence of any
30
+ God-like being; ``T3`` necessarily, a God-like being exists; ``MC`` **modal
31
+ collapse**, ``φ → □φ`` for every proposition, which is the argument's
32
+ best-known and least comfortable consequence. Plus ``consistency``: Nitpick
33
+ finds a genuine model of the axioms, so the theory proves those things because
34
+ they follow, not because it proves everything.
35
+
36
+ *Gödel's original* — ``emptyEssence`` the empty property is an essence of every
37
+ individual, and ``inconsistent``: ``False``. The control that makes that
38
+ meaningful lives on the other side: in Scott's theory
39
+ ``essenceImpliesInstance`` (``Ess(P, x) → P(x)``) is provable, so there the
40
+ empty property is an essence of NOTHING and the step is blocked by exactly the
41
+ conjunct Gödel omitted.
42
+
43
+ **The proofs are data, not search.** The Isar proof scripts below are written
44
+ out by hand and shipped as text; the kit emits the theory and
45
+ :func:`check_variant` hands it to Isabelle. Nothing here calls a prover to
46
+ *find* a proof, and nothing claims a result the caller has not run. Without a
47
+ local Isabelle the module still gives you the axioms as kit formulas and the
48
+ theory as text.
49
+
50
+ **Frame.** S5, the setting the argument is standardly stated in; ``T3`` needs
51
+ symmetry, and the inconsistency needs only reflexivity.
52
+ """
53
+
54
+ from typing import Dict, List, Optional
55
+
56
+ from ..fol.msflparser import MSFLParser
57
+ from ..fol.nodes import Node
58
+ from .ho_modal import HoAxiom, HoGoal, isabelle_ho_modal_theory
59
+
60
+ _PARSER = MSFLParser(third_order=True, modal=True)
61
+
62
+
63
+ def _f(text: str) -> Node:
64
+ """Parse one axiom in the kit's third-order modal syntax."""
65
+ return _PARSER.parse(text)
66
+
67
+
68
+ #: The axioms shared by both variants, in the kit's own Unicode syntax. ``Pos``
69
+ #: is Gödel's ``P`` (positiveness), ``G`` is God-likeness, ``Ess(P, x)`` is
70
+ #: "``P`` is an essence of ``x``", ``NE`` is necessary existence. ``P`` is
71
+ #: renamed because a predicate OF properties and a property variable both
72
+ #: spelled ``P`` would be needlessly hard to read, not because the kit needs it.
73
+ _SHARED = {
74
+ "A1": "∀P (Pos(λx. ¬P(x)) ↔ ¬Pos(P))",
75
+ "A2": "∀P ∀Q (Pos(P) ∧ □∀x (P(x) → Q(x)) → Pos(Q))",
76
+ "D1": "∀x (G(x) ↔ ∀P (Pos(P) → P(x)))",
77
+ "A3": "Pos(G)",
78
+ "A4": "∀P (Pos(P) → □Pos(P))",
79
+ "D3": "∀x (NE(x) ↔ ∀P (Ess(P, x) → □∃y P(y)))",
80
+ "A5": "Pos(NE)",
81
+ }
82
+
83
+ #: The one axiom the two variants disagree about — see the module docstring.
84
+ _D2 = {
85
+ "scott": "∀P ∀x (Ess(P, x) ↔ P(x) ∧ ∀Q (Q(x) → □∀y (P(y) → Q(y))))",
86
+ "goedel": "∀P ∀x (Ess(P, x) ↔ ∀Q (Q(x) → □∀y (P(y) → Q(y))))",
87
+ }
88
+
89
+ _COMMENTS = {
90
+ "A1": "A1 a property is positive iff its complement is not",
91
+ "A2": "A2 positiveness is closed under necessary entailment",
92
+ "D1": "D1 God-like: having every positive property",
93
+ "A3": "A3 being God-like is positive",
94
+ "A4": "A4 positiveness is necessary",
95
+ "D2": "D2 essence",
96
+ "D3": "D3 necessary existence: every essence is necessarily instantiated",
97
+ "A5": "A5 necessary existence is positive",
98
+ }
99
+
100
+ VARIANTS = ("scott", "goedel")
101
+
102
+ #: The conclusions, in the kit's syntax. Stated separately from the axioms
103
+ #: because they are what the prover has to EARN.
104
+ _CONCLUSIONS = {
105
+ "T1": "∀P (Pos(P) → ◇∃x P(x))",
106
+ "C": "◇∃x G(x)",
107
+ "T2": "∀x (G(x) → Ess(G, x))",
108
+ "T3": "□∃x G(x)",
109
+ "MC": "∀Q (Q → □Q)",
110
+ }
111
+
112
+
113
+ def _order(variant: str) -> List[str]:
114
+ """Axiom names in presentation order (Gödel's own numbering interleaves definitions)."""
115
+ return ["A1", "A2", "D1", "A3", "A4", "D2", "D3", "A5"]
116
+
117
+
118
+ def axiom_texts(variant: str = "scott") -> Dict[str, str]:
119
+ """Return ``{name: source text}`` for ``variant``'s axioms, in the kit's syntax.
120
+
121
+ ``variant`` is ``"scott"`` (the consistent reading) or ``"goedel"`` (Gödel's
122
+ own, which is inconsistent). The two differ in ``D2`` and nowhere else —
123
+ which :func:`variant_difference` states outright.
124
+ """
125
+ if variant not in VARIANTS:
126
+ raise ValueError(f"goedel: unknown variant {variant!r}; expected one of {VARIANTS}.")
127
+ texts = dict(_SHARED)
128
+ texts["D2"] = _D2[variant]
129
+ return {name: texts[name] for name in _order(variant)}
130
+
131
+
132
+ def axioms(variant: str = "scott") -> Dict[str, Node]:
133
+ """Return ``{name: formula}`` for ``variant``'s axioms, parsed."""
134
+ return {name: _f(text) for name, text in axiom_texts(variant).items()}
135
+
136
+
137
+ def conclusions() -> Dict[str, Node]:
138
+ """Return ``{name: formula}`` for the argument's conclusions, parsed.
139
+
140
+ ``T1``, ``C``, ``T2``, ``T3`` are the argument's own steps; ``MC`` is modal
141
+ collapse, which is not a step of the argument but a consequence of it.
142
+ """
143
+ return {name: _f(text) for name, text in _CONCLUSIONS.items()}
144
+
145
+
146
+ def variant_difference() -> str:
147
+ """Return a one-line statement of what separates the two variants."""
148
+ return (f"D2 scott : {_D2['scott']}\n"
149
+ f"D2 goedel: {_D2['goedel']}\n"
150
+ f"(the missing 'P(x)' conjunct is what makes the empty property an "
151
+ f"essence of everything, and the axiom set inconsistent)")
152
+
153
+
154
+ # --------------------------------------------------------------------------
155
+ # Isar proof scripts — written by hand, shipped as data
156
+ # --------------------------------------------------------------------------
157
+ #
158
+ # Each is a complete Isabelle proof for the goal directly above it in the
159
+ # emitted theory. They are structured rather than one-line automation calls on
160
+ # purpose: the one-liners either fail or search unboundedly at this order, and a
161
+ # proof that takes ten minutes to not finish is not a check. Every step names
162
+ # the facts it uses, so what carries a lemma is readable off the script.
163
+
164
+ _T1_PROOF = r"""proof -
165
+ { fix v :: world and Q :: "i \<Rightarrow> sigma"
166
+ assume pos: "Pos Q v"
167
+ have "\<exists>u. R v u \<and> (\<exists>x. Q x u)"
168
+ proof (rule ccontr)
169
+ assume "\<not> (\<exists>u. R v u \<and> (\<exists>x. Q x u))"
170
+ hence empty: "\<forall>u. R v u \<longrightarrow> (\<forall>x. Q x u \<longrightarrow> \<not> Q x u)" by blast
171
+ have "Pos (\<lambda>x u. \<not> Q x u) v" using A2 pos empty by blast
172
+ moreover have "Pos (\<lambda>x u. \<not> Q x u) v = (\<not> Pos Q v)" using A1 by blast
173
+ ultimately show False using pos by blast
174
+ qed
175
+ }
176
+ thus ?thesis by blast
177
+ qed"""
178
+
179
+ _C_PROOF = "using T1 A3 by blast"
180
+
181
+ _T2_PROOF = r"""proof -
182
+ { fix v :: world and x :: i
183
+ assume gx: "G x v"
184
+ have allpos: "\<forall>P. Pos P v \<longrightarrow> P x v" using gx D1 by blast
185
+ { fix Q :: "i \<Rightarrow> sigma"
186
+ assume qx: "Q x v"
187
+ have posq: "Pos Q v"
188
+ proof (rule ccontr)
189
+ assume "\<not> Pos Q v"
190
+ hence "Pos (\<lambda>y u. \<not> Q y u) v" using A1 by blast
191
+ hence "\<not> Q x v" using allpos by blast
192
+ thus False using qx by blast
193
+ qed
194
+ hence "\<forall>u. R v u \<longrightarrow> Pos Q u" using A4 by blast
195
+ hence "\<forall>u. R v u \<longrightarrow> (\<forall>y. G y u \<longrightarrow> Q y u)" using D1 by blast
196
+ }
197
+ hence "Ess G x v" using gx D2 by blast
198
+ }
199
+ thus ?thesis by blast
200
+ qed"""
201
+
202
+ _T3_PROOF = r"""proof -
203
+ have step: "\<forall>v x. G x v \<longrightarrow> (\<forall>u. R v u \<longrightarrow> (\<exists>y. G y u))"
204
+ proof -
205
+ { fix v :: world and x :: i
206
+ assume gx: "G x v"
207
+ hence ne: "NE x v" using A5 D1 by blast
208
+ have "Ess G x v" using gx T2 by blast
209
+ hence "\<forall>u. R v u \<longrightarrow> (\<exists>y. G y u)" using ne D3 by blast
210
+ }
211
+ thus ?thesis by blast
212
+ qed
213
+ { fix w :: world
214
+ obtain u x where ru: "R w u" and gx: "G x u" using C by blast
215
+ { fix z assume rz: "R w z"
216
+ have "R u z" using ru rz R_sym R_trans by blast
217
+ hence "\<exists>y. G y z" using gx step by blast
218
+ }
219
+ hence "\<forall>z. R w z \<longrightarrow> (\<exists>y. G y z)" by blast
220
+ }
221
+ thus ?thesis by blast
222
+ qed"""
223
+
224
+ _MC_PROOF = r"""proof -
225
+ { fix v :: world and Phi :: sigma
226
+ assume phi: "Phi v"
227
+ obtain x where gx: "G x v" using T3 R_refl by blast
228
+ have allpos: "\<forall>P. Pos P v \<longrightarrow> P x v" using gx D1 by blast
229
+ have "Pos (\<lambda>y::i. Phi) v"
230
+ proof (rule ccontr)
231
+ assume "\<not> Pos (\<lambda>y::i. Phi) v"
232
+ hence "Pos (\<lambda>y::i. \<lambda>z. \<not> Phi z) v" using A1 by blast
233
+ hence "\<not> Phi v" using allpos by blast
234
+ thus False using phi by blast
235
+ qed
236
+ hence "\<forall>u. R v u \<longrightarrow> Pos (\<lambda>y::i. Phi) u" using A4 by blast
237
+ hence "\<forall>u. R v u \<longrightarrow> Phi u" using T3 D1 by blast
238
+ }
239
+ thus ?thesis by blast
240
+ qed"""
241
+
242
+ _INCONSISTENT_PROOF = r"""proof -
243
+ have ess: "\<forall>v x. Ess (\<lambda>y::i. \<lambda>z. False) x v" using D2 by blast
244
+ \<comment> \<open>C holds at EVERY world, so any world will do to start from;
245
+ a typedecl type is inhabited, which is all `undefined` is used for\<close>
246
+ obtain u x where ru: "R (undefined::world) u" and gx: "G x u" using C by blast
247
+ have ne: "NE x u" using gx A5 D1 by blast
248
+ have "\<forall>z. R u z \<longrightarrow> (\<exists>y::i. False)" using ne ess D3 by blast
249
+ moreover have "R u u" using R_refl by blast
250
+ ultimately show False by blast
251
+ qed"""
252
+
253
+ #: The empty property, as an Isabelle term: no individual has it at any world.
254
+ _EMPTY = r"(\<lambda>y::i. \<lambda>z. False)"
255
+
256
+
257
+ def _scott_goals() -> List[HoGoal]:
258
+ """The four steps of the argument, plus modal collapse, the block, and consistency."""
259
+ conc = conclusions()
260
+ return [
261
+ HoGoal("T1", conc["T1"], _T1_PROOF,
262
+ "T1 every positive property is possibly instantiated"),
263
+ HoGoal("C", conc["C"], _C_PROOF,
264
+ "C a God-like being is possible"),
265
+ HoGoal("T2", conc["T2"], _T2_PROOF,
266
+ "T2 God-likeness is an essence of every God-like being"),
267
+ HoGoal("T3", conc["T3"], _T3_PROOF,
268
+ "T3 necessarily, a God-like being exists"),
269
+ HoGoal("MC", conc["MC"], _MC_PROOF,
270
+ "MC modal collapse: everything true is necessarily true"),
271
+ HoGoal("essenceImpliesInstance", proof="using D2 by blast",
272
+ statement=r"\<forall>v P x. Ess P x v \<longrightarrow> P x v",
273
+ comment="Scott's conjunct, isolated: an essence of x is a property x HAS"),
274
+ HoGoal("emptyNotEssence", proof="using essenceImpliesInstance by blast",
275
+ statement=rf"\<forall>v x. \<not> Ess {_EMPTY} x v",
276
+ comment="so the empty property is an essence of nothing "
277
+ "-- exactly the step Goedel's D2 leaves open"),
278
+ HoGoal("consistency", statement="True", kind="lemma",
279
+ proof="nitpick [satisfy, user_axioms, expect = genuine]\n oops",
280
+ comment="Nitpick finds a genuine model: the axioms are consistent, "
281
+ "so the theorems above hold because they FOLLOW"),
282
+ ]
283
+
284
+
285
+ def _goedel_goals() -> List[HoGoal]:
286
+ """The collapse of Gödel's own reading: the empty property is an essence, hence falsity."""
287
+ conc = conclusions()
288
+ return [
289
+ HoGoal("T1", conc["T1"], _T1_PROOF,
290
+ "T1 every positive property is possibly instantiated"),
291
+ HoGoal("C", conc["C"], _C_PROOF,
292
+ "C a God-like being is possible"),
293
+ HoGoal("emptyEssence", proof="using D2 by blast",
294
+ statement=rf"\<forall>v x. Ess {_EMPTY} x v",
295
+ comment="without the P(x) conjunct the empty property is "
296
+ "vacuously an essence of EVERY individual"),
297
+ HoGoal("inconsistent", statement="False", proof=_INCONSISTENT_PROOF,
298
+ comment="and necessary existence then demands it be instantiated"),
299
+ ]
300
+
301
+
302
+ def goedel_theory(variant: str = "scott", name: Optional[str] = None,
303
+ frame: str = "S5") -> str:
304
+ """Emit the complete Isabelle theory for one variant of the argument.
305
+
306
+ ``variant`` is ``"scott"`` or ``"goedel"``; ``name`` defaults to
307
+ ``GoedelScott`` / ``GoedelOriginal``. The axioms come from
308
+ :func:`axioms`, the embedding from
309
+ :func:`unicode_logic_kit.hol.ho_modal.isabelle_ho_modal_theory`, and the
310
+ proofs from this module's scripts — so the emitted text is the kit's, end to
311
+ end, and can be read, edited or run outside it.
312
+ """
313
+ if variant not in VARIANTS:
314
+ raise ValueError(f"goedel: unknown variant {variant!r}; expected one of {VARIANTS}.")
315
+ name = name or ("GoedelScott" if variant == "scott" else "GoedelOriginal")
316
+ formulas = axioms(variant)
317
+ axiom_list = [HoAxiom(key, formulas[key], _COMMENTS[key]) for key in formulas]
318
+ goals = _scott_goals() if variant == "scott" else _goedel_goals()
319
+ return isabelle_ho_modal_theory(name, axiom_list, goals, frame=frame)
320
+
321
+
322
+ def check_variant(variant: str = "scott", frame: str = "S5",
323
+ timeout: int = 600):
324
+ """Emit ``variant``'s theory and run it through the local Isabelle.
325
+
326
+ Returns the :class:`~unicode_logic_kit.hol.isabelle_runner.BuildResult`;
327
+ ``result.ok`` means every lemma in the theory was discharged — for
328
+ ``"scott"`` that the argument goes through and its axioms have a model, for
329
+ ``"goedel"`` that they prove falsity. Raises
330
+ :class:`~unicode_logic_kit.hol.isabelle_runner.IsabelleNotAvailable` if no
331
+ Isabelle is installed; the kit does not ship one.
332
+ """
333
+ from .isabelle_runner import check_theory
334
+ name = "GoedelScott" if variant == "scott" else "GoedelOriginal"
335
+ theory = goedel_theory(variant, name, frame=frame)
336
+ return check_theory(theory, name, session_timeout=timeout, wall_timeout=timeout)