Created
November 25, 2016 00:33
-
-
Save rodrigogribeiro/e8f6bde70b54c871f8c744a9b3570bb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set Implicit Arguments. | |
Require Import Ascii String. | |
Inductive regex : Set := | |
| Emp : regex | |
| Eps : regex | |
| Chr : ascii -> regex | |
| Cat : regex -> regex -> regex | |
| Choice : regex -> regex -> regex | |
| Star : regex -> regex. | |
Open Scope string_scope. | |
Notation "'#0'" := Emp. | |
Notation "'#1'" := Eps. | |
Notation "'$' c" := (Chr c)(at level 40). | |
Notation "e '@' e1" := (Cat e e1)(at level 15, left associativity). | |
Notation "e ':+:' e1" := (Choice e e1)(at level 20, left associativity). | |
Notation "e '^*'" := (Star e)(at level 40). | |
(** Semantics of regular expressions *) | |
Reserved Notation "s '<<-' e" (at level 40). | |
Inductive in_regex : string -> regex -> Prop := | |
| InEps | |
: "" <<- #1 | |
| InChr | |
: forall c | |
, (String c EmptyString) <<- ($ c) | |
| InCat | |
: forall e e' s s' s1 | |
, s <<- e | |
-> s' <<- e' | |
-> s1 = s ++ s' | |
-> s1 <<- (e @ e') | |
| InLeft | |
: forall s e e' | |
, s <<- e | |
-> s <<- (e :+: e') | |
| InRight | |
: forall s' e e' | |
, s' <<- e' | |
-> s' <<- (e :+: e') | |
| InStar | |
: forall s e | |
, s <<- (#1 :+: (e @ (e ^*))) | |
-> s <<- (e ^*) | |
where "s '<<-' e" := (in_regex s e). | |
Hint Constructors in_regex. | |
Lemma star_lemma : forall s, s <<- (#1 ^*) -> s = "". | |
Proof. | |
intros s H ; induction s ; auto. | |
absurd (String a s = ""). | |
Admitted. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment