Comments (12)
@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.
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.
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.
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.
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.
@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.
Yes but I also corrected other stuffs in this branch.
from metacoq.
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.
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.
#89 was merged into 8.8 through another PR
from metacoq.
Does this fix the original issue?
from metacoq.
Yes. I'm closing the issue.
from metacoq.
Related Issues (20)
- MetaCoq is missing `Hint Opaque` HOT 2
- coq-8.17 branch no longer builds on ocaml 4.11.2
- In 8.18, MetaCoq Run sometimes returns an anomaly when running incorrectly typed code. HOT 1
- Please create a tag for the version of MetaCoq that CertiCoq can depend on HOT 1
- Please create a tag for Coq 8.19 in Coq Platform 2024.01 HOT 3
- Anomaly as a result of extraction in CertiCoq (assertion fails in ml code) HOT 2
- Universe inconsistency with MetaCoq and stdpp HOT 1
- `tmUnquote` will normalize the term (get rid of all `tLetIn`)
- `tmQuoteModule` should return global references in dependency order, without duplicates HOT 1
- Request: `tmOpenModule` and `tmCloseModule`
- Request: `tmLocateModule`
- `tmDefinition` says that MetaCoq tactics are bugged and fail to declare universes HOT 2
- Error: Anomaly "Evar ?X40 was not declared." when running template programs with holes which involve `tmDefinition`
- [Feature Request] Please allow scripting `#[export] Typeclasses Opaque foo.` in the template monad HOT 1
- Please create a tag for Coq 8.17 in Coq Platform 2023.03 HOT 7
- Please enable auto rebase from the web interface
- [Feature] Please add `tmTry`
- [Request] Please add debug support for the template monad
- Please create a tag for Coq 8.18 in Coq Platform 2023.10 HOT 4
- Should default branch be coq-8.18 or main? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metacoq.