Narrate
opulse.language.narrate ¶
Turn recorded forward and reverse steps into checkable prose.
The narrator reads values and expressions already present in a trace or hole problem. Three styles of forward narration:
full(the default, used by stored chains of thought): every line names the step and repeats the whole expression before and after it;terse: one short line per step, about the rewritten part only;explained: says why each case is taken, with the values of the compared expressions ("since7 % 5 = 2and2 > 0, case 2 applies"), and shows the whole expression after each unfolding.
collapse merges a run of consecutive computed steps into one line: "atoms" merges
base operations, "known" every step computed in one go (atoms and operators the reducer
did not unfold), or pass a predicate on the operator. Every number in a narration is a value
of the trace or of a comparison the trace records; the values of compared expressions are
recomputed with the reference interpreter from the step's inputs.
narrate ¶
narrate(
trace: Trace,
renderer: ExpressionRenderer,
lang: str,
style: str = "full",
registry=None,
collapse=None,
semantics=None,
) -> str
Describe each verified reduction step in trace order.
registry is needed for the explained style. Pass the trace's semantics when
explaining a trace produced with nondefault arithmetic bounds.
narrate_reverse ¶
narrate_reverse(
problem: HoleProblem,
renderer: ExpressionRenderer,
lang: str,
) -> str
Work from the outside in: what each enclosing operation needs from the part that holds x.