Index: /reasoner/reasoner.tex
===================================================================
--- /reasoner/reasoner.tex	(revision 56)
+++ /reasoner/reasoner.tex	(revision 57)
@@ -420,7 +420,7 @@
 Algorithm \ref{algTranslateDeclaration} translates all constraints related to a given variable declaration $d$ and respective variable $v$ through their actual type. Basically, the algorithm considers for the given variable, depending on the actual type, derived type constraints, annotation defaults, compound constraints, container constraints, and constraints of overridden slots leading to a deferred default initialization through the global constraints set $\deferredDefaultConstraints$.
 
-In more detail, Algorithm \ref{algTranslateDeclaration} first declares some local variables in line \ref{algTranslateDeclarationDecl}, including the actual type $t$ (to be overridden by the type of the default value expression if needed), the default value expression $dflt$, the actual set of default constraints ($\defaultConstraints$ or $\deferredDefaultConstraints$) to be utilized for adding the final constraint and the actual value of self $s$ (for compound types only). Then, if $t$ is a derived data type, constraints are translated and collected through Algorithm \ref{algTranslateDerivedDatatypeConstraints}. In non-incremental mode, i.e., we shall translate default value expressions to assignment constraints, the default constraints for annotations can then be translated using \ref{algTranslateAnnotationDefaults}. Due to potential type interactions, we determine now the actual type through the type of the default value expression if defined. 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 compound accessor, a default value expression and reasoning is not in incremental mode, i.e., we shall translate default value expressions to assignment constraints, we determine the target constraint set (deferred or not deferred) and translate the constraint to replace self by the compound accessor. Remaining default constraints are not translated in incremental mode.
-
-If there is finally a default value expression to be translated, we distinguish whether the actual variable is a constraint variable or another variable. In the first case, we jan cust add the constraint and there is no compound accessor, then we can add default value expression, which is actually a constraint, to the set of other constraints $\otherConstraints$ and register the relevant variables for the new constraint and the causing variable $v$. For all remaining default constraints, we create a value assignment, either for the compound accessor if given or $d$ with a value determined by the default value expression (having self and $\variableMapping$ substituted).
+In more detail, Algorithm \ref{algTranslateDeclaration} first declares some local variables in line \ref{algTranslateDeclarationDecl}, including the actual type $t$ (to be overridden by the type of the default value expression if needed), the default value expression $dflt$, the actual set of default constraints ($\defaultConstraints$ or $\deferredDefaultConstraints$) to be utilized for adding the final constraint and the actual value of self $s$ (for compound types only). Then, if $t$ is a derived data type, constraints are translated and collected through Algorithm \ref{algTranslateDerivedDatatypeConstraints}. In non-incremental mode, i.e., we translate default value expressions to assignment constraints as well as the default constraints for annotations can then be translated using \ref{algTranslateAnnotationDefaults}. Due to potential type interferences with derived types, we determine then the actual type through the type of the default value expression if defined. 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, we have to distinguish whether the actual variable is a usual or a constraint variable. In the first case, we turn the default value expression into an assignment expression, through the compound accessor if it currently represents \IVML{self}, the variable else. Then, we substitute \IVML{self} and the actual variable mapping on the default value expression. The actual variable is a constraint variable, we can just \TBD{ca??} turn the default value into a constraint, add it to the set of other constraints $\otherConstraints$ and register the relevant variables for the new constraint and the causing variable $v$. For usual variables, turn the already created value assignment expression in $dflt$ into a default constraint and add it either to $\deferredDefaultConstraints$ the constraint may override a complete value assignment (\IVML{self} is used or $d$ is an overridden slot) or to the usual default constraints set $\defaultConstraints$.
 
 \begin{algorithm}[H]
@@ -429,5 +429,5 @@
   \KwData{variable mapping $\variableMapping$, constraint variables $\otherConstraints$, default (deferred) constraints $\defaultConstraints$ and $\deferredDefaultConstraints$, relevant constraints $\relevantConstraints$, incremental $inc$}
   
-      $t \assng type(d)$; $dflt \assng default(d)$; $dfltS \assng \defaultConstraints$; $s \assng \undef$\; \label{algTranslateDeclarationDecl}
+      $t \assng type(d)$; $dflt \assng default(d)$; $s \assng \undef$\; \label{algTranslateDeclarationDecl}
       \lIf{$isDerived(t)$} {$translateDerivedDatatypeConstraints(d, t)$} \label{algTranslateDeclarationDerivedDatatype}
       \lIf{$\neg inc$} {
@@ -440,18 +440,20 @@
        } \uElseIf{$ isContainer(type(d)) $}{ \label{algTranslateDeclarationHasDefault}
             $translateContainerDeclaration(d, v, t)$\;
-       } \uElseIf{$ca \neq \undef$}{
-          \If{$dflt \neq \undef \wedge \neg inc$}{
-               \lIf{$\IVMLself{} \in deflt \vee isOverridenSlot(d)$}{$dfltS \assng \deferredDefaultConstraints$}
-               $dflt \assng \varSubstitutionSelfVarMapping{dflt}{ca}$ \TBD{double translation, s=ca}\;
-           }
+       } \uElseIf{$dflt \neq \undef \wedge \neg inc$}{
+          \lIf{$ca \neq \undef$}{$s \assng ca$}
       }\lElseIf{$inc$}{$ dflt \assng \undef $}
       \If{$ deflt \neq \undef $}{ 
+          \uIf{$\neg isConstraint(type(d))$}{
+              $dflt \assng \createExpression{\IVML{assign}(\closedCases{ca, & \text{if } s = ca \\ d, &\text{else}}, dflt)}$\; \label{algTranslateDeclarationTranslateDefault}
+          }
+          $dflt \assng \varSubstitutionSelfVarMapping{dflt}{s}$\;
           \uIf{$isConstraint(type(d))$}{
-              \If{$ ca == \undef $}{
-                  $add(\otherConstraints, \createConstraint{dflt}, true)$\TBD{Substitution here?}\;
+              \If{$ ca == \undef $ \TBD{really needed???}}{
+                  $add(\otherConstraints, \createConstraint{dflt}, true)$\;
                   $\relevantConstraints \assng \relevantConstraints \addMap \mapEntry{\createConstraint{dflt}}{v}$
                }
           }\Else{ 
-              $add(dfltS, \createDefaultConstraint{\IVML{assign}(\closedCases{ca, & \text{if } dfltS == \defaultConstraints \\ d, &\text{else}}, \varSubstitutionSelfVarMapping{dflt}{s})})$\; \label{algTranslateDeclarationTranslateDefault}
+             \lIf{$\IVMLself{} \in dflt \vee isOverridenSlot(d)$}{$dfltS \assng \deferredDefaultConstraints$}\lElse{$dfltS \assng \defaultConstraints$}
+              $add(dfltS, \createDefaultConstraint{dflt})$\; 
           }
       }
