anchor.diff:  %%% Internal functions
   %%%===================================================================
   
  -%% @doc Generate advertisements and advertisement contracts.
  +%% @private
   create_ads_and_contracts(Ads, Contracts) ->
       AdIds = lists:map(fun(_) ->
                                 {ok, Unique} = lasp_unique:unique(),
  
positive.code:     %% Generate actor identifier.
      Actor = self(),
  
      %% For each identifier, generate a contract.
      {ok, {Contracts, _, _, _}} = lasp:declare(?SET_TYPE),
  
      %% Generate Rovio's advertisements.
      {ok, {RovioAds, _, _, _}} = lasp:declare(?SET_TYPE),
      _RovioAdList = create_ads_and_contracts(RovioAds, Contracts),
  
      %% Generate Riot's advertisements.
      {ok, {RiotAds, _, _, _}} = lasp:declare(?SET_TYPE),
      _RiotAdList = create_ads_and_contracts(RiotAds, Contracts),
  
      %% Union ads.
      {ok, {Ads, _, _, _}} = lasp:declare(?SET_TYPE),
      ok = lasp:union(RovioAds, RiotAds, Ads),
  
      %% Compute the Cartesian product of both ads and contracts.
      {ok, {AdsContracts, _, _, _}} = lasp:declare(?SET_TYPE),
      ok = lasp:product(Ads, Contracts, AdsContracts),
  
      %% Filter items by join on item it.
      {ok, {AdsWithContracts, _, _, _}} = lasp:declare(?ADS_WITH_CONTRACTS, ?SET_TYPE),
      FilterFun = fun({#ad{id=Id1}, #contract{id=Id2}}) ->
          Id1 =:= Id2
      end,
      ok = lasp:filter(AdsContracts, FilterFun, AdsWithContracts),
  
      {ok, #state{actor=Actor}}.
  
  %% @private
  -spec handle_call(term(), {pid(), term()}, #state{}) ->
  
negative.code: 
  %% @private
  -spec handle_info(term(), #state{}) -> {noreply, #state{}}.
  handle_info(log, #state{ads=Ads}=State) ->
      %% Print number of enabled ads.
      {ok, AdList} = lasp:query(Ads),
      Size = sets:size(AdList),
  
      lager:info("Enabled advertisements: ~p", [Size]),
  
      %% Schedule advertisement counter impression.
      schedule_logging(),
  
      {noreply, State};
  handle_info(Msg, State) ->
      lager:warning("Unhandled messages: ~p", [Msg]),
      {noreply, State}.
  