Keep the dependencies between members of a mutual inductive block - #180
Open
JasonGross wants to merge 2 commits into
Open
Keep the dependencies between members of a mutual inductive block#180JasonGross wants to merge 2 commits into
JasonGross wants to merge 2 commits into
Conversation
`reduce_graph` computes, for each node, the set of nodes reachable from
it in two steps or more, and removes an edge whose target is in that
set. It does so by recursing along the edges, memoizing each node's
result once the recursion under it has finished. On a cycle that
recursion never finishes: `dpd2dot` dies with `Fatal error: exception
Stack_overflow` on so small an input as
N: 1 "a" [kind=cnst, body=yes, prop=no, path="T", ];
N: 2 "b" [kind=cnst, body=yes, prop=no, path="T", ];
E: 1 2 [weight=1, ];
E: 2 1 [weight=1, ];
Compute reachability over the strongly connected components instead.
They form an acyclic graph, so the recursion terminates, and each
component is visited once as before.
The redundancy test moves to components too, which is what it should
have been all along: "reachable in two steps or more" answers yes for
every edge *entering* a cycle -- `a -> b` is redundant as soon as `b`
sits on any cycle, since `a -> b -> ... -> b` is a longer path to the
same node -- so `a` would come out isolated. Asking instead whether the
target's component is reachable from the source's in two component-steps
or more says no, correctly, and coincides with the old test on a graph
without cycles, where every component is a single node.
Edges between two distinct nodes of one component are kept. Each is
redundant in the above sense, so applying the rule to them would drop
the cycle from the graph altogether.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012gna9AxbEH5BjMv5V4Q97n
`collect_dependance` walks the constructor types of an inductive with an
`avoid` list, so that `S : nat -> nat` does not make `nat` depend on
itself. But the list holds a whole `MutInd`, and the guard tests the
`MutInd` of each `Ind`/`Construct` it meets, so it avoids every member
of the block, not just the one being processed. For
Inductive expr := OfVal (v : val) with val := RecV (e : expr).
the graph comes out with the four nodes and no edges at all: `OfVal ->
val`, `RecV -> expr` and the two between the types are all dropped.
Anything that reads the graph to find the block -- a tool that has to
re-emit the two types in one command, say -- cannot see that the two are
related.
Avoid the inductive being processed rather than its whole block. Self
reference stays suppressed, `nat` still has no edge to itself, and the
edges within a block appear.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012gna9AxbEH5BjMv5V4Q97n
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.
collect_dependanceavoids a wholeMutIndwhen walking constructor types, so it drops the edges between members of a mutual inductive block, not just the self-reference it means to suppress.Inductive expr := OfVal (v : val) with val := RecV (e : expr)yields four nodes and no edges at all. First commit: avoid the inductive being processed instead.dpd2dotstack-overflows on any cycle. Second commit: computereduce_graph's reachability over strongly connected components. Identical results on acyclic graphs; every pre-existing oracle unchanged.tests/MutualInductivecase.make testpasses, 26 tests, against Rocq dev.🤖 Generated with Claude Code
https://claude.ai/code/session_012gna9AxbEH5BjMv5V4Q97n