]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/grafite_engine/grafiteEngine.ml
ncopy partially implemented and fixed (a ?) chain to print elimintaors
[helm.git] / helm / software / components / grafite_engine / grafiteEngine.ml
index 6533e3f86397dbfc38b34a552a5b4880427ba0ef..3a108acccc5c079ee7e2426edf0d3490f60628c1 100644 (file)
@@ -956,6 +956,7 @@ let rec eval_ncommand opts status (text,prefix_len,cmd) =
         in
         let obj = uri,height,[],[],obj_kind in
          let status = NCicLibrary.add_obj status obj in
+       prerr_endline (NCicPp.ppobj obj);
          let objs = NCicElim.mk_elims obj in
          let timestamp,uris_rev =
            List.fold_left
@@ -965,6 +966,37 @@ let rec eval_ncommand opts status (text,prefix_len,cmd) =
             ) (status,[]) objs in
          let uris = uri::List.rev uris_rev in
           status#set_ng_mode `CommandMode,`New uris
+  | GrafiteAst.NCopy (log,tgt,src_uri, map) ->
+     if status#ng_mode <> `CommandMode then
+      raise (GrafiteTypes.Command_error "Not in command mode")
+     else
+       let tgt_uri_ext, old_ok = 
+         match NCicEnvironment.get_checked_obj src_uri with
+         | _,_,[],[], (NCic.Inductive _ as ok) -> ".ind", ok
+         | _,_,[],[], (NCic.Fixpoint _ as ok) -> ".con", ok
+         | _,_,[],[], (NCic.Constant _ as ok) -> ".con", ok
+         | _ -> assert false
+       in
+       let tgt_uri = NUri.uri_of_string (status#baseuri^"/"^tgt^tgt_uri_ext) in
+       let map = (src_uri, tgt_uri) :: map in
+       let ok = 
+         let rec subst () = function
+           | NCic.Meta _ -> assert false
+           | NCic.Const (NReference.Ref (u,spec)) as t ->
+               (try NCic.Const 
+                 (NReference.reference_of_spec (List.assoc u map)spec)
+               with Not_found -> t)
+           | t -> NCicUtils.map (fun _ _ -> ()) () subst t
+         in
+         NCicUntrusted.map_obj_kind ~skip_body:false (subst ()) old_ok
+       in
+       let ninitial_stack = Continuationals.Stack.of_nmetasenv [] in
+       let status = status#set_obj (tgt_uri,0,[],[],ok) in
+       prerr_endline (NCicPp.ppobj (tgt_uri,0,[],[],ok));
+       let status = status#set_stack ninitial_stack in
+       let status = subst_metasenv_and_fix_names status in
+       let status = status#set_ng_mode `ProofMode in
+       eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
   | GrafiteAst.NObj (loc,obj) ->
      if status#ng_mode <> `CommandMode then
       raise (GrafiteTypes.Command_error "Not in command mode")