Index: /reasoner/reasoner.tex
===================================================================
--- /reasoner/reasoner.tex	(revision 70)
+++ /reasoner/reasoner.tex	(revision 71)
@@ -317,5 +317,5 @@
   \SetAlgoLined
   \KwIn{project $p$}
-  \KwData{constraint $base$, constraint base copy $base_c$, variable mapping $\variableMapping$, relevant constraints $\relevantConstraints$, incremental mode flag $inc$}
+  \KwData{constraint $base$, constraint base copy $base_c$, variable mapping $\variableMapping$, relevant constraints $\relevantConstraints$, incremental mode flag $inc$, eval-blocks flag $inEval$}
 
    \If{$base_c = \undef \vee |base_c| = 0$} {
@@ -329,5 +329,7 @@
         $translateAnnotationAssignments(a, \undef, \undef, \undef)$\; \label{algTranslateConstraintsTopLevelAnnotationAssignments}
      } \label{algTranslateConstraintsTranslationEnd}
+     $inEvals \assng true$\;
      $add(\topLevelConstraints,\seqWith{constraints(e)}{e\in evals(p)}\TBD{Priority?}$\;\label{algTranslateConstraintsTopLevelEvals}
+     $inEvals \assng false$\;
      \tcp{end of model visitor}%<ConstraintTranslationVisitor
     $base \assng base \addSeq \defaultConstraints \addSeq \deferredDefaultConstraints \addSeq \topLevelConstraints \addSeq \otherConstraints$\; \label{algTranslateConstraintsCompose}
@@ -343,5 +345,5 @@
 \end{algorithm}
 
-Then, the algorithm identifies and translates the constraints in the respective project\footnote{The top-translation steps in this algorithm are realized in the implementation by an IVML model visitor implicitly identifying and handling the types without iterating over the project multiple times as the notation here might suggest.}. To separate and prioritize the constraints, the reasoner uses several global sets, which are populated independently during the constraint translation and, in Algorithm ref \ref{algTranslateConstraints} added to the constraint base. In more details, the reasoner maintains the following temporary constraint sets 
+Then, the algorithm identifies and translates the constraints in the respective project\footnote{The top-translation steps in this algorithm are realized in the implementation by an IVML model visitor implicitly identifying and handling the types without iterating over the project multiple times as the notation here might suggest.}. To separate and prioritize the constraints, the reasoner uses several global sets, which are populated independently during the constraint translation and, in Algorithm \ref{algTranslateConstraints} added to the constraint base. In more details, the reasoner maintains the following temporary constraint sets 
 
 \begin{enumerate}
@@ -352,5 +354,5 @@
 \end{enumerate}
 
-These constraint sets are filled through the top-level calls in line \ref{algTranslateConstraintsTranslationStart}-\ref{algTranslateConstraintsTranslationEnd} including subsequent calls, prioritizing the project contents over the eval-blocks \cite{IVML-LS}. Please note that adding constraints to a constraint set (currently) requires filtering out unneeded constraints as well as indexing used variables. This is done by the $add$ function (e.g., in line \ref{algTranslateConstraintsAdd}), which we will detail below in Section \ref{sectTranslation}. According to the priority of the constraint sets introduced above, Algorithm \ref{algTranslateConstraints} composes the constraint base (keeping remaining constraints from prior project evaluations of the same configuration) in line \ref{algTranslateConstraintsCompose}. Finally, Algorithm \ref{algTranslateConstraints} clears the temporary constraint sets in lines \ref{algTranslateConstraintsClearSetsStart}-\ref{algTranslateConstraintsClearSetsEnd} and copies the constraint $base$ in the first run of the incremental reasoning mode with re-used constraint base.
+These constraint sets are filled through the top-level calls in line \ref{algTranslateConstraintsTranslationStart}-\ref{algTranslateConstraintsTranslationEnd} including subsequent calls, prioritizing eval-blocks \cite{IVML-LS}. Please note that adding constraints to a constraint set (currently) requires filtering out unneeded constraints as well as indexing used variables. This is done by the $add$ function (e.g., in line \ref{algTranslateConstraintsAdd}), which we will detail below in Section \ref{sectTranslation}. This algorithm also takes into account the $inEval$ flag prioritizing eval-block contents. According to the priority of the constraint sets introduced above, Algorithm \ref{algTranslateConstraints} composes the constraint base (keeping remaining constraints from prior project evaluations of the same configuration) in line \ref{algTranslateConstraintsCompose}. Finally, Algorithm \ref{algTranslateConstraints} clears the temporary constraint sets in lines \ref{algTranslateConstraintsClearSetsStart}-\ref{algTranslateConstraintsClearSetsEnd} and copies the constraint $base$ in the first run of the incremental reasoning mode with re-used constraint base.
 
 \subsection{Top-level Constraints Evaluation}\label{sectTopLevelConstraintsEvaluation}
@@ -450,5 +452,5 @@
             $translateCompoundDeclaration(d, v, ca, t)$\; \label{algTranslateDeclarationTranslateCompound}
        } \uElseIf{$ isContainer(type(d)) $}{ \label{algTranslateDeclarationHasDefault}
-            $translateContainerDeclaration(d, v, t)$\; \label{algTranslateDeclarationTranslateContainer}
+            $translateContainerDeclaration(d, v, ca, t)$\; \label{algTranslateDeclarationTranslateContainer}
        } \uElseIf{$dflt \neq \undef \wedge \neg inc$}{
           \lIf{$ca \neq \undef$}{$s \assng ca$} \label{algTranslateDeclarationTranslateInCompound}
@@ -500,8 +502,7 @@
 \item Creation and registration of access expressions to all slots and attributes so that cross references can be implicitly resolved during variable substitution applied to all default value expressions and constraints.
 \item Translating all slot declarations and attributes using Algorithm \ref{algTranslateDeclaration}.
-\item Special treatment of (constraint) container default values to $\otherConstraints$ as these constraints can be treated as usual constraints.
-\item Translating all nested eval blocks to $\otherConstraints$ before further constraints to take their priority into account.
-\item Translating all nested annotation assignment blocks $\otherConstraints$ as assignment and contained constraints represent usual constraints.
-\item Translating all compound constraints to $\otherConstraints$ as these constraints can be treated as usual constraints.
+\item Translating all nested annotation assignment blocks $\otherConstraints$ as value assignment constraints (if not in incremental mode).
+\item Translating all nested eval blocks to $\otherConstraints$.
+\item Translating all compound related constraints to $\otherConstraints$.
 \end{enumerate} 
 
@@ -509,5 +510,4 @@
 
 Now, we can translate further nested values / structures or contained constraints involving the mapping. First, Algorithm \ref{algTranslateCompoundDeclaration} inspects all slots / attributes. If one slot is a container of constraints, it translates all (constraint) values into instantiated constraints by substituting \IVMLself{} with the actual declaration (including matching mappings in $\variableMapping$) adding the translated constraint to the set of other constraints $\otherConstraints$. 
-If the slot is a compound container, it translates all contained compound variables, calling constraints using Algorithm \ref{algTranslateCompoundContainer}. Then the algorithm adds all 
 
 \begin{algorithm}[H]
@@ -523,13 +523,4 @@
       $translateDeclaration(s, decision(v, s), c)$\; \label{algTranslateCompoundDeclarationTranslateSlots}
   }
-  \ForAll{$s \iterAssng slots(v)$} { %actual slots
-      \uIf{$isConstraintContainer(type(s))$} {
-          $add(\otherConstraints, \setWith{\createConstraint{\varSubstitutionSelfVarMapping{value(e)}{d}}}{e \in elements(value(s))}, true)$\;
-      }\ElseIf{$isContainer(type(s))$} {
-         $add(\otherConstraints, translateCompoundContainer(s, v, \variableMapping[s]), true)$\;
-     }
-  }
-  \leIf{$ca \neq \undef$}{$f\assng ca$}{$f\assng d$}
-  $add(\otherConstraints, \setWith{\createConstraint{\varSubstitutionSelfVarMapping{f}{c}}}{c\in \bigcup_{r\in allRefines^+(t)} allEvalConstraints(r)}, true)$\;
   \If{$\neg inc$} {
       \ForAll{$a \iterAssng assignments(t)$}{
@@ -537,4 +528,6 @@
       }
   }
+  \leIf{$ca \neq \undef$}{$f\assng ca$}{$f\assng d$}
+  $add(\otherConstraints, \setWith{\createConstraint{\varSubstitutionSelfVarMapping{f}{c}}}{c\in \bigcup_{r\in allRefines^+(t)} allEvalConstraints(r)}, true)$\;
   $add(\otherConstraints, \setWith{\createConstraint{\varSubstitutionSelfVarMapping{c}{f}}}{c\in allCompoundConstraints(t, false)}, true)$\;
 
@@ -542,7 +535,9 @@
 \end{algorithm}
 
-Finally, the algorithm translates all attribute assignments using Algorithm \ref{algTranslateAnnotationAssignments}, all direct compound constraints (substituting \IVMLself{} and registered variables), and translates and collects all eval constraints (\TBD{no self??}).
-
-We define now the specific helper functions used in Algorithm \ref{algTranslateCompoundDeclaration}.
+Finally, the algorithm translates the nested structures. Then it translates all annotation value assignments using Algorithm \ref{algTranslateAnnotationAssignments}. For the last two translations, we need the actual value of \IVMLself{}, to be determined for the recent compound, either based on the given accessor $ca$ or the declaration $d$. Then, to keep the priority of eval-blocks, it collects all constraints of all nested eval-blocks, replaces \IVMLself{} and variable mappings $\variableMapping$ and adds them to $\otherConstraints$. Finally, we take over and translate all constraints of all transitively declared constraints refined compounds, constraint variables, and assignment constraints.
+
+Algorithm \ref{algTranslateCompoundDeclaration} uses various functions, which we define for completeness below.
+
+\MISSING{---HERE---}
 
 %Expressions may be simple variables, calculations or operation calls, in compounds also using the predefined variable \texttt{self} indicating the actual instance of the respective compound. These constraints must be evaluated upon each variable instance, i.e., for top-level basic variables, top-level compound variables, compound values within compounds as well as compound values within container initialiers, each potentially with a different access expression to make the variable unique. 
@@ -579,7 +574,8 @@
 Algorithm \ref{algTranslateCompoundDeclaration} translates the default constraints for a compound variable $v$ with declaration $d$, potential compound accessor $ca$ and (default value) type (or $type(d)$ if no default expression is defined for $d$). The types are related by $type(d) = type(v) \in allRefines^+(t)$. 
 
-\subsection{Container default constraints}\label{sectContainerDefaults}
+\subsection{Container constraints}\label{sectContainerDefaults}
 
 Constraints defined on types that are implicitly instantiated within a container must be turned into individual constraints with proper access (all-quantification) and stored in the constraint base. This holds only for compound instances, but not for compound references as the reference targets are already instantiated variables. Algorithm \ref{algTranslateDefaultsCompoundContainer} performs this transformation for a variable declaration $d$ and a specific type $t$ used within the default value expression of $d$. For all slots $s$ of $t$ and its refined compounds, the algorithm creates a new default constraint. If $d$ is nested, $d$ must first be flattened (can be omitted $d$ is not a nested container). Then, all elements not complying with $d$ must be filtered out so that the remaining expression can be applied to the specific slots of type $t$ (the type selection can be omitted if $t=type(d)$). Then, an all-quantification over all elements of type $t$ of the container using the iterator variable $i$ applies an assignment expression to the respective slot $s$, assigning to $i.s$ the default value expression of $s$ with \IVMLself{} substituted by the iterator variable $i$.
+If the slot is a constraint container, it translates all contained constraints performing the usual variable substutions.
 
 \begin{algorithm}[H]
@@ -594,7 +590,10 @@
                }
            }
-      $add(\otherConstraints, translateCompoundContainer(d, v, \undef), true)$\;
-      \If{$isContainer(t) \wedge isDerived(contained(t))$}{
+      $add(\otherConstraints, translateCompoundContainer(d, v, ca), true)$\;
+      \uIf{$isContainer(t) \wedge isDerived(contained(t))$}{
           $translateDerivedDatatypeConstraints(contained(t), d)$\;
+      }
+      \uIf{$isConstraintContainer(type(s))$} {
+          $add(\otherConstraints, \setWith{\createConstraint{\varSubstitutionSelfVarMapping{value(v)}{ca}}}{e \in elements(value(s))}, true)$\;
       }
  \caption{Translating declaration default value expressions to constraints (\IVML{translateContainerDeclaration}).}\label{algTranslateContainerDeclaration}
@@ -750,5 +749,5 @@
 \begin{algorithm}[H]
   \KwIn{constraint sequence $s$, constraint $c$, perform initializers $check$}
-  \KwData{variable mapping $\variableMapping$, relevant constraints $\relevantConstraints$ , incremental $inc$}
+  \KwData{top level and other constraints $\topLevelConstraints, \otherConstraints$, variable mapping $\variableMapping$, relevant constraints $\relevantConstraints$ , incremental flag $inc$, evals flag $inEvals$}
   \If{$\neg inc \vee (inc \wedge \neg isAssignment(c))$} {
     \If{$check$}{
@@ -759,5 +758,9 @@
       }
     }
-    $s \assng s \addSeq c$\;
+    \If{$inEvals \wedge (s=\otherConstraints \vee s = \topLevelConstraints)$} {
+       $\topLevelConstraints = c \addSeq \topLevelConstraints$\;
+    }\Else{
+       $s \assng s \addSeq c$\;
+    }
     \If{$\neg isSimpleConstraint(c)$}{
       $\relevantConstraints \assng \relevantConstraints \cup \setWith{\mapEntry{v}{c}}{v\in variables(c)}$\; % assignConstraintsToVariables
