Skip to content
Snippets Groups Projects
Commit 61f70655 authored by François Bobot's avatar François Bobot
Browse files

Allow match_any_term to work with any initial substitution

parent b4a0c773
No related branches found
No related tags found
1 merge request!6Define properly stage0 and stage1
...@@ -275,13 +275,13 @@ let env_node_by_ty = ...@@ -275,13 +275,13 @@ let env_node_by_ty =
EnvTy.create (Context.Queue.pp ~sep:Fmt.semi Node.pp) EnvTy.create (Context.Queue.pp ~sep:Fmt.semi Node.pp)
"Quantifier.Trigger.node_by_ty" (fun c _ -> Context.Queue.create c) "Quantifier.Trigger.node_by_ty" (fun c _ -> Context.Queue.create c)
let match_any_term d (p : t) : Ground.Subst.S.t = let match_any_term d subst (p : t) : Ground.Subst.S.t =
Debug.dprintf2 debug "[Quant] matching any for %a" pp p; Debug.dprintf2 debug "[Quant] matching any for %a" pp p;
match p with match p with
| Var v -> | Var v ->
EnvTy.fold EnvTy.fold
(fun ty q acc -> (fun ty q acc ->
let substs = match_ty init ty v.ty in let substs = match_ty subst ty v.ty in
if Ground.Subst.S.is_empty substs then acc if Ground.Subst.S.is_empty substs then acc
else else
Ground.Subst.S.fold_left Ground.Subst.S.fold_left
...@@ -302,7 +302,7 @@ let match_any_term d (p : t) : Ground.Subst.S.t = ...@@ -302,7 +302,7 @@ let match_any_term d (p : t) : Ground.Subst.S.t =
(fun acc n -> (fun acc n ->
let { Ground.Term.app = f; tyargs = tyl; args; _ } = Ground.sem n in let { Ground.Term.app = f; tyargs = tyl; args; _ } = Ground.sem n in
assert (Term.Const.equal f pf); assert (Term.Const.equal f pf);
let substs = List.fold_left2 match_ty init tyl ptyl in let substs = List.fold_left2 match_ty subst tyl ptyl in
let substs = let substs =
IArray.fold2_exn args pargs ~init:substs ~f:(match_term d) IArray.fold2_exn args pargs ~init:substs ~f:(match_term d)
in in
......
...@@ -56,8 +56,10 @@ val check_term_exists : Egraph.t -> Ground.Subst.t -> t -> Node.S.t ...@@ -56,8 +56,10 @@ val check_term_exists : Egraph.t -> Ground.Subst.t -> t -> Node.S.t
(** [check_term_exists d subst pat] return nodes that are equal to the pattern (** [check_term_exists d subst pat] return nodes that are equal to the pattern
[pat] substituted by the substitution [subst] *) [pat] substituted by the substitution [subst] *)
val match_any_term : Egraph.t -> t -> Ground.Subst.S.t val match_any_term : Egraph.t -> Ground.Subst.S.t -> t -> Ground.Subst.S.t
(** [match_any_term d pat] match the pattern [pat] to all the nodes of [d] *) (** [match_any_term d subst pat] match the pattern [pat] to all the nodes of [d]
for each substitution. Each return substitution corresponds to one given as
input. *)
val get_pps : t -> PP.t list Term.Var.M.t val get_pps : t -> PP.t list Term.Var.M.t
(** [get_pps pat] return the parent-parent pairs in [pat] for each variables *) (** [get_pps pat] return the parent-parent pairs in [pat] for each variables *)
......
...@@ -27,7 +27,7 @@ open Common ...@@ -27,7 +27,7 @@ open Common
let add_trigger d t = let add_trigger d t =
Trigger.add_trigger d t; Trigger.add_trigger d t;
InvertedPath.insert_pattern d t; InvertedPath.insert_pattern d t;
let substs = Pattern.match_any_term d t.pat in let substs = Pattern.match_any_term d Pattern.init t.pat in
Ground.Subst.S.iter (Trigger.instantiate d t) substs Ground.Subst.S.iter (Trigger.instantiate d t) substs
let find_new_event d n (info : Info.t) n' (info' : Info.t) = let find_new_event d n (info : Info.t) n' (info' : Info.t) =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment