- 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