anchor.diff:      let c_tm = (parse_term @"c:bool")
   
       let rec distribute tm = 
  -        match tm with
  -        | Comb(Comb(Const("/\\", _), a), Comb(Comb(Const("\\/", _), b), c)) -> 
  -            let th = 
  -                INST [a, a_tm
  -                      b, b_tm
  -                      c, c_tm] pth1
  -            TRANS th (BINOP_CONV distribute (Choice.get <| rand(concl <| Choice.get th)))
  -        | Comb(Comb(Const("/\\", _), Comb(Comb(Const("\\/", _), a), b)), c) -> 
  -            let th = INST [a, a_tm; b, b_tm; c, c_tm] pth2
  -            TRANS th (BINOP_CONV distribute (Choice.get <| rand(concl <| Choice.get th)))
  -        | _ -> REFL tm
  +        choice {
  +            match tm with
  +            | Comb(Comb(Const("/\\", _), a), Comb(Comb(Const("\\/", _), b), c)) -> 
  +                let th = INST [a, a_tm; b, b_tm; c, c_tm] pth1
  +                let! tm1 = Choice.bind (rand << concl) th
  +                return! TRANS th (BINOP_CONV distribute tm1)
  +            | Comb(Comb(Const("/\\", _), Comb(Comb(Const("\\/", _), a), b)), c) -> 
  +                let th = INST [a, a_tm; b, b_tm; c, c_tm] pth2
  +                let! tm1 = Choice.bind (rand << concl) th
  +                return! TRANS th (BINOP_CONV distribute tm1)
  +            | _ -> 
  +                return! REFL tm
  +        }
   
       let strengthen = DEPTH_BINOP_CONV (parse_term @"(\/)") CONJ_CANON_CONV
                        |> THENC <| DISJ_CANON_CONV
   
       let rec weakdnf tm = 
  -        match tm with
  -        | Comb(Const("!", _), Abs(_, _)) | Comb(Const("?", _), Abs(_, _)) -> 
  -            BINDER_CONV weakdnf tm
  -        | Comb(Comb(Const("\\/", _), _), _) -> BINOP_CONV weakdnf tm
  -        | Comb(Comb(Const("/\\", _) as op, l), r) -> 
  -            let th = MK_COMB(AP_TERM op (weakdnf l), weakdnf r)
  -            TRANS th (distribute(Choice.get <| rand(concl <| Choice.get th)))
  -        | _ -> REFL tm
  +        choice {
  +            match tm with
  +            | Comb(Const("!", _), Abs(_, _)) | Comb(Const("?", _), Abs(_, _)) -> 
  +                return! BINDER_CONV weakdnf tm
  +            | Comb(Comb(Const("\\/", _), _), _) -> 
  +                return! BINOP_CONV weakdnf tm
  +            | Comb(Comb(Const("/\\", _) as op, l), r) -> 
  +                let th = MK_COMB(AP_TERM op (weakdnf l), weakdnf r)
  +                let th1 = (Choice.bind distribute << Choice.bind rand << Choice.map concl) th
  +                return! TRANS th th1
  +            | _ -> 
  +                return! REFL tm
  +        }
   
       and substrongdnf tm = 
  -        match tm with
  -        | Comb(Const("!", _), Abs(_, _)) | Comb(Const("?", _), Abs(_, _)) -> 
  -            BINDER_CONV strongdnf tm
  -        | Comb(Comb(Const("\\/", _), _), _) -> BINOP_CONV substrongdnf tm
  -        | Comb(Comb(Const("/\\", _) as op, l), r) -> 
  -            let th = MK_COMB(AP_TERM op (substrongdnf l), substrongdnf r)
  -            TRANS th (distribute(Choice.get <| rand(concl <| Choice.get th)))
  -        | _ -> REFL tm
  +        choice {
  +            match tm with
  +            | Comb(Const("!", _), Abs(_, _)) | Comb(Const("?", _), Abs(_, _)) -> 
  +                return! BINDER_CONV strongdnf tm
  +            | Comb(Comb(Const("\\/", _), _), _) -> 
  +                return! BINOP_CONV substrongdnf tm
  +            | Comb(Comb(Const("/\\", _) as op, l), r) -> 
  +                let th = MK_COMB(AP_TERM op (substrongdnf l), substrongdnf r)
  +                return! TRANS th (distribute(Choice.get <| rand(concl <| Choice.get th)))
  +            | _ -> 
  +                return! REFL tm
  +        }
   
       and strongdnf tm = 
  -        let th = substrongdnf tm
  -        TRANS th (strengthen(Choice.get <| rand(concl <| Choice.get th)))
  +        choice {
  +            let th = substrongdnf tm
  +            let! tm1 = Choice.bind (rand << concl) th
  +            return! TRANS th (strengthen tm1)
  +        }
   
       weakdnf, strongdnf
   
  
positive.code:     let rec find_conditional fvs tm = 
          match tm with
          | Comb(s, t) -> 
              if is_cond tm && intersect (frees(Choice.get <| lhand s)) fvs = []
              then tm
              else 
                  (try 
                       (find_conditional fvs s)
  
negative.code:             let ptm = (parse_term @"P:A->bool")
              fun tm -> 
                  let stm, atm = Choice.get <| dest_comb tm
                  if is_const stm && fst(Choice.get <| dest_const stm) = "@" then 
                      CONV_RULE (LAND_CONV BETA_CONV) (PINST [Choice.get <| type_of(Choice.get <| bndvar atm), aty] [atm, ptm] pth)
                  else failwith "SELECT_ELIM_THM: not a select-term"
          fun tm -> 
              PURE_REWRITE_CONV (map SELECT_ELIM_THM (Choice.get <| find_terms is_select tm)) tm
  