External claims¶
A result can rest on an answer from an external tool, such as a computer
algebra system or a solver. judgment_shell keeps such an answer as a
claim: a hypothesis with its provenance (the query, the decider, its
version), never an axiom. A library holds closed theorems only, so a claim
reaches a library as an explicit antecedent of the theorem that rests on it.
Tracking a claim in a session¶
var claims = ClaimTable(s)
var h = assume_claim(s, claims, frame, proposition, "x = x?", "solver", "1", budget)
var guarded = export_claims(s, claims, step, [h, frame], budget)
var report = label(s, claims, guarded, budget)
assume_claim(session, claims, parent, proposition, query, decider, version, budget)assumes the proposition overparentand records the claim, with its provenance, on the assumption frame. Assuming one proposition twice over one frame gives one frame, and claims are kept per frame and decider: a second decider's claim on that frame is kept beside the first.export_claims(session, claims, step, frames, budget)exports a checked step across the claimed frames: each claim becomes an explicit antecedent, a guard, of the exported step, and the table keeps its provenance.label(session, claims, step, budget)computes the step's evidence label: its level (EvidenceLevel.CHECKEDfor a checked step) and the external claims it rests on.discharge(session, claims, guarded, proof, budget)discharges a claimed premise of a guarded step with a proof of it.
Publishing a guarded theorem¶
Prove the guarded step as a theorem (prove_step), export it, and add it to
a change like any other session theorem (changing a library).
The library stores the theorem and its proof rows; it stores no claim
table. Its statement carries every claim as an implication antecedent, so
the theorem is true whatever the tool said.
Citing it again¶
A session opened over the library's snapshot (Session.open(lib.snapshot(budget)))
cites the theorem with import_fact. The cited step's label has no external
claims: its antecedents are explicit implications, and a proof that
discharges one with an ordinary hypothesis stays conditional on it.
Example¶
"""Export checked proof-DAG theorems into a library and track external claims in a session."""
from std.tempfile import mkdtemp
from std.testing import assert_equal, assert_true
from judgment_shell import (
ClaimTable, EvidenceLevel, Session, assume_claim, export_claims, label,
)
from judgment_store import Library
from termbank import Budget
def main() raises:
var budget = Budget(10000000)
var path = String(mkdtemp(), "/lib")
var lib = Library.create(path, "none")
# Track an external claim in a session and export its guarded implication.
var s = Session.open(lib.profile_snapshot(budget))
var root = s.base()
var a = s.type_var("a")
var fx = s.fix(root, "x", a)
var x = fx[1]
var reflexive = x == x
var claims = ClaimTable(s)
var h = assume_claim(s, claims, fx[0], reflexive, "x = x?", "solver", "1", budget)
var guarded = export_claims(s, claims, s.hypothesis(h), [h, fx[0]], budget)
var guarded_label = label(s, claims, guarded, budget)
assert_equal(len(guarded_label.claims), 1)
print("Stored claim:", guarded_label.claims[0].query, "from", guarded_label.claims[0].decider, guarded_label.claims[0].version)
# Close and publish the guarded theorem into the proof-DAG library, then recheck it.
var fact = s.prove_step("claimed.refl", guarded)
var change = lib.change()
change.add(s.export(fact, "claimed.refl"))
_ = change.publish()
var reopened = Library.open(path)
var check = reopened.recheck(budget, workers=1)
assert_true(check.rows > 0)
var s2 = Session.open(reopened.snapshot(budget, workers=1))
var cited = s2.cite(s2.import_fact("claimed.refl"))
var fresh_claims = ClaimTable(s2)
var bare = label(s2, fresh_claims, cited, budget)
assert_equal(bare.level, EvidenceLevel.CHECKED)
assert_equal(len(bare.claims), 0)
print("Rechecked library theorem; plain citation has", len(bare.claims), "claims")
Run from the repository root pixi run mojo run -I src docs/examples/store/records_and_claims.mojo
Output
Stored claim: x = x? from solver 1
Rechecked library theorem; plain citation has 0 claims