let get_if_lhs hlpsl_terms =
let subst = ref []
and lcond = ref []
and lmsg = ref [] in
List.iter
(function
Equal(t1,t2) ->
(match (apply_subst !subst t1, apply_subst !subst t2) with
(Base(Var(_)) as t1, t2)
| (t2, (Base(Var(_)) as t1)) ->
let p = [(t1,t2)] in
subst := (List.map (fun (s,t) -> (s, apply_subst p t)) !subst)@p
| (Prime(Var(_)) as t1, t2)
| (t2, (Prime(Var(_)) as t1)) ->
let p = [(t1,t2)] in
subst := (List.map (fun (s,t) -> (s, apply_subst p t)) !subst)@p
| _ -> lcond := !lcond@[Ifequal(t1,t2)])
| Not(p) -> lcond := !lcond@[Ifnot(get_if_term p)]
| Leq(t1,t2) -> lcond := !lcond@[Ifleq(t1,t2)]
| In(t1,t2) -> lcond := !lcond@[Ifcontains(t1,t2)]
| New _ -> ()
| event -> lmsg := !lmsg@[get_if_term event])
hlpsl_terms;
lcond := List.map (function
Ifequal(t1,t2) ->
Ifequal(apply_subst !subst t1, apply_subst !subst t2)
| Ifleq(t1,t2) ->
Ifleq(apply_subst !subst t1, apply_subst !subst t2)
| Ifcontains(t1,t2) ->
Ifcontains(apply_subst !subst t1, apply_subst !subst t2)
| Ifnot(Ifequal(t1,t2)) ->
Ifnot(Ifequal(apply_subst !subst t1, apply_subst !subst t2))
| Ifnot(Ifleq(t1,t2)) ->
Ifnot(Ifleq(apply_subst !subst t1, apply_subst !subst t2))
| Ifnot(Ifcontains(t1,t2)) ->
Ifnot(Ifcontains(apply_subst !subst t1, apply_subst !subst t2))
| t -> t)
!lcond;
lmsg := List.map (function
Iknows(t) ->
Iknows(apply_subst !subst t)
| Ifdelete(t1,t2) ->
Ifdelete(apply_subst !subst t1, apply_subst !subst t2)
| Ifcontains(t1,t2) ->
Ifcontains(apply_subst !subst t1, apply_subst !subst t2)
| Unknown(t1,lt2) ->
Unknown(t1, List.map (apply_subst !subst) lt2)
| t -> t)
!lmsg;
(!subst,!lcond,!lmsg)