Documentation

Strata.DL.SMT.RegexMatch

Matching SMT-LIB regular expressions #

Regular expressions with their SMT-LIB meaning, and a matcher for literal strings. Matching takes the derivative of the expression by each character in turn (Brzozowski's method) and checks whether the rest accepts the empty string. For example, the derivative of "ab" ++ c* by a and then b is c*, which accepts the empty string, so "ab" matches.

A regular expression over the SMT-LIB string alphabet.

  • none : Re

    re.none: no string.

  • all : Re

    re.all: every string.

  • allChar : Re

    re.allchar: every string of one character.

  • str (s : List Char) : Re

    str.to_re s: the string s.

  • range (lo hi : Char) : Re

    re.range with single-character bounds.

  • cat (a b : Re) : Re

    re.++

  • union (a b : Re) : Re
  • inter (a b : Re) : Re
  • star (a : Re) : Re

    re.*

  • comp (a : Re) : Re

    re.comp: the complement of a.

  • loop (a : Re) (lo hi : Nat) : Re

    re.loop: lo to hi repetitions of a; no string when lo > hi.

Instances For
    def Strata.SMT.Regex.instDecidableEqRe.decEq (x✝ x✝¹ : Re) :
    Decidable (x✝ = x✝¹)
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      Equations
      Instances For

        The node count above which matches? gives no answer.

        Equations
        Instances For

          re.range of two strings: the characters between them when both have one character, and no string otherwise.

          Equations
          Instances For

            re.+: one or more repetitions.

            Equations
            Instances For

              Whether r has at most n nodes. Counting stops once it passes n, so the check is cheap even on a tree with shared subterms, such as nested plus.

              Equations
              Instances For

                Concatenation, simplified when a side is none or the empty string.

                Equations
                Instances For

                  The alternatives of r, with nested unions flattened.

                  Equations
                  Instances For
                    @[irreducible]

                    rs with each element equal to the one before it removed.

                    Equations
                    Instances For

                      Union, normalized: the alternatives of both sides are sorted, with repeats and none removed, and the union is all when one of them is. This keeps derivatives small: those of re.all ++ "a" ++ re.all by each character would otherwise grow with the length of the string. A union of more than maxSize nodes is left as is, so the sort never runs on a large term; matches? gives up on a derivative that contains it.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Intersection, which is none when either side is.

                        Equations
                        Instances For

                          Whether r matches s, or none when r or a derivative has more than maxSize nodes or s has a character outside the SMT-LIB alphabet.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For