]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/acic_content/cicNotationPp.ml
parameter sintax added to axiom statement
[helm.git] / helm / software / components / acic_content / cicNotationPp.ml
index 2873912c0129d51b9b17e9a6f2f3aae80c144797..f94891375fa7adddf8be10dc2d817692ae594270 100644 (file)
@@ -34,7 +34,7 @@ module Env = CicNotationEnv
    * be added to the output of pp_term.
    * set to false if you need, for example, cut and paste from matitac output to
    * matitatop *)
-let debug_printing = true
+let debug_printing = false
 
 let pp_binder = function
   | `Lambda -> "lambda"
@@ -54,12 +54,6 @@ let pp_literal =
       | `Keyword s
       | `Number s -> s)
 
-let pp_assoc =
-  function
-  | Gramext.NonA -> "NonA"
-  | Gramext.LeftA -> "LeftA"
-  | Gramext.RightA -> "RightA"
-
 let pp_pos =
   function
 (*      `None -> "`None" *)
@@ -74,7 +68,7 @@ let pp_attribute =
       sprintf "X(%s)"
         (String.concat ";"
           (List.map (fun (_, n, v) -> sprintf "%s=%s" n v) attrs))
-  | `Level (prec, assoc) -> sprintf "L(%d%s)" prec (pp_assoc assoc)
+  | `Level (prec) -> sprintf "L(%d)" prec 
   | `Raw _ -> "R"
   | `Loc _ -> "@"
   | `ChildPos p -> sprintf "P(%s)" (pp_pos p)
@@ -115,19 +109,22 @@ let rec pp_term ?(pp_parens = true) t =
          (match typ with None -> "" | Some t -> sprintf " return %s" (pp_term t))          
           (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 pp_term var) (pp_term ~pp_parens:true t1)
-          (pp_term ~pp_parens:true t2)
+    | Ast.LetIn ((var,t2), t1, t3) ->
+(*       let t2 = match t2 with None -> Ast.Implicit | Some t -> t in *)
+        sprintf "let %s \\def %s in %s" (pp_term var)
+(*           (pp_term ~pp_parens:true t2) *)
+          (pp_term ~pp_parens:true t1)
+          (pp_term ~pp_parens:true t3)
     | Ast.LetRec (kind, definitions, term) ->
        let rec get_guard i = function
-          | []                   -> (*assert false*) Ast.Implicit
+          | []                   -> (*assert false*) Ast.Implicit `JustOne
           | [term, _] when i = 1 -> term
           | _ :: tl              -> get_guard (pred i) tl
        in
        let map (params, (id,typ), body, i) =
          let typ =
           match typ with
-             None -> Ast.Implicit
+             None -> Ast.Implicit `JustOne
            | Some typ -> typ
          in
           sprintf "%s %s on %s: %s \\def %s" 
@@ -141,24 +138,29 @@ let rec pp_term ?(pp_parens = true) t =
           (String.concat " and " (List.map map definitions))
           (pp_term term)
     | Ast.Ident (name, Some []) | Ast.Ident (name, None)
-    | Ast.Uri (name, Some []) | Ast.Uri (name, None) ->
-        name
+    | Ast.Uri (name, Some []) | Ast.Uri (name, None) -> name
+    | Ast.NRef nref -> NReference.string_of_reference nref
+    | Ast.NCic cic -> NCicPp.ppterm ~metasenv:[] ~context:[] ~subst:[] cic
     | Ast.Ident (name, Some substs)
     | Ast.Uri (name, Some substs) ->
         sprintf "%s \\subst [%s]" name (pp_substs substs)
-    | Ast.Implicit -> "?"
+    | Ast.Implicit `Vector -> "…"
+    | Ast.Implicit `JustOne -> "?"
+    | Ast.Implicit (`Tagged name) -> "?"^name
     | Ast.Meta (index, substs) ->
         sprintf "%d[%s]" index
           (String.concat "; "
-            (List.map (function None -> "_" | Some t -> pp_term t) substs))
+            (List.map (function None -> "?" | Some t -> pp_term t) substs))
     | Ast.Num (num, _) -> num
     | Ast.Sort `Set -> "Set"
     | Ast.Sort `Prop -> "Prop"
     | Ast.Sort (`Type _) -> "Type"
-    | Ast.Sort `CProp -> "CProp"
+    | Ast.Sort (`CProp _)-> "CProp"
+    | Ast.Sort (`NType s)-> "Type[" ^ s ^ "]"
+    | Ast.Sort (`NCProp s)-> "CProp[" ^ s ^ "]"
     | Ast.Symbol (name, _) -> "'" ^ name
 
-    | Ast.UserInput -> ""
+    | Ast.UserInput -> "%"
 
     | Ast.Literal l -> pp_literal l
     | Ast.Layout l -> pp_layout l
@@ -167,7 +169,8 @@ let rec pp_term ?(pp_parens = true) t =
   in
   match pp_parens, t with
     | false, _ 
-    | true, Ast.Implicit
+    | true, Ast.Implicit _
+    | true, Ast.UserInput
     | true, Ast.Sort _
     | true, Ast.Ident (_, Some []) 
     | true, Ast.Ident (_, None)    -> t_pp
@@ -176,20 +179,24 @@ let rec pp_term ?(pp_parens = true) t =
 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, href, vars), term) =
-  let head_pp =
-    head ^
-    (match debug_printing, href with
-    | true, Some uri -> sprintf "(i.e.%s)" (UriManager.string_of_uri uri)
-    | _ -> "")
-  in
-  sprintf "%s \\Rightarrow %s"
-    (match vars with
-    | [] -> head_pp
-    | _ ->
-        sprintf "(%s %s)" head_pp
-          (String.concat " " (List.map (pp_capture_variable pp_term) vars)))
-    (pp_term term)
+and pp_pattern =
+ function
+    Ast.Pattern (head, href, vars), term ->
+     let head_pp =
+       head ^
+       (match debug_printing, href with
+       | true, Some uri -> sprintf "(i.e.%s)" (UriManager.string_of_uri uri)
+       | _ -> "")
+     in
+     sprintf "%s \\Rightarrow %s"
+       (match vars with
+       | [] -> head_pp
+       | _ ->
+           sprintf "(%s %s)" head_pp
+             (String.concat " " (List.map (pp_capture_variable pp_term) vars)))
+       (pp_term term)
+  | Ast.Wildcard, term ->
+     sprintf "_ \\Rightarrow %s" (pp_term term)
 
 and pp_patterns patterns =
   sprintf "[%s]" (String.concat " | " (List.map pp_pattern patterns))
@@ -210,6 +217,10 @@ and pp_layout = function
   | Ast.Over (t1, t2) -> sprintf "[%s \\OVER %s]" (pp_term t1) (pp_term t2)
   | Ast.Atop (t1, t2) -> sprintf "[%s \\ATOP %s]" (pp_term t1) (pp_term t2)
   | Ast.Frac (t1, t2) -> sprintf "\\FRAC %s %s" (pp_term t1) (pp_term t2)
+  | Ast.InfRule (t1, t2, t3) -> sprintf "\\INFRULE %s %s %s" (pp_term t1)
+  (pp_term t2) (pp_term t3)
+  | Ast.Maction l -> sprintf "\\MACTION (%s)" 
+     (String.concat "," (List.map pp_term l))
   | Ast.Sqrt t -> sprintf "\\SQRT %s" (pp_term t)
   | Ast.Root (arg, index) ->
       sprintf "\\ROOT %s \\OF %s" (pp_term index) (pp_term arg)
@@ -220,6 +231,14 @@ and pp_layout = function
         (String.concat " " (List.map pp_term terms))
   | Ast.Group terms ->
       sprintf "\\GROUP [%s]" (String.concat " " (List.map pp_term terms))
+  | Ast.Mstyle (l,terms) -> 
+      sprintf "\\MSTYLE %s [%s]" 
+        (String.concat " " (List.map (fun (k,v) -> k^"="^v) l))
+        (String.concat " " (List.map pp_term terms))
+  | Ast.Mpadded (l,terms) -> 
+      sprintf "\\MSTYLE %s [%s]" 
+        (String.concat " " (List.map (fun (k,v) -> k^"="^v) l))
+        (String.concat " " (List.map pp_term terms))
 
 and pp_magic = function
   | Ast.List0 (t, sep_opt) ->
@@ -249,7 +268,8 @@ and pp_sep_opt = function
 and pp_variable = function
   | Ast.NumVar s -> "number " ^ s
   | Ast.IdentVar s -> "ident " ^ s
-  | Ast.TermVar s -> "term " ^ s
+  | Ast.TermVar (s,Ast.Self _) -> s
+  | Ast.TermVar (s,Ast.Level l) -> "term " ^string_of_int l 
   | Ast.Ascription (t, n) -> assert false
   | Ast.FreshVar n -> "fresh " ^ n
 
@@ -278,10 +298,12 @@ let pp_fields pp_term fields =
     (List.map 
       (fun (name,ty,coercion,arity) -> 
         " " ^ name ^ 
-        if coercion then (":" ^ 
-          if arity > 0 then string_of_int arity else "" ^ ">") else ": " ^
-        pp_term ty) fields)
-        
+        (if coercion then 
+         (":" ^ (if arity > 0 then string_of_int arity else "") ^ "> ") 
+       else ": ") ^
+      pp_term ty)
+    fields)
+
 let pp_obj pp_term = function
  | Ast.Inductive (params, types) ->
     let pp_constructors constructors =
@@ -302,9 +324,9 @@ let pp_obj pp_term = function
             (pp_term typ) (pp_constructors constructors)
         in
         fst_typ_pp ^ String.concat "" (List.map pp_type tl))
- | Ast.Theorem (`MutualDefinition, name, typ, body) ->
+ | Ast.Theorem (`MutualDefinition, name, typ, body,_) ->
     sprintf "<<pretty printing of mutual definitions not implemented yet>>"
- | Ast.Theorem (flavour, name, typ, body) ->
+ | Ast.Theorem (flavour, name, typ, body,_) ->
     sprintf "%s %s:\n %s\n%s"
       (pp_flavour flavour)
       name
@@ -326,7 +348,7 @@ let rec pp_value = function
 
 let rec pp_value_type =
   function
-  | Env.TermType -> "Term"
+  | Env.TermType l -> "Term "^string_of_int l
   | Env.StringType -> "String"
   | Env.NumType -> "Number"
   | Env.OptType t -> "Maybe " ^ pp_value_type t
@@ -341,8 +363,9 @@ let pp_env env =
 
 let rec pp_cic_appl_pattern = function
   | Ast.UriPattern uri -> UriManager.string_of_uri uri
+  | Ast.NRefPattern nref -> NReference.string_of_reference nref
   | Ast.VarPattern name -> name
-  | Ast.ImplicitPattern -> "_"
+  | Ast.ImplicitPattern -> "?"
   | Ast.ApplPattern aps ->
       sprintf "(%s)" (String.concat " " (List.map pp_cic_appl_pattern aps))