If I understand it correctly (mainly from existence of the applyTactic
function), it is possible to write custom tactics for the theorem prover in Idris. What (or where) are some examples I could use for learning how to do that?

- 3,856
- 4
- 35
- 44
-
2I don't know anything about how to write it and use, but I've seen recently [an example of custom tactic](https://github.com/idris-lang/Idris-dev/blob/master/libs/base/Data/Vect.idr#L18-L22) and [an example of it's usage](https://github.com/idris-lang/Idris-dev/blob/master/libs/base/Data/HVect.idr#L57). Hope this will help. – laughedelic Apr 14 '14 at 23:42
-
2The above links are no longer valid because they refer to the HEAD of the repo. Please see here instead: [first](https://github.com/idris-lang/Idris-dev/blob/10ef56b8c1629347ab213e97bfff551ee27e11d0/libs/base/Data/Vect.idr#L18-L22), [second](https://github.com/idris-lang/Idris-dev/blob/fb6a0ed1ad5e3acc3795d7ab674977bdb419129a/libs/base/Data/HVect.idr#L57) – max taldykin Jul 25 '14 at 09:31
1 Answers
There are two mechanisms for writing custom tactics in Idris: high-level and low-level reflection.
Using high-level reflection, you write a function that runs on syntax rather than on evaluated data - it won't reduce its argument. These functions return a new tactic, defined using the pre-existing tactics in Idris. If you want to return a proof term directly, you can always just use Exact
. An example of this kind of reflection can be found in the effects library. High-level reflection tactics are invoked using byReflection
in proof mode.
In low-level reflection, you work directly with quoted terms from Idris's core type theory. A tactic is then a function in TT -> List (TTName, TT) -> Tactic
where the first argument is the goal type, the second is the local proof context, and the return result is the same as in high-level reflection. This is what laughadelic linked to above. These are invoked using applyTactic
in proof mode.

- 2,267
- 1
- 18
- 9