Add elaboration of qualities#21450
Conversation
cda08c0 to
26bf881
Compare
|
@coqbot run full ci |
4cfacbd to
3f8c2f6
Compare
c1101c4 to
cc003ef
Compare
|
@coqbot run full ci |
4edbda7 to
1eb5379
Compare
SkySkimmer
left a comment
There was a problem hiding this comment.
I think if you squash everything into 1 commit this should be ready
|
@SkySkimmer squashing ready 👌 |
|
@coqbot run full ci |
kernel/inductive.ml
Outdated
|
|
||
|
|
||
| let check_fix ?evars ?elim_to env ((nvect,_),(names,_,bodies as recdef) as fix) = | ||
| (* Returns the pairs of (inductive sort * output sort) or None if Type in Type *) |
There was a problem hiding this comment.
| (* Returns the pairs of (inductive sort * output sort) or None if Type in Type *) | |
| (* Returns the pairs of (inductive sort * output sort) | |
| or None if any elimination constraint was ignored. *) |
| let sorts_of_mutfix env minds names = | ||
| let ind_ignores_elim_constraints (ind, _) = Environ.ind_ignores_elim_constraints env ind in | ||
| (* recursive sprop means non record with projections -> squashed *) | ||
| if Array.exists ind_ignores_elim_constraints minds then None |
There was a problem hiding this comment.
Why skip all constraints if only one is allowed to be ignored? If universe constraints are to be taken as a reference, we should keep all constraints, remembering whether they may be ignored, and try to add them all, only ignoring in case of failure.
There was a problem hiding this comment.
This used to be a check of type in type, which made it unnecessary to check all cases. I assumed that the change to use ind_ignores_elim_constraints instead was including this type in type scenario, and so the logic remained the same. Is there more to this flag?
There was a problem hiding this comment.
The currently proposed behaviour is fine, this can be modified in a later PR.
| uj_type = expected_type } | ||
|
|
||
| let check_fix_with_elims env sigma fix = | ||
| let evars = Evd.evar_handler sigma in |
There was a problem hiding this comment.
As was suggested in another comment, this function should take in econstrs and deal with the translation to constr here : a hidden invariant is that check_fix_pre_sorts (because of check_one_fix) needs to take in evar-normalised terms, so that call to EConstr.to_constr should be reinstated (here instead).
There was a problem hiding this comment.
doesn't check_fix_pre_sorts take a evar handler? why would it need evar normal terms?
There was a problem hiding this comment.
check_one_fix doesn't evar-reduce before inspecting its body, so it may find an evar that is actually defined and not check the definition. The evar handler is only passed to the weak-head reducing function, which is not systematically called (for good reasons).
There was a problem hiding this comment.
check_fix_sorts operating on constr can be changed at a later time, only EConstr.to_constr instead of Unsafe.to_constr is required.
| (* Or should inductive_levels be cut off earlier, e.g. at L646 ? *) | ||
| let candidates = if not @@ PolyFlags.collapse_sort_variables poly | ||
| then [] | ||
| else prop_lowering_candidates evd ~arities_explicit inds |
vernac/declare.ml
Outdated
| [declare_mutual_definitions] where we get it from UState. *) | ||
| let sigma = Option.default (Evd.from_env env) sigma in | ||
| let res = Pretyping.search_guard env sigma possible_guard rec_declaration in | ||
| (* We are forgetting about sigma here -- probably missing something *) |
There was a problem hiding this comment.
This does look fishy, but I'm already surprised by the fact that this code handles regular constrs and not econstrs.
There was a problem hiding this comment.
isn't it just an outdated comment?
There was a problem hiding this comment.
Right, the evar_map isn't forgotten, but it's still weird that this code doesn't handle econstrs. This is unrelated to this PR now though.
Currently behind a Sort Polymorphism flag. fix: Generate proper sort variable in record feat: Add sort elab for interactive definitions fix: Thread sort poly flag more correctly It was being passed as unconstrained_sorts in some cases. refactor: Remove unnecessary sort_poly flags fix: Add sort_poly to prepare_obligations refactor: Remove remaining fixmes and todos refactor: General cleanup refactor: Get ?evar_handler from evd refactor: Remove search_fix_guard doc: comment collapse refactor: Remove unnecessary unconstrained_sorts refactor: Remove unnecessary check for collapse_sort_variables revert: Some changes in unify quality feat: Add elim constraints to non-prim records with sort variables doc: Add doc on flag + implicit elab of sorts chore: Add changelog entry chore: Add overlays refactor: indentation feat: Add more specific elim constraints to non-prim projections Address comments refactor: Pass on sigma in search_guard test: Move sort_poly_elab test to output folder fix: Change assert implicit sort vars for error in sections fix(attempt): Return evd from make_recursive_bodies refactor: Change option array to list option refactor: Use Cmap_env to keep elim constraints from projs Apply suggestion from @SkySkimmer update test
|
@coqbot run full ci |
|
@coqbot merge now |
|
@SkySkimmer: Please take care of the following overlays:
|
This PR depends on #21417 .
This PR adds elaboration of (implicit) qualities, which is enabled by setting the flag
Universe Polymorphismand disabling a new flagCollapse Sorts ToType.Associated RFC : rocq-prover/rfcs#111.
Examples
The test file
test-suite/success/sort_poly_elab.vhas been updated with more examples.Overlays