Skip to content

Do not store recursive trees anymore in inductive blocks.#21901

Open
ppedrot wants to merge 2 commits intorocq-prover:masterfrom
ppedrot:rm-inductive-recarg-from-declarations
Open

Do not store recursive trees anymore in inductive blocks.#21901
ppedrot wants to merge 2 commits intorocq-prover:masterfrom
ppedrot:rm-inductive-recarg-from-declarations

Conversation

@ppedrot
Copy link
Copy Markdown
Member

@ppedrot ppedrot commented Apr 8, 2026

This data is now useless as it can be recovered from the compiled automaton.

@ppedrot ppedrot added this to the 9.3+rc1 milestone Apr 8, 2026
@ppedrot ppedrot requested review from a team as code owners April 8, 2026 10:23
@ppedrot ppedrot added kind: cleanup Code removal, deprecation, refactorings, etc. request: full CI Use this label when you want your next push to trigger a full CI. labels Apr 8, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Apr 8, 2026
ppedrot added a commit to ppedrot/coq-elpi that referenced this pull request Apr 8, 2026
Backwards compatible, can be merged already.
ppedrot added a commit to ppedrot/coq-elpi that referenced this pull request Apr 8, 2026
Backwards compatible, can be merged already.
infos.is_general
|| Rtree.is_infinite Declareops.eq_recarg
graph_def.Declarations.mind_recargs
|| Inductiveops.mis_is_recursive graph_def
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this equivalent, or if not a correct replacement?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who cares, this is funind.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you made the same change for elpi.

Comment thread pretyping/inductiveops.ml
Copy link
Copy Markdown
Contributor

@yannl35133 yannl35133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can accept on behalf of @rocq-prover/kernel-maintainers but real users should be the ones to comment on the changes this PR introduces.

gares added a commit to LPCIC/coq-elpi that referenced this pull request Apr 9, 2026
@yannl35133
Copy link
Copy Markdown
Contributor

@ppedrot If you stand by and add in a comment the invariant that "a non-trivial recursive tree / automaton implies it must have a loop", I'll merge this.

@yannl35133 yannl35133 self-assigned this Apr 14, 2026
ppedrot added 2 commits April 15, 2026 09:00
This data is now useless as it can be recovered from the compiled automaton.
@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Apr 15, 2026
@ppedrot ppedrot force-pushed the rm-inductive-recarg-from-declarations branch from da06334 to 7e63485 Compare April 15, 2026 07:03
@ppedrot
Copy link
Copy Markdown
Member Author

ppedrot commented Apr 15, 2026

I've added a comment to mis_is_recursive to make clean the intended semantics.

@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Apr 15, 2026
Comment on lines +66 to +69
(** Check if a [one_inductive_body] is recursive. An inductive is recursive
either if it has a constructor that mentions it in its normal form type, or
if it nested. Note that the latter case means that an inductive is
considered recursive even if the nesting type does not mention its argument. *)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normal form type of a constructor always mention its inductive (in the codomain).
Also, mutual inductives trigger the check.
Feel free to adapt this suggestion:

Suggested change
(** Check if a [one_inductive_body] is recursive. An inductive is recursive
either if it has a constructor that mentions it in its normal form type, or
if it nested. Note that the latter case means that an inductive is
considered recursive even if the nesting type does not mention its argument. *)
(** Check if a [one_inductive_body] is recursive.
An inductive is recursive if it has a constructor argument whose type
(or, for function types, the codomain of which) is either
the inductive itself, another inductive of the same mutual block
or another type nesting over the inductive
(without it needing to mention its argument).
Equivalently, an inductive is recursive if its minimized recursive tree is not trivial. *)

I found another weird edge case, but this is independent from this PR at this stage:

Inductive P (u : unit) := c.
Inductive T := C (x : P (let x := T in tt)).

T is recursive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: cleanup Code removal, deprecation, refactorings, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants