Closed yannl35133 closed 10 months ago
I expect the quotation part should not be too hard to repair; the bulk of the code is just mirror of the rest of the development where there's a definition for every record, inductive, and type-valued-definition-containing-a-match. Assuming there are no new types that hold either informative functions (things like "here's a map from names to universes, represented as a function") nor hold Type
s nor live in Prop
while being undecidable, I expect adaptation to be pretty straightforward. I don't have much time to spend on this, but I'm happy to assist with fixing. Could you point me at what breaks / what breaks that you don't know how to fix?
I'm stuck there here, I can't quote quote_All_local_env_over_sorting
, presumably because I can't quote quote_lift_sorting
, this one I just don't know how to.
My guess is that quote_lift_sorting
just needs some extra arguments that say that not only can you quote elements of check
and sorting
but also check
and sorting
can themselves be quoted, i.e., try
- #[export] Instance quote_lift_sorting {check sorting j} {quote_check : forall tm, j_term j = Some tm -> ground_quotable (check tm (j_typ j))} {quote_sorting : forall u, ground_quotable (sorting (j_typ j) u)} : ground_quotable (@lift_sorting check sorting j) := ltac:(cbv [lift_sorting]; exact _).
+ #[export] Instance quote_lift_sorting {check sorting j} {qcheck : quotation_of check} {qsorting : quotation_of sorting} {quote_check : forall tm, j_term j = Some tm -> ground_quotable (check tm (j_typ j))} {quote_sorting : forall u, ground_quotable (sorting (j_typ j) u)} : ground_quotable (@lift_sorting check sorting j) := ltac:(cbv [lift_sorting]; exact _).
Does this work? (You shouldn't need qj : quotation_of j
because I expect there should be an instance of ground_quotable judgment
already available at this point; if not, then that should be added / exposed in the appropriate place.)
(Sorry, I wrote this all yesterday and then forgot to click "comment")
Btw, if you stick
#[local] Instance:debug_opt := true.
before the failing #[export] Instance quote_lift_sorting ...
, you'll see the printout starts with
(Ast.tVar "check"%bs)
(Ast.tVar "check"%bs)
(quotation_of check)
which indicates that it's having trouble finding quotation_of check
. Adding {qcheck : quotation_of check}
to the argument list makes the printout start with
(Ast.tVar "sorting"%bs)
(Ast.tVar "sorting"%bs)
(quotation_of sorting)
and then adding {qsorting : quotation_of sorting}
makes the instance go through.
Debugging the proof below the same way gives an output that starts with
(Ast.tVar "Hc"%bs)
(Ast.tVar "Hc"%bs)
(quotation_of Hc)
If I do
Set Typeclasses Debug Verbosity 2.
try pose proof (_ : quotation_of Hc).
I see
The important lines are
Debug: 1.1-1.1-1: looking for (ground_quotable (cproperty Γ all b (j_typ (TermTyp b t)) (fst tu))) without backtracking
Debug: 1.1-1.1-1.1: simple apply quote_cproperty on
(ground_quotable (cproperty Γ all b (j_typ (TermTyp b t)) (fst tu))) failed with: Cannot unify
(MCOption.option_default (fun tm : term => checking Γ tm (j_typ (TermTyp b t))) (j_term (TermTyp b t)) unit) and
(checking Γ b (j_typ (TermTyp b t)))
If we Set Debug "tactic-unification".
as well, between the above lines there's a unification trace ending in
Debug:
[tactic-unification] Starting unification: MCOption.option_default (fun tm : term => checking Γ tm (j_typ (TermTyp b t)))
(j_term (TermTyp b t)) unit ~= checking Γ b (j_typ (TermTyp b t))
Debug: [tactic-unification] Leaving unification with failure
So we can add cbn [MCOption.option_default j_term] in *
after induction 1
, and indeed this allows the proof to go through with induction 1; cbn [MCOption.option_default j_term] in *; exact _.
If it turns out that there are many proofs that need this sort of modification, we could try adding MCOption.option_default
and j_term
to the list of Hint Unfold
and Typeclasses Transparent
, but I'd rather keep those lists as small as possible for typeclass resolution performance.
@JasonGross This PR changes many low-level elements and seems to break quite seriously the quotation part, which I don't know how to repair. I may have to remove it from the CI if I want it to still check all other components. Can I have your opinion on how to find a solution ? (This PR is the first step towards supporting SProp in MetaCoq)