| 1 |
; =============== Regular expression membership rules |
| 2 |
|
| 3 |
(define-rule re-in-empty ((t String)) (str.in_re t re.none) false) |
| 4 |
(define-rule re-in-sigma ((t String)) (str.in_re t re.allchar) (= (str.len t) 1)) |
| 5 |
(define-rule re-in-sigma-star ((t String)) (str.in_re t (re.* re.allchar)) true) |
| 6 |
(define-rule re-in-cstring ((t String) (s String)) (str.in_re t (str.to_re s)) (= t s)) |
| 7 |
(define-rule re-in-comp ((t String) (r RegLan)) (str.in_re t (re.comp r)) (not (str.in_re t r))) |
| 8 |
|
| 9 |
(define-rule* str-in-re-union-elim ((s String) (r1 RegLan) (r2 RegLan) (rs RegLan :list)) |
| 10 |
(str.in_re s (re.union r1 r2 rs)) |
| 11 |
(str.in_re s (re.union r2 rs)) |
| 12 |
(or (str.in_re s r1) _)) |
| 13 |
|
| 14 |
(define-rule* str-in-re-inter-elim ((s String) (r1 RegLan) (r2 RegLan) (rs RegLan :list)) |
| 15 |
(str.in_re s (re.inter r1 r2 rs)) |
| 16 |
(str.in_re s (re.inter r2 rs)) |
| 17 |
(and (str.in_re s r1) _)) |
| 18 |
|
| 19 |
(define-cond-rule str-in-re-range-elim ((s String) (c1 String) (c2 String)) |
| 20 |
(and (= (str.len c1) 1) (= (str.len c2) 1)) |
| 21 |
(str.in_re s (re.range c1 c2)) |
| 22 |
(and (<= (str.to_code c1) (str.to_code s)) (<= (str.to_code s) (str.to_code c2)))) |
| 23 |
|
| 24 |
(define-rule str-in-re-contains ((t String) (s String)) |
| 25 |
(str.in_re t (re.++ (re.* re.allchar) (str.to_re s) (re.* re.allchar))) |
| 26 |
(str.contains t s)) |
| 27 |
|
| 28 |
(define-cond-rule str-in-re-from-int-nemp-dig-range ((n Int)) |
| 29 |
(>= n 0) |
| 30 |
(str.in_re (str.from_int n) (re.++ (re.range "0" "9") (re.* (re.range "0" "9")))) |
| 31 |
true) |
| 32 |
|
| 33 |
(define-rule str-in-re-from-int-dig-range ((n Int)) |
| 34 |
(str.in_re (str.from_int n) (re.* (re.range "0" "9"))) |
| 35 |
true) |