diff --git a/thys/ML_Unification/Unification_Hints/ML_Unification_Hints.thy b/thys/ML_Unification/Unification_Hints/ML_Unification_Hints.thy --- a/thys/ML_Unification/Unification_Hints/ML_Unification_Hints.thy +++ b/thys/ML_Unification/Unification_Hints/ML_Unification_Hints.thy @@ -1,103 +1,103 @@ \<^marker>\creator "Kevin Kappelmann"\ section \Unification Hints\ theory ML_Unification_Hints imports ML_Generic_Data_Utils ML_Term_Index ML_Unifiers ML_Unification_Parsers begin paragraph \Summary\ text \A generalisation of unification hints, originally introduced in \<^cite>\"unif-hints"\. We support a generalisation that \<^enum> allows additional universal variables in premises \<^enum> allows non-atomic left-hand sides for premises \<^enum> allows arbitrary functions to perform the matching/unification of a hint with a disagreement pair. General shape of a hint: \\y1...yn. (\x1...xn1. lhs1 \ rhs1) \ ... \ (\x1...xnk. lhsk \ rhsk) \ lhs \ rhs\ \ ML_file\unification_hints_base.ML\ ML_file\unification_hints.ML\ ML_file\term_index_unification_hints.ML\ text \We now set up two unifiers using unification hints. The first one allows for recursive -applications of unification hints when unifying a hint's conclusion lhs \ rhs" with a goal -"lhs' \ rhs'". +applications of unification hints when unifying a hint's conclusion \lhs \ rhs\ with a goal +\lhs' \ rhs'\. The second only uses a combination of higher-order pattern and first-order unification. This particularly implies that recursive applications of unification hints have to be made explicit in the hint itself (cf. @{dir "../Examples"}). While the former can be convenient for local hint registrations and quick developments, it is advisable to use the second for global hints to avoid unexpected looping behaviour.\ ML\ @{functor_instance struct_name = Standard_Unification_Hints_Rec and functor_name = Term_Index_Unification_Hints and id = \"rec"\ and more_args = \ structure TI = Discrimination_Tree val init_args = { concl_unifier = SOME Standard_Mixed_Unification.first_higherp_first_comb_higher_unify, prems_unifier = SOME (Standard_Mixed_Unification.first_higherp_first_comb_higher_unify |> Unification_Combinator.norm_unifier Envir_Normalisation.beta_norm_term_unif), normalisers = SOME Standard_Mixed_Unification.norms_first_higherp_first_comb_higher_unify, retrieval = SOME (Term_Index_Unification_Hints_Args.mk_sym_retrieval TI.norm_term TI.unifiables), hint_preprocessor = SOME (K I) }\} \ local_setup \Standard_Unification_Hints_Rec.setup_attribute NONE\ text\Standard unification hints using @{ML Standard_Mixed_Unification.first_higherp_first_comb_higher_unify} when looking for hints are accessible via @{attribute rec_uhint}. -\<^emph>\Note:\ when we retrieve a potential unification hint with conclusion "lhs \ rhs" for a goal -"lhs' \ rhs'", we only consider those hints whose lhs potentially higher-order unifies with -lhs' or rhs' \<^emph>\without using hints\. For otherwise, any hint "lhs \ rhs" applied to a goal -"rhs \ lhs" leads to an immediate loop.\ +\<^emph>\Note:\ when we retrieve a potential unification hint with conclusion \lhs \ rhs\ for a goal +\lhs' \ rhs'\, we only consider those hints whose lhs potentially higher-order unifies with +lhs' or rhs' \<^emph>\without using hints\. For otherwise, any hint \lhs \ rhs\ applied to a goal +\rhs \ lhs\ leads to an immediate loop.\ ML\ @{functor_instance struct_name = Standard_Unification_Hints and functor_name = Term_Index_Unification_Hints and id = \""\ and more_args = \ structure TI = Discrimination_Tree val init_args = { concl_unifier = SOME Higher_Ordern_Pattern_First_Decomp_Unification.unify, prems_unifier = SOME (Standard_Mixed_Unification.first_higherp_first_comb_higher_unify |> Unification_Combinator.norm_unifier Envir_Normalisation.beta_norm_term_unif), normalisers = SOME Standard_Mixed_Unification.norms_first_higherp_first_comb_higher_unify, retrieval = SOME (Term_Index_Unification_Hints_Args.mk_sym_retrieval TI.norm_term TI.unifiables), hint_preprocessor = SOME (K I) }\} \ local_setup \Standard_Unification_Hints.setup_attribute NONE\ text\Standard unification hints using @{ML Higher_Ordern_Pattern_First_Decomp_Unification.unify} when looking for hints are accessible via @{attribute uhint}. \<^emph>\Note:\ there will be no recursive usage of unification hints when searching for potential unification hints in this case. See also @{dir "../Examples"}.\ declare [[ucombine add = \Standard_Unification_Combine.eunif_data (Standard_Unification_Hints_Rec.try_hints |> Unification_Combinator.norm_unifier (#norm_term Standard_Mixed_Unification.norms_first_higherp_first_comb_higher_unify) |> K) (Standard_Unification_Combine.default_metadata Standard_Unification_Hints_Rec.binding)\]] and [[ucombine add = \Standard_Unification_Combine.eunif_data (Standard_Unification_Hints.try_hints |> Unification_Combinator.norm_unifier (#norm_term Standard_Mixed_Unification.norms_first_higherp_first_comb_higher_unify) |> K) (Standard_Unification_Combine.default_metadata Standard_Unification_Hints.binding)\]] text\Examples see @{dir "../Examples"}.\ end