From: Ferruccio Guidi Date: Tue, 26 Nov 2002 11:40:14 +0000 (+0000) Subject: Generator updated for new MathQL.ml X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=7e9ee837f75f38bf01240cdc03dd51c764c2665f;p=helm.git Generator updated for new MathQL.ml Level functions decoupled from Generator --- diff --git a/helm/gTopLevel/.depend b/helm/gTopLevel/.depend index 88a318793..7dce2d61f 100644 --- a/helm/gTopLevel/.depend +++ b/helm/gTopLevel/.depend @@ -41,11 +41,11 @@ fourierR.cmx: fourier.cmx primitiveTactics.cmx proofEngineHelpers.cmx \ fourierR.cmi: proofEngineTypes.cmo proofEngine.cmo: fourierR.cmi primitiveTactics.cmi proofEngineHelpers.cmi \ proofEngineReduction.cmi proofEngineStructuralRules.cmi \ - proofEngineTypes.cmo ring.cmi tacticals.cmi variousTactics.cmi \ + proofEngineTypes.cmo reductionTactics.cmi ring.cmi variousTactics.cmi \ proofEngine.cmi proofEngine.cmx: fourierR.cmx primitiveTactics.cmx proofEngineHelpers.cmx \ proofEngineReduction.cmx proofEngineStructuralRules.cmx \ - proofEngineTypes.cmx ring.cmx tacticals.cmx variousTactics.cmx \ + proofEngineTypes.cmx reductionTactics.cmx ring.cmx variousTactics.cmx \ proofEngine.cmi proofEngine.cmi: proofEngineTypes.cmo doubleTypeInference.cmo: doubleTypeInference.cmi @@ -59,6 +59,8 @@ logicalOperations.cmo: proofEngine.cmi logicalOperations.cmi logicalOperations.cmx: proofEngine.cmx logicalOperations.cmi sequentPp.cmo: cic2Xml.cmi cic2acic.cmi proofEngine.cmi sequentPp.cmi sequentPp.cmx: cic2Xml.cmx cic2acic.cmx proofEngine.cmx sequentPp.cmi +mQueryLevels.cmo: mQueryLevels.cmi +mQueryLevels.cmx: mQueryLevels.cmi mQueryGenerator.cmo: mQueryGenerator.cmi mQueryGenerator.cmx: mQueryGenerator.cmi gTopLevel.cmo: cic2Xml.cmi cic2acic.cmi logicalOperations.cmi \ diff --git a/helm/gTopLevel/Makefile b/helm/gTopLevel/Makefile index 200305cbe..7109f291a 100644 --- a/helm/gTopLevel/Makefile +++ b/helm/gTopLevel/Makefile @@ -24,7 +24,7 @@ DEPOBJS = xml2Gdome.ml xml2Gdome.mli proofEngineTypes.ml proofEngineHelpers.ml \ doubleTypeInference.ml doubleTypeInference.mli cic2acic.ml \ cic2acic.mli cic2Xml.ml cic2Xml.mli logicalOperations.ml \ logicalOperations.mli sequentPp.ml sequentPp.mli mQueryGenerator.mli \ - mQueryGenerator.ml gTopLevel.ml + mQueryLevels.ml mQueryGenerator.ml gTopLevel.ml TOPLEVELOBJS = xml2Gdome.cmo proofEngineTypes.cmo proofEngineHelpers.cmo \ proofEngineReduction.cmo proofEngineStructuralRules.cmo \ @@ -32,8 +32,8 @@ TOPLEVELOBJS = xml2Gdome.cmo proofEngineTypes.cmo proofEngineHelpers.cmo \ variousTactics.cmo \ ring.cmo fourier.cmo fourierR.cmo proofEngine.cmo \ doubleTypeInference.cmo cic2acic.cmo cic2Xml.cmo \ - logicalOperations.cmo sequentPp.cmo mQueryGenerator.cmo \ - gTopLevel.cmo + logicalOperations.cmo sequentPp.cmo \ + mQueryLevels.cmo mQueryGenerator.cmo gTopLevel.cmo depend: $(OCAMLDEP) $(DEPOBJS) > .depend diff --git a/helm/gTopLevel/gTopLevel.ml b/helm/gTopLevel/gTopLevel.ml index 4a2fdc561..8aa9e8288 100644 --- a/helm/gTopLevel/gTopLevel.ml +++ b/helm/gTopLevel/gTopLevel.ml @@ -2016,8 +2016,8 @@ let searchPattern () = let html = "

Backward Query:

" ^ "

Levels:

" ^ - MQueryGenerator.string_of_levels - (MQueryGenerator.levels_of_term metasenv ey ty) "
" ^ + MQueryLevels.string_of_levels + (MQueryLevels.levels_of_term metasenv ey ty) "
" ^ "
" ^ get_last_query result ^ "
" in output_html outputhtml html ; diff --git a/helm/gTopLevel/mQueryGenerator.ml b/helm/gTopLevel/mQueryGenerator.ml index b91261c07..b12f19bac 100644 --- a/helm/gTopLevel/mQueryGenerator.ml +++ b/helm/gTopLevel/mQueryGenerator.ml @@ -33,114 +33,6 @@ (* *) (******************************************************************************) -(* level managing functions *************************************************) - -type levels_spec = (string * bool * int) list - -let levels_of_term metasenv context term = - let module TC = CicTypeChecker in - let module Red = CicReduction in - let module Util = MQueryUtil in - let degree t = - let rec degree_aux = function - | Cic.Sort _ -> 1 - | Cic.Cast (u, _) -> degree_aux u - | Cic.Prod (_, _, t) -> degree_aux t - | _ -> 2 - in - let u = TC.type_of_aux' metasenv context t in - degree_aux (Red.whd context u) - in - let entry_eq (s1, b1, v1) (s2, b2, v2) = - s1 = s2 && b1 = b2 - in - let rec entry_in e = function - | [] -> [e] - | head :: tail -> - head :: if entry_eq head e then tail else entry_in e tail - in - let inspect_uri main l uri tc v term = - let d = degree term in - entry_in (Util.string_of_uriref (uri, tc), main, 2 * v + d - 1) l - in - let rec inspect_term main l v term = match term with - Cic.Rel _ -> l - | Cic.Meta _ -> l - | Cic.Sort _ -> l - | Cic.Implicit -> l - | Cic.Var (u,exp_named_subst) -> - let l' = inspect_uri main l u [] v term in - inspect_exp_named_subst l' (v+1) exp_named_subst - | Cic.Const (u,exp_named_subst) -> - let l' = inspect_uri main l u [] v term in - inspect_exp_named_subst l' (v+1) exp_named_subst - | Cic.MutInd (u, t, exp_named_subst) -> - let l' = inspect_uri main l u [t] v term in - inspect_exp_named_subst l' (v+1) exp_named_subst - | Cic.MutConstruct (u, t, c, exp_named_subst) -> - let l' = inspect_uri main l u [t; c] v term in - inspect_exp_named_subst l' (v+1) exp_named_subst - | Cic.Cast (uu, _) -> - inspect_term main l v uu - | Cic.Prod (_, uu, tt) -> - let luu = inspect_term false l (v + 1) uu in - inspect_term main luu (v + 1) tt - | Cic.Lambda (_, uu, tt) -> - let luu = inspect_term false l (v + 1) uu in - inspect_term false luu (v + 1) tt - | Cic.LetIn (_, uu, tt) -> - let luu = inspect_term false l (v + 1) uu in - inspect_term false luu (v + 1) tt - | Cic.Appl m -> inspect_list main l true v m - | Cic.MutCase (u, t, tt, uu, m) -> - let lu = inspect_uri main l u [t] (v + 1) term in - let ltt = inspect_term false lu (v + 1) tt in - let luu = inspect_term false ltt (v + 1) uu in - inspect_list main luu false (v + 1) m - | Cic.Fix (_, m) -> inspect_ind l (v + 1) m - | Cic.CoFix (_, m) -> inspect_coind l (v + 1) m - and inspect_list main l head v = function - | [] -> l - | tt :: m -> - let ltt = inspect_term main l (if head then v else v + 1) tt in - inspect_list false ltt false v m - and inspect_exp_named_subst l v = function - [] -> l - | (_,t) :: tl -> - let l' = inspect_term false l v t in - inspect_exp_named_subst l' v tl - and inspect_ind l v = function - | [] -> l - | (_, _, tt, uu) :: m -> - let ltt = inspect_term false l v tt in - let luu = inspect_term false ltt v uu in - inspect_ind luu v m - and inspect_coind l v = function - | [] -> l - | (_, tt, uu) :: m -> - let ltt = inspect_term false l v tt in - let luu = inspect_term false ltt v uu in - inspect_coind luu v m - in - let rec inspect_backbone = function - | Cic.Cast (uu, _) -> inspect_backbone uu - | Cic.Prod (_, _, tt) -> inspect_backbone tt - | Cic.LetIn (_, uu, tt) -> inspect_backbone tt - | t -> inspect_term true [] 0 t - in - inspect_backbone term - -let string_of_levels l sep = - let entry_out (s, b, v) = - let pos = if b then " HEAD: " else " TAIL: " in - string_of_int v ^ pos ^ s ^ sep - in - let rec levels_out = function - | [] -> "" - | head :: tail -> entry_out head ^ levels_out tail - in - levels_out l - (* Query issuing functions **************************************************) exception Discard @@ -200,12 +92,15 @@ let execute_query query = let locate s = let module M = MathQL in let q = - M.Ref (M.Attribute true M.RefineExact ("objectName", []) (M.Const [s])) + M.Ref (M.Property true M.RefineExact ("objectName", []) (M.Const [s])) in execute_query q let searchPattern e c t level = let module M = MathQL in + let module L = MQueryLevels in + let in_path s = (s, []) in + let assign v p = (in_path v, in_path p) in let v_pos = M.Const ["MainConclusion"; "InConclusion"] in let q_where = M.Sub @@ -213,9 +108,10 @@ let searchPattern e c t level = (M.Select ("uri", M.Relation - (false, M.RefineExact, ("refObj", []), M.RVar "uri0", ["pos"]), + (false, M.RefineExact, in_path "refObj", M.RVar "uri0", + [assign "pos" "position"]), M.Ex ["uri"] - (M.Meet (M.VVar "positions", M.Record ("uri", ("pos", [])))) + (M.Meet (M.VVar "positions", M.Record ("uri", in_path "pos"))) ) ), M.VVar "universe" @@ -231,19 +127,15 @@ let searchPattern e c t level = let pos = if b then "MainConclusion" else "InConclusion" in M.Select ("uri", - M.Relation - (false, - M.RefineExact, - ("backPointer", []), - M.Ref (M.Const [r]), - ["pos"]), - M.Ex ["uri"] (M.Sub (M.Const [pos], M.Record ("uri", ("pos", []))))) in + M.Relation (false, M.RefineExact, ("backPointer", []), + M.Ref (M.Const [r]), [assign "pos" "position"]), + M.Ex ["uri"] (M.Sub (M.Const [pos], M.Record ("uri", in_path "pos")))) in let rec build_intersect = function - | [] -> M.Pattern (M.Const [".*"]) + | [] -> M.Pattern (M.Const ["[.]*"]) | [hd] -> build_select hd | hd :: tl -> M.Intersect (build_select hd, build_intersect tl) in - let levels = levels_of_term e c t in + let levels = L.levels_of_term e c t in let rest = restrict level levels in info := [string_of_int (List.length rest)]; let q_in = build_intersect rest in diff --git a/helm/gTopLevel/mQueryGenerator.mli b/helm/gTopLevel/mQueryGenerator.mli index 2e4e59d5c..68c2ea257 100644 --- a/helm/gTopLevel/mQueryGenerator.mli +++ b/helm/gTopLevel/mQueryGenerator.mli @@ -35,12 +35,6 @@ exception Discard -type levels_spec = (string * bool * int) list - -val levels_of_term : Cic.metasenv -> Cic.context -> Cic.term -> levels_spec - -val string_of_levels : levels_spec -> string -> string - val set_log_file : string -> unit (* the callback function must return false iff the query must be skipped *) diff --git a/helm/gTopLevel/topLevel/Makefile b/helm/gTopLevel/topLevel/Makefile index 01dd0e173..24c631a10 100644 --- a/helm/gTopLevel/topLevel/Makefile +++ b/helm/gTopLevel/topLevel/Makefile @@ -14,7 +14,7 @@ opt: topLevel.opt DEPOBJS = topLevel.ml -TOPLEVELOBJS = ../mQueryGenerator.cmo topLevel.cmo +TOPLEVELOBJS = ../mQueryLevels.cmo ../mQueryGenerator.cmo topLevel.cmo depend: $(OCAMLDEP) $(DEPOBJS) > .depend diff --git a/helm/gTopLevel/topLevel/topLevel.ml b/helm/gTopLevel/topLevel/topLevel.ml index d4af37c23..4825c5b36 100644 --- a/helm/gTopLevel/topLevel/topLevel.ml +++ b/helm/gTopLevel/topLevel/topLevel.ml @@ -74,13 +74,13 @@ let rec display = function flush stdout let levels l = - let module Gen = MQueryGenerator in + let module Lev = MQueryLevels in let rec levels_aux = function | [] -> () | term :: tail -> levels_aux tail; print_string ("? " ^ CicPp.ppterm term ^ nl); - print_string (Gen.string_of_levels (Gen.levels_of_term [] [] term) nl); + print_string (Lev.string_of_levels (Lev.levels_of_term [] [] term) nl); flush stdout in levels_aux l