fix(library/tools/tactic): 'cases' argument precedence

This commit is contained in:
Leonardo de Moura 2014-11-29 21:03:45 -08:00
parent f51fa93292
commit 1a7dd56f0f
2 changed files with 27 additions and 4 deletions

View file

@ -3,7 +3,7 @@
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Author: Leonardo de Moura
----------------------------------------------------------------------------------------------------
import data.string.decl data.num.decl
import data.string.decl data.num.decl general_notation
-- 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.
@ -60,15 +60,15 @@ opaque definition exact (e : expr) : tactic := builtin
opaque definition trace (s : string) : tactic := builtin
opaque definition inversion (id : expr) : tactic := builtin
notation a `↦` b := rename a b
notation a `↦` b:max := rename a b
inductive expr_list : Type :=
nil : expr_list,
cons : expr → expr_list → expr_list
opaque definition inversion_with (id : expr) (ids : expr_list) : tactic := builtin
notation `cases` a := inversion a
notation `cases` a `with` `(` l:(foldr `,` (h t, expr_list.cons h t) expr_list.nil) `)` := inversion_with a l
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
opaque definition intro_lst (ids : expr_list) : tactic := builtin
notation `intros` := intro_lst expr_list.nil

View file

@ -0,0 +1,23 @@
import data.nat.basic data.empty data.prod
open nat eq.ops prod
inductive vector (T : Type) : → Type :=
nil {} : vector T 0,
cons : T → ∀{n}, vector T n → vector T (succ n)
set_option pp.metavar_args true
set_option pp.implicit true
set_option pp.notation false
namespace vector
variables {A B C : Type}
variables {n m : nat}
theorem z_cases_on {C : vector A 0 → Type} (v : vector A 0) (Hnil : C nil) : C v :=
by cases v; apply Hnil
protected definition destruct (v : vector A (succ n)) {P : Π {n : nat}, vector A (succ n) → Type}
(H : Π {n : nat} (h : A) (t : vector A n), P (cons h t)) : P v :=
by cases v with (h', n', t'); apply (H h' t')
end vector