Skip to content

feat: Generate sort poly scheme with elim constraints#21567

Draft
TDiazT wants to merge 3 commits intorocq-prover:masterfrom
TDiazT:poly_elim_rec
Draft

feat: Generate sort poly scheme with elim constraints#21567
TDiazT wants to merge 3 commits intorocq-prover:masterfrom
TDiazT:poly_elim_rec

Conversation

@TDiazT
Copy link
Contributor

@TDiazT TDiazT commented Jan 30, 2026

This PR adds the generation of an eliminator "_poly_rec" to sort-polymorphic inductives, leveraging elimination constraints to support any input and output sorts.

Existing "_rect", "_ind", etc., could be defined in terms of this one (for any sort, not just sort variables), but I think that'd be best in a separate PR.

Example:

Inductive nat@{s;|} : Type@{s;0} :=
| O : nat
| S : nat -> nat.

About nat_poly_rec.
(* nat_poly_rec@{α α0 ; u} :
forall (P : forall _ : nat@{α ; }, Type@{α0 ; u}) (_ : P O@{α ; })
  (_ : forall (n : nat@{α ; }) (_ : P n), P (S@{α ; } n)) 
  (n : nat@{α ; }),
P n *)
(* α α0 ; u |= α -> α0 *)

  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.
    • Documented any new / changed user messages.
    • Updated documented syntax by running make doc_gram_rsts.
  • Opened overlay pull requests.

@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jan 30, 2026
Comment on lines +433 to +434
| Qual (QVar _ as q) -> Some (if dep then case_poly_dep q else case_poly_nodep q)
| Set | Qual (QConstant QSProp) ->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to recheck this. Probably extend build_case_analysis_scheme_in_type in the same way as the other.

Copy link
Contributor

Choose a reason for hiding this comment

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

looks alright to me

Comment on lines +39 to +40
val case_poly_dep : Sorts.Quality.t -> individual scheme_kind
val case_poly_nodep : Sorts.Quality.t -> individual scheme_kind
Copy link
Contributor Author

Choose a reason for hiding this comment

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

idem, recheck

@thomas-lamiaux thomas-lamiaux self-assigned this Jan 30, 2026
(UnivGen.QualityOrSet.sprop, "sind")]
in
let elims = List.map (fun (to_kind, dflt_suff) ->
if from_prop then elim_scheme ~dep:false ~to_kind, Some dflt_suff
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not in your code, you do dependent by default

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you mege both functions as before by simply adding an element to elims ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, that's what I was doing before but, to be honest, a lot of the code in the original declare_one_induction_scheme was really adhoc for handling Type, Prop, and SProp specific cases.

For sort variables it's really short actually, so I preferred to separate them, making it easier to understand imo. I just renamed the original declare_one_induction_scheme to declare_one_induction_scheme_const but otherwise is the same code.

Co-authored-by: Thomas Lamiaux <85848641+thomas-lamiaux@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants