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
|
|
|
|
import init.datatypes init.reserved_notation
|
|
|
|
|
|
|
|
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
|
2014-09-19 20:44:44 +00:00
|
|
|
opaque definition and_then (t1 t2 : tactic) : tactic := builtin
|
|
|
|
opaque definition or_else (t1 t2 : tactic) : tactic := builtin
|
|
|
|
opaque definition append (t1 t2 : tactic) : tactic := builtin
|
|
|
|
opaque definition interleave (t1 t2 : tactic) : tactic := builtin
|
|
|
|
opaque definition par (t1 t2 : tactic) : tactic := builtin
|
|
|
|
opaque definition fixpoint (f : tactic → tactic) : tactic := builtin
|
|
|
|
opaque definition repeat (t : tactic) : tactic := builtin
|
|
|
|
opaque definition at_most (t : tactic) (k : num) : tactic := builtin
|
|
|
|
opaque definition discard (t : tactic) (k : num) : tactic := builtin
|
|
|
|
opaque definition focus_at (t : tactic) (i : num) : tactic := builtin
|
|
|
|
opaque definition try_for (t : tactic) (ms : num) : tactic := builtin
|
|
|
|
opaque definition now : tactic := builtin
|
|
|
|
opaque definition assumption : tactic := builtin
|
|
|
|
opaque definition eassumption : tactic := builtin
|
|
|
|
opaque definition state : tactic := builtin
|
|
|
|
opaque definition fail : tactic := builtin
|
|
|
|
opaque definition id : tactic := builtin
|
|
|
|
opaque definition beta : tactic := builtin
|
2014-10-23 20:18:30 +00:00
|
|
|
opaque definition info : tactic := builtin
|
2014-10-29 06:18:49 +00:00
|
|
|
opaque definition whnf : tactic := builtin
|
2014-10-30 02:13:55 +00:00
|
|
|
opaque definition rotate_left (k : num) := builtin
|
|
|
|
opaque definition rotate_right (k : num) := builtin
|
|
|
|
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-11-26 22:49:48 +00:00
|
|
|
opaque definition apply (e : expr) : tactic := builtin
|
|
|
|
opaque definition rapply (e : expr) : tactic := builtin
|
2014-11-30 03:20:41 +00:00
|
|
|
opaque definition fapply (e : expr) : tactic := builtin
|
2014-11-26 22:49:48 +00:00
|
|
|
opaque definition rename (a b : expr) : tactic := builtin
|
|
|
|
opaque definition intro (e : expr) : tactic := builtin
|
|
|
|
opaque definition generalize (e : expr) : tactic := builtin
|
|
|
|
opaque definition clear (e : expr) : tactic := builtin
|
|
|
|
opaque definition revert (e : expr) : tactic := builtin
|
|
|
|
opaque definition unfold (e : expr) : tactic := builtin
|
|
|
|
opaque definition exact (e : expr) : tactic := builtin
|
|
|
|
opaque definition trace (s : string) : tactic := builtin
|
2014-11-29 06:25:37 +00:00
|
|
|
opaque definition inversion (id : expr) : tactic := builtin
|
2014-10-22 23:15:00 +00:00
|
|
|
|
2014-11-30 05:03:45 +00:00
|
|
|
notation a `↦` b:max := rename a b
|
2014-11-27 03:02:11 +00:00
|
|
|
|
2014-10-22 23:15:00 +00:00
|
|
|
inductive expr_list : Type :=
|
|
|
|
nil : expr_list,
|
|
|
|
cons : expr → expr_list → expr_list
|
|
|
|
|
2014-11-29 06:25:37 +00:00
|
|
|
opaque definition inversion_with (id : expr) (ids : expr_list) : tactic := builtin
|
2014-11-30 05:03:45 +00:00
|
|
|
notation `cases` a:max := inversion a
|
|
|
|
notation `cases` a:max `with` `(` l:(foldr `,` (h t, expr_list.cons h t) expr_list.nil) `)` := inversion_with a l
|
2014-11-29 06:25:37 +00:00
|
|
|
|
|
|
|
opaque definition intro_lst (ids : expr_list) : tactic := builtin
|
2014-11-26 22:49:48 +00:00
|
|
|
notation `intros` := intro_lst expr_list.nil
|
|
|
|
notation `intros` `(` l:(foldr `,` (h t, expr_list.cons h t) expr_list.nil) `)` := intro_lst l
|
2014-10-22 22:18:43 +00:00
|
|
|
|
2014-11-26 22:49:48 +00:00
|
|
|
opaque definition generalize_lst (es : expr_list) : tactic := builtin
|
|
|
|
notation `generalizes` `(` l:(foldr `,` (h t, expr_list.cons h t) expr_list.nil) `)` := generalize_lst l
|
2014-11-23 22:39:35 +00:00
|
|
|
|
2014-11-29 06:25:37 +00:00
|
|
|
opaque definition clear_lst (ids : expr_list) : tactic := builtin
|
2014-11-26 22:49:48 +00:00
|
|
|
notation `clears` `(` l:(foldr `,` (h t, expr_list.cons h t) expr_list.nil) `)` := clear_lst l
|
|
|
|
|
2014-11-29 06:25:37 +00:00
|
|
|
opaque definition revert_lst (ids : expr_list) : tactic := builtin
|
2014-11-26 22:49:48 +00:00
|
|
|
notation `reverts` `(` l:(foldr `,` (h t, expr_list.cons h t) expr_list.nil) `)` := revert_lst l
|
2014-11-23 22:39:35 +00:00
|
|
|
|
2014-11-30 05:34:26 +00:00
|
|
|
opaque definition assert_hypothesis (id : expr) (e : expr) : tactic := builtin
|
|
|
|
notation `assert` `(` id `:` ty `)` := assert_hypothesis id ty
|
|
|
|
|
2014-10-21 00:10:16 +00:00
|
|
|
infixl `;`:15 := and_then
|
2014-11-30 02:29:48 +00:00
|
|
|
notation `[` h:10 `|`:10 r:(foldl:10 `|` (e r, or_else r e) h) `]` := r
|
2014-11-26 22:49:48 +00:00
|
|
|
|
2014-10-21 00:10:16 +00:00
|
|
|
definition try (t : tactic) : tactic := [t | id]
|
|
|
|
definition repeat1 (t : tactic) : tactic := 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
|
2014-08-20 02:32:44 +00:00
|
|
|
|
2014-08-07 23:59:08 +00:00
|
|
|
end tactic
|