aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/cc/g_congruence.mlg4
-rw-r--r--plugins/extraction/big.ml76
-rw-r--r--plugins/extraction/common.ml7
-rw-r--r--plugins/extraction/common.mli1
-rw-r--r--plugins/extraction/dune2
-rw-r--r--plugins/extraction/ocaml.ml18
-rw-r--r--plugins/funind/functional_principles_proofs.ml13
-rw-r--r--plugins/funind/recdef.ml14
-rw-r--r--plugins/ltac/extratactics.mlg8
-rw-r--r--plugins/ltac/g_class.mlg2
-rw-r--r--plugins/ltac/g_ltac.mlg2
-rw-r--r--plugins/ltac/g_obligations.mlg12
-rw-r--r--plugins/ltac/pptactic.ml2
-rw-r--r--plugins/ltac/profile_ltac_tactics.mlg4
-rw-r--r--plugins/ltac/rewrite.ml2
-rw-r--r--plugins/ltac/tacinterp.ml76
-rw-r--r--plugins/micromega/certificate.ml5
-rw-r--r--plugins/micromega/sos.ml31
-rw-r--r--plugins/micromega/zify.ml11
-rw-r--r--plugins/nsatz/dune2
-rw-r--r--plugins/nsatz/ideal.ml6
-rw-r--r--plugins/nsatz/nsatz.ml81
-rw-r--r--plugins/nsatz/polynom.ml10
-rw-r--r--plugins/nsatz/polynom.mli4
-rw-r--r--plugins/omega/coq_omega.ml219
-rw-r--r--plugins/setoid_ring/newring.ml22
-rw-r--r--plugins/ssr/ssrcommon.ml4
-rw-r--r--plugins/ssr/ssrelim.ml38
-rw-r--r--plugins/ssr/ssrequality.ml2
-rw-r--r--plugins/ssr/ssrparser.mlg8
-rw-r--r--plugins/ssr/ssrvernac.mlg2
-rw-r--r--plugins/syntax/float_syntax.ml10
-rw-r--r--plugins/syntax/g_numeral.mlg12
-rw-r--r--plugins/syntax/r_syntax.ml49
34 files changed, 418 insertions, 341 deletions
diff --git a/plugins/cc/g_congruence.mlg b/plugins/cc/g_congruence.mlg
index 3920e3da75..2c91901477 100644
--- a/plugins/cc/g_congruence.mlg
+++ b/plugins/cc/g_congruence.mlg
@@ -22,9 +22,9 @@ DECLARE PLUGIN "cc_plugin"
TACTIC EXTEND cc
| [ "congruence" ] -> { congruence_tac 1000 [] }
-| [ "congruence" integer(n) ] -> { congruence_tac n [] }
+| [ "congruence" natural(n) ] -> { congruence_tac n [] }
| [ "congruence" "with" ne_constr_list(l) ] -> { congruence_tac 1000 l }
- |[ "congruence" integer(n) "with" ne_constr_list(l) ] ->
+| [ "congruence" natural(n) "with" ne_constr_list(l) ] ->
{ congruence_tac n l }
END
diff --git a/plugins/extraction/big.ml b/plugins/extraction/big.ml
index 19055fd425..7228f709f1 100644
--- a/plugins/extraction/big.ml
+++ b/plugins/extraction/big.ml
@@ -8,63 +8,61 @@
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
-(** [Big] : a wrapper around ocaml [Big_int] with nicer names,
+(** [Big] : a wrapper around ocaml [ZArith] with nicer names,
and a few extraction-specific constructions *)
-(** To be linked with [nums.(cma|cmxa)] *)
+(** To be linked with [zarith] *)
-open Big_int
-
-type big_int = Big_int.big_int
+type big_int = Z.t
(** The type of big integers. *)
-let zero = zero_big_int
+let zero = Z.zero
(** The big integer [0]. *)
-let one = unit_big_int
+let one = Z.one
(** The big integer [1]. *)
-let two = big_int_of_int 2
+let two = Z.of_int 2
(** The big integer [2]. *)
(** {6 Arithmetic operations} *)
-let opp = minus_big_int
+let opp = Z.neg
(** Unary negation. *)
-let abs = abs_big_int
+let abs = Z.abs
(** Absolute value. *)
-let add = add_big_int
+let add = Z.add
(** Addition. *)
-let succ = succ_big_int
- (** Successor (add 1). *)
+let succ = Z.succ
+(** Successor (add 1). *)
-let add_int = add_int_big_int
+let add_int = Z.add
(** Addition of a small integer to a big integer. *)
-let sub = sub_big_int
+let sub = Z.sub
(** Subtraction. *)
-let pred = pred_big_int
+let pred = Z.pred
(** Predecessor (subtract 1). *)
-let mult = mult_big_int
+let mult = Z.mul
(** Multiplication of two big integers. *)
-let mult_int = mult_int_big_int
+let mult_int x y = Z.mul (Z.of_int x) y
(** Multiplication of a big integer by a small integer *)
-let square = square_big_int
+let square x = Z.mul x x
(** Return the square of the given big integer *)
-let sqrt = sqrt_big_int
+let sqrt = Z.sqrt
(** [sqrt_big_int a] returns the integer square root of [a],
that is, the largest big integer [r] such that [r * r <= a].
Raise [Invalid_argument] if [a] is negative. *)
-let quomod = quomod_big_int
+let quomod = Z.div_rem
(** Euclidean division of two big integers.
The first part of the result is the quotient,
the second part is the remainder.
@@ -72,18 +70,18 @@ let quomod = quomod_big_int
[a = q * b + r] and [0 <= r < |b|].
Raise [Division_by_zero] if the divisor is zero. *)
-let div = div_big_int
+let div = Z.div
(** Euclidean quotient of two big integers.
This is the first result [q] of [quomod_big_int] (see above). *)
-let modulo = mod_big_int
+let modulo = Z.(mod)
(** Euclidean modulus of two big integers.
This is the second result [r] of [quomod_big_int] (see above). *)
-let gcd = gcd_big_int
+let gcd = Z.gcd
(** Greatest common divisor of two big integers. *)
-let power = power_big_int_positive_big_int
+let power = Z.pow
(** Exponentiation functions. Return the big integer
representing the first argument [a] raised to the power [b]
(the second argument). Depending
@@ -92,45 +90,45 @@ let power = power_big_int_positive_big_int
(** {6 Comparisons and tests} *)
-let sign = sign_big_int
+let sign = Z.sign
(** Return [0] if the given big integer is zero,
[1] if it is positive, and [-1] if it is negative. *)
-let compare = compare_big_int
+let compare = Z.compare
(** [compare_big_int a b] returns [0] if [a] and [b] are equal,
[1] if [a] is greater than [b], and [-1] if [a] is smaller
than [b]. *)
-let eq = eq_big_int
-let le = le_big_int
-let ge = ge_big_int
-let lt = lt_big_int
-let gt = gt_big_int
+let eq = Z.equal
+let le = Z.leq
+let ge = Z.geq
+let lt = Z.lt
+let gt = Z.gt
(** Usual boolean comparisons between two big integers. *)
-let max = max_big_int
+let max = Z.max
(** Return the greater of its two arguments. *)
-let min = min_big_int
+let min = Z.min
(** Return the smaller of its two arguments. *)
(** {6 Conversions to and from strings} *)
-let to_string = string_of_big_int
+let to_string = Z.to_string
(** Return the string representation of the given big integer,
in decimal (base 10). *)
-let of_string = big_int_of_string
+let of_string = Z.of_string
(** Convert a string to a big integer, in decimal.
The string consists of an optional [-] or [+] sign,
followed by one or several decimal digits. *)
(** {6 Conversions to and from other numerical types} *)
-let of_int = big_int_of_int
+let of_int = Z.of_int
(** Convert a small integer to a big integer. *)
-let is_int = is_int_big_int
+let is_int = Z.fits_int
(** Test whether the given big integer is small enough to
be representable as a small integer (type [int])
without loss of precision. On a 32-bit platform,
@@ -139,7 +137,7 @@ let is_int = is_int_big_int
[is_int_big_int a] returns [true] if and only if
[a] is between -2{^62} and 2{^62}-1. *)
-let to_int = int_of_big_int
+let to_int = Z.to_int
(** Convert a big integer to a small integer (type [int]).
Raises [Failure "int_of_big_int"] if the big integer
is not representable as a small integer. *)
diff --git a/plugins/extraction/common.ml b/plugins/extraction/common.ml
index 4a41f4c890..d215a7673d 100644
--- a/plugins/extraction/common.ml
+++ b/plugins/extraction/common.ml
@@ -604,6 +604,13 @@ let pp_global k r =
| Haskell -> if modular () then pp_haskell_gen k mp rls else s
| Ocaml -> pp_ocaml_gen k mp rls (Some l)
+(* Main name printing function for declaring a reference *)
+
+let pp_global_name k r =
+ let ls = ref_renaming (k,r) in
+ assert (List.length ls > 1);
+ List.hd ls
+
(* The next function is used only in Ocaml extraction...*)
let pp_module mp =
diff --git a/plugins/extraction/common.mli b/plugins/extraction/common.mli
index 0bd9efd255..a482cfc03d 100644
--- a/plugins/extraction/common.mli
+++ b/plugins/extraction/common.mli
@@ -55,6 +55,7 @@ val opened_libraries : unit -> ModPath.t list
type kind = Term | Type | Cons | Mod
val pp_global : kind -> GlobRef.t -> string
+val pp_global_name : kind -> GlobRef.t -> string
val pp_module : ModPath.t -> string
val top_visible_mp : unit -> ModPath.t
diff --git a/plugins/extraction/dune b/plugins/extraction/dune
index 0c01dcd488..d9d675fe6a 100644
--- a/plugins/extraction/dune
+++ b/plugins/extraction/dune
@@ -2,6 +2,6 @@
(name extraction_plugin)
(public_name coq.plugins.extraction)
(synopsis "Coq's extraction plugin")
- (libraries num coq.plugins.ltac))
+ (libraries coq.plugins.ltac))
(coq.pp (modules g_extraction))
diff --git a/plugins/extraction/ocaml.ml b/plugins/extraction/ocaml.ml
index 088405da5d..6425c3111e 100644
--- a/plugins/extraction/ocaml.ml
+++ b/plugins/extraction/ocaml.ml
@@ -99,6 +99,8 @@ let str_global k r =
let pp_global k r = str (str_global k r)
+let pp_global_name k r = str (Common.pp_global k r)
+
let pp_modname mp = str (Common.pp_module mp)
(* grammar from OCaml 4.06 manual, "Prefix and infix symbols" *)
@@ -451,7 +453,7 @@ let pp_val e typ =
let pp_Dfix (rv,c,t) =
let names = Array.map
- (fun r -> if is_inline_custom r then mt () else pp_global Term r) rv
+ (fun r -> if is_inline_custom r then mt () else pp_global_name Term r) rv
in
let rec pp init i =
if i >= Array.length rv then mt ()
@@ -504,7 +506,7 @@ let pp_logical_ind packet =
fnl ()
let pp_singleton kn packet =
- let name = pp_global Type (GlobRef.IndRef (kn,0)) in
+ let name = pp_global_name Type (GlobRef.IndRef (kn,0)) in
let l = rename_tvars keywords packet.ip_vars in
hov 2 (str "type " ++ pp_parameters l ++ name ++ str " =" ++ spc () ++
pp_type false l (List.hd packet.ip_types.(0)) ++ fnl () ++
@@ -513,7 +515,7 @@ let pp_singleton kn packet =
let pp_record kn fields ip_equiv packet =
let ind = GlobRef.IndRef (kn,0) in
- let name = pp_global Type ind in
+ let name = pp_global_name Type ind in
let fieldnames = pp_fields ind fields in
let l = List.combine fieldnames packet.ip_types.(0) in
let pl = rename_tvars keywords packet.ip_vars in
@@ -535,7 +537,7 @@ let pp_ind co kn ind =
let nextkwd = fnl () ++ str "and " in
let names =
Array.mapi (fun i p -> if p.ip_logical then mt () else
- pp_global Type (GlobRef.IndRef (kn,i)))
+ pp_global_name Type (GlobRef.IndRef (kn,i)))
ind.ind_packets
in
let cnames =
@@ -575,7 +577,7 @@ let pp_decl = function
| Dterm (r,_,_) when is_inline_custom r -> mt ()
| Dind (kn,i) -> pp_mind kn i
| Dtype (r, l, t) ->
- let name = pp_global Type r in
+ let name = pp_global_name Type r in
let l = rename_tvars keywords l in
let ids, def =
try
@@ -592,7 +594,7 @@ let pp_decl = function
if is_custom r then str (" = " ^ find_custom r)
else pp_function (empty_env ()) a
in
- let name = pp_global Term r in
+ let name = pp_global_name Term r in
pp_val name t ++ hov 0 (str "let " ++ name ++ def ++ mt ())
| Dfix (rv,defs,typs) ->
pp_Dfix (rv,defs,typs)
@@ -603,10 +605,10 @@ let pp_spec = function
| Sind (kn,i) -> pp_mind kn i
| Sval (r,t) ->
let def = pp_type false [] t in
- let name = pp_global Term r in
+ let name = pp_global_name Term r in
hov 2 (str "val " ++ name ++ str " :" ++ spc () ++ def)
| Stype (r,vl,ot) ->
- let name = pp_global Type r in
+ let name = pp_global_name Type r in
let l = rename_tvars keywords vl in
let ids, def =
try
diff --git a/plugins/funind/functional_principles_proofs.ml b/plugins/funind/functional_principles_proofs.ml
index 743afe4177..72e6006b7e 100644
--- a/plugins/funind/functional_principles_proofs.ml
+++ b/plugins/funind/functional_principles_proofs.ml
@@ -483,7 +483,10 @@ let treat_new_case ptes_infos nb_prod continue_tac term dyn_infos g =
(Proofview.V82.of_tactic
(intro_avoiding (Id.Set.of_list dyn_infos.rec_hyps)))
; (* Then the equation itself *)
- Proofview.V82.of_tactic (intro_using heq_id)
+ Proofview.V82.of_tactic
+ (intro_using_then heq_id
+ (* we get the fresh name with onLastHypId *)
+ (fun _ -> Proofview.tclUNIT ()))
; onLastHypId (fun heq_id ->
tclTHENLIST
[ (* Then the new hypothesis *)
@@ -1113,16 +1116,18 @@ let prove_princ_for_struct (evd : Evd.evar_map ref) interactive_proof fun_num
in
let first_tac : tactic =
(* every operations until fix creations *)
+ (* names are already refreshed *)
tclTHENLIST
[ observe_tac "introducing params"
(Proofview.V82.of_tactic
- (intros_using (List.rev_map id_of_decl princ_info.params)))
+ (intros_mustbe_force (List.rev_map id_of_decl princ_info.params)))
; observe_tac "introducing predictes"
(Proofview.V82.of_tactic
- (intros_using (List.rev_map id_of_decl princ_info.predicates)))
+ (intros_mustbe_force
+ (List.rev_map id_of_decl princ_info.predicates)))
; observe_tac "introducing branches"
(Proofview.V82.of_tactic
- (intros_using (List.rev_map id_of_decl princ_info.branches)))
+ (intros_mustbe_force (List.rev_map id_of_decl princ_info.branches)))
; observe_tac "building fixes" mk_fixes ]
in
let intros_after_fixes : tactic =
diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml
index 253c95fa67..066ade07d2 100644
--- a/plugins/funind/recdef.ml
+++ b/plugins/funind/recdef.ml
@@ -414,7 +414,8 @@ let treat_case forbid_new_ids to_intros finalize_tac nb_lam e infos : tactic =
observe_tclTHENLIST
(fun _ _ -> str "treat_case1")
[ h_intros (List.rev rev_ids)
- ; Proofview.V82.of_tactic (intro_using teq_id)
+ ; Proofview.V82.of_tactic
+ (intro_using_then teq_id (fun _ -> Proofview.tclUNIT ()))
; onLastHypId (fun heq ->
observe_tclTHENLIST
(fun _ _ -> str "treat_case2")
@@ -601,7 +602,11 @@ let rec destruct_bounds_aux infos (bound, hyple, rechyps) lbounds g =
(Proofview.V82.of_tactic (simplest_case (mkVar id)))
[ observe_tclTHENLIST
(fun _ _ -> str "")
- [ Proofview.V82.of_tactic (intro_using h_id)
+ [ Proofview.V82.of_tactic
+ (intro_using_then h_id
+ (* We don't care about the refreshed name,
+ accessed only through auto? *)
+ (fun _ -> Proofview.tclUNIT ()))
; Proofview.V82.of_tactic
(simplest_elim
(mkApp (delayed_force lt_n_O, [|s_max|])))
@@ -865,7 +870,10 @@ let terminate_app_rec (f, args) expr_info continuation_tac _ g =
(simplest_elim (mkApp (mkVar expr_info.ih, Array.of_list args))))
[ observe_tclTHENLIST
(fun _ _ -> str "terminate_app_rec2")
- [ Proofview.V82.of_tactic (intro_using rec_res_id)
+ [ Proofview.V82.of_tactic
+ (intro_using_then rec_res_id
+ (* refreshed name gotten from onNthHypId *)
+ (fun _ -> Proofview.tclUNIT ()))
; Proofview.V82.of_tactic intro
; onNthHypId 1 (fun v_bound ->
onNthHypId 2 (fun v ->
diff --git a/plugins/ltac/extratactics.mlg b/plugins/ltac/extratactics.mlg
index 66c72a30a2..4f20e5a800 100644
--- a/plugins/ltac/extratactics.mlg
+++ b/plugins/ltac/extratactics.mlg
@@ -43,7 +43,7 @@ DECLARE PLUGIN "ltac_plugin"
(**********************************************************************)
(* replace, discriminate, injection, simplify_eq *)
-(* cutrewrite, dependent rewrite *)
+(* dependent rewrite *)
let with_delayed_uconstr ist c tac =
let flags = {
@@ -203,12 +203,6 @@ TACTIC EXTEND dependent_rewrite
-> { rewriteInHyp b c id }
END
-TACTIC EXTEND cut_rewrite
-| [ "cutrewrite" orient(b) constr(eqn) ] -> { cutRewriteInConcl b eqn }
-| [ "cutrewrite" orient(b) constr(eqn) "in" hyp(id) ]
- -> { cutRewriteInHyp b eqn id }
-END
-
(**********************************************************************)
(* Decompose *)
diff --git a/plugins/ltac/g_class.mlg b/plugins/ltac/g_class.mlg
index 35c90444b1..8d197e6056 100644
--- a/plugins/ltac/g_class.mlg
+++ b/plugins/ltac/g_class.mlg
@@ -77,7 +77,7 @@ END
(* true = All transparent, false = Opaque if possible *)
VERNAC COMMAND EXTEND Typeclasses_Settings CLASSIFIED AS SIDEFF
- | [ "Typeclasses" "eauto" ":=" debug(d) eauto_search_strategy(s) int_opt(depth) ] -> {
+ | [ "Typeclasses" "eauto" ":=" debug(d) eauto_search_strategy(s) integer_opt(depth) ] -> {
set_typeclasses_debug d;
Option.iter set_typeclasses_strategy s;
set_typeclasses_depth depth
diff --git a/plugins/ltac/g_ltac.mlg b/plugins/ltac/g_ltac.mlg
index 114acaa412..78cde2cde8 100644
--- a/plugins/ltac/g_ltac.mlg
+++ b/plugins/ltac/g_ltac.mlg
@@ -271,7 +271,7 @@ GRAMMAR EXTEND Gram
message_token:
[ [ id = identref -> { MsgIdent id }
| s = STRING -> { MsgString s }
- | n = integer -> { MsgInt n } ] ]
+ | n = natural -> { MsgInt n } ] ]
;
ltac_def_kind:
diff --git a/plugins/ltac/g_obligations.mlg b/plugins/ltac/g_obligations.mlg
index fa176482bf..a6673699af 100644
--- a/plugins/ltac/g_obligations.mlg
+++ b/plugins/ltac/g_obligations.mlg
@@ -88,13 +88,13 @@ let classify_obbl _ = Vernacextend.(VtStartProof (Doesn'tGuaranteeOpacity,[]))
}
VERNAC COMMAND EXTEND Obligations CLASSIFIED BY { classify_obbl } STATE declare_program
-| [ "Obligation" integer(num) "of" ident(name) ":" lglob(t) withtac(tac) ] ->
+| [ "Obligation" natural(num) "of" ident(name) ":" lglob(t) withtac(tac) ] ->
{ obligation (num, Some name, Some t) tac }
-| [ "Obligation" integer(num) "of" ident(name) withtac(tac) ] ->
+| [ "Obligation" natural(num) "of" ident(name) withtac(tac) ] ->
{ obligation (num, Some name, None) tac }
-| [ "Obligation" integer(num) ":" lglob(t) withtac(tac) ] ->
+| [ "Obligation" natural(num) ":" lglob(t) withtac(tac) ] ->
{ obligation (num, None, Some t) tac }
-| [ "Obligation" integer(num) withtac(tac) ] ->
+| [ "Obligation" natural(num) withtac(tac) ] ->
{ obligation (num, None, None) tac }
| [ "Next" "Obligation" "of" ident(name) withtac(tac) ] ->
{ next_obligation (Some name) tac }
@@ -102,9 +102,9 @@ VERNAC COMMAND EXTEND Obligations CLASSIFIED BY { classify_obbl } STATE declare_
END
VERNAC COMMAND EXTEND Solve_Obligation CLASSIFIED AS SIDEFF STATE program
-| [ "Solve" "Obligation" integer(num) "of" ident(name) "with" tactic(t) ] ->
+| [ "Solve" "Obligation" natural(num) "of" ident(name) "with" tactic(t) ] ->
{ try_solve_obligation num (Some name) (Some (Tacinterp.interp t)) }
-| [ "Solve" "Obligation" integer(num) "with" tactic(t) ] ->
+| [ "Solve" "Obligation" natural(num) "with" tactic(t) ] ->
{ try_solve_obligation num None (Some (Tacinterp.interp t)) }
END
diff --git a/plugins/ltac/pptactic.ml b/plugins/ltac/pptactic.ml
index 6233807016..f69fe064a7 100644
--- a/plugins/ltac/pptactic.ml
+++ b/plugins/ltac/pptactic.ml
@@ -831,7 +831,7 @@ let pr_goal_selector ~toplevel s =
++ pr_non_empty_arg (pr_clauses (Some true) pr.pr_name) h
)
| TacChange (check,op,c,h) ->
- let name = if check then "change_no_check" else "change" in
+ let name = if check then "change" else "change_no_check" in
hov 1 (
primitive name ++ brk (1,1)
++ (
diff --git a/plugins/ltac/profile_ltac_tactics.mlg b/plugins/ltac/profile_ltac_tactics.mlg
index eb9d9cbdce..e5309ea441 100644
--- a/plugins/ltac/profile_ltac_tactics.mlg
+++ b/plugins/ltac/profile_ltac_tactics.mlg
@@ -55,7 +55,7 @@ END
TACTIC EXTEND show_ltac_profile
| [ "show" "ltac" "profile" ] -> { tclSHOW_PROFILE ~cutoff:!Flags.profile_ltac_cutoff }
-| [ "show" "ltac" "profile" "cutoff" int(n) ] -> { tclSHOW_PROFILE ~cutoff:(float_of_int n) }
+| [ "show" "ltac" "profile" "cutoff" integer(n) ] -> { tclSHOW_PROFILE ~cutoff:(float_of_int n) }
| [ "show" "ltac" "profile" string(s) ] -> { tclSHOW_PROFILE_TACTIC s }
END
@@ -74,7 +74,7 @@ END
VERNAC COMMAND EXTEND ShowLtacProfile CLASSIFIED AS QUERY
| [ "Show" "Ltac" "Profile" ] -> { print_results ~cutoff:!Flags.profile_ltac_cutoff }
-| [ "Show" "Ltac" "Profile" "CutOff" int(n) ] -> { print_results ~cutoff:(float_of_int n) }
+| [ "Show" "Ltac" "Profile" "CutOff" integer(n) ] -> { print_results ~cutoff:(float_of_int n) }
END
VERNAC COMMAND EXTEND ShowLtacProfileTactic CLASSIFIED AS QUERY
diff --git a/plugins/ltac/rewrite.ml b/plugins/ltac/rewrite.ml
index fb149071c9..a1dbf9a439 100644
--- a/plugins/ltac/rewrite.ml
+++ b/plugins/ltac/rewrite.ml
@@ -546,7 +546,7 @@ let rewrite_core_unif_flags = {
Unification.check_applied_meta_types = true;
Unification.use_pattern_unification = true;
Unification.use_meta_bound_pattern_unification = true;
- Unification.allowed_evars = Unification.AllowAll;
+ Unification.allowed_evars = Evarsolve.AllowedEvars.all;
Unification.restrict_conv_on_strict_subterms = false;
Unification.modulo_betaiota = false;
Unification.modulo_eta = true;
diff --git a/plugins/ltac/tacinterp.ml b/plugins/ltac/tacinterp.ml
index fdebe14a23..2258201c22 100644
--- a/plugins/ltac/tacinterp.ml
+++ b/plugins/ltac/tacinterp.ml
@@ -161,27 +161,45 @@ let catching_error call_trace fail (e, info) =
fail located_exc
end
-let update_loc ?loc (e, info) =
- (e, Option.cata (Loc.add_loc info) info loc)
+let update_loc loc use_finer (e, info as e') =
+ match loc with
+ | Some loc ->
+ if use_finer then
+ (* ensure loc if there is none *)
+ match Loc.get_loc info with
+ | None -> (e, Loc.add_loc info loc)
+ | _ -> (e, info)
+ else
+ (* override loc (because loc refers to inside of Ltac functions) *)
+ (e, Loc.add_loc info loc)
+ | None -> e'
-let catch_error ?loc call_trace f x =
+let catch_error_with_trace_loc loc use_finer call_trace f x =
try f x
with e when CErrors.noncritical e ->
let e = Exninfo.capture e in
- let e = update_loc ?loc e in
+ let e = update_loc loc use_finer e in
catching_error call_trace Exninfo.iraise e
-let catch_error_loc ?loc tac =
- Proofview.tclOR tac (fun exn ->
- let (e, info) = update_loc ?loc exn in
+let catch_error_loc loc use_finer tac =
+ Proofview.tclORELSE tac (fun exn ->
+ let (e, info) = update_loc loc use_finer exn in
Proofview.tclZERO ~info e)
-let wrap_error ?loc tac k =
+let wrap_error tac k =
+ if is_traced () then Proofview.tclORELSE tac k else tac
+
+let wrap_error_loc loc use_finer tac k =
if is_traced () then Proofview.tclORELSE tac k
- else catch_error_loc ?loc tac
+ else catch_error_loc loc use_finer tac
-let catch_error_tac ?loc call_trace tac =
- wrap_error ?loc
+let catch_error_tac call_trace tac =
+ wrap_error
+ tac
+ (catching_error call_trace (fun (e, info) -> Proofview.tclZERO ~info e))
+
+let catch_error_tac_loc loc use_finer call_trace tac =
+ wrap_error_loc loc use_finer
tac
(catching_error call_trace (fun (e, info) -> Proofview.tclZERO ~info e))
@@ -553,7 +571,7 @@ let interp_gen kind ist pattern_mode flags env sigma c =
let loc = loc_of_glob_constr term in
let trace = push_trace (loc,LtacConstrInterp (term,vars)) ist in
let (evd,c) =
- catch_error ?loc trace (understand_ltac flags env sigma vars kind) term
+ catch_error_with_trace_loc loc true trace (understand_ltac flags env sigma vars kind) term
in
(* spiwack: to avoid unnecessary modifications of tacinterp, as this
function already use effect, I call [run] hoping it doesn't mess
@@ -1066,12 +1084,12 @@ let rec val_interp ist ?(appl=UnnamedAppl) (tac:glob_tactic_expr) : Val.t Ftacti
| _ -> value_interp ist >>= fun v -> return (name_vfun appl v)
-and eval_tactic ist tac : unit Proofview.tactic = match tac with
+and eval_tactic_ist ist tac : unit Proofview.tactic = match tac with
| TacAtom {loc;v=t} ->
let call = LtacAtomCall t in
let trace = push_trace(loc,call) ist in
Profile_ltac.do_profile "eval_tactic:2" trace
- (catch_error_tac ?loc trace (interp_atomic ist t))
+ (catch_error_tac_loc loc true trace (interp_atomic ist t))
| TacFun _ | TacLetIn _ | TacMatchGoal _ | TacMatch _ -> interp_tactic ist tac
| TacId [] -> Proofview.tclLIFT (db_breakpoint (curr_debug ist) [])
| TacId s ->
@@ -1145,7 +1163,7 @@ and eval_tactic ist tac : unit Proofview.tactic = match tac with
| TacFirst l -> Tacticals.New.tclFIRST (List.map (interp_tactic ist) l)
| TacSolve l -> Tacticals.New.tclSOLVE (List.map (interp_tactic ist) l)
| TacComplete tac -> Tacticals.New.tclCOMPLETE (interp_tactic ist tac)
- | TacArg a -> interp_tactic ist (TacArg a)
+ | TacArg a -> Ftactic.run (val_interp ist tac) (fun v -> catch_error_loc a.CAst.loc false (tactic_of_value ist v))
| TacSelect (sel, tac) -> Tacticals.New.tclSELECT sel (interp_tactic ist tac)
(* For extensions *)
| TacAlias {loc; v=(s,l)} ->
@@ -1162,7 +1180,7 @@ and eval_tactic ist tac : unit Proofview.tactic = match tac with
; poly
; extra = TacStore.set ist.extra f_trace trace } in
val_interp ist alias.Tacenv.alias_body >>= fun v ->
- Ftactic.lift (catch_error_loc ?loc (tactic_of_value ist v))
+ Ftactic.lift (catch_error_loc loc false (tactic_of_value ist v))
in
let tac =
Ftactic.with_env interp_vars >>= fun (env, lr) ->
@@ -1191,7 +1209,7 @@ and eval_tactic ist tac : unit Proofview.tactic = match tac with
let args = Ftactic.List.map_right (fun a -> interp_tacarg ist a) l in
let tac args =
let name _ _ = Pptactic.pr_extend (fun v -> print_top_val () v) 0 opn args in
- Proofview.Trace.name_tactic name (catch_error_tac ?loc trace (tac args ist))
+ Proofview.Trace.name_tactic name (catch_error_tac_loc loc false trace (tac args ist))
in
Ftactic.run args tac
@@ -1225,7 +1243,7 @@ and interp_ltac_reference ?loc' mustbetac ist r : Val.t Ftactic.t =
let ist = { lfun = Id.Map.empty; poly; extra } in
let appl = GlbAppl[r,[]] in
Profile_ltac.do_profile "interp_ltac_reference" trace ~count_call:false
- (val_interp ~appl ist (Tacenv.interp_ltac r))
+ (catch_error_tac_loc loc false trace (val_interp ~appl ist (Tacenv.interp_ltac r)))
and interp_tacarg ist arg : Val.t Ftactic.t =
match arg with
@@ -1294,7 +1312,7 @@ and interp_app loc ist fv largs : Val.t Ftactic.t =
; extra = TacStore.set ist.extra f_trace []
} in
Profile_ltac.do_profile "interp_app" trace ~count_call:false
- (catch_error_tac ?loc trace (val_interp ist body)) >>= fun v ->
+ (catch_error_tac_loc loc false trace (val_interp ist body)) >>= fun v ->
Ftactic.return (name_vfun (push_appl appl largs) v)
end
begin fun (e, info) ->
@@ -1341,7 +1359,7 @@ and tactic_of_value ist vle =
lfun = lfun;
poly;
extra = TacStore.set ist.extra f_trace []; } in
- let tac = name_if_glob appl (eval_tactic ist t) in
+ let tac = name_if_glob appl (eval_tactic_ist ist t) in
Profile_ltac.do_profile "tactic_of_value" trace (catch_error_tac trace tac)
| VFun (appl,_,vmap,vars,_) ->
let tactic_nm =
@@ -1428,7 +1446,7 @@ and interp_match_success ist { Tactic_matching.subst ; context ; terms ; lhs } =
; poly
; extra = TacStore.set ist.extra f_trace trace
} in
- let tac = eval_tactic ist t in
+ let tac = eval_tactic_ist ist t in
let dummy = VFun (appl,extract_trace ist, Id.Map.empty, [], TacId []) in
catch_error_tac trace (tac <*> Ftactic.return (of_tacvalue dummy))
| _ -> Ftactic.return v
@@ -1909,11 +1927,11 @@ let default_ist () =
let eval_tactic t =
Proofview.tclUNIT () >>= fun () -> (* delay for [default_ist] *)
Proofview.tclLIFT db_initialize <*>
- interp_tactic (default_ist ()) t
+ eval_tactic_ist (default_ist ()) t
let eval_tactic_ist ist t =
Proofview.tclLIFT db_initialize <*>
- interp_tactic ist t
+ eval_tactic_ist ist t
(** FFI *)
@@ -1959,7 +1977,7 @@ let interp_tac_gen lfun avoid_ids debug t =
let extra = TacStore.set extra f_avoid_ids avoid_ids in
let ist = { lfun; poly; extra } in
let ltacvars = Id.Map.domain lfun in
- interp_tactic ist
+ eval_tactic_ist ist
(intern_pure_tactic { (Genintern.empty_glob_sign env) with ltacvars } t)
end
@@ -2010,6 +2028,9 @@ let () =
declare_uniform wit_int
let () =
+ declare_uniform wit_nat
+
+let () =
declare_uniform wit_bool
let () =
@@ -2076,7 +2097,7 @@ let () =
register_interp0 wit_tactic interp
let () =
- let interp ist tac = interp_tactic ist tac >>= fun () -> Ftactic.return () in
+ let interp ist tac = eval_tactic_ist ist tac >>= fun () -> Ftactic.return () in
register_interp0 wit_ltac interp
let () =
@@ -2103,12 +2124,11 @@ let _ =
let eval lfun poly env sigma ty tac =
let extra = TacStore.set TacStore.empty f_debug (get_debug ()) in
let ist = { lfun; poly; extra; } in
- let tac = interp_tactic ist tac in
+ let tac = eval_tactic_ist ist tac in
(* EJGA: We should also pass the proof name if desired, for now
poly seems like enough to get reasonable behavior in practice
*)
- let name, poly = Id.of_string "ltac_gen", poly in
- let name, poly = Id.of_string "ltac_gen", poly in
+ let name = Id.of_string "ltac_gen" in
let (c, sigma) = Proof.refine_by_tactic ~name ~poly env sigma ty tac in
(EConstr.of_constr c, sigma)
in
diff --git a/plugins/micromega/certificate.ml b/plugins/micromega/certificate.ml
index 9eeba614c7..148c1772bf 100644
--- a/plugins/micromega/certificate.ml
+++ b/plugins/micromega/certificate.ml
@@ -1020,10 +1020,11 @@ let lia (can_enum : bool) (prfdepth : int) sys =
p)
sys
end;
+ let bnd1 = bound_monomials sys in
let sys = subst sys in
- let bnd = bound_monomials sys in
+ let bnd2 = bound_monomials sys in
(* To deal with non-linear monomials *)
- let sys = bnd @ saturate_by_linear_equalities sys @ sys in
+ let sys = bnd1 @ bnd2 @ saturate_by_linear_equalities sys @ sys in
let sys' = List.map (fun ((p, o), prf) -> (cstr_of_poly (p, o), prf)) sys in
xlia (List.map fst sys) can_enum reduction_equations sys'
diff --git a/plugins/micromega/sos.ml b/plugins/micromega/sos.ml
index 2b04bb80e2..03d2a2d233 100644
--- a/plugins/micromega/sos.ml
+++ b/plugins/micromega/sos.ml
@@ -80,7 +80,7 @@ let is_zero (d, v) = match v with Empty -> true | _ -> false
(* Vectors. Conventionally indexed 1..n. *)
(* ------------------------------------------------------------------------- *)
-let vector_0 n = ((n, undefined) : vector)
+let vector_0 n : vector = (n, undefined)
let dim (v : vector) = fst v
let vector_const c n =
@@ -99,7 +99,7 @@ let vector_of_list l =
(* Matrices; again rows and columns indexed from 1. *)
(* ------------------------------------------------------------------------- *)
-let matrix_0 (m, n) = (((m, n), undefined) : matrix)
+let matrix_0 (m, n) : matrix = ((m, n), undefined)
let dimensions (m : matrix) = fst m
let matrix_cmul c (m : matrix) =
@@ -107,7 +107,7 @@ let matrix_cmul c (m : matrix) =
if c =/ Q.zero then matrix_0 (i, j)
else ((i, j), mapf (fun x -> c */ x) (snd m))
-let matrix_neg (m : matrix) = ((dimensions m, mapf Q.neg (snd m)) : matrix)
+let matrix_neg (m : matrix) : matrix = (dimensions m, mapf Q.neg (snd m))
let matrix_add (m1 : matrix) (m2 : matrix) =
let d1 = dimensions m1 and d2 = dimensions m2 in
@@ -138,7 +138,7 @@ let diagonal (v : vector) =
(* Monomials. *)
(* ------------------------------------------------------------------------- *)
let monomial_1 = (undefined : monomial)
-let monomial_var x = (x |=> 1 : monomial)
+let monomial_var x : monomial = x |=> 1
let (monomial_mul : monomial -> monomial -> monomial) =
combine ( + ) (fun x -> false)
@@ -152,16 +152,16 @@ let monomial_variables m = dom m
(* ------------------------------------------------------------------------- *)
let poly_0 = (undefined : poly)
let poly_isconst (p : poly) = foldl (fun a m c -> m = monomial_1 && a) true p
-let poly_var x = (monomial_var x |=> Q.one : poly)
+let poly_var x : poly = monomial_var x |=> Q.one
let poly_const c = if c =/ Q.zero then poly_0 else monomial_1 |=> c
let poly_cmul c (p : poly) =
if c =/ Q.zero then poly_0 else mapf (fun x -> c */ x) p
-let poly_neg (p : poly) = (mapf Q.neg p : poly)
+let poly_neg (p : poly) : poly = mapf Q.neg p
-let poly_add (p1 : poly) (p2 : poly) =
- (combine ( +/ ) (fun x -> x =/ Q.zero) p1 p2 : poly)
+let poly_add (p1 : poly) (p2 : poly) : poly =
+ combine ( +/ ) (fun x -> x =/ Q.zero) p1 p2
let poly_sub p1 p2 = poly_add p1 (poly_neg p2)
@@ -1191,14 +1191,13 @@ let sumofsquares_general_symmetry tool pol =
let diagents =
end_itlist equation_add (List.map (fun i -> apply allassig (i, i)) (1 -- n))
in
- let mk_matrix v =
- ( ( (n, n)
- , foldl
- (fun m (i, j) ass ->
- let c = tryapplyd ass v Q.zero in
- if c =/ Q.zero then m else ((j, i) |-> c) (((i, j) |-> c) m))
- undefined allassig )
- : matrix )
+ let mk_matrix v : matrix =
+ ( (n, n)
+ , foldl
+ (fun m (i, j) ass ->
+ let c = tryapplyd ass v Q.zero in
+ if c =/ Q.zero then m else ((j, i) |-> c) (((i, j) |-> c) m))
+ undefined allassig )
in
let mats = List.map mk_matrix qvars
and obj =
diff --git a/plugins/micromega/zify.ml b/plugins/micromega/zify.ml
index 4e1f9a66ac..fa29e6080e 100644
--- a/plugins/micromega/zify.ml
+++ b/plugins/micromega/zify.ml
@@ -1324,9 +1324,14 @@ let do_let tac (h : Constr.named_declaration) =
let env = Tacmach.New.pf_env gl in
let evd = Tacmach.New.project gl in
try
- ignore (get_injection env evd (EConstr.of_constr ty));
- tac id.Context.binder_name (EConstr.of_constr t)
- (EConstr.of_constr ty)
+ let x = id.Context.binder_name in
+ ignore
+ (let eq = Lazy.force eq in
+ find_option
+ (match_operator env evd eq
+ [|EConstr.of_constr ty; EConstr.mkVar x; EConstr.of_constr t|])
+ (HConstr.find_all eq !table_cache));
+ tac x (EConstr.of_constr t) (EConstr.of_constr ty)
with Not_found -> Tacticals.New.tclIDTAC)
let iter_let_aux tac =
diff --git a/plugins/nsatz/dune b/plugins/nsatz/dune
index b921c9c408..3b67ab3429 100644
--- a/plugins/nsatz/dune
+++ b/plugins/nsatz/dune
@@ -2,6 +2,6 @@
(name nsatz_plugin)
(public_name coq.plugins.nsatz)
(synopsis "Coq's nsatz solver plugin")
- (libraries num coq.plugins.ltac))
+ (libraries coq.plugins.ltac))
(coq.pp (modules g_nsatz))
diff --git a/plugins/nsatz/ideal.ml b/plugins/nsatz/ideal.ml
index 387145a5d0..cbc1773ede 100644
--- a/plugins/nsatz/ideal.ml
+++ b/plugins/nsatz/ideal.ml
@@ -153,8 +153,8 @@ end
module Make (P:Polynom.S) = struct
type coef = P.t
- let coef0 = P.of_num (Num.Int 0)
- let coef1 = P.of_num (Num.Int 1)
+ let coef0 = P.of_num Q.zero
+ let coef1 = P.of_num Q.one
let string_of_coef c = "["^(P.to_string c)^"]"
(***********************************************************************
@@ -305,7 +305,7 @@ let mult_t_pol a m p =
let map (b, m') = (P.multP a b, mult_mon m m') in
CList.map map p
-let coef_of_int x = P.of_num (Num.Int x)
+let coef_of_int x = P.of_num (Q.of_int x)
(* variable i *)
let gen d i =
diff --git a/plugins/nsatz/nsatz.ml b/plugins/nsatz/nsatz.ml
index 29d08fb4ea..f3021f4ee6 100644
--- a/plugins/nsatz/nsatz.ml
+++ b/plugins/nsatz/nsatz.ml
@@ -13,30 +13,20 @@ open Util
open Constr
open Tactics
-open Num
open Utile
(***********************************************************************
Operations on coefficients
*)
-let num_0 = Int 0
-and num_1 = Int 1
-and num_2 = Int 2
-
-let numdom r =
- let r' = Ratio.normalize_ratio (ratio_of_num r) in
- num_of_big_int(Ratio.numerator_ratio r'),
- num_of_big_int(Ratio.denominator_ratio r')
-
module BigInt = struct
- open Big_int
+ open Big_int_Z
type t = big_int
let of_int = big_int_of_int
let coef0 = of_int 0
- let of_num = Num.big_int_of_num
- let to_num = Num.num_of_big_int
+ let of_num = Q.to_bigint
+ let to_num = Q.of_bigint
let equal = eq_big_int
let lt = lt_big_int
let le = le_big_int
@@ -113,7 +103,7 @@ type vname = string
type term =
| Zero
- | Const of Num.num
+ | Const of Q.t
| Var of vname
| Opp of term
| Add of term * term
@@ -122,7 +112,7 @@ type term =
| Pow of term * int
let const n =
- if eq_num n num_0 then Zero else Const n
+ if Q.(equal zero) n then Zero else Const n
let pow(p,i) = if Int.equal i 1 then p else Pow(p,i)
let add = function
(Zero,q) -> q
@@ -131,8 +121,8 @@ let add = function
let mul = function
(Zero,_) -> Zero
| (_,Zero) -> Zero
- | (p,Const n) when eq_num n num_1 -> p
- | (Const n,q) when eq_num n num_1 -> q
+ | (p,Const n) when Q.(equal one) n -> p
+ | (Const n,q) when Q.(equal one) n -> q
| (p,q) -> Mul(p,q)
let gen_constant n = lazy (UnivGen.constr_of_monomorphic_global (Coqlib.lib_ref n))
@@ -167,62 +157,64 @@ let mkt_app name l = mkApp (Lazy.force name, Array.of_list l)
let tlp () = mkt_app tlist [mkt_app tpexpr [Lazy.force tz]]
let tllp () = mkt_app tlist [tlp()]
-let rec mkt_pos n =
- if n =/ num_1 then Lazy.force pxH
- else if mod_num n num_2 =/ num_0 then
- mkt_app pxO [mkt_pos (quo_num n num_2)]
+let mkt_pos n =
+ let rec mkt_pos n =
+ if Z.(equal one) n then Lazy.force pxH
+ else if Z.is_even n then
+ mkt_app pxO [mkt_pos Z.(n asr 1)]
else
- mkt_app pxI [mkt_pos (quo_num n num_2)]
+ mkt_app pxI [mkt_pos Z.(n asr 1)]
+ in mkt_pos (Q.to_bigint n)
let mkt_n n =
- if Num.eq_num n num_0
+ if Q.(equal zero) n
then Lazy.force nN0
else mkt_app nNpos [mkt_pos n]
let mkt_z z =
- if z =/ num_0 then Lazy.force z0
- else if z >/ num_0 then
+ if Q.(equal zero) z then Lazy.force z0
+ else if Q.(lt zero) z then
mkt_app zpos [mkt_pos z]
else
- mkt_app zneg [mkt_pos ((Int 0) -/ z)]
+ mkt_app zneg [mkt_pos (Q.neg z)]
let rec mkt_term t = match t with
-| Zero -> mkt_term (Const num_0)
-| Const r -> let (n,d) = numdom r in
- mkt_app ttconst [Lazy.force tz; mkt_z n]
-| Var v -> mkt_app ttvar [Lazy.force tz; mkt_pos (num_of_string v)]
+| Zero -> mkt_term (Const Q.zero)
+| Const r -> let n = r |> Q.num |> Q.of_bigint in
+ mkt_app ttconst [Lazy.force tz; mkt_z n]
+| Var v -> mkt_app ttvar [Lazy.force tz; mkt_pos (Q.of_string v)]
| Opp t1 -> mkt_app ttopp [Lazy.force tz; mkt_term t1]
| Add (t1,t2) -> mkt_app ttadd [Lazy.force tz; mkt_term t1; mkt_term t2]
| Sub (t1,t2) -> mkt_app ttsub [Lazy.force tz; mkt_term t1; mkt_term t2]
| Mul (t1,t2) -> mkt_app ttmul [Lazy.force tz; mkt_term t1; mkt_term t2]
| Pow (t1,n) -> if Int.equal n 0 then
- mkt_app ttconst [Lazy.force tz; mkt_z num_1]
+ mkt_app ttconst [Lazy.force tz; mkt_z Q.one]
else
- mkt_app ttpow [Lazy.force tz; mkt_term t1; mkt_n (num_of_int n)]
+ mkt_app ttpow [Lazy.force tz; mkt_term t1; mkt_n (Q.of_int n)]
let rec parse_pos p =
match Constr.kind p with
| App (a,[|p2|]) ->
- if Constr.equal a (Lazy.force pxO) then num_2 */ (parse_pos p2)
- else num_1 +/ (num_2 */ (parse_pos p2))
-| _ -> num_1
+ if Constr.equal a (Lazy.force pxO) then Q.(mul (of_int 2)) (parse_pos p2)
+ else Q.(add one) Q.(mul (of_int 2) (parse_pos p2))
+| _ -> Q.one
let parse_z z =
match Constr.kind z with
| App (a,[|p2|]) ->
- if Constr.equal a (Lazy.force zpos) then parse_pos p2 else (num_0 -/ (parse_pos p2))
-| _ -> num_0
+ if Constr.equal a (Lazy.force zpos) then parse_pos p2 else Q.neg (parse_pos p2)
+| _ -> Q.zero
let parse_n z =
match Constr.kind z with
| App (a,[|p2|]) ->
parse_pos p2
-| _ -> num_0
+| _ -> Q.zero
let rec parse_term p =
match Constr.kind p with
| App (a,[|_;p2|]) ->
- if Constr.equal a (Lazy.force ttvar) then Var (string_of_num (parse_pos p2))
+ if Constr.equal a (Lazy.force ttvar) then Var (Q.to_string (parse_pos p2))
else if Constr.equal a (Lazy.force ttconst) then Const (parse_z p2)
else if Constr.equal a (Lazy.force ttopp) then Opp (parse_term p2)
else Zero
@@ -231,7 +223,7 @@ let rec parse_term p =
else if Constr.equal a (Lazy.force ttsub) then Sub (parse_term p2, parse_term p3)
else if Constr.equal a (Lazy.force ttmul) then Mul (parse_term p2, parse_term p3)
else if Constr.equal a (Lazy.force ttpow) then
- Pow (parse_term p2, int_of_num (parse_n p3))
+ Pow (parse_term p2, Q.to_int (parse_n p3))
else Zero
| _ -> Zero
@@ -278,7 +270,7 @@ let term_pol_sparse nvars np t=
match t with
| Zero -> zeroP
| Const r ->
- if Num.eq_num r num_0
+ if Q.(equal zero) r
then zeroP
else polconst d (Poly.Pint (Coef.of_num r))
| Var v ->
@@ -316,7 +308,7 @@ let pol_sparse_to_term n2 p =
let p = PIdeal.repr p in
let rec aux p =
match p with
- [] -> const (num_of_string "0")
+ [] -> const Q.zero
| (a,m)::p1 ->
let m = Ideal.Monomial.repr m in
let n = (Array.length m)-1 in
@@ -443,8 +435,9 @@ let expand_pol lb lp =
let theoremedeszeros_termes lp =
let nvars = List.fold_left set_nvars_term 0 lp in
match lp with
- | Const (Int sugarparam)::Const (Int nparam)::lp ->
- ((match sugarparam with
+ | Const sugarparam :: Const nparam :: lp ->
+ let nparam = Q.to_int nparam in
+ ((match Q.to_int sugarparam with
|0 -> sinfo "computation without sugar";
lexico:=false;
|1 -> sinfo "computation with sugar";
diff --git a/plugins/nsatz/polynom.ml b/plugins/nsatz/polynom.ml
index 726ad54cad..2565d88b13 100644
--- a/plugins/nsatz/polynom.ml
+++ b/plugins/nsatz/polynom.ml
@@ -30,7 +30,7 @@ module type Coef = sig
val pgcd : t -> t -> t
val hash : t -> int
- val of_num : Num.num -> t
+ val of_num : Q.t -> t
val to_string : t -> string
end
@@ -39,7 +39,7 @@ module type S = sig
type variable = int
type t = Pint of coef | Prec of variable * t array
- val of_num : Num.num -> t
+ val of_num : Q.t -> t
val x : variable -> t
val monome : variable -> int -> t
val is_constantP : t -> bool
@@ -106,7 +106,7 @@ end
module Make (C:Coef) = struct
type coef = C.t
-let coef_of_int i = C.of_num (Num.Int i)
+let coef_of_int i = C.of_num (Q.of_int i)
let coef0 = coef_of_int 0
let coef1 = coef_of_int 1
@@ -125,8 +125,8 @@ type t =
(* constant polynomials *)
let of_num x = Pint (C.of_num x)
-let cf0 = of_num (Num.Int 0)
-let cf1 = of_num (Num.Int 1)
+let cf0 = of_num Q.zero
+let cf1 = of_num Q.one
(* nth variable *)
let x n = Prec (n,[|cf0;cf1|])
diff --git a/plugins/nsatz/polynom.mli b/plugins/nsatz/polynom.mli
index 3807a8582b..91f1bcda90 100644
--- a/plugins/nsatz/polynom.mli
+++ b/plugins/nsatz/polynom.mli
@@ -26,7 +26,7 @@ module type Coef = sig
val pgcd : t -> t -> t
val hash : t -> int
- val of_num : Num.num -> t
+ val of_num : Q.t -> t
val to_string : t -> string
end
@@ -35,7 +35,7 @@ module type S = sig
type variable = int
type t = Pint of coef | Prec of variable * t array
- val of_num : Num.num -> t
+ val of_num : Q.t -> t
val x : variable -> t
val monome : variable -> int -> t
val is_constantP : t -> bool
diff --git a/plugins/omega/coq_omega.ml b/plugins/omega/coq_omega.ml
index 3ba6365783..4f7b3fbe74 100644
--- a/plugins/omega/coq_omega.ml
+++ b/plugins/omega/coq_omega.ml
@@ -32,7 +32,22 @@ open Tactypes
open Context.Named.Declaration
module NamedDecl = Context.Named.Declaration
-module OmegaSolver = Omega.MakeOmegaSolver (Bigint)
+
+module ZOmega = struct
+ type bigint = Z.t
+ let equal = Z.equal
+ let less_than = Z.lt
+ let add = Z.add
+ let sub = Z.sub
+ let mult = Z.mul
+ let euclid = Z.div_rem
+ let neg = Z.neg
+ let zero = Z.zero
+ let one = Z.one
+ let to_string = Z.to_string
+end
+
+module OmegaSolver = Omega.MakeOmegaSolver (ZOmega)
open OmegaSolver
(* Added by JCF, 09/03/98 *)
@@ -719,7 +734,7 @@ let rec shuffle p (t1,t2) =
Oplus(l2,t')
else [],Oplus(t1,t2)
| Oz t1,Oz t2 ->
- [focused_simpl p], Oz(Bigint.add t1 t2)
+ [focused_simpl p], Oz(Z.add t1 t2)
| t1,t2 ->
if weight t1 < weight t2 then
[clever_rewrite p [[P_APP 1];[P_APP 2]]
@@ -741,7 +756,7 @@ let shuffle_mult p_init k1 e1 k2 e2 =
[P_APP 2; P_APP 2]]
(Lazy.force coq_fast_OMEGA10)
in
- if Bigint.add (Bigint.mult k1 c1) (Bigint.mult k2 c2) =? zero then
+ if Z.add (Z.mul k1 c1) (Z.mul k2 c2) =? zero then
let tac' =
clever_rewrite p [[P_APP 1;P_APP 1];[P_APP 2]]
(Lazy.force coq_fast_Zred_factor5) in
@@ -798,7 +813,7 @@ let shuffle_mult_right p_init e1 k2 e2 =
[P_APP 2; P_APP 2]]
(Lazy.force coq_fast_OMEGA15)
in
- if Bigint.add c1 (Bigint.mult k2 c2) =? zero then
+ if Z.add c1 (Z.mul k2 c2) =? zero then
let tac' =
clever_rewrite p [[P_APP 1;P_APP 1];[P_APP 2]]
(Lazy.force coq_fast_Zred_factor5)
@@ -1004,7 +1019,7 @@ let reduce_factor p = function
| Otimes(Oatom v,c) ->
let rec compute = function
| Oz n -> n
- | Oplus(t1,t2) -> Bigint.add (compute t1) (compute t2)
+ | Oplus(t1,t2) -> Z.add (compute t1) (compute t2)
| _ -> CErrors.user_err Pp.(str "condense.1")
in
[focused_simpl (P_APP 2 :: p)], Otimes(Oatom v,Oz(compute c))
@@ -1055,6 +1070,9 @@ let rec clear_zero p = function
let tac,t = clear_zero (P_APP 2 :: p) r in tac,Oplus(f,t)
| t -> [],t
+open Proofview
+open Proofview.Notations
+
let replay_history tactic_normalisation =
let aux = Id.of_string "auxiliary" in
let aux1 = Id.of_string "auxiliary_1" in
@@ -1085,8 +1103,8 @@ let replay_history tactic_normalisation =
mk_integer k;
mkVar id1; mkVar id2 |])];
mk_then tac;
- (intros_using [aux]);
- resolve_id aux;
+ intro_using_then aux (fun aux ->
+ resolve_id aux);
reflexivity
]
| CONTRADICTION (e1,e2) :: l ->
@@ -1128,24 +1146,25 @@ let replay_history tactic_normalisation =
tclTHENS
(cut state_eg)
[ tclTHENS
- (tclTHENLIST [
- (intros_using [aux]);
- (generalize_tac
- [mkApp (Lazy.force coq_OMEGA1,
- [| eq1; rhs; mkVar aux; mkVar id |])]);
- (clear [aux;id]);
- (intros_using [id]);
- (cut (mk_gt kk dd)) ])
+ (intro_using_then aux (fun aux ->
+ tclTHENLIST [
+ (generalize_tac
+ [mkApp (Lazy.force coq_OMEGA1,
+ [| eq1; rhs; mkVar aux; mkVar id |])]);
+ (clear [aux;id]);
+ (intro_mustbe_force id);
+ (cut (mk_gt kk dd)) ]))
[ tclTHENS
(cut (mk_gt kk izero))
- [ tclTHENLIST [
- (intros_using [aux1; aux2]);
+ [ intro_using_then aux1 (fun aux1 ->
+ intro_using_then aux2 (fun aux2 ->
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_Zmult_le_approx,
[| kk;eq2;dd;mkVar aux1;mkVar aux2; mkVar id |])]);
(clear [aux1;aux2;id]);
- (intros_using [id]);
- (loop l) ];
+ (intro_mustbe_force id);
+ (loop l) ]));
tclTHENLIST [
(unfold sp_Zgt);
simpl_in_concl;
@@ -1156,7 +1175,7 @@ let replay_history tactic_normalisation =
| NOT_EXACT_DIVIDE (e1,k) :: l ->
let c = floor_div e1.constant k in
- let d = Bigint.sub e1.constant (Bigint.mult c k) in
+ let d = Z.sub e1.constant (Z.mul c k) in
let e2 = {id=e1.id; kind=EQUA;constant = c;
body = map_eq_linear (fun c -> c / k) e1.body } in
let eq2 = val_of(decompile e2) in
@@ -1166,21 +1185,24 @@ let replay_history tactic_normalisation =
tclTHENS
(cut (mk_gt dd izero))
[ tclTHENS (cut (mk_gt kk dd))
- [tclTHENLIST [
- (intros_using [aux2;aux1]);
- (generalize_tac
- [mkApp (Lazy.force coq_OMEGA4,
- [| dd;kk;eq2;mkVar aux1; mkVar aux2 |])]);
- (clear [aux1;aux2]);
- unfold sp_not;
- (intros_using [aux]);
- resolve_id aux;
- mk_then tac;
- assumption ] ;
- tclTHENLIST [
- unfold sp_Zgt;
- simpl_in_concl;
- reflexivity ] ];
+ [ intro_using_then aux2 (fun aux2 ->
+ intro_using_then aux1 (fun aux1 ->
+ tclTHENLIST [
+ (generalize_tac
+ [mkApp (Lazy.force coq_OMEGA4,
+ [| dd;kk;eq2;mkVar aux1; mkVar aux2 |])]);
+ (clear [aux1;aux2]);
+ unfold sp_not;
+ intro_using_then aux (fun aux ->
+ tclTHENLIST [
+ resolve_id aux;
+ mk_then tac;
+ assumption
+ ])])) ;
+ tclTHENLIST [
+ unfold sp_Zgt;
+ simpl_in_concl;
+ reflexivity ] ];
tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
@@ -1196,29 +1218,30 @@ let replay_history tactic_normalisation =
let tac = scalar_norm [P_APP 3] e2.body in
tclTHENS
(cut state_eq)
- [tclTHENLIST [
- (intros_using [aux1]);
- (generalize_tac
- [mkApp (Lazy.force coq_OMEGA18,
- [| eq1;eq2;kk;mkVar aux1; mkVar id |])]);
- (clear [aux1;id]);
- (intros_using [id]);
- (loop l) ];
- tclTHEN (mk_then tac) reflexivity ]
+ [ intro_using_then aux1 (fun aux1 ->
+ tclTHENLIST [
+ (generalize_tac
+ [mkApp (Lazy.force coq_OMEGA18,
+ [| eq1;eq2;kk;mkVar aux1; mkVar id |])]);
+ (clear [aux1;id]);
+ (intro_mustbe_force id);
+ (loop l) ]);
+ tclTHEN (mk_then tac) reflexivity ]
else
let tac = scalar_norm [P_APP 3] e2.body in
tclTHENS (cut state_eq)
[
tclTHENS
(cut (mk_gt kk izero))
- [tclTHENLIST [
- (intros_using [aux2;aux1]);
- (generalize_tac
+ [ intro_using_then aux2 (fun aux2 ->
+ intro_using_then aux1 (fun aux1 ->
+ tclTHENLIST [
+ (generalize_tac
[mkApp (Lazy.force coq_OMEGA3,
[| eq1; eq2; kk; mkVar aux2; mkVar aux1;mkVar id|])]);
(clear [aux1;aux2;id]);
- (intros_using [id]);
- (loop l) ];
+ (intro_mustbe_force id);
+ (loop l) ]));
tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
@@ -1238,13 +1261,13 @@ let replay_history tactic_normalisation =
in
tclTHENS
(cut (mk_eq eq1 (mk_inv eq2)))
- [tclTHENLIST [
- (intros_using [aux]);
- (generalize_tac [mkApp (Lazy.force coq_OMEGA8,
- [| eq1;eq2;mkVar id1;mkVar id2; mkVar aux|])]);
- (clear [id1;id2;aux]);
- (intros_using [id]);
- (loop l) ];
+ [ intro_using_then aux (fun aux ->
+ tclTHENLIST [
+ (generalize_tac
+ [mkApp (Lazy.force coq_OMEGA8, [| eq1;eq2;mkVar id1;mkVar id2; mkVar aux|])]);
+ (clear [id1;id2;aux]);
+ (intro_mustbe_force id);
+ (loop l) ]);
tclTHEN (mk_then tac) reflexivity]
| STATE {st_new_eq=e;st_def=def;st_orig=orig;st_coef=m;st_var=v} :: l ->
@@ -1271,18 +1294,19 @@ let replay_history tactic_normalisation =
orig.body m ({c= negone;v= v}::def.body) in
tclTHENS
(cut theorem)
- [tclTHENLIST [
- (intros_using [aux]);
- (elim_id aux);
- (clear [aux]);
- (intros_using [vid; aux]);
- (generalize_tac
+ [ tclTHENLIST [ intro_using_then aux (fun aux ->
+ (elim_id aux) <*>
+ (clear [aux]));
+ intro_using_then vid (fun vid ->
+ intro_using_then aux (fun aux ->
+ tclTHENLIST [
+ (generalize_tac
[mkApp (Lazy.force coq_OMEGA9,
[| mkVar vid;eq2;eq1;mm; mkVar id2;mkVar aux |])]);
mk_then tac;
(clear [aux]);
- (intros_using [id]);
- (loop l) ];
+ (intro_mustbe_force id);
+ (loop l) ]))];
tclTHEN (exists_tac eq1) reflexivity ]
| SPLIT_INEQ(e,(e1,act1),(e2,act2)) :: l ->
let id1 = new_identifier ()
@@ -1294,8 +1318,8 @@ let replay_history tactic_normalisation =
let eq = val_of(decompile e) in
tclTHENS
(simplest_elim (applist (Lazy.force coq_OMEGA19, [eq; mkVar id])))
- [tclTHENLIST [ mk_then tac1; (intros_using [id1]); (loop act1) ];
- tclTHENLIST [ mk_then tac2; (intros_using [id2]); (loop act2) ]]
+ [tclTHENLIST [ mk_then tac1; (intro_mustbe_force id1); (loop act1) ];
+ tclTHENLIST [ mk_then tac2; (intro_mustbe_force id2); (loop act2) ]]
| SUM(e3,(k1,e1),(k2,e2)) :: l ->
let id = new_identifier () in
tag_hypothesis id e3;
@@ -1318,7 +1342,7 @@ let replay_history tactic_normalisation =
(generalize_tac
[mkApp (tac_thm, [| eq1; eq2; kk; mkVar id1; mkVar id2 |])]);
mk_then tac;
- (intros_using [id]);
+ (intro_mustbe_force id);
(loop l)
]
else
@@ -1329,25 +1353,26 @@ let replay_history tactic_normalisation =
tclTHENS (cut (mk_gt kk1 izero))
[tclTHENS
(cut (mk_gt kk2 izero))
- [tclTHENLIST [
- (intros_using [aux2;aux1]);
- (generalize_tac
- [mkApp (Lazy.force coq_OMEGA7, [|
- eq1;eq2;kk1;kk2;
- mkVar aux1;mkVar aux2;
- mkVar id1;mkVar id2 |])]);
- (clear [aux1;aux2]);
- mk_then tac;
- (intros_using [id]);
- (loop l) ];
- tclTHENLIST [
- unfold sp_Zgt;
- simpl_in_concl;
- reflexivity ] ];
- tclTHENLIST [
- unfold sp_Zgt;
- simpl_in_concl;
- reflexivity ] ]
+ [ intro_using_then aux2 (fun aux2 ->
+ intro_using_then aux1 (fun aux1 ->
+ tclTHENLIST [
+ (generalize_tac
+ [mkApp (Lazy.force coq_OMEGA7, [|
+ eq1;eq2;kk1;kk2;
+ mkVar aux1;mkVar aux2;
+ mkVar id1;mkVar id2 |])]);
+ (clear [aux1;aux2]);
+ mk_then tac;
+ (intro_mustbe_force id);
+ (loop l) ]));
+ tclTHENLIST [
+ unfold sp_Zgt;
+ simpl_in_concl;
+ reflexivity ] ];
+ tclTHENLIST [
+ unfold sp_Zgt;
+ simpl_in_concl;
+ reflexivity ] ]
| CONSTANT_NOT_NUL(e,k) :: l ->
tclTHEN ((generalize_tac [mkVar (hyp_of_tag e)])) Equality.discrConcl
| CONSTANT_NUL(e) :: l ->
@@ -1358,9 +1383,8 @@ let replay_history tactic_normalisation =
unfold sp_Zle;
simpl_in_concl;
unfold sp_not;
- (intros_using [aux]);
- resolve_id aux;
- reflexivity
+ intro_using_then aux (fun aux ->
+ resolve_id aux <*> reflexivity)
]
| _ -> Proofview.tclUNIT ()
in
@@ -1382,7 +1406,7 @@ let normalize_equation sigma id flag theorem pos t t1 t2 (tactic,defs) =
in
if not (List.is_empty tac) then
let id' = new_identifier () in
- ((id',(tclTHENLIST [ shift_left; mk_then tac; (intros_using [id']) ]))
+ ((id',(tclTHENLIST [ shift_left; mk_then tac; (intro_mustbe_force id') ]))
:: tactic,
compile id' flag t' :: defs)
else
@@ -1423,10 +1447,7 @@ let destructure_omega env sigma tac_def (id,c) =
let reintroduce id =
(* [id] cannot be cleared if dependent: protect it by a try *)
- tclTHEN (tclTRY (clear [id])) (intro_using id)
-
-
-open Proofview.Notations
+ tclTHEN (tclTRY (clear [id])) (intro_using_then id (fun _ -> tclUNIT()))
let coq_omega =
Proofview.Goal.enter begin fun gl ->
@@ -1444,10 +1465,10 @@ let coq_omega =
tag_hypothesis id i;
(tclTHENLIST [
(simplest_elim (applist (Lazy.force coq_intro_Z, [t])));
- (intros_using [v; id]);
+ (intros_mustbe_force [v; id]);
(elim_id id);
(clear [id]);
- (intros_using [th;id]);
+ (intros_mustbe_force [th;id]);
tac ]),
{kind = INEQ;
body = [{v=intern_id v; c=one}];
@@ -1455,7 +1476,7 @@ let coq_omega =
else
(tclTHENLIST [
(simplest_elim (applist (Lazy.force coq_new_var, [t])));
- (intros_using [v;th]);
+ (intros_mustbe_force [v;th]);
tac ]),
sys)
(Proofview.tclUNIT (),[]) (dump_tables ())
@@ -1508,7 +1529,7 @@ let nat_inject =
tclTHENS
(tclTHEN
(simplest_elim (applist (Lazy.force coq_le_gt_dec, [t2;t1])))
- (intros_using [id]))
+ (intro_mustbe_force id))
[
tclTHENLIST [
(clever_rewrite_gen p
@@ -1703,7 +1724,7 @@ let onClearedName2 id tac =
(tclTRY (clear [id]))
(Proofview.Goal.enter begin fun gl ->
let id1 = fresh_id Id.Set.empty (add_suffix id "_left") gl in
- let id2 = fresh_id Id.Set.empty (add_suffix id "_right") gl in
+ let id2 = fresh_id (Id.Set.singleton id1) (add_suffix id "_right") gl in
tclTHENLIST [ introduction id1; introduction id2; tac id1 id2 ]
end)
diff --git a/plugins/setoid_ring/newring.ml b/plugins/setoid_ring/newring.ml
index 95faede7d0..6ed6b8da91 100644
--- a/plugins/setoid_ring/newring.ml
+++ b/plugins/setoid_ring/newring.ml
@@ -146,17 +146,21 @@ let ic_unsafe c = (*FIXME remove *)
let sigma = Evd.from_env env in
fst (Constrintern.interp_constr env sigma c)
-let decl_constant na univs c =
+let decl_constant name univs c =
let open Constr in
let vars = CVars.universes_of_constr c in
let univs = UState.restrict_universe_context ~lbound:(Global.universes_lbound ()) univs vars in
let () = DeclareUctx.declare_universe_context ~poly:false univs in
let types = (Typeops.infer (Global.env ()) c).uj_type in
let univs = Monomorphic_entry Univ.ContextSet.empty in
- mkConst(declare_constant ~name:(Id.of_string na)
+ mkConst(declare_constant ~name
~kind:Decls.(IsProof Lemma)
(DefinitionEntry (definition_entry ~opaque:true ~types ~univs c)))
+let decl_constant na suff univs c =
+ let na = Namegen.next_global_ident_away (Nameops.add_suffix na suff) Id.Set.empty in
+ decl_constant na univs c
+
(* Calling a global tactic *)
let ltac_call tac (args:glob_tactic_arg list) =
TacArg(CAst.make @@ TacCall (CAst.make (ArgArg(Loc.tag @@ Lazy.force tac),args)))
@@ -581,9 +585,9 @@ let add_theory0 name (sigma, rth) eqth morphth cst_tac (pre,post) power sign div
let lemma2 = params.(4) in
let lemma1 =
- decl_constant (Id.to_string name^"_ring_lemma1") ctx lemma1 in
+ decl_constant name "_ring_lemma1" ctx lemma1 in
let lemma2 =
- decl_constant (Id.to_string name^"_ring_lemma2") ctx lemma2 in
+ decl_constant name "_ring_lemma2" ctx lemma2 in
let cst_tac =
interp_cst_tac env sigma morphth kind (zero,one,add,mul,opp) cst_tac in
let pretac =
@@ -898,15 +902,15 @@ let add_field_theory0 name fth eqth morphth cst_tac inj (pre,post) power sign od
match inj with
| Some thm -> mkApp(params.(8),[|EConstr.to_constr sigma thm|])
| None -> params.(7) in
- let lemma1 = decl_constant (Id.to_string name^"_field_lemma1")
+ let lemma1 = decl_constant name "_field_lemma1"
ctx lemma1 in
- let lemma2 = decl_constant (Id.to_string name^"_field_lemma2")
+ let lemma2 = decl_constant name "_field_lemma2"
ctx lemma2 in
- let lemma3 = decl_constant (Id.to_string name^"_field_lemma3")
+ let lemma3 = decl_constant name "_field_lemma3"
ctx lemma3 in
- let lemma4 = decl_constant (Id.to_string name^"_field_lemma4")
+ let lemma4 = decl_constant name "_field_lemma4"
ctx lemma4 in
- let cond_lemma = decl_constant (Id.to_string name^"_lemma5")
+ let cond_lemma = decl_constant name "_lemma5"
ctx cond_lemma in
let cst_tac =
interp_cst_tac env sigma morphth kind (zero,one,add,mul,opp) cst_tac in
diff --git a/plugins/ssr/ssrcommon.ml b/plugins/ssr/ssrcommon.ml
index 1b7768852e..d859fe51ab 100644
--- a/plugins/ssr/ssrcommon.ml
+++ b/plugins/ssr/ssrcommon.ml
@@ -1047,7 +1047,7 @@ let refine_with ?(first_goes_last=false) ?beta ?(with_evars=true) oc =
let uct = Evd.evar_universe_context (fst oc) in
let n, oc = abs_evars_pirrel env sigma (fst oc, EConstr.to_constr ~abort_on_undefined_evars:false (fst oc) (snd oc)) in
Proofview.Unsafe.tclEVARS (Evd.set_universe_context sigma uct) <*>
- Proofview.tclOR (applyn ~with_evars ~first_goes_last ~with_shelve:true ?beta n (EConstr.of_constr oc))
+ Proofview.tclORELSE (applyn ~with_evars ~first_goes_last ~with_shelve:true ?beta n (EConstr.of_constr oc))
(fun _ -> Proofview.tclZERO dependent_apply_error)
end
@@ -1352,7 +1352,7 @@ let unsafe_intro env decl b =
Refine.refine ~typecheck:false begin fun sigma ->
let ctx = Environ.named_context_val env in
let nctx = EConstr.push_named_context_val decl ctx in
- let inst = List.map (get_id %> EConstr.mkVar) (Environ.named_context env) in
+ let inst = EConstr.identity_subst_val (Environ.named_context_val env) in
let ninst = EConstr.mkRel 1 :: inst in
let nb = EConstr.Vars.subst1 (EConstr.mkVar (get_id decl)) b in
let sigma, ev = Evarutil.new_pure_evar ~principal:true nctx sigma nb in
diff --git a/plugins/ssr/ssrelim.ml b/plugins/ssr/ssrelim.ml
index 1c81fbc10b..582c45cde1 100644
--- a/plugins/ssr/ssrelim.ml
+++ b/plugins/ssr/ssrelim.ml
@@ -478,24 +478,34 @@ let revtoptac n0 =
Proofview.Goal.enter begin fun gl ->
let sigma = Proofview.Goal.sigma gl in
let concl = Proofview.Goal.concl gl in
+ let env = Proofview.Goal.env gl in
let n = nb_prod sigma concl - n0 in
let dc, cl = EConstr.decompose_prod_n_assum sigma n concl in
- let dc' = dc @ [Context.Rel.Declaration.LocalAssum(make_annot (Name rev_id) Sorts.Relevant, EConstr.it_mkProd_or_LetIn cl (List.rev dc))] in
- let f = EConstr.it_mkLambda_or_LetIn (mkEtaApp (EConstr.mkRel (n + 1)) (-n) 1) dc' in
- Logic.refiner ~check:true EConstr.Unsafe.(to_constr (EConstr.mkApp (f, [|Evarutil.mk_new_meta ()|])))
+ let ty = EConstr.it_mkProd_or_LetIn cl (List.rev dc) in
+ let dc' = dc @ [Context.Rel.Declaration.LocalAssum(make_annot (Name rev_id) Sorts.Relevant, ty)] in
+ Refine.refine ~typecheck:true begin fun sigma ->
+ let f = EConstr.it_mkLambda_or_LetIn (mkEtaApp (EConstr.mkRel (n + 1)) (-n) 1) dc' in
+ let sigma, ev = Evarutil.new_evar env sigma ty in
+ sigma, (EConstr.mkApp (f, [|ev|]))
+ end
end
-let equality_inj l b id c =
- Proofview.V82.tactic begin fun gl ->
- let msg = ref "" in
- try Proofview.V82.of_tactic (Equality.inj None l b None c) gl
- with
- | CErrors.UserError (_,s)
- when msg := Pp.string_of_ppcmds s;
- !msg = "Not a projectable equality but a discriminable one." ||
- !msg = "Nothing to inject." ->
- Feedback.msg_warning (Pp.str !msg);
- discharge_hyp (id, (id, "")) gl
+let nothing_to_inject =
+ CWarnings.create ~name:"spurious-ssr-injection" ~category:"ssr"
+ (fun (sigma, env, ty) ->
+ Pp.(str "SSReflect: cannot obtain new equations out of" ++ fnl() ++
+ str" " ++ Printer.pr_econstr_env env sigma ty ++ fnl() ++
+ str "Did you write an extra [] in the intro pattern?"))
+
+let equality_inj l b id c = Proofview.Goal.enter begin fun gl ->
+ Proofview.tclORELSE (Equality.inj None l b None c)
+ (function
+ | (Equality.NothingToInject,_) ->
+ let open Proofview.Notations in
+ Ssrcommon.tacTYPEOF (EConstr.mkVar id) >>= fun ty ->
+ nothing_to_inject (Proofview.Goal.sigma gl, Proofview.Goal.env gl, ty);
+ Proofview.V82.tactic (discharge_hyp (id, (id, "")))
+ | (e,info) -> Proofview.tclZERO ~info e)
end
let injectidl2rtac id c =
diff --git a/plugins/ssr/ssrequality.ml b/plugins/ssr/ssrequality.ml
index da623703a2..38b26d06b9 100644
--- a/plugins/ssr/ssrequality.ml
+++ b/plugins/ssr/ssrequality.ml
@@ -465,7 +465,7 @@ let rwcltac ?under ?map_redex cl rdx dir sr =
Tactics.apply_type ~typecheck:true cl'' [rdx; EConstr.it_mkLambda_or_LetIn r3 dc], Tacticals.New.tclTHENLIST (itacs @ rwtacs), sigma0
in
let cvtac' =
- Proofview.tclOR cvtac begin function
+ Proofview.tclORELSE cvtac begin function
| (PRtype_error e, _) ->
let error = Option.cata (fun (env, sigma, te) ->
Pp.(fnl () ++ str "Type error was: " ++ Himsg.explain_pretype_error env sigma te))
diff --git a/plugins/ssr/ssrparser.mlg b/plugins/ssr/ssrparser.mlg
index 60af804c1b..98439e27a1 100644
--- a/plugins/ssr/ssrparser.mlg
+++ b/plugins/ssr/ssrparser.mlg
@@ -219,20 +219,20 @@ let test_ssrslashnum b1 b2 _ strm =
match Util.stream_nth 0 strm with
| Tok.KEYWORD "/" ->
(match Util.stream_nth 1 strm with
- | Tok.NUMERAL _ when b1 ->
+ | Tok.NUMBER _ when b1 ->
(match Util.stream_nth 2 strm with
| Tok.KEYWORD "=" | Tok.KEYWORD "/=" when not b2 -> ()
| Tok.KEYWORD "/" ->
if not b2 then () else begin
match Util.stream_nth 3 strm with
- | Tok.NUMERAL _ -> ()
+ | Tok.NUMBER _ -> ()
| _ -> raise Stream.Failure
end
| _ -> raise Stream.Failure)
| Tok.KEYWORD "/" when not b1 ->
(match Util.stream_nth 2 strm with
| Tok.KEYWORD "=" when not b2 -> ()
- | Tok.NUMERAL _ when b2 ->
+ | Tok.NUMBER _ when b2 ->
(match Util.stream_nth 3 strm with
| Tok.KEYWORD "=" -> ()
| _ -> raise Stream.Failure)
@@ -243,7 +243,7 @@ let test_ssrslashnum b1 b2 _ strm =
| Tok.KEYWORD "//" when not b1 ->
(match Util.stream_nth 1 strm with
| Tok.KEYWORD "=" when not b2 -> ()
- | Tok.NUMERAL _ when b2 ->
+ | Tok.NUMBER _ when b2 ->
(match Util.stream_nth 2 strm with
| Tok.KEYWORD "=" -> ()
| _ -> raise Stream.Failure)
diff --git a/plugins/ssr/ssrvernac.mlg b/plugins/ssr/ssrvernac.mlg
index 24772a8514..4a907b2795 100644
--- a/plugins/ssr/ssrvernac.mlg
+++ b/plugins/ssr/ssrvernac.mlg
@@ -159,7 +159,7 @@ let declare_one_prenex_implicit locality f =
| [] ->
errorstrm (str "Expected some implicits for " ++ pr_qualid f)
| impls ->
- Impargs.set_implicits locality fref [impls]
+ Impargs.set_implicits locality fref [List.map (fun imp -> (Anonymous,imp)) impls]
}
diff --git a/plugins/syntax/float_syntax.ml b/plugins/syntax/float_syntax.ml
index 8e87fc13ca..5d8dcd04fe 100644
--- a/plugins/syntax/float_syntax.ml
+++ b/plugins/syntax/float_syntax.ml
@@ -48,21 +48,21 @@ let interp_float ?loc n =
| None -> "" | Some f -> NumTok.UnsignedNat.to_string f in
let e = match e with
| None -> "0" | Some e -> NumTok.SignedNat.to_string e in
- Bigint.of_string (i ^ f),
+ Z.of_string (i ^ f),
(try int_of_string e with Failure _ -> 0) - String.length f in
let m', e' =
let m', e' = Float64.frshiftexp f in
let m' = Float64.normfr_mantissa m' in
let e' = Uint63.to_int_min e' 4096 - Float64.eshift - 53 in
- Bigint.of_string (Uint63.to_string m'),
+ Z.of_string (Uint63.to_string m'),
e' in
- let c2, c5 = Bigint.(of_int 2, of_int 5) in
+ let c2, c5 = Z.(of_int 2, of_int 5) in
(* check m*5^e <> m'*2^e' *)
let check m e m' e' =
- not (Bigint.(equal (mult m (pow c5 e)) (mult m' (pow c2 e')))) in
+ not (Z.(equal (mul m (pow c5 e)) (mul m' (pow c2 e')))) in
(* check m*5^e*2^e' <> m' *)
let check' m e e' m' =
- not (Bigint.(equal (mult (mult m (pow c5 e)) (pow c2 e')) m')) in
+ not (Z.(equal (mul (mul m (pow c5 e)) (pow c2 e')) m')) in
(* we now have to check m*10^e <> m'*2^e' *)
if e >= 0 then
if e <= e' then check m e m' (e' - e)
diff --git a/plugins/syntax/g_numeral.mlg b/plugins/syntax/g_numeral.mlg
index e66dbe17b2..c030925ea9 100644
--- a/plugins/syntax/g_numeral.mlg
+++ b/plugins/syntax/g_numeral.mlg
@@ -24,6 +24,11 @@ let pr_numnot_option = function
| Warning n -> str "(warning after " ++ NumTok.UnsignedNat.print n ++ str ")"
| Abstract n -> str "(abstract after " ++ NumTok.UnsignedNat.print n ++ str ")"
+let warn_deprecated_numeral_notation =
+ CWarnings.create ~name:"numeral-notation" ~category:"deprecated"
+ (fun () ->
+ strbrk "Numeral Notation is deprecated, please use Number Notation instead.")
+
}
VERNAC ARGUMENT EXTEND numnotoption
@@ -34,8 +39,13 @@ VERNAC ARGUMENT EXTEND numnotoption
END
VERNAC COMMAND EXTEND NumeralNotation CLASSIFIED AS SIDEFF
- | #[ locality = Attributes.locality; ] [ "Numeral" "Notation" reference(ty) reference(f) reference(g) ":"
+ | #[ locality = Attributes.locality; ] [ "Number" "Notation" reference(ty) reference(f) reference(g) ":"
ident(sc) numnotoption(o) ] ->
{ vernac_numeral_notation (Locality.make_module_locality locality) ty f g (Id.to_string sc) o }
+ | #[ locality = Attributes.locality; ] [ "Numeral" "Notation" reference(ty) reference(f) reference(g) ":"
+ ident(sc) numnotoption(o) ] ->
+
+ { warn_deprecated_numeral_notation ();
+ vernac_numeral_notation (Locality.make_module_locality locality) ty f g (Id.to_string sc) o }
END
diff --git a/plugins/syntax/r_syntax.ml b/plugins/syntax/r_syntax.ml
index 23a7cc07c5..d66b9537b4 100644
--- a/plugins/syntax/r_syntax.ml
+++ b/plugins/syntax/r_syntax.ml
@@ -11,7 +11,6 @@
open Util
open Names
open Glob_term
-open Bigint
(* Poor's man DECLARE PLUGIN *)
let __coq_plugin_name = "r_syntax_plugin"
@@ -47,10 +46,10 @@ let pos_of_bignat ?loc x =
let ref_xH = DAst.make @@ GRef (glob_xH, None) in
let ref_xO = DAst.make @@ GRef (glob_xO, None) in
let rec pos_of x =
- match div2_with_rest x with
- | (q,false) -> DAst.make @@ GApp (ref_xO,[pos_of q])
- | (q,true) when not (Bigint.equal q zero) -> DAst.make @@ GApp (ref_xI,[pos_of q])
- | (q,true) -> ref_xH
+ match Z.(div_rem x (of_int 2)) with
+ | (q,rem) when rem = Z.zero -> DAst.make @@ GApp (ref_xO,[pos_of q])
+ | (q,_) when not Z.(equal q zero) -> DAst.make @@ GApp (ref_xI,[pos_of q])
+ | (q,_) -> ref_xH
in
pos_of x
@@ -59,9 +58,9 @@ let pos_of_bignat ?loc x =
(**********************************************************************)
let rec bignat_of_pos c = match DAst.get c with
- | GApp (r, [a]) when is_gr r glob_xO -> mult_2(bignat_of_pos a)
- | GApp (r, [a]) when is_gr r glob_xI -> add_1(mult_2(bignat_of_pos a))
- | GRef (a, _) when GlobRef.equal a glob_xH -> Bigint.one
+ | GApp (r, [a]) when is_gr r glob_xO -> Z.mul Z.(of_int 2) (bignat_of_pos a)
+ | GApp (r, [a]) when is_gr r glob_xI -> Z.add Z.one Z.(mul (of_int 2) (bignat_of_pos a))
+ | GRef (a, _) when GlobRef.equal a glob_xH -> Z.one
| _ -> raise Non_closed_number
(**********************************************************************)
@@ -77,9 +76,9 @@ let glob_POS = GlobRef.ConstructRef path_of_POS
let glob_NEG = GlobRef.ConstructRef path_of_NEG
let z_of_int ?loc n =
- if not (Bigint.equal n zero) then
+ if not Z.(equal n zero) then
let sgn, n =
- if is_pos_or_zero n then glob_POS, n else glob_NEG, Bigint.neg n in
+ if Z.(leq zero n) then glob_POS, n else glob_NEG, Z.neg n in
DAst.make @@ GApp(DAst.make @@ GRef (sgn,None), [pos_of_bignat ?loc n])
else
DAst.make @@ GRef (glob_ZERO, None)
@@ -90,8 +89,8 @@ let z_of_int ?loc n =
let bigint_of_z c = match DAst.get c with
| GApp (r,[a]) when is_gr r glob_POS -> bignat_of_pos a
- | GApp (r,[a]) when is_gr r glob_NEG -> Bigint.neg (bignat_of_pos a)
- | GRef (a, _) when GlobRef.equal a glob_ZERO -> Bigint.zero
+ | GApp (r,[a]) when is_gr r glob_NEG -> Z.neg (bignat_of_pos a)
+ | GRef (a, _) when GlobRef.equal a glob_ZERO -> Z.zero
| _ -> raise Non_closed_number
(**********************************************************************)
@@ -122,13 +121,13 @@ let r_of_rawnum ?loc n =
let rdiv r r' =
DAst.make @@ GApp (DAst.make @@ GRef(glob_Rdiv,None), [r; r']) in
let pow p e =
- let p = z_of_int ?loc (Bigint.of_int p) in
+ let p = z_of_int ?loc (Z.of_int p) in
let e = pos_of_bignat e in
DAst.make @@ GApp (DAst.make @@ GRef(glob_pow_pos,None), [p; e]) in
let n =
izr (z_of_int ?loc n) in
- if Bigint.is_strictly_pos e then rmult n (izr (pow p e))
- else if Bigint.is_strictly_neg e then rdiv n (izr (pow p (neg e)))
+ if Int.equal (Z.sign e) 1 then rmult n (izr (pow p e))
+ else if Int.equal (Z.sign e) (-1) then rdiv n (izr (pow p (Z.neg e)))
else n (* e = 0 *)
(**********************************************************************)
@@ -141,24 +140,24 @@ let rawnum_of_r c =
(* choose between 123e-2 and 1.23, this is purely heuristic
and doesn't play any soundness role *)
let choose_exponent =
- if Bigint.is_strictly_pos e then
+ if Int.equal (Z.sign e) 1 then
true (* don't print 12 * 10^2 as 1200 to distinguish them *)
else
- let i = Bigint.to_string i in
+ let i = Z.to_string i in
let li = if i.[0] = '-' then String.length i - 1 else String.length i in
- let e = Bigint.neg e in
- let le = String.length (Bigint.to_string e) in
- Bigint.(less_than (add (of_int li) (of_int le)) e) in
+ let e = Z.neg e in
+ let le = String.length (Z.to_string e) in
+ Z.(lt (add (of_int li) (of_int le)) e) in
(* print 123 * 10^-2 as 123e-2 *)
let numTok_exponent () =
NumTok.Signed.of_bigint_and_exponent i (NumTok.EDec e) in
(* print 123 * 10^-2 as 1.23, precondition e < 0 *)
let numTok_dot () =
let s, i =
- if Bigint.is_pos_or_zero i then NumTok.SPlus, Bigint.to_string i
- else NumTok.SMinus, Bigint.(to_string (neg i)) in
+ if Z.sign i >= 0 then NumTok.SPlus, Z.to_string i
+ else NumTok.SMinus, Z.(to_string (neg i)) in
let ni = String.length i in
- let e = - (Bigint.to_int e) in
+ let e = - (Z.to_int e) in
assert (e > 0);
let i, f =
if e < ni then String.sub i 0 (ni - e), String.sub i (ni - e) e
@@ -178,12 +177,12 @@ let rawnum_of_r c =
begin match DAst.get r with
| GApp (p, [t; e]) when is_gr p glob_pow_pos ->
let t = bigint_of_z t in
- if not (Bigint.(equal t (of_int 10))) then
+ if not (Z.(equal t (of_int 10))) then
raise Non_closed_number
else
let i = bigint_of_z l in
let e = bignat_of_pos e in
- let e = if is_gr md glob_Rdiv then neg e else e in
+ let e = if is_gr md glob_Rdiv then Z.neg e else e in
numTok_of_int_exp i e
| _ -> raise Non_closed_number
end