aboutsummaryrefslogtreecommitdiff
path: root/contrib/first-order/g_ground.ml4
blob: 95488265b5084d2a300eba3d279d52d64dc6ebb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(***********************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team    *)
(* <O___,, *        INRIA-Rocquencourt  &  LRI-CNRS-Orsay              *)
(*   \VV/  *************************************************************)
(*    //   *      This file is distributed under the terms of the      *)
(*         *       GNU Lesser General Public License Version 2.1       *)
(***********************************************************************)

(*i camlp4deps: "parsing/grammar.cma"  i*)

(* $Id$ *)

open Formula
open Sequent
open Ground
open Goptions
open Tactics
open Tacticals
open Term
open Names

(* declaring search depth as a global option *)

let ground_depth=ref 5

let _=
  let gdopt=
    { optsync=true;
      optname="Ground Depth";
      optkey=SecondaryTable("Ground","Depth"); 
      optread=(fun ()->Some !ground_depth); 
      optwrite=
   (function 
	None->ground_depth:=5
      |	Some i->ground_depth:=(max i 0))}
  in
    declare_int_option gdopt
      
let default_solver=(Tacinterp.interp <:tactic<Auto with *>>)
    
let fail_solver=tclFAIL 0 "GTauto failed"
		      
let gen_ground_tac flag taco l gl=
  let backup= !qflag in
    try
      qflag:=flag;
      let solver= 
	match taco with 
	    Some tac->tac
	  | None-> default_solver in
      let startseq=create_with_ref_list l !ground_depth in
      let result=ground_tac solver startseq gl in 
	qflag:=backup;result
    with e ->qflag:=backup;raise e

(* special for compatibility with old Intuition *)

let constant str = Coqlib.gen_constant "User" ["Init";"Logic"] str

let defined_connectives=lazy
  [[],EvalConstRef (destConst (constant "not"));
   [],EvalConstRef (destConst (constant "iff"))]

let normalize_evaluables=
  onAllClauses
    (function 
	 None->unfold_in_concl (Lazy.force defined_connectives)
       | Some id-> 
	   unfold_in_hyp (Lazy.force defined_connectives) 
	   (Tacexpr.InHypType id))

TACTIC EXTEND Ground
      |   [ "Ground" tactic(t) "with" ne_reference_list(l) ] -> 
	    [ gen_ground_tac true (Some (snd t)) l ]
      |   [ "Ground" tactic(t) ] -> 
	    [ gen_ground_tac true (Some (snd t)) [] ]
      |   [ "Ground" "with" ne_reference_list(l) ] -> 
	    [ gen_ground_tac true None l ]
      |   [ "Ground" ] ->
	    [ gen_ground_tac true None [] ]
END

TACTIC EXTEND GTauto   
  [ "GTauto" ] ->
     [ gen_ground_tac false (Some fail_solver) [] ]   
END

TACTIC EXTEND GIntuition
   ["GIntuition" tactic(t)] ->
     [ gen_ground_tac false 
	 (Some(tclTHEN normalize_evaluables (snd t))) [] ]
|  [ "GIntuition" ] ->
     [ gen_ground_tac false 
	 (Some (tclTHEN normalize_evaluables default_solver)) [] ] 
END