GithubHelp home page GithubHelp logo

Comments (12)

CohenCyril avatar CohenCyril commented on August 27, 2024

@drouhling I just realized we should continue the minimization a bit further... replacing the first call of tTranslate by a simpler function... (maybe a single tmMkDefinition or tmMkInductive is enough?)

from metacoq.

CohenCyril avatar CohenCyril commented on August 27, 2024

Also, maybe the backtracking comes from typeclass resolution, we should try forcing the Translation to be a fixed one: I just noticed Translation is a class without parameters, so it is extremely dangerous to keep it implicit.

from metacoq.

SimonBoulier avatar SimonBoulier commented on August 27, 2024

I encountered the same problem!
I will try to fix it as soon as I can.
Say me if you make some progress.

from metacoq.

drouhling avatar drouhling commented on August 27, 2024

I focused on these lines in tTranslate (lines 91 to 93 in translation_utils.v):

        monad_fold_left (fun _ e => tmMkInductive' e) decls tt ;;
        print_nf  (id ++ " has been translated as " ++ id') ;;
        ret (add_global_decl (InductiveDecl kn d) (fst ΣE), E ++ snd ΣE)%list

since they are the last lines to be executed when translating for instance unit.

In the case of the translation of unit chained with a definition:

Notation pb :=
     (tInd {| inductive_mind := "Top.unitᵗ"; inductive_ind := 0 |} []).
Fail Run TemplateProgram (tTranslate' emptyTC "unit" ;; tmMkDefinition "toto" pb).

What is executed at the end of the call to tTranslate corresponds to:

Notation bt :=
 ({|
 ind_npars := 0;
 ind_bodies := [{|
                ind_name := "unitᵗ";
                ind_type := tProd nAnon
                              (tInd
                                 {|
                                 inductive_mind := "Coq.Init.Datatypes.unit";
                                 inductive_ind := 0 |} []) (tSort [(Level.lSet, false)]);
                ind_kelim := [InProp; InSet; InType];
                ind_ctors := [("ttᵗ",
                              tApp (tRel 0)
                                [tConstruct
                                   {|
                                   inductive_mind := "Coq.Init.Datatypes.unit";
                                   inductive_ind := 0 |} 0 []], 0)];
                ind_projs := [] |}];
 ind_universes := Monomorphic_ctx
                    ([],
                    {| ConstraintSet.this := [];
                       ConstraintSet.is_ok := ConstraintSet.Raw.empty_ok |}) |}).

Notation d :=
  ({|
ind_npars := 0;
ind_bodies := [{|
               ind_name := "unit";
               ind_type := tSort [(Level.lSet, false)];
               ind_kelim := [InProp; InSet; InType];
               ind_ctors := [("tt", tRel 0, 0)];
               ind_projs := [] |}];
ind_universes := Monomorphic_ctx (UContext.make [] ConstraintSet.empty) |}).

Notation E := [(IndRef {| inductive_mind := "Coq.Init.Datatypes.unit"; inductive_ind := 0 |},
pb); (ConstructRef {| inductive_mind := "Coq.Init.Datatypes.unit"; inductive_ind := 0 |} 0,
tConstruct {| inductive_mind := "Top.unitᵗ"; inductive_ind := 0 |} 0 [])].

Run TemplateProgram (tmMkInductive' bt ;; ret (add_global_decl
(InductiveDecl "Coq.Init.Datatypes.unit" d) (fst emptyTC), E)%list).

If we run after this the command

Run TemplateProgram (tmMkDefinition "toto" pb).

everything is ok, but if we chain both commands:

Run TemplateProgram (tmMkInductive' bt ;; ret (add_global_decl
(InductiveDecl "Coq.Init.Datatypes.unit" d) (fst emptyTC), E)%list ;;
tmMkDefinition "toto" pb).

we get Error: Anomaly "Uncaught exception Not_found." Please report at http://coq.inria.fr/bugs/.

The ret part does not seem to matter much since

Run TemplateProgram (tmMkInductive' bt ;; tmMkDefinition "toto" pb).

also raises the exception.

from metacoq.

SimonBoulier avatar SimonBoulier commented on August 27, 2024

I don't remember exactly what was the problem but I fixed it in #89.
(Moreover the translation plugin becomes up to date).
Say me if you encounter any other problem.

from metacoq.

CohenCyril avatar CohenCyril commented on August 27, 2024

@SimonBoulier since

Run TemplateProgram (tmMkInductive' bt ;; ret (add_global_decl
(InductiveDecl "Coq.Init.Datatypes.unit" d) (fst emptyTC), E)%list ;;
tmMkDefinition "toto" pb).

raises an anomaly, it is not about the translation plugin.

from metacoq.

SimonBoulier avatar SimonBoulier commented on August 27, 2024

Yes but I also corrected other stuffs in this branch.

from metacoq.

CohenCyril avatar CohenCyril commented on August 27, 2024

Hi @mattam82, any idea about @drouhling's bug?
@SimonBoulier, in #89, why are you merging in a branch that is not master (or any coq release)?

from metacoq.

mattam82 avatar mattam82 commented on August 27, 2024

I think it was fixed by properly threading the updated global environment in the monadic interpretation function (e.g. Not_found was raised because tmMkDefinition did not see the declaration of the inductive before).

from metacoq.

mattam82 avatar mattam82 commented on August 27, 2024

#89 was merged into 8.8 through another PR

from metacoq.

mattam82 avatar mattam82 commented on August 27, 2024

Does this fix the original issue?

from metacoq.

drouhling avatar drouhling commented on August 27, 2024

Yes. I'm closing the issue.

from metacoq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.