feat(display): add responder coalgebras - #84
Merged
Merged
Conversation
quangvdao
force-pushed
the
agent/aberle-g1-display-coalgebra
branch
from
July 18, 2026 08:22
1d7c37e to
bef8a50
Compare
quangvdao
marked this pull request as ready for review
July 18, 2026 08:27
This was referenced Jul 18, 2026
quangvdao
force-pushed
the
refactor/displayed-algebra-names
branch
from
July 18, 2026 19:16
0dc493d to
9f68b3d
Compare
quangvdao
force-pushed
the
agent/aberle-g1-display-coalgebra
branch
from
July 18, 2026 19:16
bef8a50 to
53aa6cd
Compare
dtumad
approved these changes
Jul 19, 2026
dtumad
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the responder coalgebra variance and dependent evidence flow. A displayed position supplies post-evidence from query plus pre-evidence, while directions retain the supplied evidence; the coalgebra equivalence correctly packages answer and next witness. Empty and dependent examples cover the delicate cases. No blocking findings.
dtumad
force-pushed
the
refactor/displayed-algebra-names
branch
from
July 19, 2026 02:38
9f68b3d to
4a15062
Compare
dtumad
force-pushed
the
agent/aberle-g1-display-coalgebra
branch
from
July 19, 2026 02:48
53aa6cd to
c912fe9
Compare
dtumad
approved these changes
Jul 19, 2026
dtumad
left a comment
Collaborator
There was a problem hiding this comment.
Approval renewed after GitHub merged current main into the patch-identical restack; the endpoint diff remains the previously reviewed isolated change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and context
This is G1 of the Aberlé general-theory stack, based directly on #75 (which is
itself stacked on #74). #74 introduces
PFunctor.Display, the intrinsicdependent-polynomial layer over a base polynomial. This PR supplies the first
coalgebraic application of that layer: proof-relevant responder contracts in
the exact local form used by Aberlé's Agda
DepMealy.appD.The key distinction is variance. For a display
Sover a query interfaceP, a verified responder does not choose a precondition witness. Its callersupplies
c : S.position a; the responder returns evidence that its committedanswer satisfies
S.direction a c ..., together with a recursively preservedstate witness. Capturing that dependency correctly is what makes the API
useful for the later dependent-program and coinductive-behavior slices.
What this PR adds
Generic displayed coalgebras
Display.Coalgebra S step Fis the transparent abbreviationIt deliberately does not bundle or duplicate the base coalgebra. For a
Responder C P, it is applied directly to the existingR.outmap.The responder display
Display.responder Slies over the existing responder interfaceP ⊸ X.Above an answer section, its data are
position answer := (a : P.A) → (c : S.position a) → S.direction a c (answer a) direction _answer _post query := S.position query.1Thus a displayed position gives answer-dependent post-evidence for every
query and supplied pre-witness, while the displayed direction retains that
pre-witness for the recursively verified continuation.
responderChartis the canonical covariant chart that forgets this evidence.Exact local dependent-Mealy interface
responderCoalgebraEquividentifies a generic displayed coalgebra overR.outwith the literal local obligation(state : C) → F state → (a : P.A) → (c : S.position a) → S.direction a c (R.answer state a) × F (R.next state a)This is the state-presented, one-step form of the Agda declaration
Both directions of the equivalence have simp-normal projection equations for
the postcondition and continuation components.
Relationship to existing PolyFun abstractions
Displayis intrinsic dependent-polynomial data over onePFunctor.Display.Coalgebrapreserves a proof-relevant family through one basecoalgebra step.
Displayednamespace concerns algebras, folds, anddecorations indexed over already-built
Freetrees. It remains the rightlayer for the later applications, but it is not the representation of the
dependent polynomial itself.
DynSystem.SafetyRefinement: that API is proposition-valued andrelational between two systems. Here the contract is proof-relevant and
intrinsic to one responder.
Responder/DynSystemstate presentation is reused; nosecond verified-machine structure or paper-specific alias is introduced.
Tests and falsifiable canaries
The tests include:
Fin (state + 1);paper obligation is vacuously inhabited and does not manufacture evidence;
Bool, detecting accidental erasure of continuation dependence;
display positions, display directions, states, and state witnesses.
Alternatives rejected and implementation findings
The first draft used
Σ c : S.position a, ...for responder positions andPUnitfor displayed directions. Independent review found that this reversesthe paper's precondition variance: it chooses one witness instead of accepting
every caller-supplied witness, and forces one shared continuation per query.
An empty precondition fiber is a minimal counterexample.
That initial representation also appeared to admit a stronger forgetting
Lens. The corrected representation shows why no such lens exists ingeneral: lifting a bare query contravariantly would require inventing an
element of
S.position a, which may be empty. The invalid lens and all of itslaws were removed; the covariant chart is the correct general projection.
This finding changes the later coinductive-behavior design: it must construct
a genuinely displayed/coinductive fiber over fixed base behavior, rather than
using a fiber of
M.mapLensinduced by a nonexistent total-to-base lens.Deliberate non-goals
DepMealyobject yet; that belongs tothe later behavior slice.
G2/G3 slices.
express the concept.
lenses.
Stack and validation
9f68b3da59b3bf59c38527415164dd2f1ebd0c1f53aa6cdd937075704f5bf3e423a6642ce904d755./scripts/validate.sh --lint --test: passed on the exact head (8832 projectjobs, umbrella-import and documentation checks, environment lint, and all
1970 test jobs).
lake exe lint-style,lake lint, andgit diff --check: passed.review-lean-formalizationreview: the initial variance andlens findings were resolved, and the exact-head closure pass reported no
remaining actionable findings.
Final restack and audit (2026-07-19)
This final record supersedes earlier candidate SHA and count language above.
9f68b3da59b3bf59c38527415164dd2f1ebd0c1f(refactor(displayed): use algebra terminology #75)53aa6cdd937075704f5bf3e423a6642ce904d755The final exact-head review reconfirmed that
Display.Coalgebrais the correct transparent generic layer, whileDisplay.responderandresponderCoalgebraEquivare the responder specialization with caller-supplied precondition variance. Empty-fiber and Boolean-continuation canaries reject evidence erasure or existential variance. No universe coupling or duplicate bundle remains.Fresh
./scripts/validate.sh --lint --testpassed at this head: 8,840 build jobs, generated imports, docs integrity, environment lint, and the full test library. Style, diff, trust, and axiom audits pass. Hosted style and summary pass; the full local validator is authoritative for this non-default stacked base.