From 23886971f037b00a358d9b422aa0b3b40a75dc10 Mon Sep 17 00:00:00 2001 From: natile Date: Mon, 9 Dec 2002 12:08:46 +0000 Subject: [PATCH] Now "only" constraint are more restrictive. --- helm/gTopLevel/gTopLevel.ml | 8 +- helm/gTopLevel/mQueryGenerator.ml | 261 +++++++++++++++++++++++------- 2 files changed, 209 insertions(+), 60 deletions(-) diff --git a/helm/gTopLevel/gTopLevel.ml b/helm/gTopLevel/gTopLevel.ml index 60d0d344b..89e56bafc 100644 --- a/helm/gTopLevel/gTopLevel.ml +++ b/helm/gTopLevel/gTopLevel.ml @@ -60,8 +60,8 @@ 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";; @@ -85,8 +85,8 @@ 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";; diff --git a/helm/gTopLevel/mQueryGenerator.ml b/helm/gTopLevel/mQueryGenerator.ml index 6736bc8e0..7e061eb0b 100644 --- a/helm/gTopLevel/mQueryGenerator.ml +++ b/helm/gTopLevel/mQueryGenerator.ml @@ -143,14 +143,16 @@ let searchPattern must_use can_use = None -> [] | Some cr_o -> (List.map tsnd cr_o) in - let odep = + let odep = match cr_o with None -> [] - | Some cr_o -> let odep_option_list = List.map trd cr_o in + | Some cr_o -> List.map trd cr_o + (* let odep_option_list = List.map trd cr_o in let lo_dep_int = List.fold_left to_int_list [] odep_option_list in - List.map string_of_int lo_dep_int + List.map string_of_int lo_dep_int*) in - + print_string "#### LUNGHEZZA ODEP: "; print_int (List.length odep); flush stdout; + print_endline""; let rpos = match cr_r with None -> [] @@ -159,9 +161,10 @@ let searchPattern must_use can_use = let rdep = match cr_r with None -> [] - | Some cr_r -> let rdep_option_list = List.map snd cr_r in + | Some cr_r -> List.map snd cr_r + (* let rdep_option_list = List.map snd cr_r in let lr_dep_int = List.fold_left to_int_list [] rdep_option_list in - List.map string_of_int lr_dep_int + List.map string_of_int lr_dep_int *) in @@ -174,9 +177,10 @@ let searchPattern must_use can_use = let sdep = match cr_s with None -> [] - | Some cr_s -> let sdep_option_list = List.map tsnd cr_s in + | Some cr_s -> List.map tsnd cr_s + (* let sdep_option_list = List.map tsnd cr_s in let ls_dep_int = List.fold_left to_int_list [] sdep_option_list in - List.map string_of_int ls_dep_int + List.map string_of_int ls_dep_int*) in @@ -185,8 +189,7 @@ let searchPattern must_use can_use = None -> [] | Some cr_s -> List.map trd cr_s in - - let q_where_obj = function + (* let q_where_obj = function Some l -> if odep = [] then M.Sub @@ -217,31 +220,93 @@ let searchPattern must_use can_use = ) | None -> M.True - in - - let q_where_rel = function + in*) + + + + let q_where_obj n = function Some l -> - let q0 = + let rec q_ex n = function + [] -> M.True + | [(u,p,None)] -> + M.Meet (M.VVar ("obj_position" ^ string_of_int n), M.Record ("uri", in_path "p")) + + | [(u,p,d)] -> + print_string "@@@@@ IN-WHERE-OBJ"; flush stdout; + print_endline""; + M.And + (M.Meet(M.VVar ("obj_position" ^ string_of_int n),M.Record("uri",in_path "p")), + M.Meet(M.VVar ("obj_depth" ^ string_of_int n), M.Record("uri",in_path "d"))) + | (u,p,None)::tl -> + M.Or + (M.Meet (M.VVar ("obj_position" ^ string_of_int n), M.Record ("uri", in_path "p")), + q_ex (n+1) tl) + | (u,p,d)::tl -> + print_string "@@@@@ IN-WHERE-OBJ"; flush stdout; + print_endline""; + M.Or + ((M.And + ((M.Meet(M.VVar ("obj_position" ^ string_of_int n),M.Record("uri",in_path "p"))), + (M.Meet(M.VVar ("obj_depth" ^ string_of_int n), M.Record("uri",in_path "d"))))), + q_ex (n+1) tl) + in + M.Sub + (M.RefOf + (M.Select + ("uri", + M.Relation + (false, M.RefineExact, in_path "refObj", + M.Ref (M.RefOf (M.RVar "uri0")), + [assign "p" "position"; assign "d" "depth"] + ), + M.Ex ["uri"] + (q_ex 1 l))), + M.VVar "universe") + | None -> M.True + in + + + + + let rec q_where_rel n cr_r= (*function*) + (* Some l ->*) + let q0 = M.Sub (M.Property (false, M.RefineExact, ("refRel", ["position"]), M.RefOf(M.RVar "uri0")), - M.VVar "rel_positions") - in - if rdep = [] then q0 - else - M.And - (q0, - M.Sub - (M.Property - (false, M.RefineExact, ("refRel", ["depth"]), - M.RefOf(M.RVar "uri0")), - M.VVar "rel_depths")) - | None -> M.True - in + M.VVar ("rel_position" ^ string_of_int n)) + in + match cr_r with + Some [] -> M.True + | Some [(p,None)] -> q0 + | Some [(p,d)] -> + M.And + (q0, + M.Sub + (M.Property + (false, M.RefineExact, ("refRel", ["depth"]), + M.RefOf(M.RVar "uri0")), + M.VVar ("rel_depth" ^ string_of_int n))) + | Some ((p,None)::tl) -> + M.Or + (q0, + q_where_rel (n+1) (Some tl)) + | Some ((p,d)::tl) -> + M.Or + (M.And + (q0, + M.Sub + (M.Property + (false, M.RefineExact, ("refRel", ["depth"]), + M.RefOf(M.RVar "uri0")), + M.VVar ("rel_depth" ^ string_of_int n))), + q_where_rel (n+1) (Some tl)) + | None -> M.True + in - let q_where_sort = function - Some l -> + let rec q_where_sort n cr_s = (*function *) + (* Some l ->*) let q0 = M.And (M.Sub @@ -249,29 +314,50 @@ let searchPattern must_use can_use = (false, M.RefineExact, ("refSort", ["position"]), M.RefOf(M.RVar "uri0") ), - M.VVar "sort_positions"), + M.VVar ("sort_position" ^ string_of_int n)), M.Sub (M.Property (false, M.RefineExact, ("refSort", ["sort"]), M.RefOf(M.RVar "uri0")), - M.VVar "sorts")) - in - if sdep = [] then - q0 - else - M.And - (q0, - M.Sub - (M.VVar "sort_depths", - M.Property - (false, M.RefineExact, ("refSort", ["depth"]), - M.RefOf(M.RVar "uri0")))) - | None -> M.True + M.VVar ("sort" ^ string_of_int n))) + in + match cr_s with + Some [] -> M.True + | Some [(p,None,s)] -> q0 + + | Some [(p,d,s)] -> + M.And + (q0, + M.Sub + (M.Property + (false, M.RefineExact, ("refSort", ["depth"]), + M.RefOf(M.RVar "uri0")), + M.VVar ("sort_depth" ^ string_of_int n))) + + | Some ((p,None,s)::tl) -> + M.Or + (q0, + q_where_sort (n+1) (Some tl)) + + | Some((p,d,s)::tl) -> + M.Or + (M.And + (q0, + M.Sub + (M.Property + (false, M.RefineExact, ("refSort", ["depth"]), + M.RefOf(M.RVar "uri0")), + M.VVar ("sort_depth" ^ string_of_int n))), + q_where_sort (n+1) (Some tl)) + | 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) + M.And(M.And(q_where_obj 1 cr_o, (q_where_rel 1 cr_r)), (q_where_sort 1 cr_s)) in @@ -282,9 +368,9 @@ let searchPattern must_use can_use = None -> M.Select ("uri", M.Relation (false, M.RefineExact, ("backPointer", []), - M.Ref (M.Const [r]), [assign "pos" "position"]), + M.Ref (M.Const [r]), [assign "p" "position"]), M.Ex ["uri"] - ((M.Sub (M.Const [pos], M.Record ("uri", in_path "pos"))))) + ((M.Sub (M.Const [pos], M.Record ("uri", in_path "p"))))) | Some dep -> let string_dep = string_of_int dep in M.Select ("uri", @@ -389,18 +475,81 @@ let searchPattern must_use can_use = let q_let_u = M.LetVVar ("universe", M.Const universe, q_select) in - let q_let_s = M.LetVVar ("sorts", M.Const sor, q_let_u) in + let rec q_let_s sor n = + match sor with + [] -> q_let_u + | [s] -> M.LetVVar ("sort" ^ (string_of_int n), M.Const [s], q_let_u) + | s::tl -> M.LetVVar ("sort" ^ (string_of_int n), M.Const [s], q_let_s tl (n+1)) + in + +(* let q_let_s = M.LetVVar ("sorts", M.Const sor, q_let_u) in *) + + let rec q_let_ds sdep n = + match sdep with + [] + | [None] -> q_let_s sor 1 + | (None)::tl -> q_let_ds tl (n+1) + | [Some d] -> M.LetVVar ("sort_depth" ^ (string_of_int n), M.Const [(string_of_int d)], q_let_s sor 1) + | (Some d)::tl -> M.LetVVar ("sort_depth" ^ (string_of_int n), M.Const [(string_of_int d)], q_let_ds tl (n+1)) + in + +(* let q_let_ds = M.LetVVar ("sort_depths", M.Const sdep, q_let_s) in *) + + let rec q_let_dr rdep n = + match rdep with + [] + | [None] -> q_let_ds sdep 1 + | (None)::tl -> q_let_dr tl (n+1) + | [Some d] -> M.LetVVar ("rel_depth" ^ (string_of_int n), M.Const [(string_of_int d)], q_let_ds sdep 1) + | (Some d)::tl -> M.LetVVar ("rel_depth" ^ (string_of_int n), M.Const [(string_of_int d)], q_let_dr tl (n+1)) + in + - let q_let_ds = M.LetVVar ("sort_depths", M.Const sdep, q_let_s) in + (*let q_let_dr = M.LetVVar ("rel_depths", M.Const rdep, q_let_ds) in*) - let q_let_dr = M.LetVVar ("rel_depths", M.Const rdep, q_let_ds) in + let rec q_let_do odep n = + match odep with + [] + | [None] -> q_let_dr rdep 1 + | (None)::tl -> q_let_do tl (n+1) + | [Some d] -> M.LetVVar ("obj_depth" ^ (string_of_int n), M.Const [(string_of_int d)], q_let_dr rdep 1) + | (Some d)::tl -> M.LetVVar ("obj_depth" ^ (string_of_int n), M.Const [(string_of_int d)], q_let_do tl (n+1)) + in + - let q_let_do = M.LetVVar ("obj_depths", M.Const odep, q_let_dr) in +(* let q_let_do = M.LetVVar ("obj_depths", M.Const odep, q_let_dr) in *) - let q_let_ps = M.LetVVar ("sort_positions", M.Const spos, q_let_do) in - let q_let_pr = M.LetVVar ("rel_positions", M.Const rpos, q_let_ps) in + let rec q_let_ps spos n = + match spos with + [] -> q_let_do odep 1 + | [p] -> M.LetVVar ("sort_position" ^ (string_of_int n), M.Const [p], q_let_do odep 1) + | p::tl -> M.LetVVar ("sort_position" ^ (string_of_int n), M.Const [p], q_let_ps tl (n+1)) + in + + +(* let q_let_ps = M.LetVVar ("sort_positions", M.Const spos, q_let_do) in *) + + + let rec q_let_pr rpos n = + match rpos with + [] -> q_let_ps spos 1 + | [p] -> M.LetVVar ("rel_position" ^ (string_of_int n), M.Const [p], q_let_ps spos 1) + | p::tl -> M.LetVVar ("rel_position" ^ (string_of_int n), M.Const [p], q_let_pr tl (n+1)) + in + + + +(* let q_let_pr = M.LetVVar ("rel_positions", M.Const rpos, q_let_ps) in *) + + let rec q_let_po opos n = + match opos with + [] -> q_let_pr rpos 1 + | [p] -> M.LetVVar ("obj_position" ^ (string_of_int n), M.Const [p], q_let_pr rpos 1) + | p::tl -> M.LetVVar ("obj_position" ^ (string_of_int n), M.Const [p], q_let_po tl (n+1)) + in + + (*let q_let_po = M.LetVVar ("obj_positions", M.Const opos, q_let_pr) in*) - let q_let_po = M.LetVVar ("obj_positions", M.Const opos, q_let_pr) in -print_endline ("### " ^ MQueryUtil.text_of_query q_let_po) ; flush stdout; - execute_query q_let_po +print_endline ("### " ^ MQueryUtil.text_of_query (q_let_po opos 1)) ; flush stdout; + execute_query (q_let_po opos 1) -- 2.39.2