From 4cbd4cadc2e71d4d25469dd7dddf05088baacb62 Mon Sep 17 00:00:00 2001 From: natile Date: Wed, 4 Dec 2002 17:34:58 +0000 Subject: [PATCH] *** empty log message *** --- helm/gTopLevel/.depend | 20 +- helm/gTopLevel/gTopLevel.ml | 32 ++-- helm/gTopLevel/mQueryGenerator.ml | 282 ++++++++++++++++++++++++----- helm/gTopLevel/mQueryGenerator.mli | 21 ++- helm/gTopLevel/mQueryLevels2.ml | 2 +- 5 files changed, 288 insertions(+), 69 deletions(-) diff --git a/helm/gTopLevel/.depend b/helm/gTopLevel/.depend index 026b4aacf..a1f583bb0 100644 --- a/helm/gTopLevel/.depend +++ b/helm/gTopLevel/.depend @@ -22,9 +22,13 @@ primitiveTactics.cmx: proofEngineHelpers.cmx proofEngineReduction.cmx \ proofEngineTypes.cmx reductionTactics.cmx tacticals.cmx \ primitiveTactics.cmi primitiveTactics.cmi: proofEngineTypes.cmo -variousTactics.cmo: primitiveTactics.cmi proofEngineTypes.cmo tacticals.cmi \ +variousTactics.cmo: primitiveTactics.cmi proofEngineHelpers.cmi \ + proofEngineReduction.cmi proofEngineStructuralRules.cmi \ + proofEngineTypes.cmo reductionTactics.cmi tacticals.cmi \ variousTactics.cmi -variousTactics.cmx: primitiveTactics.cmx proofEngineTypes.cmx tacticals.cmx \ +variousTactics.cmx: primitiveTactics.cmx proofEngineHelpers.cmx \ + proofEngineReduction.cmx proofEngineStructuralRules.cmx \ + proofEngineTypes.cmx reductionTactics.cmx tacticals.cmx \ variousTactics.cmi variousTactics.cmi: proofEngineTypes.cmo ring.cmo: primitiveTactics.cmi proofEngineStructuralRules.cmi \ @@ -33,11 +37,11 @@ ring.cmx: primitiveTactics.cmx proofEngineStructuralRules.cmx \ proofEngineTypes.cmx tacticals.cmx variousTactics.cmx ring.cmi ring.cmi: proofEngineTypes.cmo fourierR.cmo: fourier.cmo primitiveTactics.cmi proofEngineHelpers.cmi \ - proofEngineReduction.cmi proofEngineTypes.cmo reductionTactics.cmi \ - ring.cmi tacticals.cmi fourierR.cmi + proofEngineTypes.cmo reductionTactics.cmi ring.cmi tacticals.cmi \ + variousTactics.cmi fourierR.cmi fourierR.cmx: fourier.cmx primitiveTactics.cmx proofEngineHelpers.cmx \ - proofEngineReduction.cmx proofEngineTypes.cmx reductionTactics.cmx \ - ring.cmx tacticals.cmx fourierR.cmi + proofEngineTypes.cmx reductionTactics.cmx ring.cmx tacticals.cmx \ + variousTactics.cmx fourierR.cmi fourierR.cmi: proofEngineTypes.cmo proofEngine.cmo: fourierR.cmi primitiveTactics.cmi proofEngineHelpers.cmi \ proofEngineReduction.cmi proofEngineStructuralRules.cmi \ @@ -63,8 +67,8 @@ mQueryLevels.cmo: mQueryLevels.cmi mQueryLevels.cmx: mQueryLevels.cmi mQueryLevels2.cmo: mQueryLevels2.cmi mQueryLevels2.cmx: mQueryLevels2.cmi -mQueryGenerator.cmo: mQueryLevels.cmi mQueryGenerator.cmi -mQueryGenerator.cmx: mQueryLevels.cmx mQueryGenerator.cmi +mQueryGenerator.cmo: mQueryGenerator.cmi +mQueryGenerator.cmx: mQueryGenerator.cmi gTopLevel.cmo: cic2Xml.cmi cic2acic.cmi logicalOperations.cmi \ mQueryGenerator.cmi mQueryLevels.cmi mQueryLevels2.cmi proofEngine.cmi \ sequentPp.cmi xml2Gdome.cmi diff --git a/helm/gTopLevel/gTopLevel.ml b/helm/gTopLevel/gTopLevel.ml index a3e369057..4363b3bee 100644 --- a/helm/gTopLevel/gTopLevel.ml +++ b/helm/gTopLevel/gTopLevel.ml @@ -27,7 +27,7 @@ (* *) (* PROJECT HELM *) (* *) -(* Claudio Sacerdoti Coen *) +(* Claudio Sacerdoti Coen *) (* 06/01/2002 *) (* *) (* *) @@ -60,12 +60,12 @@ let htmlfooter = "" ;; -let prooffile = "/public/sacerdot/currentproof";; -let prooffiletype = "/public/sacerdot/currentprooftype";; +let prooffile = "/public/natile/currentproof";; +let prooffiletype = "/public/natile/currentprooftype";; (* SACERDOT -let prooffile = "/public/sacerdot/currentproof";; -let prooffiletype = "/public/sacerdot/currentprooftype";; +let prooffile = "/public/natile/currentproof";; +let prooffiletype = "/public/natile/currentprooftype";; *) (* TASSI @@ -80,12 +80,12 @@ let prooffiletype = "/home/galata/miohelm/currentprooftype";; (*CSC: the getter should handle the innertypes, not the FS *) -let innertypesfile = "/public/sacerdot/innertypes";; -let constanttypefile = "/public/sacerdot/constanttype";; +let innertypesfile = "/public/natile/innertypes";; +let constanttypefile = "/public/natile/constanttype";; (* SACERDOT -let innertypesfile = "/public/sacerdot/innertypes";; -let constanttypefile = "/public/sacerdot/constanttype";; +let innertypesfile = "/public/natile/innertypes";; +let constanttypefile = "/public/natile/constanttype";; *) (* TASSI @@ -2369,7 +2369,10 @@ let completeSearchPattern () = try let dom,mk_metasenv_and_expr = inputt#get_term ~context:[] ~metasenv:[] in let metasenv,expr = disambiguate_input [] [] dom mk_metasenv_and_expr in - ignore (MQueryLevels2.get_constraints expr) + let must,can = MQueryLevels2.get_constraints expr in + let result = MQueryGenerator.searchPattern must can in + output_html outputhtml + ("

" ^ MQueryUtil.text_of_result result "\n" ^ "

") with e -> output_html outputhtml @@ -2516,7 +2519,14 @@ let searchPattern () = let (_, ey ,ty) = List.find (function (m,_,_) -> m=metano) metasenv in let list_of_must,can = MQueryLevels.out_restr metasenv ey ty in let must = choose_must list_of_must can in - let result = MQueryGenerator.searchPattern metasenv ey ty must can in + let torigth_restriction (u,b) = + let p = if b then "http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion" + else "http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion" in + (u,p,None) + in + let rigth_must = List.map torigth_restriction must in + let rigth_can = Some (List.map torigth_restriction can) in + let result = MQueryGenerator.searchPattern (rigth_must,[],[]) (rigth_can,None,None) in let uris = List.map (function uri,_ -> diff --git a/helm/gTopLevel/mQueryGenerator.ml b/helm/gTopLevel/mQueryGenerator.ml index c925e27a6..88a50c41d 100644 --- a/helm/gTopLevel/mQueryGenerator.ml +++ b/helm/gTopLevel/mQueryGenerator.ml @@ -35,6 +35,28 @@ (* Query issuing functions **************************************************) + + +type uri = string +type position = string +type depth = int +type sort = string + +type r_obj = (uri * position * depth option) +type r_rel = (position* depth) +type r_sort = (position* depth * sort) + +type must_restrictions = (r_obj list * r_rel list * r_sort list) +type can_restrictions = (r_obj list option * r_rel list option * r_sort list option) + + + + + + + + + exception Discard let nl = "

\n" @@ -96,59 +118,223 @@ let locate s = in execute_query q -let searchPattern e c t must_use can_use = +let searchPattern must_use can_use = let module M = MathQL in - let module L = MQueryLevels in - let mainConclusion = - "http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion" in - let inConclusion = - "http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion" 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 - (M.RefOf - (M.Select - ("uri", - M.Relation - (false, M.RefineExact, in_path "refObj", - M.Ref (M.RefOf (M.RVar "uri0")), - [assign "pos" "position"]), - M.Ex ["uri"] - (M.Meet (M.VVar "positions", M.Record ("uri", in_path "pos"))) - ) - ), - M.VVar "universe" - ) in - let uri_of_entry (r, b) = r in - (*let rec restrict level = function - | [] -> [] - | (u, b, v) :: tail -> - if v <= level then (u, b, v) :: restrict level tail - else restrict level tail - in*) - let build_select (r, b) = - print_endline (">>>>LA URI: "^r); - let pos = if b then mainConclusion else inConclusion in - M.Select + + let q_where_obj = function + Some l -> + M.Sub + (M.RefOf + (M.Select + ("uri", + M.Relation + (false, M.RefineExact, in_path "refObj", + M.Ref (M.RefOf (M.RVar "uri0")), + [assign "pos" "position"]), + M.Ex ["uri"] + (M.Meet (M.VVar "obj_positions", M.Record ("uri", in_path "pos"))) + ) + ), + M.VVar "universe" + ) + | None -> M.True + in + + let q_where_rel = function + Some l -> + M.And + (M.Sub(M.VVar "rel_positions", M.Property(false, M.RefineExact, ("refRel", ["position"]), M.RefOf(M.RVar "uri0"))), + M.Sub(M.VVar "rel_depths", M.Property(false, M.RefineExact, ("refRel", ["depth"]), M.RefOf(M.RVar "uri0")))) + | None -> M.True + in + + let q_where_sort = function + Some l -> + M.And + (M.And + (M.Sub(M.VVar "sort_positions", M.Property(false, M.RefineExact, ("refSort", ["position"]), M.RefOf(M.RVar "uri0"))), + M.Sub(M.VVar "sort_depths", M.Property(false, M.RefineExact, ("refSort", ["depth"]), M.RefOf(M.RVar "uri0")))), + M.Sub(M.VVar "sorts", M.Property(false, M.RefineExact, ("refSort", ["sort"]), M.RefOf(M.RVar "uri0")))) + | None -> M.True + in + + let q_where cr = + let (cr_o,cr_r,cr_s) = cr in + M.And(M.And(q_where_obj cr_o, q_where_rel cr_r), q_where_sort cr_s) + + in + + let uri_of_entry (r, p, d) = r in + + let build_select_obj (r, pos, dep) = + match dep with + None -> M.Select + ("uri", + 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"))))) + | Some dep -> let string_dep = string_of_int dep in + M.Select + ("uri", + M.Relation (false, M.RefineExact, ("backPointer", []), + M.Ref (M.Const [r]), [assign "p" "position";assign "d" "depth"]), + M.Ex ["uri"] + (M.And + ((M.Sub (M.Const [pos], M.Record ("uri", in_path "p"))), + (M.Sub (M.Const [string_dep], M.Record ("uri", in_path "d")))))) + in + + let build_select_rel (pos, dep) = + M.Select + ("uri", + M.Relation (true, M.RefineExact, ("refRel", []), M.Ref (M.Const [""]), [assign "p" "position";assign "d" "depth"]), + M.Ex ["uri"] + (M.And + ((M.Sub (M.Const [pos], M.Record ("uri", in_path "p"))), + (M.Sub (M.Const [dep], M.Record ("uri", in_path "d")))))) + in + + let build_select_sort (pos, dep, sor) = + M.Select ("uri", - 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 ["[.]*"]) - | [hd] -> build_select hd - | hd :: tl -> M.Intersect (build_select hd, build_intersect tl) + M.Relation (true, M.RefineExact, ("refSort", []), M.Ref (M.Const [""]), [assign "p" "position";assign "d" "depth";assign "s" "sort"]), + M.Ex ["uri"] + (M.And + ((M.And + ((M.Sub (M.Const [pos], M.Record ("uri", in_path "p"))), + (M.Sub (M.Const [dep], M.Record ("uri", in_path "d"))))), + (M.Sub (M.Const [sor], M.Record ("uri", in_path "s")))))) + in + + let rec build_intersect_obj = function + [] -> M.Pattern (M.Const ["[.]*"]) + | [hd] -> build_select_obj hd + | hd :: tl -> M.Intersect (build_select_obj hd, build_intersect_obj tl) + in + + let rec build_intersect_rel = function + [] -> M.Ref(M.Const []) + | [hd] -> build_select_rel hd + | hd :: tl -> M.Intersect (build_select_rel hd, build_intersect_rel tl) 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 rec build_intersect_sort = function + [] -> M.Ref(M.Const []) + | [hd] -> build_select_sort hd + | hd :: tl -> M.Intersect (build_select_sort hd, build_intersect_sort tl) + in + + let build_intersect must = + let tostring_sort (a,b,c) = + let b1 = string_of_int b in + (a,b1,c) + in + let tostring_rel (a,b) = + let b1 = string_of_int b in + (a,b1) + in + + let (l1,l2,l3) = must in + match (l1,l2,l3) with + l1,[],[] -> build_intersect_obj l1 + | [],l2,[] -> let lrel = List.map tostring_rel l2 in + build_intersect_rel lrel + | [],[],l3 -> let lsort = List.map tostring_sort l3 in + build_intersect_sort lsort + | l1,l2,[] -> let lrel = List.map tostring_rel l2 in + M.Intersect (build_intersect_obj l1, build_intersect_rel lrel) + | l1,[],l3 -> let lsort = List.map tostring_sort l3 in + M.Intersect (build_intersect_obj l1, build_intersect_sort lsort) + | [],l2,l3 -> let lrel = List.map tostring_rel l2 in + let lsort = List.map tostring_sort l3 in + M.Intersect (build_intersect_rel lrel, build_intersect_sort lsort) + | _ -> let lrel = List.map tostring_rel l2 in + let lsort = List.map tostring_sort l3 in + M.Intersect (M.Intersect (build_intersect_obj l1, build_intersect_rel lrel), build_intersect_sort lsort) + in + let q_in = build_intersect must_use in - let q_select = M.Select ("uri0", q_in, q_where) in - let universe = M.Const (List.map uri_of_entry can_use) in + let q_select = M.Select ("uri0", q_in, q_where can_use) in + + let (cr_o,cr_r,cr_s) = can_use in + + let universe = + match cr_o with + None -> M.Const [] + | Some cr_o -> M.Const (List.map uri_of_entry cr_o) + in + + let tfst (a,b,c) = a in + let tsnd (a,b,c) = b in + let trd (a,b,c) = c in + + let opos = + match cr_o with + None -> M.Const [] + | Some cr_o -> M.Const (List.map tsnd cr_o) in + + let odep = + match cr_o with + None -> M.Const [] + | Some cr_o -> let lofc = List.map trd cr_o in + let f l c = + match c with + None -> l + | Some c -> l@[c] + in + let lof_dep_int = List.fold_left f [] lofc in + M.Const(List.map string_of_int lof_dep_int) + in + + let rpos = + match cr_r with + None -> M.Const [] + | Some cr_r -> M.Const (List.map fst cr_r) in + + let rdep = + match cr_r with + None -> M.Const [] + | Some cr_r -> let rdep_int = List.map snd cr_r in + M.Const (List.map string_of_int rdep_int) + in + + + let spos = + match cr_s with + None -> M.Const [] + | Some cr_s -> M.Const (List.map tfst cr_s) in + + + let sdep = + match cr_s with + None -> M.Const [] + | Some cr_s -> let sdep_int = List.map tsnd cr_s in + M.Const (List.map string_of_int sdep_int) + in + + + let sor = + match cr_s with + None -> M.Const[] + | Some cr_s -> M.Const (List.map trd cr_s) in + let q_let_u = M.LetVVar ("universe", universe, q_select) in - let q_let_p = M.LetVVar ("positions", v_pos, q_let_u) in -print_endline ("### " ^ MQueryUtil.text_of_query q_let_p) ; flush stdout; - execute_query q_let_p + + let q_let_s = M.LetVVar ("sorts", sor, q_let_u) in + + let q_let_ds = M.LetVVar ("sort_depths", sdep, q_let_s) in + + let q_let_dr = M.LetVVar ("rel_depths", rdep, q_let_ds) in + + let q_let_do = M.LetVVar ("obj_depths", odep, q_let_dr) in + + let q_let_ps = M.LetVVar ("sort_positions", spos, q_let_do) in + + let q_let_pr = M.LetVVar ("rel_positions", rpos, q_let_ps) in + + let q_let_po = M.LetVVar ("obj_positions", opos, q_let_pr) in +print_endline ("### " ^ MQueryUtil.text_of_query q_let_po) ; flush stdout; + execute_query q_let_po diff --git a/helm/gTopLevel/mQueryGenerator.mli b/helm/gTopLevel/mQueryGenerator.mli index 8723f9c9f..e6b98c2ea 100644 --- a/helm/gTopLevel/mQueryGenerator.mli +++ b/helm/gTopLevel/mQueryGenerator.mli @@ -35,6 +35,25 @@ exception Discard +type uri = string +type position = string +type depth = int +type sort = string + +type r_obj = (uri * position * depth option) +type r_rel = (position * depth) +type r_sort = (position * depth * sort) +(* +type r_obj = (string * string * int option) +type r_rel = (string * int) +type r_sort = (string * int * string) +*) + +type must_restrictions = (r_obj list * r_rel list * r_sort list) +type can_restrictions = (r_obj list option * r_rel list option * r_sort list option) + + + val set_log_file : string -> unit (* the callback function must return false iff the query must be skipped *) @@ -44,6 +63,6 @@ val execute_query : MathQL.query -> MathQL.result val locate : string -> MathQL.result -val searchPattern : Cic.metasenv -> Cic.context -> Cic.term -> (string * bool) list -> (string * bool) list -> MathQL.result +val searchPattern : must_restrictions -> can_restrictions -> MathQL.result val get_query_info : unit -> string list diff --git a/helm/gTopLevel/mQueryLevels2.ml b/helm/gTopLevel/mQueryLevels2.ml index 80bbdf1b6..c4bf895dd 100644 --- a/helm/gTopLevel/mQueryLevels2.ml +++ b/helm/gTopLevel/mQueryLevels2.ml @@ -88,7 +88,7 @@ let get_constraints term = let s' = match s with Cic.Prop -> - "http://www.cs.unibo.it/helm/schemas/schema-helm#Prod" + "http://www.cs.unibo.it/helm/schemas/schema-helm#Prop" | Cic.Set -> "http://www.cs.unibo.it/helm/schemas/schema-helm#Set" | Cic.Type -> -- 2.39.2