| `Loc _ -> "@"
| `ChildPos p -> sprintf "P(%s)" (pp_pos p)
+let pp_capture_variable pp_term =
+ function
+ | term, None -> pp_term (* ~pp_parens:false *) term
+ | term, Some typ -> "(" ^ pp_term (* ~pp_parens:false *) term ^ ": " ^ pp_term typ ^ ")"
+
let rec pp_term ?(pp_parens = true) t =
let t_pp =
match t with
(match typ with None -> "?" | Some typ -> pp_term typ)
(pp_term ~pp_parens:true body)
| Ast.Binder (kind, var, body) ->
- sprintf "\\%s %s.%s" (pp_binder kind) (pp_capture_variable var)
+ sprintf "\\%s %s.%s" (pp_binder kind) (pp_capture_variable pp_term var)
(pp_term ~pp_parens:true body)
| Ast.Case (term, indtype, typ, patterns) ->
sprintf "match %s%s%s with %s"
(pp_patterns patterns)
| Ast.Cast (t1, t2) -> sprintf "(%s: %s)" (pp_term ~pp_parens:true t1) (pp_term ~pp_parens:true t2)
| Ast.LetIn (var, t1, t2) ->
- sprintf "let %s \\def %s in %s" (pp_capture_variable var) (pp_term ~pp_parens:true t1)
+ sprintf "let %s \\def %s in %s" (pp_capture_variable pp_term var) (pp_term ~pp_parens:true t1)
(pp_term ~pp_parens:true t2)
| Ast.LetRec (kind, definitions, term) ->
let rec get_guard i = function
in
sprintf "%s %s on %s: %s \\def %s"
(pp_term ~pp_parens:false term)
- (String.concat " " (List.map pp_capture_variable params))
+ (String.concat " " (List.map (pp_capture_variable pp_term) params))
(pp_term ~pp_parens:false (get_guard i params))
(pp_term typ) (pp_term body)
in
| [] -> head_pp
| _ ->
sprintf "(%s %s)" head_pp
- (String.concat " " (List.map pp_capture_variable vars)))
+ (String.concat " " (List.map (pp_capture_variable pp_term) vars)))
(pp_term term)
and pp_patterns patterns =
sprintf "[%s]" (String.concat " | " (List.map pp_pattern patterns))
-and pp_capture_variable =
- function
- | term, None -> pp_term ~pp_parens:false term
- | term, Some typ -> "(" ^ pp_term ~pp_parens:false term ^ ": " ^ pp_term typ ^ ")"
-
and pp_box_spec (kind, spacing, indent) =
let int_of_bool b = if b then 1 else 0 in
let kind_string =
let pp_term t = !_pp_term t
let set_pp_term f = _pp_term := f
-let pp_params = function
+let pp_params pp_term = function
| [] -> ""
- | params -> " " ^ String.concat " " (List.map pp_capture_variable params)
+ | params -> " " ^ String.concat " " (List.map (pp_capture_variable pp_term) params)
let pp_flavour = function
| `Definition -> "definition"
| `Variant -> "variant"
| `Axiom -> "axiom"
-let pp_fields fields =
+let pp_fields pp_term fields =
(if fields <> [] then "\n" else "") ^
String.concat ";\n"
(List.map
if arity > 0 then string_of_int arity else "" ^ ">") else ": " ^
pp_term ty) fields)
-let pp_obj = function
+let pp_obj pp_term = function
| Ast.Inductive (params, types) ->
let pp_constructors constructors =
String.concat "\n"
| (name, inductive, typ, constructors) :: tl ->
let fst_typ_pp =
sprintf "%sinductive %s%s: %s \\def\n%s"
- (if inductive then "" else "co") name (pp_params params)
+ (if inductive then "" else "co") name (pp_params pp_term params)
(pp_term typ) (pp_constructors constructors)
in
fst_typ_pp ^ String.concat "" (List.map pp_type tl))
| None -> ""
| Some body -> "\\def\n " ^ pp_term body)
| Ast.Record (params,name,ty,fields) ->
- "record " ^ name ^ " " ^ pp_params params ^ ": " ^ pp_term ty ^
- " \\def {" ^ pp_fields fields ^ "\n}"
+ "record " ^ name ^ " " ^ pp_params pp_term params ^ ": " ^ pp_term ty ^
+ " \\def {" ^ pp_fields pp_term fields ^ "\n}"
let rec pp_value = function
| Env.TermValue t -> sprintf "$%s$" (pp_term t)
*)
val pp_term: CicNotationPt.term -> string
-val pp_obj: CicNotationPt.obj -> string
+val pp_obj: ('term -> string) -> 'term CicNotationPt.obj -> string
val pp_env: CicNotationEnv.t -> string
val pp_value: CicNotationEnv.value -> string
type case_indtype = string * href option
+type 'term capture_variable = 'term * 'term option
+
(** To be increased each time the term type below changes, used for "safe"
* marshalling *)
-let magic = 1
+let magic = 2
type term =
(* CIC AST *)
| AttributedTerm of term_attribute * term
| Appl of term list
- | Binder of binder_kind * capture_variable * term (* kind, name, body *)
+ | Binder of binder_kind * term capture_variable * term (* kind, name, body *)
| Case of term * case_indtype option * term option *
(case_pattern * term) list
(* what to match, inductive type, out type, <pattern,action> list *)
| Cast of term * term
- | LetIn of capture_variable * term * term (* name, body, where *)
- | LetRec of induction_kind * (capture_variable list * capture_variable * term * int) list * term
+ | LetIn of term capture_variable * term * term (* name, body, where *)
+ | LetRec of induction_kind * (term capture_variable list * term capture_variable * term * int) list * term
(* (params, name, body, decreasing arg) list, where *)
| Ident of string * subst list option
(* literal, substitutions.
| Variable of pattern_variable
(* name, type. First component must be Ident or Variable (FreshVar _) *)
-and capture_variable = term * term option
and meta_subst = term option
and subst = string * term
-and case_pattern = string * href option * capture_variable list
+and case_pattern = string * href option * term capture_variable list
and box_kind = H | V | HV | HOV
and box_spec = box_kind * bool * bool (* kind, spacing, indent *)
* true means inductive, false coinductive *)
type 'term inductive_type = string * bool * 'term * (string * 'term) list
-type obj =
- | Inductive of capture_variable list * term inductive_type list
+type 'term obj =
+ | Inductive of 'term capture_variable list * 'term inductive_type list
(** parameters, list of loc * mutual inductive types *)
- | Theorem of Cic.object_flavour * string * term * term option
+ | Theorem of Cic.object_flavour * string * 'term * 'term option
(** flavour, name, type, body
* - name is absent when an unnamed theorem is being proved, tipically in
* interactive usage
* will be given in proof editing mode using the tactical language,
* unless the flavour is an Axiom
*)
- | Record of capture_variable list * string * term * (string * term * bool * int) list
+ | Record of 'term capture_variable list * string * 'term * (string * 'term * bool * int) list
(** left parameters, name, type, fields *)
(** {2 Standard precedences} *)
(** Symbol/Numbers instances *)
val freshen_term: CicNotationPt.term -> CicNotationPt.term
-val freshen_obj: CicNotationPt.obj -> CicNotationPt.obj
+val freshen_obj: CicNotationPt.term CicNotationPt.obj -> CicNotationPt.term CicNotationPt.obj
(** Notation id handling *)
let out_command och cmd =
let term_pp = NP.pp_term in
let lazy_term_pp = NP.pp_term in
- let obj_pp = NP.pp_obj in
+ let obj_pp = NP.pp_obj NP.pp_term in
let s = GP.pp_statement ~term_pp ~lazy_term_pp ~obj_pp cmd in
Printf.fprintf och "%s\n\n" s
aliases:DisambiguateTypes.environment ->(* previous interpretation status *)
universe:DisambiguateTypes.multiple_environment option ->
uri:UriManager.uri option -> (* required only for inductive types *)
- CicNotationPt.obj disambiguator_input ->
+ CicNotationPt.term CicNotationPt.obj disambiguator_input ->
((DisambiguateTypes.domain_item * DisambiguateTypes.codomain_item) list *
Cic.metasenv * (* new metasenv *)
Cic.obj *
if fresh_instances then CicNotationUtil.freshen_obj obj else obj
in
disambiguate_thing ~dbd ~context:[] ~metasenv:[] ~aliases ~universe ~uri
- ~pp_thing:CicNotationPp.pp_obj ~domain_of_thing:domain_of_obj
+ ~pp_thing:(CicNotationPp.pp_obj CicNotationPp.pp_term) ~domain_of_thing:domain_of_obj
~interpretate_thing:interpretate_obj ~refine_thing:refine_obj
(text,prefix_len,obj)
end
aliases:DisambiguateTypes.environment ->(* previous interpretation status *)
universe:DisambiguateTypes.multiple_environment option ->
uri:UriManager.uri option -> (* required only for inductive types *)
- CicNotationPt.obj disambiguator_input ->
+ CicNotationPt.term CicNotationPt.obj disambiguator_input ->
((DisambiguateTypes.domain_item * DisambiguateTypes.codomain_item) list *
Cic.metasenv * (* new metasenv *)
Cic.obj *
val term : CicNotationPt.term Grammar.Entry.e
val let_defs :
- (CicNotationPt.capture_variable list * CicNotationPt.capture_variable * CicNotationPt.term * int) list
+ (CicNotationPt.term CicNotationPt.capture_variable list * CicNotationPt.term CicNotationPt.capture_variable * CicNotationPt.term * int) list
Grammar.Entry.e
val protected_binder_vars :
* http://cs.unibo.it/helm/.
*)
-let content2procedural ~ids_to_inner_sorts prefix annterm = []
+module H = HExtlib
+module C = Content
+module G = GrafiteAst
+
+(* grafite ast constructors *************************************************)
+
+let floc = H.dummy_floc
+
+let mk_note str = G.Comment (floc, G.Note (floc, str))
+
+(* interface functions ******************************************************)
+
+let out_arg = function
+ | C.Aux _ -> "aux"
+ | C.Premise _ -> "premise"
+ | C.Lemma _ -> "lemma"
+ | C.Term _ -> "term"
+ | C.ArgProof _ -> "proof"
+ | C.ArgMethod _ -> "method"
+
+let out_args args = String.concat " " (List.map out_arg args)
+
+let out_name = function
+ | None -> ""
+ | Some str -> str
+
+let content2procedural ~ids_to_inner_sorts prefix (_, params, xmenv, obj) =
+ if List.length params > 0 || xmenv <> None then assert false;
+ match obj with
+ | `Def (C.Const, t, `Proof {
+ C.proof_name = Some name; C.proof_context = [];
+ C.proof_apply_context = []; C.proof_conclude = {
+ C.conclude_conclusion = Some b
+ }
+ }) ->
+ [mk_note (Printf.sprintf "%s" name)]
+ | _ -> assert false
ids_to_inner_sorts:(Cic.id, Cic2acic.sort_kind) Hashtbl.t -> string ->
Cic.annterm Content.cobj ->
(CicNotationPt.term, CicNotationPt.term,
- CicNotationPt.term GrafiteAst.reduction, CicNotationPt.obj, string)
+ CicNotationPt.term GrafiteAst.reduction, CicNotationPt.term CicNotationPt.obj, string)
GrafiteAst.statement list
| GrafiteAst.Procedural ->
let term_pp = CicNotationPp.pp_term in
let lazy_term_pp = CicNotationPp.pp_term in
- let obj_pp = CicNotationPp.pp_obj in
+ let obj_pp = CicNotationPp.pp_obj CicNotationPp.pp_term in
let aux = GrafiteAstPp.pp_statement ~term_pp ~lazy_term_pp ~obj_pp in
let script = Content2Procedural.content2procedural ~ids_to_inner_sorts prefix cobj in
- String.concat "" (List.map aux script)
+ "\n\n" ^ String.concat "" (List.map aux script)
LexiconEngine.status ->
baseuri:string option ->
Cic.metasenv ->
- ((CicNotationPt.term,CicNotationPt.obj) GrafiteAst.command) Disambiguate.disambiguator_input ->
+ ((CicNotationPt.term,CicNotationPt.term CicNotationPt.obj) GrafiteAst.command) Disambiguate.disambiguator_input ->
LexiconEngine.status * Cic.metasenv * (Cic.term,Cic.obj) GrafiteAst.command
val disambiguate_macro:
type ast_statement =
(CicNotationPt.term, CicNotationPt.term,
- CicNotationPt.term GrafiteAst.reduction, CicNotationPt.obj, string)
+ CicNotationPt.term GrafiteAst.reduction,
+ CicNotationPt.term CicNotationPt.obj, string)
GrafiteAst.statement
type statement =
type ast_statement =
(CicNotationPt.term, CicNotationPt.term,
- CicNotationPt.term GrafiteAst.reduction, CicNotationPt.obj, string)
+ CicNotationPt.term GrafiteAst.reduction,
+ CicNotationPt.term CicNotationPt.obj, string)
GrafiteAst.statement
type statement =
in
CicNotationPp.set_pp_term term_pp;
let lazy_term_pp = fun x -> assert false in
- let obj_pp = CicNotationPp.pp_obj in
+ let obj_pp = CicNotationPp.pp_obj CicNotationPp.pp_term in
GrafiteAstPp.pp_statement ~term_pp ~lazy_term_pp ~obj_pp t
in
let buri = Pcre.replace ~pat:"\\.p$" ("cic:/matita/TPTP/" ^ filename) in
<keyword-list _name = "Matita Macro" style = "Others 3" case-sensitive="TRUE">
<keyword>inline</keyword>
+ <keyword>procedural</keyword>
<keyword>check</keyword>
<keyword>hint</keyword>
<keyword>set</keyword>
GrafiteTypes.status ->
string * int *
((CicNotationPt.term, CicNotationPt.term,
- CicNotationPt.term GrafiteAst.reduction, CicNotationPt.obj, string)
+ CicNotationPt.term GrafiteAst.reduction, CicNotationPt.term CicNotationPt.obj, string)
GrafiteAst.statement) ->
((GrafiteTypes.status * LexiconEngine.status) *
(DisambiguateTypes.domain_item * DisambiguateTypes.codomain_item) option
Ulexing.lexbuf ->
(GrafiteTypes.status ->
(CicNotationPt.term, CicNotationPt.term,
- CicNotationPt.term GrafiteAst.reduction, CicNotationPt.obj, string)
+ CicNotationPt.term GrafiteAst.reduction, CicNotationPt.term CicNotationPt.obj, string)
GrafiteAst.statement -> unit) ->
((GrafiteTypes.status * LexiconEngine.status) *
(DisambiguateTypes.domain_item * DisambiguateTypes.codomain_item) option
let pp_ast_statement =
GrafiteAstPp.pp_statement ~term_pp:CicNotationPp.pp_term
- ~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:CicNotationPp.pp_obj
+ ~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:(CicNotationPp.pp_obj CicNotationPp.pp_term)
(** {2 Initialization} *)