deeperthawt 1.0.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.
- deeperthawt/__init__.py +140 -0
- deeperthawt/_backends.py +46 -0
- deeperthawt/_backends_core.py +38 -0
- deeperthawt/_vendored/__init__.py +0 -0
- deeperthawt/_vendored/known_theorems.py +294 -0
- deeperthawt/_vendored/logic_engine.py +340 -0
- deeperthawt/_vendored/math_solver_oracle.py +580 -0
- deeperthawt/_vendored/nl_math_parser.py +246 -0
- deeperthawt/_vendored/python_knowledge.py +194 -0
- deeperthawt/_vendored/scientific_knowledge.py +151 -0
- deeperthawt/cli.py +111 -0
- deeperthawt-1.0.0.dist-info/METADATA +120 -0
- deeperthawt-1.0.0.dist-info/RECORD +17 -0
- deeperthawt-1.0.0.dist-info/WHEEL +5 -0
- deeperthawt-1.0.0.dist-info/entry_points.txt +2 -0
- deeperthawt-1.0.0.dist-info/licenses/LICENSE.commercial.md +53 -0
- deeperthawt-1.0.0.dist-info/top_level.txt +1 -0
deeperthawt/__init__.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DeeperThawt — deterministic verifiable reasoning engine.
|
|
3
|
+
|
|
4
|
+
A packaged product exposing the VRE/hybrid-agi harness as one clean API.
|
|
5
|
+
|
|
6
|
+
CAPABILITY ARCHITECTURE (secret-ingredients stay remote):
|
|
7
|
+
- LOCAL, deterministic, non-secret solvers (shipped with the package):
|
|
8
|
+
* Symbolic math oracle (deterministic SymPy solver, no LLM guessing)
|
|
9
|
+
* Logic + syllogism inference
|
|
10
|
+
* Known-theorem / science / python knowledge retrieval (cited)
|
|
11
|
+
- REMOTE, secret-engine (never shipped locally): the semantic engine
|
|
12
|
+
(gematria projection + fixed-parameter attention + trained latent adapter
|
|
13
|
+
+ tuned weights). Exposed to the local client ONLY through a thin,
|
|
14
|
+
numeric-only RPC to the remote server (/assess). The method and weights
|
|
15
|
+
never leave the remote server — a local buyer sees the contract, not the
|
|
16
|
+
pearl.
|
|
17
|
+
|
|
18
|
+
Dual-licensed: AGPL-3.0 open core + commercial license for proprietary embedding.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import os as _os
|
|
24
|
+
import sys as _sys
|
|
25
|
+
import urllib.request as _urlreq
|
|
26
|
+
import urllib.error as _urlerr
|
|
27
|
+
import json as _json
|
|
28
|
+
from typing import Any, Dict
|
|
29
|
+
|
|
30
|
+
# --------------------------------------------------------------------------- #
|
|
31
|
+
# LOCAL capability solvers (deterministic, non-secret) — vendored from the
|
|
32
|
+
# hybrid-agi core. These are the cited/bounded solvers, safe to ship.
|
|
33
|
+
# --------------------------------------------------------------------------- #
|
|
34
|
+
try:
|
|
35
|
+
from ._backends import ( # type: ignore
|
|
36
|
+
MathematicalOracle,
|
|
37
|
+
evaluate_inference,
|
|
38
|
+
verify_logic_argument,
|
|
39
|
+
parse_known_theorem,
|
|
40
|
+
lookup_science_fact_combined,
|
|
41
|
+
lookup_python_knowledge_combined,
|
|
42
|
+
)
|
|
43
|
+
_HAS_LOCAL = True
|
|
44
|
+
except Exception as _e: # pragma: no cover
|
|
45
|
+
_HAS_LOCAL = False
|
|
46
|
+
_LOCAL_ERR = str(_e)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
_DEFAULT_API = "https://mcp-token-saver-pro.fly.dev"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class _SemanticRemote:
|
|
53
|
+
"""Thin numeric-only client to the remote semantic engine.
|
|
54
|
+
|
|
55
|
+
The secret method (gematria projection, attention, adapter weights) lives
|
|
56
|
+
ONLY on the remote server. This client sends de-identified rows and
|
|
57
|
+
receives a number back — it never carries the engine, the method, or the
|
|
58
|
+
weights. If `requests` is unavailable we fall back to urllib.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(self, base: str = "", api_key: str = ""):
|
|
62
|
+
self.base = (base or _os.environ.get("DEEPER_THAWT_API", _DEFAULT_API)).rstrip("/")
|
|
63
|
+
self.api_key = api_key or _os.environ.get("DEEPER_THAWT_API_KEY", "")
|
|
64
|
+
|
|
65
|
+
def assess(self, rows: list, tier: str = "content") -> Dict[str, Any]:
|
|
66
|
+
"""POST de-identified rows to the remote engine; return numeric result."""
|
|
67
|
+
body = _json.dumps({"tier": tier, "messages": rows}).encode()
|
|
68
|
+
headers = {"Content-Type": "application/json"}
|
|
69
|
+
if self.api_key:
|
|
70
|
+
headers["Authorization"] = f"Bearer {self.api_key}"
|
|
71
|
+
req = _urlreq.Request(self.base + "/assess", data=body, headers=headers, method="POST")
|
|
72
|
+
try:
|
|
73
|
+
with _urlreq.urlopen(req, timeout=60) as r:
|
|
74
|
+
return _json.loads(r.read().decode()) # {"result": {...}}
|
|
75
|
+
except _urlerr.HTTPError as e:
|
|
76
|
+
return {"error": f"http_{e.code}", "detail": e.read().decode()[:200]}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# --------------------------------------------------------------------------- #
|
|
80
|
+
# Public product surface
|
|
81
|
+
# --------------------------------------------------------------------------- #
|
|
82
|
+
|
|
83
|
+
class DeeperThawt:
|
|
84
|
+
"""The DeeperThawt engine: local deterministic solvers + remote semantic UI."""
|
|
85
|
+
|
|
86
|
+
def __init__(self, api_base: str = "", api_key: str = ""):
|
|
87
|
+
self.math = MathematicalOracle()
|
|
88
|
+
self._remote = _SemanticRemote(api_base, api_key)
|
|
89
|
+
|
|
90
|
+
# -- math (local, deterministic) -----------------------------------------
|
|
91
|
+
def solve_math(self, text: str) -> dict:
|
|
92
|
+
return self.math.evaluate(text)
|
|
93
|
+
|
|
94
|
+
# -- logic (local, deterministic) ----------------------------------------
|
|
95
|
+
def verify_logic(self, premises, conclusion) -> dict:
|
|
96
|
+
return verify_logic_argument(list(premises), conclusion)
|
|
97
|
+
|
|
98
|
+
# -- knowledge (local, cited retrieval) ----------------------------------
|
|
99
|
+
def knowledge_math_theorem(self, text: str) -> dict:
|
|
100
|
+
return parse_known_theorem(text) or {"known": False, "reason": "no known theorem matched"}
|
|
101
|
+
|
|
102
|
+
def knowledge_science(self, text: str) -> dict:
|
|
103
|
+
return lookup_science_fact_combined(text)
|
|
104
|
+
|
|
105
|
+
def knowledge_python(self, text: str) -> dict:
|
|
106
|
+
return lookup_python_knowledge_combined(text)
|
|
107
|
+
|
|
108
|
+
# -- semantic token intelligence (REMOTE, numeric-only) ------------------
|
|
109
|
+
def semantic_assess(self, messages: list, tier: str = "content") -> dict:
|
|
110
|
+
"""Ask the remote semantic engine to assess token redundancy.
|
|
111
|
+
|
|
112
|
+
Returns ONLY numbers (baseline, exact dedupe, semantic additional
|
|
113
|
+
savings). The engine + weights stay on the remote server; this ships
|
|
114
|
+
nothing secret.
|
|
115
|
+
"""
|
|
116
|
+
return self._remote.assess(messages, tier=tier)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def version() -> str:
|
|
120
|
+
return "1.0.0"
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def api_status() -> str:
|
|
124
|
+
"""Remote semantic engine health (numeric/opaque)."""
|
|
125
|
+
try:
|
|
126
|
+
with _urlreq.urlopen(_DEFAULT_API + "/healthz", timeout=15) as r:
|
|
127
|
+
return r.read().decode()
|
|
128
|
+
except Exception as e: # pragma: no cover
|
|
129
|
+
return f"unreachable: {e}"
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
_has_remote = _HAS_LOCAL
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
__all__ = [
|
|
136
|
+
"DeeperThawt", "version", "api_status",
|
|
137
|
+
"MathematicalOracle", "evaluate_inference", "verify_logic_argument",
|
|
138
|
+
"parse_known_theorem", "lookup_science_fact_combined",
|
|
139
|
+
"lookup_python_knowledge_combined",
|
|
140
|
+
]
|
deeperthawt/_backends.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DeeperThawt vendored capability backends — LOCAL, deterministic, NON-SECRET.
|
|
3
|
+
|
|
4
|
+
This module bundles the minimal, self-contained deterministic solvers from the
|
|
5
|
+
VRE/hybrid-agi harness so the pip package stands alone:
|
|
6
|
+
|
|
7
|
+
- MathematicalOracle + fib helper (deterministic SymPy math solver)
|
|
8
|
+
- logic_engine inference + syllogism (propositional + category logic)
|
|
9
|
+
- known_theorems / science / python knowledge retrieval (cited)
|
|
10
|
+
|
|
11
|
+
SECRET-INGREDIENT POLICY: the semantic engine (gematria projection +
|
|
12
|
+
fixed-parameter attention + trained latent adapter + tuned weights) lives ONLY
|
|
13
|
+
on the remote DeeperThawt server and is intentionally NOT vendored here. The
|
|
14
|
+
local package ships only a numeric-only RPC client to that server.
|
|
15
|
+
|
|
16
|
+
AGPL-3.0 open core; commercial license for proprietary embedding.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import os as _os
|
|
22
|
+
import sys as _sys
|
|
23
|
+
|
|
24
|
+
# Make the vendored deterministic core importable by absolute module names.
|
|
25
|
+
_HARNESS = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), "_vendored")
|
|
26
|
+
if _HARNESS not in _sys.path:
|
|
27
|
+
_sys.path.insert(0, _HARNESS)
|
|
28
|
+
|
|
29
|
+
# Re-export the real local solvers (NO semantic engine — it stays remote).
|
|
30
|
+
from ._backends_core import ( # noqa: E402
|
|
31
|
+
MathematicalOracle,
|
|
32
|
+
evaluate_inference,
|
|
33
|
+
verify_logic_argument,
|
|
34
|
+
parse_known_theorem,
|
|
35
|
+
lookup_science_fact_combined,
|
|
36
|
+
lookup_python_knowledge_combined,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Safety: if anyone tries to vendored-import the semantic engine here it must
|
|
40
|
+
# not be present. GematriaTokenizer / SemanticSpace / adapter are NOT exported.
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"MathematicalOracle", "evaluate_inference", "verify_logic_argument",
|
|
44
|
+
"parse_known_theorem", "lookup_science_fact_combined",
|
|
45
|
+
"lookup_python_knowledge_combined",
|
|
46
|
+
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DeeperThawt vendored core — re-exports the real LOCAL deterministic solvers.
|
|
3
|
+
|
|
4
|
+
The `_vendored` directory holds vendored copies of the hybrid-agi/VRE core
|
|
5
|
+
modules (AGPL-3.0 open core) — but ONLY the deterministic, non-secret solvers.
|
|
6
|
+
The semantic engine (gematria projection / attention / adapter / weights) is
|
|
7
|
+
deliberately NOT vendored: it lives on the remote DeeperThawt server and is
|
|
8
|
+
reached through a numeric-only RPC client.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import os as _os
|
|
14
|
+
import sys as _sys
|
|
15
|
+
|
|
16
|
+
_V = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), "_vendored")
|
|
17
|
+
if _V not in _sys.path:
|
|
18
|
+
_sys.path.insert(0, _V)
|
|
19
|
+
|
|
20
|
+
# --- math solver (local, deterministic) ---
|
|
21
|
+
from math_solver_oracle import MathematicalOracle # noqa: E402
|
|
22
|
+
|
|
23
|
+
# --- logic engine (local, deterministic) ---
|
|
24
|
+
from logic_engine import ( # noqa: E402
|
|
25
|
+
evaluate_inference,
|
|
26
|
+
verify_logic_argument,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# --- knowledge (local, cited retrieval) ---
|
|
30
|
+
from known_theorems import parse_known_theorem # noqa: E402
|
|
31
|
+
from scientific_knowledge import lookup_science_fact_combined # noqa: E402
|
|
32
|
+
from python_knowledge import lookup_python_knowledge_combined # noqa: E402
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"MathematicalOracle", "evaluate_inference", "verify_logic_argument",
|
|
36
|
+
"parse_known_theorem", "lookup_science_fact_combined",
|
|
37
|
+
"lookup_python_knowledge_combined",
|
|
38
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Curated catalog of famous mathematical theorems.
|
|
3
|
+
|
|
4
|
+
This is NOT a proof generator. For a small set of well-known theorems it
|
|
5
|
+
returns an honest "known theorem, not generated" record: a canonical formal
|
|
6
|
+
statement and a citation. Claims not in the catalog fall through to abstention.
|
|
7
|
+
This lets the system acknowledge a famous theorem is TRUE without pretending
|
|
8
|
+
to have derived it — a bounded, honest capability.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
import re
|
|
12
|
+
from typing import Optional, Dict, Any
|
|
13
|
+
|
|
14
|
+
# keyword patterns -> theorem entry
|
|
15
|
+
_CATALOG = [
|
|
16
|
+
{
|
|
17
|
+
"keys": ["infinite", "infinitude", "infinitely", "infinitely many primes",
|
|
18
|
+
"infinitely many prime numbers", "euclid"],
|
|
19
|
+
"name": "Euclid's theorem (infinitude of primes)",
|
|
20
|
+
"statement": "There are infinitely many prime numbers.",
|
|
21
|
+
"formal": "∀N ∈ ℕ, ∃p prime with p > N",
|
|
22
|
+
"citation": "Euclid, Elements, Book IX, Proposition 20 (c. 300 BCE)",
|
|
23
|
+
"verified": True,
|
|
24
|
+
"kind": "known_theorem",
|
|
25
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"keys": ["fermat's last theorem", "fermat last theorem", "fermats last theorem",
|
|
29
|
+
"x^n + y^n = z^n", "no three positive integers"],
|
|
30
|
+
"name": "Fermat's Last Theorem",
|
|
31
|
+
"statement": "No three positive integers a, b, c satisfy a^n + b^n = c^n for integer n > 2.",
|
|
32
|
+
"formal": "∀a,b,c,n∈ℤ⁺, n>2 ⇒ aⁿ+bⁿ≠cⁿ",
|
|
33
|
+
"citation": "Wiles, 'Modular elliptic curves and Fermat's Last Theorem', Ann. of Math. 141 (1995), 443–551",
|
|
34
|
+
"verified": True,
|
|
35
|
+
"kind": "known_theorem",
|
|
36
|
+
"note": "Known theorem recognized from catalog; not generated by this system. (Proved 1994–95 by A. Wiles.)",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"keys": ["pythagorean theorem", "pythagoras", "a^2 + b^2 = c^2", "right triangle"],
|
|
40
|
+
"name": "Pythagorean theorem",
|
|
41
|
+
"statement": "In a right triangle, the square of the hypotenuse equals the sum of squares of the legs.",
|
|
42
|
+
"formal": "a² + b² = c² for a right triangle with legs a, b and hypotenuse c",
|
|
43
|
+
"citation": "Euclid, Elements, Book I, Proposition 47",
|
|
44
|
+
"verified": True,
|
|
45
|
+
"kind": "known_theorem",
|
|
46
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"keys": ["fundamental theorem of arithmetic", "unique prime factorization",
|
|
50
|
+
"prime factorization is unique"],
|
|
51
|
+
"name": "Fundamental theorem of arithmetic",
|
|
52
|
+
"statement": "Every integer greater than 1 is a product of primes, uniquely up to order.",
|
|
53
|
+
"formal": "∀n>1, n = ∏ p_i^{e_i} uniquely",
|
|
54
|
+
"citation": "Euclid, Elements, Book VII; Gauss, Disquisitiones Arithmeticae (1801)",
|
|
55
|
+
"verified": True,
|
|
56
|
+
"kind": "known_theorem",
|
|
57
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"keys": ["goldbach", "every even integer greater than 2 is the sum of two primes",
|
|
61
|
+
"golbach's conjecture"],
|
|
62
|
+
"name": "Goldbach's conjecture (OPEN — unproven, do not assert)",
|
|
63
|
+
"statement": "Every even integer greater than 2 is the sum of two primes.",
|
|
64
|
+
"formal": "∀even n>2, ∃ primes p,q with p+q=n",
|
|
65
|
+
"citation": "Letter from Goldbach to Euler, 1742 (unproven conjecture)",
|
|
66
|
+
"verified": False,
|
|
67
|
+
"kind": "open_conjecture",
|
|
68
|
+
"note": "OPEN CONJECTURE — not proven. The system must NOT assert it as true. This entry signals 'known open problem, correct posture = abstain from truth claim.'",
|
|
69
|
+
},
|
|
70
|
+
# ---- number theory ------------------------------------------------
|
|
71
|
+
{
|
|
72
|
+
"keys": ["euclid's lemma", "if a prime divides a product", "prime divides product"],
|
|
73
|
+
"name": "Euclid's lemma",
|
|
74
|
+
"statement": "If a prime p divides the product ab, then p divides a or p divides b.",
|
|
75
|
+
"formal": "p prime ∧ p|ab ⇒ p|a ∨ p|b",
|
|
76
|
+
"citation": "Euclid, Elements, Book VII, Proposition 30",
|
|
77
|
+
"verified": True, "kind": "known_theorem",
|
|
78
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"keys": ["dirichlet's theorem", "dirichlet arithmetic progression", "infinitely many primes in every arithmetic progression"],
|
|
82
|
+
"name": "Dirichlet's theorem on arithmetic progressions",
|
|
83
|
+
"statement": "There are infinitely many primes congruent to a mod m whenever gcd(a,m)=1.",
|
|
84
|
+
"formal": "∀a,m with gcd(a,m)=1: #(primes p ≡ a mod m) = ∞",
|
|
85
|
+
"citation": "Dirichlet, 1837",
|
|
86
|
+
"verified": True, "kind": "known_theorem",
|
|
87
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"keys": ["prime number theorem", "asymptotic distribution of primes", "number of primes up to x"],
|
|
91
|
+
"name": "Prime number theorem",
|
|
92
|
+
"statement": "π(x) ~ x / ln x as x → ∞.",
|
|
93
|
+
"formal": "lim_{x→∞} π(x)·ln(x)/x = 1",
|
|
94
|
+
"citation": "Hadamard & de la Vallée Poussin, 1896",
|
|
95
|
+
"verified": True, "kind": "known_theorem",
|
|
96
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"keys": ["sum of two squares which integers", "fermat two squares", "p = a^2 + b^2"],
|
|
100
|
+
"name": "Fermat's theorem on sums of two squares",
|
|
101
|
+
"statement": "An odd prime p is a sum of two squares iff p ≡ 1 (mod 4).",
|
|
102
|
+
"formal": "odd prime p = a²+b² ⟺ p ≡ 1 (mod 4)",
|
|
103
|
+
"citation": "Fermat (1640); proved by Euler 1749",
|
|
104
|
+
"verified": True, "kind": "known_theorem",
|
|
105
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
106
|
+
},
|
|
107
|
+
# ---- algebra ------------------------------------------------------
|
|
108
|
+
{
|
|
109
|
+
"keys": ["fundamental theorem of algebra", "every polynomial has a root", "degree n polynomial n roots"],
|
|
110
|
+
"name": "Fundamental theorem of algebra",
|
|
111
|
+
"statement": "Every non-constant polynomial with complex coefficients has a complex root.",
|
|
112
|
+
"formal": "∀p∈ℂ[x], deg p>0: ∃ z∈ℂ, p(z)=0",
|
|
113
|
+
"citation": "Gauss, 1799 (first rigorous proof); Argand 1814; Cauchy",
|
|
114
|
+
"verified": True, "kind": "known_theorem",
|
|
115
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"keys": ["cayley-hamilton", "cayley hamilton", "cayley hamilton theorem",
|
|
119
|
+
"every matrix satisfies its characteristic equation", "characteristic polynomial"],
|
|
120
|
+
"name": "Cayley–Hamilton theorem",
|
|
121
|
+
"statement": "Every square matrix satisfies its own characteristic equation.",
|
|
122
|
+
"formal": "Let p(A)=det(λI−A); then p(A)=0 (matrix identity)",
|
|
123
|
+
"citation": "Cayley (1858), Hamilton (1853)",
|
|
124
|
+
"verified": True, "kind": "known_theorem",
|
|
125
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"keys": ["binomial theorem", "expansion of (x + y)^n", "binomial expansion"],
|
|
129
|
+
"name": "Binomial theorem",
|
|
130
|
+
"statement": "(x + y)ⁿ = Σₖ ₙCₖ xⁿ⁻ᵏ yᵏ for integer n ≥ 0.",
|
|
131
|
+
"formal": "(x+y)^n = Σ_{k=0}^n C(n,k) x^{n-k} y^k",
|
|
132
|
+
"citation": "Pascal (1654); known to Chinese/Islamic mathematicians earlier",
|
|
133
|
+
"verified": True, "kind": "known_theorem",
|
|
134
|
+
"note": "Known identity recognized from catalog; not generated by this system.",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"keys": ["lamé", "zero divisor ring", "every finite integral domain is a field"],
|
|
138
|
+
"name": "Finite integral domains are fields (Wedderburn's little theorem)",
|
|
139
|
+
"statement": "Every finite integral domain is a field.",
|
|
140
|
+
"formal": "finite domain ⇒ every non-zero element has a multiplicative inverse",
|
|
141
|
+
"citation": "Wedderburn, 1905",
|
|
142
|
+
"verified": True, "kind": "known_theorem",
|
|
143
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
144
|
+
},
|
|
145
|
+
# ---- analysis ------------------------------------------------------
|
|
146
|
+
{
|
|
147
|
+
"keys": ["intermediate value theorem", "continuous function crosses", "bolzano", "ivt"],
|
|
148
|
+
"name": "Intermediate value theorem (Bolzano)",
|
|
149
|
+
"statement": "A continuous function on a closed interval attains every value between its endpoints.",
|
|
150
|
+
"formal": "f:[a,b]→ℝ continuous, y between f(a),f(b) ⇒ ∃ c ∈ [a,b], f(c)=y",
|
|
151
|
+
"citation": "Bolzano 1817",
|
|
152
|
+
"verified": True, "kind": "known_theorem",
|
|
153
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"keys": ["mean value theorem", "rolle", "there exists c where f'(c)", "lagrange mvt"],
|
|
157
|
+
"name": "Mean value theorem",
|
|
158
|
+
"statement": "For differentiable f on [a,b], ∃ c with f'(c) = (f(b)−f(a))/(b−a).",
|
|
159
|
+
"formal": "∃ c: f'(c) = (f(b)-f(a))/(b-a)",
|
|
160
|
+
"citation": "Lagrange 1797; Rolle (1691) for the f(a)=f(b) case",
|
|
161
|
+
"verified": True, "kind": "known_theorem",
|
|
162
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"keys": ["fundamental theorem of calculus", "differentiation integration inverse", "ftc", "antiderivative"],
|
|
166
|
+
"name": "Fundamental theorem of calculus",
|
|
167
|
+
"statement": "Differentiation and integration are inverse operations over an interval.",
|
|
168
|
+
"formal": "d/dx ∫_a^x f(t) dt = f(x)",
|
|
169
|
+
"citation": "Newton & Leibniz, 17th c.",
|
|
170
|
+
"verified": True, "kind": "known_theorem",
|
|
171
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"keys": ["euler's identity", "e^(i*pi) + 1 = 0", "e to the i pi", "e^i*pi"],
|
|
175
|
+
"name": "Euler's identity",
|
|
176
|
+
"statement": "e^(iπ) + 1 = 0.",
|
|
177
|
+
"formal": "e^{iπ} + 1 = 0",
|
|
178
|
+
"citation": "Euler, 1748 (Introductio)",
|
|
179
|
+
"verified": True, "kind": "known_theorem",
|
|
180
|
+
"note": "Known identity recognized from catalog; not generated by this system.",
|
|
181
|
+
},
|
|
182
|
+
# ---- geometry / set theory / misc ----------------------------------
|
|
183
|
+
{
|
|
184
|
+
"keys": ["triangle inequality", "abs", "|x + y| <= |x| + |y|"],
|
|
185
|
+
"name": "Triangle inequality",
|
|
186
|
+
"statement": "|x + y| ≤ |x| + |y| for real (or complex) x, y.",
|
|
187
|
+
"formal": "|x+y| ≤ |x|+|y|",
|
|
188
|
+
"citation": "Euclid, Elements, Book I, Prop. 20 (geometry); analytic form standard",
|
|
189
|
+
"verified": True, "kind": "known_theorem",
|
|
190
|
+
"note": "Known inequality recognized from catalog; not generated by this system.",
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"keys": ["cantor's theorem", "cardinality of power set", "set has more subsets", "diagonalization set"],
|
|
194
|
+
"name": "Cantor's theorem",
|
|
195
|
+
"statement": "The cardinality of a set's power set is strictly greater than the set's cardinality.",
|
|
196
|
+
"formal": "|P(S)| > |S| for every set S",
|
|
197
|
+
"citation": "Cantor, 1891 (diagonal argument)",
|
|
198
|
+
"verified": True, "kind": "known_theorem",
|
|
199
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"keys": ["pythagorean theorem", "pythagoras", "a^2 + b^2 = c^2", "right triangle"],
|
|
203
|
+
"name": "Pythagorean theorem",
|
|
204
|
+
"statement": "In a right triangle, the square of the hypotenuse equals the sum of squares of the legs.",
|
|
205
|
+
"formal": "a² + b² = c² for a right triangle with legs a, b and hypotenuse c",
|
|
206
|
+
"citation": "Euclid, Elements, Book I, Proposition 47",
|
|
207
|
+
"verified": True, "kind": "known_theorem",
|
|
208
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"keys": ["five platonic solids", "exactly 5 platonic solids", "only five regular convex polyhedra"],
|
|
212
|
+
"name": "There are exactly five Platonic solids",
|
|
213
|
+
"statement": "There are exactly five regular convex polyhedra (tetrahedron, cube, octahedron, dodecahedron, icosahedron).",
|
|
214
|
+
"formal": "exactly 5 regular convex polyhedra in ℝ³",
|
|
215
|
+
"citation": "Theaetetus (c. 370 BCE); Euclid, Elements, Book XIII",
|
|
216
|
+
"verified": True, "kind": "known_theorem",
|
|
217
|
+
"note": "Known theorem recognized from catalog; not generated by this system.",
|
|
218
|
+
},
|
|
219
|
+
# ---- more open conjectures (never assert as true) -------------------
|
|
220
|
+
{
|
|
221
|
+
"keys": ["riemann hypothesis", "zeta function zeros", "all non-trivial zeros"],
|
|
222
|
+
"name": "Riemann hypothesis (OPEN)",
|
|
223
|
+
"statement": "All non-trivial zeros of the Riemann zeta function have real part 1/2.",
|
|
224
|
+
"formal": "ζ(s)=0, s non-trivial ⇒ Re(s)=1/2",
|
|
225
|
+
"citation": "Riemann, 1859 (unproven; Millennium Prize)",
|
|
226
|
+
"verified": False, "kind": "open_conjecture",
|
|
227
|
+
"note": "OPEN CONJECTURE — unproven. Must NOT be asserted true.",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"keys": ["collatz", "3n+1", "hailstone", "syracuse"],
|
|
231
|
+
"name": "Collatz conjecture (OPEN)",
|
|
232
|
+
"statement": "Iterating n ↦ 3n+1 (odd) or n/2 (even) eventually reaches 1 for every positive integer n.",
|
|
233
|
+
"formal": "∀n∈ℤ⁺ iterating the Collatz map reaches 1",
|
|
234
|
+
"citation": "Collatz, 1937 (unproven)",
|
|
235
|
+
"verified": False, "kind": "open_conjecture",
|
|
236
|
+
"note": "OPEN CONJECTURE — unproven. Must NOT be asserted true.",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"keys": ["twin prime", "infinitely many twin primes", "twin primes are infinite"],
|
|
240
|
+
"name": "Twin prime conjecture (OPEN — note the partial result)",
|
|
241
|
+
"statement": "There are infinitely many pairs of primes differing by 2.",
|
|
242
|
+
"formal": "#{(p, p+2): both prime} = ∞ (OPEN)",
|
|
243
|
+
"citation": "de Polignac 1849 (unproven); Zhang 2013 proved bounded gaps",
|
|
244
|
+
"verified": False, "kind": "open_conjecture",
|
|
245
|
+
"note": "OPEN CONJECTURE — unproven. Zhang (2013) proved gaps are bounded but NOT the full conjecture. Must NOT be asserted true.",
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"keys": ["p = np", "p vs np", "p equals np"],
|
|
249
|
+
"name": "P vs NP (OPEN)",
|
|
250
|
+
"statement": "Whether every problem whose solution can be quickly verified can also be solved quickly is unknown.",
|
|
251
|
+
"formal": "P = NP ? (unresolved)",
|
|
252
|
+
"citation": "Cook, 1971; Levin (unproven; Millennium Prize)",
|
|
253
|
+
"verified": False, "kind": "open_conjecture",
|
|
254
|
+
"note": "OPEN PROBLEM — unresolved. Must NOT be asserted either way.",
|
|
255
|
+
},
|
|
256
|
+
]
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def parse_known_theorem(text: str) -> Optional[Dict[str, Any]]:
|
|
260
|
+
"""Return the theater record for a known theorem if `text` matches the
|
|
261
|
+
catalog, else None (abstention)."""
|
|
262
|
+
if not text:
|
|
263
|
+
return None
|
|
264
|
+
t = text.lower()
|
|
265
|
+
for entry in _CATALOG:
|
|
266
|
+
keys = [k.lower() for k in entry["keys"]]
|
|
267
|
+
if any(k in t for k in keys):
|
|
268
|
+
# return a copy (no mutation of the catalog)
|
|
269
|
+
return {
|
|
270
|
+
"status": entry["kind"] if entry["kind"] in ("open_conjecture",) else "known_theorem",
|
|
271
|
+
"kind": entry["kind"],
|
|
272
|
+
"verified": entry["verified"],
|
|
273
|
+
"name": entry["name"],
|
|
274
|
+
"answer": entry["verified"],
|
|
275
|
+
"statement": entry["statement"],
|
|
276
|
+
"formal": entry["formal"],
|
|
277
|
+
"citation": entry["citation"],
|
|
278
|
+
"summary": f"{entry['name']}: {entry['statement']} [citation: {entry['citation']}]",
|
|
279
|
+
"note": entry["note"],
|
|
280
|
+
}
|
|
281
|
+
return None
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
# quick self-test
|
|
285
|
+
if __name__ == "__main__":
|
|
286
|
+
for q in [
|
|
287
|
+
"Prove that there are infinitely many primes",
|
|
288
|
+
"There are infinitely many prime numbers",
|
|
289
|
+
"State Fermat's Last Theorem",
|
|
290
|
+
"Every even integer > 2 is the sum of two primes",
|
|
291
|
+
"2 + 2 = 4",
|
|
292
|
+
]:
|
|
293
|
+
r = parse_known_theorem(q)
|
|
294
|
+
print(f" {q[:45]:47} -> {r['kind'] if r else 'abstain'} | {(r or {}).get('name','')[:40]}")
|