Procházet zdrojové kódy

Added FLC lesson-03

Federico Amedeo Izzo před 9 roky
rodič
revize
0362e066dc

+ 20 - 13
Formal Languages and Compilers/lesson_02.md

@@ -2,7 +2,7 @@
 ##### Luca Oddone Breveglieri
 ###### 8 october 2015
 
-### Operations on languages
+## Operations on languages
 Applies (and is defined) to each string in the language
 $$L^R=\{|x=y^R\wedge y\in L\}$$
 #### Prefix-free language
@@ -14,27 +14,34 @@ $$\text{prefix(L)} \cap L=\Phi$$
 $$L'L''=\{xy|x\in L' \wedge y \in L''\}$$
 #### m-th power (m≥0)
 $$L^m=L^{m-1}L,m>0\;\;L^0=\{\varepsilon\}$$
-#### Star Operator
-Also called Kleene star or Concatenation closure.
-##### The union of all powers of a language
-$$L=\{ab,ba\}\;L^*=\{\varepsilon,ab,ba,abab,abba,baab,baba,...\}$$
-**
+---
+### Set-theoretic Operations
+#### Universal language
+The set of all strings defined over the alphabet $\Sigma$, also called __free monoid__.
+#### Complement of a language
+Set-theoretic difference between the universal language and the given language
+$$\lnot L =L_{universal} \setminus L$$
+#### Set-theoretic difference
 
+---
+### Star Operator
+Also called Kleene star or Concatenation closure.  
+Is the union of all powers of a language
+$$L=\{ab,ba\}\;L^*=\{\varepsilon,ab,ba,abab,abba,baab,baba,...\}$$
+<!--*-->
 #### Properties:
 - monotonic
 - closed w.r.t. Concatenation
 - idempotent
 - commutes with mirroring
 
-#### Example of star operator
+##### example
 $$\sum_A=\{A,B,...,Z\} \; \sum_N=\{0,1,2,...,9\}$$
 
+#### Cross Operator
+Also called Kleene cross, or $\varepsilon$-free concatenation closure
+$$\{ab,bb\}^+ =\{ab,bb,ab^3,b^2ab,abab,b^4,...\}$$
+
 #### Quotient Operator
 It shortens the phrases of a language L' by stripping off a suffix out of another languare L''
 $$L=L'/L''=\{y|(x=yz\in L') x\in L''\}$$
-
----
-### Regular Expressions
-
-__Regular Expresions__ are defined by operators over an alphabet,
-The operation admitted are:

+ 45 - 0
Formal Languages and Compilers/lesson_03.md

@@ -0,0 +1,45 @@
+# FLC - lesson 03
+##### Luca Oddone Breveglieri
+###### 8 october 2015
+
+## Regular Expressions
+
+__Regular Languages__ are the simplest family of formal languages.  
+Can be defined in different ways:
+- algebrically
+- through generating grammars
+- through recognizer machines
+
+__Regular Expression__ (*regexp*) is a string $r$ defined with the terminal alphabet $\Sigma$  
+containing some *metasymbols*  
+##### Possible cases:
+$r,s,t$ are regexp
+1. $r=\varnothing$
+2. $r=a, \;\;a\in \Sigma$
+3. $r=s\cup t\;\; \text{or}\;\; r=s|t$
+4. $r=s.t\;\; \text{or}\;\; r=st$
+5. $r=s^*$ <!--*-->
+##### Precedence of operators
+1. star *
+2. concatenation .
+3. union $\cup$ or |
+
+A language is __regular__ if it is generated by a *regular expression*
+
+regexp|language
+---|---
+$\varepsilon \;\text{or}\;\varnothing$|$\{\varepsilon\}$
+$a\in\Sigma$|$\{a\}$
+$s \cup t \; \text{or} \; s \mid t$ | $L_s \cup L_t$
+$s.t \; \text{or} \; st$ | $L_s.L_t$
+$s^*$|${L_s}^*$
+
+#####example
+>The regexp $e$ that generates the language of integers, possibly signed  
+$e={(+\cup - \cup\varepsilon)dd}^*$ $L_e=\{+,-,\varepsilon\}\{d\}\{d\}^*$
+
+__Family of regular languages__ or __REG__:  
+Is the collection of all regular languages.
+
+__Family of finite languages__ or __FIN__:  
+Is the collection of all languages of finite cardinality.