Agda: Implicit arguments hard to find in interface

Created on 8 Jul 2016  ยท  4Comments  ยท  Source: agda/agda

Sometimes during pattern matching with a number of constructors, it becomes very difficult to know the source of a given implicit variable in order to make it explicit so that it can be referred to.

Currently if it is possible to pattern match on the variable, one can use C-c C-c to case split and then manually unsplit to use the variable, but if it is not possible there appears to be no way to find the source other than guessing based on Agda's algorithm for changing variable names which is time consuming.

Would it be possible to introduce a command that would take an implicit argument in the hole and introduce it explicitly on the lhs?

case-splitting hidden-arguments interaction enhancement

All 4 comments

Thanks for reporting! Can you please add a concrete case with

  • a short example and
  • the envisioned behavior of the new command for this example.

Thanks!

A completely contrived example which hopefully conveys the underlying feature request:

module FeatureExample where

infix 30 _โ‰ก_ 
data _โ‰ก_ {A : Set} : A โ†’ A โ†’ Set where
  refl : {x : A} โ†’ x โ‰ก x

data List (A : Set) : Set where
  [] : List A
  โˆท : {x : A} โ†’ {xs : List A} โ†’ List A

_++_ : โˆ€ {A : Set} โ†’ List A โ†’ List A โ†’ List A
[] ++ ys = ys
_++_ {A} (โˆท {x} {xs}) ys = โˆท {A} {x} {xs ++ ys}

++-comm : โˆ€ {A : Set} (xs ys zs : List A) โ†’ (xs ++ (ys ++ zs)) โ‰ก ((xs ++ ys) ++ zs)
++-comm [] ys zs = refl
++-comm โˆท [] zs = {!!}
++-comm โˆท โˆท [] = {!!}
++-comm โˆท โˆท โˆท = {! .xโ‚‚ !}  

In the final hole we have the following goal:

Goal: โˆท โ‰ก โˆท
โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”
.xsโ‚‚ : List .A
.xโ‚‚  : .A
.xsโ‚ : List .A
.xโ‚  : .A
.xs  : List .A
.x   : .A
.A   : Set

It's not so clear which constructor to augment to make a given implicit parameter, explicit, in order to refer to it.

Some Key sequence (C-c C-j ?) could potentially take the implicit parameter in the hole and transform it to:

++-comm : โˆ€ {A : Set} (xs ys zs : List A) โ†’ (xs ++ (ys ++ zs)) โ‰ก ((xs ++ ys) ++ zs)
++-comm [] ys zs = refl
++-comm โˆท [] zs = {!!}
++-comm โˆท โˆท [] = {!!}
++-comm โˆท โˆท (โˆท {_} {xโ‚‚}) = {! !} 

Thanks. A possibility would be to modify the case split command C-c C-c to not split on a hidden variable, but to bring it into scope. Then, one can split on it on a second invokation of C-c C-c. Seems more economic: the user has to remember less commands.

Thanks to @jespercockx 5e71c3d6bb10cfa43d464ca21e58523645f17e96, this was straightforward to implement.
@GavinMendelGleason , does this suit your needs?

Was this page helpful?
0 / 5 - 0 ratings