Regular Expressions #
This file contains the formal definition for regular expressions and basic lemmas. Note these are regular expressions in terms of formal language theory. Note this is different to regexes used in computer science such as the POSIX standard.
TODO #
Currently, we do not show that regular expressions and DFAs/NFAs are equivalent. Multiple competing PRs towards that goal are in review. See https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Regular.20languages.3A.20the.20review.20queue
This is the definition of regular expressions. The names used here are meant to mirror the definition of a Kleene algebra (https://en.wikipedia.org/wiki/Kleene_algebra).
0(zero) matches nothing1(epsilon) matches only the empty stringchar amatches only the string 'a'star Pmatches any finite concatenation of strings that matchPP + Q(plus P Q) matches anything that matchesPorQP * Q(comp P Q) matchesx ++ yifxmatchesPandymatchesQ
- zero {α : Type u} : RegularExpression α
- epsilon {α : Type u} : RegularExpression α
- char {α : Type u} : α → RegularExpression α
- plus {α : Type u} : RegularExpression α → RegularExpression α → RegularExpression α
- comp {α : Type u} : RegularExpression α → RegularExpression α → RegularExpression α
- star {α : Type u} : RegularExpression α → RegularExpression α
Instances For
matches' P provides a language which contains all strings that P matches.
Not named matches since that is a reserved word.
Instances For
matchEpsilon P is true if and only if P matches the empty string
Instances For
P.deriv a matches x if P matches a :: x, the Brzozowski derivative of P with respect
to a
Instances For
Map the alphabet of a regular expression.
Instances For
The language of the map is the map of the language.