Skip to content

Keep the dependencies between members of a mutual inductive block - #180

Open
JasonGross wants to merge 2 commits into
rocq-community:coq-masterfrom
theorem-labs:mutual-inductive-sibling-deps
Open

Keep the dependencies between members of a mutual inductive block#180
JasonGross wants to merge 2 commits into
rocq-community:coq-masterfrom
theorem-labs:mutual-inductive-sibling-deps

Conversation

@JasonGross

@JasonGross JasonGross commented Aug 13, 2026

Copy link
Copy Markdown
Member
  • collect_dependance avoids a whole MutInd when 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.
  • That makes cycles reachable for the first time — nothing else in a dpd graph produces one — and dpd2dot stack-overflows on any cycle. Second commit: compute reduce_graph's reachability over strongly connected components. Identical results on acyclic graphs; every pre-existing oracle unchanged.
  • New tests/MutualInductive case. make test passes, 26 tests, against Rocq dev.

🤖 Generated with Claude Code

https://claude.ai/code/session_012gna9AxbEH5BjMv5V4Q97n

JasonGross and others added 2 commits August 13, 2026 14:43
`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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant