aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/nsatz
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2016-07-13 16:44:41 +0200
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2016-07-13 16:58:37 +0200
commit45250332a1e65d434432940a468312f2ab18a2e8 (patch)
treeede20d574b6ba112db5b37c15d56ad4a255ca819 /plugins/nsatz
parent3f9215b2b65b902cc52fd540f57f67342401a91f (diff)
parent65ba1b36df33a74998240a02fecc1fb80c3eeeee (diff)
Merge branch 'v8.5' into v8.6
Diffstat (limited to 'plugins/nsatz')
-rw-r--r--plugins/nsatz/nsatz.ml51
1 files changed, 49 insertions, 2 deletions
diff --git a/plugins/nsatz/nsatz.ml b/plugins/nsatz/nsatz.ml
index 93dad18d9..36bce780b 100644
--- a/plugins/nsatz/nsatz.ml
+++ b/plugins/nsatz/nsatz.ml
@@ -468,6 +468,44 @@ let theoremedeszeros lpol p =
open Ideal
+(* Remove zero polynomials and duplicates from the list of polynomials lp
+ Return (clp, lb)
+ where clp is the reduced list and lb is a list of booleans
+ that has the same size than lp and where true indicates an
+ element that has been removed
+ *)
+let rec clean_pol lp =
+ let t = Hashpol.create 12 in
+ let find p = try Hashpol.find t p
+ with
+ Not_found -> Hashpol.add t p true; false in
+ let rec aux lp =
+ match lp with
+ | [] -> [], []
+ | p :: lp1 ->
+ let clp, lb = aux lp1 in
+ if equal p zeroP || find p then clp, true::lb
+ else
+ (p :: clp, false::lb) in
+ aux lp
+
+(* Expand the list of polynomials lp putting zeros where the list of
+ booleans lb indicates there is a missing element
+ Warning:
+ the expansion is relative to the end of the list in reversed order
+ lp cannot have less elements than lb
+*)
+let expand_pol lb lp =
+ let rec aux lb lp =
+ match lb with
+ | [] -> lp
+ | true :: lb1 -> zeroP :: aux lb1 lp
+ | false :: lb1 ->
+ match lp with
+ [] -> assert false
+ | p :: lp1 -> p :: aux lb1 lp1
+ in List.rev (aux lb (List.rev lp))
+
let theoremedeszeros_termes lp =
nvars:=0;(* mise a jour par term_pol_sparse *)
List.iter set_nvars_term lp;
@@ -518,20 +556,29 @@ let theoremedeszeros_termes lp =
| [] -> assert false
| p::lp1 ->
let lpol = List.rev lp1 in
+ (* preprocessing :
+ we remove zero polynomials and duplicate that are not handled by in_ideal
+ lb is kept in order to fix the certificate in the post-processing
+ *)
+ let lpol, lb = clean_pol lpol in
let (cert,lp0,p,_lct) = theoremedeszeros lpol p in
info "cert ok\n";
let lc = cert.last_comb::List.rev cert.gb_comb in
match remove_zeros (fun x -> equal x zeroP) lc with
| [] -> assert false
| (lq::lci) ->
+ (* post-processing : we apply the correction for the last line *)
+ let lq = expand_pol lb lq in
(* lci commence par les nouveaux polynomes *)
- let m= !nvars in
+ let m = !nvars in
let c = pol_sparse_to_term m (polconst m cert.coef) in
let r = Pow(Zero,cert.power) in
let lci = List.rev lci in
+ (* post-processing we apply the correction for the other lines *)
+ let lci = List.map (expand_pol lb) lci in
let lci = List.map (List.map (pol_sparse_to_term m)) lci in
let lq = List.map (pol_sparse_to_term m) lq in
- info ("number of parametres: "^string_of_int nparam^"\n");
+ info ("number of parameters: "^string_of_int nparam^"\n");
info "term computed\n";
(c,r,lci,lq)
)