Skip to content

Conversation

@TDiazT
Copy link
Contributor

@TDiazT TDiazT commented Dec 11, 2025

This PR adds implicit elaboration of elimination constraints. Only elimination constraints, not qualities.
(Also some fixes in printing + some refactoring/renaming that don't change the API)

Associated RFC : rocq-prover/rfcs#111.

Examples

Set Universe Polymorphism.

Inductive sum@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) : Type@{s;max(ul,ur)} :=
| inl : A -> sum A B
| inr : B -> sum A B.

(* Elimination constraint left explicitly empty. Definition fails because of missing constraint. *)
Fail Definition sum_elim@{sl sr s0 s0';ul ur v|}
  (A : Type@{sl;ul}) (B : Type@{sr;ur}) (P : sum@{sl sr s0;ul ur} A B -> Type@{s0';v})
  (fl : forall a, P (inl a)) (fr : forall b, P (inr b)) (x : sum@{sl sr s0;ul ur} A B) :=
    match x with
    | inl a => fl a
    | inr b => fr b
    end.
(* The command has indeed failed with message:
Elimination constraints are not implied by the ones declared: s0->s0' *)

(* Using + to elaborate missing constraints. Definition passes *)
Definition sum_elim@{sl sr s0 s0';ul ur v|+}
  (A : Type@{sl;ul}) (B : Type@{sr;ur}) (P : sum@{sl sr s0;ul ur} A B -> Type@{s0';v})
  (fl : forall a, P (inl a)) (fr : forall b, P (inr b)) (x : sum@{sl sr s0;ul ur} A B) :=
    match x with
    | inl a => fl a
    | inr b => fr b
    end.
(* sl sr s0 s0' ; ul ur v |= s0->s0' *)

(* Implicit constraints are elaborated *)
Definition idT@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) (x : sum@{sl sr s;ul ur} A B)
  : sum@{sl sr Type;ul ur} A B :=
  match x return sum@{sl sr Type;ul ur} A B with
  | inl a => inl a
  | inr b => inr b
  end.
(* sl sr s ; ul ur |= s->Type *)

(* Implicit constraints are elaborated *)
Definition idP@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) (x : sum@{sl sr s;ul ur} A B)
  : sum@{sl sr Prop;ul ur} A B :=
  match x return sum@{sl sr Prop;ul ur} A B with
  | inl a => inl a
  | inr b => inr b
  end.
(* sl sr s ; ul ur |= s->Prop *)

Main API Changes

  • univProblem.mli : Extending constraints to include QElimTo
  • evd.mli : Adding a set_elim_to function

Overlays

@TDiazT TDiazT requested review from a team as code owners December 11, 2025 13:14
@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 Dec 11, 2025
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Dec 11, 2025
@TDiazT TDiazT force-pushed the elab-elim-constraints branch 2 times, most recently from a49439b to a83f6ad Compare December 11, 2025 14:56
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Dec 11, 2025
Copy link
Contributor

@SkySkimmer SkySkimmer left a comment

Choose a reason for hiding this comment

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

With the current syntax @{|+} means allow both extra level constraints and extra elimination constraints, I wonder if we should have some way to allow one but not the other.

@SkySkimmer SkySkimmer self-assigned this Dec 15, 2025
because strict proofs can be eliminated only to build strict proofs.
The quality constraints are inconsistent: cannot enforce SProp -> Type
because it would identify Type and SProp which is inconsistent.
This is introduced by the constraints SProp -> Type
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems a bit verbose (repeating "SProp -> Type")
Maybe it's less redundant when transitive constraints are involved? We don't seem to have an output test involving transitive constraints.
If so then maybe we could avoid the repetition when transitivity isn't involved?

Copy link
Contributor

Choose a reason for hiding this comment

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

also we may want to have a custom error message for the "Prop -> Type" (and "SProp -> Type"?) case as that can easily be hit by noobs (eg Goal False \/ False -> nat. intros x; destruct x.) who seem likely to get confused by -> not meaning implication.

@SkySkimmer
Copy link
Contributor

@coqbot run full ci

@coqbot-app coqbot-app bot removed 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 Dec 15, 2025
α1 := Type
α2 := Type
α3 := α1
α3 := α1 |= α1 -> α2 , α1 -> α3 , α1 -> Prop , α1 -> SProp , α1 -> Type , α2 -> α1 , α2 -> α3 , α2 -> Prop , α2 -> SProp , α2 -> Type , α3 -> α1 , α3 -> α2 , α3 -> Prop , α3 -> SProp , α3 -> Type , Prop -> SProp , Type -> α1 , Type -> α2 , Type -> α3 , Type -> Prop , Type -> SProp
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 pretty verbose and could use some line break hints
we probably shouldn't be printing tautologies (Prop -> SProp, Type -> anything)
and maybe when a variable eliminates to grounds we should only print the strongest constraint (here we have both α1 -> Prop and α1 -> SProp, α1 -> Prop implies α1 -> SProp)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not the normalized result, so for me it makes sense that it is "verbose". Below we print the normalized version (I'm adding a fix because the normalized version does not include elimination constraints...). The normalized output is simply:

Normalized constraints:
 {  ; ShowUnivs.26 ShowUnivs.25 } |= ShowUnivs.25 < ShowUnivs.26

which matches what you are saying.

I think another question is whether we want to actually print the non-normalized one ?

Copy link
Contributor

Choose a reason for hiding this comment

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

"normalized" means after minimization so it's very lossy

@TDiazT
Copy link
Contributor Author

TDiazT commented Dec 16, 2025

With the current syntax @{|+} means allow both extra level constraints and extra elimination constraints, I wonder if we should have some way to allow one but not the other.

Mmhh, I have no idea if that would be a desired feature, to be honest. I can't think of a case where one would specifically want the system only to elaborate the constraints for levels or qualities, but not the other 🤷 .

In any case, if we want that we would first need to adjust the parser to distinguish the two types of constraints, right? As of now, there is no restriction on the order in which you can define the constraints, just that they are separated by a comma.

@TDiazT TDiazT force-pushed the elab-elim-constraints branch from a83f6ad to 4e2674d Compare December 16, 2025 10:55
@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 Dec 16, 2025
@SkySkimmer
Copy link
Contributor

@coqbot run full ci

@coqbot-app coqbot-app bot removed 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 Dec 16, 2025
@SkySkimmer
Copy link
Contributor

@coqbot bench

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Dec 16, 2025

🏁 Bench results:

┌─────────────────────────────────────┬─────────────────────────┬───────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]      │           CPU instructions            │  max resident mem [KB]  │
│                                     │                         │                                       │                         │
│            package_name             │   NEW      OLD    PDIFF │      NEW             OLD        PDIFF │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼─────────────────────────┼───────────────────────────────────────┼─────────────────────────┤
│                      rocq-equations │    8.60     8.84  -2.71 │    58647183470     58638852595   0.01 │  398792   397856   0.24 │
│                         rocq-stdlib │  448.36   453.20  -1.07 │  1551254458345   1551475162442  -0.01 │  629460   631216  -0.28 │
│                           rocq-core │    6.64     6.71  -1.04 │    41757677992     41756462230   0.00 │  457744   456376   0.30 │
│                            coq-core │    2.92     2.95  -1.02 │    19747088764     19752437868  -0.03 │  107892   107968  -0.07 │
│                        rocq-bignums │   25.00    25.19  -0.75 │   158801865820    158779857439   0.01 │  460460   459004   0.32 │
│                         coq-unimath │ 1798.47  1807.56  -0.50 │ 14960478261332  14960567121246  -0.00 │ 1054400  1052532   0.18 │
│                        rocq-runtime │   73.96    74.21  -0.34 │   539581571873    539432567874   0.03 │  512648   512976  -0.06 │
│                           coq-verdi │   43.15    43.23  -0.19 │   287162023475    287172684977  -0.00 │  533500   533288   0.04 │
│          rocq-metarocq-translations │   15.63    15.63   0.00 │   110183248998    110209546385  -0.02 │  779596   780352  -0.10 │
│                 rocq-metarocq-utils │   23.87    23.85   0.08 │   154072310290    154060067566   0.01 │  588396   590484  -0.35 │
│                            coq-hott │  154.84   154.57   0.17 │  1050090131169   1050009015880   0.01 │  466912   466908   0.00 │
│              rocq-metarocq-template │   82.29    82.11   0.22 │   565951068655    565959550324  -0.00 │ 1043460  1042944   0.05 │
│               rocq-metarocq-erasure │  476.57   475.48   0.23 │  3264881707626   3264855202623   0.00 │ 1912620  1913156  -0.03 │
│                    coq-fiat-parsers │  276.57   275.84   0.26 │  2112315937906   2112430175548  -0.01 │ 2027264  2033568  -0.31 │
│          coq-performance-tests-lite │  909.89   907.46   0.27 │  7320454799571   7320087106774   0.01 │ 2081724  2081332   0.02 │
│                        coq-compcert │  303.04   302.23   0.27 │  1976539230419   1976710196346  -0.01 │ 1264572  1267312  -0.22 │
│                           coq-color │  230.98   230.20   0.34 │  1458134799470   1458261537720  -0.01 │ 1144148  1145120  -0.08 │
│                        coq-coqprime │   52.99    52.79   0.38 │   360924775876    360935061979  -0.00 │  827028   827324  -0.04 │
│ coq-neural-net-interp-computed-lite │  237.72   236.82   0.38 │  2266268905106   2266287363765  -0.00 │  841964   847540  -0.66 │
│        coq-fiat-crypto-with-bedrock │ 7269.11  7241.24   0.38 │ 59912226326484  59913900937612  -0.00 │ 3170800  3164576   0.20 │
│                 coq-category-theory │  567.20   564.95   0.40 │  4130769462024   4131096185577  -0.01 │  979048   979056  -0.00 │
│         coq-rewriter-perf-SuperFast │  479.81   477.72   0.44 │  3733597745322   3732701139886   0.02 │ 1249204  1261340  -0.96 │
│                        coq-rewriter │  335.32   333.83   0.45 │  2492923183716   2492926343322  -0.00 │ 1492740  1492580   0.01 │
│                             coq-vst │  844.35   839.21   0.61 │  6351245861202   6351374090700  -0.00 │ 2192964  2194380  -0.06 │
│                rocq-metarocq-common │   40.81    40.54   0.67 │   261905800179    261928855208  -0.01 │  902848   900924   0.21 │
│               coq-engine-bench-lite │  128.94   128.08   0.67 │   958754558075    962664891819  -0.41 │ 1156820  1156712   0.01 │
│                 rocq-metarocq-pcuic │  629.10   624.88   0.68 │  4018368567588   4018460721568  -0.00 │ 1940988  1943048  -0.11 │
│                      coq-verdi-raft │  501.49   498.08   0.68 │  3445473930573   3445427555591   0.00 │  826932   829996  -0.37 │
│                       coq-fiat-core │   54.95    54.57   0.70 │   333958728742    334014127323  -0.02 │  482108   481060   0.22 │
│                        coq-bedrock2 │  354.84   352.14   0.77 │  2922439375260   2922758654680  -0.01 │  842416   841420   0.12 │
│                   coq-iris-examples │  369.30   366.47   0.77 │  2419832088418   2419867013814  -0.00 │ 1132196  1130020   0.19 │
│                    coq-math-classes │   83.71    83.03   0.82 │   504594702795    504573693144   0.00 │  515568   514792   0.15 │
│           rocq-metarocq-safechecker │  314.59   312.01   0.83 │  2341543273257   2341879012745  -0.01 │ 1853444  1861776  -0.45 │
│                         coq-coqutil │   46.83    46.33   1.08 │   289440451634    289450489899  -0.00 │  562712   566076  -0.59 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

INFO: failed to install
rocq-elpi (in NEW)

rocq-mathcomp-boot (dependency rocq-elpi failed)
rocq-mathcomp-order (dependency rocq-elpi failed)
rocq-mathcomp-ssreflect (dependency rocq-elpi failed)
rocq-mathcomp-fingroup (dependency rocq-elpi failed)
rocq-mathcomp-algebra (dependency rocq-elpi failed)
rocq-mathcomp-solvable (dependency rocq-elpi failed)
rocq-mathcomp-field (dependency rocq-elpi failed)
rocq-mathcomp-character (dependency rocq-elpi failed)
coq-mathcomp-odd-order (dependency rocq-elpi failed)
coq-mathcomp-analysis (dependency rocq-elpi failed)
coq-corn (dependency rocq-elpi failed)
coq-coquelicot (dependency rocq-elpi failed)
coq-fourcolor (dependency rocq-elpi failed)

🐢 Top 25 slow downs
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                               TOP 25 SLOW DOWNS                                                               │
│                                                                                                                                               │
│  OLD     NEW     DIFF    %DIFF   Ln                      FILE                                                                                 │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│    175     177  1.5950    0.91%  233  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeByExtension.v.html │
│   65.0    66.2  1.1752    1.81%  608  coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html                                             │
│   64.7    65.8  1.1427    1.77%  608  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html           │
│    201     202  0.9196    0.46%    8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html           │
│   58.7    59.6  0.8329    1.42%   27  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                                │
│    119     120  0.6336    0.53%   22  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                                  │
│   6.81    7.43  0.6207    9.11%  165  coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/XZProofs.v.html                                      │
│   21.2    21.7  0.5189    2.45%   24  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/MultiRetSplit.v.html                                   │
│   42.2    42.7  0.5102    1.21%  223  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                            │
│   83.3    83.8  0.4782    0.57%   48  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                                 │
│   36.3    36.7  0.4545    1.25%  224  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                            │
│   30.6    31.0  0.4080    1.33%  225  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                            │
│ 34.155  34.552  0.3970    1.16%   97  coq-vst/veric/binop_lemmas5.v.html                                                                      │
│   31.0    31.4  0.3786    1.22%  148  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html                    │
│   46.3    46.7  0.3744    0.81%  115  coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html                                              │
│   30.7    31.1  0.3681    1.20%  139  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html                    │
│   64.5    64.9  0.3549    0.55%  716  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                                   │
│  0.340   0.690  0.3497  102.92%    1  rocq-stdlib/theories/btauto/Algebra.v.html                                                              │
│   36.6    37.0  0.3469    0.95%  835  coq-fiat-crypto-with-bedrock/src/Fancy/Compiler.v.html                                                  │
│   29.2    29.5  0.3242    1.11%  715  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html                                    │
│   25.2    25.5  0.3188    1.27%  226  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                            │
│   12.4    12.7  0.3026    2.44%  505  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvCommon.v.html           │
│   21.6    21.9  0.2976    1.38%  244  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                            │
│  0.287   0.584  0.2969  103.34%   36  rocq-stdlib/theories/MSets/MSetAVL.v.html                                                               │
│   35.1    35.4  0.2943    0.84%  174  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                           │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                            TOP 25 SPEED UPS                                                            │
│                                                                                                                                        │
│  OLD    NEW    DIFF     %DIFF    Ln                     FILE                                                                           │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  22.8   21.4  -1.3767   -6.05%    49  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                          │
│  40.5   39.9  -0.6668   -1.64%  1423  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html │
│  27.8   27.2  -0.6076   -2.18%   148  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html                     │
│  44.7   44.1  -0.6046   -1.35%   578  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/MMIO.v.html                 │
│  44.7   44.2  -0.5349   -1.20%     3  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html              │
│  1.84   1.38  -0.4578  -24.94%    75  rocq-stdlib/theories/Numbers/HexadecimalString.v.html                                            │
│  48.9   48.4  -0.4484   -0.92%   376  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                      │
│  1.43   1.02  -0.4087  -28.67%   813  rocq-stdlib/theories/MSets/MSetRBT.v.html                                                        │
│  18.7   18.3  -0.3862   -2.06%   481  coq-verdi-raft/theories/RaftProofs/EndToEndLinearizability.v.html                                │
│  21.6   21.3  -0.3571   -1.65%   651  rocq-stdlib/theories/Zmod/ZmodBase.v.html                                                        │
│  45.0   44.7  -0.3570   -0.79%     3  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/bedrock2_fiat_crypto.v.html                 │
│ 0.527  0.171  -0.3561  -67.54%   592  rocq-stdlib/theories/MSets/MSetAVL.v.html                                                        │
│  1.11  0.777  -0.3357  -30.18%   816  rocq-stdlib/theories/MSets/MSetRBT.v.html                                                        │
│  39.1   38.7  -0.3274   -0.84%   239  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                    │
│  29.3   29.0  -0.3236   -1.10%   145  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html                     │
│  14.2   13.9  -0.3114   -2.20%   216  coq-fiat-crypto-with-bedrock/src/Fancy/Barrett256.v.html                                         │
│  97.2   96.9  -0.3082   -0.32%   999  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                  │
│  31.2   30.9  -0.2732   -0.88%   214  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html             │
│ 0.853  0.597  -0.2555  -29.95%   690  rocq-stdlib/theories/setoid_ring/Field_theory.v.html                                             │
│ 0.585  0.344  -0.2407  -41.15%    13  rocq-stdlib/theories/Numbers/DecimalFacts.v.html                                                 │
│ 0.459  0.220  -0.2384  -51.96%    11  rocq-stdlib/theories/QArith/Qcanon.v.html                                                        │
│ 0.499  0.262  -0.2369  -47.49%    13  rocq-stdlib/theories/ZArith/Zmax.v.html                                                          │
│ 0.443  0.213  -0.2299  -51.87%   246  rocq-stdlib/theories/Structures/OrdersEx.v.html                                                  │
│  12.1   11.9  -0.2270   -1.87%   388  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html         │
│ 0.519  0.301  -0.2174  -41.90%  1161  rocq-stdlib/theories/Strings/Byte.v.html                                                         │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@jrosain jrosain requested a review from a team as a code owner January 6, 2026 15:57
@TDiazT TDiazT force-pushed the elab-elim-constraints branch from 1b773df to 969220d Compare January 6, 2026 16:42
@TDiazT TDiazT requested a review from SkySkimmer January 6, 2026 16:45
@jrosain jrosain force-pushed the elab-elim-constraints branch from 969220d to 7d5e87c Compare January 6, 2026 21:24
@SkySkimmer SkySkimmer removed needs: squashing Some commits should be squashed together. needs: documentation Documentation was not added or updated. needs: changelog entry This should be documented in doc/changelog. labels Jan 7, 2026
@SkySkimmer
Copy link
Contributor

This change makes this error message

rocq/vernac/himsg.ml

Lines 301 to 307 in 8613ed9

hov 0
(str "the return type has sort" ++ spc () ++ ppt ++ spc () ++
str "while it should be in a sort " ++ pr_evd_qvar sigma squashq ++ str " eliminates to.") ++
fnl () ++
hov 0
(str "Elimination of a sort polymorphic inductive object instantiated to a variable sort quality" ++ spc() ++
str "is only allowed on itself or with an explicit elimination constraint to the target sort.")
(NotAllowedElimination with SquashToQuality) harder to get (eg in the test suite it got replaced by "constraints are not implied by the ones that were declared") but it's still possible, eg

Set Universe Polymorphism.
Inductive Box@{s s';+} (A:Type@{s;_}) : Type@{s';_} := box (_:A).

Definition unbox@{s s'; +| Prop -> s', s -> Type} A (x:Box@{s s';_} A) := match x with box _ v => v end.
(*
Error:
Incorrect elimination of "x" in the inductive type "Box@{s s' ; foo.25}":
the return type has sort "Type@{s ; foo.25}" while it should be in a sort s' eliminates to.
Elimination of a sort polymorphic inductive object instantiated to a variable sort quality
is only allowed on itself or with an explicit elimination constraint to the target sort.
*)

The message should probably be changed, at least it isn't true anymore that elim constraints must be explicit.

@TDiazT
Copy link
Contributor Author

TDiazT commented Jan 8, 2026

The message should probably be changed, at least it isn't true anymore that elim constraints must be explicit.

Yeah, I would actually simply remove the second part of this message. That's all there is to know about the error.

edit: Or actually, maybe give a hint on how to solve:

(*
Error:
Incorrect elimination of "x" in the inductive type "Box@{s s' ; foo.25}":
the return type has sort "Type@{s ; foo.25}" while it should be in a sort s' eliminates to.
Either adjust the sort qualities accordingly or add an explicit elimination constraint from 
s' to s.
*)

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 8, 2026
@@ -0,0 +1,4 @@
- **Added:**
implicit elaboration of elimination constraints
Copy link
Contributor

Choose a reason for hiding this comment

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

should have a link to the doc section about this

Suggested change
implicit elaboration of elimination constraints
implicit elaboration of :ref:`elimination constraints <elim-constraints>`

together with my other requested change

instance is sort polymorphic, the return type of the elimination must
be at the same quality. These restrictions ignore :flag:`Definitional
UIP`.
Elimination of Sort-Polymorphic Inductives
Copy link
Contributor

Choose a reason for hiding this comment

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

makes this a target for the :ref: I suggest in the changelog

Suggested change
Elimination of Sort-Polymorphic Inductives
.. _elim-constraints:
Elimination of Sort-Polymorphic Inductives

@SkySkimmer
Copy link
Contributor

Yeah, I would actually simply remove the second part of this message. That's all there is to know about the error.

We could also try to keep the qgraph error, eg 652ebda produces (however too verbose IMO, probably we shouldn't say the "is only allowed" sentence when we have a qgraph error)

Error:
Incorrect elimination of "x" in the inductive type "Box@{s s' ; foo.25}":
the return type has sort "Type@{s ; foo.25}" while it should be in a sort s' eliminates to.
Elimination of a sort polymorphic inductive object instantiated to a variable sort quality
is only allowed on itself or with an explicit elimination constraint to the target sort.
The quality constraints are inconsistent: cannot enforce s' -> s because it would identify Prop
which is inconsistent. This is introduced by the constraints Prop -> s' -> s.

@TDiazT TDiazT force-pushed the elab-elim-constraints branch from 7d5e87c to ef3588a Compare January 8, 2026 23:02
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 8, 2026
@TDiazT
Copy link
Contributor Author

TDiazT commented Jan 8, 2026

Error:
Incorrect elimination of "x" in the inductive type "Box@{s s' ; foo.25}":
the return type has sort "Type@{s ; foo.25}" while it should be in a sort s' eliminates to.
Elimination of a sort polymorphic inductive object instantiated to a variable sort quality
is only allowed on itself or with an explicit elimination constraint to the target sort.
The quality constraints are inconsistent: cannot enforce s' -> s because it would identify Prop
which is inconsistent. This is introduced by the constraints Prop -> s' -> s.

Yeah, although in your example it would be weird for a user to read that the qualities are inconsistent. Maybe it would be ok with the part stating that it is trying to enforce s -> s' but... still a bit weird if they are being explicit about the constraints (ie. why is it trying to enforce the other).

In this case I feel the first part of the error is enough to understand what is happening: You don't need to know it's trying to enforce it under the hood and the "is allowed sentence" sentence is not completely correct. We could replace the second sentence with suggestions on how to fix?

@SkySkimmer
Copy link
Contributor

We could replace the second sentence with suggestions on how to fix?

What suggestions could we make?

@SkySkimmer
Copy link
Contributor

So what do we do about the error messages?

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 15, 2026
@TDiazT
Copy link
Contributor Author

TDiazT commented Jan 15, 2026

We could replace the second sentence with suggestions on how to fix?

What suggestions could we make?

"Either adjust the sort qualities accordingly or add an explicit elimination constraint from s' to s"?

TDiazT and others added 5 commits January 16, 2026 00:04
Whenever an elimination constraint is not satisfied, then it adds the constraint
as a new local one for the definition. Currently behind a flag to avoid
backward compatibility for the moment.

fix: Reintroduce QElimTo to univProblem

It was replaced by QLeq to deal only with cumulativity
constraints.

refactor: Remove unnecessary abstraction of code

Maybe it's using a more general API than it should, considering
PConstraints instead of simply UnivConstrants.

fix: Handle new EliminationError exception in cases and inductiveops

print: Improve printing of qGraph and elimination errors

refactor: Printing suggestions from code review

Co-authored-by: Gaëtan Gilbert <[email protected]>

refactor: Printing suggestion
Remove overlay for hb
@TDiazT TDiazT force-pushed the elab-elim-constraints branch from ef3588a to fa7a374 Compare January 15, 2026 23:04
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jan 15, 2026
@SkySkimmer
Copy link
Contributor

@coqbot run full ci

@coqbot-app coqbot-app bot removed 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 16, 2026
@SkySkimmer SkySkimmer added the kind: enhancement Enhancement to an existing user-facing feature, tactic, etc. label Jan 16, 2026
@SkySkimmer SkySkimmer added this to the 9.2+rc1 milestone Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: enhancement Enhancement to an existing user-facing feature, tactic, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants