2014-12-01 04:34:12 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
|
|
|
|
This is just a trick to embed the 'tactic language' as a Lean
|
|
|
|
expression. We should view 'tactic' as automation that when execute
|
|
|
|
produces a term. tactic.builtin is just a "dummy" for creating the
|
|
|
|
definitions that are actually implemented in C++
|
|
|
|
-/
|
|
|
|
prelude
|
2015-03-03 21:37:38 +00:00
|
|
|
import init.datatypes init.reserved_notation init.num
|
2014-12-01 04:34:12 +00:00
|
|
|
|
|
|
|
inductive tactic :
|
|
|
|
Type := builtin : tactic
|
2014-09-04 23:36:06 +00:00
|
|
|
|
|
|
|
namespace tactic
|
2014-07-02 02:05:22 +00:00
|
|
|
-- Remark the following names are not arbitrary, the tactic module
|
|
|
|
-- uses them when converting Lean expressions into actual tactic objects.
|
|
|
|
-- The bultin 'by' construct triggers the process of converting a
|
2014-07-02 14:08:20 +00:00
|
|
|
-- a term of type 'tactic' into a tactic that sythesizes a term
|
2015-05-08 22:01:09 +00:00
|
|
|
definition and_then (t1 t2 : tactic) : tactic := builtin
|
|
|
|
definition or_else (t1 t2 : tactic) : tactic := builtin
|
|
|
|
definition append (t1 t2 : tactic) : tactic := builtin
|
|
|
|
definition interleave (t1 t2 : tactic) : tactic := builtin
|
|
|
|
definition par (t1 t2 : tactic) : tactic := builtin
|
|
|
|
definition fixpoint (f : tactic → tactic) : tactic := builtin
|
|
|
|
definition repeat (t : tactic) : tactic := builtin
|
|
|
|
definition at_most (t : tactic) (k : num) : tactic := builtin
|
|
|
|
definition discard (t : tactic) (k : num) : tactic := builtin
|
|
|
|
definition focus_at (t : tactic) (i : num) : tactic := builtin
|
|
|
|
definition try_for (t : tactic) (ms : num) : tactic := builtin
|
|
|
|
definition all_goals (t : tactic) : tactic := builtin
|
|
|
|
definition now : tactic := builtin
|
|
|
|
definition assumption : tactic := builtin
|
|
|
|
definition eassumption : tactic := builtin
|
|
|
|
definition state : tactic := builtin
|
|
|
|
definition fail : tactic := builtin
|
|
|
|
definition id : tactic := builtin
|
|
|
|
definition beta : tactic := builtin
|
|
|
|
definition info : tactic := builtin
|
|
|
|
definition whnf : tactic := builtin
|
|
|
|
definition contradiction : tactic := builtin
|
|
|
|
definition exfalso : tactic := builtin
|
|
|
|
definition congruence : tactic := builtin
|
|
|
|
definition rotate_left (k : num) := builtin
|
|
|
|
definition rotate_right (k : num) := builtin
|
2014-10-30 02:13:55 +00:00
|
|
|
definition rotate (k : num) := rotate_left k
|
2014-10-22 22:18:43 +00:00
|
|
|
|
|
|
|
-- This is just a trick to embed expressions into tactics.
|
|
|
|
-- The nested expressions are "raw". They tactic should
|
|
|
|
-- elaborate them when it is executed.
|
|
|
|
inductive expr : Type :=
|
|
|
|
builtin : expr
|
|
|
|
|
2014-10-22 23:15:00 +00:00
|
|
|
inductive expr_list : Type :=
|
2015-02-26 01:00:10 +00:00
|
|
|
| nil : expr_list
|
|
|
|
| cons : expr → expr_list → expr_list
|
2014-10-22 23:15:00 +00:00
|
|
|
|
2015-03-06 02:07:06 +00:00
|
|
|
-- auxiliary type used to mark optional list of arguments
|
|
|
|
definition opt_expr_list := expr_list
|
|
|
|
|
2015-05-13 03:20:33 +00:00
|
|
|
-- auxiliary types used to mark that the expression is suppose to be an identifier, optional, or a list.
|
2015-04-22 23:03:22 +00:00
|
|
|
definition identifier := expr
|
|
|
|
definition identifier_list := expr_list
|
|
|
|
definition opt_identifier_list := expr_list
|
|
|
|
|
2015-05-18 16:25:07 +00:00
|
|
|
-- Marker for instructing the parser to parse it as '?(using <expr>)'
|
|
|
|
definition using_expr := expr
|
|
|
|
-- Constant used to denote the case were no expression was provided
|
|
|
|
definition none_expr : expr := expr.builtin
|
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition apply (e : expr) : tactic := builtin
|
|
|
|
definition eapply (e : expr) : tactic := builtin
|
|
|
|
definition fapply (e : expr) : tactic := builtin
|
|
|
|
definition rename (a b : identifier) : tactic := builtin
|
|
|
|
definition intro (e : identifier_list) : tactic := builtin
|
|
|
|
definition generalize_tac (e : expr) (id : identifier) : tactic := builtin
|
|
|
|
definition clear (e : identifier_list) : tactic := builtin
|
|
|
|
definition revert (e : identifier_list) : tactic := builtin
|
|
|
|
definition refine (e : expr) : tactic := builtin
|
|
|
|
definition exact (e : expr) : tactic := builtin
|
2015-04-22 23:03:22 +00:00
|
|
|
-- Relaxed version of exact that does not enforce goal type
|
2015-05-08 22:01:09 +00:00
|
|
|
definition rexact (e : expr) : tactic := builtin
|
|
|
|
definition check_expr (e : expr) : tactic := builtin
|
|
|
|
definition trace (s : string) : tactic := builtin
|
2015-04-22 23:03:22 +00:00
|
|
|
|
2015-02-03 03:20:24 +00:00
|
|
|
-- rewrite_tac is just a marker for the builtin 'rewrite' notation
|
|
|
|
-- used to create instances of this tactic.
|
2015-05-27 23:32:43 +00:00
|
|
|
definition rewrite_tac (e : expr_list) : tactic := builtin
|
|
|
|
definition xrewrite_tac (e : expr_list) : tactic := builtin
|
|
|
|
definition krewrite_tac (e : expr_list) : tactic := builtin
|
2015-02-03 03:20:24 +00:00
|
|
|
|
2015-05-31 04:57:28 +00:00
|
|
|
definition cases (h : expr) (ids : opt_identifier_list) : tactic := builtin
|
2014-11-29 06:25:37 +00:00
|
|
|
|
2015-05-31 04:57:28 +00:00
|
|
|
definition induction (h : expr) (rec : using_expr) (ids : opt_identifier_list) : tactic := builtin
|
2015-05-13 03:20:33 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition intros (ids : opt_identifier_list) : tactic := builtin
|
2014-10-22 22:18:43 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition generalizes (es : expr_list) : tactic := builtin
|
2014-11-23 22:39:35 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition clears (ids : identifier_list) : tactic := builtin
|
2014-11-26 22:49:48 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition reverts (ids : identifier_list) : tactic := builtin
|
2014-11-23 22:39:35 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition change (e : expr) : tactic := builtin
|
2015-03-01 22:15:23 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition assert_hypothesis (id : identifier) (e : expr) : tactic := builtin
|
2014-11-30 05:34:26 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition lettac (id : identifier) (e : expr) : tactic := builtin
|
2015-04-29 00:20:39 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition constructor (k : option num) : tactic := builtin
|
|
|
|
definition existsi (e : expr) : tactic := builtin
|
|
|
|
definition split : tactic := builtin
|
|
|
|
definition left : tactic := builtin
|
|
|
|
definition right : tactic := builtin
|
2015-05-01 00:52:29 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition injection (e : expr) (ids : opt_identifier_list) : tactic := builtin
|
2015-05-01 19:45:21 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition subst (ids : identifier_list) : tactic := builtin
|
2015-05-25 22:44:22 +00:00
|
|
|
definition substvars : tactic := builtin
|
2015-05-02 02:31:24 +00:00
|
|
|
|
2015-05-08 22:01:09 +00:00
|
|
|
definition reflexivity : tactic := builtin
|
|
|
|
definition symmetry : tactic := builtin
|
|
|
|
definition transitivity (e : expr) : tactic := builtin
|
2015-05-02 22:48:25 +00:00
|
|
|
|
2015-04-28 00:46:13 +00:00
|
|
|
definition try (t : tactic) : tactic := or_else t id
|
|
|
|
definition repeat1 (t : tactic) : tactic := and_then t (repeat t)
|
2014-07-03 19:59:48 +00:00
|
|
|
definition focus (t : tactic) : tactic := focus_at t 0
|
|
|
|
definition determ (t : tactic) : tactic := at_most t 1
|
2015-04-28 00:46:13 +00:00
|
|
|
definition trivial : tactic := or_else (or_else (apply eq.refl) (apply true.intro)) assumption
|
2015-03-03 21:37:38 +00:00
|
|
|
definition do (n : num) (t : tactic) : tactic :=
|
2015-04-28 00:46:13 +00:00
|
|
|
nat.rec id (λn t', and_then t t') (nat.of_num n)
|
2014-08-07 23:59:08 +00:00
|
|
|
end tactic
|
2015-04-28 00:46:13 +00:00
|
|
|
tactic_infixl `;`:15 := tactic.and_then
|
|
|
|
tactic_notation `(` h `|` r:(foldl `|` (e r, tactic.or_else r e) h) `)` := r
|