2 (** {1 Theory of regular expressions} *)
15 | Concat regexp regexp
20 (** Words are sequences of characters. *)
28 (** Inductive predicate `mem w r` means
29 "word `w` belongs to the language of `r`". *)
31 inductive mem (w: word) (r: regexp) =
35 forall c: char. mem (singleton c) (Char c)
37 forall w: word, r1 r2: regexp. mem w r1 -> mem w (Alt r1 r2)
39 forall w: word, r1 r2: regexp. mem w r2 -> mem w (Alt r1 r2)
41 forall w1 w2: word, r1 r2: regexp.
42 mem w1 r1 -> mem w2 r2 -> mem (w1 ++ w2) (Concat r1 r2)
44 forall r: regexp. mem empty (Star r)
46 forall w1 w2: word, r: regexp.
47 mem w1 r -> mem w2 (Star r) -> mem (w1 ++ w2) (Star r)
49 (** Optimizing constructors for Alt and Concat *)
51 let alt (r1 r2: regexp) : regexp
52 ensures { forall w: word. mem w result <-> mem w (Alt r1 r2) }
59 let concat (r1 r2: regexp) : regexp
60 ensures { forall w: word. mem w result <-> mem w (Concat r1 r2) }