21
(*translates a formula into a centaur-tree --> FORMULA *)
22
let translate_constr at_top env c =
23
xlate_formula (Constrextern.extern_constr at_top env c);;
25
(*translates a named_context into a centaur-tree --> PREMISES_LIST *)
26
(* this code is inspired from printer.ml (function pr_named_context_of) *)
27
let translate_sign env =
29
Environ.fold_named_context
30
(fun env (id,v,c) l ->
33
CT_premise(CT_ident(string_of_id id), translate_constr false env c)
36
(CT_coerce_ID_to_FORMULA (CT_ident (string_of_id id)),
37
translate_constr false env v1,
38
translate_constr false env c))::l)
43
(* the function rev_and_compact performs two operations:
44
1- it reverses the list of integers given as argument
45
2- it replaces sequences of "1" by a negative number that is
46
the length of the sequence. *)
47
let rec rev_and_compact l = function
53
rev_and_compact ((n - 1)::tl') tl
55
rev_and_compact ((-1)::l) tl
56
| [] -> rev_and_compact [-1] tl)
62
rev_and_compact ((n + a)::tl') tl
64
rev_and_compact (a::l) tl
65
| [] -> rev_and_compact (a::l) tl)
67
rev_and_compact (a::l) tl;;
69
(*translates an int list into a centaur-tree --> SIGNED_INT_LIST *)
70
let translate_path l =
72
(List.map (function n -> CT_coerce_INT_to_SIGNED_INT (CT_int n))
73
(rev_and_compact [] l));;
75
(*translates a path and a goal into a centaur-tree --> RULE *)
76
let translate_goal (g:goal) =
77
CT_rule(translate_sign (evar_env g), translate_constr true (evar_env g) g.evar_concl);;
79
let translate_goals (gl: goal list) =
80
CT_rule_list (List.map translate_goal gl);;