aboutsummaryrefslogtreecommitdiff
path: root/pretyping/unification.ml
AgeCommit message (Collapse)Author
2015-11-15Merge branch 'v8.5'Pierre-Marie Pédrot
2015-11-11Ensure that conversion is called on terms of the same type inMatthieu Sozeau
unification (not necessarily preserved due to the fo approximation rule).
2015-11-10Revert "Fixing #1225: we now skip the canonically built binding contexts of"Hugo Herbelin
This reverts commit 07620386b3c1b535ee7e43306a6345f015a318f0. Very sorry not ready.
2015-11-10Fixing #1225: we now skip the canonically built binding contexts ofHugo Herbelin
the return clause and of the branches in a "match", computing them automatically when using the "at" clause of pattern, destruct, ... In principle, this is a source of incompatibilities in the numbering, since the internal binders of a "match" are now skipped. We shall deal with that later on.
2015-10-19More monotonicity in Tactics.Pierre-Marie Pédrot
2015-10-18Making Evarutil.new_evar monotonous.Pierre-Marie Pédrot
2015-09-27Removing subst_defined_metas_evars from Evd.Pierre-Marie Pédrot
2015-07-16Refining 71def2f8 on too strong occur-check limiting evar-evarHugo Herbelin
unification in tactics. The relaxing of occur-check was ok but was leading trivial problems of the form ?X[?Meta] = ?X[?Meta] to enter a complex Evar-ization into ?X[?Meta] = ?X[?Y], ?Meta:=?Y which consider_remaining_unif_problems was not any more able to deal with. Doing quick: treat the trivial cases ?X[args] = ?X[args] in an ad hoc way, so that it behaves as if the occur-check had not been restricted.
2015-05-13Safer typing primitives.Pierre-Marie Pédrot
Some functions from pretyping/typing.ml and their derivatives were potential source of evarmap leaks, as they dropped their resulting evarmap. This commit clarifies the situation by renaming them according to a unsafe_* scheme. Their sound variant is likewise renamed to their old name. The following renamings were made. - Typing.type_of -> unsafe_type_of - Typing.e_type_of -> type_of - A new e_type_of function that matches the e_ prefix policy - Tacmach.pf_type_of -> pf_unsafe_type_of - A new safe pf_type_of function. All uses of unsafe_* functions should be eventually eliminated.
2015-04-23Remove almost all the uses of string concatenation when building error messages.Guillaume Melquiond
Since error messages are ultimately passed to Format, which has its own buffers for concatenating strings, using concatenation for preparing error messages just doubles the workload and increases memory pressure.
2015-02-23Fixing rewrite/subst when the subterm to rewrite is argument of an Evar.Hugo Herbelin
This was broken by the attempt to use the same algorithm for rewriting closed subterms than for rewriting subterms with evars: the algorithm to find subterms (w_unify_to_subterm) did not go through evars. But what to do when looking say, for a pattern "S ?n" in a goal "S ?x[a:=S ?y]"? Should we unify ?x[a:=S ?y] with ?n or consider ?x as rigid and look in the instance? If we adopt the first approach, then, what to do when looking for "S ?n" in a goal "?x[a:=S ?y]"? Failing? Looking in the instance? Is it normal that an evar behaves as a rigid constant when it cannot be unified with the pattern?
2015-02-23Fixing occur-check which was too strong in unification.ml.Hugo Herbelin
2015-01-15Correct restriction of vm_compute when handling universe polymorphicMatthieu Sozeau
definitions. Instead of failing with an anomaly when trying to do conversion or computation with the vm's, consider polymorphic constants as being opaque and keep instances around. This way the code is still correct but (obviously) incomplete for polymorphic definitions and we avoid introducing an anomaly. The patch does nothing clever, it only keeps around instances with constants/inductives and compile constant bodies only for non-polymorphic definitions.
2015-01-12Update headers.Maxime Dénès
2014-12-30Simplifying second_order_matching: no need to invert the linearHugo Herbelin
initial segment of the context of the evar.
2014-12-15New try on Fixing an evar_map bug revealed by commit 603b66f81 onHugo Herbelin
unification flags (see also temporary revert in d083200ae5b).
2014-12-15Documenting check_record + changing a possibly undefined int into int option.Hugo Herbelin
2014-12-12Two fixes in unification (bugs #3782 and #3709)Matthieu Sozeau
- In evarconv, check_conv_record properly computes the parameters of primitive record projections for later unification, adding env and sigma as arguments. - In unification, backtrack on pattern-unification and not only application unification if eta for a record failed.
2014-12-11Commit not ready. Sorry.Hugo Herbelin
Revert "Fixing an evar_map bug revealed by commit 603b66f81 on unification flags." This reverts commit d083200ae5b391ceffaa0329a8e3a334036c7968.
2014-12-11Fixing an evar_map bug revealed by commit 603b66f81 on unification flags.Hugo Herbelin
This fixes current failure of RelationAlgebra.
2014-12-05Fix debugger Tactic Unification.Hugo Herbelin
2014-12-05Small cleaning and uniformization in unification flags:Hugo Herbelin
- new function set_flags_for_type for setting flags when converting types of the terms to unify - it now sets all conversion flags, possibly restricting delta using modulo_delta_types - it is now used in w_unify_core_0 too - fixing/improving documentation of options - deprecating "Set Tactic Evars Pattern Unification"
2014-11-27Reverting the following block of three commits:Hugo Herbelin
- Registering strict implicit arguments systematically (35fc7d728168) - Experimenting always forcing convertibility on strict implicit arguments (a1a6d7b99eef5e6) - Fixing Coq compilation (894a3d16471) Systematically computing strict implicit arguments can lead to big computations, so I suspend this attempt, waiting for improved computation of implicit arguments, or alternative heuristics going toward having more conversion in rewrite.
2014-11-26Fixing Coq compilation.Pierre-Marie Pédrot
2014-11-26Experimenting always forcing convertibility on strict implicit argumentsHugo Herbelin
in tactic unification.
2014-11-25A bit more information in debug tactic unification.Hugo Herbelin
2014-11-25Experimenting using unification when matching evar/meta free subtermsHugo Herbelin
while before these were supposed to consider only syntactically. Made the experiment to unify with all delta flags unset. Keeping the same flags as for non evar/meta free subterms would lead to too much successes, as e.g. "true && b" matching "b" when the modulo_conv_on_closed_terms flag is set, which is the case for rewrite. But maybe should we instead investigate to have the same flags but with the restrict_conv_on_strict_subterms flag set. This rules out examples like "true && b" unifying with "b" and this is another option which is ok for compiling the stdlib without any changes.
2014-11-19Option -type-in-type continued (deactivate test for inferred sort ofHugo Herbelin
inductive types + deactivate test for equality of sort + deactivate the check that the constraints Prop/Set <= Type are declared).
2014-11-11Accepting conversion on inner closed subterms while looking forHugo Herbelin
matching subterm destruct/induction on a partially applied pattern. AFAICS, there is only such instance of destruct that needs this in the contrins (in EuclideanGeometry/G3_ParticularAngle.v), but while a more global decision is taken, I prefer at the current time to adopt this approximation of 8.4 semantics, even if the flags are not the same when the pattern is fully applied or not. Only so little cases are concerned because in most cases, destruct/induction on a partially applied pattern is of the form "destruct cst" (e.g. "destruct eq_dec") and no conversion is needed anyway. Not being uniform whether the pattern is fully applied or not is a bit unsatisfactory, but hopefully, this is temporary.
2014-11-08Follow up to experimental eager evar unification in bcba6d1bc9:Hugo Herbelin
Observing that systematic eager evar unification makes unification works better, for instance in setoid rewrite (ATBR, SemiRing.v), we add a new flag use_evars_eagerly_in_conv_on_closed_terms which is put to true only in Rewrite.rewrite_core_unif_flags (empirically, this makes the "rewrite" from rewrite.ml working again on examples which were previously treated by use_metas_eagerly_in_conv_on_closed_terms).
2014-11-04Experimentally applying eager evar substitution at the same time asHugo Herbelin
eager meta substition in w_unify, so as to preserve compatibility after PMP's move of (setoid) rewrite clauses from metas to evars (fbbe491cfa). Hoping it is compatible for non-rewrite uses of the eager meta flag, and that it is not too costly.
2014-11-02Fixing subterm matched for destruct when it is matched from prefix.Hugo Herbelin
2014-10-31Reorganization of the test for generic selection of occurrences inHugo Herbelin
clause; extended it so that an induction over "x" is considered generic when the clause has the form "in H |-" (w/o the conclusion) and x does not occur in the conclusion.
2014-10-31Enlarge the cases where the like first selection is used in destruct.Hugo Herbelin
This is now a "like first" strategy iff there is no occurrences selected in either the goal or in one of the hypotheses possibly given in an "in" clause. Before, it was "like first" if and only if no "in" clause was given at all.
2014-10-27Dead codeHugo Herbelin
2014-10-26Applying like-first selection for destruct in hypotheses.Hugo Herbelin
2014-10-26Fixing destruct/induction with a using clause on a non-inductive type,Hugo Herbelin
that was broken by commit bf01856940 + use types from induction scheme to restrict selection of pattern + accept matching from partially applied term when using "using".
2014-10-26Dead code + typo.Hugo Herbelin
2014-10-25This commit introduces changes in induction and destruct.Hugo Herbelin
The main change is that selection of subterm is made similar whether the given term is fully applied or not. - The selection of subterm now works as follows depending on whether the "at" is given, of whether the subterm is fully applied or not, and whether there are incompatible subterms matching the pattern. In particular, we have: "at" given | subterm fully applied | | incompatible subterms | | | Y Y - it works like in 8.4 Y N - this was broken in 8.4 ("at" was ineffective and it was finding all subterms syntactically equal to the first one which matches) N Y Y it now finds all subterms like the first one which matches while in 8.4 it used to fail (I hope it is not a too risky in-draft for a semantics we would regret...) (e.g. "destruct (S _)" on goal "S x = S y + S x" now selects the two occurrences of "S x" while it was failing before) N Y N it works like in 8.4 N N - it works like in 8.4, selecting all subterms like the first one which matches - Note that the "historical" semantics, when looking for a subterm, to select all subterms that syntactically match the first subterm to match the pattern (looking from left to right) is now internally called "like first". - Selection of subterms can now find the type by pattern-matching (useful e.g. for "induction (nat_rect _ _ _ _)") - A version of Unification.w_unify w/o any conversion is used for finding the subterm: it could be easily replaced by an other matching algorithm. In particular, "destruct H" now works on a goal such as "H:True -> x<=y |- P y". Secondary change is in the interpretation of terms with existential variables: - When several arguments are given, interpretation is delayed at the time of execution - Because we aim at eventually accepting "edestruct c" with unresolved holes in c, we need the sigma obtained from c to be an extension of the sigma of the tactics, while before, we just type-checked c independently of the sigma of the tactic - Finishing the resolution of evars (using type classes, candidates, pending conversion problems) is made slightly cleaner: it now takes three states: a term is evaluated in state sigma, leading to state sigma' >= sigma, with evars finally solved in state sigma'' >= sigma'; we solve evars in the diff of sigma' and sigma and report the solution in sigma'' - We however renounce to give now a success semantics to "edestruct c" when "c" has unresolved holes, waiting instead for a decision on what to do in the case of a similar eapply (see mail to coqdev). An auxiliary change is that an "in" clause can be attached to each component of a "destruct t, u, v", etc. Incidentally, make_abstraction does not do evar resolution itself any longer.
2014-10-15Reenable FO unification of primitive projections and their eta-expandedMatthieu Sozeau
forms in evarconv and unification, as well as fallback to first-order unification when eta for constructors fail. Update test-suite file 3484 to test for the FO case in evarconv as well.
2014-10-15Implement a different strategy to expand primitive projections only whenMatthieu Sozeau
required, i.e. in first-order unification cases where the head of the other side is a hole or the eta-expanded constant.
2014-10-14Oops, forgot a fix needed after the rebase.Matthieu Sozeau
2014-10-14Fix bug #3698: stack overflow due to eta+canonical structures inMatthieu Sozeau
unification.
2014-10-13Moving function about locs in locusops.Hugo Herbelin
2014-10-11Revert d0cd27e209be08ee51a2d609157367f053438a10: giving a different nameMatthieu Sozeau
for the record binder of classes. This name is no longer generated in the kernel but part of the declaration. Also cleanup the interface to recognize primitive records based on an option type instead of a dynamic check of the length of an array.
2014-10-10Add a "Debug Tactic Unification" option and correct the first-orderMatthieu Sozeau
application case to expand primitive projections at the head of both applications.
2014-10-02Work around issues with FO unification trying to unify terms ofMatthieu Sozeau
potentially different types, resulting in ill-typed terms due to eta. Projection expansion now fails gracefully on retyping errors. The proper fix to unification, checking that the heads for FO have unifiable types, is currently too strong, adding unnecessary universe constraints, so it is disabled for now. It might be quite expensive too also it's not noticeable on the stdlib.
2014-09-30Simplify evarconv thanks to new delta status of projections,Matthieu Sozeau
using whd_state_gen to handle unfolding. Add an isProj/destProj in term. Use the proper environment everywhere in unification.ml.
2014-09-29Restoring non-uniform delta on local and global constants in 2nd orderHugo Herbelin
unification for apply (compatibility reason). Waiting for another way to provide a more uniform scheme by default (keyed unification?).
2014-09-29In evarconv and unification, expand folded primitive projections toMatthieu Sozeau
their eta-expanded forms which can then unfold back to the unfolded primitive projection form. This removes all special code that was necessary to handle primitive projections before, while keeping compatibility. Also fix cbn which was not refolding primitive projections correctly in all cases. Update some test-suite files accordingly.