]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaProof.ml
snapshot
[helm.git] / helm / matita / matitaProof.ml
index 17b44ffd3ee600ca79af6e2d7d123c2fd01ef7b6..4f485445d45df0dba5918fab2301fa8bac88e3c8 100644 (file)
@@ -29,16 +29,42 @@ let currentProof (uri, metasenv, bo, ty) =
     (* TODO CSC: Wrong: [] is just plainly wrong *)
   Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, [])
 
+let init_metadata status =
+  let ((_, metasenv, _, _) as proof, _) = status in
+  let proof_object_metadata = (* compute proof annotations *)
+    Cic2acic.acic_object_of_cic_object (currentProof proof)
+  in
+  let sequents_metadata = (* compute all sequent annotations from scratch *)
+    List.map
+      (fun ((metano, context, term) as sequent) ->
+        (metano, Cic2acic.asequent_of_sequent metasenv sequent))
+      metasenv
+  in
+  (proof_object_metadata, sequents_metadata)
+
+let compute_metadata (old_status, old_metadata) new_status =
+  let ((_, new_metasenv, _, _) as new_proof, _) = new_status in
+  let proof_object_metadata = (* compute proof annotations *)
+    Cic2acic.acic_object_of_cic_object (currentProof new_proof)
+  in
+  let sequents_metadata = (* compute all sequent annotations from scratch *)
+    (** TODO Zack could we reuse some of the annotations from the previous
+    * status to avoid recomputing all of them? uhm ... we have to which
+    * sequents haven't been changed by last tactic applications ... doh! *)
+    List.map
+      (fun ((metano, context, term) as sequent) ->
+        (metano, Cic2acic.asequent_of_sequent new_metasenv sequent))
+      new_metasenv
+  in
+  (proof_object_metadata, sequents_metadata)
+
 class proof ?uri ~typ ~metasenv ~body () =
   object (self)
 
     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)))
-        ()
+      StatefulProofEngine.status
+        ~history_size:BuildTimeConf.history_size ?uri ~typ ~body ~metasenv
+        init_metadata compute_metadata ()
 
     method toXml =
       let currentproof = currentProof self#proof in