1***************************
2Tactics and Theorem Proving
3***************************
5Idris supports interactive theorem proving, and the analyse of context
6through holes. To list all unproven holes, use the command ``:m``.
7This will display their qualified names and the expected types. To
8interactively prove a holes, use the command ``:p name`` where ``name``
9is the hole. Once the proof is complete, the command ``:a`` will append
10it to the current module.
12Once in the interactive prover, the following commands are available:
17- ``:q`` - Quits the prover (gives up on proving current lemma).
18- ``abandon`` - Same as :q
19- ``state`` - Displays the current state of the proof.
20- ``term`` - Displays the current proof term complete with its
21 yet-to-be-filled holes (is only really useful for debugging).
22- ``undo`` - Undoes the last tactic.
23- ``qed`` - Once the interactive theorem prover tells you "No more
24 goals," you get to type this in celebration! (Completes the proof and
33- ``compute`` - Normalizes all terms in the goal (note: does not
34 normalize assumptions)
38 ---------- Goal: ----------
39 (Vect (S (S Z + (S Z) + (S n))) Nat) -> Vect (S (S (S (S n)))) Nat
41 ---------- Goal: ----------
42 (Vect (S (S (S (S n)))) Nat) -> Vect (S (S (S (S n)))) Nat
48- ``exact`` - Provide a term of the goal type directly.
52 ---------- Goal: ----------
61- ``refine`` - Use a name to refine the goal. If the name needs
62 arguments, introduce them as new goals.
67- ``trivial`` - Satisfies the goal using an assumption that matches its
72 ---------- Assumptions: ----------
74 ---------- Goal: ----------
83- ``intro`` - If your goal is an arrow, turns the left term into an
88 ---------- Goal: ----------
91 ---------- Assumptions: ----------
93 ---------- Goal: ----------
97You can also supply your own name for the assumption:
101 ---------- Goal: ----------
104 ---------- Assumptions: ----------
106 ---------- Goal: ----------
113- ``intros`` - Exactly like intro, but it operates on all left terms at
118 ---------- Goal: ----------
121 ---------- Assumptions: ----------
124 ---------- Goal: ----------
131- ``let`` - Introduces a new assumption; you may use current
132 assumptions to define the new one.
136 ---------- Assumptions: ----------
138 ---------- Goal: ----------
140 -lemma> let x = toIntegerNat n
141 ---------- Assumptions: ----------
143 x = toIntegerNat n: BigInt
144 ---------- Goal: ----------
151- ``rewrite`` - Takes an expression with an equality type (x = y), and
152 replaces all instances of x in the goal with y. Is often useful in
153 combination with 'sym'.
157 ---------- Assumptions: ----------
161 ---------- Goal: ----------
163 -lemma> rewrite sym (multZeroRightZero n)
164 ---------- Assumptions: ----------
168 ---------- Goal: ----------
175- ``induction`` - (``Note that this is still experimental`` and you may
176 get strange results and error messages. We are aware of these and
177 will finish the implementation eventually!) Prove the goal by
178 induction. Each constructor of the datatype becomes a goal.
179 Constructors with recursive arguments become induction steps, while
180 simple constructors become base cases. Note that this only works for
181 datatypes that have eliminators: a datatype definition must have the
188- ``sourceLocation`` - Solve the current goal with information about
189 the location in the source code where the tactic was invoked. This is
190 mostly for embedded DSLs and programmer tools like assertions that
191 need to know where they are called. See
192 ``Language.Reflection.SourceLocation`` for more information.
194Less commonly-used tactics
195==========================
197- ``applyTactic`` - Apply a user-defined tactic. This should be a
198 function of type ``List (TTName, Binder TT) -> TT -> Tactic``, where
199 the first argument represents the proof context and the second
200 represents the goal. If your tactic will produce a proof term
201 directly, use the ``Exact`` constructor from ``Tactic``.
203- ``equiv`` - Replaces the goal with a new one that is convertible with
207- ``mrefine`` - Refining by matching against a type
209- ``solve`` - Takes a guess with the correct type and fills a hole with
210 it, closing a proof obligation. This happens automatically in the
211 interactive prover, so ``solve`` is really only relevant in tactic
212 scripts used for helping implicit argument resolution.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list