Debian Codegraph @

vernac/g_proofs.mlg

raw
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 DECLARE GLOBAL PLUGIN
12
13 {
14
15 open Vernacexpr
16 open Hints
17
18 open Procq
19 open Procq.Prim
20 open Procq.Constr
21 open Pvernac.Vernac_
22
23 let thm_token = G_vernac.thm_token
24
25 let hint = Entry.make "hint"
26
27 let warn_deprecated_focus =
28 CWarnings.create ~name:"deprecated-focus" ~category:Deprecation.Version.v8_8
29 Pp.(function
30 | None ->
31 strbrk "The Focus command is deprecated; use bullets or focusing brackets instead."
32 | Some n ->
33 str "The Focus command is deprecated;" ++ spc ()
34 ++ str "use '" ++ int n ++ str ": {' instead.")
35
36 let warn_deprecated_focus_n ?loc n = warn_deprecated_focus ?loc (Some n)
37
38 let warn_deprecated_focus ?loc () = warn_deprecated_focus ?loc None
39
40 let warn_deprecated_unfocus =
41 CWarnings.create ~name:"deprecated-unfocus" ~category:Deprecation.Version.v8_8
42 (fun () -> Pp.strbrk "The Unfocus command is deprecated")
43
44 }
45
46 (* Proof commands *)
47 GRAMMAR EXTEND Gram
48 GLOBAL: hint command;
49
50 opt_hintbases:
51 [ [ -> { [] }
52 | ":"; l = LIST1 [id = IDENT -> { id } ] -> { l } ] ]
53 ;
54 command: TOP
55 [ [ IDENT "Goal"; c = lconstr ->
56 { VernacSynPure (VernacDefinition (Decls.(NoDischarge, Definition), ((CAst.make ~loc Names.Anonymous), None), ProveBody ([], c))) }
57 | IDENT "Proof" -> { VernacSynPure (VernacProof (None,None)) }
58 | IDENT "Proof"; IDENT "using"; l = G_vernac.section_subset_expr ->
59 { VernacSynPure (VernacProof (None,Some l)) }
60 | IDENT "Proof"; "with"; ta = generic_tactic;
61 l = OPT [ IDENT "using"; l = G_vernac.section_subset_expr -> { l } ] ->
62 { Vernacexpr.VernacSynPure (Vernacexpr.VernacProof (Some ta, l)) }
63 | IDENT "Proof"; IDENT "using"; l = G_vernac.section_subset_expr;
64 "with"; ta = generic_tactic ->
65 { Vernacexpr.VernacSynPure (Vernacexpr.VernacProof (Some ta,Some l)) }
66 | IDENT "Proof" ; IDENT "Mode" ; mn = string -> { VernacSynterp (VernacProofMode mn) }
67 | IDENT "Proof"; c = lconstr -> { VernacSynPure (VernacExactProof c) }
68 | IDENT "Abort" -> { VernacSynPure VernacAbort }
69 | IDENT "Abort"; IDENT "All" -> { VernacSynPure VernacAbortAll }
70 | IDENT "Admitted" -> { VernacSynPure (VernacEndProof Admitted) }
71 | IDENT "Qed" -> { VernacSynPure (VernacEndProof (Proved (Opaque,None))) }
72 | IDENT "Save"; id = identref ->
73 { VernacSynPure (VernacEndProof (Proved (Opaque, Some id))) }
74 | IDENT "Defined" -> { VernacSynPure (VernacEndProof (Proved (Transparent,None))) }
75 | IDENT "Defined"; id=identref ->
76 { VernacSynPure (VernacEndProof (Proved (Transparent,Some id))) }
77 | IDENT "Restart" -> { VernacSynPure VernacRestart }
78 | IDENT "Undo" -> { VernacSynPure (VernacUndo 1) }
79 | IDENT "Undo"; n = natural -> { VernacSynPure (VernacUndo n) }
80 | IDENT "Undo"; IDENT "To"; n = natural -> { VernacSynPure (VernacUndoTo n) }
81 | IDENT "Focus" ->
82 { warn_deprecated_focus ~loc ();
83 VernacSynPure (VernacFocus None) }
84 | IDENT "Focus"; n = natural ->
85 { warn_deprecated_focus_n n ~loc;
86 VernacSynPure (VernacFocus (Some n)) }
87 | IDENT "Unfocus" ->
88 { warn_deprecated_unfocus ~loc ();
89 VernacSynPure VernacUnfocus }
90 | IDENT "Unfocused" -> { VernacSynPure VernacUnfocused }
91 | IDENT "Show" -> { VernacSynPure (VernacShow (ShowGoal OpenSubgoals)) }
92 | IDENT "Show"; n = natural -> { VernacSynPure (VernacShow (ShowGoal (NthGoal n))) }
93 | IDENT "Show"; id = qualid -> { VernacSynPure (VernacShow (ShowGoal (GoalId id))) }
94 | IDENT "Show"; IDENT "Existentials" -> { VernacSynPure (VernacShow ShowExistentials) }
95 | IDENT "Show"; IDENT "Universes" -> { VernacSynPure (VernacShow ShowUniverses) }
96 | IDENT "Show"; IDENT "Conjectures" -> { VernacSynPure (VernacShow ShowProofNames) }
97 | IDENT "Show"; IDENT "Proof" -> { VernacSynPure (VernacShow ShowProof) }
98 | IDENT "Show"; IDENT "Intro" -> { VernacSynPure (VernacShow (ShowIntros false)) }
99 | IDENT "Show"; IDENT "Intros" -> { VernacSynPure (VernacShow (ShowIntros true)) }
100 | IDENT "Show"; IDENT "Match"; id = reference -> { VernacSynPure (VernacShow (ShowMatch id)) }
101 | IDENT "Guarded" -> { VernacSynPure VernacCheckGuard }
102 | IDENT "Validate"; IDENT "Proof" -> { VernacSynPure VernacValidateProof }
103 (* Hints for Auto and EAuto *)
104 | IDENT "Create"; IDENT "HintDb" ;
105 id = IDENT ; b = [ IDENT "discriminated" -> { true } | -> { false } ] ->
106 { VernacSynPure (VernacCreateHintDb (id, b)) }
107 | IDENT "Remove"; IDENT "Hints"; ids = LIST1 global; dbnames = opt_hintbases ->
108 { VernacSynPure (VernacRemoveHints (dbnames, ids)) }
109 | IDENT "Hint"; h = hint; dbnames = opt_hintbases ->
110 { VernacSynPure (VernacHints (dbnames, h)) }
111 ] ];
112 reference_or_constr:
113 [ [ r = global -> { HintsReference r }
114 | c = constr -> { HintsConstr c } ] ]
115 ;
116 hint:
117 [ [ IDENT "Resolve"; lc = LIST1 reference_or_constr; info = hint_info ->
118 { HintsResolve (List.map (fun x -> (info, true, x)) lc) }
119 | IDENT "Resolve"; "->"; lc = LIST1 global; n = OPT natural ->
120 { HintsResolveIFF (true, lc, n) }
121 | IDENT "Resolve"; "<-"; lc = LIST1 global; n = OPT natural ->
122 { HintsResolveIFF (false, lc, n) }
123 | IDENT "Immediate"; lc = LIST1 reference_or_constr -> { HintsImmediate lc }
124 | IDENT "Variables"; IDENT "Transparent" -> { HintsTransparency (HintsVariables, true) }
125 | IDENT "Variables"; IDENT "Opaque" -> { HintsTransparency (HintsVariables, false) }
126 | IDENT "Constants"; IDENT "Transparent" -> { HintsTransparency (HintsConstants, true) }
127 | IDENT "Constants"; IDENT "Opaque" -> { HintsTransparency (HintsConstants, false) }
128 | IDENT "Projections"; IDENT "Transparent" -> { HintsTransparency (HintsProjections, true) }
129 | IDENT "Projections"; IDENT "Opaque" -> { HintsTransparency (HintsProjections, false) }
130 | IDENT "Transparent"; lc = LIST1 global -> { HintsTransparency (HintsReferences lc, true) }
131 | IDENT "Opaque"; lc = LIST1 global -> { HintsTransparency (HintsReferences lc, false) }
132 | IDENT "Mode"; l = global; m = mode -> { HintsMode (l, m) }
133 | IDENT "Unfold"; lqid = LIST1 global -> { HintsUnfold lqid }
134 | IDENT "Constructors"; lc = LIST1 global -> { HintsConstructors lc }
135 | IDENT "Extern"; n = natural; c = OPT Constr.constr_pattern ; "=>";
136 tac = generic_tactic ->
137 { Vernacexpr.HintsExtern (n,c, tac) }
138 ] ]
139 ;
140 mode:
141 [ [ l = LIST1 [ "+" -> { ModeInput }
142 | "!" -> { ModeNoHeadEvar }
143 | "-" -> { ModeOutput } ] -> { l } ] ]
144 ;
145 END
146
147 VERNAC COMMAND EXTEND OptimizeProof
148 | ![ proof ] [ "Optimize" "Proof" ] => { Vernacextend.classify_as_proofstep } ->
149 { fun ~pstate -> Declare.Proof.compact pstate }
150 | [ "Optimize" "Heap" ] => { Vernacextend.classify_as_proofstep } ->
151 { Gc.compact () }
152 END