now matitaScript has a mathviewer to show terms...
(MatitaGui.interactive_interp_choice ())
let script =
- MatitaScript.script ~buffer:gui#main#scriptTextView#buffer
- ~init:(Lazy.force MatitaEngine.initial_status) ()
+ MatitaScript.script
+ ~buffer:gui#main#scriptTextView#buffer
+ ~init:(Lazy.force MatitaEngine.initial_status)
+ ~mathviewer:(MatitaMathView.mathViewer ())
+ ()
(* math viewers *)
let _ =
sequentsViewer ~notebook:gui#main#sequentsNotebook ~sequentViewer ()
let sequentsViewer_instance = MatitaMisc.singleton default_sequentsViewer
+
+let mathViewer () =
+ object
+ method show_term t = (cicBrowser ()) # loadTerm t
+ end
exception Browser_failure of string
-type term_source =
- [ `Ast of DisambiguateTypes.term
- | `Cic of Cic.term * Cic.metasenv
- | `String of string
- ]
class type cicBrowser =
object
method loadUri: string -> unit
- method loadTerm: term_source -> unit
+ method loadTerm: MatitaTypes.term_source -> unit
end
(** {2 Constructors} *)
val sequentViewer_instance: unit -> sequentViewer
val sequentsViewer_instance: unit -> sequentsViewer
+val mathViewer: unit -> MatitaTypes.mathViewer
+
let (_, context, _) = CicUtil.lookup_meta goal metasenv in
context
| _ -> []
+
+let get_proof_aliases status = status.aliases
let qualify status name = get_string_option status "baseuri" ^ "/" ^ name
val get_proof_status: MatitaTypes.status -> ProofEngineTypes.status
val get_proof_metasenv: MatitaTypes.status -> Cic.metasenv
val get_proof_context: MatitaTypes.status -> Cic.context
+val get_proof_aliases: MatitaTypes.status -> DisambiguateTypes.environment
let loc = CicAst.dummy_floc in
A.Tactical (loc, A.Tactic (loc, A.Goal (loc, n)))
-let eval_statement status user_goal s =
+let eval_statement status mathviewer user_goal s =
let st = CicTextualParser2.parse_statement (Stream.of_string s) in
match st with
| TacticAst.Command (loc, _) | TacticAst.Tactical (loc, _) ->
in
[ new_status, new_text ], parsed_text_length
| TacticAst.Macro (loc, mac) ->
+ let parsed_text_length = snd (CicAst.loc_of_floc loc) in
(match mac with (* TODO *)
+ | TacticAst.Hint _ ->
+ let s = MatitaMisc.get_proof_status status in
+ let l = List.map fst
+ (MetadataQuery.experimental_hint ~dbd:(MatitaDb.instance ()) s)
+ in
+ List.iter prerr_endline l;
+ prerr_endline "FINITA LA HINT"; assert false
+ | TacticAst.Check (_,t) ->
+ let metasenv = MatitaMisc.get_proof_metasenv status in
+ let context = MatitaMisc.get_proof_context status in
+ let aliases = MatitaMisc.get_proof_aliases status in
+ let db = MatitaDb.instance () in
+ let (_env,_metasenv,term,_graph) =
+ let interps =
+ MatitaDisambiguator.disambiguate_term db context metasenv
+ aliases t
+ in
+ match interps with
+ | [x] -> x
+ | _ -> assert false
+ in
+ let ty,_ =
+ CicTypeChecker.type_of_aux' metasenv context term
+ CicUniv.empty_ugraph
+ in
+ mathviewer # show_term (`Cic (ty,metasenv) );
+ [ status, "" ] , parsed_text_length
| _ -> failwith "not implemented")
-class script ~(buffer: GText.buffer) ~(init: MatitaTypes.status) () =
+class script ~(buffer: GText.buffer) ~(init: MatitaTypes.status)
+ ~(mathviewer: MatitaTypes.mathViewer) () =
object (self)
initializer self#reset ()
let s = match statement with Some s -> s | None -> self#getFuture in
if Pcre.pmatch ~rex:blanks_RE s then raise Margin;
MatitaLog.debug ("evaluating: " ^ first_line s ^ " ...");
- let (entries, parsed_len) = eval_statement self#status userGoal s in
+ let (entries, parsed_len) =
+ eval_statement self#status mathviewer userGoal s in
let (new_statuses, new_statements) = List.split entries in
(*
prerr_endline "evalStatement returned";
let _script = ref None
-let script ~buffer ~init () =
- let s = new script ~buffer ~init () in
+let script ~buffer ~init ~mathviewer () =
+ let s = new script ~buffer ~init ~mathviewer () in
_script := Some s;
s
let instance () = match !_script with None -> assert false | Some s -> s
+
end
-val script: buffer:GText.buffer -> init:MatitaTypes.status -> unit -> script
+val script:
+ buffer:GText.buffer ->
+ init:MatitaTypes.status ->
+ mathviewer: MatitaTypes.mathViewer->
+ unit ->
+ script
(* each time script above is called an internal ref is set, instance will return
* the value of this ref *)
let obj = Cic.Constant (name, body, ty, params, attrs) in
let ugraph = CicUnivUtils.clean_and_fill uri obj ugraph in
CicEnvironment.add_type_checked_term uri (obj, ugraph);
- MetadataDb.index_constant ~dbd ~uri ~body ~ty;
+ MetadataDb.index_obj ~dbd ~uri; (* must be in the env *)
let new_stuff = save_object_to_disk status uri obj in
MatitaLog.message (sprintf "%s constant defined" suri);
{ status with objects = new_stuff @ status.objects }
let obj = Cic.InductiveDefinition (types, params, leftno, attrs) in
let ugraph = CicUnivUtils.clean_and_fill uri obj ugraph in
CicEnvironment.put_inductive_definition uri (obj, ugraph);
- MetadataDb.index_inductive_def ~dbd ~uri ~types:types;
+ MetadataDb.index_obj ~dbd ~uri; (* must be in the env *)
let new_stuff = save_object_to_disk status uri obj in
MatitaLog.message (sprintf "%s inductive type defined" suri);
let status = { status with objects = new_stuff @ status.objects } in
method show : ?msg:string -> unit -> unit
end
+type term_source =
+ [ `Ast of DisambiguateTypes.term
+ | `Cic of Cic.term * Cic.metasenv
+ | `String of string
+ ]
+
+class type mathViewer =
+ object
+ method show_term: term_source -> unit
+ end
+