module A = Ast;;
let floc = HExtlib.dummy_floc;;
+let kw = [
+ "and","myand"
+];;
+
+let mk_ident s =
+ PT.Ident ((try List.assoc s kw with Not_found -> s),None)
+;;
+
+
let rec collect_arities_from_term = function
| A.Constant name -> [name,0]
| A.Variable name -> []
;;
let rec convert_term = function
- | A.Variable x -> PT.Ident (x,None)
- | A.Constant x -> PT.Ident (x,None)
+ | A.Variable x -> mk_ident x
+ | A.Constant x -> mk_ident x
| A.Function (name, args) ->
- PT.Appl (PT.Ident (name,None) :: List.map convert_term args)
+ PT.Appl (mk_ident name :: List.map convert_term args)
;;
let atom_of_formula = function
;;
let rec mk_arrow component = function
- | 0 -> PT.Ident (component,None)
+ | 0 -> mk_ident component
| n ->
PT.Binder
(`Forall,
- ((PT.Ident ("_",None)),Some (PT.Ident (component,None))),
+ ((mk_ident "_"),Some (mk_ident component)),
mk_arrow component (n-1))
;;
| (name,nargs)::tl ->
PT.Binder
(`Forall,
- (PT.Ident (name,None),Some (mk_arrow "A" nargs)),
+ (mk_ident name,Some (mk_arrow "A" nargs)),
aux tl)
in
aux arities
let convert_atom a =
let aux = function
| A.Proposition _ -> assert false
- | A.Predicate (name,params) -> assert false
- | A.True -> PT.Ident ("True",None)
- | A.False -> PT.Ident ("False",None)
+ | A.Predicate (name,params) ->
+ prerr_endline ("Predicate is unsupported: " ^ name);
+ assert false
+ | A.True -> mk_ident "True"
+ | A.False -> mk_ident "False"
| A.Eq (l,r)
| A.NotEq (l,r) -> (* removes the negation *)
- PT.Appl [
- PT.Ident ("eq",None); PT.Ident ("A",None); convert_term l; convert_term r]
+ PT.Appl [mk_ident "eq";mk_ident "A";convert_term l;convert_term r]
in
build_ctx_for_arities (List.map (fun x -> (x,0)) (collect_fv_from_atom a)) (aux a)
;;
| hp::tl ->
PT.Binder
(`Forall,
- (PT.Ident ("H" ^ string_of_int n,None),
+ (mk_ident ("H" ^ string_of_int n),
Some (convert_formula true [] hp)),
build_ctx (n+1) tl)
in
let f =
PT.Binder
(`Forall,
- (PT.Ident ("A",None),Some (PT.Sort `Set)),
+ (mk_ident "A",Some (PT.Sort `Set)),
convert_formula false context f)
in
let o = PT.Theorem (`Theorem,name,f,None) in
in
let pp t =
(* for a correct pp we should disambiguate the term... *)
- let term_pp = CicNotationPp.pp_term in
+ let term_pp x =
+ BoxPp.render_to_string 80 (CicNotationPres.render (Hashtbl.create 1)
+ (TermContentPres.pp_ast x))
+ in
let lazy_term_pp = fun x -> assert false in
let obj_pp = CicNotationPp.pp_obj in
print_endline