Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import type { PropositionStep } from '../types' import type { ProofFact } from '../engine/facts' import { citationDefFromFact } from '../engine/citations' /** * Compute progressive disclosure ordinals for citations. * * Each citation key tracks how many times it has appeared so far: * - 1st: full label + axiom text * - 2nd: full label only * - 3rd+: abbreviated key * * Returns a Map from `"step-{i}"` or `"fact-{id}"` to the ordinal. */ export function computeCitationOrdinals( steps: PropositionStep[], factsByStep: Map<number, ProofFact[]> ): Map<string, number> { const counts = new Map<string, number>() const ordinals = new Map<string, number>() for (let i = 0; i < steps.length; i++) { const step = steps[i] if (step.citation) { const n = (counts.get(step.citation) ?? 0) + 1 counts.set(step.citation, n) ordinals.set(`step-${i}`, n) } for (const fact of factsByStep.get(i) ?? []) { const cd = citationDefFromFact(fact.citation) if (cd) { const n = (counts.get(cd.key) ?? 0) + 1 counts.set(cd.key, n) ordinals.set(`fact-${fact.id}`, n) } } } // Conclusion facts (atStep === steps.length) for (const fact of factsByStep.get(steps.length) ?? []) { const cd = citationDefFromFact(fact.citation) if (cd) { const n = (counts.get(cd.key) ?? 0) + 1 counts.set(cd.key, n) ordinals.set(`fact-${fact.id}`, n) } } return ordinals } |