let pp_ntactic ~map_unicode_to_tex = function
| NApply (_,t) -> "napply " ^ CicNotationPp.pp_term t
+ | NCase1 (_,n) -> "*" ^ n ^ ":"
| NChange (_,what,wwhat) -> "nchange " ^ assert false ^
" with " ^ CicNotationPp.pp_term wwhat
| NElim (_,what,where) -> "nelim " ^ CicNotationPp.pp_term what ^
assert false ^ " " ^ assert false
| NId _ -> "nid"
- | NIntro (_,n) -> n
+ | NIntro (_,n) -> "#" ^ n
;;
let rec pp_tactic ~map_unicode_to_tex ~term_pp ~lazy_term_pp =
let eval_ng_tac (text, prefix_len, tac) =
match tac with
| GrafiteAst.NApply (_loc, t) -> NTactics.apply_tac (text,prefix_len,t)
+ | GrafiteAst.NCase1 (_loc,n) -> NTactics.case1_tac n
| GrafiteAst.NChange (_loc, pat, ww) ->
NTactics.change_tac
~where:(text,prefix_len,pat) ~with_what:(text,prefix_len,ww)
None, ctx, ty
;;
+let whd status ?delta where t =
+ let _,_,metasenv,subst,_ = status.pstatus in
+ let ctx = match where with `Ctx c -> c | `Term (_,c,_) -> c in
+ let _,_,t = relocate ctx t in
+ let t = NCicReduction.whd ~subst ?delta ctx t in
+ None, ctx, t
+;;
+
let unify status where a b =
let n,h,metasenv,subst,o = status.pstatus in
let ctx = match where with `Ctx c -> c | `Term (_,c,_) -> c in
exact_tac
("",0,(CicNotationPt.Binder (`Lambda,
(CicNotationPt.Ident (name,None),None),CicNotationPt.Implicit)))
-;;
+;;
+
+let case status goal =
+ let _,ctx,_ = get_goal status goal in
+ let ty = typeof status (`Ctx ctx) ("",ctx,NCic.Rel 1) in
+ let ref =
+ match whd status (`Ctx ctx) ty with
+ _,_,NCic.Const ref
+ | _,_,NCic.Appl (NCic.Const ref :: _) -> ref
+ | _,_,_ -> fail (lazy ("not an inductive type")) in
+ let _,_,tl,_,i = NCicEnvironment.get_checked_indtys ref in
+ let _,_,_,cl = List.nth tl i in
+ let consno = List.length cl in
+ let t =
+ NCic.Match (ref,NCic.Implicit `Term,NCic.Rel 1,HExtlib.mk_list (NCic.Implicit `Term) consno)
+ in
+ let status,t,ty = refine status (`Ctx ctx) ("",ctx,t) None in
+ instantiate status goal t
+;;
+
+let case_tac = distribute_tac case;;
+
+let case1_tac name =
+ block_tac [ intro_tac name; case_tac ]
+;;
axiom a: A.
axiom b: B.
+include "logic/connectives.ma".
notation "#" non associative with precedence 90 for @{ 'sharp }.
interpretation "a" 'sharp = a.
interpretation "b" 'sharp = b.
-ntheorem prova : ((A â\86\92 A → B) → (A → B) → C) → C.
+ntheorem prova : ((A â\88§ A → B) → (A → B) → C) → C.
# H;
-napply (H ? ?) [#L | #K1; #K2]
+napply (H ? ?) [#L | *w; #K1; #K2]
napply #.
nqed.
\ No newline at end of file