Comments (9)
I don't suppose setting a mode of -
for word
changes anything? I think this might also be worth a bug report on Coq?
from bedrock2.
since the first subgoal appears as a dependency in the second subgoal, the first subgoal is shelved, and typeclass search works on the second subgoal
This is the part that seems wrong/surprising to me. It'd be great if we got coqdev advice on whether this is intended and/or how to avoid it.
Would "just use parameter records instead of word and map parameters" be an acceptable workaround in your use case?
from bedrock2.
I don't suppose setting a mode of
-
forword
changes anything?
It does change something: It sends typeclass search into an infinite loop! I minimized the infinite loop to the following:
Class word := { }.
Module MMIO.
Class parameters := {
word :> word;
}.
End MMIO.
Instance MMIO_compiler_params{word: word}: MMIO.parameters := {
MMIO.word := word;
}.
Check MMIO.word. (* loops for a few seconds, then stack overflow *)
I'm surprised that Coq doesn't have any mechanism to avoid such loops. Is it my responsibility to set Hint Mode
or other flags appropriately in the code base to make sure no loops happen? If so, do you have a systematic approach to convince yourself that a codebase is typeclass-search-loop free? Or is this a Coq bug?
I think this might also be worth a bug report on Coq?
I'll try to also isolate the original bug above.
This is the part that seems wrong/surprising to me. It'd be great if we got coqdev advice on whether this is intended and/or how to avoid it.
I'll ask once I have isolated it.
Would "just use parameter records instead of word and map parameters" be an acceptable workaround in your use case?
No, because I'm still trying to get rid of parameter records, which are one of the biggest sources of user-unfriendliness (syntactically different implicit arguments cause rewrite
, lia
, ecancel_assumption
and many other tactics to stop working).
from bedrock2.
I'm surprised that Coq doesn't have any mechanism to avoid such loops.
It has a manual mechanism called Hint Cut
Is it my responsibility to set [...] flags appropriately in the code base to make sure no loops happen?
Generally, yes
If so, do you have a systematic approach to convince yourself that a codebase is typeclass-search-loop free?
Write out the typeclass hint graph and make sure it's a dag?
Or is this a Coq bug?
What's the typeclass debug log? It's probably not a bug, but we need to see the log to be sure.
from bedrock2.
It has a manual mechanism called
Hint Cut
That only allows regular expressions to match branches to cut, but I'd like to cut all branches with a duplicate hint, but I guess that's not expressible as a regex.
Write out the typeclass hint graph and make sure it's a dag?
The way we were intending to use parameter records keeps creating situations where it's not a DAG. Here's an example:
Module Semantics.
Class parameters := {}.
End Semantics.
Module Lib1.
Class parameters := {
foo: nat;
semantics_params :> Semantics.parameters;
}.
End Lib1.
Module SubprojectWithFooEqual42.
Module CommonDefinitions.
Instance make_Lib1_params{p: Semantics.parameters}: Lib1.parameters := {
foo := 42;
semantics_params := p;
}.
End CommonDefinitions.
Module File1.
Section WithParams.
Context {p: Semantics.parameters}.
(* use definitions of Lib1... *)
End WithParams.
End File1.
Module File2.
Section WithParams.
Context {p: Semantics.parameters}.
(* use definitions of Lib1... *)
End WithParams.
End File2.
Module File3.
Section OoopsForgotToRequireParameters.
Fail Timeout 1 Check (_ : Semantics.parameters).
End OoopsForgotToRequireParameters.
End File3.
End SubprojectWithFooEqual42.
To break the loop, we'd have to stop sharing parameter record transformer instances like make_Lib1_params
, and each file would have to redeclare all of them. This would lead to boilerplate explosion and even more syntactically mismatching implicit arguments. Or is there a better way to do parameter records in this example?
from bedrock2.
I guess make_Lib1_params
could be a Definition
, and then I'd do Existing Instance make_Lib1_params
in each section, but still not so thrilled by it ...
from bedrock2.
Or maybe we should just ban :>
inside typeclass definitions, and instead of doing tc_field :> T
, do Existing Instance tc_field
but only inside sections. This would require a series of Existing Instance
lines at the beginning of each section, but would maintain the invariant that Require
ing a file never adds parameter record projections as typeclass hints, so in order to know all parameter record projections in the typeclass hints, it suffices to look at all Existing Instance
commands of the current section.
And since in this setting, a loop always contains at least one projection, the local list of Existing Instance
could serve as a starting point for checking for loops.
from bedrock2.
On the other hand, one benefit of parameter records is that if several files take the same n
arguments, we only need to spell them out once in the definition of a parameter record, instead of spelling them out at the beginning of each file, but if we require an Existing Instance
command for each field which itself is a typeclass, that benefit is gone.
from bedrock2.
This is the part that seems wrong/surprising to me. It'd be great if we got coqdev advice on whether this is intended and/or how to avoid it.
See coq/coq#14707
from bedrock2.
Related Issues (20)
- Platform HOT 4
- predicates describing bytes in memory HOT 3
- Best practice for proving loop termination in firmware? HOT 22
- Missing operators HOT 1
- Makefile doesn't work with EXTERNAL_DEPENDENCIES=1 HOT 4
- bedrock1 CPS semantics vs bedrock2 postcondition semantics HOT 1
- Test suite for ToCString HOT 1
- Move MMIO.v HOT 3
- stackloop: `main` should return `int`, not `void` HOT 1
- Using multiple return values HOT 2
- Why does bedrock2 use `Load`? HOT 2
- Please create a tag for Coq 8.16 in Coq Platform 2022.09 HOT 6
- bedrock2 fails with a syntax error on Windows HOT 9
- bedrock2 lightbulb example is incompatible with native_compute HOT 5
- Less Memory-Hungry, More Principled Solution for Decidable Side-Conditions HOT 2
- Failing in coq CI HOT 1
- `make` should not run `coq` and `cc` when there's nothing to be done
- Update tested is failing with rate limits HOT 2
- Bedrock2 is broken on Coq's CI HOT 1
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 bedrock2.