Comments (5)
If we don't have
--save-metas
, then none ofbs
,sigRewriteRules
anddisp
are instantiated and traversed for reachability. Hence, the metas which only occur in these will be eliminated, and should become dangling in the interface. As I see now, the only way this could work correctly in practice is if the mentioned things are already fully instantiated (which may well be the case in the current codebase).
Perhaps @UlfNorell knows why this is supposed to work.
Also,
sigSections
looks puzzling inrootMetas
. The public sections are already traversed for reachability, inreachableFrom
. This leaves the non-public sections here as additionally traversed, but I don't understand why the metas there should be roots.
@andreasabel seems to have done some work on this recently (d12ad84).
from agda.
The rootMetas
was added by @nad in b52a21d when --save-metas
was added. I don't know why those particular root sets where chosen. The basic specification should be straightforward though: don't delete things that may be referenced from a module importing this module, and delete everything else.
from agda.
After testing the current implementation a bit, I can point out more concrete problems:
- Rewrite rules and module parameters can cause crash.
- I could not produce a crash with display forms, but IMO they behave weirdly.
- Rewrite rules and pattern synonyms are never pruned, but they could be.
Rewrite rule crash. b
is eliminated but it's reachable through a rewrite rule.
-- A.agda
{-# OPTIONS --rewriting #-}
module A where
postulate Rel : ∀{i}{A : Set i}(x y : A) → Set
{-# BUILTIN REWRITE Rel #-}
postulate a : Set₁
private
b : Set₁
b = Set
postulate a~> : Rel a b
{-# REWRITE a~> #-}
-- B.agda
{-# OPTIONS --rewriting #-}
module B where
open import A
_ : a
_ = Set
Module param crash. P
is eliminated but it's reachable through M
.
-- A.agda
module A where
private P = Set₁
module M (x : P) where
-- B.agda
module B where
open import A
module M' = M Set
Display form behavior which I don't think is desirable:
-- A.agda
module A where
postulate a : Set
private postulate b : Set
c : Set
c = b
{-# DISPLAY a = b #-}
-- B.agda
module B where
open import A
_ : Set
_ = {!!}
Here, if I print the normal form of c
in the B.agda
hole, I get A.b
. But if I print the nf of a
, I get a
.
Based on the above, I have this proposal for liveness:
- Public definitions and pattern synonyms are alive.
- Any definition which is a primitive or has a COMPILE pragma is alive.
- Display forms whose LHS-es only contain live symbols are alive, and so are their RHS-es.
- Rewrite rules whose LHS-es only contain live symbols are alive, and so are their RHS-es.
- Parameters of public modules are alive.
Questions and comments:
- I don't think currently there is a way to detect whether a rewrite rule or a display pragma was defined in a private block. Is this correct? If there was a way, it would make sense to always consider "private" rewrites and displays dead.
- I don't understand this comment in Interaction/Imports.
from agda.
I realized that checking my previous liveness proposal is rather hard, and right now I don't know any efficient way to do it. The problem is the LHS liveness conditions plus the arbitrary mutual dependencies in rewrite rules and display forms.
The following looks efficiently decidable: we only pick a single LHS head symbol for each rewrite rule and display form. If the head symbol is alive, every other symbol involved in the rewrite/display is alive.
This can be checked by first building a map from symbols to lists of rewrites/displays, and in the next phase, when we traverse a symbol for reachability, we also traverse the rewrites/displays headed by the symbol.
from agda.
Discovered another issue while working on this: make std-lib-compiler-test
crashes with --save-metas
, apparently hitting a meta that's not defined anywhere.
from agda.
Related Issues (20)
- No warning about useless `{-# CATCHALL #-}` pragma
- HTML backend: inconsistent highlighting for macro names
- Internal error on pattern lambda with no clauses
- wrong type for unnamed record constructor
- Search for project root crashes when (parent) directory lacks permissions HOT 1
- quoteTerm loops on dependent copattern lambda HOT 3
- Caching loses reflection-generated pragmas
- Emacs: Support default value of `agda2-infer-type-maybe-toplevel` from type at point HOT 1
- Proof of ⊥ using HIT-indexed type HOT 6
- Literate programming Org/LaTeX feature request
- `--save-metas` causes internal error in `lookupMetaInstantiation` HOT 3
- Consider using `Set` instead of `nub`
- Mimer options `-l` and `-s` not covered by testsuite HOT 2
- The specification of `--safe` misses the pragmas
- MAlonzo bug: `unreachable code reached` HOT 9
- Our error messages do not follow the GNU standard HOT 4
- Agda 2.7.0-rc1 crashes when run twice, probably serialization issue HOT 3
- .cabal description "...: It ..." HOT 4
- Is pattern `AnnP` unused? (added in Oct 2020 as "not usable yet") HOT 2
- Pattern matching unifier does not preserve instances 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 agda.