| `Inductive ind -> inductive2pres term2pres ind
| _ -> assert false (* ZACK or raise ToDo? *)
-let content2pres
+let content2pres0
?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
(id,params,metasenv,obj)
=
let content2pres
?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
=
- content2pres ?skip_initial_lambdas ?skip_thm_and_qed
+ content2pres0 ?skip_initial_lambdas ?skip_thm_and_qed
(fun ?(prec=90) annterm ->
let ast, ids_to_uris =
TermAcicContent.ast_of_acic ~output_type:`Term ids_to_inner_sorts annterm
(CicNotationPres.render
~lookup_uri:(CicNotationPres.lookup_uri ids_to_uris) ~prec
(TermContentPres.pp_ast ast)))
+
+let ncontent2pres ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_nrefs =
+ let lookup_uri id =
+ try
+ let nref = Hashtbl.find ids_to_nrefs id in
+ Some (NReference.string_of_reference nref)
+ with Not_found -> None
+ in
+ content2pres0 ?skip_initial_lambdas ?skip_thm_and_qed
+ (fun ?(prec=90) ast ->
+ CicNotationPres.box_of_mpres
+ (CicNotationPres.render ~lookup_uri ~prec (TermContentPres.pp_ast ast)))
aux appl_pattern
*)
-let nmap_sequent ~subst (i,(n,context,ty):int * NCic.conjecture) =
+let nmap_sequent0 ~idref ~subst (i,(n,context,ty):int * NCic.conjecture) =
let module K = Content in
- let ids_to_refs = Hashtbl.create 211 in
- let register_ref = Hashtbl.add ids_to_refs in
- let nast_of_cic =
- nast_of_cic1 ~idref:(idref register_ref) ~output_type:`Term
- ~subst in
+ let nast_of_cic = nast_of_cic1 ~idref ~output_type:`Term ~subst in
let context',_ =
List.fold_right
(fun item (res,context) ->
})::res,item::context
) context ([],[])
in
- ("-1",i,context',nast_of_cic ~context ty), ids_to_refs
+ ("-1",i,context',nast_of_cic ~context ty)
+;;
+
+let nmap_sequent ~subst metasenv =
+ let module K = Content in
+ let ids_to_refs = Hashtbl.create 211 in
+ let register_ref = Hashtbl.add ids_to_refs in
+ nmap_sequent0 ~idref:(idref register_ref) ~subst metasenv, ids_to_refs
+;;
+
+let object_prefix = "obj:";;
+let declaration_prefix = "decl:";;
+let definition_prefix = "def:";;
+
+let get_id =
+ function
+ Ast.AttributedTerm (`IdRef id, _) -> id
+ | _ -> assert false
+;;
+
+let gen_id prefix seed =
+ let res = prefix ^ string_of_int !seed in
+ incr seed ;
+ res
+;;
+
+let build_def_item seed context metasenv id n t ty =
+ let module K = Content in
+(*
+ try
+ let sort = Hashtbl.find ids_to_inner_sorts id in
+ if sort = `Prop then
+ (let p =
+ (acic2content seed context metasenv ?name:(name_of n) ~ids_to_inner_sorts ~ids_to_inner_types t)
+ in
+ `Proof p;)
+ else
+*)
+ `Definition
+ { K.def_name = Some n;
+ K.def_id = gen_id definition_prefix seed;
+ K.def_aref = id;
+ K.def_term = t;
+ K.def_type = ty
+ }
+(*
+ with
+ Not_found -> assert false
+*)
+
+let build_decl_item seed id n s =
+ let module K = Content in
+(*
+ let sort =
+ try
+ Some (Hashtbl.find ids_to_inner_sorts (Cic2acic.source_id_of_id id))
+ with Not_found -> None
+ in
+ match sort with
+ | Some `Prop ->
+ `Hypothesis
+ { K.dec_name = name_of n;
+ K.dec_id = gen_id declaration_prefix seed;
+ K.dec_inductive = false;
+ K.dec_aref = id;
+ K.dec_type = s
+ }
+ | _ ->
+*)
+ `Declaration
+ { K.dec_name = Some n;
+ K.dec_id = gen_id declaration_prefix seed;
+ K.dec_inductive = false;
+ K.dec_aref = id;
+ K.dec_type = s
+ }
;;
+let nmap_obj (uri,_,metasenv,subst,kind) =
+ let module K = Content in
+ let ids_to_refs = Hashtbl.create 211 in
+ let register_ref = Hashtbl.add ids_to_refs in
+ let idref = idref register_ref in
+ let nast_of_cic =
+ nast_of_cic1 ~idref ~output_type:`Term ~subst in
+ let seed = ref 0 in
+ let conjectures =
+ match metasenv with
+ [] -> None
+ | _ -> (*Some (List.map (map_conjectures seed) metasenv)*)
+ (*CSC: used to be the previous line, that uses seed *)
+ Some (List.map (nmap_sequent0 ~idref ~subst) metasenv)
+ in
+ let res =
+ match kind with
+ NCic.Constant (_,_,Some bo,ty,_) ->
+ let ty = nast_of_cic ~context:[] ty in
+ let bo = nast_of_cic ~context:[] bo in
+ (gen_id object_prefix seed, [], conjectures,
+ `Def (K.Const,ty,
+ build_def_item seed [] [] (get_id bo) (NUri.name_of_uri uri) bo ty))
+ | NCic.Constant (_,_,None,ty,_) ->
+ let ty = nast_of_cic ~context:[] ty in
+ (gen_id object_prefix seed, [], conjectures,
+ `Decl (K.Const,
+ (*CSC: ??? get_id ty here used to be the id of the axiom! *)
+ build_decl_item seed (get_id ty) (NUri.name_of_uri uri) ty))
+(*
+ | C.AInductiveDefinition (id,l,params,nparams,_) ->
+ (gen_id object_prefix seed, params, conjectures,
+ `Joint
+ { K.joint_id = gen_id joint_prefix seed;
+ K.joint_kind = `Inductive nparams;
+ K.joint_defs = List.map (build_inductive seed) l
+ })
+
+and
+ build_inductive seed =
+ let module K = Content in
+ fun (_,n,b,ty,l) ->
+ `Inductive
+ { K.inductive_id = gen_id inductive_prefix seed;
+ K.inductive_name = n;
+ K.inductive_kind = b;
+ K.inductive_type = ty;
+ K.inductive_constructors = build_constructors seed l
+ }
+
+and
+ build_constructors seed l =
+ let module K = Content in
+ List.map
+ (fun (n,t) ->
+ { K.dec_name = Some n;
+ K.dec_id = gen_id declaration_prefix seed;
+ K.dec_inductive = false;
+ K.dec_aref = "";
+ K.dec_type = t
+ }) l
+*)
+ in
+ res,ids_to_refs
+;;
self#_showMath;
match self#script#grafite_status.proof_status with
| Proof (uri, metasenv, _subst, bo, ty, attrs) ->
- let name = UriManager.name_of_uri (HExtlib.unopt uri) in
- let obj = Cic.CurrentProof (name, metasenv, Lazy.force bo, ty, [], attrs) in
+ let name = UriManager.name_of_uri (HExtlib.unopt uri) in
+ let obj =
+ Cic.CurrentProof (name, metasenv, Lazy.force bo, ty, [], attrs)
+ in
self#_loadObj obj
| Incomplete_proof { proof = (uri, metasenv, _subst, bo, ty, attrs) } ->
- let name = UriManager.name_of_uri (HExtlib.unopt uri) in
- let obj = Cic.CurrentProof (name, metasenv, Lazy.force bo, ty, [], attrs) in
+ let name = UriManager.name_of_uri (HExtlib.unopt uri) in
+ let obj =
+ Cic.CurrentProof (name, metasenv, Lazy.force bo, ty, [], attrs)
+ in
self#_loadObj obj
- | _ -> self#blank ()
+ | _ ->
+ match self#script#grafite_status.ng_status with
+ ProofMode tstatus ->
+ let nobj = tstatus.NTacStatus.istatus.NTacStatus.pstatus in
+ self#_loadNObj nobj
+ | _ -> self#blank ()
(** loads a cic uri from the environment
* @param uri UriManager.uri *)