Index: doc/theses/jiada_liang_MMath/CFAenum.tex
===================================================================
--- doc/theses/jiada_liang_MMath/CFAenum.tex	(revision 1d8a349d2e6b2f16b9c13dd45016011adf5118e6)
+++ doc/theses/jiada_liang_MMath/CFAenum.tex	(revision 4e09af2fe53d4632e8667617a260ed2c5a2058d2)
@@ -202,18 +202,22 @@
 An enumeration's type can be another enumeration.
 \begin{cfa}
-enum( char ) Letter { A = 'A', ... };
-enum( @Letter@ ) Greek { Alph = A, Beta = B, ... }; // alphabet intersection
-
-void foo(Letter l);
-foo(Beta);			$\C{// foo(value(Beta))}$
-\end{cfa}
-Enumeration @Greek@ may have more or less enumerators than @Letter@, but the enum values \emph{must} be of a member of @Letter@.
-Therefore, the set of @Greek@ enum value in a subset of the value set of type @Letter@. 
-@Letter@ is type compatible with enumeration @Letter@ thanks to \CFA inserts value conversion whenever @Letter@ be used 
-in place of @Greek@. On the other hand, @Letter@ enums are not type compatible with enumeration @Greek@.
-As a result, @Greek@ becomes a logical subtype of @Letter@.
-
-Subset defines an implicit subtyping relationship between two \CFA enumerations. \CFA also has 
-containment inheritance for \CFA enumerations where subtyping is explicitly structured.
+enum( char ) Letter { A = 'A', ..., Z = 'Z' };
+enum( @Letter@ ) Greek { Alph = @A@, Beta = @B@, Gamma = @G@, ..., Zeta = @Z@ }; // alphabet intersection
+\end{cfa}
+Enumeration @Greek@ may have more or less enumerators than @Letter@, but its enumerator values \emph{must} be from @Letter@.
+Therefore, the set of @Greek@ enumerator values in a subset of the @Letter@ enumerator values. 
+@Letter@ is type compatible with enumeration @Letter@ because value conversions are inserted whenever @Letter@ is used in place of @Greek@.
+\begin{cfa}
+Letter l = A;						$\C{// allowed}$
+Greek g = Alph;						$\C{// allowed}$
+l = Alph;							$\C{// allowed, conversion to base type}$
+g = A;								$\C{// {\color{red}disallowed}}$
+void foo( Letter );
+foo( Beta );						$\C{// allowed, conversion to base type}$
+void bar( Greek );
+bar( A );							$\C{// {\color{red}disallowed}}$
+\end{cfa}
+Hence, @Letter@ enumerators are not type compatible with the @Greek@ enumeration but the reverse is true.
+
 
 \section{Inheritance}
@@ -223,5 +227,5 @@
 Containment is nominative: an enumeration inherits all enumerators from another enumeration by declaring an @inline statement@ in its enumerator lists.
 \begin{cfa}
-enum( char * ) Names { /* $\see{\VRef[Figure]{f:EumeratorTyping}}$ */ };
+enum( char * ) Names { /* $\see{\VRef[Figure]{f:EumeratorTyping}}$ */  };
 enum( char * ) Names2 { @inline Names@, Jack = "JACK", Jill = "JILL" };
 enum( char * ) Names3 { @inline Names2@, Sue = "SUE", Tom = "TOM" };
@@ -244,26 +248,27 @@
 However, the position of the underlying representation is the order of the enumerator in the new enumeration.
 \begin{cfa}
-enum() E1 { B };								$\C{// B}$						
-enum() E2 { C, D };								$\C{// C D}$
-enum() E3 { inline E1, inline E2, E };			$\C{// {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C D {\color{red}]} E}$
-enum() E4 { A, inline E3, F};					$\C{// A {\color{blue}[\(_{E3}\)} {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C D {\color{red}]} E {\color{blue}]} F }$
-\end{cfa}
-In the example above, @B@ has the position 0 in @E1@ and @E3@, but it at the position 1 in @E4@ as @A@ taking the 0 in @E4@.
-@C@ is at the position 0 in @E2@, 1 in @E3@ and 2 in E4. @D@ is at the position 1 in @E2@, 2 in @E3@ and 3 in @E4@. 
-
-A subtype enumeration can be casted, or implicitly converted into its supertype, with a @safe@ cost. Such conversion is an @enumeration conversion@. 
+enum() E1 { B };									$\C{// B}$						
+enum() E2 { C, D };						$\C{// C D}$
+enum() E3 { inline E1, inline E2, E };	$\C{// {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C D {\color{red}]} E}$
+enum() E4 { A, inline E3, F};			$\C{// A {\color{blue}[\(_{E3}\)} {\color{red}[\(_{E1}\)} B {\color{red}]} {\color{red}[\(_{E2}\)} C D {\color{red}]} E {\color{blue}]} F}$
+\end{cfa}
+In the example, @B@ is at position 0 in @E1@ and @E3@, but position 1 in @E4@ as @A@ takes position 0 in @E4@.
+@C@ is at position 0 in @E2@, 1 in @E3@, and 2 in @E4@.
+@D@ is at position 1 in @E2@, 2 in @E3@, and 3 in @E4@. 
+
+A subtype enumeration can be casted, or implicitly converted into its supertype, with a @safe@ cost, called \newterm{enumeration conversion}. 
 \begin{cfa}
 enum E2 e2 = C;
 posn( e2 );			$\C[1.75in]{// 0}$
 enum E3 e3 = e2;
-posn( e2 );			$\C{// 1}$
+posn( e2 );			$\C{// 1 cost}$
 void foo( E3 e );
 foo( e2 );
-posn( (E3)e2 );		$\C{// 1}$
+posn( (E3)e2 );		$\C{// 1 cost}$
 E3 e31 = B;
-posn( e31 );		$\C{// 0}\CRT$
+posn( e31 );		$\C{// 0 cost}\CRT$
 \end{cfa}
 The last expression is unambiguous.
-While both @E2.B@ and @E3.B@ are valid candidate, @E2.B@ has an associated safe cost and \CFA selects the zero cost candidate @E3.B@.
+While both @E2.B@ and @E3.B@ are valid candidates, @E2.B@ has an associated safe cost, so \CFA selects the zero cost candidate.
 
 For the given function prototypes, the following calls are valid.
@@ -287,10 +292,10 @@
 Note, the validity of calls is the same for call-by-reference as for call-by-value, and @const@ restrictions are the same as for other types.
 
+
 \subsection{Offset Calculation}
+
 As discussed in \VRef{s:OpaqueEnum}, \CFA chooses position as a representation of a \CFA enumeration variable.
-Because enumerators has different @position@ between subtype and supertype, \CFA might need to manipulate the representation whenever a cast or 
-implicit conversion involves two \CFA enums. \CFA determine how a position is going to change with an @offset calculation@ function, reflects to 
-enumerator as an arithmetic expression. Casting an enumeration of subtype to a supertype, the position can be unchanged or increase. The change 
-of position is an @offset@.  
+When a cast or implicit conversion moves an enumeration from subtype to supertype, the position can be unchanged or increase.
+\CFA determines the position offset with an \newterm{offset calculation} function.
 
 \begin{figure}
@@ -301,14 +306,14 @@
 pair<bool, int> calculateEnumOffset(CFAEnum src, CFAEnum dst) {
 	int offset = 0;
-	if (src == dst) return make_pair(true, 0);
-	for (auto v : dst.members) {
-		if (holds_alternative<Enumerator>(v)) {
+	if ( src == dst ) return make_pair(true, 0);
+	for ( auto v : dst.members ) {
+		if ( holds_alternative<Enumerator>(v) ) {
 			offset++;
 		} else {
 			auto m = get<CFAEnum>(v);
-			if (m == src) return make_pair(true, offset);
-			auto dist = calculateEnumOffset(src, m);
-			if (dist.first) {
-				return make_pair(true, offset + dist.second);
+			if ( m == src ) @return@ make_pair( true, offset );
+			auto dist = calculateEnumOffset( src, m );
+			if ( dist.first ) {
+				@return@ make_pair( true, offset + dist.second );
 			} else {
 				offset += dist.second;
@@ -316,5 +321,5 @@
 		}
 	}
-	return make_pair(false, offset);
+	@return@ make_pair( false, offset );
 }
 \end{cfa}
@@ -323,17 +328,16 @@
 \end{figure}
 
-Figure~\ref{s:OffsetSubtypeSuperType} shows a minimum of @offset calculation@, written in \CC. CFAEnum represents \CFA enumeration 
-which has a vector of variants of Enumerator or CFAEnum. Two CFAEnums are differentiable by their unquie name.
-The algorithm takes two CFAEnums as parameters @src@ and @dst@, with @src@ being type of expression the conversion applies on, 
-and @dst@ being type that the expression cast into. The algorithm returns a pair of value: when @src@ is convertible to @dst@ (@src@ is a subtype of @dst@),
-it returns boolean true and the offset. Otherwise, it returns false and the size of @src@ (total number of enumerators in @src@). The offset between a type and itself is defined 
-as 0. 
-
-The algorithm iterates over members in @dst@ to find @src@. If a member is an enumerator of @dst@, the positions of all subsequent members
-increment by one. If the current member is @dst@, the function returns true indicating "found" and the accumulated offset. Otherwise, the algorithm recurse 
-into the current CFAEnum @m@ and find out if the @src@ is convertible to @m@. The @src@ being convertible to the current member @m@ means @src@ 
-is a "subtype of subtype" of @dst@. The offset between @src@ and @dst@ is the sum of the offset of @m@ in @dst@ and the offset of 
-@src@ in @m@. If @src@ is not a subtype of @m@, the loop continue but with offset shifted by the size of @m@. The procedure reaches the end 
-of the loop proves @src@ is not convertible to @dst@. It returns size of @src@ in case it is in a recurse innvocation and size is needed for offset update. 
+Figure~\ref{s:OffsetSubtypeSuperType} shows an outline of the offset calculation in \CC.
+Structure @CFAEnum@ represents the \CFA enumeration with a vector of variants of @CFAEnum@ or @Enumerator@.
+The algorithm takes two @CFAEnums@ parameters, @src@ and @dst@, with @src@ being the type of expression the conversion applies to, and @dst@ being the type the expression is cast to.
+The algorithm iterates over the members in @dst@ to find @src@.
+If a member is an enumerator of @dst@, the positions of all subsequent members is increment by one.
+If the current member is @dst@, the function returns true indicating \emph{found} and the accumulated offset.
+Otherwise, the algorithm recurses into the current @CFAEnum@ @m@ to check if its @src@ is convertible to @m@.
+If @src@ is convertible to the current member @m@, this means @src@ is a subtype-of-subtype of @dst@.
+The offset between @src@ and @dst@ is the sum of the offset of @m@ in @dst@ and the offset of @src@ in @m@.
+If @src@ is not a subtype of @m@, the loop continues but with the offset shifted by the size of @m@.
+If the loop ends, than @src@ is not convertible to @dst@, and false is returned.
+
 
 \section{Control Structures}
