Index: /reasoner/reasoner.tex
===================================================================
--- /reasoner/reasoner.tex	(revision 106)
+++ /reasoner/reasoner.tex	(revision 107)
@@ -583,13 +583,12 @@
           \uIf{$isConstraint(type(d))$}{ \label{algTranslateDeclarationTranslateConstraintDefaultStart}
               $createConstraintVariableConstraint(dflt, s, v)$\; \label{algTranslateDeclarationConstraintVariableConstraint}
-          }\Else{  \label{algTranslateDeclarationTranslateConstraintDefaultEnd}
-              \uIf{$isAnnotation(v)$}{
-                  $ac\assng \closedCases{\IVMLMeta{acc}(d,a), & \text{if } ca = \undef \\ \IVMLMeta{acc}(ca,a), &\text{else}}$\;\label{algTranslateDeclarationTranslateAnnotationAccess}
-              }\uElse{
-                  $ac \assng \closedCases{ca, & \text{if } f = ca \\ d, &\text{else}}$\; \label{algTranslateDeclarationTranslateUsualAccess} \label{algTranslateDeclarationTranslateSelf2}
-              }
-             \lIf{$\IVMLself{} \in dflt \vee isOverridenSlot(d)$}{$dfltS \assng \deferredDefaultConstraints$}\lElse{$dfltS \assng \defaultConstraints$} \label{algTranslateDeclarationTranslateSelf3}
-              $add(dfltS, \createDefaultConstraint{\varSubstitutionSelfVarMapping{\IVML{assign}(ac, dflt)}{f}})$\; \label{algTranslateDeclarationTranslateDefault}
-          }
+          }\label{algTranslateDeclarationTranslateConstraintDefaultEnd}
+          \uIf{$isAnnotation(v)$}{
+               $ac\assng \closedCases{\IVMLMeta{acc}(d,a), & \text{if } ca = \undef \\ \IVMLMeta{acc}(ca,a), &\text{else}}$\;\label{algTranslateDeclarationTranslateAnnotationAccess}
+           }\uElse{
+              $ac \assng \closedCases{ca, & \text{if } f = ca \\ d, &\text{else}}$\; \label{algTranslateDeclarationTranslateUsualAccess} \label{algTranslateDeclarationTranslateSelf2}
+           }
+          \lIf{$\IVMLself{} \in dflt \vee isOverridenSlot(d)$}{$dfltS \assng \deferredDefaultConstraints$}\lElse{$dfltS \assng \defaultConstraints$} \label{algTranslateDeclarationTranslateSelf3}
+          $add(dfltS, \createDefaultConstraint{\varSubstitutionSelfVarMapping{\IVML{assign}(ac, dflt)}{f}})$\; \label{algTranslateDeclarationTranslateDefault}
       }
  \caption{Translating declarations (\IVML{translateDeclaration}).}\label{algTranslateDeclaration}
@@ -598,5 +597,5 @@
 If $t$ is a compound type, we set the value of self $v$ to the actual variable declaration $d$ and execute the specific translations for compound types using Algorithm \ref{algTranslateCompoundDeclaration}. If $t$ is a container type, we call \ref{algTranslateContainerDeclaration} instead. Otherwise, if there is a default value expression and reasoning is not in incremental mode, i.e., we shall translate default value expressions to assignment constraints, and if there is a compound accessor, we just have to schedule a replacement of \IVML{self} by the compound accessor. Remaining default constraints are taken over as defined as long as the reasoner is not operating incremental mode as there no default value assignments are needed.
 
-If there is finally a default value expression to be recorded in the constraint base and $d$ is not an attribute used within an assignment block (this may otherwise collide with default values defined by the assignment block), we have to distinguish whether the actual variable is a constraint variable or an usual variable. In the first case, we apply Algorithm \ref{algCreateConstraintVariableConstraint} (cf. Section \ref{sectConstraintVariables}). In the second case, we turn the default value expression into an assignment expression. However, the accessor creation depends on whether $d$ is an annotation or an usual variable. Then, we substitute \IVML{self} and the actual variable mapping on the complete constraint expression and turn the result into a default constraint. We either either it to $\deferredDefaultConstraints$ if the constraint may override a complete value assignment (\IVML{self} is used referring to another variable in the same compound or $d$ is an overridden slot that may accidentally be overriden by a complex compound value) or in all other cases to the usual default constraints set $\defaultConstraints$.
+If there is finally a default value expression to be recorded in the constraint base and $d$ is not an attribute used within an assignment block (this may otherwise collide with default values defined by the assignment block), we have to check whether the actual variable is a constraint variable or an usual variable. If the variable is a constraint variable, we apply Algorithm \ref{algCreateConstraintVariableConstraint} (cf. Section \ref{sectConstraintVariables}) to create an evaluatable constraint from $dflt$. In any case, we turn the default value expression into an assignment expression. However, the accessor creation depends on whether $d$ is an annotation or an usual variable. Then, we substitute \IVML{self} and the actual variable mapping on the complete constraint expression and turn the result into a default constraint. We either either it to $\deferredDefaultConstraints$ if the constraint may override a complete value assignment (\IVML{self} is used referring to another variable in the same compound or $d$ is an overridden slot that may accidentally be overriden by a complex compound value) or in all other cases to the usual default constraints set $\defaultConstraints$.
 
 \subsection{Derived types}\label{sectDerivedTypes}
@@ -811,5 +810,5 @@
       $pushContext(\variableMapping, \undef, e, l, true)$\;
       $registerCompoundMapping(t, l, d, t)$\; \label{algTranslateDefaultsCompoundContainerMapping}
-      $translateCompoundContent(l, \undef, t, ca)$\; \label{algTranslateDefaultsCompoundContainerContent}
+      $translateCompoundContent(l, \undef, t, \closedCases{\undef, & \text{if } ca = \undef\\l & \text{else}})$\; \label{algTranslateDefaultsCompoundContainerContent}
       $popContext()$\;
     }
@@ -819,5 +818,5 @@
 Algorithm \ref{algTranslateCompoundContainer} targets this by creating all-quantized constraints over all elements of the container, mostly be reusing Algorithm \ref{algRegisterCompoundMapping} to create a compound mapping and Algorithm \ref{algTranslateCompoundContent} to translate the compound content. Initially, we a local variable $l$ as later iterator variable for the quantifier expressions. Then, we create a prefix expression $e$ of the quantor constraint expression, i.e., we determine in line \ref{algTranslateDefaultsCompoundContainerInitE} the access expression to the collection either using $ca$ or just holding the variable of the container $d$. If the container is a sequence that may contain duplicates, we first turn it into a set to avoid accidentally duplicated constraints (line \ref{algTranslateDefaultsCompoundContainerFlatten}). If the container is nested, we flatten it in line \ref{algTranslateDefaultsCompoundContainerFlatten} as constraints only need to be created for the elements (no specific constraints can be attached to a container type except for derived values, which are handled by Algorithm \ref{algTranslateDeclaration}). If the actual type $t$ is not the same as the type of the declaration $u)$, we must consider that the slot $s$ only exists for the specific refined type $t$. Then, the instantiation shall apply only to container elements of type $t$ (or of refined types), i.e., we insert in line \ref{algTranslateDefaultsCompoundContainerCast} an element selection by projecting the container to all elements of type $t$ (and refined types). 
 
-Now we create a context for the container on the stack of $\variableMapping$. In contrast to compound translations, we also register the prefix expression $e$ and the iterator variable $l$. This will be taken up by the $add$ operation, which completes the full constraint from the given information on the stack, i.e., the full creation of the constraint is prepared but not shown in Algorithm \ref{algRegisterCompoundMapping}. As for compounds, we create now the compound mapping using Algorithm \ref{algTranslateCompoundContent}. Please note that slot access now happens via the iterator variable $l$, while annotation access happens through $ca$. Specifying $t$ also as target type avoids unnecessary type casts here. Then, we call Algorithm \ref{algTranslateCompoundContent} to translate the compound slots, implying translation of annotations as well as recursion over further compounds and containers. 
+Now we create a context for the container on the stack of $\variableMapping$. In contrast to compound translations, we also register the prefix expression $e$ and the iterator variable $l$. This will be taken up by the $add$ operation, which completes the full constraint from the given information on the stack, i.e., the full creation of the constraint is prepared but not shown in Algorithm \ref{algRegisterCompoundMapping}. As for compounds, we create now the compound mapping using Algorithm \ref{algRegisterCompoundMapping}. Please note that slot access now happens via the iterator variable $l$, while annotation access happens through $ca$. Specifying $t$ also as target type avoids unnecessary type casts here. Then, we call Algorithm \ref{algTranslateCompoundContent} to translate the compound slots, implying translation of annotations as well as recursion over further compounds and containers. Thereby, we replace a given access expression by the iterator variable $l$ or leave the access undefined as it is implicity given in and used from the actual context.
 
 By storing constraint information on the stack of $\variableMapping$ and assembling the information in one place, we can even handle recursive compound containers, which leads to a recursive creation of constraints. The formula below indicates the constraint that we must create in case of a compound container nested into a compound container. 
@@ -1082,5 +1081,5 @@
 Constraint & 2, 3 & \tabAlgLine{algTranslateConstraints}{algTranslateConstraintsTopLevelConstraints} & B2, ...\\
 
-Constraint variable & 3.1.10 & \tabAlgLine{algTranslateConstraints}{algTranslateConstraintsTranslationDeclaration}\tabAlgFollow\tabAlgLines{algTranslateDeclaration}{algTranslateDeclarationTranslateConstraintDefaultStart}{algTranslateDeclarationTranslateConstraintDefaultEnd} \TBD{change} & Cs1, Cs2 \\
+Constraint variable & 3.1.10 & \tabAlgLine{algTranslateConstraints}{algTranslateConstraintsTranslationDeclaration}\tabAlgFollow\tabAlgLines{algTranslateDeclaration}{algTranslateDeclarationTranslateConstraintDefaultStart}{algTranslateDeclarationTranslateConstraintDefaultEnd}, change \tabAlg{algVarChange}\TBD{addLine} & Cs1, Cs2, CsCtCn1 \\
 
 Annotation & 2.2.2 & \tabAlgLine{algTranslateConstraints}{algTranslateConstraintsTranslationDeclaration}\tabAlgFollow\tabAlgLine{algTranslateDeclaration}{algTranslateDeclarationAnnotationDefault}\tabAlgFollow\tabAlgLine{algTranslateAnnotationDeclarations}{algTranslateAnnotationDeclarationsTranslateDeclV} or \tabAlgLine{algTranslateAnnotationDeclarations}{algTranslateAnnotationDeclarationsTranslateDeclD} \tabAlgFollow Table \ref{tab:completenessAnnotations} & A1, A2, A3\\
@@ -1154,5 +1153,5 @@
 Container type & 2.1.3.3 & \tabAlgLines{algTranslateCompoundContent}{algTranslateCompoundDeclarationTranslateSlotsStart}{algTranslateCompoundDeclarationTranslateSlotsEnd}\tabAlgFollow\tabAlgLine{algTranslateDeclaration}{algTranslateDeclarationTranslateContainer}\tabAlgFollow Table \ref{tab:completenessContainers} & CnCt3, CnCt4 \\
 
-Constraint type & 3.10.1 & \tabAlgLines{algTranslateCompoundContent}{algTranslateCompoundDeclarationTranslateSlotsStart}{algTranslateCompoundDeclarationTranslateSlotsEnd}\tabAlgFollow\tabAlgLines{algTranslateDeclaration}{algTranslateDeclarationTranslateConstraintDefaultStart}{algTranslateDeclarationTranslateConstraintDefaultEnd} & CsCn1, CsCn2 \\
+Constraint type & 3.10.1 & \tabAlgLines{algTranslateCompoundContent}{algTranslateCompoundDeclarationTranslateSlotsStart}{algTranslateCompoundDeclarationTranslateSlotsEnd}\tabAlgFollow\tabAlgLines{algTranslateDeclaration}{algTranslateDeclarationTranslateConstraintDefaultStart}{algTranslateDeclarationTranslateConstraintDefaultEnd}, change \tabAlg{algVarChange}\TBD{addLine} & CsCn1, CsCn2, CsCtCn1 \\
 
 Constraints & & \tabAlgLines{algTranslateCompoundDeclaration}{algTranslateCompoundDeclarationAllStart}{algTranslateCompoundDeclarationAllEnd}& Cn1 \\
@@ -1211,5 +1210,5 @@
 Reference type & 2.2.3.2 & no specific constraints, cf. Section \ref{sectNotationOthers} & CnFCt1, CnTFCt1 \\
 
-Constraint type & 3.1.10 & \tabAlgLine{algTranslateContainerDeclaration}{algTranslateContainerDeclarationConstraintContainer}\TBD{change}  & CnCt1, CnCt2 \\
+Constraint type & 3.1.10 & \tabAlgLine{algTranslateContainerDeclaration}{algTranslateContainerDeclarationConstraintContainer}, change \tabAlg{algVarChange}\TBD{addLine}  & CnCt1, CnCt2, CsCtCn1 \\
 
 Annotation & 2.2.2 & top-level only, see Table \ref{tab:completenessTopLevelTypes}  & TFCnCtCsA1 \\
@@ -1440,4 +1439,5 @@
 AFCn1 & \class{compounds/ReferenceCompoundAnnotationTest.ivml}\\
 ATCn1 & \class{compounds/DerivedCompoundAnnotationTest.ivml}\\
+CsCtCn1 & \class{compounds/CompoundConstraintTest.ivml}\\
 CnTCt1 & \class{collectionConstraints/constraintSetDerivedCompound.ivml}\\
 CnTCt2 & \class{collectionConstraints/constraintSetSetDerivedCompound.ivml}\\
