Debian Codegraph @

pretyping/program.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open CErrors
12 open Util
13
14 let papp env sigma r args =
15 let open EConstr in
16 let gr = delayed_force r in
17 let evd, hd = Evd.fresh_global env sigma gr in
18 sigma, mkApp (hd, args)
19
20 let sig_typ () = Rocqlib.lib_ref "core.sig.type"
21 let sig_intro () = Rocqlib.lib_ref "core.sig.intro"
22 let sig_proj1 () = Rocqlib.lib_ref "core.sig.proj1"
23 (* let sig_proj2 () = Rocqlib.lib_ref "core.sig.proj2" *)
24
25 let sigT_typ () = Rocqlib.lib_ref "core.sigT.type"
26 let sigT_intro () = Rocqlib.lib_ref "core.sigT.intro"
27 let sigT_proj1 () = Rocqlib.lib_ref "core.sigT.proj1"
28 let sigT_proj2 () = Rocqlib.lib_ref "core.sigT.proj2"
29
30 let prod_typ () = Rocqlib.lib_ref "core.prod.type"
31 let prod_intro () = Rocqlib.lib_ref "core.prod.intro"
32 let prod_proj1 () = Rocqlib.lib_ref "core.prod.proj1"
33 let prod_proj2 () = Rocqlib.lib_ref "core.prod.proj2"
34
35 let coq_eq_ind () = Rocqlib.lib_ref "core.eq.type"
36 let coq_eq_refl () = Rocqlib.lib_ref "core.eq.refl"
37 let coq_eq_refl_ref () = Rocqlib.lib_ref "core.eq.refl"
38 let coq_eq_rect () = Rocqlib.lib_ref "core.eq.rect"
39
40 let mk_coq_not env sigma x =
41 let sigma, notc = Evd.fresh_global env sigma Rocqlib.(lib_ref "core.not.type") in
42 sigma, EConstr.mkApp (notc, [| x |])
43
44 let coq_JMeq_ind () =
45 try Rocqlib.lib_ref "core.JMeq.type"
46 with Not_found ->
47 user_err (Pp.str "cannot find Stdlib.Logic.JMeq.JMeq; maybe library Stdlib.Logic.JMeq has to be required first.")
48 let coq_JMeq_refl () = Rocqlib.lib_ref "core.JMeq.refl"
49
50 let unsafe_fold_right f = function
51 hd :: tl -> List.fold_right f tl hd
52 | [] -> invalid_arg "unsafe_fold_right"
53
54 let mk_coq_and env sigma l =
55 let sigma, and_typ = Evd.fresh_global env sigma Rocqlib.(lib_ref "core.and.type") in
56 sigma, unsafe_fold_right
57 (fun c conj ->
58 EConstr.(mkApp (and_typ, [| c ; conj |])))
59 l
60
61 (* true = transparent by default, false = opaque if possible *)
62 let proofs_transparency = ref true
63 let program_cases = ref true
64 let program_generalized_coercion = ref true
65
66 let set_proofs_transparency = (:=) proofs_transparency
67 let get_proofs_transparency () = !proofs_transparency
68
69 let is_program_generalized_coercion () = !program_generalized_coercion
70 let is_program_cases () = !program_cases
71
72 open Goptions
73
74 let () =
75 declare_bool_option
76 { optstage = Summary.Stage.Interp;
77 optdepr = None;
78 optkey = ["Transparent";"Obligations"];
79 optread = get_proofs_transparency;
80 optwrite = set_proofs_transparency; }
81
82 let () =
83 declare_bool_option
84 { optstage = Summary.Stage.Interp;
85 optdepr = None;
86 optkey = ["Program";"Cases"];
87 optread = (fun () -> !program_cases);
88 optwrite = (:=) program_cases }
89
90 let () =
91 declare_bool_option
92 { optstage = Summary.Stage.Interp;
93 optdepr = None;
94 optkey = ["Program";"Generalized";"Coercion"];
95 optread = (fun () -> !program_generalized_coercion);
96 optwrite = (:=) program_generalized_coercion }