]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_tactics/nTactics.ml
added tentative elim
[helm.git] / helm / software / components / ng_tactics / nTactics.ml
index 0c5f5360c5ef579fa75851dbbbcea576298047a6..2521498ba8f71115d0cb44638bed8be6051f226f 100644 (file)
@@ -198,7 +198,7 @@ let compare_statuses ~past ~present =
    (e.g. the tactic could perform a global analysis of the set of goals)
 *)
 
-let exec tac (low_status,g) =
+let exec tac low_status g =
   let stack = [ [0,Open g], [], [], `NoTag ] in
   let status = tac { gstatus = stack ; istatus = low_status } in
    status.istatus
@@ -427,6 +427,20 @@ let select_term low_status (name,context,term) (wanted,path) =
   mk_meta status ~name:out_scope_tag (`Ctx context) (`Def term)
 ;;
 
+let select ~where status goal = 
+ let name, _, _ as goalty = get_goal status goal in
+ let (wanted,_,where) = GrafiteDisambiguate.disambiguate_npattern where in
+ let path = 
+   match where with None -> NCic.Implicit `Term | Some where -> where 
+ in
+ let status, newgoalty = select_term status goalty (wanted,path) in
+ let status, instance = 
+   mk_meta status ?name (`Term newgoalty) (`Decl newgoalty) 
+ in
+ instantiate status goal instance
+;;
+
+let select_tac ~where = distribute_tac (select ~where) ;;
 
 let exact t status goal =
  let goalty = get_goal status goal in
@@ -434,7 +448,6 @@ let exact t status goal =
  instantiate status goal t
 ;;
 
-
 let reopen status =
  let n,h,metasenv,subst,o = status.pstatus in
  let subst, newm = 
@@ -477,21 +490,29 @@ let change ~where ~with_what status goal =
  instantiate status goal instance
 ;;
 
-let apply t status goal =
- let uri,height,metasenv, subst,obj = status.pstatus in
- let name,context,gty = List.assoc goal metasenv in
- let metasenv, subst, lexicon_status, t = 
-   GrafiteDisambiguate.disambiguate_nterm (Some gty) 
-    status.lstatus context metasenv subst t 
- in
- let subst, metasenv = 
-   (goal, (name, context, t, gty)):: subst,
-   List.filter(fun (x,_) -> x <> goal) metasenv
- in
- let new_pstatus = uri,height,metasenv,subst,obj in
- { lstatus = lexicon_status; pstatus = new_pstatus }
-;;
+let apply t status goal = exact t status goal;;
 
 let apply_tac t = distribute_tac (apply t) ;;
 let change_tac ~where ~with_what = distribute_tac (change ~where ~with_what) ;;
 
+let elim_tac ~what ~where status =
+ block_tac
+   [ select_tac ~where;
+     distribute_tac (fun status goal ->
+       let goalty = get_goal status goal in
+       let status, (_,_,w as what) = 
+         disambiguate status what None (`Term goalty) in
+       let _ty_what = typeof status (`Term what) what in 
+       (* check inductive... find eliminator *)
+       let w = (*astify what *) CicNotationPt.Ident ("m",None) in
+       let holes = [ 
+         CicNotationPt.Implicit;CicNotationPt.Implicit;CicNotationPt.Implicit]
+       in
+       let eliminator = 
+         CicNotationPt.Appl(CicNotationPt.Ident("nat_ind",None)::holes @ [ w ])
+       in
+       exec (apply_tac ("",0,eliminator)) status goal) ] 
+   status
+;;
+
+