- method private string_of_node node =
- let get_id (node: Gdome.element) =
- let xref_attr =
- node#getAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref_ds
- in
- xref_attr#to_string
- in
- let id = get_id node in
- let script = MatitaScript.instance () in
- let metasenv = script#proofMetasenv in
- let context = script#proofContext in
- let metasenv, context, conclusion =
- if script#onGoingProof () then
- script#proofMetasenv, script#proofContext, script#proofConclusion
- else
- [], [],
+ method private string_of_node ~(paste_kind:paste_kind) node =
+ if node#hasAttributeNS ~namespaceURI:helm_ns ~localName:xref_ds
+ then
+ let id = id_of_node node in
+ self#string_of_cic_sequent (self#sequent_of_id ~paste_kind id)
+ else string_of_dom_node node
+
+ method private string_of_cic_sequent cic_sequent =
+ let script = MatitaScript.current () in
+ let metasenv =
+ if script#onGoingProof () then script#proofMetasenv else [] in
+ let _, (acic_sequent, _, _, ids_to_inner_sorts, _) =
+ Cic2acic.asequent_of_sequent metasenv cic_sequent in
+ let _, _, _, annterm = acic_sequent in
+ let ast, ids_to_uris =
+ TermAcicContent.ast_of_acic ids_to_inner_sorts annterm in
+ let pped_ast = TermContentPres.pp_ast ast in
+ let markup = CicNotationPres.render ids_to_uris pped_ast in
+ BoxPp.render_to_string text_width markup
+
+ method private pattern_of term context unsh_sequent =
+ let context_len = List.length context in
+ let _, unsh_context, conclusion = unsh_sequent in
+ try
+ (match
+ List.nth unsh_context (List.length unsh_context - context_len - 1)
+ with
+ | None -> assert false (* can't select a restricted hypothesis *)
+ | Some (name, Cic.Decl ty) ->
+ ProofEngineHelpers.pattern_of ~term:ty [term]
+ | Some (name, Cic.Def (bo, _)) ->
+ ProofEngineHelpers.pattern_of ~term:bo [term])
+ with Failure _ | Invalid_argument _ ->
+ ProofEngineHelpers.pattern_of ~term:conclusion [term]
+
+ method private get_cic_info id =
+ match self#cic_info with
+ | Some ((Some unsh_sequent, _, _, _, _, _) as info) -> info, unsh_sequent
+ | Some ((None, _, _, _, _, _) as info) ->