regular expressions – How to Formally Verify if a (or a Sequence of) Regex Modification(s) is an Idempotent

I’m performing a sequence of text formatting using regex in Python. I’m curious to know if it’s possible to formally verify whether a single (or a sequence of) regex modification(s) is an idempotent, i.e. if we denote the resulting total modification as a function d, then for any text, d ∘ d (text) = d (text).

The motivation behind this is to achieve a formatting process where the modifications can be applied multiple times without affecting the already formatted text, ensuring a stable and consistent format.

Edit: Initially, I used the term “involution,” but based on the feedback in the comments, I’ve corrected this to “idempotent.”

Read more here: Source link