]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/grafite/grafiteAstPp.ml
f489b15b5e399667c655ea336a39fba0d5a9b7b0
[helm.git] / helm / software / components / grafite / grafiteAstPp.ml
1 (* Copyright (C) 2004, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (* $Id$ *)
27
28 open GrafiteAst
29
30 let tactical_terminator = ""
31 let tactic_terminator = tactical_terminator
32 let command_terminator = tactical_terminator
33
34 let pp_idents idents = 
35    let map = function Some s -> s | None -> "_" in
36    "(" ^ String.concat " " (List.map map idents) ^ ")"
37 let pp_hyps idents = String.concat " " idents
38
39 let pp_reduction_kind ~term_pp = function
40   | `Normalize -> "normalize"
41   | `Reduce -> "reduce"
42   | `Simpl -> "simplify"
43   | `Unfold (Some t) -> "unfold " ^ term_pp t
44   | `Unfold None -> "unfold"
45   | `Whd -> "whd"
46  
47 let pp_tactic_pattern ~map_unicode_to_tex ~term_pp ~lazy_term_pp (what, hyp, goal) = 
48   if what = None && hyp = [] && goal = None then "" else 
49   let what_text =
50     match what with
51     | None -> ""
52     | Some t -> Printf.sprintf "in match (%s) " (lazy_term_pp t) in
53   let hyp_text =
54     String.concat " "
55       (List.map (fun (name, p) -> Printf.sprintf "%s:(%s)" name (term_pp p)) hyp) in
56   let goal_text =
57     match goal with
58     | None -> ""
59     | Some t ->
60        let vdash = if map_unicode_to_tex then "\\vdash" else "⊢" in
61         Printf.sprintf "%s (%s)" vdash (term_pp t)
62   in
63    Printf.sprintf "%sin %s%s" what_text hyp_text goal_text
64
65 let pp_intros_specs s = function
66    | None, []         -> ""
67    | Some num, []     -> Printf.sprintf " %s%i" s num
68    | None, idents     -> Printf.sprintf " %s%s" s (pp_idents idents)
69    | Some num, idents -> Printf.sprintf " %s%i %s" s num (pp_idents idents)
70
71 let pp_terms ~term_pp terms = String.concat ", " (List.map term_pp terms)
72
73 let opt_string_pp = function
74    | None -> ""
75    | Some what -> what ^ " "
76  
77 let pp_auto_params ~term_pp (univ, params) = 
78    String.concat " " 
79      (List.map (fun (k,v) -> if v <> "" then k ^ "=" ^ v else k) params) ^
80      match univ with
81        | None -> ""
82        | Some l -> (if params <> [] then " " else "") ^ "by " ^ 
83            String.concat " " (List.map term_pp l)
84 ;;
85
86 let pp_just ~term_pp =
87  function
88     `Term term -> "exact " ^ term_pp term
89   | `Auto params -> pp_auto_params ~term_pp params
90 ;;
91
92 let rec pp_ntactic ~map_unicode_to_tex =
93  let term_pp = CicNotationPp.pp_term in
94  let lazy_term_pp = fun _ -> assert false in
95  let pp_tactic_pattern =
96   pp_tactic_pattern ~map_unicode_to_tex ~lazy_term_pp ~term_pp in
97  function
98   | NApply (_,t) -> "napply " ^ CicNotationPp.pp_term t
99   | NAuto (_,(None,flgs)) ->
100       "nauto" ^
101         String.concat " " (List.map (fun a,b -> a ^ "=" ^ b) flgs)
102   | NAuto (_,(Some l,flgs)) ->
103       "nauto" ^ " by " ^
104          (String.concat "," (List.map CicNotationPp.pp_term l)) ^
105         String.concat " " (List.map (fun a,b -> a ^ "=" ^ b) flgs)
106   | NCases (_,what,where) -> "ncases " ^ CicNotationPp.pp_term what ^
107       assert false ^ " " ^ assert false
108   | NConstructor (_,None,l) -> "@ " ^
109       String.concat " " (List.map CicNotationPp.pp_term l)
110   | NConstructor (_,Some x,l) -> "@" ^ string_of_int x ^ " " ^
111       String.concat " " (List.map CicNotationPp.pp_term l)
112   | NCase1 (_,n) -> "*" ^ n ^ ":"
113   | NChange (_,what,wwhat) -> "nchange " ^ assert false ^ 
114       " with " ^ CicNotationPp.pp_term wwhat
115   | NCut (_,t) -> "ncut " ^ CicNotationPp.pp_term t
116 (*| NDiscriminate (_,t) -> "ndiscriminate " ^ CicNotationPp.pp_term t
117   | NSubst (_,t) -> "nsubst " ^ CicNotationPp.pp_term t *)
118   | NDestruct _ -> "ndestruct"
119   | NElim (_,what,where) -> "nelim " ^ CicNotationPp.pp_term what ^
120       assert false ^ " " ^ assert false
121   | NId _ -> "nid"
122   | NIntro (_,n) -> "#" ^ n
123   | NInversion (_,what,where) -> "ninversion " ^ CicNotationPp.pp_term what ^
124       assert false ^ " " ^ assert false
125   | NLApply (_,t) -> "lapply " ^ CicNotationPp.pp_term t
126   | NRewrite (_,dir,n,where) -> "nrewrite " ^
127      (match dir with `LeftToRight -> ">" | `RightToLeft -> "<") ^
128      " " ^ CicNotationPp.pp_term n ^ " " ^ pp_tactic_pattern where
129   | NReduce _ | NGeneralize _ | NLetIn _ | NAssert _ -> "TO BE IMPLEMENTED"
130   | NDot _ -> "##."
131   | NSemicolon _ -> "##;"
132   | NBranch _ -> "##["
133   | NShift _ -> "##|"
134   | NPos (_, l) -> "##" ^String.concat "," (List.map string_of_int l)^ ":"
135   | NPosbyname (_, s) -> "##" ^ s ^ ":"
136   | NWildcard _ -> "##*:"
137   | NMerge _ -> "##]"
138   | NFocus (_,l) -> 
139       Printf.sprintf "##focus %s" 
140         (String.concat " " (List.map string_of_int l))
141   | NUnfocus _ -> "##unfocus"
142   | NSkip _ -> "##skip"
143   | NTry (_,tac) -> "ntry " ^ pp_ntactic ~map_unicode_to_tex tac
144   | NAssumption _ -> "nassumption"
145   | NBlock (_,l) -> 
146      "(" ^ String.concat " " (List.map (pp_ntactic ~map_unicode_to_tex) l)^ ")"
147   | NRepeat (_,t) -> "nrepeat " ^ pp_ntactic ~map_unicode_to_tex t
148 ;;
149
150 let rec pp_tactic ~map_unicode_to_tex ~term_pp ~lazy_term_pp =
151  let pp_terms = pp_terms ~term_pp in
152  let pp_tactics = pp_tactics ~map_unicode_to_tex ~term_pp ~lazy_term_pp in
153  let pp_reduction_kind = pp_reduction_kind ~term_pp in
154  let pp_tactic_pattern =
155   pp_tactic_pattern ~map_unicode_to_tex ~lazy_term_pp ~term_pp in
156  let rec pp_tactic =
157   function
158   (* Higher order tactics *)
159   | Do (_, count, tac) ->
160       Printf.sprintf "do %d %s" count (pp_tactic tac)
161   | Repeat (_, tac) -> "repeat " ^ pp_tactic tac
162   | Seq (_, tacs) -> pp_tactics ~sep:"; " tacs
163   | Then (_, tac, tacs) ->
164       Printf.sprintf "%s; [%s]" (pp_tactic tac)
165         (pp_tactics ~sep:" | " tacs)
166   | First (_, tacs) ->
167      Printf.sprintf "tries [%s]" (pp_tactics ~sep:" | " tacs)
168   | Try (_, tac) -> "try " ^ pp_tactic tac
169   | Solve (_, tac) ->
170      Printf.sprintf "solve [%s]" (pp_tactics ~sep:" | " tac)
171   | Progress (_, tac) -> "progress " ^ pp_tactic tac
172   (* First order tactics *)
173   | Absurd (_, term) -> "absurd" ^ term_pp term
174   | Apply (_, term) -> "apply " ^ term_pp term
175   | ApplyRule (_, term) -> "apply rule " ^ term_pp term
176   | ApplyP (_, term) -> "applyP " ^ term_pp term
177   | ApplyS (_, term, params) ->
178      "applyS " ^ term_pp term ^ pp_auto_params ~term_pp params
179   | AutoBatch (_,params) -> "autobatch " ^ 
180       pp_auto_params ~term_pp params
181   | Assumption _ -> "assumption"
182   | Cases (_, term, pattern, specs) -> 
183       Printf.sprintf "cases %s %s%s" 
184       (term_pp term)
185       (pp_tactic_pattern pattern)
186       (pp_intros_specs "names " specs)
187   | Change (_, where, with_what) ->
188       Printf.sprintf "change %s with %s" (pp_tactic_pattern where) (lazy_term_pp with_what)
189   | Clear (_,ids) -> Printf.sprintf "clear %s" (pp_hyps ids)
190   | ClearBody (_,id) -> Printf.sprintf "clearbody %s" (pp_hyps [id])
191   | Constructor (_,n) -> "constructor " ^ string_of_int n
192   | Compose (_,t1, t2, times, intro_specs) -> 
193       Printf.sprintf "compose %s%s %s%s" 
194         (if times > 0 then string_of_int times ^ " " else "")
195         (term_pp t1) (match t2 with None -> "" | Some t2 -> "with "^term_pp t2)
196         (pp_intros_specs " as " intro_specs)
197   | Contradiction _ -> "contradiction"
198   | Cut (_, ident, term) ->
199      "cut " ^ term_pp term ^
200       (match ident with None -> "" | Some id -> " as " ^ id)
201   | Decompose (_, names) ->
202       Printf.sprintf "decompose%s" 
203       (pp_intros_specs "names " (None, names)) 
204   | Demodulate (_, params) -> "demodulate " ^ pp_auto_params ~term_pp params
205   | Destruct (_, None) -> "destruct" 
206   | Destruct (_, Some terms) -> "destruct " ^ pp_terms terms
207   | Elim (_, what, using, pattern, specs) ->
208       Printf.sprintf "elim %s%s %s%s" 
209       (term_pp what)
210       (match using with None -> "" | Some term -> " using " ^ term_pp term)
211       (pp_tactic_pattern pattern)
212       (pp_intros_specs "names " specs) 
213   | ElimType (_, term, using, specs) ->
214       Printf.sprintf "elim type %s%s%s" 
215       (term_pp term)
216       (match using with None -> "" | Some term -> " using " ^ term_pp term)
217       (pp_intros_specs "names " specs)
218   | Exact (_, term) -> "exact " ^ term_pp term
219   | Exists _ -> "exists"
220   | Fold (_, kind, term, pattern) ->
221       Printf.sprintf "fold %s %s %s" (pp_reduction_kind kind)
222        (lazy_term_pp term) (pp_tactic_pattern pattern)
223   | FwdSimpl (_, hyp, names) -> 
224       Printf.sprintf "fwd %s%s" hyp (pp_intros_specs "names " (None, names))
225   | Generalize (_, pattern, ident) ->
226      Printf.sprintf "generalize %s%s" (pp_tactic_pattern pattern)
227       (match ident with None -> "" | Some id -> " as " ^ id)
228   | Fail _ -> "fail"
229   | Fourier _ -> "fourier"
230   | IdTac _ -> "id"
231   | Intros (_, specs) -> Printf.sprintf "intros%s" (pp_intros_specs "" specs)
232   | Inversion (_, term) -> "inversion " ^ term_pp term
233   | LApply (_, linear, level_opt, terms, term, ident_opt) -> 
234       Printf.sprintf "lapply %s%s%s%s%s" 
235         (if linear then " linear " else "")
236         (match level_opt with None -> "" | Some i -> " depth = " ^ string_of_int i ^ " ")  
237         (term_pp term) 
238         (match terms with [] -> "" | _ -> " to " ^ pp_terms terms)
239         (match ident_opt with None -> "" | Some ident -> " as " ^ ident)
240   | Left _ -> "left"
241   | LetIn (_, term, ident) -> 
242      Printf.sprintf "letin %s \\def %s" ident (term_pp term)
243   | Reduce (_, kind, pat) ->
244       Printf.sprintf "%s %s" (pp_reduction_kind kind) (pp_tactic_pattern pat)
245   | Reflexivity _ -> "reflexivity"
246   | Replace (_, pattern, t) ->
247       Printf.sprintf "replace %s with %s" (pp_tactic_pattern pattern) (lazy_term_pp t)
248   | Rewrite (_, pos, t, pattern, names) -> 
249       Printf.sprintf "rewrite %s %s %s%s" 
250         (if pos = `LeftToRight then ">" else "<")
251         (term_pp t)
252         (pp_tactic_pattern pattern)
253         (if names = [] then "" else " as " ^ pp_idents names)
254   | Right _ -> "right"
255   | Ring _ -> "ring"
256   | Split _ -> "split"
257   | Symmetry _ -> "symmetry"
258   | Transitivity (_, term) -> "transitivity " ^ term_pp term
259   (* Tattiche Aggiunte *)
260   | Assume (_, ident , term) -> "assume" ^ ident ^ ":" ^ term_pp term 
261   | Suppose (_, term, ident,term1) -> "suppose" ^ term_pp term ^ "("  ^ ident ^ ")" ^ (match term1 with None -> " " | Some term1 -> term_pp term1)
262   | Bydone (_, just) ->  pp_just ~term_pp just ^ "done"
263   | By_just_we_proved (_, just, term1, ident, term2) -> pp_just ~term_pp just  ^ "we proved" ^ term_pp term1 ^ (match ident with None -> "" | Some ident -> "(" ^ident^ ")") ^
264        (match term2 with  None -> " " | Some term2 -> term_pp term2)
265   | We_need_to_prove (_, term, ident, term1) -> "we need to prove" ^ term_pp term ^ (match ident with None -> "" | Some ident -> "(" ^ ident ^ ")") ^ (match term1 with None -> " " | Some term1 -> term_pp term1)
266   | We_proceed_by_cases_on (_, term, term1) -> "we proceed by cases on" ^ term_pp term ^ "to prove" ^ term_pp term1
267   | We_proceed_by_induction_on (_, term, term1) -> "we proceed by induction on" ^ term_pp term ^ "to prove" ^ term_pp term1
268   | Byinduction (_, term, ident) -> "by induction hypothesis we know" ^ term_pp term ^ "(" ^ ident ^ ")"
269   | Thesisbecomes (_, term) -> "the thesis becomes " ^ term_pp term
270   | ExistsElim (_, just, ident, term, ident1, term1) -> pp_just ~term_pp just ^ "let " ^ ident ^ ":" ^ term_pp term ^ "such that " ^ lazy_term_pp term1 ^ "(" ^ ident1 ^ ")"
271   | AndElim (_, just, ident1, term1, ident2, term2) -> pp_just ~term_pp just ^ "we have " ^ term_pp term1 ^ " (" ^ ident1 ^ ") " ^ "and " ^ term_pp term2 ^ " (" ^ ident2 ^ ")" 
272   | RewritingStep (_, term, term1, term2, cont) -> 
273       (match term with 
274       | None -> " " 
275       | Some (None,term) -> "conclude " ^ term_pp term 
276       | Some (Some name,term) -> 
277           "obtain (" ^ name ^ ") " ^ term_pp term) 
278       ^ "=" ^
279       term_pp term1 ^ 
280       (match term2 with 
281       | `Auto params -> pp_auto_params ~term_pp params
282       | `Term term2 -> " exact " ^ term_pp term2 
283       | `Proof -> " proof"
284       | `SolveWith term -> " using " ^ term_pp term)
285       ^ (if cont then " done" else "")
286   | Case (_, id, args) ->
287      "case" ^ id ^
288        String.concat " "
289         (List.map (function (id,term) -> "(" ^ id ^ ": " ^ term_pp term ^  ")")
290           args)
291  in pp_tactic
292
293 and pp_tactics ~map_unicode_to_tex ~term_pp ~lazy_term_pp ~sep tacs =
294   String.concat sep
295    (List.map (pp_tactic ~map_unicode_to_tex ~lazy_term_pp ~term_pp) tacs)
296
297  let pp_search_kind = function
298   | `Locate -> "locate"
299   | `Hint -> "hint"
300   | `Match -> "match"
301   | `Elim -> "elim"
302   | `Instance -> "instance"
303
304 let pp_arg ~term_pp arg = 
305   let s = term_pp arg in
306    if s = "" || (s.[0] = '(' && s.[String.length s - 1] = ')') then
307      (* _nice_ heuristic *)
308      s
309    else
310      "(" ^ s ^ ")"
311   
312 let pp_nmacro = function
313   | NCheck (_, term) -> Printf.sprintf "ncheck %s" (CicNotationPp.pp_term term)
314   | Screenshot (_, name) -> Printf.sprintf "screenshot \"%s\"" name
315 ;;
316
317 let pp_macro ~term_pp ~lazy_term_pp = 
318   let term_pp = pp_arg ~term_pp in
319   let flavour_pp = function
320      | `Definition       -> "definition"
321      | `Fact             -> "fact"
322      | `Lemma            -> "lemma"
323      | `Remark           -> "remark"
324      | `Theorem          -> "theorem"
325      | `Variant          -> "variant"
326      | `Axiom            -> "axiom"
327      | `MutualDefinition -> assert false
328   in
329   let pp_inline_params l =
330      let pp_param = function
331         | IPPrefix prefix -> "prefix = \"" ^ prefix ^ "\""
332         | IPAs flavour  -> flavour_pp flavour
333         | IPCoercions   -> "coercions"
334         | IPDebug debug -> "debug = " ^ string_of_int debug
335         | IPProcedural  -> "procedural"
336         | IPNoDefaults  -> "nodefaults"
337         | IPDepth depth -> "depth = " ^ string_of_int depth
338         | IPLevel level -> "level = " ^ string_of_int level
339         | IPComments    -> "comments"
340         | IPCR          -> "cr"
341      in
342      let s = String.concat " " (List.map pp_param l) in
343      if s = "" then s else " " ^ s
344   in
345   let pp_reduction_kind = pp_reduction_kind ~term_pp:lazy_term_pp in
346   function 
347   (* Whelp *)
348   | WInstance (_, term) -> "whelp instance " ^ term_pp term
349   | WHint (_, t) -> "whelp hint " ^ term_pp t
350   | WLocate (_, s) -> "whelp locate \"" ^ s ^ "\""
351   | WElim (_, t) -> "whelp elim " ^ term_pp t
352   | WMatch (_, term) -> "whelp match " ^ term_pp term
353   (* real macros *)
354   | Eval (_, kind, term) -> 
355       Printf.sprintf "eval %s on %s" (pp_reduction_kind kind) (term_pp term) 
356   | Check (_, term) -> Printf.sprintf "check %s" (term_pp term)
357   | Hint (_, true) -> "hint rewrite"
358   | Hint (_, false) -> "hint"
359   | AutoInteractive (_,params) -> "auto " ^ pp_auto_params ~term_pp params
360   | Inline (_, suri, params) ->  
361       Printf.sprintf "inline \"%s\"%s" suri (pp_inline_params params) 
362
363 let pp_associativity = function
364   | Gramext.LeftA -> "left associative"
365   | Gramext.RightA -> "right associative"
366   | Gramext.NonA -> "non associative"
367
368 let pp_precedence i = Printf.sprintf "with precedence %d" i
369
370 let pp_default what uris = 
371   Printf.sprintf "default \"%s\" %s" what
372     (String.concat " " (List.map UriManager.string_of_uri uris))
373
374 let pp_coercion ~term_pp t do_composites arity saturations=
375    Printf.sprintf "coercion %s %d %d %s"
376     (term_pp t) arity saturations
377     (if do_composites then "" else "nocomposites")
378
379 let pp_ncommand = function
380   | UnificationHint (_,t, n) -> 
381       "unification hint " ^ string_of_int n ^ " " ^ CicNotationPp.pp_term t
382   | NDiscriminator (_,_)
383   | NInverter (_,_,_,_,_)
384   | NObj (_,_)
385   | NUnivConstraint (_) -> "not supported"
386   | NCoercion (_) -> "not supported"
387   | NQed (_) -> "nqed"
388   | NCopy (_,name,uri,map) -> 
389       "copy " ^ name ^ " from " ^ NUri.string_of_uri uri ^ " with " ^ 
390         String.concat " and " 
391           (List.map 
392             (fun (a,b) -> NUri.string_of_uri a ^ " ↦ " ^ NUri.string_of_uri b) 
393             map)
394 ;;
395     
396 let pp_command ~term_pp ~obj_pp = function
397   | Index (_,_,uri) -> "Indexing " ^ UriManager.string_of_uri uri
398   | Select (_,uri) -> "Selecting " ^ UriManager.string_of_uri uri
399   | Coercion (_, t, do_composites, i, j) ->
400      pp_coercion ~term_pp t do_composites i j
401   | PreferCoercion (_,t) -> 
402      "prefer coercion " ^ term_pp t
403   | Inverter (_,n,ty,params) ->
404      "inverter " ^ n ^ " for " ^ term_pp ty ^ " " ^ List.fold_left (fun acc x -> acc ^ (match x with true -> "%" | _ -> "?")) "" params
405   | Default (_,what,uris) -> pp_default what uris
406   | Drop _ -> "drop"
407   | Include (_,true,`OldAndNew,path) -> "include \"" ^ path ^ "\""
408   | Include (_,false,`OldAndNew,path) -> "include source \"" ^ path ^ "\""
409   | Include (_,_,`New,path) -> "RECURSIVELY INCLUDING " ^ path
410   | Obj (_,obj) -> obj_pp obj
411   | Qed _ -> "qed"
412   | Relation (_,id,a,aeq,refl,sym,trans) ->
413      "relation " ^ term_pp aeq ^ " on " ^ term_pp a ^
414      (match refl with
415          Some r -> " reflexivity proved by " ^ term_pp r
416        | None -> "") ^
417      (match sym with
418          Some r -> " symmetry proved by " ^ term_pp r
419        | None -> "") ^
420      (match trans with
421          Some r -> " transitivity proved by " ^ term_pp r
422        | None -> "")
423   | Print (_,s) -> "print " ^ s
424   | Set (_, name, value) -> Printf.sprintf "set \"%s\" \"%s\"" name value
425   | Pump (_) -> "not supported"
426
427 let pp_punctuation_tactical =
428   function
429   | Dot _ -> "."
430   | Semicolon _ -> ";"
431   | Branch _ -> "["
432   | Shift _ -> "|"
433   | Pos (_, i) -> Printf.sprintf "%s:" (String.concat "," (List.map string_of_int i))
434   | Wildcard _ -> "*:"
435   | Merge _ -> "]"
436
437 let pp_non_punctuation_tactical =
438   function
439   | Focus (_, goals) ->
440       Printf.sprintf "focus %s" (String.concat " " (List.map string_of_int goals))
441   | Unfocus _ -> "unfocus"
442   | Skip _ -> "skip"
443
444 let pp_executable ~map_unicode_to_tex ~term_pp ~lazy_term_pp ~obj_pp =
445   function
446   | NMacro (_, macro) -> pp_nmacro macro ^ "."
447   | Macro (_, macro) -> pp_macro ~term_pp ~lazy_term_pp macro ^ "."
448   | Tactic (_, Some tac, punct) ->
449       pp_tactic ~map_unicode_to_tex ~term_pp ~lazy_term_pp tac
450       ^ pp_punctuation_tactical punct
451   | Tactic (_, None, punct) ->
452      pp_punctuation_tactical punct
453   | NTactic (_,tacl) ->
454       String.concat " " (List.map (pp_ntactic ~map_unicode_to_tex) tacl)
455   | NonPunctuationTactical (_, tac, punct) ->
456      pp_non_punctuation_tactical tac
457      ^ pp_punctuation_tactical punct
458   | Command (_, cmd) -> pp_command ~term_pp ~obj_pp cmd ^ "."
459   | NCommand (_, cmd) -> pp_ncommand cmd ^ "."
460                       
461 let pp_comment ~map_unicode_to_tex ~term_pp ~lazy_term_pp ~obj_pp =
462   function
463   | Note (_,"") -> Printf.sprintf "\n"
464   | Note (_,str) -> Printf.sprintf "\n(* %s *)" str
465   | Code (_,code) ->
466       Printf.sprintf "\n(** %s. **)" (pp_executable ~map_unicode_to_tex ~term_pp ~lazy_term_pp ~obj_pp code)
467
468 let pp_statement ~term_pp ~lazy_term_pp ~obj_pp =
469   function
470   | Executable (_, ex) -> pp_executable ~lazy_term_pp ~term_pp ~obj_pp ex 
471   | Comment (_, c) -> pp_comment ~term_pp ~lazy_term_pp ~obj_pp c