| 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 |
|
| 13 |
open Ltac_plugin |
| 14 |
open Sequent |
| 15 |
open Ground |
| 16 |
open Goptions |
| 17 |
open Tacticals |
| 18 |
open Tacinterp |
| 19 |
open Stdarg |
| 20 |
open Tacarg |
| 21 |
open Procq.Prim |
| 22 |
|
| 23 |
} |
| 24 |
|
| 25 |
DECLARE PLUGIN "rocq-runtime.plugins.firstorder" |
| 26 |
|
| 27 |
(* declaring search depth as a global option *) |
| 28 |
|
| 29 |
{ |
| 30 |
|
| 31 |
let { Goptions.get = ground_depth } = |
| 32 |
declare_nat_option_and_ref |
| 33 |
~key:["Firstorder";"Depth"] |
| 34 |
~value:3 |
| 35 |
() |
| 36 |
|
| 37 |
let (set_default_solver, default_solver, print_default_solver) = |
| 38 |
Tactic_option.declare_tactic_option "Firstorder default solver" |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
VERNAC COMMAND EXTEND Firstorder_Set_Solver CLASSIFIED AS SIDEFF |
| 43 |
| #[ locality = Tactic_option.tac_option_locality; ] [ "Set" "Firstorder" "Solver" generic_tactic(t) ] -> { |
| 44 |
set_default_solver |
| 45 |
locality |
| 46 |
(Gentactic.intern (Global.env()) t) |
| 47 |
} |
| 48 |
END |
| 49 |
|
| 50 |
VERNAC COMMAND EXTEND Firstorder_Print_Solver CLASSIFIED AS QUERY |
| 51 |
| [ "Print" "Firstorder" "Solver" ] -> { |
| 52 |
Feedback.msg_notice |
| 53 |
(Pp.(++) (Pp.str"Firstorder solver tactic is ") (print_default_solver ())) } |
| 54 |
END |
| 55 |
|
| 56 |
{ |
| 57 |
|
| 58 |
let gen_ground_tac ist taco ids bases = |
| 59 |
let flags = Ground.get_flags () in |
| 60 |
Proofview.tclOR begin |
| 61 |
Proofview.Goal.enter begin fun gl -> |
| 62 |
let solver= |
| 63 |
match taco with |
| 64 |
| Some tac -> tactic_of_value ist tac |
| 65 |
| None-> default_solver () |
| 66 |
in |
| 67 |
let startseq k = |
| 68 |
Proofview.Goal.enter begin fun gl -> |
| 69 |
let sigma = Proofview.Goal.sigma gl in |
| 70 |
let env = Proofview.Goal.env gl in |
| 71 |
let seq = empty_seq (ground_depth ()) in |
| 72 |
let seq, sigma = extend_with_ref_list ~flags env sigma ids seq in |
| 73 |
let seq, sigma = extend_with_auto_hints ~flags env sigma bases seq in |
| 74 |
tclTHEN (Proofview.Unsafe.tclEVARS sigma) (k seq) |
| 75 |
end |
| 76 |
in |
| 77 |
let () = |
| 78 |
if Tacinterp.get_debug()=Tactic_debug.DebugOn 0 |
| 79 |
then |
| 80 |
Feedback.msg_debug (Printer.Debug.pr_goal gl) |
| 81 |
in |
| 82 |
let result=ground_tac ~flags solver startseq in |
| 83 |
result |
| 84 |
end |
| 85 |
end |
| 86 |
(fun (e, info) -> Proofview.tclZERO ~info e) |
| 87 |
|
| 88 |
(* special for compatibility with Intuition |
| 89 |
|
| 90 |
let constant str = Rocqlib.get_constr str |
| 91 |
|
| 92 |
let defined_connectives=lazy |
| 93 |
[[],EvalConstRef (destConst (constant "core.not.type")); |
| 94 |
[],EvalConstRef (destConst (constant "core.iff.type"))] |
| 95 |
|
| 96 |
let normalize_evaluables= |
| 97 |
onAllHypsAndConcl |
| 98 |
(function |
| 99 |
None->unfold_in_concl (Lazy.force defined_connectives) |
| 100 |
| Some id-> |
| 101 |
unfold_in_hyp (Lazy.force defined_connectives) |
| 102 |
(Tacexpr.InHypType id)) *) |
| 103 |
|
| 104 |
open Ppconstr |
| 105 |
open Printer |
| 106 |
let pr_firstorder_using_raw _ _ _ = Pptactic.pr_auto_using pr_qualid |
| 107 |
let pr_firstorder_using_glob _ _ _ = Pptactic.pr_auto_using (Pputils.pr_or_var (fun x -> pr_global (snd x))) |
| 108 |
let pr_firstorder_using_typed _ _ _ = Pptactic.pr_auto_using pr_global |
| 109 |
|
| 110 |
} |
| 111 |
|
| 112 |
ARGUMENT EXTEND firstorder_using |
| 113 |
TYPED AS reference list |
| 114 |
PRINTED BY { pr_firstorder_using_typed } |
| 115 |
RAW_PRINTED BY { pr_firstorder_using_raw } |
| 116 |
GLOB_PRINTED BY { pr_firstorder_using_glob } |
| 117 |
| [ "using" ne_reference_list_sep(l,",") ] -> { l } |
| 118 |
| [ ] -> { [] } |
| 119 |
END |
| 120 |
|
| 121 |
TACTIC EXTEND firstorder |
| 122 |
| [ "firstorder" tactic_opt(t) firstorder_using(l) ] -> |
| 123 |
{ gen_ground_tac ist t l [] } |
| 124 |
| [ "firstorder" tactic_opt(t) "with" ne_preident_list(l) ] -> |
| 125 |
{ gen_ground_tac ist t [] l } |
| 126 |
| [ "firstorder" tactic_opt(t) firstorder_using(l) |
| 127 |
"with" ne_preident_list(l') ] -> |
| 128 |
{ gen_ground_tac ist t l l' } |
| 129 |
END |