diff options
author | Frédéric Besson <frederic.besson@inria.fr> | 2016-09-01 16:21:11 +0200 |
---|---|---|
committer | Frédéric Besson <frederic.besson@inria.fr> | 2016-09-01 16:21:11 +0200 |
commit | 1ae74bfd16f00bea0de14299cace8b638f768a70 (patch) | |
tree | 1c31965eab0b5cc89d1d30ad264cb4b5fdb3ae0a /plugins/micromega/coq_micromega.ml | |
parent | 5ea872c80cc8b9d2845629cc75369f061e3bad05 (diff) |
Fixed Bug #5003 : more careful generalisation of dependent terms.
Diffstat (limited to 'plugins/micromega/coq_micromega.ml')
-rw-r--r-- | plugins/micromega/coq_micromega.ml | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/plugins/micromega/coq_micromega.ml b/plugins/micromega/coq_micromega.ml index edcb00b90..42ea8c459 100644 --- a/plugins/micromega/coq_micromega.ml +++ b/plugins/micromega/coq_micromega.ml @@ -1437,7 +1437,36 @@ let rcst_domain_spec = lazy { open Proofview.Notations - +(** Naive topological sort of constr according to the subterm-ordering *) + +(* An element is minimal x is minimal w.r.t y if + x <= y or (x and y are incomparable) *) + +let is_min le x y = + if le x y then true + else if le y x then false else true + +let is_minimal le l c = List.for_all (is_min le c) l + +let find_rem p l = + let rec xfind_rem acc l = + match l with + | [] -> (None, acc) + | x :: l -> if p x then (Some x, acc @ l) + else xfind_rem (x::acc) l in + xfind_rem [] l + +let find_minimal le l = find_rem (is_minimal le l) l + +let rec mk_topo_order le l = + match find_minimal le l with + | (None , _) -> [] + | (Some v,l') -> v :: (mk_topo_order le l') + + +let topo_sort_constr l = mk_topo_order Termops.dependent l + + (** * Instanciate the current Coq goal with a Micromega formula, a varmap, and a * witness. @@ -1464,7 +1493,7 @@ let micromega_order_change spec cert cert_typ env ff (*: unit Proofview.tactic* ] (Tacmach.pf_concl gl)) ; - Tactics.generalize env ; + Tactics.generalize (topo_sort_constr env) ; Tacticals.New.tclTHENLIST (List.map (fun id -> (Tactics.introduction id)) ids) ] end } @@ -1774,7 +1803,7 @@ let micromega_order_changer cert env ff = ("__wit", cert, cert_typ) ] (Tacmach.pf_concl gl))); - Tactics.generalize env ; + Tactics.generalize (topo_sort_constr env) ; Tacticals.New.tclTHENLIST (List.map (fun id -> (Tactics.introduction id)) ids) ] end } |