Legend:
Library
Module
Module type
Parameter
Class
Class type
Incremental verification of local confluence
by checking the joinability of critical pairs.
CP(l-->r, p, g-->d) = (s(r), s(l[d]_p) | s = mgu(l|_p,g) is the critical pair between l|_p and g.
CP*(l-->r, g-->d) = U CP(l-->r, p, g-->d) | p in FPos(l)
CP*(R,S) = U CP*(l-->r, g-->d) | l-->r in R, g-->d in S
The set of critical pairs of a rewrite system R is CP(R) = CP*(R,R).
We have CP(R U S) = CP*(R,R) U CP*(R,S) U CP*(S,R) U CP*(S,S).
As a consequence, assuming that we already checked the local confluence of R and add a new set S of rules, we do not need to check CP*(R,R) again.
Warning: we currently do not take into account the rules having higher-order pattern variables and critical pairs on AC symbols.
Remark: When trying to unify a subterm of a rule LHS with the LHS of another rule, we need to rename the pattern variables of one of the LHS to avoid name clashes. To this end, we use the shift function below which replaces Patt(i,n,_) by Patt(-i-1,n ^ "'",_). The printing function subs below takes this into account.
unif pos t u returns None if t and u are not unifiable, and Some
s with s an idempotent mgu otherwise. Precondition: l and r must have distinct indexes in Patt subterms.
Type of rule identifiers. Hack: we use the rule position to distinguish between user-defined and generated rules (in completion), by giving a unique negative start_line to every generated rule.
iter_cps_with_rule iter_subterms h pos sr1 sr2 applies h on all the critical pairs between all the subterms of the sr1 LHS and the sr2 LHS using the iterator iter_subterms.
check_cp pos _ l r p l_p _ g d s checks that, if l_p and g are unifiable with mgu s, then s(r) and s(l[d]_p) are joinable. Precondition: l and r must have distinct indexes in Patt subterms.
update_cp_pos pos map rs extends map by mapping every definable symbol s' such that there is a rule l-->r of rs and a position p of l such that l_p is headed by s' to (l,r,p,l_p).