| 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 |
(* |
| 12 |
Syntax for the subtac terms and types. |
| 13 |
Elaborated from correctness/psyntax.ml4 by Jean-Christophe Filliâtre *) |
| 14 |
|
| 15 |
DECLARE GLOBAL PLUGIN |
| 16 |
|
| 17 |
{ |
| 18 |
|
| 19 |
open Stdarg |
| 20 |
|
| 21 |
let (set_default_tactic, get_default_tactic, print_default_tactic) = |
| 22 |
Tactic_option.declare_tactic_option "Program tactic" |
| 23 |
|
| 24 |
let () = |
| 25 |
(* Delay to recover the tactic imperatively *) |
| 26 |
let tac = Proofview.tclBIND (Proofview.tclUNIT ()) begin fun () -> |
| 27 |
get_default_tactic () |
| 28 |
end |
| 29 |
in |
| 30 |
Declare.Obls.default_tactic := tac |
| 31 |
|
| 32 |
let with_tac f tac = |
| 33 |
let tac = Option.map (fun tac -> Gentactic.intern (Global.env()) tac) tac in |
| 34 |
f tac |
| 35 |
|
| 36 |
let interp_gen tac = |
| 37 |
Proofview.Goal.enter begin fun gl -> |
| 38 |
let tac = Gentactic.intern ~strict:false (Proofview.Goal.env gl) tac in |
| 39 |
Gentactic.interp tac |
| 40 |
end |
| 41 |
|
| 42 |
(* We define new entries for programs, with the use of this module |
| 43 |
* Subtac. These entries are named Subtac.<foo> |
| 44 |
*) |
| 45 |
|
| 46 |
let pr_withtac env sigma = let open Pp in function |
| 47 |
| None -> mt () |
| 48 |
| Some tac -> str "with" ++ spc () ++ Gentactic.print_raw env sigma tac |
| 49 |
|
| 50 |
let generic_tactic = Pvernac.Vernac_.generic_tactic |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
VERNAC ARGUMENT EXTEND withtac PRINTED BY { pr_withtac env sigma } |
| 55 |
| [ ] -> { None } |
| 56 |
| [ "with" generic_tactic(tac) ] -> { Some tac } |
| 57 |
END |
| 58 |
|
| 59 |
{ |
| 60 |
|
| 61 |
open Declare.Obls |
| 62 |
|
| 63 |
let obligation ~pm obl tac = with_tac (fun t -> obligation ~pm obl t) tac |
| 64 |
let next_obligation ~pm ?final obl tac = with_tac (fun t -> next_obligation ~pm ?final obl t) tac |
| 65 |
|
| 66 |
let classify_obbl _ = Vernacextend.(VtStartProof (Doesn'tGuaranteeOpacity,[])) |
| 67 |
|
| 68 |
} |
| 69 |
|
| 70 |
VERNAC COMMAND EXTEND Obligations CLASSIFIED BY { classify_obbl } STATE declare_program |
| 71 |
| [ "Obligation" natural(num) "of" identref(name) withtac(tac) ] -> |
| 72 |
{ obligation (num, Some name.CAst.v) tac } |
| 73 |
| [ "Obligation" natural(num) withtac(tac) ] -> |
| 74 |
{ obligation (num, None) tac } |
| 75 |
| [ "Next" "Obligation" "of" identref(name) withtac(tac) ] -> |
| 76 |
{ next_obligation (Some name.CAst.v) tac } |
| 77 |
| [ "Next" "Obligation" withtac(tac) ] -> { next_obligation None tac } |
| 78 |
| [ "Final" "Obligation" "of" identref(name) withtac(tac) ] -> |
| 79 |
{ next_obligation ~final:true (Some name.CAst.v) tac } |
| 80 |
| [ "Final" "Obligation" withtac(tac) ] -> { next_obligation ~final:true None tac } |
| 81 |
END |
| 82 |
|
| 83 |
VERNAC COMMAND EXTEND Solve_Obligations CLASSIFIED AS SIDEFF STATE program |
| 84 |
| [ "Solve" "Obligations" "of" identref(name) withtac(t) ] -> |
| 85 |
{ solve_obligations (Some name.CAst.v) (Option.map interp_gen t) } |
| 86 |
| [ "Solve" "Obligations" withtac(t) ] -> |
| 87 |
{ solve_obligations None (Option.map interp_gen t) } |
| 88 |
END |
| 89 |
|
| 90 |
VERNAC COMMAND EXTEND Solve_All_Obligations CLASSIFIED AS SIDEFF STATE program |
| 91 |
| [ "Solve" "All" "Obligations" withtac(t) ] -> |
| 92 |
{ solve_all_obligations (Option.map interp_gen t) } |
| 93 |
END |
| 94 |
|
| 95 |
VERNAC COMMAND EXTEND Admit_Obligations CLASSIFIED AS SIDEFF STATE program |
| 96 |
| [ "Admit" "Obligations" "of" identref(name) ] -> { admit_obligations (Some name.CAst.v) } |
| 97 |
| [ "Admit" "Obligations" ] -> { admit_obligations None } |
| 98 |
END |
| 99 |
|
| 100 |
VERNAC COMMAND EXTEND Set_Solver CLASSIFIED AS SIDEFF |
| 101 |
| #[ locality = Tactic_option.tac_option_locality; ] [ "Obligation" "Tactic" ":=" generic_tactic(t) ] -> { |
| 102 |
set_default_tactic |
| 103 |
locality |
| 104 |
(Gentactic.intern (Global.env()) t); |
| 105 |
} |
| 106 |
END |
| 107 |
|
| 108 |
VERNAC COMMAND EXTEND Show_Solver CLASSIFIED AS QUERY |
| 109 |
| [ "Show" "Obligation" "Tactic" ] -> { |
| 110 |
Feedback.msg_notice Pp.(str"Program obligation tactic is " ++ print_default_tactic ()) } |
| 111 |
END |
| 112 |
|
| 113 |
VERNAC COMMAND EXTEND Show_Obligations CLASSIFIED AS QUERY STATE read_program |
| 114 |
| [ "Obligations" "of" identref(name) ] -> { fun ~pm -> show_obligations ~pm (Some name.CAst.v) } |
| 115 |
| [ "Obligations" ] -> { fun ~pm -> show_obligations ~pm None } |
| 116 |
END |
| 117 |
|
| 118 |
VERNAC COMMAND EXTEND Show_Preterm CLASSIFIED AS QUERY STATE read_program |
| 119 |
| [ "Preterm" "of" identref(name) ] -> { fun ~pm -> Feedback.msg_notice (show_term ~pm (Some name.CAst.v)) } |
| 120 |
| [ "Preterm" ] -> { fun ~pm -> Feedback.msg_notice (show_term ~pm None) } |
| 121 |
END |