Symbolic derivations#
Workspace is the vocabulary a derivation is written against: a sequential
list of typed steps, each either a real SymPy computation with a verdict
(CONFIRMED / REFUTED / INCONCLUSIVE) or an explicitly recorded
assumption (ASSERTED).
The split is the point. Anything SymPy can adjudicate is checked mechanically and carries its verdict; anything it cannot—an ansatz, a physical claim, an unverified relation—is recorded as an assumption rather than blurred into the derivation. A reader of the rendered result can always tell which is which.
This is what MathExpertAgent writes when a run needs an analytical result
rather than a measured one.
adda.Workspace
#
Records a derivation as a sequential list of typed steps.
Source code in src/adda/_src/epistemics/math_dsl.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
name = name
instance-attribute
#
_steps: list[dict] = []
instance-attribute
#
symbols(names: str, **assumptions) -> tuple[sp.Symbol, ...]
#
Source code in src/adda/_src/epistemics/math_dsl.py
65 66 67 68 69 | |
function(name: str, *args)
#
Source code in src/adda/_src/epistemics/math_dsl.py
71 72 | |
assume(name: str, statement: str, expr=None, symbolic_effect: str | None = None) -> None
#
Record a claim SymPy never adjudicates. Verdict is always
"ASSERTED" — an ansatz (pass expr), a scaling/truncation
argument (pass symbolic_effect), or a bare physical claim.
Source code in src/adda/_src/epistemics/math_dsl.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
check_equals(name: str, lhs, rhs, derived_from=()) -> str
#
CONFIRMED if (lhs - rhs) simplifies to / is proven equal to 0;
REFUTED if proven not equal; INCONCLUSIVE if SymPy can't decide
(.equals() returning None — never coerced to either pole).
Source code in src/adda/_src/epistemics/math_dsl.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
check_holds(name: str, predicate, assumptions=None, derived_from=()) -> str
#
Same three-valued verdict as check_equals, via SymPy's assumptions
engine (ask) instead of equality — a domain/inequality claim is not
an equality claim and check_equals cannot express it.
Source code in src/adda/_src/epistemics/math_dsl.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
check_dimensions(name: str, lhs, rhs, derived_from=()) -> str
#
Unit-homogeneity check via the dimension SYSTEM's own equivalence
(equivalent_dims), not raw subtraction of dimensional expressions —
two dimensionally-equal quantities can have syntactically different
dimensional expressions (a named unit like newton reduces to a
symbol, a built-up expression reduces to length*mass/time**2).
Source code in src/adda/_src/epistemics/math_dsl.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
truncate_series(name: str, expr, small_param, order: int, derived_from=())
#
Perturbation/asymptotic truncation — not expressible via check_equals/substitution alone. A computation, not a checked claim: verdict is None.
Source code in src/adda/_src/epistemics/math_dsl.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
solve_ode(name: str, expr, func, ics=None, derived_from=())
#
Integration with an initial/boundary condition (dsolve-based) —
algebraically distinct from algebraic solving. A computation, not a
checked claim: verdict is None.
Source code in src/adda/_src/epistemics/math_dsl.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
coefficient(expr, term)
#
Source code in src/adda/_src/epistemics/math_dsl.py
194 195 | |
render_latex(path: str) -> None
#
One block per step, in call order — the sequential document a human or another agent reads directly.
Source code in src/adda/_src/epistemics/math_dsl.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
write_summary(path: str) -> None
#
The interoperability contract: a consumer parses this without importing SymPy or reading the .py source at all.
{"schema", "workspace", "counts", "steps"}, where each step is
{name, type, verdict, statement, latex, residual, derived_from}.
Three deliberate properties (run 20260912T142229 motivated all three):
schema The file names its own format. Two consumers — the
math_expert comparing two editions, and the critic auditing them —
independently guessed the envelope and had to sniff it with an
isinstance() guard. A record that does not say what it is forces
every reader to infer it, and a later change breaks them silently
instead of loudly.
counts The verdict tally, computed once where the verdicts are
authoritative. Every downstream consumer was recomputing it by
hand and then narrating the result in prose, which puts an
arithmetic step between the evidence and the claim. unchecked
counts steps SymPy never adjudicates (truncate_series, solve_ode:
verdict None); ASSERTED is its own bucket, not a check.
residual The evidence for a non-CONFIRMED verdict. Without it the
contract holds for the steps that passed and fails for exactly the
steps a skeptical reader needs to examine.
Source code in src/adda/_src/epistemics/math_dsl.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
_append_history(path: str, doc: dict) -> None
staticmethod
#
Append this execution's summary to a sibling .history.jsonl.
A derivation script is edited and rerun until its checks pass, and every rerun builds a fresh Workspace and overwrites the summary. So a check that came back INCONCLUSIVE, prompted a correction, and then CONFIRMED leaves exactly the same trace as one that passed on the first try: none. That is the most informative event in the derivation — it is the evidence that a result was earned rather than assumed — and it was the one event the record could not hold.
This is durability of evidence, not a claim about what a verdict means: nothing here changes a verdict, a count, or what the agent must do. The summary file remains the current state and the single thing any consumer reads; the journal is additive and write-only.
NOT the JSONL call-log that spec 10 considered and dropped. That one replaced the .py script as the source of truth and needed bespoke code to replay it — dropped because a real derivation is linear and running the script top to bottom already IS the replay, which is still right. This appends finished summary documents; there is nothing to replay and the script stays the document.
Never fatal: the summary is the contract and is already on disk by the time this runs. A journal that cannot be written costs a warning, not the derivation.
Source code in src/adda/_src/epistemics/math_dsl.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |