anchor.diff:              let l1, r1 = Choice.get <| dest_comb tm1
               let l2, r2 = Choice.get <| dest_comb tm2
               unify vars l1 l2 (unify vars r1 r2 sofar)
  +
       fun vars tm1 tm2 -> 
  -        Choice.attempt (fun () -> [], unify vars tm1 tm2 [], [])
  +        Choice.attempt <| fun () ->
  +            [], unify vars tm1 tm2 [], []
   
   (* ------------------------------------------------------------------------- *)
   (* Modify bound variable names at depth. (Not very efficient...)             *)
  
positive.code: 
      fun (bcs, tmin, tyin) th -> 
          let ith = 
              if tyin = []
              then th
              else INST_TYPE tyin th
          if tmin = []
          then ith
          else
              choice { 
                  let tth = INST tmin ith
  
negative.code:                             (insts, (env, lc, lv) :: (tl homs))
                      let tyins' = get_type_insts (fst pinsts_homs') []
                      term_homatch lconsts tyins' pinsts_homs'
      fun lconsts vtm ctm ->
          Choice.attempt <| fun () ->
              let pinsts_homs = term_pmatch lconsts [] vtm ctm ([], [])
              let tyins = get_type_insts (fst pinsts_homs) []
              let insts = term_homatch lconsts tyins pinsts_homs
              separate_insts insts
  
  (* ------------------------------------------------------------------------- *)
  (* First order unification (no type instantiation -- yet).                   *)
  (* ------------------------------------------------------------------------- *)
  
  /// Unify two terms.
  let term_unify : term list -> term -> term -> Choice<_, exn> = 
      let augment1 sofar (s, x) = 
          let s' = Choice.get <| subst sofar s
          if vfree_in x s && not(s = x) then
              failwith "augment_insts"
          else (s', x)
  
      let raw_augment_insts p insts =
          p :: (map (augment1 [p]) insts)
  
      let augment_insts (t, v) insts =
          let t' = Choice.get <| vsubst insts t
          if t' = v then insts
          elif vfree_in v t' then
              failwith "augment_insts"
          else raw_augment_insts (t', v) insts
  
      let rec unify vars tm1 tm2 sofar = 
          if tm1 = tm2 then sofar
          elif is_var tm1 && mem tm1 vars then
              match rev_assoc tm1 sofar with
              | Some tm1' ->
                  unify vars tm1' tm2 sofar
              | None ->
                  augment_insts (tm2, tm1) sofar
          elif is_var tm2 && mem tm2 vars then
              match rev_assoc tm2 sofar with
              | Some tm2' ->
                  unify vars tm1 tm2' sofar
              | None ->
                  augment_insts (tm1, tm2) sofar
          elif is_abs tm1 then 
              let tm1' = Choice.get <| body tm1
              let tm2' = Choice.get <| subst [Choice.get <| bndvar tm1, Choice.get <| bndvar tm2] (Choice.get <| body tm2)
              unify vars tm1' tm2' sofar
  