Quellcode durchsuchen

Space before titles, others graphical fix

andreagus vor 9 Jahren
Ursprung
Commit
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
 ##### Years '70-'80
 - Formal language theory becomes a standard university discipline
 - Formal language theory becomes a standard university discipline
 - Introduction of SDKs like Flex or Bison
 - Introduction of SDKs like Flex or Bison
+
 ---
 ---
+
 ## Formal Languages, Basic Notions
 ## Formal Languages, Basic Notions
 ### Definition of a language
 ### Definition of a language
+
 - __Alphabet__: finite set of elements
 - __Alphabet__: finite set of elements
 - __String__: Ordered set of atomic elements, possibly repeated
 - __String__: Ordered set of atomic elements, possibly repeated
 - __Language__: Finite or infinite set of __strings__
 - __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__.
 It can be 0 for the __empty language__ or *infinite* for __infinite languages__.
 
 
 ---
 ---
+
 ### Operations on strings
 ### Operations on strings
 
 
 #### Lenght of a string
 #### Lenght of a string

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

@@ -5,6 +5,7 @@
 ## Operations on languages
 ## Operations on languages
 An operation defined on a language, applies to (and is definable over) each string in the language.
 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\}$$
 $$L^R=\{|x=y^R\wedge y\in L\}$$
+
 #### Prefix-free language
 #### Prefix-free language
 $$\text{prefix}(L)=\{y|x=yz\wedge x\in L\wedge y,z\neq\varepsilon\}$$
 $$\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.
 In the language there is not any string that is prefix of another.
@@ -12,8 +13,10 @@ $$\text{prefix(L)} \cap L=\Phi$$
 
 
 #### Concatenation
 #### Concatenation
 $$L'L''=\{xy|x\in L' \wedge y \in L''\}$$
 $$L'L''=\{xy|x\in L' \wedge y \in L''\}$$
+
 #### m-th power (m≥0)
 #### m-th power (m≥0)
 $$L^m=L^{m-1}L,m>0\;\;L^0=\{\varepsilon\}$$
 $$L^m=L^{m-1}L,m>0\;\;L^0=\{\varepsilon\}$$
+
 #### Strings of finite length
 #### Strings of finite length
 The language of the strings that have a length not greater than an integer k
 The language of the strings that have a length not greater than an integer k
 $$L=\{\varepsilon,a,b\}^3 \;k=3$$
 $$L=\{\varepsilon,a,b\}^3 \;k=3$$
@@ -24,13 +27,16 @@ $$L\{a,b\}\{\varepsilon,a,b\}^2$$
 ---
 ---
 ### Set-theoretic Operations
 ### Set-theoretic Operations
 Are traditional operators of set theory, like __union__ $\cup$, __intersection__ $\cap$, __complement__ $\lnot$, also __strict inclusion__, __inclusion__, __equality__, __inequality__...
 Are traditional operators of set theory, like __union__ $\cup$, __intersection__ $\cap$, __complement__ $\lnot$, also __strict inclusion__, __inclusion__, __equality__, __inequality__...
+
 #### Universal language
 #### Universal language
 The set of all strings defined over the alphabet $\Sigma$, also called __free monoid__.
 The set of all strings defined over the alphabet $\Sigma$, also called __free monoid__.
+
 #### Complement of a language
 #### Complement of a language
 over the alphabet $\Sigma$ is the set-theoretic difference between the universal language and the given language
 over the alphabet $\Sigma$ is the set-theoretic difference between the universal language and the given language
 $$\lnot L =L_{universal} \setminus L$$
 $$\lnot L =L_{universal} \setminus L$$
 >The complement of a finite language is always an infinite language  
 >The complement of a finite language is always an infinite language  
 The complement of ain infinite language may be infinite or finite.
 The complement of ain infinite language may be infinite or finite.
+
 #### Set-theoretic difference
 #### Set-theoretic difference
 $$L_1\setminus L_2$$
 $$L_1\setminus L_2$$
 Is the language containing all the strings of $L_1$ that __are not part__ of $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.
 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^*=\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,...\}$$
 $$L=\{ab,ba\}\;L^*=\{\varepsilon,ab,ba,abab,abba,baab,baba,...\}$$
+
 #### Properties:
 #### Properties:
 - monotonic
 - monotonic
 - closed w.r.t. Concatenation
 - 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*   
 __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\;(\;)$
 is a string $r$ defined over the elements of a terminal alphabet $\Sigma$, using one of the following *metasymbols* $\;\cdot\;\cup\;\varnothing\;(\;)$
+
 #### regexp cases:
 #### regexp cases:
+
 $r,s,t$ are regexp
 $r,s,t$ are regexp
 1. $r=\varnothing$
 1. $r=\varnothing$
 2. $r=a, \;\;a\in \Sigma$
 2. $r=a, \;\;a\in \Sigma$
 3. $r=s\cup t\;\; \text{or}\;\; r=s|t$
 3. $r=s\cup t\;\; \text{or}\;\; r=s|t$
 4. $r=s.t\;\; \text{or}\;\; r=st$
 4. $r=s.t\;\; \text{or}\;\; r=st$
 5. $r=s^*$ <!--*-->
 5. $r=s^*$ <!--*-->
+
 #### Precedence of operators
 #### Precedence of operators
+
 1. star $*$
 1. star $*$
 2. concatenation $\;\cdot$
 2. concatenation $\;\cdot$
 3. union $\cup$ or |
 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_2b_3\;\;\;\;\;\;c_4^\;\;\;\;a_5 \;\;(b_6b_7)$$
 $$ a_1\;\;\;\;b_2\;\;\;b_3\;\;\;\;\;\;c_4^\;\;\;\;a_5 \;\;\;b_6\;\;\;b_7$$
 $$ a_1\;\;\;\;b_2\;\;\;b_3\;\;\;\;\;\;c_4^\;\;\;\;a_5 \;\;\;b_6\;\;\;b_7$$
 <!--*-->
 <!--*-->
+
 ### Different parenthesization
 ### Different parenthesization
 And hence different interpretations of a regexp
 And hence different interpretations of a regexp
 $$f=(a\cup bb)^*(c^+\cup a\cup bb)$$
 $$f=(a\cup bb)^*(c^+\cup a\cup bb)$$
@@ -86,6 +91,7 @@ With
 - $\beta$ subexpression of $e'$
 - $\beta$ subexpression of $e'$
 - $\gamma$ subexpression of $e''$
 - $\gamma$ subexpression of $e''$
 - $\gamma$ is a *choice* of $\beta$
 - $\gamma$ is a *choice* of $\beta$
+
 ##### examples
 ##### examples
 - one step derivation
 - one step derivation
 $$a^*\cup b^+\Rightarrow a^*\;\;\;a^*\cup b^+\Rightarrow b^+$$
 $$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)
 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
 ##### examples
 $$(aa|ba)^*a|b(aa|ba)^*\;\; \text{is ambiguous}$$
 $$(aa|ba)^*a|b(aa|ba)^*\;\; \text{is ambiguous}$$
 in fact the marking
 in fact the marking
@@ -170,6 +177,7 @@ $$ie(se)^*f\;\;\;i[e(se)^*]f$$
 
 
 ### Substitution
 ### Substitution
 Operation that replaces the terminal characters of the source language with the phrases of the destination languages
 Operation that replaces the terminal characters of the source language with the phrases of the destination languages
+
 ##### example
 ##### example
 $$L\subset \Sigma^*\;\;\;L_b\subset\Delta^*$$
 $$L\subset \Sigma^*\;\;\;L_b\subset\Delta^*$$
 $$x\in L \;\;\;x=a_1a_2...a_n\;\;\text{and for some}\;\;\;a_i=b$$
 $$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)
 ### Nested lists (or precedence lists)
 Lists may contain atomic objects as elements, but also other lists of lower level
 Lists may contain atomic objects as elements, but also other lists of lower level
+
 ##### example
 ##### example
 >livello 1: begin istr1;istr2;...;istrn end  
 >livello 1: begin istr1;istr2;...;istrn end  
 livello 2: STAMPA(var1,var2,...,varn)
 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
 - Identifying the non-terminal symbold that are unreachable
 
 
 The resulting grammar can be reduced but is not *guaranteed to be minimal*
 The resulting grammar can be reduced but is not *guaranteed to be minimal*
+
 #### Phase 1
 #### Phase 1
 Construct the complement set DEF and the defined non-term symbols
 Construct the complement set DEF and the defined non-term symbols
 $$DEF=V\setminus UNDEF$$
 $$DEF=V\setminus UNDEF$$