anchor.diff:  %%-------------------------------------------------------------------------------------
   %% Internal - Helpers for transforming abstractions and applications
   %%-------------------------------------------------------------------------------------
  -transform1_frozen_dims(Is, P, HD, HV) ->
  -  Ns = lists:seq(1, length(Is)), %% 1,2,...
  +transform1_frozen_dims(Is, Ps, HD, HV) ->
     tset:union(
       tset:union(HD, HV),
  -    [transform1(I, subexpr_pos(N,P), HD, HV) || {I, N} <- lists:zip(Is, Ns)]).
  -
  -transform1_actual_params(Eis, P, HD, HV) ->
  -  Ns = lists:seq(1, length(Eis)), %% 1,2,...
  -  lists:map(
  -    fun({Ei, N}) ->
  -        transform1(Ei, subexpr_pos(N,P), HD, HV) %% Pos 1,2,...
  -    end,
  -    lists:zip(Eis, Ns)).
  +    [transform1(I, P, HD, HV) || {I, P} <- lists:zip(Is, Ps)]).
  +
  +transform1_actual_params(Eis, Ps, HD, HV) ->
  +  lists:map(fun({Ei, P}) -> transform1(Ei, P, HD, HV) end, lists:zip(Eis, Ps)).
   
   
   %%-------------------------------------------------------------------------------------
  
positive.code: %% Dimensional Query
  %%------------------------------------------------------------------------------
  transform1({'#', E0}, P, HD, HV) ->
    {'#', transform1(E0, P, HD, HV)};
  
  %%------------------------------------------------------------------------------
  %% Base Abstraction
  %%------------------------------------------------------------------------------
  transform1({b_abs, Is, Params, E}, P, HD, HV) ->
    ParamsAsDims = lists:map(fun(Param) -> {phi, Param} end, Params),
    {b_abs, transform1_frozen_dims(Is, P, HD, HV),
     ParamsAsDims,
     transform1(E, subexpr_pos(0,P), HD, tset:union(HV, ParamsAsDims))};
  
  transform1({b_apply, E0, Eis}, P, HD, HV) ->
    {b_apply, transform1(E0, subexpr_pos(0,P), HD, HV),
     transform1_actual_params(Eis, P, HD, HV)};
  
  %%------------------------------------------------------------------------------
  %% Value Abstraction
  %%------------------------------------------------------------------------------
  transform1({v_abs, Is, Params, E}, P, HD, HV) ->
    ParamsAsDims = lists:map(fun(Param) -> {phi, Param} end, Params),
    {v_abs, transform1_frozen_dims(Is, P, HD, HV),
     ParamsAsDims,
     transform1(E, subexpr_pos(0,P), HD, tset:union(HV, ParamsAsDims))};
  
  transform1({v_apply, E0, Eis}, P, HD, HV) ->
    {v_apply, transform1(E0, subexpr_pos(0,P), HD, HV),
     transform1_actual_params(Eis, P, HD, HV)};
  
  %%------------------------------------------------------------------------------
  %% Intension Abstraction
  %%------------------------------------------------------------------------------
  transform1({i_abs, Is, E}, P, HD, HV) ->
    {i_abs, transform1_frozen_dims(Is, P, HD, HV),
     transform1(E, subexpr_pos(0,P), HD, HV)};
  
  transform1({i_apply, E}, P, HD, HV) ->
    {i_apply, transform1(E, subexpr_pos(0,P), HD, HV)}; %% XXX Need for subexpression???
  
  %%------------------------------------------------------------------------------
  %% Wherevar
  
negative.code:   NewXiEis =
      [{Xi, transform1(Ei, subexpr_pos(N,P), HD, HV)} %% Pos 1,2,...
       || {{Xi, Ei}, N} <- lists:zip(XiEis, Ns)],
    %% XXX The way position is assigned here is completely different
    %% from literature.
    {wherevar, transform1(E0, subexpr_pos(0,P), HD, HV),
     NewXiEis};
  
  