瀏覽代碼

Space before titles, others graphical fix

andreagus 9 年之前
父節點
當前提交
87bf7bccf1

+ 4 - 0
Formal Languages and Compilers/lesson_01.md

@@ -28,9 +28,12 @@ There is an effective procedure to verify the grammatical *correctness* of a phr
 ##### Years '70-'80
 - Formal language theory becomes a standard university discipline
 - Introduction of SDKs like Flex or Bison
+
 ---
+
 ## Formal Languages, Basic Notions
 ### Definition of a language
+
 - __Alphabet__: finite set of elements
 - __String__: Ordered set of atomic elements, possibly repeated
 - __Language__: Finite or infinite set of __strings__
@@ -42,6 +45,7 @@ The __cardinality__ of a *language* determines the number of elements contained,
 It can be 0 for the __empty language__ or *infinite* for __infinite languages__.
 
 ---
+
 ### Operations on strings
 
 #### Lenght of a string

+ 7 - 0
Formal Languages and Compilers/lesson_02.md

@@ -5,6 +5,7 @@
 ## Operations on languages
 An operation defined on a language, applies to (and is definable over) each string in the language.
 $$L^R=\{|x=y^R\wedge y\in L\}$$
+
 #### Prefix-free language
 $$\text{prefix}(L)=\{y|x=yz\wedge x\in L\wedge y,z\neq\varepsilon\}$$
 In the language there is not any string that is prefix of another.
@@ -12,8 +13,10 @@ $$\text{prefix(L)} \cap L=\Phi$$
 
 #### Concatenation
 $$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\}$$
+
 #### Strings of finite length
 The language of the strings that have a length not greater than an integer k
 $$L=\{\varepsilon,a,b\}^3 \;k=3$$
@@ -24,13 +27,16 @@ $$L\{a,b\}\{\varepsilon,a,b\}^2$$
 ---
 ### Set-theoretic Operations
 Are traditional operators of set theory, like __union__ $\cup$, __intersection__ $\cap$, __complement__ $\lnot$, also __strict inclusion__, __inclusion__, __equality__, __inequality__...
+
 #### Universal language
 The set of all strings defined over the alphabet $\Sigma$, also called __free monoid__.
+
 #### Complement of a language
 over the alphabet $\Sigma$ is the set-theoretic difference between the universal language and the given language
 $$\lnot L =L_{universal} \setminus L$$
 >The complement of a finite language is always an infinite language  
 The complement of ain infinite language may be infinite or finite.
+
 #### Set-theoretic difference
 $$L_1\setminus L_2$$
 Is the language containing all the strings of $L_1$ that __are not part__ of $L_2$
@@ -41,6 +47,7 @@ Also called __Kleene star__ or __concatenation closure__.
 Is the union of all powers of a language, for every positive or null exponent.
 $$L^*=\bigcup_{h=0...\infty}L^h=L^0\cup L^1\cup L^2...=\varepsilon\cup L^1\cup L^2...$$
 $$L=\{ab,ba\}\;L^*=\{\varepsilon,ab,ba,abab,abba,baab,baba,...\}$$
+
 #### Properties:
 - monotonic
 - closed w.r.t. Concatenation

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

@@ -12,14 +12,18 @@ Can be defined in different ways:
 
 __Regular Expression__ or *regexp*   
 is a string $r$ defined over the elements of a terminal alphabet $\Sigma$, using one of the following *metasymbols* $\;\cdot\;\cup\;\varnothing\;(\;)$
+
 #### regexp 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 $\;\cdot$
 3. union $\cup$ or |
@@ -68,6 +72,7 @@ $$ a_1\cup (b_2b_3)\;\;\;\;\;\;c_4^+\;\;\;\;a_5 \cup (b_6b_7)$$
 $$ a_1\;\;\;\;b_2b_3\;\;\;\;\;\;c_4^\;\;\;\;a_5 \;\;(b_6b_7)$$
 $$ a_1\;\;\;\;b_2\;\;\;b_3\;\;\;\;\;\;c_4^\;\;\;\;a_5 \;\;\;b_6\;\;\;b_7$$
 <!--*-->
+
 ### Different parenthesization
 And hence different interpretations of a regexp
 $$f=(a\cup bb)^*(c^+\cup a\cup bb)$$
@@ -86,6 +91,7 @@ With
 - $\beta$ subexpression of $e'$
 - $\gamma$ subexpression of $e''$
 - $\gamma$ is a *choice* of $\beta$
+
 ##### examples
 - one step derivation
 $$a^*\cup b^+\Rightarrow a^*\;\;\;a^*\cup b^+\Rightarrow b^+$$
@@ -105,6 +111,7 @@ $$(a\cup b)^*a(a\cup b)^* \Rightarrow \varepsilon a(a\cup b)^*\Rightarrow \varep
 <!--*-->
 
 A regexp is __ambiguous__ if the corresponding marked (with numbers on letters) regexp $f_\#$ generates two marked strings $x$ and $y$ such that, removing the indices, we obtain the same string (sufficient condition, not necessary)
+
 ##### examples
 $$(aa|ba)^*a|b(aa|ba)^*\;\; \text{is ambiguous}$$
 in fact the marking
@@ -170,6 +177,7 @@ $$ie(se)^*f\;\;\;i[e(se)^*]f$$
 
 ### Substitution
 Operation that replaces the terminal characters of the source language with the phrases of the destination languages
+
 ##### example
 $$L\subset \Sigma^*\;\;\;L_b\subset\Delta^*$$
 $$x\in L \;\;\;x=a_1a_2...a_n\;\;\text{and for some}\;\;\;a_i=b$$
@@ -178,6 +186,7 @@ $$\{y|y=y_1y_2...y_n\wedge (ifa_i\neq b\;\text{then}\;y_i=a_i\;\text{else}\;y_i\
 
 ### Nested lists (or precedence lists)
 Lists may contain atomic objects as elements, but also other lists of lower level
+
 ##### example
 >livello 1: begin istr1;istr2;...;istrn end  
 livello 2: STAMPA(var1,var2,...,varn)

+ 1 - 0
Formal Languages and Compilers/lesson_05.md

@@ -16,6 +16,7 @@ There is an algorithm in two phases:
 - Identifying the non-terminal symbold that are unreachable
 
 The resulting grammar can be reduced but is not *guaranteed to be minimal*
+
 #### Phase 1
 Construct the complement set DEF and the defined non-term symbols
 $$DEF=V\setminus UNDEF$$