anchor.diff:    | Some x -> f x
     | None -> d
   
  +(* We memoize the normal form of variables in the environment, in
  + * order to implement call-by-need and avoid an exponential explosion,
  + * but we take care to only reuse memoized values when the cfg has not
  + * changed. The main reason is normalization requests, which can "grow"
  + * the set of allowed computations steps, and hence we may memoize
  + * something during the request that is used outside of it. This will
  + * essentially make it invalid. See issue #2155 in Github.
  + *
  + * We compare the cfg with physical equality, so it has to be the
  + * exact same object in memory. See read_memo and set_memo below. *)
  +type cfg_memo<'a> = memo<(Cfg.cfg * 'a)>
  +
   type closure =
  -  | Clos of env * term * memo<(env * term)> * bool //memo for lazy evaluation; bool marks whether or not this is a fixpoint
  +  | Clos of env * term * cfg_memo<(env * term)> * bool //memo for lazy evaluation; bool marks whether or not this is a fixpoint
     | Univ of universe                               //universe terms do not have free variables
     | Dummy                                          //Dummy is a placeholder for a binder when doing strong reduction
   and env = list<(option<binder>*closure)>
  
positive.code:                    let stack =
                       stack |>
                       List.fold_right (fun (a, aq) stack ->
                         Arg (Clos(env, a, BU.mk_ref (Some ([], a)), false),aq,t.pos)::stack)
                       norm_args
                     in
                     log cfg  (fun () -> BU.print1 "\tPushed %s arguments\n" (string_of_int <| List.length args));
  
negative.code: 
  let head_of t = let hd, _ = U.head_and_args' t in hd
  
  let read_memo cfg (r:memo<(Cfg.cfg * 'a)>) : option<'a> =
    match !r with
    | Some (cfg', a) when BU.physical_equality cfg cfg' ->
      Some a
    | _ -> None
  
  let set_memo cfg (r:memo<(Cfg.cfg * 'a)>) (t:'a) : unit =
    if cfg.memoize_lazy then begin
      (* We do this only as a sanity check. The only situation where we
       * should set a memo again is when the cfg has changed. *)
      if Option.isSome (read_memo cfg r) then
        failwith "Unexpected set_memo: thunk already evaluated";
      r := Some (cfg, t)
    end
  
  let closure_to_string = function
      | Clos (env, t, _, _) -> BU.format2 "(env=%s elts; %s)" (List.length env |> string_of_int) (Print.term_to_string t)
  