agda-stdlib icon indicating copy to clipboard operation
agda-stdlib copied to clipboard

Runtime irrelevance

Open kurnevsky opened this issue 1 year ago • 7 comments

Hi. I'm trying to use erased annotations but as I can see agda stdlib doesn't really support them. What I stumbled upon so far:

  • ⊥-elim can't take an erased argument which is often needed when all proofs are erased.
  • Idris defines Σ variants with erased first and second values called Exists and Subset which are also quite convenient to erase proofs.

Here is an example.

Should maybe agda stdlib have something similar? That would require agda stdlib to have --erasure option enabled which requires all dependent modules to have it.

kurnevsky avatar Sep 26 '24 22:09 kurnevsky

See #2346 for an earlier version of a similar line of thought... I'd be broadly in favour, but for the complicated balance of forces/compatibility issues (esp. wrt infective options) involved in what constitutes a 'standard' library.

jamesmckinna avatar Sep 28 '24 07:09 jamesmckinna

Note that you can implement

recover : @0 ⊥ → ⊥
recover ()

so you can plug your contradiction into a call to ⊥-elim.

gallais avatar Sep 30 '24 09:09 gallais

Cf. Relation.Nullary.Recomputable.⊥-recompute... ob @gallais 's observation, while your other examples from Idris seem to be related to the other combinators defined there...?

jamesmckinna avatar Sep 30 '24 10:09 jamesmckinna

while your other examples from Idris seem to be related to the other combinators defined there...?

Is it a question to me? :) I meant that it's sometimes useful to have dependent sum types with erased first/second values, and Idris has them. For instance, using my own definition of such type gave me almost 2x speed up in runtime for my code :)

kurnevsky avatar Sep 30 '24 11:09 kurnevsky

See also: Data.Refinement for a version of "dependent sum types with erased second values" at least. Agree that erased first projections are independently interesting, though...

jamesmckinna avatar Oct 03 '24 12:10 jamesmckinna

There's also the issue of Irrelevant vs. @0 annotation. I don't think we have anything @0-related in the lib at the minute.

gallais avatar Oct 03 '24 13:10 gallais

There's also the issue of Irrelevant vs. @0 annotation. I don't think we have anything @0-related in the lib at the minute.

Absolutely! I raised this explicitly as a point for us to discuss after the merge of experimental following the v2.7.0 release...

jamesmckinna avatar Oct 03 '24 13:10 jamesmckinna