let debug_print = MatitaTypes.debug_print
+let save_dom =
+ let domImpl = lazy (Gdome.domImplementation ()) in
+ fun ~doc ~dest ->
+ ignore
+ ((Lazy.force domImpl)#saveDocumentToFile ~doc ~name:dest ~indent:true ())
+
(** {2 Initialization} *)
let _ = Helm_registry.load_from "matita.conf.xml"
()
let proof_viewer =
let mml_of_cic_object = BuildTimeConf.Transformer.mml_of_cic_object in
- MatitaMathView.proof_viewer ~mml_of_cic_object ~show:true
- ~packing:(gui#proof#scrolledProof#add) ()
+(*
+ let frame = GBin.frame ~packing:(gui#proof#scrolledProof#add) ~show:true () in
+ MatitaMathView.proof_viewer ~show:true ~packing:(frame#add) ()
+*)
+ MatitaMathView.proof_viewer ~show:true ~packing:(gui#proof#scrolledProof#add) ()
(*
let sequent_viewer =
let mml_of_cic_sequent = BuildTimeConf.Transformer.mml_of_cic_sequent in
* - ids_to_inner_types, ids_to_inner_sorts handling
* - sequent viewer notification
*)
- let xmldump_observer _ (status, _) = print_endline proof#toString in
- ignore (proof#attach_observer ~interested_in:StatefulProofEngine.all_events
- xmldump_observer);
-(*
- let proof_observer _ (status, ()) =
-prerr_endline "proof_observer";
- let ((uri_opt, metasenv, bo, ty), _) = status in
+ let xmldump_observer _ _ = print_endline proof#toString in
+ let proof_observer _ (status, metadata) =
+ debug_print "proof_observer";
+ let (acic, ids_to_terms, ids_to_father_ids, ids_to_inner_sorts,
+ ids_to_inner_types, ids_to_conjectures, ids_to_hypotheses) =
+ metadata
+ in
+ let ((uri_opt, _, _, _), _) = status in
let uri = MatitaTypes.unopt_uri uri_opt in
- (* TODO CSC [] is wrong *)
- let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
-try
- ignore (proof_viewer#load_proof uri proof)
-with exn ->
-prerr_endline "proof_observer exception:";
-prerr_endline (Printexc.to_string exn);
-raise exn
- in
- let proof_observer_id =
- proof#attach_observer ~interested_in:StatefulProofEngine.all_events
- proof_observer
+ debug_print "apply transformation";
+ let mathml =
+ BuildTimeConf.Transformer.mml_of_cic_object
+ ~explode_all:true uri acic ids_to_inner_sorts ids_to_inner_types
+ in
+ if BuildTimeConf.debug then save_dom ~doc:mathml ~dest:"/tmp/matita.xml";
+ proof_viewer#load_proof mathml metadata;
+ debug_print "/proof_observer"
in
-*)
+ ignore (proof#attach_observer ~interested_in:StatefulProofEngine.all_events
+ xmldump_observer);
+ ignore (proof#attach_observer ~interested_in:StatefulProofEngine.all_events
+ proof_observer);
proof#notify;
set_proof (Some proof)
open MatitaTypes
(* List utility functions *)
-exception Skip;;
+exception Skip
let list_map_fail f =
let rec aux =
(aux tl)
in
aux
-;;
+
(* End of the list utility functions *)
-class sequent_viewer ~(mml_of_cic_sequent:mml_of_cic_sequent) obj =
+(*
+class sequent_viewer obj =
object(self)
inherit GMathViewAux.multi_selection_math_view obj
current_infos <-
Some (ids_to_terms,ids_to_father_ids,ids_to_hypotheses)
end
-;;
+*)
-class proof_viewer ~(mml_of_cic_object:mml_of_cic_object) obj =
+class proof_viewer obj =
object(self)
inherit GMathViewAux.single_selection_math_view obj
+(* initializer self#set_log_verbosity 3 *)
+
val mutable current_infos = None
val mutable current_mml = None
- method load_proof uri currentproof =
- let
- (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
- ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
- = Cic2acic.acic_object_of_cic_object currentproof
- in
- let mml =
- mml_of_cic_object
- ~explode_all:true uri acic ids_to_inner_sorts ids_to_inner_types
+ method load_proof (mml:Gdome.document) (metadata:MatitaTypes.hist_metadata) =
+ let (acic, ids_to_terms, ids_to_father_ids, ids_to_inner_sorts,
+ ids_to_inner_types, ids_to_conjectures, ids_to_hypotheses) =
+ metadata
in
current_infos <-
Some
(ids_to_terms,ids_to_father_ids,ids_to_conjectures,ids_to_hypotheses);
- (match current_mml with
- None ->
+ match current_mml with
+ | None ->
+ MatitaTypes.debug_print "no previous MathML";
self#load_root ~root:mml#get_documentElement ;
current_mml <- Some mml
| Some current_mml' ->
+ MatitaTypes.debug_print "Previous MathML available: xmldiffing ...";
self#freeze ;
XmlDiff.update_dom ~from:current_mml' mml ;
- self#thaw);
- (acic, ids_to_inner_types, ids_to_inner_sorts)
+ self#thaw
end
(** constructors *)
-let sequent_viewer ~(mml_of_cic_sequent: mml_of_cic_sequent) =
+(*
+let sequent_viewer ?hadjustment ?vadjustment ?font_size ?log_verbosity =
GtkBase.Widget.size_params
~cont:(OgtkMathViewProps.pack_return (fun p ->
OgtkMathViewProps.set_params
- (new sequent_viewer ~mml_of_cic_sequent
- (GtkMathViewProps.MathView_GMetaDOM.create p))
- ?font_size:None ?log_verbosity:None))
- ?width:None ?height:None []
+ (new sequent_viewer (GtkMathViewProps.MathView_GMetaDOM.create p))
+ ~font_size ~log_verbosity))
+ []
+*)
-let proof_viewer ~(mml_of_cic_object: mml_of_cic_object) =
+let proof_viewer ?hadjustment ?vadjustment ?font_size ?log_verbosity =
GtkBase.Widget.size_params
~cont:(OgtkMathViewProps.pack_return (fun p ->
OgtkMathViewProps.set_params
- (new proof_viewer ~mml_of_cic_object
- (GtkMathViewProps.MathView_GMetaDOM.create p))
- ?font_size:None ?log_verbosity:None))
- ?width:None ?height:None []
+ (new proof_viewer (GtkMathViewProps.MathView_GMetaDOM.create p))
+ ~font_size ~log_verbosity))
+ []
* http://helm.cs.unibo.it/
*)
-val sequent_viewer :
- mml_of_cic_sequent:MatitaTypes.mml_of_cic_sequent ->
- ?packing:(GObj.widget -> unit) -> ?show:bool ->
- unit ->
- MatitaTypes.sequent_viewer
-
val proof_viewer :
- mml_of_cic_object:MatitaTypes.mml_of_cic_object ->
- ?packing:(GObj.widget -> unit) -> ?show:bool ->
+ ?hadjustment:GData.adjustment ->
+ ?vadjustment:GData.adjustment ->
+ ?font_size:int ->
+ ?log_verbosity:int ->
+ ?width:int ->
+ ?height:int ->
+ ?packing:(GObj.widget -> unit) ->
+ ?show:bool ->
unit ->
MatitaTypes.proof_viewer
+(*
+val sequent_viewer :
+ ?hadjustment:GData.adjustment ->
+ ?vadjustment:GData.adjustment ->
+ ?font_size:int ->
+ ?log_verbosity:int ->
+ ?width:int ->
+ ?height:int ->
+ ?packing:(GObj.widget -> unit) ->
+ ?show:bool ->
+ unit ->
+ MatitaTypes.sequent_viewer
+*)
+
* http://helm.cs.unibo.it/
*)
+ (** create a Cic.CurrentProof from a given proof *)
+let currentProof (uri, metasenv, bo, ty) =
+ let uri = MatitaTypes.unopt_uri uri in
+ (* TODO CSC: Wrong: [] is just plainly wrong *)
+ Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, [])
+
class proof ?uri ~typ ~metasenv ~body () =
object (self)
- inherit [unit] StatefulProofEngine.status ?uri ~typ ~body ~metasenv
- (fun _ -> ())
- (fun _ _ -> ())
- ()
-
- method private currentProof =
- let (uri, metasenv, bo, ty) = self#proof in
- let uri =
- match uri with
- | Some uri -> uri
- | None -> MatitaTypes.untitled_con_uri
- in
- (* TODO CSC: Wrong: [] is just plainly wrong *)
- Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, [])
+ inherit [MatitaTypes.hist_metadata]
+ StatefulProofEngine.status ?uri ~typ ~body ~metasenv
+ (fun proof ->
+ Cic2acic.acic_object_of_cic_object (currentProof (fst proof)))
+ (fun (old_proof, old_metadata) new_proof ->
+ Cic2acic.acic_object_of_cic_object (currentProof (fst new_proof)))
+ ()
method toXml =
- let currentproof = self#currentProof in
+ let currentproof = currentProof self#proof in
let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
Cic2acic.acic_object_of_cic_object ~eta_fix:false currentproof
in
(DisambiguateTypes.environment * Cic.metasenv * Cic.term)
end
+type hist_metadata =
+ Cic.annobj *
+ (Cic.id, Cic.term) Hashtbl.t *
+ (Cic.id, Cic.id option) Hashtbl.t *
+ (Cic.id, string) Hashtbl.t *
+ (Cic.id, Cic2acic.anntypes) Hashtbl.t *
+ (Cic.id, Cic.conjecture) Hashtbl.t *
+ (Cic.id, Cic.hypothesis) Hashtbl.t
+
class type proof =
object
- inherit [unit] StatefulProofEngine.status
+ inherit [hist_metadata] StatefulProofEngine.status
(** return a pair of "xml" (as defined in Xml module) representing the *
* current proof type and body, respectively *)
type mml_of_cic_object =
explode_all:bool -> UriManager.uri -> Cic.annobj ->
- (string, string) Hashtbl.t ->
- (string, Cic2acic.anntypes) Hashtbl.t -> Gdome.document
+ (string, string) Hashtbl.t -> (string, Cic2acic.anntypes) Hashtbl.t ->
+ Gdome.document
+ (** TODO Zack to be reviewed and unified with proof_viewer above *)
class type sequent_viewer =
object
inherit GMathViewAux.multi_selection_math_view
(** @return the annotated cic term and the ids_to_inner_types and
* ids_to_inner_sorts maps *)
- method load_proof :
- UriManager.uri -> Cic.obj ->
- Cic.annobj * (Cic.id, Cic2acic.anntypes) Hashtbl.t *
- (Cic.id, string) Hashtbl.t
+ method load_proof: Gdome.document -> hist_metadata -> unit
end