1 (* Copyright (C) 2004, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
30 let pp_term term = CicAstPp.pp_term term
32 let pp_idents idents = "[" ^ String.concat "; " idents ^ "]"
34 let pp_reduction_kind = function
39 let rec pp_tactic = function
40 | LocatedTactic (loc, tac) -> pp_tactic tac
41 | Absurd term -> "absurd" ^ pp_term term
42 | Apply term -> "apply " ^ pp_term term
44 | Assumption -> "assumption"
45 | Change (t1, t2, where) ->
46 sprintf "change %s with %s%s" (pp_term t1) (pp_term t2)
47 (match where with None -> "" | Some ident -> "in " ^ ident)
48 | Change_pattern (_, _, _) -> assert false (* TODO *)
49 | Contradiction -> "contradiction"
50 | Cut term -> "cut " ^ pp_term term
51 | Decompose (ident, principles) ->
52 sprintf "decompose %s %s" (pp_idents principles) ident
53 | Discriminate ident -> "discriminate " ^ ident
54 | Elim (term, using) ->
55 sprintf "elim " ^ pp_term term ^
56 (match using with None -> "" | Some term -> " using " ^ pp_term term)
57 | ElimType term -> "elim type " ^ pp_term term
58 | Exact term -> "exact " ^ pp_term term
60 | Fold (kind, term) ->
61 sprintf "fold %s %s" (pp_reduction_kind kind) (pp_term term)
62 | Fourier -> "fourier"
64 | Injection ident -> "injection " ^ ident
65 | Intros (num, idents) ->
67 (match num with None -> "" | Some num -> " " ^ string_of_int num)
68 (match idents with [] -> "" | idents -> " " ^ pp_idents idents)
70 | LetIn (term, ident) -> sprintf "let %s in %s" (pp_term term) ident
71 | Reduce (_, _, _) -> assert false (* TODO *)
72 | Reflexivity -> "reflexivity"
73 | Replace (t1, t2) -> sprintf "replace %s with %s" (pp_term t1) (pp_term t2)
74 | Replace_pattern (_, _) -> assert false (* TODO *)
75 | Rewrite (_, _, _) -> assert false (* TODO *)
79 | Symmetry -> "symmetry"
80 | Transitivity term -> "transitivity " ^ pp_term term
82 let pp_flavour = function
83 | `Definition -> "Definition"
88 | `Theorem -> "Theorem"
90 let pp_command = function
92 | Check term -> sprintf "Check %s" (CicAstPp.pp_term term)
95 (match name with None -> "Qed" | Some name -> sprintf "Save %s" name)
98 | Redo (Some n) -> sprintf "Redo %d" n
99 | Theorem (flavour, name, typ, body) ->
100 sprintf "%s %s: %s %s"
102 (match name with None -> "" | Some name -> name)
103 (CicAstPp.pp_term typ)
106 | Some body -> "\\def " ^ CicAstPp.pp_term body)
107 | Undo None -> "Undo"
108 | Undo (Some n) -> sprintf "Undo %d" n
110 let rec pp_tactical = function
111 | LocatedTactical (loc, tac) -> pp_tactical tac
113 | Tactic tac -> pp_tactic tac
114 | Command cmd -> pp_command cmd
117 | Do (count, tac) -> sprintf "do %d %s" count (pp_tactical tac)
119 | Repeat tac -> "repeat " ^ pp_tactical tac
120 | Seq tacs -> pp_tacticals tacs
121 | Then (tac, tacs) -> sprintf "%s [%s]" (pp_tactical tac) (pp_tacticals tacs)
122 | Tries tacs -> sprintf "tries [%s]" (pp_tacticals tacs)
123 | Try tac -> "try " ^ pp_tactical tac
125 and pp_tacticals tacs = String.concat "; " (List.map pp_tactical tacs)
127 let pp_tactical tac = pp_tactical tac ^ "."