+++ /dev/null
-(* Copyright (C) 2004, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://helm.cs.unibo.it/
- *)
-
-open Printf
-
-let pp_binder = function
- | `Lambda -> "lambda"
- | `Pi -> "Pi"
- | `Exists -> "exists"
- | `Forall -> "forall"
-
-let pp_name = function Cic.Anonymous -> "_" | Cic.Name s -> s
-
-let rec pp_term = function
- | CicAst.AttributedTerm (_, term) -> pp_term term
-
- | CicAst.Appl terms ->
- sprintf "(%s)" (String.concat " " (List.map pp_term terms))
- | CicAst.Binder (`Forall, (Cic.Anonymous, typ), body)
- | CicAst.Binder (`Pi, (Cic.Anonymous, typ), body) ->
- sprintf "(%s \\to %s)"
- (match typ with None -> "?" | Some typ -> pp_term typ)
- (pp_term body)
- | CicAst.Binder (kind, var, body) ->
- sprintf "\\%s %s.%s" (pp_binder kind) (pp_capture_variable var)
- (pp_term body)
- | CicAst.Case (term, indtype, typ, patterns) ->
- sprintf "%smatch %s with %s"
- (match typ with None -> "" | Some t -> sprintf "<%s>" (pp_term t))
- (pp_term term) (pp_patterns patterns)
- | CicAst.LetIn (var, t1, t2) ->
- sprintf "let %s = %s in %s" (pp_capture_variable var) (pp_term t1)
- (pp_term t2)
- | CicAst.LetRec (kind, definitions, term) ->
- sprintf "let %s %s in %s"
- (match kind with `Inductive -> "rec" | `CoInductive -> "corec")
- (String.concat " and "
- (List.map
- (fun (var, body, _) ->
- sprintf "%s = %s" (pp_capture_variable var) (pp_term body))
- definitions))
- (pp_term term)
- | CicAst.Ident (name, Some [])
- | CicAst.Ident (name, None) ->
- name
- | CicAst.Ident (name, Some substs) -> sprintf "%s \\subst [%s]" name (pp_substs substs)
- | CicAst.Implicit -> "?"
- | CicAst.Meta (index, substs) ->
- sprintf "%d[%s]" index
- (String.concat "; "
- (List.map (function None -> "_" | Some term -> pp_term term) substs))
- | CicAst.Num (num, _) -> num
- | CicAst.Sort `Set -> "Set"
- | CicAst.Sort `Prop -> "Prop"
- | CicAst.Sort `Type -> "Type"
- | CicAst.Sort `CProp -> "CProp"
- | CicAst.Symbol (name, _) -> name
-
-and pp_subst (name, term) = sprintf "%s \\Assign %s" name (pp_term term)
-and pp_substs substs = String.concat "; " (List.map pp_subst substs)
-
-and pp_pattern ((head, vars), term) =
- sprintf "%s \Rightarrow %s"
- (match vars with
- | [] -> head
- | _ ->
- sprintf "(%s %s)" head
- (String.concat " " (List.map pp_capture_variable vars)))
- (pp_term term)
-
-and pp_patterns patterns =
- sprintf "[%s]" (String.concat " | " (List.map pp_pattern patterns))
-
-and pp_capture_variable = function
- | name, None -> pp_name name
- | name, Some typ -> "(" ^ pp_name name ^ ": " ^ pp_term typ ^ ")"
-