| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open Util |
| 12 |
open Namegen |
| 13 |
open Termops |
| 14 |
open Reductionops |
| 15 |
open Typing |
| 16 |
open Tacred |
| 17 |
open Logic |
| 18 |
open Context.Named.Declaration |
| 19 |
|
| 20 |
module NamedDecl = Context.Named.Declaration |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
let project gl = |
| 25 |
Proofview.Goal.sigma gl |
| 26 |
|
| 27 |
let pf_apply f gl = |
| 28 |
f (Proofview.Goal.env gl) (project gl) |
| 29 |
|
| 30 |
let pf_env = Proofview.Goal.env |
| 31 |
let pf_concl = Proofview.Goal.concl |
| 32 |
|
| 33 |
let pf_type_of gl t = |
| 34 |
pf_apply type_of gl t |
| 35 |
|
| 36 |
let pf_conv_x gl t1 t2 = pf_apply is_conv gl t1 t2 |
| 37 |
|
| 38 |
let pf_ids_of_hyps gl = |
| 39 |
|
| 40 |
let hyps = Proofview.Goal.hyps gl in |
| 41 |
ids_of_named_context hyps |
| 42 |
|
| 43 |
let pf_ids_set_of_hyps gl = |
| 44 |
|
| 45 |
let env = Proofview.Goal.env gl in |
| 46 |
Environ.ids_of_named_context_val (Environ.named_context_val env) |
| 47 |
|
| 48 |
let pf_get_new_id id gl = |
| 49 |
let ids = pf_ids_set_of_hyps gl in |
| 50 |
next_ident_away id ids |
| 51 |
|
| 52 |
let pf_get_hyp id gl = |
| 53 |
let hyps = Proofview.Goal.env gl in |
| 54 |
let sigma = project gl in |
| 55 |
let sign = |
| 56 |
try EConstr.lookup_named id hyps |
| 57 |
with Not_found -> raise (RefinerError (hyps, sigma, NoSuchHyp id)) |
| 58 |
in |
| 59 |
sign |
| 60 |
|
| 61 |
let pf_get_hyp_typ id gl = |
| 62 |
pf_get_hyp id gl |> NamedDecl.get_type |
| 63 |
|
| 64 |
let pf_hyps_types gl = |
| 65 |
let env = Proofview.Goal.env gl in |
| 66 |
let sign = Environ.named_context env in |
| 67 |
List.map (function LocalAssum (id,x) |
| 68 |
| LocalDef (id,_,x) -> id.Context.binder_name, EConstr.of_constr x) |
| 69 |
sign |
| 70 |
|
| 71 |
let pf_last_hyp gl = |
| 72 |
let hyps = Proofview.Goal.hyps gl in |
| 73 |
List.hd hyps |
| 74 |
|
| 75 |
let pf_nf_concl (gl : Proofview.Goal.t) = |
| 76 |
|
| 77 |
let concl = Proofview.Goal.concl gl in |
| 78 |
let sigma = project gl in |
| 79 |
nf_evar sigma concl |
| 80 |
|
| 81 |
let pf_whd_all gl t = pf_apply whd_all gl t |
| 82 |
|
| 83 |
let pf_get_type_of gl t = pf_apply Retyping.get_type_of gl t |
| 84 |
|
| 85 |
let pf_hnf_constr gl t = pf_apply hnf_constr gl t |
| 86 |
let pf_hnf_type_of gl t = |
| 87 |
pf_whd_all gl (pf_get_type_of gl t) |
| 88 |
|
| 89 |
let pf_compute gl t = pf_apply compute gl t |
| 90 |
let pf_whd_compute gl t = pf_apply whd_compute gl t |
| 91 |
|
| 92 |
let pf_nf_evar gl t = nf_evar (project gl) t |
| 93 |
|
| 94 |
open Pp |
| 95 |
|
| 96 |
let pr_gls gl = |
| 97 |
let sigma = project gl in |
| 98 |
let env = pf_env gl in |
| 99 |
let concl = Proofview.Goal.concl gl in |
| 100 |
let penv = Termops.Internal.print_named_context env sigma in |
| 101 |
let pc = Termops.Internal.print_constr_env env sigma concl in |
| 102 |
let g = str" " ++ hv 0 (penv ++ fnl () ++ |
| 103 |
str "============================" ++ fnl () ++ |
| 104 |
str" " ++ pc) ++ fnl () |
| 105 |
in |
| 106 |
hov 0 (pr_evar_map (Some 2) env sigma ++ fnl () ++ g) |