anchor.diff:          }
           |> Choice.mapError (fun e -> nestedFailure e "MATCH_MP: Not an implication")
   
  -    let match_fun = PART_MATCH (Choice.map fst << dest_imp) sth
  +    let match_fun : term -> thm =
  +        PART_MATCH (Choice.map fst << dest_imp) sth
  +
       fun (th : thm) ->
  -        // TODO : The Choice.attemptNested "wrapper" can be removed once match_fun is safe to use.
  -        Choice.attemptNested <| fun () ->
  -            MP (match_fun(concl <| Choice.get th)) th
  -            |> Choice.mapError (fun e -> nestedFailure e "MATCH_MP: No match")
  +        choice {
  +        let! th' = th
  +        // CLEAN : Rename this value to something reasonable.
  +        let! foo1 = match_fun <| concl th'
  +        return! MP (Choice.result foo1) th
  +        }
  +        |> Choice.mapError (fun e -> nestedFailure e "MATCH_MP: No match")
   
   (* ------------------------------------------------------------------------- *)
   (* Useful instance of more general higher order matching.                    *)
  
positive.code: (* ------------------------------------------------------------------------- *)
  
  /// Modify bound variable according to renaming scheme.
  let deep_alpha = 
      let tryalpha v tm = 
          try 
              Choice.get <| alpha v tm
          with
          | Failure _ -> 
              try 
                  let v' = Choice.get <| variant (frees tm) v
                  Choice.get <| alpha v' tm
              with
              | Failure _ -> tm
      let rec deep_alpha env tm = 
          if env = []
          then tm
          else 
              try 
                  let v, bod = Choice.get <| dest_abs tm
                  let vn, vty = Choice.get <| dest_var v
                  try 
                      let (vn', _), newenv = Option.get <| remove (fun (_, x) -> x = vn) env
                      let v' = mk_var(vn', vty)
                      let tm' = tryalpha v' tm
                      let iv, ib = Choice.get <| dest_abs tm'
                      Choice.get <| mk_abs(iv, deep_alpha newenv ib)
                  with
                  | Failure _ -> Choice.get <| mk_abs(v, deep_alpha env bod)
              with
              | Failure _ -> 
                  try 
                      let l, r = Choice.get <| dest_comb tm
                      Choice.get <| mk_comb(deep_alpha env l, deep_alpha env r)
                  with
                  | Failure _ -> tm
      deep_alpha
  
  (* ------------------------------------------------------------------------- *)
  (* Instantiate theorem by matching part of it to a term.                     *)
  
negative.code:     choice {
          let! l, r = Choice.bind (dest_imp << concl) th
          let ath = cnv l
          return!
              MP th (EQT_ELIM ath)
              |> Choice.bindError (fun _ -> MP th ath)
      }    
  
  (* ------------------------------------------------------------------------- *)
  