An Isabelle/HOL Formalization of Semi-Thue and Conditional Semi-Thue Systems
Abstract
We present a formalized framework for semi-Thue and conditional semi-Thue systems for studying monoids and their word problem using the Isabelle/HOL proof assistant. We provide a formalized decision procedure for the word problem of monoids if they are finitely presented by complete semi-Thue systems. In particular, we present a new formalized method for checking confluence using (conditional) critical pairs for certain conditional semi-Thue systems. We propose and formalize an inference system for generating conditional equational theories and Thue congruences using conditional semi-Thue systems. Then we provide a new formalized decision procedure for the word problem of monoids which have finite complete (reductive) conditional presentations.
Keywords and phrases:
semi-Thue systems, conditional semi-Thue systems, conditional string rewriting, monoids, word problem2012 ACM Subject Classification:
Theory of computation Logic and verification ; Theory of computation Equational logic and rewritingSupplementary Material:
Software (Source Code): http://cl-informatik.uibk.ac.at/experiments/ITP2025/material.zipAcknowledgements:
The author would like to thank René Thiemann for his valuable comments on this paper. The author also would like to thank the anonymous reviewers for their valuable comments to improve the presentation of this paper.Funding:
This research was funded by the Austrian Science Fund (FWF) project I 5943-N.Editors:
Yannick Forster and Chantal KellerSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
It is generally accepted that semi-Thue systems, also known as string rewriting systems, were first introduced by Axel Thue in 1910’s in order to solve the word problem of semigroups and monoids [39]. They can also be viewed as presentations of monoids, where monoids are fundamental algebraic structures widely used in mathematics and computer science. In particular, they serve as a well-known framework for solving the word problem for monoids and groups. The word problem of monoids (or groups) is undecidable in general but it is decidable if they are presented by finite complete (i.e., terminating and confluent) semi-Thue systems over finite alphabets. If a finite semi-Thue system is terminating, then the critical pair lemma provides a decision procedure for confluence. If a monoid is presented by a finite terminating semi-Thue system but it is not confluent, then one may attempt to construct a finite complete semi-Thue system equivalent to using a completion procedure.
Semi-Thue systems can also be considered as a special case of term rewriting systems (TRSs), where term rewriting systems play an important role in programming languages (e.g., functional programming) [26], software engineering (e.g., equationally specified abstract data types) [37], computer algebra [29], and automated theorem proving [20]. For example, a semi-Thue system on can be associated with a term rewriting system (TRS) in such a way that [7], where each letter from an alphabet is interpreted as a unary function symbol. Here, variables in are renamed whenever necessary.
The formalization111In this paper, by “formalization”, we mean a computer-assisted formalization using a proof assistant. of TRSs has been done extensively via Isabelle/HOL (e.g., IsaFoR [44]) and Coq (e.g., [8, 9]), and word problems of algebraic structures using TRSs were also discussed in early systems, such as the RRL [25] and the REVE system [31]. However, they are not directly suited for monoid and group presentations.
Our Isabelle/HOL formalization of semi-Thue systems and their related results is based on the simple string matching methods instead of using the more complex term structures. It also uses the simple shortlex order (i.e. length-lexicographic order) [7] on strings, which is simpler than the usual term orderings, such as the lexicographic path order (LPO) [22], the Knuth–Bendix order (KBO) [29] and the weighted path order (WPO) [45]. Some results of semi-Thue systems were also formalized, for example, in Lean [15] and Coq [17].
Meanwhile, conditional semi-Thue systems are extensions of semi-Thue systems, where each of their rules has the form for strings . (Here, can also be denoted as an ordered pair .) A finitely generated monoid with decidable word problem may not admit a finite complete (unconditional) presentation, but it may admit a finite complete conditional presentation [11]. For example, the monoid presented by on does not admit a finite complete (unconditional) presentation by a semi-Thue system but admits a finite complete conditional presentation by a conditional semi-Thue system.
The equality symbol in conditional string rewriting rules of conditional semi-Thue systems can be interpreted in different ways, yielding different types of conditional semi-Thue systems. Note that some conditional semi-Thue systems, such as right conditional semi-Thue systems, can be associated with conditional term rewriting systems (CTRSs) [23], but this is not the case for all types of conditional semi-Thue systems, for example, left-right conditional semi-Thue systems. We classify and formalize different types of conditional semi-Thue systems, which extend the classification of conditional semi-Thue systems discussed in [11].
We also formalize conditional equational theories and Thue congruences using conditional semi-Thue systems for the associated monoids and their word problem. In particular, we provide a formalized method for checking confluence using (conditional) critical pairs for certain types of conditional semi-Thue systems, which provides a decision procedure for confluence if they are reductive w.r.t. the shortlex order.
Our Isabelle/HOL formalization of semi-Thue and conditional semi-Thue systems along with their related results is built on IsaFoR (Isabelle/HOL Formalization of Rewriting) [44], where Isabelle/HOL [36] is a generic proof assistant and a theorem prover allowing the users to express concepts in mathematics and computer science and to prove properties about them. It also relies on the “A Case Study in Basic Algebra” AFP (archive of formal proofs) entry [4] for a formalization of monoids and groups, and the “Abstract Rewriting” AFP entry [42] for a formalization of the abstract rewriting systems (ARSs) [1] and their related properties, such as the Church-Rosser (CR) and the strong normalization (SN) property.
To the best of our knowledge, conditional semi-Thue systems and their related results have not been formalized in any proof assistant. Our formalization may provide a formalized framework for string rewriting and conditional string rewriting along with their wide variety of applications. The relevant Isabelle/HOL theory files222http://cl-informatik.uibk.ac.at/experiments/ITP2025/material.zip. inside IsaFoR under the directory thys/Conditional_Semi_Thue_Systems are as follows:
| Semi_Thue_Systems.thy | Conditional_Semi_Thue_Systems.thy |
| String_Rewriting | Conditional_String_Rewriting.thy |
| ShortLex.thy | STS_Completion.thy |
| Conditional_Equational_Theories.thy | STS_Critical_Pairs.thy |
| CSTS_P_Critical_Pairs.thy | CSTS_R_Critical_Pairs.thy.thy |
In the remainder of this paper, we use hyperlinks marked by for providing an HTML rendering for our formalized proofs in Isabelle/HOL.
2 Preliminaries
Let be a finite alphabet, be a strict order on (i.e. a precedence on ), and be the set of all finite (possibly empty) strings from .
The shortlex order (or length-lexicographic order) on induced by > is defined as follows: if , or they have the same length (i.e., ) and comes before lexicographically using a precedence on . Here, comes before lexicographically using a precedence on if there is a such that and . If , then for all .
A monoid is a set equipped with an associative binary operation and a (two-sided) identity element. Note that a monoid cannot be empty because of an identity element. For example, is a (free) monoid generated by under the operation of concatenation as an associative binary operation with the empty string as an identity element. A homomorphism between two monoids and ) is a function such that for all and , where and are the identities of and , respectively. A bijective monoid homomorphism is called a monoid isomorphism. Two monoids are said to be isomorphic if there is a monoid isomorphism between them. An element of a monoid is invertible if there is an element such that , where 1 is an identity element of . A group is a monoid in which every element is invertible.
The reflexive and transitive closure of a binary relation is denoted by , and the reflexive, symmetric and transitive closure of is denoted by called conversion.
A derivation for a binary relation is a sequence of form . A binary relation is terminating (or strongly normalizing) if there are no infinite derivations . An element is reducible (w.r.t. a given binary relation ) if there is an element such that ; otherwise, is irreducible. We say that is an -normal form of if and is irreducible via . A binary relation is confluent if there is an element such that and whenever and . A binary relation is locally confluent if there is an element such that and whenever and . A binary relation is Church-Rosser if there is an element such that and whenever . Here, is Church-Rosser iff it is confluent. Two elements and are joinable w.r.t. a binary relation , denoted by , if there is an element such that (i.e., and ). A binary relation is complete if it is both terminating and confluent. If is terminating, then it is confluent iff it is locally confluent (see Newman’s lemma [35, 1]).
3 Semi-Thue Systems
A semi-Thue system (STS) [7] over a finite alphabet is a subset of . If is an STS over a finite alphabet , then the single-step string rewriting relation on induced by is defined as follows: for any , iff there exists such that for some , and . Also, denotes the reflexive, transitive closure of . By extension, the terms “terminating”, “confluent”, etc., used in Section 2 are also applied to an STS whose single-step string rewriting relation has those properties. In the remainder of this paper, unless otherwise stated, we denote by a finite alphabet and assume that a total precedence on is always given so that the shortlext order is a well-founded total order on .
An STS with the property that implies is called a Thue system. The Thue congruence induced by is the relation . Two strings are congruent (modulo ) if . The congruence class of a word is defined as . The set of congruence classes (modulo ) is denoted by . In this section, we refer to [7, 21, 18] for the definitions and results related to STSs, monoids, and completion.
In fact, is the factor monoid of the free monoid modulo the congruence , i.e., .
Definition 2.
-
(i)
Let be an STS over . If a monoid is isomorphic to the factor monoid (), then the ordered pair () is a presentation of , and simply write . If is complete, then () is a complete presentation of .
-
(ii)
The monoid is finitely presented if both and are finite.
-
(iii)
The word problem of the monoid is the following decision problem: Given two words , decide if in .
Our formalization of STSs and their associated monoids is based on the following Isabelle’s locale, where a locale [3] is a named context for fixed parameters with assumptions.
locale semi_Thue
fixes and and ""
assumes "" and "" and "" and "" and ""
begin
Above, denotes a finite STS over a finite non-empty alphabet , while denotes the Thue congruence induced by . The sts type for and is declared as follows:
type_synonym sts "srule set"
where the type srule is declared simply as stringstring. (Alternatively, instead of using the Isabelle’s dedicated string type (i.e., char list type), one can use the ’a list type, which is suitable for more general STSs.) Also, represents the assumption , which also implies . Our formalization of Lemma 1 also uses the locale monoid in the AFP entry [4]. It is instantiated as a sublocale using the following parameters, where represents the factor monoid with identity .
sublocale "" "" ""
We also use the locale group in the same AFP entry, which extends the locale monoid by adding the assumption that every element of a monoid is invertible. This can be further refined as in the following lemma.
If an STS is complete, then each congruence class contains a unique irreducible word only, which can be chosen as a normal form for this congruence class. Therefore, if is finite and complete, then the word problem of the monoid can be solved using string rewriting, that is, given two strings , reduce and by to their respective -normal forms and and simply compare them. Now, if one can show that () is a finite complete presentation, then one can decide the word problem of the monoid (). First, in order to show that is terminating, there is an easy sufficient condition for it.
In Lemma 4, the shortlex order is formalized as follows:
fun shortlex:: "" where
"
where the lenorder function is used for comparing the lengths of two strings and the lexorder function is used for comparing two strings of the same length via the lexicographic order (see below).
fun lenorder:: "" where
""
fun lexorder:: "" where
""
Above, “@” denotes the list append function in Isabelle/HOL. Here, the list append function “@” serves as the string concatenation function. Accordingly, both and are characters, where denotes that has a higher precedence than . It is also the case that is greater than w.r.t. the lexicographic order if is a strict prefix of (see [14]). We omit this case because this case is not necessary for the shortlex order. The shortlex order using the shortlex function is abbreviated as .
abbreviation shortlex_s (infix "" 50) where ""
abbreviation shortlex_ns (infix "" 50) where ""
Definition 6.
-
(i)
For each pair of not necessarily distinct string rewriting rules from , say and , the set of critical pairs, denoted by , corresponding to this pair is .
-
(ii)
A critical pair is joinable if .
By using Definition 6(i), the set of critical pairs for an STS is formalized as follows:
definition sts_critical_pairs where
"
"
lemma sts_critical_pair_lemma:
""
Our formalization of Lemma 8 is as above. Here, WCR [42] is the existing formalized definition of the Weak Church-Rosser property, where denotes that is locally confluent.
The following theorem and its proof provide a decision procedure for the word problem of a monoid if it is presented by a finite complete STS.
Theorem 10.
Proof.
Observe that if , then and are the same element in ; otherwise, they are the different elements in . Since is finite and complete, we can decide whether by comparing the normal forms of and w.r.t. , that is, if the normal forms of and w.r.t. are the same, then they are the same element in (i.e., ); otherwise, they are the different elements in (i.e., ).
Remark 11.
Thus far, this section has been concerned with the word problem of monoids and its decision procedure if they are presented by finite complete STSs. Our formalization can also be used for the word problem for finitely presented groups. Group presentations can be converted into monoid presentations (see [19, 40]). (Recall that groups are also monoids.) Let be a set of generators of a group , be a set of relations of , and . Then the group defined by the presentation is equivalent to the monoid defined by the presentation , where and is an STS orienting the equations in using the total shortlex order on . (Here, if , then is defined to be equal to .) Therefore, Theorem 10 can also be used for the word problem of a group if its group presentation yields the monoid presentation such that is a finite complete STS on .
Completion [1, 29, 18] attempts to transform a set of equations (or string rewriting rules in equational form) on into an equivalent complete string rewriting system. It basically converts non-joinable critical pairs into string rewriting rules so that they are joinable. It uses a reduction order [19] (e.g. the shortlex order) to orient equations on , and also uses string rewriting for simplification. (Here, an equation is an unordered pair of strings on , written as .) The inference rules, which are given in Figure 1, operate on pairs , where is a set of equations and is a set of string rewriting rules on . Intuitively speaking, is a set of input equations or critical pairs that have not yet been transformed (i.e., oriented) into string rewriting rules, while is a terminating set of string rewriting rules.
Definition 12.
We write if can be obtained from by applying one of the inference rules in Figure 1.
Definition 13.
-
(i)
A (finite) run for an initial set of equations is a finite sequence , where and .
-
(ii)
A run fails if .
-
(iii)
A run is fair if .
Definition 15 (cf. [18]).
Let be an STS on and be a finite multiset of strings on . We write (the labeled string rewriting) if and there are some such that and . Here, denotes the reflexive closure of .
Definition 17.
-
(i)
An abstract rewrite system (ARS) is a set equipped with a binary relation . We also write an ARS as where we denote by the part of the binary relation with label indexed by so that .
-
(ii)
An ARS is peak decreasing if there exists a well-founded order on such that for all the inclusion
holds. Here, denotes the set and if then denotes a conversion consisting of steps.
See [18] for the proof of the following lemma and its Isabelle/HOL formalization.
Lemma 18.
Every peak decreasing ARS is confluent.
Theorem 19 (cf. [18]).
Sketch of the proof.
We first show that is terminating. If and , then by the case analysis of each inference rule in Figure 1. We leave the straightforward induction proof to our formalization for showing , which in turn shows that is terminating. Now, we let be a labeled local peak in and show that is peak decreasing. By Lemma 7, we have or , and thus or by fairness and Definition 13(iii). Here, we only consider the case where and leave the proof of the other case to our formalization. Since , there is some such that . Now, let . Then, we have , and thus . By repeated applications of Lemma 16, we have . This means that there is a conversion between and , where each step in the conversion is labeled by . Let denote the multiset extension of . Then, is well-founded because is well-founded. Since and , is peak decreasing, and thus confluent by Lemma 18.
Our formalization of the inference rules in Figure 1 for a completion step uses the “inductively defined predicates” in Isabelle/HOL.
inductive :: "" (infix "" 55) where
: ""
if "" and "" and ""
: ""
if ""
: ""
if ""
: "" if ""
: "" if ""
: "" if ""
: "" if ""
: ""
Note that in Figure 1, consists of unordered pairs (i.e., equations). In our formalization above, it consists of ordered pairs for technical convenience, so we use and for the simplify rule and and for the orient rule in Figure 1.
Now, Theorem 19 is formalized as follows, where the assumptions describe a fair non-failing run in Theorem 19.
theorem : assumes and
and ""
and ""
shows ""
Remark 20.
Using an inference system for a completion procedure is known to be simple and efficient, and it is easy to apply simplification rules [1]. An inference system-based completion procedure for TRSs was already discussed in the literature [2, 18, 1]. Our inference system in Figure 1 is adapted from the existing Knuth-Bendix completion procedures for STSs [24, 7] that do not use an inference system. (There are also inference systems for equational reasoning over strings, such as [27, 28], but they are not directly applicable to a completion procedure for STSs.) Regarding a completion procedure for finitely presented monoids and groups, one may attempt to use an inference system discussed in abstract completion [18, 2] by converting STSs into TRSs as discussed in Section 1. This is not tailored toward a completion procedure for finitely presented monoids and groups. In particular, we use the simple string matching method and the simple shortlex order on strings in Figure 1 rather than using more complex term structures for unification/matching and ordering. Note that given a fixed signature with its precedence, it takes only linear time to compare two finite strings w.r.t. the shortlex order. It takes also linear time to match two finite strings using, for example, the Knuth–Morris–Pratt (KMP) algorithm [30].
4 Conditional Semi-Thue Systems
Conditional semi-Thue systems (CSTSs) [11] are extensions of STSs in the sense that their rules may admit non-empty conditions. A CSTS on [11] is defined to be a set of conditional string rewriting rules, where each rule has the form (also denoted as ) consisting of strings and a sequence of unordered pairs of strings on . Here, can be thought of as a conjunction of conditions for the rule . In the following, let be a CSTS on .
Definition 21.
We write if the equation is derivable from the inference rules in Figure 2, and say that belongs to the left-right conditional equational theory induced by .
We may also consider other types of conditional equational theories depending on how contexts are used for the conditions in each conditional string rewriting rule (cf. [11]).
Above, each condition is considered with a right context and this context is also used for the conclusion.
Definition 22.
We write if the equation is derivable from the inference rules in Figure 2 substituting the above “Replacement (R)” rule for the “Replacement (LR)” rule. If , then we say that belongs to the right conditional equational theory induced by .
Above, no additional context is used for each condition and the conclusion.
Definition 23.
We write if the equation is derivable from the inference rules in Figure 2 substituting the above “Replacement (P)” rule for the “Replacement (LR)” rule. If , then we say that belongs to the pure conditional equational theory induced by .
Our formalization of the inference rules in Figure 2 for the left-right conditional equational theory induced by also uses the “inductively defined predicates” in Isabelle/HOL.
inductive :: "" (infix "" 55) where
: ""
: "" if ""
: "" if ""
: "" if ""
: ""
if ""
Above, denotes that belongs to the left-right conditional equational theory induced by . The right (resp. pure) conditional equational theory induced by can be formalized in a similar way, where (resp. ) is used for inductively defined predicate for the right (resp. pure) conditional equational theory induced by . They are only different from the replacement part (see below):
: ""
if ""
: ""
if ""
Meanwhile, the types of CSTSs depend on the string rewriting relations induced by CSTSs. More specifically, the types of CSTSs depend on how conditions are evaluated in the conditional parts of their conditional string rewriting rules (cf. [5, 46]). The induced string rewriting relations from CSTSs are structured into levels (cf. [41, 46]).
Definition 24.
The string rewriting relation for a left-right-semi-equational CSTS on is defined as follows: iff for some . Here, the unconditional STS are inductively defined as follows:
The string rewriting relation for a left-right-join CSTS on is defined as: iff for some , where are inductively defined as follows:
Definition 25.
The string rewriting relation for a right-semi-equational CSTS on is defined as follows: iff for some . Here, the unconditional STS are inductively defined as follows:
The string rewriting relation for a right-join CSTS on is defined as: iff for some , where are inductively defined as follows:
Definition 26.
The string rewriting relation for a pure-semi-equational CSTS on is defined as follows: iff for some . Here, the unconditional STS are inductively defined as follows:
The string rewriting relation for a pure-join CSTS on is defined as: iff for some , where are inductively defined as follows:
The following lemma says that our inference system for yielding the left-right, right, and pure conditional equational theories is sound w.r.t. the Thue congruences induced by the string rewriting relations associated with the left-right-semi-equational, right-semi-equational, and pure-semi-equational CSTSs, respectively.
The bidirectional use of the string rewriting relations for evaluating the conditions in semi-equational CSTSs is both inefficient and unnatural (cf. [46]). We can use the join CSTSs instead of the semi-equational CSTSs if they have the confluence property.
Lemma 28.
Remark 29.
Recall that an STS on can be associated with a TRS , where each letter from is interpreted as a unary function symbol. Similarly, a right-join CSTS on can be associated with a join CTRS in such a way that [11]. (Here, variables in are renamed whenever necessary.) However, this is not the case for left-right-join CSTSs.
Example 30.
Consider , where with . If is a pure-join CSTS, then neither nor holds. If is a right-join CSTS, then holds, but does not hold. If is a left-right-join CSTS, then both and hold.
Now, we discuss our formalization of right-join and pure-join CSTSs. (Our formalization of left-right-join CSTSs is similar and is omitted.) First, the string rewriting relation associated with a right-join CSTS is formalized as follows:
definition "csr_r_join_step "
fun csr_r_join_step_n:: "" where
""
"
In the csr_r_join_step_n function, is a (string) context and (resp. ) denotes the application of the context to the string (resp. ). We formalize a context for strings based on the existing formalization of contexts for terms in IsaFoR.
datatype sctxt Hole "" More "string" "sctxt" "string"
fun sctxt_apply_string :: "" ("_" [900, 0] 900) where
""
"(More ss1 ss2)"
Using the above function, denotes for some (possibly empty) strings and . In the csr_r_join_step_n function, we consider all possible contexts because is a string rewriting relation, i.e., implies for all (possibly empty) strings and . Next, the string rewriting relation associated with a pure-join CSTS is formalized as follows. Here, no additional string is appended for evaluating each condition.
definition "csr_p_join_step "
fun csr_p_join_step_n:: "" where
""
"
Our formalization of CSTSs and their associated monoids relies on the following locale.
locale conditional_semi_Thue
fixes and ""
assumes "" and "" and ""
For example, the locale for right-join CSTSs extends the above locale and is described as:
locale conditional_r_join_semi_Thue
for and ""
fixes
assumes "" and ""
begin
Since the locale conditional_r_join_semi_Thue extends the locale conditional_semi_Thue, the alphabet denoted by is assumed to be finite and non-empty. The assumptions in the locale conditional_r_join_semi_Thue also represent the assumption , which also implies the assumption .
Definition 31.
-
(i)
We call a CSTS reductive if for all , , , and for all (cf. decreasingness [12] in CTRSs).
-
(ii)
Two STSs and on are equivalent if , that is, they present the same monoid.
-
(iii)
An STS and a reductive right-join (resp. a pure-join) CSTS on are equivalent if (resp. .
Example 32 (see [11]).
The monoid , where and , is finitely presented and have decidable word problem, but does not admit an equivalent monoid presentation with , where is a finite complete STS. More specifically, a completion procedure for may only yield an infinite complete semi-Thue system . However, admits an equivalent finite complete (reductive) right-join CSTS . (Here, is a finite complete (reductive) conditional presentation of , which will be discussed later in this section.)
Unlike the string rewriting relations induced by semi-Thue systems, is not necessarily decidable even if it is terminating (cf. [37]).
Lemma 33.
In the above lemma, if is finite and reductive and (resp. ) is terminating, then we may simulate the decidability of (resp. ) using the finiteness of the set of descendants (resp. ) for all . Here, the set (resp. ) can be shown to be computable for all using the well-founded induction on if is finite and reductive (cf. Theorem 7.2.9 in [37]).
Definition 34.
-
(i)
Let be a right-join CSTS. For each pair of not necessarily distinct conditional string rewriting rules from , say and , the set of critical pairs w.r.t. corresponding to this pair is .
-
(ii)
A critical pair is joinable w.r.t. if for any , for all implies .
-
(iii)
Let be a pure-join CSTS. For each pair of not necessarily distinct conditional string rewriting rules from , say and , the set of critical pairs w.r.t. corresponding to this pair is .
-
(iv)
A critical pair is joinable w.r.t. if for all implies .
Now, we discuss our formalization of Definition 34. First, the set of critical pairs for a right-join CSTS is formalized as follows:
definition csts_r_critical_pairs where
"
"
Above, if is of the form , then is . Also, denotes the conditional string rewriting rule , where is the list type for technical convenience. Based on Definition 34(ii), the statement that all critical pairs of are joinable w.r.t. is formalized as follows:
definition all_ccps_r_joinable where
"
"
where the definition of csts_conds_r_sat is formalized as follows:
definition csts_conds_r_sat where
""
Meanwhile, the set of critical pairs for a pure-join CSTS is formalized as follows:
definition csts_p_critical_pairs where
"
"
Note that conditions are evaluated without using any context in the above formalization. The statement that all critical pairs of are joinable w.r.t. is formalized as follows:
definition all_ccps_p_joinable where
"
"
where the definition of csts_conds_p_sat is simply formalized as follows:
definition csts_conds_p_sat where
""
Lemma 35 (see [11]).
Lemma 36.
Proof.
Since the “only if” direction is straightforward, we only show the “if” direction. Suppose that all critical pairs of are joinable w.r.t. . Since is finite and reductive, is terminating and decidable by Lemma 33(ii), so by Newman’s Lemma, it suffices to show that is locally confluent. Let and , and let and be two rules to reduce to and , respectively. We show that by considering the following three cases according to the positions of and in .
-
1.
and do not overlap, i.e., and using the rules and , where . Since and , we have . Therefore, and are joinable w.r.t. .
-
2.
is a substring of , i.e., and using the rules and , where . Since , we have a critical pair . This critical pair is joinable w.r.t. by hypothesis with and , so there is some such that and . Since and , we have , and thus and are joinable w.r.t. .
-
3.
and have an overlap in such a way that and using the rules and , where and . Since with , we have a critical pair . This critical pair is also joinable w.r.t. by hypothesis with and , so there is some such that and . Since and , we have , and thus and are joinable w.r.t. .
This shows that , and thus is locally confluent.
lemma csts_r_critical_pair_lemma: assumes ""
""
lemma csts_p_critical_pair_lemma: assumes ""
""
For reductive right-join (or pure-join) CSTSs, joinability of critical pairs suffices to show confluence by Lemma 35 (resp. Lemma 36). However, this is not the case for reductive left-right-join CSTSs. In particular, unlike reductive right-join or pure-join CSTSs, non-overlap may not be joinable for reductive left-right-join CSTSs as shown in the following example.
Example 37.
Consider the left-right-join CSTS over . Using the shortlex ordering induced by the precedence , we see that is reductive. Now, consider a non-overlap . Here, the step uses the rules and , and the step uses the rules and . However, it is not the case that .
Now, we discuss the monoids defined by certain congruence relations induced by the string rewriting relations and .
Definition 38.
Let be a reductive right-join (resp. a pure-join) CSTS on . The Thue congruence induced by (resp. ) is the relation (resp. ). Two strings are congruent w.r.t. (resp. ) if (resp. ). The congruence class (resp. ) of a word is defined as (resp. ). The set (resp. ) of congruence classes w.r.t. (resp. ) is denoted by (resp. ).
Remark 39.
In Definition 38, one can alternatively define (resp. ) only if (resp. ) is confluent so that () is the same as the right (resp. pure) conditional equational theory induced by (see Lemmas 27 and 28). In this case, (resp. ) can be directly associated with the right (resp. pure) conditional equational theory induced by . We use the simpler definition of (resp. ) as in Definition 38 instead of adding the restriction that (resp. ) is confluent (cf. Theorem 42).
Lemma 40.
Definition 41.
Let be a reductive right-join (resp. a pure-join) CSTS over . The ordered pair () is a (reductive) conditional presentation of the monoid (resp. ). The monoid (resp. ) is finitely presented if both and are finite in (). The ordered pair () is a complete (reductive) conditional presentation of the monoid (resp. ) if (resp. ) is complete.
The following theorem and its proof provide a decision procedure for the word problem of monoids with finite complete (reductive) conditional presentations.
Proof.
For the proof of (i), if , then and are the same element in . Otherwise, and are the different elements in . Since is finite and reductive, is terminating and decidable. Furthermore, is confluent by hypothesis, so we can decide whether by comparing the normal forms of and w.r.t. . In other words, if the normal forms of and w.r.t. are the same, then they are the same element in , and they are the different elements in , otherwise. We omit the proof of (ii) because it is similar to the proof of (i).
Our formalization of Theorem 42 is an extension of the formalization of Theorem 10 discussed in Section 3 in conditional setting, where the locale monoid is instantiated using the different parameters for and , respectively:
"" "" ""
"" "" ""
Above, and are (csr_r_join_step and (csr_p_join_step, respectively. They correspond to the Thue congruence relations induced by and , respectively. Also, (resp. ) represents an associative binary operator for the monoid (resp. ) in such a way that (resp. ) for all , where is represented by in the above. Finally, (resp. ) represents the congruence class (resp. ) corresponding to the identity element in (resp. ).
5 Conclusion
Semi-Thue and certain types of conditional semi-Thue systems can be viewed as presentations of monoids because they define a quotient of the free monoid modulo the Thue congruence that they induce. We have presented an Isabelle/HOL formalization of semi-Thue and conditional semi-Thue systems along with a decision procedure for the word problem of monoids with finite complete unconditional or reductive conditional presentations. Also, our formalized framework for semi-Thue and Thue systems can provide formalized building blocks for different kinds applications because there is a wide variety of applications of semi-Thue and Thue systems, such as formal language theory [7, 38], group theory [10, 33, 19, 40], and algebraic protocols [7, 6].
The main contributions of this paper are as follows: (i) We have presented the first (computer-aided) formalization of conditional semi-Thue systems (using a proof assistant). In particular, we have provided a new formalized method for checking confluence using (conditional) critical pairs for finite reductive right-join and pure-join conditional semi-Thue systems. (ii) The existing classification of conditional semi-Thue systems basically consists only of left-right-join and right-join conditional semi-Thue systems (see [11]). We have extended this classification depending on how conditions are evaluated in the conditional parts of their rules, and provided a formalized framework for the different types of conditional semi-Thue systems. (For the classification of conditional term rewriting systems, see [46].) Furthermore, we have proposed and formalized a new inference system for generating different conditional equational theories and Thue congruences for the associated monoids along with their word problem. (iii) We have presented and formalized an inference system for a completion procedure of semi-Thue systems, which is adapted from the existing Knuth-completion procedure [24, 7] of semi-Thue systems and an abstract completion procedure [18, 2] of term rewriting systems. When attempting to construct a finite complete presentation of a monoid or a group, our inference-system based completion procedure is straightforward and easy to use (in comparison to algorithm-based completion procedures [24, 7]) by means of simple string matching. We have also provided the formalized proof of its correctness.
Yet, much work still remains ahead. Unlike semi-Thue systems, conditional semi-Thue systems have not been well researched. For example, effective/operation termination [32, 37], confluence, and the reachability analysis [16] of the different types of conditional semi-Thue systems along with their formalization are possible future research directions. Another possible future research direction is to classify and formalize the different types of conditional string rewriting in terms of the expressive power [34] of string rewriting.
References
- [1] Franz Baader and Tobias Nipkow. Term Rewriting and All That. Cambridge University Press, Cambridge, UK, 1998. doi:10.1017/CBO9781139172752.
- [2] Leo Bachmair, Nachum Dershowitz, and Jieh Hsiang. Orderings for Equational Proofs. In Proceedings of the Symposium on Logic in Computer Science (LICS ’86), Cambridge, Massachusetts, USA, June 16-18, 1986, pages 346–357. IEEE Computer Society, 1986.
- [3] Clemens Ballarin. Tutorial to Locales and Locale Interpretation, 2010. URL: http://isabelle.in.tum.de/doc/locales.pdf.
- [4] Clemens Ballarin. A Case Study in Basic Algebra. Arch. Formal Proofs, 2019. URL: https://www.isa-afp.org/entries/Jacobson_Basic_Algebra.html.
- [5] Jan A. Bergstra and Jan Willem Klop. Conditional Rewrite Rules: Confluence and Termination. J. Comput. Syst. Sci., 32(3):323–362, 1986. doi:10.1016/0022-0000(86)90033-4.
- [6] Ronald V. Book and Friedrich Otto. On the Verifiability of Two-Party Algebraic Protocols. Theor. Comput. Sci., 40:101–130, 1985. doi:10.1016/0304-3975(85)90161-6.
- [7] Ronald V. Book and Friedrich Otto. String-Rewriting Systems. Springer, New York, NY, 1993. doi:10.1007/978-1-4613-9771-7.
- [8] Thomas Braibant and Damien Pous. Tactics for Reasoning Modulo AC in Coq. In Jean-Pierre Jouannaud and Zhong Shao, editors, Certified Programs and Proofs - First International Conference, CPP 2011, Kenting, Taiwan, December 7-9, 2011. Proceedings, volume 7086 of Lecture Notes in Computer Science, pages 167–182. Springer, 2011. doi:10.1007/978-3-642-25379-9_14.
- [9] Jacek Chrzaszcz and Daria Walukiewicz-Chrzaszcz. Towards Rewriting in Coq. In Hubert Comon-Lundh, Claude Kirchner, and Hélène Kirchner, editors, Rewriting, Computation and Proof, Essays Dedicated to Jean-Pierre Jouannaud on the Occasion of His 60th Birthday, volume 4600 of Lecture Notes in Computer Science, pages 113–131. Springer, 2007. doi:10.1007/978-3-540-73147-4_6.
- [10] Daniel E. Cohen. String Rewriting – A Survey for Group Theorists. In Graham A. Niblo and Martin A. Roller, editors, Geometric Group Theory, London Mathematical Society Lecture Note Series, pages 37–47. Cambridge University Press, 1993.
- [11] Thomas Deiß. Conditional Semi-Thue systems for Presenting Monoids. Technical report, Universität Kaiserslautern, 1992. SEKI Report SR-92-12 available at https://agent.informatik.uni-kl.de/seki/1992/Deiss.SR-92-12.english.ps.Z. A shorter version of the paper was presented at Annual Symposium on Theoretical Aspects of Computer Science in 1992 (STACS 92) with the same title.
- [12] Nachum Dershowitz, Mitsuhiro Okada, and G. Sivakumar. Confluence of Conditional Rewrite Systems. In Stéphane Kaplan and Jean-Pierre Jouannaud, editors, Conditional Term Rewriting Systems, 1st International Workshop, Orsay, France, July 8-10, 1987, Proceedings, volume 308 of LNCS, pages 31–44. Springer, 1987. doi:10.1007/3-540-19242-5_3.
- [13] Nachum Dershowitz and David A. Plaisted. Rewriting. In John Alan Robinson and Andrei Voronkov, editors, Handbook of Automated Reasoning (in 2 volumes), pages 535–610. Elsevier and MIT Press, 2001. doi:10.1016/B978-044450813-3/50011-4.
- [14] Patrick Baxter Dragon, Oscar I. Hernandez, Joe Sawada, Aaron Williams, and Dennis Wong. Constructing de Bruijn sequences with co-lexicographic order: The k-ary Grandmama sequence. Eur. J. Comb., 72:1–11, 2018. doi:10.1016/J.EJC.2018.03.006.
- [15] Hannah Fechtner. Braids in Lean. Master’s thesis, Carnegie Mellon University, PA, USA, 2024.
- [16] Guillaume Feuillade, Thomas Genet, and Valérie Viet Triem Tong. Reachability Analysis over Term Rewriting Systems. J. Autom. Reason., 33(3-4):341–383, 2004. doi:10.1007/S10817-004-6246-0.
- [17] Yannick Forster, Dominique Larchey-Wendling, Andrej Dudenhefner, Edith Heiter, Dominik Kirst, Fabian Kunze, Gert Smolka, Simon Spies, Dominik Wehr, and Maximilian Wuttke. A Coq Library of Undecidable Problems. In CoqPL 2020 The Sixth International Workshop on Coq for Programming Languages, New Orleans, USA, 2020. URL: https://hal.science/hal-02944217.
- [18] Nao Hirokawa, Aart Middeldorp, Christian Sternagel, and Sarah Winkler. Abstract Completion, Formalized. Log. Methods Comput. Sci., 15(3), 2019. doi:10.23638/LMCS-15(3:19)2019.
- [19] D. F. Holt, B. Eick, and E. A. O’Brien. Handbook of computational group theory. CRC Press, Boca Raton, FL, 2005.
- [20] Jieh Hsiang, Hélène Kirchner, Pierre Lescanne, and Michaël Rusinowitch. The Term Rewriting Approach to Automated Theorem Proving. J. Log. Program., 14(1&2):71–99, 1992. doi:10.1016/0743-1066(92)90047-7.
- [21] Nathan Jacobson. Basic algebra I. Dover Publications, Inc., Mineola, NY, 2nd edition, 2009.
- [22] Sam Kamin and Jean-Jacques Levy. Two generalizations of the recursive path ordering. Technical report, Dept. of Computer Science, Univ. of Illinois at Urbana-Champaign, 1980.
- [23] Stéphane Kaplan. Conditional Rewrite Rules. Theor. Comput. Sci., 33:175–193, 1984. doi:10.1016/0304-3975(84)90087-2.
- [24] Deepak Kapur and Paliath Narendran. The Knuth-Bendix Completion Procedure and Thue Systems. SIAM J. Comput., 14(4):1052–1072, 1985. doi:10.1137/0214073.
- [25] Deepak Kapur and G. Sivakumar. RRL: theorem proving environment based on rewriting techniques. SIGSOFT Softw. Eng. Notes, 10(4):67–68, 1985. doi:10.1145/1012497.1012522.
- [26] Yutaka Kikuchi and Takuya Katayama. An Application of Term Rewriting Systems for Functional Programming. In Yutaka Ohno and Toshiko Matsuda, editors, Distributed Environments: Software Paradigms and Workstations, pages 79–106. Springer Japan, 1991. doi:10.1007/978-4-431-68144-1_7.
- [27] Dohan Kim. Equational theorem proving for clauses over strings. Mathematical Structures in Computer Science, 34(10):1055–1078, 2024. doi:10.1017/S0960129524000112.
- [28] Dohan Kim. Congruence Closure Modulo Groups. Logical Methods in Computer Science, Volume 21, Issue 1, 2025. doi:10.46298/lmcs-21(1:20)2025.
- [29] D. E. Knuth and P. B. Bendix. Simple Word Problems in Universal Algebras. In Jörg H. Siekmann and Graham Wrightson, editors, Automation of Reasoning: 2: Classical Papers on Computational Logic 1967–1970, pages 342–376. Springer Berlin Heidelberg, 1983. doi:10.1007/978-3-642-81955-1.
- [30] Donald E. Knuth, James H. Morris Jr., and Vaughan R. Pratt. Fast Pattern Matching in Strings. SIAM J. Comput., 6(2):323–350, 1977. doi:10.1137/0206024.
- [31] Pierre Lescanne. Computer experiments with the REVE term rewriting system generator. In Proceedings of the 10th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL ’83, pages 99–108, 1983. doi:10.1145/567067.567078.
- [32] Salvador Lucas, Claude Marché, and José Meseguer. Operational termination of conditional term rewriting systems. Inf. Process. Lett., 95(4):446–453, 2005. doi:10.1016/J.IPL.2005.05.002.
- [33] Klaus Madlener and Friedrich Otto. Using String-Rewriting for Solving the Word Problem for Finitely Presented Groups. Inf. Process. Lett., 24(5):281–284, 1987. doi:10.1016/0020-0190(87)90149-9.
- [34] Massimo Marchiori. On the Expressive Power of Rewriting. In S. Ramesh and G. Sivakumar, editors, Foundations of Software Technology and Theoretical Computer Science, 17th Conference, Kharagpur, India, December 18-20, 1997, Proceedings, volume 1346 of Lecture Notes in Computer Science, pages 88–102. Springer, 1997. doi:10.1007/BFB0058025.
- [35] M. H. A. Newman. On Theories with a Combinatorial Definition of “Equivalence”. Annals of Mathematics, 43(2):223–243, 1942. doi:10.2307/1968867.
- [36] Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. Isabelle/HOL - A Proof Assistant for Higher-Order Logic, volume 2283 of Lecture Notes in Computer Science. Springer, 2002. doi:10.1007/3-540-45949-9.
- [37] Enno Ohlebusch. Advanced topics in term rewriting. Springer Science & Business Media, Berlin/Heidelberg, Germany, 2002.
- [38] Friedrich Otto. On the Connections between Rewriting and Formal Language Theory. In Paliath Narendran and Michaël Rusinowitch, editors, Rewriting Techniques and Applications, 10th International Conference, RTA-99, Trento, Italy, July 2-4, 1999, Proceedings, volume 1631 of LNCS, pages 332–355. Springer, 1999. doi:10.1007/3-540-48685-2_27.
- [39] James F Power. Thue’s 1914 paper: a translation. arXiv preprint arXiv:1308.5858, 2013. doi:10.48550/arXiv.1308.5858.
- [40] C. C. Sims. Computation with finitely presented groups. Cambridge University Press, New York, NY, 1994.
- [41] Christian Sternagel and Thomas Sternagel. Certifying Confluence of Quasi-Decreasing Strongly Deterministic Conditional Term Rewrite Systems. In Leonardo de Moura, editor, Automated Deduction - CADE 26 - 26th International Conference on Automated Deduction, Gothenburg, Sweden, August 6-11, 2017, Proceedings, volume 10395 of Lecture Notes in Computer Science, pages 413–431. Springer, 2017. doi:10.1007/978-3-319-63046-5_26.
- [42] Christian Sternagel and René Thiemann. Abstract Rewriting. Arch. Formal Proofs, 2010, 2010. URL: https://www.isa-afp.org/entries/Abstract-Rewriting.shtml.
- [43] Terese. Term Rewriting Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 2003.
- [44] René Thiemann and Christian Sternagel. Certification of Termination Proofs Using CeTA. In Stefan Berghofer, Tobias Nipkow, Christian Urban, and Makarius Wenzel, editors, Theorem Proving in Higher Order Logics, 22nd International Conference, TPHOLs 2009, Munich, Germany, August 17-20, 2009. Proceedings, volume 5674 of Lecture Notes in Computer Science, pages 452–468. Springer, 2009. doi:10.1007/978-3-642-03359-9_31.
- [45] Akihisa Yamada, Keiichirou Kusakari, and Toshiki Sakabe. A unified ordering for termination proving. Sci. Comput. Program., 111:110–134, 2015. doi:10.1016/J.SCICO.2014.07.009.
- [46] Toshiyuki Yamada, Jürgen Avenhaus, Carlos Loría-Sáenz, and Aart Middeldorp. Logicality of conditional rewrite systems. Theor. Comput. Sci., 236(1-2):209–232, 2000. doi:10.1016/S0304-3975(99)00210-8.
